Version: dev

lower_reactions_to_equations

Stable function · Reactions

Tier: stable · Kind: function · Topic: Reactions

JuliaTypeScriptPythonRustGo
lower_reactions_to_equationsnot exportednot exportedlower_reactions_to_equationsnot exported

Julia

lower_reactions_to_equations(reactions::Vector{Reaction}, species::Vector{Species})
lower_reactions_to_equations(reactions, species) -> Vector{Equation}

Produce the ODE equations induced by a set of reactions using standard mass-action kinetics: d[X]/dt = Σ (stoich_ij * rate_j).

Shared by derive_odes (reaction → Model) and flatten (EsmFile → FlattenedSystem) so there is exactly one place that turns stoichiometry into equations.

The tree is the canonical form esm-libraries-spec §4.6.2 pins byte for byte across the bindings (tests/conformance/reactions/lowering_form.json): an n-ary + over the species’ terms in reaction order, each term the bare rate law or stoich * rate with an integer literal for an integral coefficient.

The LHS is always D(X, t) symbolically, regardless of the document’s domain — dimension promotion (§4.7.6) is applied by flatten, not here. Spatial operators are added downstream when coupling adds them.

A species with constant: true is a RESERVOIR (§7.4): it is held fixed, so no D(X, t) equation is emitted for it, while it still contributes its concentration to every rate law it appears in. It is therefore skipped as an equation TARGET only — it stays in species so mass_action_rate keeps reading it as a substrate/product factor.

A species whose NET stoichiometry is zero in every reaction likewise gets no equation — usually because it appears in no reaction at all, but a catalyst (equal substrate and product stoichiometry everywhere it appears) meets the same test. Its rate is the empty sum, and emitting D(X, t) = 0 for it would make it a differential unknown that never moves; esm-spec §6.3.1 classifies by COMPLEMENT, so leaving the equation out is what makes it the ALGEBRAIC unknown it is. See the comment at the skip below.

Source

TypeScript

TypeScript does not export this function.

Python

Python does not export this function.

Rust

pub fn lower_reactions_to_equations(reactions: &[Reaction], species: &IndexMap<String, Species>) -> Result<Vec<Equation>, DeriveError>

Lower a reaction network to an ODE equation list.

Produces one D(species, t) = Σ(net_stoichiometry · rate) equation per species per spec §4.7.5 step 1. Reusable from both derive_odes and crate::flatten::flatten so the reaction-to-equation core lives in one place.

Each reaction’s base rate is enhanced with mass-action concentration factors per spec §7.4 (the rate field is the coefficient; the runner always multiplies by the substrate product). Net stoichiometry combines substrate and product contributions for each species.

Source · Rust docs

Go

Go does not export this function.