Version: dev

species

Stable type · Document types

Tier: stable · Kind: type · Topic: Document types

JuliaTypeScriptPythonRustGo
Speciesnot exportedSpeciesSpeciesSpecies

Julia

struct Species
Species(name::String; units, default, description, default_units, constant)
Species

Chemical species definition with name and optional properties.

Source

TypeScript

TypeScript does not export this type.

Python

class Species
Species(name: str, units: str | None = None, default: float | None = None, default_units: str | None = None, description: str | None = None, formula: str | None = None, constant: bool | None = None)

A chemical species in a reaction system.

Source

Example (reactions)

doc = earthsci_ast.load_path(FIXTURES / "ozone.esm")
system = doc.reaction_systems["Ozone"]
assert [s.name for s in system.species] == ["O3", "NO", "NO2"]
assert [r.id for r in system.reactions] == ["R1", "R2"]

odes = earthsci_ast.derive_odes(system)
for eq in odes.equations:
    print(earthsci_ast.to_ascii(eq))

# One equation per species, in declaration order; rate constants become parameters.
assert earthsci_ast.ode_states(odes) == ["NO", "NO2", "O3"]
assert [eq.lhs.args[0] for eq in odes.equations] == ["O3", "NO", "NO2"]
assert odes.variables["k1"].type == "parameter"
assert earthsci_ast.to_ascii(odes.equations[2]) == "D(NO2)/Dt = k1 * NO * O3 + -1 * jNO2 * NO2"

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

Rust

pub struct Species {
    pub units: Option<String>,
    pub default: Option<f64>,
    pub default_units: Option<String>,
    pub description: Option<String>,
    pub constant: Option<bool>,
}

Chemical species in a reaction system. Keyed by name in the parent map.

Source · Rust docs

Go

type Species struct {
	Units   *string `json:"units,omitempty"`
	Default any     `json:"default,omitempty"`
	// DefaultUnits declares the units the scalar `default` is expressed in when
	// they differ from `units` — the Species twin of ModelVariable.DefaultUnits.
	// `omitempty`: an optional key, absent from most species.
	DefaultUnits *string `json:"default_units,omitempty"`
	Description  *string `json:"description,omitempty"`
	// Constant marks reservoir species (held fixed, no ODE).
	// Maps to Catalyst's isconstantspecies=true.
	Constant *bool `json:"constant,omitempty"`
}

func (s *Species) UnmarshalJSON(data []byte) error

Species represents a chemical species

Methods

func (s *Species) UnmarshalJSON(data []byte) error

Custom JSON unmarshaling for Species. Decodes default through UnmarshalExpression so an integer-valued default keeps its int wire shape (RFC §5.4.1); a plain decode would coerce it to float64 and re-emit “1.0”.

Source · Go docs