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

Public Member Functions

def __init__
 
def analyse_model
 

Private Member Functions

def _check_var
 

Private Attributes

 _var
 
 _conv
 
 _alpha
 
 _beta
 
 _ab_pattern
 
 _alt_ab_pattern
 
 _tau
 
 _inf
 
 _ti_pattern
 
 _alt_ti_pattern
 

Detailed Description

Analyse a model to identify Hodgkin-Huxley style gating variable equations.

We look for ODEs whose definition matches "alpha*(1-x) - beta*x" (where x is
the state variable, and alpha & beta are any expression).  Alternatively for
models which already have tau & inf variables, we match against "(inf-x)/tau".

To allow for when units conversions have been performed, we chase 'simple'
assignments and (the semantically equivalent) variable mappings until reaching
an 'interesting' defining equation.  We also need to allow the whole RHS to be
multiplied by a constant.  If this occurs, the constant conversion factor is
also stored; otherwise we store None.

Stores a dictionary on the document root mapping cellml_variable instances to
4-tuples.  The tuple is either ('ab', alpha, beta, conv) or ('ti', tau, inf, conv)
depending on which formulation has been used.  Note that the expressions in these
are not cloned copies - they are the original objects still embedded within the
relevant ODE.  The units conversion factor 'conv' is stored as a Python double.

Definition at line 1428 of file optimize.py.

Constructor & Destructor Documentation

def CellMLToNektar.optimize.RushLarsenAnalyser.__init__ (   self)
Create the patterns to match against.

Definition at line 1447 of file optimize.py.

1448  def __init__(self):
1449  """Create the patterns to match against."""
1450  em = ExpressionMatcher
1451  self._var = em.V()
1452  self._conv = em.N()
1453  # Alpha/beta form
1454  self._alpha = em.X()
1455  self._beta = em.X()
1456  self._ab_pattern = em.R(em.A('minus', [em.A('times', [self._alpha,
1457  em.A('minus', [em.N(1), self._var])]),
1458  em.A('times', [self._beta, self._var])]))
1459  self._alt_ab_pattern = em.R(em.A('times', [self._conv, self._ab_pattern]))
1460  # Tau/inf form
1461  self._tau = em.X()
1462  self._inf = em.X()
1463  self._ti_pattern = em.R(em.A('divide', [em.A('minus', [self._inf, self._var]),
1464  self._tau]))
1465  self._alt_ti_pattern = em.R(em.A('times', [self._conv, self._ti_pattern]))

Member Function Documentation

def CellMLToNektar.optimize.RushLarsenAnalyser._check_var (   self,
  var,
  ode_expr,
  mapping 
)
private

Definition at line 1479 of file optimize.py.

Referenced by CellMLToNektar.optimize.RushLarsenAnalyser.analyse_model().

1480  def _check_var(self, var, ode_expr, mapping):
1481  rhs = ode_expr.eq.rhs
1482  self._var.set_variable(ode_expr.eq.lhs.diff.dependent_variable)
1483  if self._ab_pattern.match(rhs):
1484  mapping[var] = ('ab', self._alpha.matched, self._beta.matched, None)
1485  elif self._alt_ab_pattern.match(rhs):
1486  mapping[var] = ('ab', self._alpha.matched, self._beta.matched, self._conv.value)
1487  elif self._ti_pattern.match(rhs):
1488  mapping[var] = ('ti', self._tau.matched, self._inf.matched, None)
1489  elif self._alt_ti_pattern.match(rhs):
1490  mapping[var] = ('ti', self._tau.matched, self._inf.matched, self._conv.value)
def CellMLToNektar.optimize.RushLarsenAnalyser.analyse_model (   self,
  doc 
)

Definition at line 1466 of file optimize.py.

References CellMLToNektar.optimize.RushLarsenAnalyser._check_var().

1467  def analyse_model(self, doc):
1468  # First, find linear ODEs that have the potential to be gating variables
1469  la = LinearityAnalyser()
1470  V = doc._cml_config.V_variable
1471  state_vars = doc.model.find_state_vars()
1472  free_var = doc.model.find_free_vars()[0]
1473  linear_vars = la.find_linear_odes(state_vars, V, free_var)
1474  # Next, check they match dn/dt = a (1-n) - b n
1475  doc._cml_rush_larsen = {}
1476  for var in linear_vars:
1477  ode_expr = var.get_ode_dependency(free_var)
1478  self._check_var(var, ode_expr, doc._cml_rush_larsen)

Member Data Documentation

CellMLToNektar.optimize.RushLarsenAnalyser._ab_pattern
private

Definition at line 1455 of file optimize.py.

CellMLToNektar.optimize.RushLarsenAnalyser._alpha
private

Definition at line 1453 of file optimize.py.

CellMLToNektar.optimize.RushLarsenAnalyser._alt_ab_pattern
private

Definition at line 1458 of file optimize.py.

CellMLToNektar.optimize.RushLarsenAnalyser._alt_ti_pattern
private

Definition at line 1464 of file optimize.py.

CellMLToNektar.optimize.RushLarsenAnalyser._beta
private

Definition at line 1454 of file optimize.py.

CellMLToNektar.optimize.RushLarsenAnalyser._conv
private

Definition at line 1451 of file optimize.py.

CellMLToNektar.optimize.RushLarsenAnalyser._inf
private

Definition at line 1461 of file optimize.py.

CellMLToNektar.optimize.RushLarsenAnalyser._tau
private

Definition at line 1460 of file optimize.py.

CellMLToNektar.optimize.RushLarsenAnalyser._ti_pattern
private

Definition at line 1462 of file optimize.py.

CellMLToNektar.optimize.RushLarsenAnalyser._var
private

Definition at line 1450 of file optimize.py.