model.roottol¶
The time roadrunner reports the rows of an event of the model at.
libroadrunner reports an event of the model in the steps of the integrator
(variable_step_size) as two rows: the state at the root of its trigger,
before the event, at root - roottol, and the state after the event at
root + roottol; an event which roadrunner finds at the end of a step of
CVODE rather than as a root has its first row at the end of the step less the
machine epsilon (CVODEIntegrator::integrate of libroadrunner 2.10). A first
step of CVODE after an event which ends within roottol of it is not
reported, a second one is, after the row at root + roottol, so the times are
not sorted. roottol is a static const of the function, which the first call
of the process fixes to 100 * 32 * eps * (|t0| + |h|) of that call, t0 and
h the start and the step of the first integration of the process, of any
model: the steps of the integrator over 0..10000, whose first call
integrates the whole interval, fix it to 7.1e-9, roadrunner's default
simulate(0, 10000), 51 output times 200 apart, to 1.42e-10. After the first
of them the rows of every event are 7.1e-9 before and after it, more than
the resolution of the time of a simulation over 0..2.5, and a worker of a
pool, whose first integration is its own, has other rows than the process
which runs the scan.
root_tolerance runs a probe once per process, before the first model
sbmlsim loads (RoadrunnerSBMLModel) and when a worker of a pool starts
(sbmlsim.parallel), unless the main module, which a worker imports first,
integrates when it is imported: a model with one event, whose first
integration spans PIN_SPAN, so roottol is 6.2e-31 in every process in
which sbmlsim integrates first, the two rows of an event have the time of the
event and the first step of CVODE after it is reported. The probe then
measures roottol from the rows of its event, also where an integration
before fixed it, and at_event_times gives the two rows of every event the
time of the event; the executor restores the rows of an event less than
roottol before or after the end of a segment, whose row after it roadrunner
folds into its last row, see sbmlsim.simulator.executor._events_at_the_end.
In a process in which roadrunner integrated before sbmlsim loaded a model, the
steps inside a segment lack the first step of CVODE after an event if it is
shorter than that roottol, which roadrunner does not report, and the rows of
an event which CVODE finds in that step, which roadrunner applies without
rows; a worker of a pool has both, so the rows differ by them and the values
on a grid by the interpolation across them. The probe warns once.
A roadrunner whose roottol is no constant of the process, which the probe
cannot measure or which reports both rows of an event at its time degrades
without an error and without a warning: the probe gives a roottol of 0 and
the rows of an event stay at the times roadrunner reports them, which a time
of a grid sees as a chain of jumps closer than the resolution of the time,
see sbmlsim.result.timecourse.grid_weights. The behavior of libroadrunner
2.10 which sbmlsim depends on is pinned by the tests a new release of
roadrunner has to pass: tests/model/test_roottol.py (the pin, the
measurement and the warning), tests/simulator/test_event_rows.py (the rows
of events after a first integration with roadrunner, in fresh processes),
tests/simulator/test_executor.py (the events at the end of a segment and
of a simulation, the folded rows, the rounding of the output times by
roadrunner and the runs again past the end) and
tests/fit/test_data_at_change.py (the data at an event).
RootTolerance
dataclass
¶
The roottol of roadrunner in the process, see the module.
Attributes:
| Name | Type | Description |
|---|---|---|
value |
float
|
the time between an event and the row of the state after it. |
precision |
float
|
the precision of the measurement of |
root_tolerance
cached
¶
Get the roottol of roadrunner in the process, measured once by a probe.
The probe fixes roottol to PINNED if it is the first integration of
the process, see the module, and measures it as half the time between the
two rows of its event, in two integrations to PROBE_END and to
PROBE_SHORT_END. If roadrunner integrated before, the measured
roottol is larger and a warning names the consequence and the remedy,
once per process. A process which forks keeps the roottol of roadrunner
and the measurement.
Returns:
| Type | Description |
|---|---|
RootTolerance
|
The root tolerance; |
RootTolerance
|
or measures two values, a |
RootTolerance
|
process, so |
RootTolerance
|
roadrunner reports them. |
slack
¶
Get the rounding of the time between two rows of an event.
Four units in the last place of either time and the precision of the
measurement of roottol: the times of the rows of an event are
root -/+ roottol rounded, and a row at the end of a step of CVODE the
end of the step less the machine epsilon.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
earlier
|
ndarray | float
|
the times of the rows before the events. |
required |
later
|
ndarray | float
|
the times of the rows after them. |
required |
tolerance
|
RootTolerance
|
the root tolerance of roadrunner in the process. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
The rounding of the time between the rows. |
at_event_times
¶
Give the two rows of every event of the model the time of the event.
Two rows of the steps of the integrator are an event if the second is
2 * roottol after the first, the root of a trigger, or roottol and at
most the machine epsilon after it, an event at the end of a step of CVODE,
to the rounding of the times and of the measurement of roottol. Both
rows get the time of the second less roottol, the time of the event, so
an event is a jump at one time, as a change is, see the module. A row
belongs to one event, the rows are taken from the first. roadrunner's last
row, interpolated to the end, is no row of an event and is left out by the
caller, see sbmlsim.simulator.executor._at_event_times.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
ndarray
|
the times of the rows, in their order. |
required |
tolerance
|
RootTolerance
|
the root tolerance of roadrunner in the process, see
|
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
The times, a copy. |