Nektar++
|
Classes | |
class | OPS |
Public Member Functions | |
def | __init__ |
def | clear_dependency_info |
def | get_dependencies |
def | operator |
def | qualifiers |
def | operands |
def | evaluate |
def | tree_complexity |
def | get_units |
def | check_assigned_var |
def | classify_variables |
def | is_top_level |
def | is_ode |
def | is_assignment |
def | assigned_variable |
Public Member Functions inherited from CellMLToNektar.utilities.Colourable | |
def | __init__ |
def | set_colour |
def | get_colour |
def | clear_colour |
Public Member Functions inherited from CellMLToNektar.pycml.mathml_constructor | |
def | __init__ |
Public Member Functions inherited from CellMLToNektar.pycml.mathml | |
def | __init__ |
def | __repr__ |
def | __deepcopy__ |
def | clone_self |
def | get_original_of_clone |
def | get_component |
def | model |
def | eval |
Public Member Functions inherited from CellMLToNektar.pycml.element_base | |
def | __init__ |
def | __delattr__ |
def | __setattr__ |
def | rootNode |
def | cmeta_id |
def | xml_remove_child_at |
def | xml_doc |
def | xml_properties |
Static Public Member Functions | |
def | create_new |
Static Public Member Functions inherited from CellMLToNektar.pycml.mathml | |
def | clone |
Static Public Attributes | |
tuple | QUALIFIERS |
Private Member Functions | |
def | _is_qualifier |
def | _get_operand_units |
def | _set_in_units |
def | _get_binding_time |
def | _reduce |
Private Attributes | |
_cml_units | |
_cml_binding_time | |
_cml_depends_on | |
_cml_assigns_to | |
_cml_ode_has_free_var_on_rhs | |
Additional Inherited Members | |
Public Attributes inherited from CellMLToNektar.pycml.element_base | |
xml_attributes | |
Properties inherited from CellMLToNektar.pycml.mathml | |
component = property(get_component) | |
def CellMLToNektar.pycml.mathml_apply.__init__ | ( | self | ) |
|
private |
Return the binding time of this expression. The binding time will be computed recursively and cached. It will also be made available as an attribute in the XML. It is computed by taking the least upper bound of the binding times of our operands, unless the operator possesses an alternative method.
Definition at line 4934 of file pycml.py.
References CellMLToNektar.pycml.cellml_variable._cml_binding_time, CellMLToNektar.pycml.mathml_apply._cml_binding_time, CellMLToNektar.pycml.mathml_constructor._get_element_binding_time(), CellMLToNektar.optimize.ExpressionMatcher.A.operands, CellMLToNektar.pycml.mathml_apply.operands(), CellMLToNektar.optimize.ExpressionMatcher.A.operator, and CellMLToNektar.pycml.mathml_apply.operator().
Referenced by CellMLToNektar.pycml.mathml_apply._reduce(), and CellMLToNektar.pycml.mathml_piecewise._reduce().
|
private |
Return an iterable containing a <units> element for each operand of this expression.
Definition at line 4439 of file pycml.py.
References CellMLToNektar.pycml.mathml_constructor._get_element_units(), CellMLToNektar.optimize.ExpressionMatcher.A.operands, and CellMLToNektar.pycml.mathml_apply.operands().
Referenced by CellMLToNektar.pycml.mathml_apply.get_units().
|
private |
Return True iff element is a qualifier element.
Definition at line 4416 of file pycml.py.
References CellMLToNektar.pycml.mathml_apply.QUALIFIERS.
Referenced by CellMLToNektar.pycml.mathml_apply.operands(), and CellMLToNektar.pycml.mathml_apply.qualifiers().
|
private |
Reduce this expression by evaluating its static parts.
Definition at line 4968 of file pycml.py.
References CellMLToNektar.pycml.mathml_constructor._eval_self(), CellMLToNektar.pycml.cellml_variable._get_binding_time(), CellMLToNektar.pycml.mathml_cn._get_binding_time(), CellMLToNektar.pycml.mathml_ci._get_binding_time(), CellMLToNektar.pycml.mathml_apply._get_binding_time(), CellMLToNektar.pycml.mathml_constructor._reduce_elt(), CellMLToNektar.pycml.mathml_constructor._update_usage_counts(), CellMLToNektar.utilities.DEBUG(), CellMLToNektar.optimize.ExpressionMatcher.A.operands, CellMLToNektar.pycml.mathml_apply.operands(), CellMLToNektar.optimize.ExpressionMatcher.A.operator, and CellMLToNektar.pycml.mathml_apply.operator().
|
private |
Set the units this expression should be given in. If these aren't our natural units (as given by an initial get_units) then we need to add units conversion code.
Definition at line 4523 of file pycml.py.
References CellMLToNektar.pycml.cellml_model._cml_units, CellMLToNektar.pycml.cellml_component._cml_units, CellMLToNektar.pycml.mathml_units_mixin_tokens._cml_units, CellMLToNektar.pycml.mathml_units_mixin_container._cml_units, CellMLToNektar.pycml.mathml_cn._cml_units, CellMLToNektar.pycml.mathml_ci._cml_units, CellMLToNektar.pycml.mathml_apply._cml_units, CellMLToNektar.pycml.mathml_units_mixin._set_element_in_units(), CellMLToNektar.pycml.cellml_variable.get_units(), CellMLToNektar.pycml.mathml_cn.get_units(), CellMLToNektar.pycml.mathml_ci.get_units(), CellMLToNektar.pycml.mathml_apply.get_units(), CellMLToNektar.optimize.ExpressionMatcher.A.operator, and CellMLToNektar.pycml.mathml_apply.operator().
def CellMLToNektar.pycml.mathml_apply.assigned_variable | ( | self | ) |
Return the variable assigned to by this assignment. Should only be called on a top-level assignment expression. If it's a straightforward assignment (so self.is_assignment() returns True) then return the cellml_variable object representing the variable assigned to. If it's an ODE, return a pair (dependent variable, independent variable).
Definition at line 4917 of file pycml.py.
References CellMLToNektar.pycml.mathml_apply._cml_assigns_to, and CellMLToNektar.pycml.mathml_apply.is_top_level().
def CellMLToNektar.pycml.mathml_apply.check_assigned_var | ( | self | ) |
Check the current component owns the variable being assigned to. Should only be called if this object represents an assignment expression. Checks that the variable being assigned to doesn't have an interface value of 'in'. If this isn't a simple assignment (i.e. the LHS isn't a plain ci element) then the check succeeds automatically. Adds to the model's error list if the check fails. This method always returns None.
Definition at line 4758 of file pycml.py.
References CellMLToNektar.pycml.mathml_apply.classify_variables(), CellMLToNektar.optimize.ExpressionMatcher.A.operands, CellMLToNektar.pycml.mathml_apply.operands(), CellMLToNektar.optimize.ExpressionMatcher.A.operator, and CellMLToNektar.pycml.mathml_apply.operator().
def CellMLToNektar.pycml.mathml_apply.classify_variables | ( | self, | |
root = False , |
|||
dependencies_only = False , |
|||
needs_special_treatment = lambda n: None |
|||
) |
Classify variables in this expression according to how they are used. In the process, compute and return a set of variables on which this expression depends. If root is True, store this set as a list, to represent edges of a dependency graph. Also, if root is True then this node is the root of an expression (so it will be an application of eq); treat the LHS differently. If dependencies_only then the variable classification will not be done, only dependencies will be analysed. This is useful for doing a 'light' re-analysis if the dependency set has been reduced; if the set has increased then the topological sort of equations may need to be redone. The function needs_special_treatment may be supplied to override the default recursion into sub-trees. It takes a single sub-tree as argument, and should either return the dependency set for that sub-tree, or None to use the default recursion. This is used when re-analysing dependencies after applying lookup tables, since table lookups only depend on the keying variable.
Definition at line 4786 of file pycml.py.
References CellMLToNektar.pycml.mathml_apply._cml_assigns_to, CellMLToNektar.optimize.ExpressionMatcher.A.operands, CellMLToNektar.pycml.mathml_apply.operands(), CellMLToNektar.optimize.ExpressionMatcher.A.operator, and CellMLToNektar.pycml.mathml_apply.operator().
Referenced by CellMLToNektar.pycml.mathml_apply.check_assigned_var().
def CellMLToNektar.pycml.mathml_apply.clear_dependency_info | ( | self | ) |
Clear the type, dependency, etc. information for this equation. This allows us to re-run the type & dependency analysis for the model.
Definition at line 4398 of file pycml.py.
|
static |
Create a new MathML apply element, with given content. elt should be any element in the document. operator is used as the name of the first, empty, child. operands is a list, possibly empty, of operand elements. If any member is a unicode object, it is considered to be the name of a variable. If a tuple, then it should be a pair of unicode objects: (number, units). (Although units can be an attribute dictionary.) qualifiers specifies a list of qualifier elements.
Definition at line 4992 of file pycml.py.
References CellMLToNektar.pycml.check_append_safety().
def CellMLToNektar.pycml.mathml_apply.evaluate | ( | self | ) |
Evaluate this expression, and return its value, if possible.
Definition at line 4447 of file pycml.py.
References CellMLToNektar.optimize.ExpressionMatcher.A.operator, and CellMLToNektar.pycml.mathml_apply.operator().
Referenced by CellMLToNektar.pycml.mathml_constructor._eval_self().
def CellMLToNektar.pycml.mathml_apply.get_dependencies | ( | self | ) |
Return the list of variables this expression depends on.
Definition at line 4408 of file pycml.py.
References CellMLToNektar.pycml.cellml_variable._cml_depends_on, and CellMLToNektar.pycml.mathml_apply._cml_depends_on.
def CellMLToNektar.pycml.mathml_apply.get_units | ( | self | ) |
Recursively check this expression for dimensional consistency. Checks that the operands have suitable units. What constitutes 'suitable' depends on the operator; see appendix C.3.2 of the CellML 1.0 spec. If yes, returns a <units> element for the whole expression, based on the rules in appendix C.3.3. Throws a UnitsError if the units are inconsistent.
Definition at line 4556 of file pycml.py.
References CellMLToNektar.pycml._child1(), CellMLToNektar.pycml.cellml_model._cml_units, CellMLToNektar.pycml.cellml_component._cml_units, CellMLToNektar.pycml.mathml_units_mixin_tokens._cml_units, CellMLToNektar.pycml.mathml_units_mixin_container._cml_units, CellMLToNektar.pycml.mathml_cn._cml_units, CellMLToNektar.pycml.mathml_ci._cml_units, CellMLToNektar.pycml.mathml_apply._cml_units, CellMLToNektar.pycml.mathml_constructor._get_element_binding_time(), CellMLToNektar.pycml.mathml_constructor._get_element_units(), CellMLToNektar.pycml.mathml_apply._get_operand_units(), CellMLToNektar.pycml.copy(), CellMLToNektar.pycml.mathml.eval(), CellMLToNektar.processors.ModelModifier.model, CellMLToNektar.translators.CellMLTranslator.model, CellMLToNektar.pycml.cellml_variable.model(), CellMLToNektar.pycml.mathml.model(), CellMLToNektar.optimize.ExpressionMatcher.A.operands, CellMLToNektar.pycml.mathml_apply.operands(), CellMLToNektar.optimize.ExpressionMatcher.A.operator, and CellMLToNektar.pycml.mathml_apply.operator().
Referenced by CellMLToNektar.pycml.mathml._ensure_units_exist(), CellMLToNektar.pycml.mathml_units_mixin_tokens._set_in_units(), and CellMLToNektar.pycml.mathml_apply._set_in_units().
def CellMLToNektar.pycml.mathml_apply.is_assignment | ( | self | ) |
Return True iff this is a straightforward assignment expression. Only makes sense if called on a top-level assignment expression. Checks that this is *not* an ODE, but assigns to a single variable.
Definition at line 4907 of file pycml.py.
References CellMLToNektar.pycml.mathml_apply._cml_assigns_to, and CellMLToNektar.pycml.mathml_apply.is_top_level().
def CellMLToNektar.pycml.mathml_apply.is_ode | ( | self | ) |
Return True iff this is the assignment of an ODE. Only makes sense if called on a top-level assignment expression, and checks if it represents an ODE, i.e. if the LHS is a derivative.
Definition at line 4896 of file pycml.py.
References CellMLToNektar.pycml.mathml_apply._cml_assigns_to, and CellMLToNektar.pycml.mathml_apply.is_top_level().
def CellMLToNektar.pycml.mathml_apply.is_top_level | ( | self | ) |
Test whether this is a top-level assignment expression.
Definition at line 4892 of file pycml.py.
References CellMLToNektar.pycml.mathml_apply._cml_assigns_to.
Referenced by CellMLToNektar.pycml.mathml_apply.assigned_variable(), CellMLToNektar.pycml.mathml_apply.is_assignment(), and CellMLToNektar.pycml.mathml_apply.is_ode().
def CellMLToNektar.pycml.mathml_apply.operands | ( | self | ) |
Return an iterable over the elements representing the operands for this application.
Definition at line 4428 of file pycml.py.
References CellMLToNektar.pycml.mathml_apply._is_qualifier().
Referenced by CellMLToNektar.pycml.mathml_apply._get_binding_time(), CellMLToNektar.pycml.mathml_apply._get_operand_units(), CellMLToNektar.pycml.mathml_apply._reduce(), CellMLToNektar.pycml.mathml_apply.check_assigned_var(), CellMLToNektar.pycml.mathml_apply.classify_variables(), CellMLToNektar.pycml.mathml_apply.get_units(), and CellMLToNektar.pycml.mathml_apply.tree_complexity().
def CellMLToNektar.pycml.mathml_apply.operator | ( | self | ) |
Return the element representing the operator being applied.
Definition at line 4412 of file pycml.py.
References CellMLToNektar.pycml._child1().
Referenced by CellMLToNektar.pycml.mathml_apply._get_binding_time(), CellMLToNektar.pycml.mathml_apply._reduce(), CellMLToNektar.pycml.mathml_apply._set_in_units(), CellMLToNektar.pycml.mathml_apply.check_assigned_var(), CellMLToNektar.pycml.mathml_apply.classify_variables(), CellMLToNektar.pycml.mathml_apply.evaluate(), CellMLToNektar.pycml.mathml_apply.get_units(), and CellMLToNektar.pycml.mathml_apply.tree_complexity().
def CellMLToNektar.pycml.mathml_apply.qualifiers | ( | self | ) |
Return an iterable over the elements representing the qualifiers for this application.
Definition at line 4420 of file pycml.py.
References CellMLToNektar.pycml.mathml_apply._is_qualifier().
def CellMLToNektar.pycml.mathml_apply.tree_complexity | ( | self, | |
kw | |||
) |
Calculate a rough estimate of the computation time for evaluating this <apply> element. Operates recursively, so the complexity of a function call is given by summing the complexity of the arguments and the time for evaluating the function itself. If lookup_tables is True, then assume we're using lookup tables where possible. If algebraic is True, the complexity is calculated as a dictionary, mapping node types to the number of occurences of that type.
Definition at line 4458 of file pycml.py.
References CellMLToNektar.pycml.mathml_constructor._tree_complexity(), CellMLToNektar.utilities.add_dicts(), CellMLToNektar.optimize.ExpressionMatcher.A.operands, CellMLToNektar.pycml.mathml_apply.operands(), CellMLToNektar.optimize.ExpressionMatcher.A.operator, and CellMLToNektar.pycml.mathml_apply.operator().
|
private |
Definition at line 4405 of file pycml.py.
Referenced by CellMLToNektar.pycml.mathml_apply.assigned_variable(), CellMLToNektar.pycml.mathml_apply.classify_variables(), CellMLToNektar.pycml.mathml_apply.is_assignment(), CellMLToNektar.pycml.mathml_apply.is_ode(), and CellMLToNektar.pycml.mathml_apply.is_top_level().
|
private |
Definition at line 4402 of file pycml.py.
Referenced by CellMLToNektar.pycml.mathml_apply._get_binding_time(), and CellMLToNektar.pycml.mathml_piecewise._get_binding_time().
|
private |
Definition at line 4404 of file pycml.py.
Referenced by CellMLToNektar.pycml.mathml_apply.get_dependencies().
|
private |
|
private |
Definition at line 4395 of file pycml.py.
Referenced by CellMLToNektar.pycml.mathml_apply._set_in_units(), CellMLToNektar.pycml.mathml_piecewise._set_in_units(), CellMLToNektar.pycml.mathml_apply.get_units(), and CellMLToNektar.pycml.mathml_piecewise.get_units().
|
static |
Definition at line 4374 of file pycml.py.
Referenced by CellMLToNektar.pycml.mathml_apply._is_qualifier().