sbml_odes() turns a model into what an ODE solver needs: the states,
the right-hand side of each, the assignments evaluated before the
right-hand sides at every time, and the constants.
sbml_initial_state() gives the states' values at time 0.
Value
sbml_odes() returns a list:
states: a data frame with the state'sname, the modelsymbolit belongs to, and itskind("species","compartment", ...);rhs: a named list of expressions, the time derivative of each state;assignments: a named list of expressions in evaluation order;constants: a named numeric vector of the constants' values;initial: the states' values at time 0, assbml_initial_state();species: for each species, whether its symbol is an amount and its compartment, to convert between amounts and concentrations;events: one list per event with itsid,trigger,initial_value,persistent,priorityanddelayexpressions (NULLwhen absent),use_values_from_trigger_time, andassignments, a named list of expressions by target.
sbml_initial_state() returns a named numeric vector.
Details
Species whose symbol is a concentration are integrated as concentrations,
except in a compartment whose size can change, where the amount is
integrated (as the state .amount.<id>) and the concentration is an
assignment. Reaction ids are assignments holding the reaction's rate.
Function definitions are inlined, local parameters become constants named
.local.<reaction>.<id>, and rateOf() is replaced by the right-hand
side it refers to.
Errors
zusbml_unsupportedfor algebraic rules (the model is then a DAE), thedelaycsymbol and fast reactions, each naming the element.zusbml_derive_errorfor an assignment cycle, a missing value, or a name the model does not define, naming the ids involved in itsidsfield.
Examples
m <- sbml_read(system.file("extdata", "decay.xml", package = "zusbml"))
eq <- sbml_odes(m)
eq$rhs
#> $S1
#> -R1/C
#>
#> $S2
#> R1/C
#>
sbml_initial_state(m)
#> S1 S2
#> 1 0