DiffEqState#
- class braincell.quad.DiffEqState#
Marker mixin for a state that participates in numerical integration.
A
DiffEqStateis the unit of work consumed by every solver inbraincell.quad. It contributes two slots —derivativeanddiffusion— that the surrounding solver writes during one ODE/SDE step:derivativeis the right-hand side \(f(t, y)\) for an ODE \(\dot y = f(t, y)\), or the drift term for an SDE \(dy = f(t, y)\,dt + g(t, y)\,dW\).diffusionis the SDE noise coefficient \(g(t, y)\). It staysNonefor plain ODE systems.
This class is a
brainstate.mixin.Mixin, not abrainstate.State. It carries no storage and cannot be instantiated;DiffEqState(value)raisesTypeError. Mixing it into something that is not abrainstate.Stateyields an object no solver will accept. Usestate()to allocate, or nameDiffEqSingleState/DiffEqGroupStateexplicitly.Separating the marker from the storage layout is what lets the two concrete classes be siblings. Solver state selection goes through
isinstance(value, DiffEqState)(seebraincell.quad._util.split_diffeq_states()), which staysTruefor both.- Variables:
derivative (brainstate.typing.PyTree) – Time derivative (or SDE drift) of the state. Set inside
DiffEqModule.compute_derivative(). Must carry units that satisfyunit(derivative) * unit(dt) == unit(value).diffusion (brainstate.typing.PyTree) – Optional SDE diffusion coefficient.
Nonedenotes a deterministic ODE system.
See also
DiffEqSingleStateConcrete ungrouped state, used by
SingleCompartment.DiffEqGroupStateConcrete grouped state, used by
Cell.DiffEqModuleContainer that owns and updates the states.
- property derivative#
Get the derivative of the state.
- Returns:
The derivative of the state, used to compute the derivative of the ODE system or the drift of the SDE system.
- Return type:
brainstate.typing.PyTree
- property diffusion#
Get the diffusion of the state.
- Returns:
The diffusion of the state, used to compute the diffusion of the SDE system. If it is None, the system is considered as an ODE system.
- Return type:
brainstate.typing.PyTree