Version: dev

substrate_matrix

Stable function · Reactions

Tier: stable · Kind: function · Topic: Reactions

JuliaTypeScriptPythonRustGo
not exportedsubstrateMatrixsubstrate_matrixnot exportednot exported

Julia

Julia does not export this function.

TypeScript

function substrateMatrix(system: ReactionSystem): number[][]

Compute substrate stoichiometric matrix from a reaction system

Returns the substrate stoichiometric matrix (species × reactions) where:

  • Rows are species (in declaration order)
  • Columns are reactions (in array order)
  • Entry [i][j] = substrate stoichiometry for species i in reaction j
  • Null substrates contribute 0

Parameters

  • system — ReactionSystem to compute matrix from

Returns

Substrate stoichiometric matrix

Source

Python

substrate_matrix(system: ReactionSystem) -> np.ndarray

Compute the substrate (reactant) stoichiometric matrix.

The substrate matrix gives only the reactant stoichiometric coefficients. All entries are non-negative, with S[i,j] giving the coefficient of species i as a reactant in reaction j.

Parameters

  • system (ReactionSystem) — ReactionSystem containing species and reactions

Returns

  • np.ndarray — np.ndarray: Substrate matrix with shape (n_species, n_reactions) where S[i,j] = reactant coefficient of species i in reaction j

Source

Example (stoichiometric_matrix)

# Rows are species (O3, NO, NO2) and columns are reactions (R1, R2).
net = earthsci_ast.stoichiometric_matrix(system)
assert np.array_equal(net, [[-1, 1], [-1, 1], [1, -1]])

consumed = earthsci_ast.substrate_matrix(system)
produced = earthsci_ast.product_matrix(system)
assert np.array_equal(produced - consumed, net)

From docs/api/examples/python/reactions.py

Rust

Rust does not export this function.

Go

Go does not export this function.