Nektar++
|
Public Member Functions | |
def | __init__ (self, doc, options=None) |
def | read_configuration_file (self, config_file) |
def | finalize_config (self) |
def | find_current_vars (self) |
def | annotate_currents_for_pe (self) |
def | expose_variables (self) |
def | annotate_metadata_for_pe (self) |
def | find_transmembrane_potential (self) |
def | find_membrane_capacitance (self) |
def | find_lookup_variables (self) |
def | validate_metadata (self, assume_valid=False) |
Private Member Functions | |
def | _create_var_def (self, content, defn_type) |
def | _check_var_def (self, var_elt, var_desc) |
def | _parse_var (self, elt, name) |
def | _parse_Vm (self, vm_elt) |
def | _parse_Cm (self, cm_elt) |
def | _parse_currents (self, currents) |
def | _find_variable (self, defn, pe_done=False) |
def | _process_ci_elts (self, elt, func, **kwargs) |
def | _find_transmembrane_currents_from_voltage_ode (self) |
def | _find_var (self, oxmeta_name, definitions) |
def | _parse_lookup_tables (self, lookup_tables) |
def | _set_lut_defaults (self, lut_dict) |
A container for configuration information, read in from XML configuration files. The file structure is described in the read_configuration_file method.
Definition at line 1807 of file translators.py.
def CellMLToNektar.translators.ConfigurationStore.__init__ | ( | self, | |
doc, | |||
options = None |
|||
) |
Create a new store. doc specifies a CellML document, the processing of which this configuration store will affect. If given, options should be an optparse.Values instance containing command-line options.
Definition at line 1813 of file translators.py.
|
private |
Check a variable definition is syntactically valid. If type == 'name', it must have text content of the form "component_name,variable_name". If type == 'oxmeta', it must have text content drawn from METADATA_NAMES. If type == 'config-name', it must have text content either 'stimulus' or 'transmembrane_potential'.
Definition at line 1978 of file translators.py.
Referenced by CellMLToNektar.translators.ConfigurationStore._parse_var().
|
private |
Create a variable definition object.
Definition at line 1973 of file translators.py.
Referenced by CellMLToNektar.translators.ConfigurationStore._find_var(), and CellMLToNektar.translators.ConfigurationStore.find_lookup_variables().
|
private |
Analyse the expression for dV/dt to determine the transmembrane currents. Looks for an equation defining dV/d(something) and assumes the something is time; this will be checked during code generation for Chaste. It then finds all variables on the RHS of this equation which have the same units as the stimulus current (self.i_stim_var) and identifies these as transmembrane currents. Will automatically exclude the stimulus current. If self.V_variable is not set, returns the empty list.
Definition at line 2074 of file translators.py.
References CellMLToNektar.optimize.PartialEvaluator._process_ci_elts(), CellMLToNektar.translators.ConfigurationStore._process_ci_elts(), CellMLToNektar.utilities.call_if(), Nektar::UnitTests.d(), CellMLToNektar.utilities.DEBUG(), Nektar::LibUtilities::H5DataSource.doc, CellMLToNektar.optimize.PartialEvaluator.doc, CellMLToNektar.optimize.LookupTableAnalyser.doc, CellMLToNektar.translators.CellMLTranslator.doc, CellMLToNektar.translators.ConfigurationStore.doc, CellMLToNektar.translators.ConfigurationStore.i_ionic_negated, CellMLToNektar.translators.ConfigurationStore.i_stim_negated, CellMLToNektar.translators.ConfigurationStore.i_stim_var, and CellMLToNektar.translators.ConfigurationStore.V_variable.
Referenced by CellMLToNektar.translators.ConfigurationStore.find_current_vars().
|
private |
Find the variable object in the model for a particular concept. Will look for a variable annotated with the given oxmeta_name first, then try the list of definitions from the configuration file in turn.
Definition at line 2266 of file translators.py.
References CellMLToNektar.translators.ConfigurationStore._create_var_def(), and CellMLToNektar.translators.ConfigurationStore._find_variable().
Referenced by CellMLToNektar.translators.ConfigurationStore.find_membrane_capacitance(), and CellMLToNektar.translators.ConfigurationStore.find_transmembrane_potential().
|
private |
Find a variable matching the given definition. If pe_done is True, then partial evaluation has been performed on the model, so looking for variables by name needs to look for variables called compname__varname in the single component.
Definition at line 2031 of file translators.py.
References CellMLToNektar.translators.ConfigurationStore.Cm_variable, Nektar::LibUtilities::H5DataSource.doc, CellMLToNektar.optimize.PartialEvaluator.doc, CellMLToNektar.optimize.LookupTableAnalyser.doc, CellMLToNektar.translators.CellMLTranslator.doc, CellMLToNektar.translators.ConfigurationStore.doc, CellMLToNektar.translators.ConfigurationStore.i_stim_var, and CellMLToNektar.translators.ConfigurationStore.V_variable.
Referenced by CellMLToNektar.translators.ConfigurationStore._find_var(), and CellMLToNektar.translators.ConfigurationStore.find_lookup_variables().
|
private |
Parse definition of variable holding the cell membrane capacitance.
Definition at line 2019 of file translators.py.
References CellMLToNektar.translators.ConfigurationStore._parse_var(), and CellMLToNektar.translators.ConfigurationStore.Cm_definitions.
Referenced by CellMLToNektar.translators.ConfigurationStore.read_configuration_file().
|
private |
Parse definitions of ionic and stimulus currents.
Definition at line 2023 of file translators.py.
References CellMLToNektar.translators.ConfigurationStore._parse_var(), CellMLToNektar.translators.ConfigurationStore.i_ionic_definitions, and CellMLToNektar.translators.ConfigurationStore.i_stim_definitions.
Referenced by CellMLToNektar.translators.ConfigurationStore.read_configuration_file().
|
private |
Parse a lookup_tables element.
Definition at line 2319 of file translators.py.
References CellMLToNektar.translators.ConfigurationStore._set_lut_defaults(), CellMLToNektar.pycml.get_units_by_name(), CellMLToNektar.translators.ConfigurationStore.lut_config, and CellMLToNektar.translators.ConfigurationStore.unit_definitions.
Referenced by CellMLToNektar.translators.ConfigurationStore.read_configuration_file().
|
private |
Parse definition of a special variable.
Definition at line 2001 of file translators.py.
References CellMLToNektar.translators.ConfigurationStore._check_var_def().
Referenced by CellMLToNektar.translators.ConfigurationStore._parse_Cm(), CellMLToNektar.translators.ConfigurationStore._parse_currents(), and CellMLToNektar.translators.ConfigurationStore._parse_Vm().
|
private |
Parse definition of variable holding the transmembrane potential.
Definition at line 2015 of file translators.py.
References CellMLToNektar.translators.ConfigurationStore._parse_var(), and CellMLToNektar.translators.ConfigurationStore.V_definitions.
Referenced by CellMLToNektar.translators.ConfigurationStore.read_configuration_file().
|
private |
Recursively apply func to any ci elements in the tree rooted at elt.
Definition at line 2066 of file translators.py.
References CellMLToNektar.optimize.PartialEvaluator._process_ci_elts(), and CellMLToNektar.translators.ConfigurationStore._process_ci_elts().
Referenced by CellMLToNektar.translators.ConfigurationStore._find_transmembrane_currents_from_voltage_ode(), CellMLToNektar.optimize.PartialEvaluator._process_ci_elts(), CellMLToNektar.translators.ConfigurationStore._process_ci_elts(), and CellMLToNektar.optimize.PartialEvaluator.is_instantiable().
|
private |
Set default configuration for a lookup table.
Definition at line 2340 of file translators.py.
Referenced by CellMLToNektar.translators.ConfigurationStore._parse_lookup_tables(), and CellMLToNektar.translators.ConfigurationStore.finalize_config().
def CellMLToNektar.translators.ConfigurationStore.annotate_currents_for_pe | ( | self | ) |
Annotate ionic & stimulus current vars so PE doesn't remove them. Also annotate the membrane capacitance, if defined.
Definition at line 2349 of file translators.py.
References CellMLToNektar.translators.ConfigurationStore.Cm_variable, CellMLToNektar.translators.ConfigurationStore.i_ionic_vars, and CellMLToNektar.translators.ConfigurationStore.i_stim_var.
def CellMLToNektar.translators.ConfigurationStore.annotate_metadata_for_pe | ( | self | ) |
Definition at line 2379 of file translators.py.
References CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.metadata_vars, and CellMLToNektar.translators.ConfigurationStore.metadata_vars.
def CellMLToNektar.translators.ConfigurationStore.expose_variables | ( | self | ) |
Expose variables for access with GetAnyVariable if desired.
Definition at line 2360 of file translators.py.
References CellMLToNektar.utilities.DEBUG(), Nektar::LibUtilities::H5DataSource.doc, CellMLToNektar.optimize.PartialEvaluator.doc, CellMLToNektar.optimize.LookupTableAnalyser.doc, CellMLToNektar.translators.CellMLTranslator.doc, CellMLToNektar.translators.ConfigurationStore.doc, CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.metadata_vars, CellMLToNektar.translators.ConfigurationStore.metadata_vars, CellMLToNektar.translators.CellMLTranslator.options, and CellMLToNektar.translators.ConfigurationStore.options.
def CellMLToNektar.translators.ConfigurationStore.finalize_config | ( | self | ) |
Having read all the configuration files, apply to the model.
Definition at line 1960 of file translators.py.
References CellMLToNektar.translators.ConfigurationStore._set_lut_defaults(), CellMLToNektar.translators.ConfigurationStore.find_current_vars(), CellMLToNektar.translators.ConfigurationStore.find_membrane_capacitance(), CellMLToNektar.translators.ConfigurationStore.find_transmembrane_potential(), CellMLToNektar.translators.ConfigurationStore.lut_config, CellMLToNektar.translators.CellMLTranslator.options, and CellMLToNektar.translators.ConfigurationStore.options.
def CellMLToNektar.translators.ConfigurationStore.find_current_vars | ( | self | ) |
Find the variables representing currents.
Definition at line 2281 of file translators.py.
References CellMLToNektar.translators.ConfigurationStore._find_transmembrane_currents_from_voltage_ode(), Nektar::LibUtilities::H5DataSource.doc, CellMLToNektar.optimize.PartialEvaluator.doc, CellMLToNektar.optimize.LookupTableAnalyser.doc, CellMLToNektar.translators.CellMLTranslator.doc, CellMLToNektar.translators.ConfigurationStore.doc, CellMLToNektar.translators.ConfigurationStore.i_ionic_definitions, CellMLToNektar.translators.ConfigurationStore.i_ionic_vars, CellMLToNektar.translators.ConfigurationStore.i_stim_var, CellMLToNektar.translators.CellMLTranslator.options, and CellMLToNektar.translators.ConfigurationStore.options.
Referenced by CellMLToNektar.translators.ConfigurationStore.finalize_config().
def CellMLToNektar.translators.ConfigurationStore.find_lookup_variables | ( | self | ) |
Find the variable objects used as lookup table keys. This method translates the variable names given in the configuration file into objects in the document, and then uses those objects as keys in our lut_config dictionary. The ultimate source variable for the variable specified is used, in order to avoid complications caused by intermediaries being removed (e.g. by PE). The table settings are also units-converted to match the units of the key variable.
Definition at line 2411 of file translators.py.
References CellMLToNektar.translators.ConfigurationStore._create_var_def(), CellMLToNektar.translators.ConfigurationStore._find_variable(), CellMLToNektar.utilities.DEBUG(), CellMLToNektar.utilities.LOG(), and CellMLToNektar.translators.ConfigurationStore.lut_config.
def CellMLToNektar.translators.ConfigurationStore.find_membrane_capacitance | ( | self | ) |
Find and store the variable object representing the cell membrane capacitance. Uses first metadata, if present, then the configuration file.
Definition at line 2404 of file translators.py.
References CellMLToNektar.translators.ConfigurationStore._find_var(), CellMLToNektar.translators.ConfigurationStore.Cm_definitions, CellMLToNektar.translators.ConfigurationStore.Cm_variable, and CellMLToNektar.utilities.DEBUG().
Referenced by CellMLToNektar.translators.ConfigurationStore.finalize_config().
def CellMLToNektar.translators.ConfigurationStore.find_transmembrane_potential | ( | self | ) |
Find and store the variable object representing V. Tries metadata annotation first. If that fails, uses the name given in the command line options, if present. If that fails, uses the config file.
Definition at line 2385 of file translators.py.
References CellMLToNektar.translators.ConfigurationStore._find_var(), CellMLToNektar.utilities.DEBUG(), CellMLToNektar.translators.CellMLTranslator.options, CellMLToNektar.translators.ConfigurationStore.options, CellMLToNektar.translators.ConfigurationStore.V_definitions, and CellMLToNektar.translators.ConfigurationStore.V_variable.
Referenced by CellMLToNektar.translators.ConfigurationStore.finalize_config().
def CellMLToNektar.translators.ConfigurationStore.read_configuration_file | ( | self, | |
config_file | |||
) |
Read configuration stored in config_file. The configuration file is expected to be XML, conforming to the following structure. Currently little checking is done on the file format; incorrectly formatted files are unlikely to give particularly helpful error messages. The root element may contain a 'global' element, giving global configuration options. These include: * 'lookup_tables' Contains one or more 'lookup_table' elements, one for each type of lookup table available. These contain (a selection of) the elements: * 'var' - the variable to key on. The component name given should be that from which the variable is exported. Must be present. * 'min', 'max', 'step' - table bounds parameters. Optional. Default values are used for parameters that are not present. * 'currents' Defines which variables hold the ionic and stimulus currents, if any. It contains 2 elements: * 'stimulus' - the full name of the stimulus current variable * 'ionic_match' - a regular expression matching full names of ionic current variables. It may also match the stimulus current, but the stimulus will never be considered an ionic current. The value is split on ','; the first part is then matched against component names, and the second against variables in matching components. This is mostly redundant now, because the equation for dV/dt is used first to determine the ionic currents (see documentation for _find_transmembrane_currents_from_voltage_ode), and only if this fails to find suitable currents will the ionic_match definition be used. * 'transmembrane_potential' Defines which variable holds the transmembrane potential. Defaults to 'membrane,V' if not present. * 'membrane_capacitance' Defines which variable holds the cell membrane capacitance. The root element also contains 0 or more 'for_model' elements, which contain settings for individual models. These must have at least one of an 'id' or 'name' attribute, which specify the model in question. They can also contain anything allowable as global configuration options. Options given here override those specified globally. Configuration which is identical for groups of models may be given using the 'for_models' element. This has an 'ids' element as its first child, which contains 'id' elements holding either the name or id of a model. The remaining contents of the 'for_models' element are as for 'for_model'. There are 3 ways of specifying variables: 1. By name (var type='name') Variable names are given in full form, i.e. component_name,variable_name 2. By standardised name (var type='oxmeta') Use the name from the oxmeta annotations 3. By reference to a section of the config file (when defining lookup table keys) e.g. <var type='config-name'>transmembrane_potential</var> Within any element that specifies a variable, a list of <var> elements can be provided. Each will be tried in turn to see if a match can be found in the model, and the first match wins. Some items are overridden if oxmeta annotations are present in the model, with the annotated variable taking precedence over the config file specification.
Definition at line 1848 of file translators.py.
References CellMLToNektar.translators.ConfigurationStore._parse_Cm(), CellMLToNektar.translators.ConfigurationStore._parse_currents(), CellMLToNektar.translators.ConfigurationStore._parse_lookup_tables(), CellMLToNektar.translators.ConfigurationStore._parse_Vm(), CellMLToNektar.utilities.amara_parse(), CellMLToNektar.utilities.DEBUG(), Nektar::LibUtilities::H5DataSource.doc, CellMLToNektar.optimize.PartialEvaluator.doc, CellMLToNektar.optimize.LookupTableAnalyser.doc, CellMLToNektar.translators.CellMLTranslator.doc, CellMLToNektar.translators.ConfigurationStore.doc, CellMLToNektar.translators.get_options(), CellMLToNektar.translators.CellMLTranslator.options, CellMLToNektar.translators.ConfigurationStore.options, and CellMLToNektar.translators.ConfigurationStore.unit_definitions.
def CellMLToNektar.translators.ConfigurationStore.validate_metadata | ( | self, | |
assume_valid = False |
|||
) |
Check that the metadata annotations are 'sensible'. Ensures that only names we know are used, and that the same name isn't used for multiple variables.
Definition at line 2459 of file translators.py.
References Nektar::LibUtilities::H5DataSource.doc, CellMLToNektar.optimize.PartialEvaluator.doc, CellMLToNektar.optimize.LookupTableAnalyser.doc, CellMLToNektar.translators.CellMLTranslator.doc, and CellMLToNektar.translators.ConfigurationStore.doc.
CellMLToNektar.translators.ConfigurationStore.Cm_definitions |
Definition at line 1829 of file translators.py.
Referenced by CellMLToNektar.translators.ConfigurationStore._parse_Cm(), and CellMLToNektar.translators.ConfigurationStore.find_membrane_capacitance().
CellMLToNektar.translators.ConfigurationStore.Cm_variable |
CellMLToNektar.translators.ConfigurationStore.doc |
Definition at line 1820 of file translators.py.
Referenced by CellMLToNektar.optimize.LookupTableAnalyser._determine_duplicate_tables(), CellMLToNektar.optimize.LookupTableAnalyser._determine_unneeded_tables(), CellMLToNektar.optimize.PartialEvaluator._do_reduce_eval_loop(), CellMLToNektar.optimize.LookupTableAnalyser._find_tables(), CellMLToNektar.translators.ConfigurationStore._find_transmembrane_currents_from_voltage_ode(), CellMLToNektar.translators.ConfigurationStore._find_variable(), CellMLToNektar.optimize.PartialEvaluator._get_assignment_exprs(), CellMLToNektar.optimize.LookupTableAnalyser.analyse_model(), CellMLToNektar.optimize.LookupTableAnalyser.annotate_as_suitable(), CellMLToNektar.optimize.LookupTableAnalyser.config(), CellMLToNektar.translators.CellMLTranslator.config(), CellMLToNektar.translators.ConfigurationStore.expose_variables(), CellMLToNektar.translators.ConfigurationStore.find_current_vars(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.get_stimulus_assignment(), CellMLToNektar.optimize.PartialEvaluator.is_instantiable(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.lut_parameters(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_backward_euler_mathematics(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_constructor(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_derived_quantities(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_equations(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_get_i_ionic(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_intracellular_calcium(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_lut_class(), CellMLToNektar.translators.CellMLTranslator.output_lut_declarations(), CellMLToNektar.translators.CellMLTranslator.output_lut_deletion(), CellMLToNektar.translators.CellMLTranslator.output_lut_generation(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_lut_indexing_methods(), CellMLToNektar.translators.CellMLTranslator.output_lut_indices(), CellMLToNektar.translators.CellMLTranslator.output_lut_methods(), CellMLToNektar.translators.CellMLTranslator.output_lut_row_lookup_memory(), CellMLToNektar.translators.CellMLTranslator.output_lut_row_lookup_methods(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_rush_larsen_mathematics(), CellMLToNektar.translators.CellMLTranslator.output_table_index_generation(), CellMLToNektar.translators.ConfigurationStore.read_configuration_file(), CellMLToNektar.optimize.LookupTableAnalyser.remove_lut_annotations(), CellMLToNektar.translators.CellMLTranslator.scan_for_lookup_tables(), and CellMLToNektar.translators.ConfigurationStore.validate_metadata().
CellMLToNektar.translators.ConfigurationStore.dt_variable |
Definition at line 1843 of file translators.py.
CellMLToNektar.translators.ConfigurationStore.i_data_clamp_conductance |
Definition at line 1845 of file translators.py.
CellMLToNektar.translators.ConfigurationStore.i_data_clamp_current |
Definition at line 1844 of file translators.py.
CellMLToNektar.translators.ConfigurationStore.i_ionic_definitions |
Definition at line 1836 of file translators.py.
Referenced by CellMLToNektar.translators.ConfigurationStore._parse_currents(), and CellMLToNektar.translators.ConfigurationStore.find_current_vars().
CellMLToNektar.translators.ConfigurationStore.i_ionic_negated |
Definition at line 1839 of file translators.py.
Referenced by CellMLToNektar.translators.ConfigurationStore._find_transmembrane_currents_from_voltage_ode().
CellMLToNektar.translators.ConfigurationStore.i_ionic_vars |
Definition at line 1837 of file translators.py.
Referenced by CellMLToNektar.translators.ConfigurationStore.annotate_currents_for_pe(), and CellMLToNektar.translators.ConfigurationStore.find_current_vars().
CellMLToNektar.translators.ConfigurationStore.i_stim_definitions |
Definition at line 1834 of file translators.py.
Referenced by CellMLToNektar.translators.ConfigurationStore._parse_currents().
CellMLToNektar.translators.ConfigurationStore.i_stim_negated |
Definition at line 1841 of file translators.py.
Referenced by CellMLToNektar.translators.ConfigurationStore._find_transmembrane_currents_from_voltage_ode().
CellMLToNektar.translators.ConfigurationStore.i_stim_var |
Definition at line 1835 of file translators.py.
Referenced by CellMLToNektar.translators.ConfigurationStore._find_transmembrane_currents_from_voltage_ode(), CellMLToNektar.translators.ConfigurationStore._find_variable(), CellMLToNektar.translators.ConfigurationStore.annotate_currents_for_pe(), and CellMLToNektar.translators.ConfigurationStore.find_current_vars().
CellMLToNektar.translators.ConfigurationStore.lut_config |
CellMLToNektar.translators.ConfigurationStore.metadata_vars |
CellMLToNektar.translators.ConfigurationStore.options |
Definition at line 1822 of file translators.py.
Referenced by CellMLToNektar.translators.ConfigurationStore.expose_variables(), CellMLToNektar.translators.ConfigurationStore.finalize_config(), CellMLToNektar.translators.ConfigurationStore.find_current_vars(), CellMLToNektar.translators.ConfigurationStore.find_transmembrane_potential(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_constructor(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_mathematics(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_state_assignments(), and CellMLToNektar.translators.ConfigurationStore.read_configuration_file().
CellMLToNektar.translators.ConfigurationStore.unit_definitions |
Definition at line 1823 of file translators.py.
Referenced by CellMLToNektar.translators.ConfigurationStore._parse_lookup_tables(), and CellMLToNektar.translators.ConfigurationStore.read_configuration_file().
CellMLToNektar.translators.ConfigurationStore.V_definitions |
Definition at line 1826 of file translators.py.
Referenced by CellMLToNektar.translators.ConfigurationStore._parse_Vm(), and CellMLToNektar.translators.ConfigurationStore.find_transmembrane_potential().
CellMLToNektar.translators.ConfigurationStore.V_variable |
Definition at line 1827 of file translators.py.
Referenced by CellMLToNektar.translators.ConfigurationStore._find_transmembrane_currents_from_voltage_ode(), CellMLToNektar.translators.ConfigurationStore._find_variable(), and CellMLToNektar.translators.ConfigurationStore.find_transmembrane_potential().