13.3. Model

class Model(definition)

A model is a set of equations that are supposed to be evaluated together. Those equations can be:

  • DifferentialEquation of the form dy/dt = expr : dtype
  • Equation of the form y = expr : dtype
  • Declaration of the form y : dtype

where expr is a valid python expression.

Examples

>>> model = Model('''dx/dt = 1.0 : float  # differential equation
                        y  = 1.0 : float  # equation''')
run(namespace=None, dt=0.001)

Run the model model within the given namespace

Parameters

namespace : dict
Dictionnary of necessary variables to run the model
dt : float
Elementaty time step

Examples

>>> model = Model('dx/dt = 1.0; y = 1.0')
>>> model.run({'x':0}, dt=0.01)
{'y': 1.0, 'x': 0.01}
declarations

Model declarations

equations

Model equations

diff_equations

Model differental equations