Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
CellMLToNektar.translators.CellMLTranslator Class Reference
Inheritance diagram for CellMLToNektar.translators.CellMLTranslator:
Inheritance graph
[legend]
Collaboration diagram for CellMLToNektar.translators.CellMLTranslator:
Collaboration graph
[legend]

Classes

class  NameAlreadyRegistered
 

Public Member Functions

def register
 
def __init__
 
def error
 
def config
 
def translate
 
def final_configuration_hook
 
def output_file_name
 
def subsidiary_file_name
 
def send_main_output_to_subsidiary
 
def writeln
 
def write
 
def capture_output
 
def get_captured_output
 
def output_comment
 
def output_doxygen
 
def set_indent
 
def code_name
 
def varobj
 
def var_display_name
 
def include_guard
 
def output_top_boilerplate
 
def output_mathematics
 
def output_bottom_boilerplate
 
def output_assignment
 
def output_lhs
 
def output_variable
 
def output_expr
 
def output_number
 
def eval_number
 
def output_apply
 
def output_function
 
def output_nary_operator
 
def output_unary_operator
 
def output_binary_operator
 
def output_root
 
def output_log
 
def output_minus
 
def output_piecewise
 
def open_paren
 
def close_paren
 
def open_block
 
def close_block
 
def calculate_extended_dependencies
 Dependency related methods #. More...
 
def output_equations
 
def scan_for_lookup_tables
 Lookup table methods #. More...
 
def lut_access_code
 
def lut_parameters
 
def lut_size_calculation
 
def output_lut_generation
 
def output_lut_deletion
 
def output_lut_declarations
 
def output_lut_index_declarations
 
def output_lut_indices
 
def output_lut_methods
 
def output_single_lookup
 
def output_lut_row_lookup_methods
 
def output_lut_row_lookup_memory
 
def is_lookup_table
 
def contained_table_indices
 
def lut_factor
 
def output_table_lookup
 
def output_table_index_generation
 
def output_table_index_checking
 
def output_table_index_generation_code
 

Static Public Member Functions

def generate_interface
 

Public Attributes

 options
 
 indent_level
 
 indent_char
 
 indent_factor
 
 use_lookup_tables
 
 add_timestamp
 
 doc
 
 model
 
 class_name
 
 free_vars
 
 state_vars
 
 single_component
 
 v_variable
 
 v_variable_name
 
 v_index
 
 lookup_method_prefix
 
 row_lookup_method
 
 lt_index_uses_floor
 
 constrain_table_indices
 
 subsidiary_filename
 
 output_filename
 
 out
 
 out2
 

Static Public Attributes

dictionary translators = {}
 
string STMT_END = ';'
 Various language tokens #. More...
 
string EQ_ASSIGN = ' = '
 
string COMMENT_START = '// '
 
string DOXYGEN_COMMENT_START = '//! '
 
string TYPE_DOUBLE = 'NekDouble '
 
string TYPE_VOID = 'void '
 
string TYPE_CONST_DOUBLE = 'const NekDouble '
 
string TYPE_CONST_UNSIGNED = 'const unsigned '
 
string TRUE = 'true'
 
string FALSE = 'false'
 
string PI = 'M_PI'
 
string E = 'M_E'
 
string NOT_A_NUMBER = 'NAN'
 
 USES_SUBSIDIARY_FILE = False
 
dictionary FILE_EXTENSIONS
 
dictionary function_map
 
dictionary recip_trig
 
dictionary nary_ops
 
dictionary binary_ops
 
dictionary special_roots = {2: 'sqrt', 3: 'cbrt'}
 

Private Member Functions

def _vars_in
 

Private Attributes

 _main_output_to_subsidiary
 
 _original_out
 

Detailed Description

Base class for translators from CellML to programming languages.

Provides various methods & attributes that can be overridden to
achieve the desired output language and style.

Also contains a registration system for subclasses, so the
command-line client can know what translators are available.  See
the register method for more information.

Definition at line 98 of file translators.py.

Constructor & Destructor Documentation

def CellMLToNektar.translators.CellMLTranslator.__init__ (   self,
  add_timestamp = True,
  options = None 
)
Create a translator.

Definition at line 167 of file translators.py.

168  def __init__(self, add_timestamp=True, options=None):
169  """Create a translator."""
170  self.options = options
171  # Initially output should not be indented
172  self.indent_level = 0
173  # Character to indent with
174  self.indent_char = ' '
175  # No. of occurrences of indent_char per indent_level
176  self.indent_factor = 4
177  # Whether to use lookup tables where possible
178  self.use_lookup_tables = True
179  # Whether to add a timestamp comment to generated files
180  self.add_timestamp = add_timestamp
181  # Main output goes to the main file by default
182  self._main_output_to_subsidiary = False

Member Function Documentation

def CellMLToNektar.translators.CellMLTranslator._vars_in (   self,
  expr 
)
private
Return a set of variable objects used in the given expression.

Will include state variables.  If the expression includes a derivative, the defining equation
for that derivative will be included in the set.  Also if an expression is being
replaced by a lookup table, this will only include the table key variable.

Definition at line 928 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator._vars_in(), CellMLToNektar.translators.CellMLTranslator.free_vars, CellMLToNektar.translators.CellMLTranslator.is_lookup_table(), CellMLToNektar.translators.CellMLTranslator.use_lookup_tables, CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.use_lookup_tables, and CellMLToNektar.translators.CellMLTranslator.varobj().

