DiffSL¶
Myokit provides partial export of models to the DiffSL language.
Exporters and expression writers¶
- myokit.formats.diffsl.exporters()¶
Returns a dict of all exporters available in this module.
- class myokit.formats.diffsl.DiffSLExporter¶
This
Exporter
generates a DiffSL implementation of a Myokit model.Only the model definition is exported. No inputs are provided, there is no protocol defined, and only state variables are output.
For details of the language, see https://martinjrobins.github.io/diffsl/
- model(path, model, protocol=None, convert_units=True)¶
Exports a
myokit.Model
in DiffSL format, writing the result to the file indicated bypath
.A
myokit.ExportError
will be raised if any errors occur. Warnings will be generated if unsupported functions (e.g. atan) are used in the model. For a full list, seemyokit.formats.diffsl.DiffSLExpressionWriter
.Arguments:
path
The path to write the generated model to.
model
The
myokit.Model
to export.protocol
Not implemented!
convert_units
If set to
True
(default), the method will attempt to convert to preferred units for voltage (mV), current (A/F), and time (ms).
- post_export_info()¶
Optional method that returns a string containing information about this exporter, to be shown after the export is completed.
- runnable(path, model, protocol=None, *args)¶
Exports a
myokit.Model
and optionally amyokit.Protocol
to something that can be run or compiled.The output will be stored in the directory
path
. Amyokit.ExportError
will be raised if any errors occur.
- supports_model()¶
- supports_runnable()¶
Returns
True
if this exporter supports export of a model and optional protocol to a runnable piece of code.
- myokit.formats.diffsl.ewriters()¶
Returns a dict of all expression writers available in this module.
- class myokit.formats.diffsl.DiffSLExpressionWriter¶
This
ExpressionWriter
writes equations for variables in DiffSL syntax.For details of the language, see https://martinjrobins.github.io/diffsl/.
Warnings will be generated if unsupported functions are used in the model. Unsupported functions: acos, asin, atan, ceil, floor.
Support for logic expressions is implemented with heaviside functions. For example, (a >= b) is converted to heaviside(a - b).
- eq(q)¶
Converts a
myokit.Equation
to a string.
- ex(e)¶
Converts a
myokit.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 anLhsExpression
as input and returns a string.