Nektar++
|
Public Member Functions | |
def | __init__ (self, model, force=False) |
def | add_all_info (self) |
def | add_dt_reference (self) |
def | add_transmembrane_potential_name (self) |
def | add_linearised_odes (self) |
def | add_jacobian_matrix (self) |
def | use_canonical_variable_names (self) |
def | add_membrane_ionic_current (self) |
def | add_linear_ode_update_equations (self) |
def | add_variable_links (self) |
def | do_binding_time_analysis (self) |
def | has_modifiable_mathematics (self) |
def | get_modifiable_mathematics (self) |
def | get_linearised_odes (self) |
def | create_dt (self, modifier, comp, units) |
def | get_dt (self) |
Private Member Functions | |
def | _fix_jac_var_name (self, vname) |
def | _check_state_var_units_conversions (self) |
def | _process_mathematics (self, func) |
def | _add_variable_links (self, elt) |
def | _get_variable (self, varname) |
def | _get_special_variable (self, varname, ptype=VarTypes.Unknown) |
def | _get_special_component (self) |
Private Attributes | |
_model | |
_solver_info | |
_component | |
_dt | |
Static Private Attributes | |
_jac_temp_re = re.compile(r't[0-9]+') | |
Add information for specialised translator classes into a model.
Definition at line 1359 of file translators.py.
def CellMLToNektar.translators.SolverInfo.__init__ | ( | self, | |
model, | |||
force = False |
|||
) |
Add information for the solvers as XML. The Jacobian and linearity analyses store their results in Python data structures as attributes of this object. Transcribe these into XML in a child <solver_info> element. If any of these elements exist in the model they will be left unaltered, unless force is set to True. This constructor just sets up the container element; call one of the add_* methods to actually add the information to it.
Definition at line 1361 of file translators.py.
|
private |
Recursively link ci elements in the given XML tree to cellml_variable objects. Also sets component links: for ci elements, to the component containing the linked variable, and for cn elements, to the first component in the model.
Definition at line 1743 of file translators.py.
References CellMLToNektar.translators.SolverInfo._add_variable_links(), and CellMLToNektar.translators.SolverInfo._get_variable().
Referenced by CellMLToNektar.translators.SolverInfo._add_variable_links(), CellMLToNektar.translators.SolverInfo.add_linear_ode_update_equations(), and CellMLToNektar.translators.SolverInfo.add_variable_links().
|
private |
Check if any Jacobian entries need to be altered because the units of state variables have changed. If any variable considered a state variable by the Jacobian is now of type Computed then it has been converted. We figure out the conversion factor, update the Jacobian to reference the new state variable, and units-convert the derivative.
Definition at line 1604 of file translators.py.
References CellMLToNektar.translators.SolverInfo._get_variable(), and CellMLToNektar.translators.SolverInfo._solver_info.
Referenced by CellMLToNektar.translators.SolverInfo.add_variable_links().
|
private |
If PE will be performed on a model with a single component, then we'll need full names in the variable attributes.
Definition at line 1458 of file translators.py.
References CellMLToNektar.translators.SolverInfo._model.
Referenced by CellMLToNektar.translators.SolverInfo.add_jacobian_matrix().
|
private |
Get or create a special component for containing special variables.
Definition at line 1798 of file translators.py.
References CellMLToNektar.translators.SolverInfo._component, and CellMLToNektar.translators.SolverInfo._model.
Referenced by CellMLToNektar.translators.SolverInfo._get_special_variable(), CellMLToNektar.translators.SolverInfo.add_jacobian_matrix(), and CellMLToNektar.translators.SolverInfo.add_linearised_odes().
|
private |
Get or create a special variable object that doesn't really exist in the model.
Definition at line 1787 of file translators.py.
References CellMLToNektar.translators.SolverInfo._get_special_component(), and CellMLToNektar.translators.SolverInfo._model.
Referenced by CellMLToNektar.translators.SolverInfo._get_variable(), and CellMLToNektar.translators.SolverInfo.get_dt().
|
private |
Return the variable in the model with name varname.
Definition at line 1761 of file translators.py.
References CellMLToNektar.translators.SolverInfo._get_special_variable(), CellMLToNektar.translators.SolverInfo._jac_temp_re, CellMLToNektar.translators.SolverInfo._model, and CellMLToNektar.translators.SolverInfo.get_dt().
Referenced by CellMLToNektar.translators.SolverInfo._add_variable_links(), CellMLToNektar.translators.SolverInfo._check_state_var_units_conversions(), and CellMLToNektar.translators.SolverInfo.use_canonical_variable_names().
|
private |
Apply func to each top-level mathematical construct in the solver info blocks. func must be able to accept mathml_piecewise, mathml_apply, mathml_ci and mathml_cn elements.
Definition at line 1671 of file translators.py.
References CellMLToNektar.translators.SolverInfo._solver_info.
Referenced by CellMLToNektar.translators.SolverInfo.add_variable_links(), and CellMLToNektar.translators.SolverInfo.do_binding_time_analysis().
def CellMLToNektar.translators.SolverInfo.add_all_info | ( | self | ) |
Actually add the info.
Definition at line 1386 of file translators.py.
References CellMLToNektar.translators.SolverInfo.add_dt_reference(), CellMLToNektar.translators.SolverInfo.add_jacobian_matrix(), CellMLToNektar.translators.SolverInfo.add_linearised_odes(), CellMLToNektar.translators.SolverInfo.add_membrane_ionic_current(), and CellMLToNektar.translators.SolverInfo.add_transmembrane_potential_name().
def CellMLToNektar.translators.SolverInfo.add_dt_reference | ( | self | ) |
Add a reference to the variable representing dt.
Definition at line 1394 of file translators.py.
References CellMLToNektar.translators.SolverInfo._model, CellMLToNektar.translators.SolverInfo._solver_info, and CellMLToNektar.translators.SolverInfo.get_dt().
Referenced by CellMLToNektar.translators.SolverInfo.add_all_info().
def CellMLToNektar.translators.SolverInfo.add_jacobian_matrix | ( | self | ) |
Jacobian matrix elements. Structure looks like: <jacobian> [<math> assignments of common sub-terms </math>] <entry var_i='varname' var_j='varname'> <math> apply|cn|ci ...</math> </entry> </jacobian>
Definition at line 1469 of file translators.py.
References CellMLToNektar.translators.SolverInfo._fix_jac_var_name(), CellMLToNektar.translators.SolverInfo._get_special_component(), CellMLToNektar.translators.SolverInfo._model, CellMLToNektar.translators.SolverInfo._solver_info, and CellMLToNektar.pycml.amara_parse_cellml().
Referenced by CellMLToNektar.translators.SolverInfo.add_all_info().
def CellMLToNektar.translators.SolverInfo.add_linear_ode_update_equations | ( | self | ) |
Add the update equations for the linear ODEs. A linear ODE has the form du/dt = g+h.u where g & h are not functions of u. The update expression then looks like u = (u + g.dt)/(1 - h.dt). This replaces the linear_odes block with the structure: <linear_odes> <math> <ci>u</ci> <ci>t</ci> <apply> <!-- (u + g.dt)/(1 - h.dt) --> </apply> </math> . . . </linear_odes>
Definition at line 1547 of file translators.py.
References CellMLToNektar.translators.SolverInfo._add_variable_links(), CellMLToNektar.translators.SolverInfo._model, CellMLToNektar.translators.SolverInfo._solver_info, and CellMLToNektar.translators.SolverInfo.get_linearised_odes().
def CellMLToNektar.translators.SolverInfo.add_linearised_odes | ( | self | ) |
Linearised ODEs - where du/dt = g + hu (and g, h are not functions of u). Structure looks like: <linear_odes> <math> <apply><eq/> <apply><diff/> <bvar><ci>t</ci></bvar> <ci>u</ci> </apply> <apply><plus/> g <apply><times/> h <ci>u</ci> </apply> </apply> </apply> . . . </math> </linear_odes>
Definition at line 1414 of file translators.py.
References CellMLToNektar.translators.SolverInfo._get_special_component(), CellMLToNektar.translators.SolverInfo._model, and CellMLToNektar.translators.SolverInfo._solver_info.
Referenced by CellMLToNektar.translators.SolverInfo.add_all_info().
def CellMLToNektar.translators.SolverInfo.add_membrane_ionic_current | ( | self | ) |
Add ionic current information as XML for solvers to use.
Definition at line 1530 of file translators.py.
References CellMLToNektar.translators.SolverInfo._model, and CellMLToNektar.translators.SolverInfo._solver_info.
Referenced by CellMLToNektar.translators.SolverInfo.add_all_info().
def CellMLToNektar.translators.SolverInfo.add_transmembrane_potential_name | ( | self | ) |
The name of the transmembrane potential.
Definition at line 1404 of file translators.py.
References CellMLToNektar.translators.SolverInfo._model, and CellMLToNektar.translators.SolverInfo._solver_info.
Referenced by CellMLToNektar.translators.SolverInfo.add_all_info().
def CellMLToNektar.translators.SolverInfo.add_variable_links | ( | self | ) |
Link ci elements in the added XML to cellml_variable objects. This analyses the names in the ci elements to determine which variable in the model they refer to.
Definition at line 1586 of file translators.py.
References CellMLToNektar.translators.SolverInfo._add_variable_links(), CellMLToNektar.translators.SolverInfo._check_state_var_units_conversions(), CellMLToNektar.translators.SolverInfo._model, CellMLToNektar.translators.SolverInfo._process_mathematics(), and CellMLToNektar.translators.SolverInfo._solver_info.
Referenced by CellMLToNektar.translators.SolverInfo.do_binding_time_analysis().
def CellMLToNektar.translators.SolverInfo.create_dt | ( | self, | |
modifier, | |||
comp, | |||
units | |||
) |
Create the special 'dt' variable in the given component.
Definition at line 1775 of file translators.py.
References CellMLToNektar.translators.SolverInfo._dt.
def CellMLToNektar.translators.SolverInfo.do_binding_time_analysis | ( | self | ) |
Do a binding time analysis on the additional mathematics. This requires self.add_variable_links to have been called already.
Definition at line 1664 of file translators.py.
References CellMLToNektar.translators.SolverInfo._process_mathematics(), and CellMLToNektar.translators.SolverInfo.add_variable_links().
def CellMLToNektar.translators.SolverInfo.get_dt | ( | self | ) |
Get or create a special 'dt' variable.
Definition at line 1781 of file translators.py.
References CellMLToNektar.translators.SolverInfo._dt, and CellMLToNektar.translators.SolverInfo._get_special_variable().
Referenced by CellMLToNektar.translators.SolverInfo._get_variable(), and CellMLToNektar.translators.SolverInfo.add_dt_reference().
def CellMLToNektar.translators.SolverInfo.get_linearised_odes | ( | self | ) |
Return an iterable over the linearised ODEs, i.e. ODEs of the form du/dt = g + hu (with g, h not functions of u). Yields tuples (u, t, eqns) where the form of eqns depends on whether add_linear_ode_update_equations has been called. If so, it is a 1-tuple containing the update equation; if not, it is (g,h).
Definition at line 1719 of file translators.py.
References CellMLToNektar.translators.SolverInfo._solver_info.
Referenced by CellMLToNektar.translators.SolverInfo.add_linear_ode_update_equations(), and CellMLToNektar.translators.SolverInfo.get_modifiable_mathematics().
def CellMLToNektar.translators.SolverInfo.get_modifiable_mathematics | ( | self | ) |
Get an iterable over mathematical constructs in the solver info blocks that can be changed. Returned elements will be mathml_piecewise, mathml_apply, mathml_ci or mathml_cn instances.
Definition at line 1699 of file translators.py.
References CellMLToNektar.translators.SolverInfo._solver_info, and CellMLToNektar.translators.SolverInfo.get_linearised_odes().
Referenced by CellMLToNektar.translators.SolverInfo.has_modifiable_mathematics().
def CellMLToNektar.translators.SolverInfo.has_modifiable_mathematics | ( | self | ) |
Check if the solver info blocks contain any modifiable mathematics.
Definition at line 1691 of file translators.py.
References CellMLToNektar.translators.SolverInfo.get_modifiable_mathematics().
def CellMLToNektar.translators.SolverInfo.use_canonical_variable_names | ( | self | ) |
PE has just been performed, so we need to update variable names occurring outside the modifiable mathematics sections.
Definition at line 1511 of file translators.py.
References CellMLToNektar.translators.SolverInfo._get_variable(), and CellMLToNektar.translators.SolverInfo._solver_info.
|
private |
Definition at line 1383 of file translators.py.
Referenced by CellMLToNektar.translators.SolverInfo._get_special_component().
|
private |
Definition at line 1384 of file translators.py.
Referenced by CellMLToNektar.translators.SolverInfo.create_dt(), and CellMLToNektar.translators.SolverInfo.get_dt().
|
staticprivate |
Definition at line 1760 of file translators.py.
Referenced by CellMLToNektar.translators.SolverInfo._get_variable().
|
private |
Definition at line 1374 of file translators.py.
Referenced by CellMLToNektar.translators.SolverInfo._fix_jac_var_name(), CellMLToNektar.translators.SolverInfo._get_special_component(), CellMLToNektar.translators.SolverInfo._get_special_variable(), CellMLToNektar.translators.SolverInfo._get_variable(), CellMLToNektar.translators.SolverInfo.add_dt_reference(), CellMLToNektar.translators.SolverInfo.add_jacobian_matrix(), CellMLToNektar.translators.SolverInfo.add_linear_ode_update_equations(), CellMLToNektar.translators.SolverInfo.add_linearised_odes(), CellMLToNektar.translators.SolverInfo.add_membrane_ionic_current(), CellMLToNektar.translators.SolverInfo.add_transmembrane_potential_name(), and CellMLToNektar.translators.SolverInfo.add_variable_links().
|
private |
Definition at line 1382 of file translators.py.
Referenced by CellMLToNektar.translators.SolverInfo._check_state_var_units_conversions(), CellMLToNektar.translators.SolverInfo._process_mathematics(), CellMLToNektar.translators.SolverInfo.add_dt_reference(), CellMLToNektar.translators.SolverInfo.add_jacobian_matrix(), CellMLToNektar.translators.SolverInfo.add_linear_ode_update_equations(), CellMLToNektar.translators.SolverInfo.add_linearised_odes(), CellMLToNektar.translators.SolverInfo.add_membrane_ionic_current(), CellMLToNektar.translators.SolverInfo.add_transmembrane_potential_name(), CellMLToNektar.translators.SolverInfo.add_variable_links(), CellMLToNektar.translators.SolverInfo.get_linearised_odes(), CellMLToNektar.translators.SolverInfo.get_modifiable_mathematics(), and CellMLToNektar.translators.SolverInfo.use_canonical_variable_names().