Solutions and the ledger¶
m.solve(...) returns a Solution; sol.ledger is its conservation ledger. See
Reading a model back.
tenqsp.results.Solution
dataclass
¶
Trajectories of a solved model.
t: output times, shape(n_t,);sol["B"]: a field, shape(n_t, *its axis sizes)in the field's axis order, or a compartment, shape(n_t,);sol["burst_rate"]: an observable, shape(n_t,)or(n_t, *sizes)if it varies over axes (sol.observable_axes[name]);y: the flat state, shape(n_t, n_states);stats: solver counters and wall time;messages: notes from the solver (e.g. a segment retried with Radau);options: the solver settings used (method,rtol,atol,max_step), read bym.diagnostics(sol);ledger: the conservation ledger (Ledger), unless the solve was run withledger=False;extinctions:(time, group)for each extinction group set to zero;doses:(time, target, amount, rise)for each bolus given in the run (the model's doses or the regimen that replaced them);riseis how much the dose raised the target state's value (the amount divided by the cell width, weight or volume);infusions:(start, stop, target, rate)for each infusion in the run, as it arrived (lag and bioavailability applied; the stop clipped to the end of the run);coords: per axis, its cell centres (continuous) or labels (categorical), with kind, units and, for continuous axes, cell faces;units: per field and compartment;to_xarray(): everything above as anxarray.Dataset(needs the optional xarray).
At a dose time the state is reported just after the dose.
at(name, t)
¶
Value at an output time (must be one of sol.t).
to_xarray()
¶
The solution as an xarray.Dataset.
Each field is a variable over ("t", *its axes), each compartment over ("t",),
each observable over ("t", *the axes it varies over). Continuous axes carry their
cell centres as coordinates (attributes: kind, units, faces, and
geometry for a radius) and a
<axis>_width coordinate (the widths are also in the axis attribute widths, and
the coordinate is left out if the model uses that name); categorical axes carry their
labels. Field values are densities (or concentrations for weighted fields), exactly as
sol[name].
tenqsp.ledger.Ledger
dataclass
¶
Where the amount of each field and compartment came from and went.
t: output times;initial[name]: amount at the start, before any dose at the start time;amount[name]: amount at each output time;moved[name][channel]: cumulative amount moved in (+) or out (-) since the start;rates[name][channel]: the rate of each channel at each output time (doses, being instantaneous, have no rate);kinds[name][channel]: reaction, hazard, transition, boundary, rate, routed, dose, infusion, bioavailability (the part of the doses that does not arrive, "not absorbed") or extinction;t0: the start of the solve, whereinitialand the cumulative amounts begin.
unexplained(name)
¶
Amount not accounted for by the channels, at each output time (ideally ~0).
scale(name)
¶
Size of the amounts involved, for relative comparisons.
check()
¶
Largest unexplained amount relative to scale, per field and compartment.
table(name=None)
¶
The books from the start to the last output time, as text.