Referenced by CellMLToNektar.translators.CellMLTranslator._vars_in(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_backward_euler_mathematics(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_grl_compute_partial(), and CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_rush_larsen_mathematics().

929  def _vars_in(self, expr):
930  """Return a set of variable objects used in the given expression.
931 
932  Will include state variables. If the expression includes a derivative, the defining equation
933  for that derivative will be included in the set. Also if an expression is being
934  replaced by a lookup table, this will only include the table key variable.
935  """
936  res = set()
937  if self.use_lookup_tables and isinstance(expr, mathml) and self.is_lookup_table(expr):
938  key_var = self.varobj(expr.getAttributeNS(NSS['lut'], u'var'))
939  key_var = key_var.get_source_variable(recurse=True)
940  res.add(key_var)
941  elif isinstance(expr, mathml_ci):
942  varobj = getattr(expr, '_cml_variable', None)
943  if not varobj:
944  varname = unicode(expr)
945  varobj = self.varobj(varname.strip())
946  if varobj:
947  res.add(varobj)
948  elif isinstance(expr, mathml_apply) and expr.operator().localName == u'diff':
949  dep_varname = unicode(expr.ci)
950  varobj = self.varobj(dep_varname.strip())
951  res.add(varobj.get_ode_dependency(self.free_vars[0]))
952  elif hasattr(expr, 'xml_children'):
953  for child in expr.xml_children:
954  res.update(self._vars_in(child))
955  return res
956 
def CellMLToNektar.translators.CellMLTranslator.calculate_extended_dependencies (   self,
  nodes,
  prune = [],
  prune_deps = [] 
)

Dependency related methods #.

Method moved to cellml_model.

Definition at line 899 of file translators.py.

Referenced by CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_backward_euler_mathematics(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_derivative_calculations(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_derivative_calculations_grl(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_derived_quantities(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_get_i_ionic(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_grl_compute_partial(), and CellMLToNektar.translators.CellMLTranslator.output_table_index_generation().

900  def calculate_extended_dependencies(self, nodes, prune=[], prune_deps=[]):
901  """Method moved to cellml_model."""
902 
903  # for var in nodes:
904  # self.writeln(var)
905  # self.writeln()
906 
907  # for var in self.model.calculate_extended_dependencies(nodes, prune, prune_deps):
908  # self.writeln(var)
909  # self.writeln()
910 
911 
912  return self.model.calculate_extended_dependencies(nodes, prune, prune_deps)
def calculate_extended_dependencies
Dependency related methods #.
Definition: translators.py:899
def CellMLToNektar.translators.CellMLTranslator.capture_output (   self)
Make subsequent output operations write to a string buffer.

Definition at line 405 of file translators.py.

406  def capture_output(self):
407  """Make subsequent output operations write to a string buffer."""
408  self._original_out = self.out
409  self.out = StringIO()
def CellMLToNektar.translators.CellMLTranslator.close_block (   self,
  blank_line = True,
  kwargs 
)
Close a code block and decrease indent.

Definition at line 885 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator.set_indent(), and CellMLToNektar.translators.CellMLTranslator.writeln().

Referenced by CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_backward_euler_mathematics(), CellMLToNektar.translators.CellMLTranslator.output_bottom_boilerplate(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_bottom_boilerplate(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_chaste_lut_methods(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_derived_quantities(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_evaluate_y_derivatives(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_get_i_ionic(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_grl1_mathematics(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_grl2_mathematics(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_grl_compute_partial(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_intracellular_calcium(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_lut_class(), CellMLToNektar.translators.CellMLTranslator.output_lut_deletion(), CellMLToNektar.translators.CellMLTranslator.output_lut_generation(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_lut_indexing_methods(), CellMLToNektar.translators.CellMLTranslator.output_lut_methods(), CellMLToNektar.translators.CellMLTranslator.output_lut_row_lookup_methods(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_rush_larsen_mathematics(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_serialize_method(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_state_assignments(), CellMLToNektar.translators.CellMLTranslator.output_table_index_checking(), and CellMLToNektar.translators.CellMLTranslator.output_top_boilerplate().

886  def close_block(self, blank_line=True, **kwargs):
887  """Close a code block and decrease indent."""
888  self.set_indent(offset=-1)
889  self.writeln('}', **kwargs)
890  if blank_line:
891  self.writeln(**kwargs)
892  return
def CellMLToNektar.translators.CellMLTranslator.close_paren (   self,
  paren 
)

Definition at line 878 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator.write().

Referenced by CellMLToNektar.translators.CellMLTranslator.output_log(), CellMLToNektar.translators.CellMLTranslator.output_nary_operator(), CellMLToNektar.translators.CellMLTranslator.output_piecewise(), and CellMLToNektar.translators.CellMLTranslator.output_unary_operator().

879  def close_paren(self, paren):
880  if paren: self.write(')')
def CellMLToNektar.translators.CellMLTranslator.code_name (   self,
  var,
  ode = False,
  prefix = None 
)
Return the full name of var in a form suitable for inclusion in a
source file.

If ode is True then return the name of the derivative of var
instead.  We go directly to the source variable in this case,
rather than including intermediate assignment statements as is
done for connections.

Definition at line 442 of file translators.py.

Referenced by CellMLToNektar.translators.CellMLTranslator.output_apply(), CellMLToNektar.translators.CellMLTranslator.output_assignment(), CellMLToNektar.translators.CellMLTranslator.output_bottom_boilerplate(), CellMLToNektar.translators.CellMLTranslator.output_lhs(), CellMLToNektar.translators.CellMLTranslator.output_lut_generation(), CellMLToNektar.translators.CellMLTranslator.output_table_index_checking(), CellMLToNektar.translators.CellMLTranslator.output_table_index_generation_code(), CellMLToNektar.translators.CellMLTranslator.output_top_boilerplate(), and CellMLToNektar.translators.CellMLTranslator.output_variable().

443  def code_name(self, var, ode=False, prefix=None):
444  """
445  Return the full name of var in a form suitable for inclusion in a
446  source file.
447 
448  If ode is True then return the name of the derivative of var
449  instead. We go directly to the source variable in this case,
450  rather than including intermediate assignment statements as is
451  done for connections.
452  """
453  if prefix is None:
454  prefix = ['var_', 'd_dt_'][ode]
455  if ode:
456  var = var.get_source_variable(recurse=True)
457  name = prefix + var.fullname(cellml=True)
458  return name
def CellMLToNektar.translators.CellMLTranslator.config (   self)
Get the current document's configuration store.

Definition at line 198 of file translators.py.

References Nektar::LibUtilities::H5DataSource.doc, CellMLToNektar.optimize.PartialEvaluator.doc, CellMLToNektar.translators.CellMLTranslator.doc, CellMLToNektar.optimize.LookupTableAnalyser.doc, and CellMLToNektar.translators.CellMLTranslator.translate().

199  def config(self):
200  """Get the current document's configuration store."""
201  return getattr(self.doc, '_cml_config', None)
def CellMLToNektar.translators.CellMLTranslator.contained_table_indices (   self,
  node 
)
Return all lookup tables used directly in computing this node.

If this is an expression node, checks all its children for table
lookups, and returns the set of table indices used.

Definition at line 1220 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator.contained_table_indices(), and CellMLToNektar.translators.CellMLTranslator.is_lookup_table().

Referenced by CellMLToNektar.translators.CellMLTranslator.contained_table_indices(), and CellMLToNektar.translators.CellMLTranslator.output_table_index_generation().

1221  def contained_table_indices(self, node):
1222  """Return all lookup tables used directly in computing this node.
1223 
1224  If this is an expression node, checks all its children for table
1225  lookups, and returns the set of table indices used.
1226  """
1227  result = set()
1228  if isinstance(node, amara.bindery.element_base):
1229  if self.is_lookup_table(node):
1230  result.add(node.table_index)
1231  else:
1232  for child in node.xml_children:
1233  result.update(self.contained_table_indices(child))
1234  return result
def CellMLToNektar.translators.CellMLTranslator.error (   self,
  lines,
  xml = None 
)
Raise a translation error.

lines is a list of strings describing what went wrong.
A TranslationError with that message will be raised.

If xml is given, it should be an element, which will be
pretty-printed and included in the error.

Definition at line 183 of file translators.py.

Referenced by CellMLToNektar.translators.CellMLTranslator.output_apply(), CellMLToNektar.translators.CellMLTranslator.output_binary_operator(), CellMLToNektar.translators.CellMLTranslator.output_expr(), and CellMLToNektar.translators.CellMLTranslator.writeln().

184  def error(self, lines, xml=None):
185  """Raise a translation error.
186 
187  lines is a list of strings describing what went wrong.
188  A TranslationError with that message will be raised.
189 
190  If xml is given, it should be an element, which will be
191  pretty-printed and included in the error.
192  """
193  if xml is not None:
194  lines.extend(xml.xml(indent = u'yes',
195  omitXmlDeclaration = u'yes').split('\n'))
196  raise TranslationError('\n'.join(lines))
def CellMLToNektar.translators.CellMLTranslator.eval_number (   self,
  expr 
)
Evaluate a number.

If a (unicode) string, convert to float.
If a cn element, call its evaluate method.

Definition at line 697 of file translators.py.

Referenced by CellMLToNektar.translators.CellMLTranslator.output_number().

698  def eval_number(self, expr):
699  """Evaluate a number.
700 
701  If a (unicode) string, convert to float.
702  If a cn element, call its evaluate method.
703  """
704  if isinstance(expr, mathml_cn):
705  return expr.evaluate()
706  else:
707  return float(unicode(expr))
def CellMLToNektar.translators.CellMLTranslator.final_configuration_hook (   self)
A hook for subclasses to do some final configuration.

Definition at line 320 of file translators.py.

321  def final_configuration_hook(self):
322  """A hook for subclasses to do some final configuration."""
323  return
def CellMLToNektar.translators.CellMLTranslator.generate_interface (   doc,
  solver_info 
)
static
Generate an interface component connecting the model to whatever will use it.

Stub method that subclasses can override to implement this functionality.

Definition at line 131 of file translators.py.

132  def generate_interface(doc, solver_info):
133  """Generate an interface component connecting the model to whatever will use it.
134 
135  Stub method that subclasses can override to implement this functionality.
136  """
137  pass
def CellMLToNektar.translators.CellMLTranslator.get_captured_output (   self)
Stop capturing output, and return what was captured as a string.

Definition at line 410 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator._original_out, CellMLToNektar.translators.CellMLTranslator.out, and Nektar::NekMeshUtils::DelaunayTriangle.out.

411  def get_captured_output(self):
412  """Stop capturing output, and return what was captured as a string."""
413  output = self.out.getvalue()
414  self.out = self._original_out
415  return output
def CellMLToNektar.translators.CellMLTranslator.include_guard (   self)
Get the include guard (for C/C++ output) for this cell model,
based on the class name.

Definition at line 488 of file translators.py.

Referenced by CellMLToNektar.translators.CellMLTranslator.output_top_boilerplate().

489  def include_guard(self):
490  """
491  Get the include guard (for C/C++ output) for this cell model,
492  based on the class name.
493  """
494  return self.class_name.upper() + '_HPP_'
def CellMLToNektar.translators.CellMLTranslator.is_lookup_table (   self,
  expr 
)
Return True iff expr can be replaced by a lookup table.

Uses annotations from a previous analysis.

Definition at line 1214 of file translators.py.

Referenced by CellMLToNektar.translators.CellMLTranslator._vars_in(), CellMLToNektar.translators.CellMLTranslator.contained_table_indices(), and CellMLToNektar.translators.CellMLTranslator.output_expr().

1215  def is_lookup_table(self, expr):
1216  """Return True iff expr can be replaced by a lookup table.
1217 
1218  Uses annotations from a previous analysis."""
1219  return expr.getAttributeNS(NSS['lut'], u'possible', '') == u'yes'
def CellMLToNektar.translators.CellMLTranslator.lut_access_code (   self,
  table_index,
  table_name,
  i 
)
Get the code for accessing the i'th element of the given table.

Definition at line 1062 of file translators.py.

Referenced by CellMLToNektar.translators.CellMLTranslator.output_lut_generation(), and CellMLToNektar.translators.CellMLTranslator.output_single_lookup().

1063  def lut_access_code(self, table_index, table_name, i):
1064  """Get the code for accessing the i'th element of the given table.
1065  """
1066  return '_lookup_table_%s[%s][%s]' % (table_index, i, table_name)
def CellMLToNektar.translators.CellMLTranslator.lut_factor (   self,
  idx,
  include_comma = False,
  include_type = False 
)
Return code for any extra factor needed to do a table lookup.

Will return the empty string unless linear interpolation is being used.

Definition at line 1235 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator.TYPE_DOUBLE, and CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.TYPE_DOUBLE.

Referenced by CellMLToNektar.translators.CellMLTranslator.output_lut_index_declarations(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_lut_indexing_methods(), CellMLToNektar.translators.CellMLTranslator.output_lut_methods(), CellMLToNektar.translators.CellMLTranslator.output_lut_row_lookup_methods(), CellMLToNektar.translators.CellMLTranslator.output_single_lookup(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_table_index_generation_code(), CellMLToNektar.translators.CellMLTranslator.output_table_index_generation_code(), and CellMLToNektar.translators.CellMLTranslator.output_table_lookup().

1236  def lut_factor(self, idx, include_comma=False, include_type=False):
1237  """Return code for any extra factor needed to do a table lookup.
1238 
1239  Will return the empty string unless linear interpolation is being used.
1240  """
1241  if self.config.options.lookup_type == 'linear-interpolation':
1242  factor = '_factor_' + str(idx)
1243  if include_type: factor = self.TYPE_DOUBLE + factor
1244  if include_comma: factor = ', ' + factor
1245  else:
1246  factor = ''
1247  return factor
def CellMLToNektar.translators.CellMLTranslator.lut_parameters (   self,
  key 
)
Get the bounds and step size for a particular table.

key should be a key into self.lookup_table_indices.
Returns (min, max, step, step_inverse) suitable for putting in generated code.

Definition at line 1067 of file translators.py.

Referenced by CellMLToNektar.translators.CellMLTranslator.output_lut_generation(), CellMLToNektar.translators.CellMLTranslator.output_table_index_checking(), and CellMLToNektar.translators.CellMLTranslator.output_table_index_generation_code().

1068  def lut_parameters(self, key):
1069  """Get the bounds and step size for a particular table.
1070 
1071  key should be a key into self.lookup_table_indices.
1072  Returns (min, max, step, step_inverse) suitable for putting in generated code.
1073  """
1074  return key[0:3] + [unicode(1 / float(key[2]))]
def CellMLToNektar.translators.CellMLTranslator.lut_size_calculation (   self,
  min,
  max,
  step 
)
Return the equivalent of '1 + (unsigned)((max-min)/step+0.5)'.

Definition at line 1075 of file translators.py.

Referenced by CellMLToNektar.translators.CellMLTranslator.output_lut_generation().

1076  def lut_size_calculation(self, min, max, step):
1077  """Return the equivalent of '1 + (unsigned)((max-min)/step+0.5)'."""
1078  return '1 + (unsigned)((%s-%s)/%s+0.5)' % (max, min, step)
def CellMLToNektar.translators.CellMLTranslator.open_block (   self,
  kwargs 
)
Open a new code block and increase indent.

Definition at line 881 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator.set_indent(), and CellMLToNektar.translators.CellMLTranslator.writeln().

Referenced by CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_assignment(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_backward_euler_mathematics(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_bottom_boilerplate(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_chaste_lut_methods(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_derived_quantities(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_evaluate_y_derivatives(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_get_i_ionic(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_grl1_mathematics(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_grl2_mathematics(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_grl_compute_partial(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_intracellular_calcium(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_lut_class(), CellMLToNektar.translators.CellMLTranslator.output_lut_deletion(), CellMLToNektar.translators.CellMLTranslator.output_lut_generation(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_lut_indexing_methods(), CellMLToNektar.translators.CellMLTranslator.output_lut_methods(), CellMLToNektar.translators.CellMLTranslator.output_lut_row_lookup_methods(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_rush_larsen_mathematics(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_serialize_method(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_state_assignments(), CellMLToNektar.translators.CellMLTranslator.output_table_index_checking(), CellMLToNektar.translators.CellMLTranslator.output_top_boilerplate(), and CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_verify_state_variables().

882  def open_block(self, **kwargs):
883  """Open a new code block and increase indent."""
884  self.writeln('{', **kwargs)
self.set_indent(offset=1)
def CellMLToNektar.translators.CellMLTranslator.open_paren (   self,
  paren 
)

Definition at line 876 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator.write().

Referenced by CellMLToNektar.translators.CellMLTranslator.output_log(), CellMLToNektar.translators.CellMLTranslator.output_nary_operator(), CellMLToNektar.translators.CellMLTranslator.output_piecewise(), and CellMLToNektar.translators.CellMLTranslator.output_unary_operator().

877  def open_paren(self, paren):
if paren: self.write('(')
def CellMLToNektar.translators.CellMLTranslator.output_apply (   self,
  expr,
  paren 
)
Output an <apply> expression.

paren is True if the context has requested parentheses.

Definition at line 731 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator.binary_ops, CellMLToNektar.translators.CellMLTranslator.code_name(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.code_name(), CellMLToNektar.translators.CellMLTranslator.error(), CellMLToNektar.translators.CellMLTranslator.function_map, CellMLToNektar.translators.CellMLTranslator.nary_ops, CellMLToNektar.translators.CellMLTranslator.output_binary_operator(), CellMLToNektar.translators.CellMLTranslator.output_function(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_function(), CellMLToNektar.translators.CellMLTranslator.output_log(), CellMLToNektar.translators.CellMLTranslator.output_minus(), CellMLToNektar.translators.CellMLTranslator.output_nary_operator(), CellMLToNektar.translators.CellMLTranslator.output_root(), CellMLToNektar.translators.CellMLTranslator.recip_trig, and CellMLToNektar.translators.CellMLTranslator.write().

Referenced by CellMLToNektar.translators.CellMLTranslator.output_expr().

732  def output_apply(self, expr, paren):
733  """Output an <apply> expression.
734 
735  paren is True if the context has requested parentheses.
736  """
737  op = expr.operator()
738  if op.localName in self.function_map:
739  self.output_function(self.function_map[op.localName],
740  expr.operands(), paren)
741  elif op.localName in self.recip_trig:
742  self.output_function(self.function_map[self.recip_trig[op.localName]],
743  expr.operands(), paren, reciprocal=True)
744  elif op.localName == u'root':
745  self.output_root(expr, paren)
746  elif op.localName == u'log':
747  self.output_log(expr, paren)
748  elif op.localName in self.nary_ops:
749  self.output_nary_operator(self.nary_ops[op.localName],
750  expr.operands(), paren)
751  elif op.localName in self.binary_ops:
752  self.output_binary_operator(self.binary_ops[op.localName],
753  expr.operands(), paren, expr)
754  elif op.localName == u'minus':
755  self.output_minus(expr, paren)
756  elif op.localName == u'diff':
757  # ODE occuring on the RHS
758  self.write(self.code_name(op.dependent_variable, ode=True))
759  else:
760  # Unrecognised operator
761  self.error(["Unsupported operator element " + str(op.localName)], xml=expr)
def CellMLToNektar.translators.CellMLTranslator.output_assignment (   self,
  expr 
)
Output an assignment expression.

Definition at line 592 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator.code_name(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.code_name(), CellMLToNektar.pycml.description(), CellMLToNektar.translators.CellMLTranslator.EQ_ASSIGN, CellMLToNektar.translators.CellMLTranslator.output_comment(), CellMLToNektar.translators.CellMLTranslator.output_expr(), CellMLToNektar.translators.CellMLTranslator.output_lhs(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_lhs(), CellMLToNektar.translators.CellMLTranslator.output_number(), CellMLToNektar.translators.CellMLTranslator.STMT_END, CellMLToNektar.translators.CellMLTranslator.TYPE_CONST_DOUBLE, CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.TYPE_CONST_DOUBLE, CellMLToNektar.translators.CellMLTranslator.write(), and CellMLToNektar.translators.CellMLTranslator.writeln().

Referenced by CellMLToNektar.translators.CellMLTranslator.output_equations(), and CellMLToNektar.translators.CellMLTranslator.output_mathematics().

593  def output_assignment(self, expr):
594  """Output an assignment expression."""
595  if isinstance(expr, cellml_variable):
596  # self.writeln('Test')
597  # This may be the assignment of a mapped variable, or a constant
598  t = expr.get_type()
599  if t == VarTypes.Mapped:
600  # self.writeln(self.code_name(expr))
601  self.writeln(self.TYPE_CONST_DOUBLE, self.code_name(expr),
602  self.EQ_ASSIGN,
603  self.code_name(expr.get_source_variable()),
604  self.STMT_END, nl=False)
605  self.output_comment(expr.units, indent=False, pad=True)
606  elif t == VarTypes.Constant:
607  # self.writeln('Test')
608  # self.writeln(self.code_name(expr))
609 
610 
611  # setting various stim-parameters to zero, since Nektar uses its own stimulus
612  if 'stim_amplitude' in str(self.code_name(expr)):
613  self.writeln(self.TYPE_CONST_DOUBLE, self.code_name(expr),
614  self.EQ_ASSIGN, nl=False)
615  self.output_number(0)
616  self.writeln(self.STMT_END, indent=False, nl=False)
617  self.output_comment(expr.units, indent=False, pad=True)
618  else:
619  self.writeln(self.TYPE_CONST_DOUBLE, self.code_name(expr),
620  self.EQ_ASSIGN, nl=False)
621  self.output_number(expr.initial_value)
622  self.writeln(self.STMT_END, indent=False, nl=False)
623  self.output_comment(expr.units, indent=False, pad=True)
624  else:
625  # This is a mathematical expression
626  self.writeln(self.TYPE_CONST_DOUBLE, nl=False)
627  opers = expr.operands()
628  self.output_lhs(opers.next())
629  self.write(self.EQ_ASSIGN)
630  self.output_expr(opers.next(), False)
631  self.writeln(self.STMT_END, indent=False, nl=False)
632  #1365: add a comment with the LHS units
633  self.output_comment(expr._get_element_units(expr.eq.lhs, return_set=False).description(),
634  indent=False, pad=True)
string STMT_END
Various language tokens #.
Definition: translators.py:141
def CellMLToNektar.translators.CellMLTranslator.output_binary_operator (   self,
  operator,
  operands,
  paren,
  expr 
)
Output a binary operator.

As output_nary_operator, but checks that len(list(operands)) == 2.

Definition at line 802 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator.error(), and CellMLToNektar.translators.CellMLTranslator.output_nary_operator().

Referenced by CellMLToNektar.translators.CellMLTranslator.output_apply(), and CellMLToNektar.translators.CellMLTranslator.output_minus().

803  def output_binary_operator(self, operator, operands, paren, expr):
804  """Output a binary operator.
805 
806  As output_nary_operator, but checks that len(list(operands)) == 2.
807  """
808  operands = list(operands)
809  if len(operands) != 2:
810  self.error(["Binary operator" + operator +
811  "does not have 2 operands."], xml=expr)
812  self.output_nary_operator(operator, operands, paren)
def CellMLToNektar.translators.CellMLTranslator.output_bottom_boilerplate (   self)
Output bottom boilerplate

Definition at line 580 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator.close_block(), CellMLToNektar.translators.CellMLTranslator.code_name(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.code_name(), CellMLToNektar.translators.CellMLTranslator.set_indent(), CellMLToNektar.translators.CellMLTranslator.state_vars, and CellMLToNektar.translators.CellMLTranslator.writeln().

581  def output_bottom_boilerplate(self):
582  """Output bottom boilerplate"""
583  self.writeln('\n')
584  for i, var in enumerate(self.state_vars):
585  self.writeln('rDY[', str(i), '] = ', self.code_name(var, True),
586  ';')
587  self.close_block()
588  self.set_indent(offset=-1)
589  self.writeln('};\n')
590  self.writeln('#endif')
591  return
def CellMLToNektar.translators.CellMLTranslator.output_comment (   self,
  args,
  kwargs 
)
Output a (multi-line) string as a comment.

Definition at line 416 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator.COMMENT_START, and CellMLToNektar.translators.CellMLTranslator.writeln().

Referenced by CellMLToNektar.translators.CellMLTranslator.output_assignment(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_assignment(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_backward_euler_mathematics(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_constructor(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_derivative_calculations(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_derivative_calculations_grl(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_derived_quantities(), CellMLToNektar.translators.CellMLTranslator.output_doxygen(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_evaluate_y_derivatives(), CellMLToNektar.translators.CellMLTranslator.output_lut_declarations(), 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_serialize_method(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_state_assignments(), CellMLToNektar.translators.CellMLTranslator.output_table_index_generation(), and CellMLToNektar.translators.CellMLTranslator.output_top_boilerplate().

417  def output_comment(self, *args, **kwargs):
418  """Output a (multi-line) string as a comment."""
419  start = kwargs.get('start', self.COMMENT_START)
420  if kwargs.get('pad', False):
421  start = ' ' + start
422  comment = ''.join(map(str, args))
423  lines = comment.split('\n')
424  for line in lines:
425  self.writeln(start, line, **kwargs)
def CellMLToNektar.translators.CellMLTranslator.output_doxygen (   self,
  args,
  kwargs 
)
Output a (multi-line) string as a Doxygen comment.

Definition at line 426 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator.DOXYGEN_COMMENT_START, and CellMLToNektar.translators.CellMLTranslator.output_comment().

Referenced by CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_includes().

427  def output_doxygen(self, *args, **kwargs):
428  """Output a (multi-line) string as a Doxygen comment."""
429  kwargs['start'] = self.DOXYGEN_COMMENT_START
430  self.output_comment(*args, **kwargs)
def CellMLToNektar.translators.CellMLTranslator.output_equations (   self,
  nodeset 
)
Output the mathematics described by nodeset.

nodeset represents a subset of the assignments in the model.
Output assignments in the order given by a topological sort,
but only include those in nodeset.

Since a set of assignments is given, this method does not
check whether variables are used - it is assumed that only
assignments that are actually wanted are given in nodeset.

Definition at line 913 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator.output_assignment(), and CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_assignment().

Referenced by CellMLToNektar.translators.CellMLTranslator.output_table_index_generation().

914  def output_equations(self, nodeset):
915  """Output the mathematics described by nodeset.
916 
917  nodeset represents a subset of the assignments in the model.
918  Output assignments in the order given by a topological sort,
919  but only include those in nodeset.
920 
921  Since a set of assignments is given, this method does not
922  check whether variables are used - it is assumed that only
923  assignments that are actually wanted are given in nodeset.
924  """
925  for expr in (e for e in self.model.get_assignments() if e in nodeset):
926  self.output_assignment(expr)
927  return
def CellMLToNektar.translators.CellMLTranslator.output_expr (   self,
  expr,
  paren 
)
Output the expression expr.

If paren is True then the context has requested parentheses around the
output; if expr requires them then they will be added.

Definition at line 646 of file translators.py.

References CellMLToNektar.pycml.child_i(), CellMLToNektar.translators.CellMLTranslator.E, CellMLToNektar.translators.CellMLTranslator.error(), CellMLToNektar.translators.CellMLTranslator.FALSE, CellMLToNektar.translators.CellMLTranslator.is_lookup_table(), CellMLToNektar.translators.CellMLTranslator.output_apply(), CellMLToNektar.translators.CellMLTranslator.output_expr(), CellMLToNektar.translators.CellMLTranslator.output_number(), CellMLToNektar.translators.CellMLTranslator.output_piecewise(), CellMLToNektar.translators.CellMLTranslator.output_table_lookup(), CellMLToNektar.translators.CellMLTranslator.output_variable(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_variable(), CellMLToNektar.translators.CellMLTranslator.PI, CellMLToNektar.translators.CellMLTranslator.TRUE, CellMLToNektar.translators.CellMLTranslator.use_lookup_tables, CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.use_lookup_tables, and CellMLToNektar.translators.CellMLTranslator.write().

Referenced by CellMLToNektar.translators.CellMLTranslator.output_assignment(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_backward_euler_mathematics(), CellMLToNektar.translators.CellMLTranslator.output_expr(), CellMLToNektar.translators.CellMLTranslator.output_function(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_grl_compute_partial(), CellMLToNektar.translators.CellMLTranslator.output_log(), CellMLToNektar.translators.CellMLTranslator.output_lut_generation(), CellMLToNektar.translators.CellMLTranslator.output_nary_operator(), CellMLToNektar.translators.CellMLTranslator.output_piecewise(), CellMLToNektar.translators.CellMLTranslator.output_root(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_rush_larsen_mathematics(), and CellMLToNektar.translators.CellMLTranslator.output_unary_operator().

647  def output_expr(self, expr, paren):
648  """Output the expression expr.
649 
650  If paren is True then the context has requested parentheses around the
651  output; if expr requires them then they will be added.
652  """
653  if self.use_lookup_tables and self.is_lookup_table(expr):
654  self.output_table_lookup(expr, paren)
655  elif isinstance(expr, mathml_apply):
656  self.output_apply(expr, paren)
657  elif isinstance(expr, mathml_piecewise):
658  self.output_piecewise(expr, paren)
659  elif isinstance(expr, mathml_ci):
660  self.output_variable(expr)
661  elif expr.localName == u'cn':
662  self.output_number(expr)
663  elif expr.localName == u'degree':
664  # <degree> is just a wrapper around an expression
665  self.output_expr(child_i(expr, 1), paren)
666  elif expr.localName == u'logbase':
667  # <logbase> is just a wrapper around an expression
668  self.output_expr(child_i(expr, 1), paren)
669  elif expr.localName == u'true':
670  self.write(self.TRUE)
671  elif expr.localName == u'false':
672  self.write(self.FALSE)
673  elif expr.localName == u'pi':
674  self.write(self.PI)
675  elif expr.localName == u'exponentiale':
676  self.write(self.E)
677  else:
678  self.error(["Unsupported expression element " + expr.localName],
679  xml=expr)
def CellMLToNektar.translators.CellMLTranslator.output_file_name (   self,
  model_filename 
)
Generate a name for our output file, based on the input file.

Definition at line 324 of file translators.py.

325  def output_file_name(self, model_filename):
326  """Generate a name for our output file, based on the input file."""
327  return os.path.splitext(model_filename)[0] + '.cpp'
def CellMLToNektar.translators.CellMLTranslator.output_function (   self,
  func_name,
  args,
  paren,
  reciprocal = False 
)
Output a function call with name func_name and arguments args.

Parentheses are not required so paren is ignored.
If reciprocal is True then pass the reciprocal of each arg to
func_name.

Definition at line 762 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator.output_expr(), and CellMLToNektar.translators.CellMLTranslator.write().

Referenced by CellMLToNektar.translators.CellMLTranslator.output_apply(), CellMLToNektar.translators.CellMLTranslator.output_log(), and CellMLToNektar.translators.CellMLTranslator.output_root().

763  def output_function(self, func_name, args, paren, reciprocal=False):
764  """Output a function call with name func_name and arguments args.
765 
766  Parentheses are not required so paren is ignored.
767  If reciprocal is True then pass the reciprocal of each arg to
768  func_name.
769  """
770  self.write(func_name + '(')
771  comma = False
772  for arg in args:
773  if comma: self.write(', ')
774  else: comma = True
775  if reciprocal:
776  self.write('1/')
777  self.output_expr(arg, True)
778  else:
779  self.output_expr(arg, False)
780  self.write(')')
def CellMLToNektar.translators.CellMLTranslator.output_lhs (   self,
  expr 
)
Output the left hand side of an assignment expression.

Definition at line 635 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator.code_name(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.code_name(), CellMLToNektar.translators.CellMLTranslator.output_variable(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_variable(), and CellMLToNektar.translators.CellMLTranslator.write().

Referenced by CellMLToNektar.translators.CellMLTranslator.output_assignment().

636  def output_lhs(self, expr):
637  """Output the left hand side of an assignment expression."""
638  if expr.localName == 'ci':
639  self.output_variable(expr)
640  elif expr.operator().localName == 'diff':
641  self.write(self.code_name(expr.operator().dependent_variable, ode=True))
def CellMLToNektar.translators.CellMLTranslator.output_log (   self,
  expr,
  paren 
)
Output a logarithm to the given base, which defaults to base 10.

Definition at line 833 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator.close_paren(), CellMLToNektar.translators.CellMLTranslator.open_paren(), CellMLToNektar.translators.CellMLTranslator.output_expr(), CellMLToNektar.translators.CellMLTranslator.output_function(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_function(), and CellMLToNektar.translators.CellMLTranslator.write().

Referenced by CellMLToNektar.translators.CellMLTranslator.output_apply().

834  def output_log(self, expr, paren):
835  """Output a logarithm to the given base, which defaults to base 10."""
836  if hasattr(expr, u'logbase'):
837  # A base is provided. Use the identity log_b(x) = log(x)/log(b)
838  # TODO: Optimise for log2(x)
839  self.open_paren(paren)
840  self.output_function('log', expr.operands(), paren)
841  self.write('/log(')
842  self.output_expr(expr.logbase, False)
843  self.write(')')
844  self.close_paren(paren)
845  else:
846  # Use base 10
847  self.output_function('log10', expr.operands(), paren)
def CellMLToNektar.translators.CellMLTranslator.output_lut_declarations (   self)
Output declarations for the lookup tables.

Definition at line 1126 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator.output_comment(), CellMLToNektar.translators.CellMLTranslator.STMT_END, CellMLToNektar.translators.CellMLTranslator.TYPE_DOUBLE, CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.TYPE_DOUBLE, and CellMLToNektar.translators.CellMLTranslator.writeln().

Referenced by CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_chaste_lut_methods(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_lut_class(), and CellMLToNektar.translators.CellMLTranslator.output_top_boilerplate().

1127  def output_lut_declarations(self):
1128  """Output declarations for the lookup tables."""
1129  self.output_comment('Lookup tables')
1130  # Allocate memory, per index variable for cache efficiency
1131  for idx in self.doc.lookup_table_indexes.itervalues():
1132  num_tables = unicode(self.doc.lookup_tables_num_per_index[idx])
1133  self.writeln(self.TYPE_DOUBLE, '(*_lookup_table_', idx, ')[', num_tables, ']', self.STMT_END)
1134  self.writeln()
string STMT_END
Various language tokens #.
Definition: translators.py:141
def CellMLToNektar.translators.CellMLTranslator.output_lut_deletion (   self,
  only_index = None 
)
Output code to delete memory allocated for lookup tables.

Definition at line 1116 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator.close_block(), CellMLToNektar.translators.CellMLTranslator.EQ_ASSIGN, CellMLToNektar.translators.CellMLTranslator.open_block(), CellMLToNektar.translators.CellMLTranslator.STMT_END, and CellMLToNektar.translators.CellMLTranslator.writeln().

Referenced by CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_lut_class(), and CellMLToNektar.translators.CellMLTranslator.output_top_boilerplate().

1117  def output_lut_deletion(self, only_index=None):
1118  """Output code to delete memory allocated for lookup tables."""
1119  for idx in self.doc.lookup_table_indexes.itervalues():
1120  if only_index is None or only_index == idx:
1121  self.writeln('if (_lookup_table_', idx, ')')
1122  self.open_block()
1123  self.writeln('delete[] _lookup_table_', idx, self.STMT_END)
1124  self.writeln('_lookup_table_', idx, self.EQ_ASSIGN, 'NULL', self.STMT_END)
1125  self.close_block(blank_line=False)
string STMT_END
Various language tokens #.
Definition: translators.py:141
def CellMLToNektar.translators.CellMLTranslator.output_lut_generation (   self,
  only_index = None 
)
Output code to generate lookup tables.

There should be a list of suitable expressions available as self.doc.lookup_tables,
to save having to search the whole model.

If only_index is given, only generate tables using the given table index key.

Definition at line 1079 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator.close_block(), CellMLToNektar.translators.CellMLTranslator.code_name(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.code_name(), CellMLToNektar.translators.CellMLTranslator.EQ_ASSIGN, CellMLToNektar.translators.CellMLTranslator.lut_access_code(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.lut_parameters(), CellMLToNektar.translators.CellMLTranslator.lut_parameters(), CellMLToNektar.translators.CellMLTranslator.lut_size_calculation(), CellMLToNektar.translators.CellMLTranslator.open_block(), CellMLToNektar.translators.CellMLTranslator.output_expr(), CellMLToNektar.translators.CellMLTranslator.STMT_END, CellMLToNektar.translators.CellMLTranslator.TYPE_CONST_DOUBLE, CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.TYPE_CONST_DOUBLE, CellMLToNektar.translators.CellMLTranslator.TYPE_CONST_UNSIGNED, CellMLToNektar.translators.CellMLTranslator.use_lookup_tables, CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.use_lookup_tables, and CellMLToNektar.translators.CellMLTranslator.writeln().

Referenced by CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_constructor(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_lut_class(), and CellMLToNektar.translators.CellMLTranslator.output_top_boilerplate().

1080  def output_lut_generation(self, only_index=None):
1081  """Output code to generate lookup tables.
1082 
1083  There should be a list of suitable expressions available as self.doc.lookup_tables,
1084  to save having to search the whole model.
1085 
1086  If only_index is given, only generate tables using the given table index key.
1087  """
1088  # Don't use table lookups to generate the tables!
1089  self.use_lookup_tables = False
1090  # Allocate memory for tables
1091  for key, idx in self.doc.lookup_table_indexes.iteritems():
1092  if only_index is None or only_index == idx:
1093  min, max, step, _ = self.lut_parameters(key)
1094  self.writeln(self.TYPE_CONST_UNSIGNED, '_table_size_', idx, self.EQ_ASSIGN,
1095  self.lut_size_calculation(min, max, step), self.STMT_END)
1096  self.writeln('_lookup_table_', idx, self.EQ_ASSIGN, 'new double[_table_size_', idx,
1097  '][', self.doc.lookup_tables_num_per_index[idx], ']', self.STMT_END)
1098  # Generate each table in a separate loop
1099  for expr in self.doc.lookup_tables:
1100  var = expr.component.get_variable_by_name(expr.var)
1101  key = (expr.min, expr.max, expr.step, var.get_source_variable(recurse=True))
1102  idx = self.doc.lookup_table_indexes[key]
1103  if only_index is not None and only_index != idx:
1104  continue
1105  min, max, step, _ = self.lut_parameters(key)
1106  j = expr.table_name
1107  self.writeln('for (unsigned i=0 ; i<_table_size_', idx, '; i++)')
1108  self.open_block()
1109  self.writeln(self.TYPE_CONST_DOUBLE, self.code_name(var), self.EQ_ASSIGN, min,
1110  ' + i*', step, self.STMT_END)
1111  self.writeln(self.lut_access_code(idx, j, 'i'), self.EQ_ASSIGN, nl=False)
1112  self.output_expr(expr, False)
1113  self.writeln(self.STMT_END, indent=False)
1114  self.close_block()
1115  self.use_lookup_tables = True
string STMT_END
Various language tokens #.
Definition: translators.py:141
def CellMLToNektar.translators.CellMLTranslator.output_lut_index_declarations (   self,
  idx 
)
Output declarations the variables used to index this table.

Definition at line 1135 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator.lut_factor(), CellMLToNektar.translators.CellMLTranslator.row_lookup_method, CellMLToNektar.translators.CellMLTranslator.STMT_END, and CellMLToNektar.translators.CellMLTranslator.writeln().

Referenced by CellMLToNektar.translators.CellMLTranslator.output_lut_indices().

1136  def output_lut_index_declarations(self, idx):
1137  """Output declarations the variables used to index this table."""
1138  self.writeln('unsigned _table_index_', idx, self.STMT_END)
1139  factor = self.lut_factor(idx, include_type=True)
1140  if factor:
1141  self.writeln(factor, self.STMT_END)
1142  if self.row_lookup_method:
1143  self.writeln('double* _lt_', idx, '_row', self.STMT_END)
string STMT_END
Various language tokens #.
Definition: translators.py:141
def CellMLToNektar.translators.CellMLTranslator.output_lut_indices (   self)
Output declarations for the lookup table indices.

Definition at line 1144 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator.output_comment(), CellMLToNektar.translators.CellMLTranslator.output_lut_index_declarations(), and CellMLToNektar.translators.CellMLTranslator.writeln().

1145  def output_lut_indices(self):
1146  """Output declarations for the lookup table indices."""
1147  self.output_comment('Lookup table indices')
1148  for idx in self.doc.lookup_table_indexes.itervalues():
1150  self.writeln()
def CellMLToNektar.translators.CellMLTranslator.output_lut_methods (   self)
Output the methods which look up values from lookup tables.

Definition at line 1151 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator.close_block(), CellMLToNektar.translators.CellMLTranslator.lut_factor(), CellMLToNektar.translators.CellMLTranslator.open_block(), CellMLToNektar.translators.CellMLTranslator.output_comment(), CellMLToNektar.translators.CellMLTranslator.output_lut_row_lookup_methods(), CellMLToNektar.translators.CellMLTranslator.output_single_lookup(), CellMLToNektar.translators.CellMLTranslator.row_lookup_method, and CellMLToNektar.translators.CellMLTranslator.writeln().

Referenced by CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_chaste_lut_methods(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_lut_class(), and CellMLToNektar.translators.CellMLTranslator.output_top_boilerplate().

1152  def output_lut_methods(self):
1153  """Output the methods which look up values from lookup tables."""
1154  if self.row_lookup_method:
1156  return
1157  self.output_comment('Methods to look up values from lookup tables')
1158  self.output_comment('using ', self.config.options.lookup_type)
1159  for expr in self.doc.lookup_tables:
1160  j = expr.table_name
1161  idx = expr.table_index
1162  self.writeln('inline double _lookup_', j, '(unsigned i',
1163  self.lut_factor('', include_type=True, include_comma=True), ')')
1164  self.open_block()
1165  self.output_single_lookup(idx, j, 'return ')
1166  self.close_block()
1167  self.writeln()
1168  return
def CellMLToNektar.translators.CellMLTranslator.output_lut_row_lookup_memory (   self)
Output declarations for the memory used by the row lookup methods.

Definition at line 1204 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator.output_comment(), and CellMLToNektar.translators.CellMLTranslator.writeln().

Referenced by CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_chaste_lut_methods(), and CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_lut_class().

1205  def output_lut_row_lookup_memory(self):
1206  """Output declarations for the memory used by the row lookup methods."""
1207  self.output_comment('Row lookup methods memory')
1208  for key, idx in self.doc.lookup_table_indexes.iteritems():
1209  min, max, step, var = key
1210  num_tables = unicode(self.doc.lookup_tables_num_per_index[idx])
1211  self.writeln('double _lookup_table_', idx, '_row[', num_tables, '];')
1212  self.writeln()
1213  return
def CellMLToNektar.translators.CellMLTranslator.output_lut_row_lookup_methods (   self)
Write methods that return a whole row of a lookup table.

Note: assumes that table names are numbered sequentially from 0.

Definition at line 1183 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator.close_block(), CellMLToNektar.translators.CellMLTranslator.lut_factor(), CellMLToNektar.translators.CellMLTranslator.open_block(), CellMLToNektar.translators.CellMLTranslator.output_comment(), CellMLToNektar.translators.CellMLTranslator.output_single_lookup(), and CellMLToNektar.translators.CellMLTranslator.writeln().

Referenced by CellMLToNektar.translators.CellMLTranslator.output_lut_methods().

1185  """Write methods that return a whole row of a lookup table.
1186 
1187  Note: assumes that table names are numbered sequentially from 0.
1188  """
1189  self.output_comment('Row lookup methods')
1190  self.output_comment('using ', self.config.options.lookup_type)
1191  for key, idx in self.doc.lookup_table_indexes.iteritems():
1192  num_tables = unicode(self.doc.lookup_tables_num_per_index[idx])
1193  self.writeln('double* _lookup_', idx, '_row(unsigned i',
1194  self.lut_factor('', include_type=True, include_comma=True), ')')
1195  self.open_block()
1196  self.writeln('for (unsigned j=0; j<', num_tables, '; j++)')
1197  self.open_block()
1198  self.output_single_lookup(idx, 'j', '_lookup_table_%s_row[j] = ' % idx)
1199  self.close_block(False)
1200  self.writeln('return _lookup_table_', idx, '_row;')
1201  self.close_block()
1202  self.writeln()
1203  return
def CellMLToNektar.translators.CellMLTranslator.output_mathematics (   self)
Output the mathematics in this model.

Definition at line 566 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator.COMMENT_START, CellMLToNektar.translators.CellMLTranslator.output_assignment(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_assignment(), and CellMLToNektar.translators.CellMLTranslator.writeln().

567  def output_mathematics(self):
568  """Output the mathematics in this model."""
569  self.writeln(self.COMMENT_START, 'Mathematics')
570  for expr in self.model.get_assignments():
571  # Check this expression is actually used; don't output if not
572  var = None
573  if isinstance(expr, mathml_apply) and expr.is_assignment():
574  var = expr.assigned_variable()
575  elif isinstance(expr, cellml_variable):
576  var = expr
577  if not (var and var.get_usage_count() == 0):
578  self.output_assignment(expr)
579  return
def CellMLToNektar.translators.CellMLTranslator.output_minus (   self,
  expr,
  paren 
)
Output either a unary or binary minus.

Which is chosen depends on the number of operands.

Definition at line 848 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator.output_binary_operator(), and CellMLToNektar.translators.CellMLTranslator.output_unary_operator().

Referenced by CellMLToNektar.translators.CellMLTranslator.output_apply().

849  def output_minus(self, expr, paren):
850  """Output either a unary or binary minus.
851 
852  Which is chosen depends on the number of operands.
853  """
854  operands = list(expr.operands())
855  if len(operands) == 1:
856  self.output_unary_operator('-', operands[0], paren)
857  else:
858  self.output_binary_operator('-', operands, paren, expr)
def CellMLToNektar.translators.CellMLTranslator.output_nary_operator (   self,
  operator,
  operands,
  paren 
)
Output an n-ary operator (using infix notation).

If paren is True, enclose the output in parentheses.

Definition at line 781 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator.close_paren(), CellMLToNektar.translators.CellMLTranslator.open_paren(), CellMLToNektar.translators.CellMLTranslator.output_expr(), and CellMLToNektar.translators.CellMLTranslator.write().

Referenced by CellMLToNektar.translators.CellMLTranslator.output_apply(), and CellMLToNektar.translators.CellMLTranslator.output_binary_operator().

782  def output_nary_operator(self, operator, operands, paren):
783  """Output an n-ary operator (using infix notation).
784 
785  If paren is True, enclose the output in parentheses.
786  """
787  # TODO: Optimise - to use expm1(x) for computing exp(x)-1
788  self.open_paren(paren)
789  op = False
790  for operand in operands:
791  if op: self.write(' ' + operator + ' ')
792  else: op = True
793  self.output_expr(operand, True)
794  self.close_paren(paren)
def CellMLToNektar.translators.CellMLTranslator.output_number (   self,
  expr 
)
Output the plain number expr.

We make all constants parse as doubles to avoid problems with
integer division or numbers too large for the int type.

Negative numbers will be prefixed by a space to avoid unwanted
decrement operations.

Definition at line 680 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator.eval_number(), and CellMLToNektar.translators.CellMLTranslator.write().

Referenced by CellMLToNektar.translators.CellMLTranslator.output_assignment(), and CellMLToNektar.translators.CellMLTranslator.output_expr().

681  def output_number(self, expr):
682  """Output the plain number expr.
683 
684  We make all constants parse as doubles to avoid problems with
685  integer division or numbers too large for the int type.
686 
687  Negative numbers will be prefixed by a space to avoid unwanted
688  decrement operations.
689  """
690  n = self.eval_number(expr)
691  num = "%.17g" % n
692  if num[0] == '-':
693  num = ' ' + num
694  if not '.' in num and not 'e' in num:
695  num = num + '.0'
696  self.write(num)
def CellMLToNektar.translators.CellMLTranslator.output_piecewise (   self,
  expr,
  paren 
)
Output the piecewise expression expr.

We use a cascading ternary if expression for simplicity.

Definition at line 859 of file translators.py.

References CellMLToNektar.pycml.child_i(), CellMLToNektar.translators.CellMLTranslator.close_paren(), CellMLToNektar.translators.CellMLTranslator.NOT_A_NUMBER, CellMLToNektar.translators.CellMLTranslator.open_paren(), CellMLToNektar.translators.CellMLTranslator.output_expr(), and CellMLToNektar.translators.CellMLTranslator.write().

Referenced by CellMLToNektar.translators.CellMLTranslator.output_expr().

860  def output_piecewise(self, expr, paren):
861  """Output the piecewise expression expr.
862 
863  We use a cascading ternary if expression for simplicity.
864  """
865  self.open_paren(paren)
866  for piece in getattr(expr, u'piece', []):
867  self.output_expr(child_i(piece, 2), True) # Condition
868  self.write(' ? ')
869  self.output_expr(child_i(piece, 1), True) # Result
870  self.write(' : ')
871  if hasattr(expr, u'otherwise'):
872  self.output_expr(child_i(expr.otherwise, 1), True) # Default case
873  else:
874  self.write(self.NOT_A_NUMBER)
875  self.close_paren(paren)
def CellMLToNektar.translators.CellMLTranslator.output_root (   self,
  expr,
  paren 
)
Output a root taken to some degree.

If a degree qualifier element is not provided, uses default 2.

Definition at line 814 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator.output_expr(), CellMLToNektar.translators.CellMLTranslator.output_function(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_function(), and CellMLToNektar.translators.CellMLTranslator.write().

Referenced by CellMLToNektar.translators.CellMLTranslator.output_apply().

815  def output_root(self, expr, paren):
816  """Output a root taken to some degree.
817 
818  If a degree qualifier element is not provided, uses default 2.
819  """
820  if hasattr(expr, u'degree'):
821  # A degree is given. Compute x^(1/b)
822  # TODO: Optimise for when b==2 (sqrt) or b==3 (cbrt)
823  # Try to evaluate expr.degree, and if the result is a key
824  # of self.special_roots, use the value as the function to call.
825  self.write('pow(')
826  self.output_expr(expr.operands().next(), False)
827  self.write(', 1/')
828  self.output_expr(expr.degree, True)
829  self.write(')')
830  else:
831  # Compute square root
832  self.output_function('sqrt', expr.operands(), paren)
def CellMLToNektar.translators.CellMLTranslator.output_single_lookup (   self,
  tidx,
  tname,
  result 
)
Write the lookup calculation for a single entry.

Used by output_lut_row_lookup_methods and output_lut_methods.

Definition at line 1169 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator.EQ_ASSIGN, CellMLToNektar.translators.CellMLTranslator.lut_access_code(), CellMLToNektar.translators.CellMLTranslator.lut_factor(), CellMLToNektar.translators.CellMLTranslator.STMT_END, CellMLToNektar.translators.CellMLTranslator.TYPE_CONST_DOUBLE, CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.TYPE_CONST_DOUBLE, and CellMLToNektar.translators.CellMLTranslator.writeln().

Referenced by CellMLToNektar.translators.CellMLTranslator.output_lut_methods(), and CellMLToNektar.translators.CellMLTranslator.output_lut_row_lookup_methods().

1170  def output_single_lookup(self, tidx, tname, result):
1171  """Write the lookup calculation for a single entry.
1172 
1173  Used by output_lut_row_lookup_methods and output_lut_methods.
1174  """
1175  self.writeln(self.TYPE_CONST_DOUBLE, 'y1', self.EQ_ASSIGN,
1176  self.lut_access_code(tidx, tname, 'i'), self.STMT_END)
1177  if self.config.options.lookup_type == 'linear-interpolation':
1178  self.writeln(self.TYPE_CONST_DOUBLE, 'y2', self.EQ_ASSIGN,
1179  self.lut_access_code(tidx, tname, 'i+1'), self.STMT_END)
1180  self.writeln(result, 'y1 + (y2-y1)*', self.lut_factor(''), self.STMT_END)
1181  else:
1182  self.writeln(result, 'y1', self.STMT_END)
string STMT_END
Various language tokens #.
Definition: translators.py:141
def CellMLToNektar.translators.CellMLTranslator.output_table_index_checking (   self,
  key,
  idx 
)
Check whether a table index is out of bounds.

Definition at line 1302 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator.close_block(), CellMLToNektar.translators.CellMLTranslator.code_name(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.code_name(), CellMLToNektar.translators.CellMLTranslator.constrain_table_indices, CellMLToNektar.translators.CellMLTranslator.EQ_ASSIGN, CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.lut_parameters(), CellMLToNektar.translators.CellMLTranslator.lut_parameters(), CellMLToNektar.translators.CellMLTranslator.open_block(), CellMLToNektar.translators.CellMLTranslator.STMT_END, and CellMLToNektar.translators.CellMLTranslator.writeln().

Referenced by CellMLToNektar.translators.CellMLTranslator.output_table_index_generation().

1303  def output_table_index_checking(self, key, idx):
1304  """Check whether a table index is out of bounds."""
1305  if self.config.options.check_lt_bounds:
1306  var = key[-1]
1307  min, max, _, _ = self.lut_parameters(key)
1308  varname = self.code_name(var)
1309  self.writeln('bool _oob_', idx, self.EQ_ASSIGN, 'false', self.STMT_END)
1310  self.writeln('if (', varname, '>', max, ' || ', varname, '<', min, ')')
1311  self.open_block()
1312  self.writeln('#define COVERAGE_IGNORE', indent=False)
1313  if self.constrain_table_indices:
1314  self.writeln('if (', varname, '>', max, ') ', varname, self.EQ_ASSIGN, max, self.STMT_END)
1315  self.writeln('else ', varname, self.EQ_ASSIGN, min, self.STMT_END)
1316  else:
1317  self.writeln('_oob_', idx, self.EQ_ASSIGN, 'true', self.STMT_END)
1318  self.writeln('#undef COVERAGE_IGNORE', indent=False)
1319  self.close_block(blank_line=False)
string STMT_END
Various language tokens #.
Definition: translators.py:141
def CellMLToNektar.translators.CellMLTranslator.output_table_index_generation (   self,
  time_name,
  nodeset = set() 
)
Output code to calculate indexes into any lookup tables.

If time_name is given and table bounds are being checked, the time value will be included in the
error message.  Note that we need to pass it in, since in some contexts the free variable is not
defined.

If nodeset is given, then filter the table indices calculated so
that only those needed to compute the nodes in nodeset are defined.

A nodeset is required if any table indices are computed variables rather than state variables.
In this case, we use the equations within nodeset to calculate the values of the indices, and
return a set containing just those nodes used, so we can avoid recalculating them later.

Definition at line 1258 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator.calculate_extended_dependencies(), CellMLToNektar.pycml.cellml_model.calculate_extended_dependencies(), CellMLToNektar.translators.CellMLTranslator.contained_table_indices(), CellMLToNektar.translators.CellMLTranslator.output_comment(), CellMLToNektar.translators.CellMLTranslator.output_equations(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_equations(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_table_index_checking(), CellMLToNektar.translators.CellMLTranslator.output_table_index_checking(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_table_index_generation_code(), CellMLToNektar.translators.CellMLTranslator.output_table_index_generation_code(), CellMLToNektar.translators.CellMLTranslator.var_display_name(), and CellMLToNektar.translators.CellMLTranslator.writeln().

Referenced by CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.calculate_lookup_table_indices(), and CellMLToNektar.translators.CellMLTranslator.output_top_boilerplate().

1259  def output_table_index_generation(self, time_name, nodeset=set()):
1260  """Output code to calculate indexes into any lookup tables.
1261 
1262  If time_name is given and table bounds are being checked, the time value will be included in the
1263  error message. Note that we need to pass it in, since in some contexts the free variable is not
1264  defined.
1265 
1266  If nodeset is given, then filter the table indices calculated so
1267  that only those needed to compute the nodes in nodeset are defined.
1268 
1269  A nodeset is required if any table indices are computed variables rather than state variables.
1270  In this case, we use the equations within nodeset to calculate the values of the indices, and
1271  return a set containing just those nodes used, so we can avoid recalculating them later.
1272  """
1273  tables_to_index = set()
1274  nodes_used = set()
1275  for node in nodeset:
1276  tables_to_index.update(self.contained_table_indices(node))
1277  if tables_to_index or not nodeset:
1278  self.output_comment('Lookup table indexing')
1279  for key, idx in self.doc.lookup_table_indexes.iteritems():
1280  if not nodeset or idx in tables_to_index:
1281  var = key[-1]
1282  if var.get_type() is VarTypes.Computed:
1283  if not nodeset:
1284  raise TranslationError('Unable to generate lookup table indexed on', var, 'as it is a computed variable')
1285  var_nodes = self.calculate_extended_dependencies([var]) & nodeset
1286  self.output_equations(var_nodes)
1287  nodes_used.update(var_nodes)
1288  self.output_table_index_checking(key, idx)
1289  if self.config.options.check_lt_bounds:
1290  self.writeln('#define COVERAGE_IGNORE', indent=False)
1291  self.writeln('if (_oob_', idx, ')')
1292  if time_name is None:
1293  dump_state_args = 'rY'
1294  else:
1295  dump_state_args = 'rY, ' + time_name
1296  self.writeln('EXCEPTION(DumpState("', self.var_display_name(key[-1]),
1297  ' outside lookup table range", ', dump_state_args,'));', indent_offset=1)
1298  self.writeln('#undef COVERAGE_IGNORE', indent=False)
1299  self.output_table_index_generation_code(key, idx)
1300  self.writeln()
1301  return nodes_used
def calculate_extended_dependencies
Dependency related methods #.
Definition: translators.py:899
def CellMLToNektar.translators.CellMLTranslator.output_table_index_generation_code (   self,
  key,
  idx 
)
Method called by output_table_index_generation to output the code for a single table.

Definition at line 1320 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator.code_name(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.code_name(), CellMLToNektar.translators.CellMLTranslator.EQ_ASSIGN, CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.lookup_method_prefix, CellMLToNektar.translators.CellMLTranslator.lookup_method_prefix, CellMLToNektar.translators.CellMLTranslator.lt_index_uses_floor, CellMLToNektar.translators.CellMLTranslator.lut_factor(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.lut_parameters(), CellMLToNektar.translators.CellMLTranslator.lut_parameters(), CellMLToNektar.translators.CellMLTranslator.row_lookup_method, CellMLToNektar.translators.CellMLTranslator.STMT_END, CellMLToNektar.translators.CellMLTranslator.TYPE_CONST_DOUBLE, CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.TYPE_CONST_DOUBLE, and CellMLToNektar.translators.CellMLTranslator.writeln().

Referenced by CellMLToNektar.translators.CellMLTranslator.output_table_index_generation().

1321  def output_table_index_generation_code(self, key, idx):
1322  """Method called by output_table_index_generation to output the code for a single table."""
1323  index_type = 'const unsigned '
1324  factor_type = 'const double '
1325  row_type = 'const double* const '
1326  var = key[-1]
1327  min, max, _, step_inverse = self.lut_parameters(key)
1328  offset = '_offset_' + idx
1329  offset_over_step = offset + '_over_table_step'
1330  varname = self.code_name(var)
1331  self.writeln(self.TYPE_CONST_DOUBLE, offset, self.EQ_ASSIGN, varname, ' - ', min, self.STMT_END)
1332  self.writeln(self.TYPE_CONST_DOUBLE, offset_over_step, self.EQ_ASSIGN,
1333  offset, ' * ', step_inverse, self.STMT_END)
1334  idx_var = '_table_index_' + str(idx)
1335  if self.config.options.lookup_type == 'nearest-neighbour':
1336  if self.lt_index_uses_floor:
1337  self.writeln(index_type, idx_var, ' = (unsigned) round(', offset_over_step, ');')
1338  else:
1339  self.writeln(index_type, idx_var, ' = (unsigned) (', offset_over_step, '+0.5);')
1340  else:
1341  if self.lt_index_uses_floor:
1342  self.writeln(index_type, idx_var, ' = (unsigned) floor(', offset_over_step, ');')
1343  else:
1344  self.writeln(index_type, idx_var, ' = (unsigned)(', offset_over_step, ');')
1345  factor = self.lut_factor(idx)
1346  if factor:
1347  self.writeln(factor_type, factor, ' = ', offset_over_step, ' - ', idx_var, self.STMT_END)
1348  if self.row_lookup_method:
1349  self.writeln(row_type, '_lt_', idx, '_row = ', self.lookup_method_prefix, '_lookup_', idx,
1350  '_row(', idx_var, self.lut_factor(idx, include_comma=True), ');')
1351 
1352 
1353 
string STMT_END
Various language tokens #.
Definition: translators.py:141
def CellMLToNektar.translators.CellMLTranslator.output_table_lookup (   self,
  expr,
  paren 
)
Output code to look up expr in the appropriate table.

Definition at line 1248 of file translators.py.

References CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.lookup_method_prefix, CellMLToNektar.translators.CellMLTranslator.lookup_method_prefix, CellMLToNektar.translators.CellMLTranslator.lut_factor(), CellMLToNektar.translators.CellMLTranslator.row_lookup_method, and CellMLToNektar.translators.CellMLTranslator.write().

Referenced by CellMLToNektar.translators.CellMLTranslator.output_expr().

1249  def output_table_lookup(self, expr, paren):
1250  """Output code to look up expr in the appropriate table."""
1251  i = expr.table_index
1252  if self.row_lookup_method:
1253  self.write('_lt_', i, '_row[', expr.table_name, ']')
1254  else:
1255  self.write(self.lookup_method_prefix, '_lookup_', expr.table_name,
1256  '(_table_index_', i, self.lut_factor(i, include_comma=True), ')')
1257  return
def CellMLToNektar.translators.CellMLTranslator.output_top_boilerplate (   self)
Output top boilerplate.

Definition at line 495 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator.add_timestamp, CellMLToNektar.translators.CellMLTranslator.class_name, CellMLToNektar.translators.CellMLTranslator.close_block(), CellMLToNektar.translators.CellMLTranslator.code_name(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.code_name(), CellMLToNektar.translators.CellMLTranslator.free_vars, CellMLToNektar.translators.CellMLTranslator.include_guard(), CellMLToNektar.translators.CellMLTranslator.NOT_A_NUMBER, CellMLToNektar.translators.CellMLTranslator.open_block(), CellMLToNektar.translators.CellMLTranslator.output_comment(), CellMLToNektar.translators.CellMLTranslator.output_lut_declarations(), CellMLToNektar.translators.CellMLTranslator.output_lut_deletion(), CellMLToNektar.translators.CellMLTranslator.output_lut_generation(), CellMLToNektar.translators.CellMLTranslator.output_lut_methods(), CellMLToNektar.translators.CellMLTranslator.output_table_index_generation(), CellMLToNektar.translators.CellMLTranslator.set_indent(), CellMLToNektar.translators.CellMLTranslator.state_vars, CellMLToNektar.translators.CellMLTranslator.use_lookup_tables, CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.use_lookup_tables, CellMLToNektar.translators.CellMLTranslator.v_index, CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.v_index, CellMLToNektar.translators.version_comment(), and CellMLToNektar.translators.CellMLTranslator.writeln().

496  def output_top_boilerplate(self):
497  """Output top boilerplate."""
498  self.writeln('#ifndef _', self.include_guard, '_')
499  self.writeln('#define _', self.include_guard, '_\n')
500  self.output_comment('Model: ', self.model.name)
502  self.writeln()
503  self.writeln('#include <cmath>')
504  self.writeln('#include "AbstractOdeSystem.hpp"')
505  self.writeln('#include "Exception.hpp"')
506  self.writeln('#include "AbstractStimulusFunction.hpp"\n')
507  self.writeln('class ', self.class_name, ' : public AbstractOdeSystem')
508  self.writeln('{')
509  self.writeln('private:')
510  self.writeln('AbstractStimulusFunction *mpStimulus;\n',
511  indent_offset=1)
512  self.writeln('public:')
513  self.set_indent(1)
514  self.writeln('const static unsigned _NB_OF_STATE_VARIABLES_ = ',
515  str(len(self.state_vars)), ';\n')
516  self.writeln('//', ('-'*66))
517  self.writeln('// Methods')
518  self.writeln('//', ('-'*66), '\n')
519  # Constructor
520  self.writeln('', self.class_name,
521  '(AbstractStimulusFunction *stim)')
522  self.writeln(' : AbstractOdeSystem(_NB_OF_STATE_VARIABLES_, ',
523  self.v_index, ')')
524  self.open_block()
525  self.writeln('mpStimulus = stim;\n')
526  for var in self.state_vars:
527  self.writeln('mVariableNames.push_back("', var.name, '");')
528  self.writeln('mVariableUnits.push_back("', var.units, '");')
529  init_val = getattr(var, u'initial_value', None)
530  if init_val is None:
531  init_comm = ' // Value not given in model'
532  # Don't want compiler error, but shouldn't be a real number
533  init_val = self.NOT_A_NUMBER
534  else:
535  init_comm = ''
536  self.writeln('mInitialConditions.push_back(', init_val, ');',
537  init_comm, '\n')
539  self.close_block()
540  # Destructor
541  self.writeln('~', self.class_name, '(void)')
542  self.open_block()
543  if self.use_lookup_tables: self.output_lut_deletion()
544  self.close_block()
545  # Lookup table declarations & methods
546  if self.use_lookup_tables:
548  self.output_lut_methods()
549  # Evaluation function
550  self.writeln('void EvaluateYDerivatives (')
551  self.writeln(' double ', self.code_name(self.free_vars[0]), ',')
552  self.writeln(' const std::vector<double> &rY,')
553  self.writeln(' std::vector<double> &rDY)')
554  self.open_block()
555  self.writeln('// Inputs:')
556  self.writeln('// Time units: ', self.free_vars[0].units)
557  for i, var in enumerate(self.state_vars):
558  self.writeln('double ', self.code_name(var),
559  ' = rY[', str(i), '];')
560  self.writeln('// Units: ', var.units, '; Initial value: ',
561  getattr(var, u'initial_value', 'Unknown'))
562  self.writeln()
563  if self.use_lookup_tables:
565  return
def CellMLToNektar.translators.CellMLTranslator.output_unary_operator (   self,
  operator,
  operand,
  paren 
)
Output a unary operator (using prefix notation).

Definition at line 795 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator.close_paren(), CellMLToNektar.translators.CellMLTranslator.open_paren(), CellMLToNektar.translators.CellMLTranslator.output_expr(), and CellMLToNektar.translators.CellMLTranslator.write().

Referenced by CellMLToNektar.translators.CellMLTranslator.output_minus().

796  def output_unary_operator(self, operator, operand, paren):
797  """Output a unary operator (using prefix notation)."""
798  self.open_paren(paren)
799  self.write(operator)
800  self.output_expr(operand, True)
801  self.close_paren(paren)
def CellMLToNektar.translators.CellMLTranslator.output_variable (   self,
  ci_elt,
  ode = False 
)
Output a ci element, i.e. a variable lookup.

Definition at line 642 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator.code_name(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.code_name(), and CellMLToNektar.translators.CellMLTranslator.write().

Referenced by CellMLToNektar.translators.CellMLTranslator.output_expr(), and CellMLToNektar.translators.CellMLTranslator.output_lhs().

643  def output_variable(self, ci_elt, ode=False):
644  """Output a ci element, i.e. a variable lookup."""
645  self.write(self.code_name(ci_elt.variable, ode=ode))
def CellMLToNektar.translators.CellMLTranslator.register (   cls,
  subclass,
  name 
)
Register a new translator subclass.

Registers the subclass `subclass' with name `name' in the
translators class attribute of CellMLTranslator.  If the name
given is already in use, raises NameAlreadyRegistered.

Definition at line 117 of file translators.py.

118  def register(cls, subclass, name):
119  """Register a new translator subclass.
120 
121  Registers the subclass `subclass' with name `name' in the
122  translators class attribute of CellMLTranslator. If the name
123  given is already in use, raises NameAlreadyRegistered.
124  """
125  if name in cls.translators:
126  raise cls.NameAlreadyRegistered(name)
127  cls.translators[name] = subclass
128  return
129 
def CellMLToNektar.translators.CellMLTranslator.scan_for_lookup_tables (   self)

Lookup table methods #.

Search for lookup tables used in this document.

Store a list of suitable expressions on the document root.
Generate a dictionary mapping tables to their index variables.

Definition at line 980 of file translators.py.

References Nektar::LibUtilities::H5DataSource.doc, CellMLToNektar.optimize.PartialEvaluator.doc, CellMLToNektar.translators.CellMLTranslator.doc, and CellMLToNektar.optimize.LookupTableAnalyser.doc.

981  def scan_for_lookup_tables(self):
982  """Search for lookup tables used in this document.
983 
984  Store a list of suitable expressions on the document root.
985  Generate a dictionary mapping tables to their index variables.
986  """
987  doc = self.doc
988  # Get list of suitable expressions
989  doc.lookup_tables = doc.xml_xpath(u"//*[@lut:possible='yes']")
990  doc.lookup_tables.sort(cmp=element_path_cmp)
991  # Map table keys (min, max, step, var) to an index variable
992  doc.lookup_table_indexes = {}
993  # Count the no. of lookup tables with each index variable
994  doc.lookup_tables_num_per_index = {}
995  if not doc.lookup_tables:
996  # If no suitable expressions, we're done
997  return
998  # Search for table index variables already assigned
999  table_indexes = [int(getattr(expr, u'table_index', -1))
1000  for expr in doc.lookup_tables]
1001  tidx = max(table_indexes) + 1
1002  # Search for table names already assigned
1003  table_numbers = {}
1004  for expr in doc.lookup_tables:
1005  if hasattr(expr, u'table_name'):
1006  idx = expr.table_index
1007  table_numbers[idx] = max(table_numbers.get(idx, 0), 1 + int(expr.table_name))
1008  # Now assign new names, and construct mapping from tables to index variables
1009  for expr in doc.lookup_tables:
1010  # Get a suitable table index variable
1011  comp = expr.get_component()
1012  var = comp.get_variable_by_name(expr.var)
1013  var = var.get_source_variable(recurse=True)
1014  key = (expr.min, expr.max, expr.step, var)
1015  if not key in doc.lookup_table_indexes:
1016  var._cml_modifiable = True # Table index variables shouldn't be const, in case we constrain to table bounds
1017  if hasattr(expr, u'table_index'):
1018  doc.lookup_table_indexes[key] = expr.table_index
1019  else:
1020  doc.lookup_table_indexes[key] = unicode(tidx)
1021  tidx += 1
1022  expr.xml_set_attribute((u'lut:table_index', NSS['lut']),
1023  doc.lookup_table_indexes[key])
1024  # Get a table name, unique over all tables with this index variable
1025  if not hasattr(expr, u'table_name'):
1026  tnum = table_numbers.get(doc.lookup_table_indexes[key], 0)
1027  expr.xml_set_attribute((u'lut:table_name', NSS['lut']), unicode(tnum))
1028  table_numbers[doc.lookup_table_indexes[key]] = tnum + 1
1029  # Re-number table indices so they are contiguous starting from 0.
1030  table_index_map = {}
1031  table_name_map = {}
1032  tidx = 0
1033  for key in sorted(doc.lookup_table_indexes.keys()):
1034  idx = unicode(tidx)
1035  table_index_map[doc.lookup_table_indexes[key]] = idx
1036  table_name_map[idx] = {}
1037  doc.lookup_table_indexes[key] = idx
1038  doc.lookup_tables_num_per_index[idx] = 0
1039  tidx += 1
1040  # Make sure each lookup table is only listed once in doc.lookup_tables,
1041  # so we don't get 2 tables for the same expression!
1042  # Also re-number table names so they are contiguous starting from 0 for each table index.
1043  candidates = doc.lookup_tables[:]
1044  doc.lookup_tables = []
1045  listed = set()
1046  for expr in candidates:
1047  tid = (expr.table_index, expr.table_name)
1048  if not tid in listed:
1049  listed.add(tid)
1050  doc.lookup_tables.append(expr)
1051  # Renumber
1052  expr.table_index = table_index_map[expr.table_index]
1053  table_name_map[expr.table_index][expr.table_name] = unicode(doc.lookup_tables_num_per_index[expr.table_index])
1054  expr.table_name = table_name_map[expr.table_index][expr.table_name]
1055  # Increment count for this index variable
1056  doc.lookup_tables_num_per_index[expr.table_index] += 1
1057  else:
1058  # Just renumber to match the new id for this expression
1059  expr.table_index = table_index_map[expr.table_index]
1060  expr.table_name = table_name_map[expr.table_index][expr.table_name]
1061  return
def scan_for_lookup_tables
Lookup table methods #.
Definition: translators.py:980
def CellMLToNektar.translators.CellMLTranslator.send_main_output_to_subsidiary (   self,
  to_subsidiary = True 
)
Set subsequent main-file writes to go to the subsidiary file instead.

Supplying a False argument reverts this setting.

Has no effect if not using a subsidiary file.

Definition at line 355 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator._main_output_to_subsidiary.

Referenced by CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_chaste_lut_methods().

356  def send_main_output_to_subsidiary(self, to_subsidiary=True):
357  """Set subsequent main-file writes to go to the subsidiary file instead.
358 
359  Supplying a False argument reverts this setting.
360 
361  Has no effect if not using a subsidiary file.
362  """
363  self._main_output_to_subsidiary = to_subsidiary
def CellMLToNektar.translators.CellMLTranslator.set_indent (   self,
  level = None,
  offset = None 
)
Set the indentation level for subsequent writes.

If offset is given, adjust the level by that amount, otherwise
set it to an absolute value.

Definition at line 431 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator.indent_level.

Referenced by CellMLToNektar.translators.CellMLTranslator.close_block(), CellMLToNektar.translators.CellMLTranslator.open_block(), CellMLToNektar.translators.CellMLTranslator.output_bottom_boilerplate(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_bottom_boilerplate(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_lut_class(), and CellMLToNektar.translators.CellMLTranslator.output_top_boilerplate().

432  def set_indent(self, level=None, offset=None):
433  """Set the indentation level for subsequent writes.
434 
435  If offset is given, adjust the level by that amount, otherwise
436  set it to an absolute value.
437  """
438  if offset is not None:
439  self.indent_level += offset
440  else:
441  self.indent_level = level
def CellMLToNektar.translators.CellMLTranslator.subsidiary_file_name (   self,
  output_filename 
)
Generate a name for the subsidiary output file, based on the main one.

Returns a pair (main_output_file_name, subsidiary_file_name).  This is in
case the user specifies (e.g.) a .hpp file as the main output - we consider
the main output to be the .cpp file.

Definition at line 328 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator.FILE_EXTENSIONS, CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.USES_SUBSIDIARY_FILE, and CellMLToNektar.translators.CellMLTranslator.USES_SUBSIDIARY_FILE.

329  def subsidiary_file_name(self, output_filename):
330  """Generate a name for the subsidiary output file, based on the main one.
331 
332  Returns a pair (main_output_file_name, subsidiary_file_name). This is in
333  case the user specifies (e.g.) a .hpp file as the main output - we consider
334  the main output to be the .cpp file.
335  """
336  base, ext = os.path.splitext(output_filename)
337  ext = ext[1:] # Remove the '.'
338  try:
339  new_ext = self.FILE_EXTENSIONS[ext]
340  swap = False
341  except KeyError:
342  swap = True
343  for key, val in self.FILE_EXTENSIONS.iteritems():
344  if val == ext:
345  new_ext = key
346  break
347  else:
348  # Turn off usage of subsidiary file
349  self.USES_SUBSIDIARY_FILE = False
350  return output_filename, None
351  subsidiary_filename = base + '.' + new_ext
352  if swap:
353  output_filename, subsidiary_filename = subsidiary_filename, output_filename
354  return output_filename, subsidiary_filename
def CellMLToNektar.translators.CellMLTranslator.translate (   self,
  doc,
  model_filename,
  output_filename = None,
  subsidiary_file_name = None,
  class_name = None,
  v_variable = None,
  continuation = None,
  lookup_method_prefix = '',
  row_lookup_method = False,
  lt_index_uses_floor = True,
  constrain_table_indices = False 
)
Generate code for the given model.

doc should be an instance of cellml_model representing a
valid CellML model, such as might be produced from a call
to
>>> valid, doc = validator.CellMLValidator().validate(
...     model_filename, True)

model_filename is the filename of the input model.
The output program will by default be generated in the same
folder, but with a different extension.  This can be
overridden by supplying the output_filename keyword argument.

By default the name of the class representing the model will
be derived from the model name.  This can be overridden by
passing an alternative as the class_name argument.

The variable representing the transmembrane potential should
be passed in using the v_variable argument.

By default this method will perform some setup and then call
    self.output_top_boilerplate()
    self.output_mathematics()
    self.output_bottom_boilerplate()
To alter this, pass a callable as the continuation parameter;
this will then be called instead.

lookup_method_prefix and row_lookup_method can be used to
customise some aspects of lookup table usage.  The former is
used by the Chaste translator to place lookup tables within a
singleton class, while the latter can improve cache
performance by looking up all tables in a single call, and
returning an array of the results.

lt_index_uses_floor specifies whether to use the floor()
function to calculate the index into the lookup tables, or
just cast to unsigned.

constrain_table_indices specifies whether to throw an
exception if lookup table index variables go outside the
bounds specified (default), or just to cap them at the bounds.

Definition at line 207 of file translators.py.

Referenced by CellMLToNektar.translators.CellMLTranslator.config().

208  lt_index_uses_floor=True, constrain_table_indices=False):
209  """Generate code for the given model.
210 
211  doc should be an instance of cellml_model representing a
212  valid CellML model, such as might be produced from a call
213  to
214  >>> valid, doc = validator.CellMLValidator().validate(
215  ... model_filename, True)
216 
217  model_filename is the filename of the input model.
218  The output program will by default be generated in the same
219  folder, but with a different extension. This can be
220  overridden by supplying the output_filename keyword argument.
221 
222  By default the name of the class representing the model will
223  be derived from the model name. This can be overridden by
224  passing an alternative as the class_name argument.
225 
226  The variable representing the transmembrane potential should
227  be passed in using the v_variable argument.
228 
229  By default this method will perform some setup and then call
230  self.output_top_boilerplate()
231  self.output_mathematics()
232  self.output_bottom_boilerplate()
233  To alter this, pass a callable as the continuation parameter;
234  this will then be called instead.
235 
236  lookup_method_prefix and row_lookup_method can be used to
237  customise some aspects of lookup table usage. The former is
238  used by the Chaste translator to place lookup tables within a
239  singleton class, while the latter can improve cache
240  performance by looking up all tables in a single call, and
241  returning an array of the results.
242 
243  lt_index_uses_floor specifies whether to use the floor()
244  function to calculate the index into the lookup tables, or
245  just cast to unsigned.
246 
247  constrain_table_indices specifies whether to throw an
248  exception if lookup table index variables go outside the
249  bounds specified (default), or just to cap them at the bounds.
250  """
251  self.doc = doc
252  self.model = doc.model
253  # Name of the class that will represent this model
254  if class_name is None:
255  self.class_name = u'CML_' + doc.model.name.replace('-', '_')
256  else:
257  self.class_name = class_name
258  # Figure out the free & state vars in this model
259  self.free_vars = doc.model.find_free_vars()
260  self.state_vars = doc.model.find_state_vars()
261  if len(self.free_vars) > 1:
262  self.error(["Model has more than one free variable; exiting.",
263  "Free vars:" + str(self.free_vars)])
264  if len(self.free_vars) == 0:
265  if self.model.get_option('protocol'):
266  # We may be dealing with an algebraic model; check for an Unknown variable
267  for var in self.model.get_all_variables():
268  if var.get_type() == VarTypes.Unknown:
269  self.free_vars.append(var)
270  if len(self.free_vars) != 1:
271  self.error(["Model has no free variable; exiting."])
272  # If only a single component, don't add it to variable names
273  self.single_component = (len(getattr(self.model, u'component', [])) == 1)
274  # Find the (index of the) transmembrane potential
275  self.v_variable = v_variable
276  if self.v_variable:
277  self.v_variable_name = (v_variable.component.name, v_variable.name)
278  else:
279  self.v_variable = None
280  for i, var in enumerate(self.state_vars):
281  if var is v_variable:
282  self.v_index = i
283  break
284  else:
285  self.v_index = -1
286  # Check to see if we're using lookup tables
287  self.lookup_method_prefix = lookup_method_prefix
288  self.row_lookup_method = row_lookup_method
289  self.lt_index_uses_floor = lt_index_uses_floor
290  self.constrain_table_indices = constrain_table_indices
292  if not doc.lookup_tables:
293  # No tables found
294  self.use_lookup_tables = False
295 
296  # Extra configuration hook
298 
299  # Open the output file(s)
300  if output_filename is None:
301  output_filename = self.output_file_name(model_filename)
303  output_filename, self.subsidiary_filename = self.subsidiary_file_name(output_filename)
304  self.output_filename = output_filename
305  self.out = open_output_stream(output_filename)
308 
309  # Translate
310  if continuation:
311  continuation()
312  else:
314  self.output_mathematics()
317  if self.USES_SUBSIDIARY_FILE:
319  return
def scan_for_lookup_tables
Lookup table methods #.
Definition: translators.py:980
def CellMLToNektar.translators.CellMLTranslator.var_display_name (   self,
  var 
)
Return a display name for the given variable.

If it has an oxmeta name, uses that.  Otherwise, looks first for a bqbiol:is annotation,
or uses the cmeta:id if present, or the name attribute if not.  If there is an interface
component, strip the name of it out of the display name.

Definition at line 463 of file translators.py.

References CellMLToNektar.processors.ModelModifier.model, and CellMLToNektar.translators.CellMLTranslator.model.

Referenced by CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_bottom_boilerplate(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_constructor(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_lut_class(), and CellMLToNektar.translators.CellMLTranslator.output_table_index_generation().

464  def var_display_name(self, var):
465  """Return a display name for the given variable.
466 
467  If it has an oxmeta name, uses that. Otherwise, looks first for a bqbiol:is annotation,
468  or uses the cmeta:id if present, or the name attribute if not. If there is an interface
469  component, strip the name of it out of the display name.
470  """
471  if var.oxmeta_name:
472  name = var.oxmeta_name
473  else:
474  for uri in var.get_rdf_annotations(('bqbiol:is', NSS['bqbiol'])):
475  if '#' in uri:
476  name = uri[1 + uri.rfind('#'):]
477  break
478  else:
479  if hasattr(var, u'id') and var.id:
480  name = var.id
481  else:
482  name = var.name
483  iface = getattr(self.model, 'interface_component_name', '#N/A#')
484  if name.startswith(iface):
485  name = name[len(iface)+2:]
486  return name
def CellMLToNektar.translators.CellMLTranslator.varobj (   self,
  varname 
)
Return the variable object that has code_name varname.

Definition at line 459 of file translators.py.

References CellMLToNektar.processors.ModelModifier.model, and CellMLToNektar.translators.CellMLTranslator.model.

Referenced by CellMLToNektar.translators.CellMLTranslator._vars_in(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_backward_euler_mathematics(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_get_i_ionic(), and CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_variable().

460  def varobj(self, varname):
461  """Return the variable object that has code_name varname."""
462  return cellml_variable.get_variable_object(self.model, varname)
def CellMLToNektar.translators.CellMLTranslator.write (   self,
  args 
)
Write to our output file.

This variant does not indent the output, or add a newline.

Definition at line 398 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator.writeln().

Referenced by CellMLToNektar.translators.CellMLTranslator.close_paren(), CellMLToNektar.translators.CellMLTranslator.open_paren(), CellMLToNektar.translators.CellMLTranslator.output_apply(), CellMLToNektar.translators.CellMLTranslator.output_assignment(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_backward_euler_mathematics(), CellMLToNektar.translators.CellMLTranslator.output_expr(), CellMLToNektar.translators.CellMLTranslator.output_function(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_get_i_ionic(), CellMLToNektar.translators.CellMLTranslator.output_lhs(), CellMLToNektar.translators.CellMLTranslator.output_log(), CellMLToNektar.translators.CellMLTranslator.output_nary_operator(), CellMLToNektar.translators.CellMLTranslator.output_number(), CellMLToNektar.translators.CellMLTranslator.output_piecewise(), CellMLToNektar.translators.CellMLTranslator.output_root(), CellMLToNektar.translators.CellMLTranslator.output_table_lookup(), CellMLToNektar.translators.CellMLTranslator.output_unary_operator(), CellMLToNektar.translators.CellMLTranslator.output_variable(), and CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_variable().

399  def write(self, *args):
400  """Write to our output file.
401 
402  This variant does not indent the output, or add a newline.
403  """
404  self.writeln(indent=False, nl=False, *args)
def CellMLToNektar.translators.CellMLTranslator.writeln (   self,
  args,
  kwargs 
)
Write a line to our output file.

Takes any number of strings as input, and writes them out to file.

Unless the keyword argument indent is given as False, then the
output will be indented to the level set by self.set_indent().
Setting indent_level will override this value.
Setting indent_offset will adjust the current level temporarily.

If nl is set to False then a newline character will not be
appended to the output.

If subsidiary=True, then the line will be written to the subsidiary
output file instead of the main one.  An error will be raised if
there is no subsidiary output file.

Definition at line 364 of file translators.py.

References CellMLToNektar.translators.CellMLTranslator._main_output_to_subsidiary, CellMLToNektar.translators.CellMLTranslator.error(), CellMLToNektar.translators.CellMLTranslator.indent_char, CellMLToNektar.translators.CellMLTranslator.indent_factor, CellMLToNektar.translators.CellMLTranslator.indent_level, CellMLToNektar.translators.CellMLTranslator.out, Nektar::NekMeshUtils::DelaunayTriangle.out, CellMLToNektar.translators.CellMLTranslator.out2, CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.USES_SUBSIDIARY_FILE, and CellMLToNektar.translators.CellMLTranslator.USES_SUBSIDIARY_FILE.

Referenced by CellMLToNektar.translators.CellMLTranslator.close_block(), CellMLToNektar.translators.CellMLTranslator.open_block(), CellMLToNektar.translators.CellMLTranslator.output_assignment(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_assignment(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_backward_euler_mathematics(), CellMLToNektar.translators.CellMLTranslator.output_bottom_boilerplate(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_bottom_boilerplate(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_chaste_lut_methods(), CellMLToNektar.translators.CellMLTranslator.output_comment(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_constructor(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_derivative_calculations(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_derivative_calculations_grl(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_derived_quantities(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_evaluate_y_derivatives(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_get_i_ionic(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_grl1_mathematics(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_grl2_mathematics(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_grl_compute_partial(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_includes(), 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.translators.CellMLTranslator.output_lut_index_declarations(), 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.translators.CellMLTranslator.output_mathematics(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_method_start(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_model_attributes(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_nonlinear_state_assignments(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_rush_larsen_mathematics(), CellMLToNektar.translators.CellMLTranslator.output_single_lookup(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_state_assignments(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_table_index_checking(), CellMLToNektar.translators.CellMLTranslator.output_table_index_checking(), CellMLToNektar.translators.CellMLTranslator.output_table_index_generation(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_table_index_generation_code(), CellMLToNektar.translators.CellMLTranslator.output_table_index_generation_code(), CellMLToNektar.translators.CellMLTranslator.output_top_boilerplate(), CellMLToNektar.translators.CellMLTranslator.write(), and CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.writeln_hpp().

365  def writeln(self, *args, **kwargs):
366  """Write a line to our output file.
367 
368  Takes any number of strings as input, and writes them out to file.
369 
370  Unless the keyword argument indent is given as False, then the
371  output will be indented to the level set by self.set_indent().
372  Setting indent_level will override this value.
373  Setting indent_offset will adjust the current level temporarily.
374 
375  If nl is set to False then a newline character will not be
376  appended to the output.
377 
378  If subsidiary=True, then the line will be written to the subsidiary
379  output file instead of the main one. An error will be raised if
380  there is no subsidiary output file.
381  """
382  if kwargs.get('subsidiary', False) or self._main_output_to_subsidiary:
383  if not self.USES_SUBSIDIARY_FILE:
384  self.error('Tried to write to non-existent subsidiary file')
385  else:
386  target = self.out2
387  else:
388  target = self.out
389  indent = kwargs.get('indent', True)
390  nl = kwargs.get('nl', True)
391  if indent:
392  level = kwargs.get('indent_level', self.indent_level)
393  level += kwargs.get('indent_offset', 0)
394  target.write(self.indent_char * self.indent_factor * level)
395  target.write(''.join(map(str, args)))
396  if nl:
397  target.write('\n')

Member Data Documentation

CellMLToNektar.translators.CellMLTranslator._main_output_to_subsidiary
private

Definition at line 181 of file translators.py.

Referenced by CellMLToNektar.translators.CellMLTranslator.send_main_output_to_subsidiary(), and CellMLToNektar.translators.CellMLTranslator.writeln().

CellMLToNektar.translators.CellMLTranslator._original_out
private

Definition at line 407 of file translators.py.

Referenced by CellMLToNektar.translators.CellMLTranslator.get_captured_output().

CellMLToNektar.translators.CellMLTranslator.add_timestamp

Definition at line 179 of file translators.py.

Referenced by CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_includes(), and CellMLToNektar.translators.CellMLTranslator.output_top_boilerplate().

dictionary CellMLToNektar.translators.CellMLTranslator.binary_ops
static
Initial value:
1 = {'divide': '/',
2  'xor': '!=', 'eq': '==', 'neq': '!=',
3  'geq': '>=','leq': '<=','gt': '>','lt': '<'}

Definition at line 727 of file translators.py.

Referenced by CellMLToNektar.translators.CellMLTranslator.output_apply().

CellMLToNektar.translators.CellMLTranslator.class_name

Definition at line 254 of file translators.py.

Referenced by CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_backward_euler_mathematics(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_bottom_boilerplate(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_constructor(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_evaluate_y_derivatives(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_method_start(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_serialize_method(), and CellMLToNektar.translators.CellMLTranslator.output_top_boilerplate().

string CellMLToNektar.translators.CellMLTranslator.COMMENT_START = '// '
static

Definition at line 143 of file translators.py.

Referenced by CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_backward_euler_mathematics(), CellMLToNektar.translators.CellMLTranslator.output_comment(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_constructor(), CellMLToNektar.translators.CellMLTranslator.output_mathematics(), and CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_state_assignments().

CellMLToNektar.translators.CellMLTranslator.constrain_table_indices

Definition at line 289 of file translators.py.

Referenced by CellMLToNektar.translators.CellMLTranslator.output_table_index_checking().

CellMLToNektar.translators.CellMLTranslator.doc

Definition at line 250 of file translators.py.

Referenced by CellMLToNektar.translators.CellMLTranslator.config(), and CellMLToNektar.translators.CellMLTranslator.scan_for_lookup_tables().

string CellMLToNektar.translators.CellMLTranslator.DOXYGEN_COMMENT_START = '//! '
static

Definition at line 144 of file translators.py.

Referenced by CellMLToNektar.translators.CellMLTranslator.output_doxygen().

string CellMLToNektar.translators.CellMLTranslator.E = 'M_E'
static

Definition at line 156 of file translators.py.

Referenced by CellMLToNektar.translators.CellMLTranslator.output_expr().

string CellMLToNektar.translators.CellMLTranslator.EQ_ASSIGN = ' = '
static

Definition at line 142 of file translators.py.

Referenced by CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.get_stimulus_assignment(), CellMLToNektar.translators.CellMLTranslator.output_assignment(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_assignment(), 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_grl2_mathematics(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_lut_class(), CellMLToNektar.translators.CellMLTranslator.output_lut_deletion(), CellMLToNektar.translators.CellMLTranslator.output_lut_generation(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_nonlinear_state_assignments(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_rush_larsen_mathematics(), CellMLToNektar.translators.CellMLTranslator.output_single_lookup(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_state_assignments(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_table_index_checking(), CellMLToNektar.translators.CellMLTranslator.output_table_index_checking(), and CellMLToNektar.translators.CellMLTranslator.output_table_index_generation_code().

string CellMLToNektar.translators.CellMLTranslator.FALSE = 'false'
static

Definition at line 154 of file translators.py.

Referenced by CellMLToNektar.translators.CellMLTranslator.output_expr().

dictionary CellMLToNektar.translators.CellMLTranslator.FILE_EXTENSIONS
static
Initial value:
1 = {'cpp': 'h',
2  'c': 'h',
3  'cxx': 'hxx'}

Definition at line 163 of file translators.py.

Referenced by CellMLToNektar.translators.CellMLTranslator.subsidiary_file_name().

CellMLToNektar.translators.CellMLTranslator.free_vars

Definition at line 258 of file translators.py.

Referenced by CellMLToNektar.translators.CellMLTranslator._vars_in(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.code_name(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.get_stimulus_assignment(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.modifier_call(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_backward_euler_mathematics(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_derivative_calculations(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_derivative_calculations_grl(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_derived_quantities(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_evaluate_y_derivatives(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_grl1_mathematics(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_grl2_mathematics(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_grl_compute_partial(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_rush_larsen_mathematics(), and CellMLToNektar.translators.CellMLTranslator.output_top_boilerplate().

dictionary CellMLToNektar.translators.CellMLTranslator.function_map
static
Initial value:
1 = {'power': 'pow', 'abs': 'fabs', 'ln': 'log', 'exp': 'exp',
2  'floor': 'floor', 'ceiling': 'ceil',
3  'factorial': 'factorial', # Needs external definition
4  'not': '!', 'rem': 'fmod',
5  'sin': 'sin', 'cos': 'cos', 'tan': 'tan',
6  'sec': '1/cos', 'csc': '1/sin', 'cot': '1/tan',
7  'sinh': 'sinh', 'cosh': 'cosh', 'tanh': 'tanh',
8  'sech': '1/cosh', 'csch': '1/sinh', 'coth': '1/tanh',
9  'arcsin': 'asin', 'arccos': 'acos', 'arctan': 'atan',
10  'arcsinh': 'asinh', 'arccosh': 'acosh', 'arctanh': 'atanh'}

Definition at line 710 of file translators.py.

Referenced by CellMLToNektar.translators.CellMLTranslator.output_apply().

CellMLToNektar.translators.CellMLTranslator.indent_char

Definition at line 173 of file translators.py.

Referenced by CellMLToNektar.translators.CellMLTranslator.writeln().

CellMLToNektar.translators.CellMLTranslator.indent_factor

Definition at line 175 of file translators.py.

Referenced by CellMLToNektar.translators.CellMLTranslator.writeln().

CellMLToNektar.translators.CellMLTranslator.indent_level

Definition at line 171 of file translators.py.

Referenced by CellMLToNektar.translators.CellMLTranslator.set_indent(), and CellMLToNektar.translators.CellMLTranslator.writeln().

CellMLToNektar.translators.CellMLTranslator.lookup_method_prefix

Definition at line 286 of file translators.py.

Referenced by CellMLToNektar.translators.CellMLTranslator.output_table_index_generation_code(), and CellMLToNektar.translators.CellMLTranslator.output_table_lookup().

CellMLToNektar.translators.CellMLTranslator.lt_index_uses_floor

Definition at line 288 of file translators.py.

Referenced by CellMLToNektar.translators.CellMLTranslator.output_table_index_generation_code().

CellMLToNektar.translators.CellMLTranslator.model

Definition at line 251 of file translators.py.

Referenced by CellMLToNektar.pycml.cellml_variable._set_source_variable(), CellMLToNektar.pycml.cellml_variable.add_rdf_annotation(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.code_name(), CellMLToNektar.pycml.cellml_variable.get_rdf_annotation(), CellMLToNektar.pycml.cellml_variable.get_rdf_annotations(), CellMLToNektar.pycml.mathml_apply.get_units(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_backward_euler_mathematics(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_constructor(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_get_i_ionic(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_model_attributes(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_verify_state_variables(), CellMLToNektar.pycml.cellml_variable.remove_rdf_annotations(), CellMLToNektar.translators.CellMLTranslator.var_display_name(), and CellMLToNektar.translators.CellMLTranslator.varobj().

dictionary CellMLToNektar.translators.CellMLTranslator.nary_ops
static
Initial value:
1 = {'plus': '+', 'times': '*',
2  'and': '&&', 'or': '||'}

Definition at line 725 of file translators.py.

Referenced by CellMLToNektar.translators.CellMLTranslator.output_apply().

string CellMLToNektar.translators.CellMLTranslator.NOT_A_NUMBER = 'NAN'
static

Definition at line 157 of file translators.py.

Referenced by CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_bottom_boilerplate(), CellMLToNektar.translators.CellMLTranslator.output_piecewise(), and CellMLToNektar.translators.CellMLTranslator.output_top_boilerplate().

CellMLToNektar.translators.CellMLTranslator.options

Definition at line 169 of file translators.py.

Referenced by CellMLToNektar.translators.ConfigurationStore.find_transmembrane_potential(), and CellMLToNektar.translators.ConfigurationStore.read_configuration_file().

CellMLToNektar.translators.CellMLTranslator.out

Definition at line 304 of file translators.py.

Referenced by CellMLToNektar.translators.CellMLTranslator.get_captured_output(), and CellMLToNektar.translators.CellMLTranslator.writeln().

CellMLToNektar.translators.CellMLTranslator.out2

Definition at line 306 of file translators.py.

Referenced by CellMLToNektar.translators.CellMLTranslator.writeln().

CellMLToNektar.translators.CellMLTranslator.output_filename

Definition at line 303 of file translators.py.

string CellMLToNektar.translators.CellMLTranslator.PI = 'M_PI'
static

Definition at line 155 of file translators.py.

Referenced by CellMLToNektar.translators.CellMLTranslator.output_expr().

dictionary CellMLToNektar.translators.CellMLTranslator.recip_trig
static
Initial value:
1 = {'arcsec': 'arccos', 'arccsc': 'arcsin', 'arccot': 'arctan',
2  'arcsech': 'arccosh', 'arccsch': 'arcsinh', 'arccoth': 'arctanh'}

Definition at line 722 of file translators.py.

Referenced by CellMLToNektar.translators.CellMLTranslator.output_apply().

CellMLToNektar.translators.CellMLTranslator.row_lookup_method

Definition at line 287 of file translators.py.

Referenced by CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_lut_class(), CellMLToNektar.translators.CellMLTranslator.output_lut_index_declarations(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_lut_indexing_methods(), CellMLToNektar.translators.CellMLTranslator.output_lut_methods(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_table_index_generation_code(), CellMLToNektar.translators.CellMLTranslator.output_table_index_generation_code(), and CellMLToNektar.translators.CellMLTranslator.output_table_lookup().

CellMLToNektar.translators.CellMLTranslator.single_component

Definition at line 272 of file translators.py.

dictionary CellMLToNektar.translators.CellMLTranslator.special_roots = {2: 'sqrt', 3: 'cbrt'}
static

Definition at line 813 of file translators.py.

CellMLToNektar.translators.CellMLTranslator.state_vars

Definition at line 259 of file translators.py.

Referenced by CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_backward_euler_mathematics(), CellMLToNektar.translators.CellMLTranslator.output_bottom_boilerplate(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_bottom_boilerplate(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_derivative_calculations_grl(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_evaluate_y_derivatives(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_grl1_mathematics(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_grl2_mathematics(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_intracellular_calcium(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_rush_larsen_mathematics(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_state_assignments(), and CellMLToNektar.translators.CellMLTranslator.output_top_boilerplate().

string CellMLToNektar.translators.CellMLTranslator.STMT_END = ';'
static

Various language tokens #.

Definition at line 141 of file translators.py.

Referenced by CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.get_stimulus_assignment(), CellMLToNektar.translators.CellMLTranslator.output_assignment(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_assignment(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_backward_euler_mathematics(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_constructor(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_derivative_calculations(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_derived_quantities(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_equations(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_get_i_ionic(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_grl1_mathematics(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_grl2_mathematics(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_grl_compute_partial(), 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.translators.CellMLTranslator.output_lut_index_declarations(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_lut_indexing_methods(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_method_start(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_nonlinear_state_assignments(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_rush_larsen_mathematics(), CellMLToNektar.translators.CellMLTranslator.output_single_lookup(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_state_assignments(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_table_index_checking(), CellMLToNektar.translators.CellMLTranslator.output_table_index_checking(), CellMLToNektar.translators.CellMLTranslator.output_table_index_generation_code(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.vector_create(), and CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.vector_initialise().

CellMLToNektar.translators.CellMLTranslator.subsidiary_filename

Definition at line 302 of file translators.py.

Referenced by CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_includes().

dictionary CellMLToNektar.translators.CellMLTranslator.translators = {}
static

Definition at line 110 of file translators.py.

string CellMLToNektar.translators.CellMLTranslator.TRUE = 'true'
static

Definition at line 153 of file translators.py.

Referenced by CellMLToNektar.translators.CellMLTranslator.output_expr().

string CellMLToNektar.translators.CellMLTranslator.TYPE_CONST_DOUBLE = 'const NekDouble '
static

Definition at line 149 of file translators.py.

Referenced by CellMLToNektar.translators.CellMLTranslator.output_assignment(), CellMLToNektar.translators.CellMLTranslator.output_lut_generation(), CellMLToNektar.translators.CellMLTranslator.output_single_lookup(), and CellMLToNektar.translators.CellMLTranslator.output_table_index_generation_code().

string CellMLToNektar.translators.CellMLTranslator.TYPE_CONST_UNSIGNED = 'const unsigned '
static

Definition at line 150 of file translators.py.

Referenced by CellMLToNektar.translators.CellMLTranslator.output_lut_generation().

string CellMLToNektar.translators.CellMLTranslator.TYPE_DOUBLE = 'NekDouble '
static

Definition at line 147 of file translators.py.

Referenced by CellMLToNektar.translators.CellMLTranslator.lut_factor(), and CellMLToNektar.translators.CellMLTranslator.output_lut_declarations().

string CellMLToNektar.translators.CellMLTranslator.TYPE_VOID = 'void '
static

Definition at line 148 of file translators.py.

Referenced by CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_bottom_boilerplate(), and CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_evaluate_y_derivatives().

CellMLToNektar.translators.CellMLTranslator.use_lookup_tables

Definition at line 177 of file translators.py.

Referenced by CellMLToNektar.translators.CellMLTranslator._vars_in(), CellMLToNektar.translators.CellMLTranslator.output_expr(), CellMLToNektar.translators.CellMLTranslator.output_lut_generation(), and CellMLToNektar.translators.CellMLTranslator.output_top_boilerplate().

CellMLToNektar.translators.CellMLTranslator.USES_SUBSIDIARY_FILE = False
static

Definition at line 161 of file translators.py.

Referenced by CellMLToNektar.translators.CellMLTranslator.subsidiary_file_name(), and CellMLToNektar.translators.CellMLTranslator.writeln().

CellMLToNektar.translators.CellMLTranslator.v_index

Definition at line 281 of file translators.py.

Referenced by CellMLToNektar.translators.CellMLTranslator.output_top_boilerplate().

CellMLToNektar.translators.CellMLTranslator.v_variable

Definition at line 274 of file translators.py.

Referenced by CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_assignment(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_derivative_calculations(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_grl1_mathematics(), CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_grl2_mathematics(), and CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_rush_larsen_mathematics().

CellMLToNektar.translators.CellMLTranslator.v_variable_name

Definition at line 276 of file translators.py.