C¶
Export to a simple Ansi-C format is provided based on the sundials ODE solver.
Limitations:
No plots or other post-processing are included
API¶
The standard interface for exporting and accessing expression writers is provided:
- myokit.formats.ansic.exporters()¶
Returns a dict of all exporters available in this module.
- class myokit.formats.ansic.AnsiCExporter¶
This
Exporter
generates a runnable ansic C model implementation and integrator. The integration is based on the Sundials CVODE library, which is required to run the program.Both the model definition and pacing protocol are exported and the file is set up ready to run a simulation. No post-processing is included.
Provides the following external variables:
time
The current simulation time
pace
The current value of the pacing system, implemented using the given protocol.
- post_export_info()¶
Optional method that returns a string containing information about this exporter, to be shown after the export is completed.
- class myokit.formats.ansic.AnsiCCableExporter¶
This
Exporter
generates a 1d cable simulation using a simple forward-Euler scheme in ansi-C.Both the model definition and pacing protocol are exported and the file is set up ready to run a simulation. No post-processing is included.
Provides the following external variables:
time
The simulation time
pace
The value of the pacing variable, implemented using the given protocol.
diffusion_current
The current flowing from each cell to its neighbors. This will be positive if the cell is acting as a source, negative when it’s acting as a sink.
Requires the following labels to be set in the model:
membrane_potential
The membrane potential.
Variables are linked using
diffusion_current
, this is calculated from the membrane potentials as:i = g * ((V - V_next) - (V_last - V))
At the boundaries, V is substituted for V_last or V_next.
- post_export_info()¶
Optional method that returns a string containing information about this exporter, to be shown after the export is completed.
- class myokit.formats.ansic.AnsiCEulerExporter¶
This
Exporter
generates an ansic C implementation using a simple explicit forward-Euler scheme.Both the model definition and pacing protocol are exported and the file is set up ready to run a simulation. No post-processing is included.
Provides the following external variables:
time
The simulation time
pace
The value of the pacing variable, implemented using the given protocol.
No labeled variables are required.
- post_export_info()¶
Optional method that returns a string containing information about this exporter, to be shown after the export is completed.
- myokit.formats.ansic.ewriters()¶
Returns a dict of all expression writers available in this module.
- class myokit.formats.ansic.AnsiCExpressionWriter¶
This
ExpressionWriter
writes equations for variables in a C-style syntax.- eq(q)¶
Converts a
myokit.Equation
to a string.
- ex(e)¶
Converts a
myokit.Expression
to a string.
- set_condition_function(func=None)¶
Sets a function name to use for
myokit.If
; if not set the ternary operatur will be used.If given, the function arguments should be
(condition, value_if_true, value_if_false)
. To revert to using the ternary operator, call withfunc=None
.
- 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.
- class myokit.formats.ansic.CBasedExpressionWriter¶
Base class for C-style expression writers.
- 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.