Skip to content

simulate

Simulation of CellML models with libopencor.

libopencor is part of the simulate extra; it is imported when a simulation runs, so the rest of the package works without it. See LIBOPENCOR_INSTALL.

SimulationError

Bases: RuntimeError

libopencor reported issues for the file, the document or the run.

run_timecourse

run_timecourse(
    cellml_path,
    start=0.0,
    end=100.0,
    steps=100,
    relative_tolerance=None,
    absolute_tolerance=None,
    maximum_number_of_steps=MAXIMUM_NUMBER_OF_STEPS,
)

Run a uniform timecourse of a CellML model.

Parameters:

Name Type Description Default
cellml_path Path

path of the CellML file.

required
start float

start time of the output.

0.0
end float

end time of the output.

100.0
steps int

number of steps, the output has steps + 1 rows.

100
relative_tolerance float | None

relative tolerance of the ODE solver, the libopencor default when None.

None
absolute_tolerance float | None

absolute tolerance of the ODE solver, the libopencor default when None.

None
maximum_number_of_steps int

number of internal steps the ODE solver may take between two time points of the output.

MAXIMUM_NUMBER_OF_STEPS

Returns:

Type Description
DataFrame

The timecourse with the variable of integration in the first column

dict[str, str]

followed by the states, the algebraic variables, the constants and

tuple[DataFrame, dict[str, str]]

the computed constants, and the units of every column. A model

tuple[DataFrame, dict[str, str]]

without a variable of integration (an algebraic model, which

tuple[DataFrame, dict[str, str]]

libopencor solves as a steady state) has the same values at every

tuple[DataFrame, dict[str, str]]

time point, in a first column time of the requested time points.

Raises:

Type Description
ImportError

if libopencor is not installed.

SimulationError

if libopencor reports issues, e.g., for a model which is not valid or not fully constrained, or two result columns get the same name.

plot_timecourse

plot_timecourse(df, units, show=True)

Plot every column of a timecourse against the first column.

Parameters:

Name Type Description Default
df DataFrame

timecourse from run_timecourse.

required
units dict[str, str]

units of the columns from run_timecourse.

required
show bool

call matplotlib.pyplot.show.

True

Returns:

Type Description
Figure

The figure.