Python

Full simulation export to Python is provided.

Limitations:

  • For running simulations, this method is incredibly slow.

API

The standard exporting API is provided:

myokit.formats.python.exporters()

Returns a dict of all exporters available in this module.

class myokit.formats.python.PythonExporter

This Exporter generates a python-only model implementation and a simple (but slow) integration routine.

Both the model definition and the pacing protocol are fully exported.

Provides the following external variables:

time
The current simulation time
pace
The current value of the pacing system, implemented using the given protocol.

A graph of the results is generated using matplotlib.

myokit.formats.python.ewriters()

Returns a dict of all expression writers available in this module.

class myokit.formats.python.PythonExpressionWriter

This ExpressionWriter translates Myokit expressions to their Python equivalent.

eq(q)

Converts an equation to a string

ex(e)

Converts an Expression to a string.

set_lhs_function(f)
Sets a naming function, will be called to get the variable name from a
myokit.LhsExpression object.

The argument f should be a function that takes an LhsExpression as input and returns a string.

class myokit.formats.python.NumpyExpressionWriter

This ExpressionWriter translates Myokit expressions to Python expressions intended for use in NumPy arrays.

eq(q)

Converts an equation to a string

ex(e)

Converts an Expression to a string.

set_lhs_function(f)
Sets a naming function, will be called to get the variable name from a
myokit.LhsExpression object.

The argument f should be a function that takes an LhsExpression as input and returns a string.