Right-hand-side evaluations

myokit.step(model, initial=None, reference=None, ignore_errors=False)

Evaluates the state derivatives in a model and compares the results with a list of reference values, if given.

The model should be given as a valid myokit.Model. The state values to start from can be given as initial, which should be any item that can be converted to a valid state using model.map_to_state.

The values can be compared to reference output given as a list reference. Alternatively, if reference is a model the two models’ outputs will be compared.

By default, the evaluation routine checks for numerical errors (divide-by-zeros, invalid operations and overflows). To run an evaluation without error checking, set ignore_errors=True.

Returns a string indicating the results.

class myokit.RhsBenchmarker(model, variables=None, exclude_selected=False)

Benchmarks a model’s right hand side (rhs).

To enable partial benchmarking the argument variables can be used to pass in a list of variables whose combined evaluation time can be obtained by using bench_part(). Only non-constant, non-bound variables can be selected.

By default, the given list of variables are the only variables included in a partial simulation. This behaviour can be inverted by setting exclude_selected=True. With this setting, all variables except those in the given list will be tested.

A valid myokit model should be provided as the model argument.

bench_full(log, repeats=40000, fastest=False)

Benchmarks the entire RHS for every position found in the given log file.

The argument log should point to a myokit.DataLog or similar containing the values of all state variables and any bound variables used in the model.

The benchmark can be performed in two ways:

fastest=False (default)
Each point in the given log is calculated repeats number of times. For each point, the average time it took to do a single calculation is returned.
fastest=True
Each point in the given log is calculated repeats number of times. For each point, the fastest evaluation time is returned.
bench_part(log, repeats=40000, fastest=False)

This method benchmarks the combined evaluation time of the RHS for all variables passed in when this RhsBenchmarker was created. The combined RHS is benchmarked repeats number of times for every point in the given log.

The argument log should point to a myokit.DataLog or similar containing the values of all state variables and any bound variables used in the model.

Only the selected variables RHS will be evaluated, not their dependencies or nested children variables. Bound and constant variables cannot be selected. If state variables are chosen, their derivative is evaluated.

The benchmark can be performed in two ways:

fastest=False (default)
Each point in the given log is calculated repeats number of times. For each point, the average time it took to do a single calculation is returned.
fastest=True
Each point in the given log is calculated repeats number of times. For each point, the fastest evaluation time is returned.
mean(times)

Like meth:mean_std() but returns only the final mean.

mean_std(times)

Removes outliers and then calculates the mean and standard deviation of the given benchmarked times.