Stan

Model export to Stan.

API

The standard exporting API is provided:

myokit.formats.stan.exporters()

Returns a dict of all exporters available in this module.

class myokit.formats.stan.StanExporter

This:class:Exporter <myokit.formats.Exporter> generates a Stan implementation of a Myokit model.

Only the model definition is exported. An interpolating pacing input method is added. No post-processing is included.

The following inputs are provided:

time
The current simulation time
pace
The current value of the pacing system, implemented using a very simple pacing mechanism.
info()

Returns a string containing information about this exporter.

This should be implemented by each subclass.

runnable(path, model, protocol=None, parameters=None, output=None)

Exports a:class:myokit.Model to a Stan model with a parameter estimation file.

Arguments:

path
A string representing the directory to store the output in.
model
A Myokit model to export
protocol
Not implemented!
parameters
A list of variables or variable names, specifying the model variables to be estimated by stan.
output
A single variable to be used as the model output (for example an ion current).
myokit.formats.stan.ewriters()

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

class myokit.formats.stan.StanExpressionWriter

This:class:ExpressionWriter <myokit.formats.ExpressionWriter> translates Myokit:class:expressions <myokit.Expression> to a Stan syntax.

eq(q)

Converts an equation to a string

ex(e)

Converts an Expression to a string.

set_condition_function(func=None)

Sets a function name to use for if statements

By setting func to None you can revert back to the default behavior
(the ternary operator). Any other value will be interpreted as the name of a function taking arguments (condition, value_if_true, value_if_false).
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.