DiffEqState#
- class braincell.quad.DiffEqState(*args, **kwargs)#
A
brainstatestate that participates in numerical integration.A
DiffEqStateis the unit of work consumed by every solver inbraincell.quad. It extendsbrainstate.HiddenStatewith two extra 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.
Solver step functions (
*_step) read the currentvalueof everyDiffEqStatein aDiffEqModule, callDiffEqModule.compute_derivative()to populatederivative(and optionallydiffusion), and then write the integrated result back intovalue.Both setters call
brainstate._state.record_state_value_write()so that any active state-trace stack picks up the assignment — the Runge-Kutta and exponential-Euler drivers rely on this to discover which states actually participate in the integration.- derivative#
Time derivative (or SDE drift) of the state. Set inside
DiffEqModule.compute_derivative(). Must carry units that satisfyunit(derivative) * unit(dt) == unit(value).- Type:
brainstate.typing.PyTree
- diffusion#
Optional SDE diffusion coefficient.
Nonedenotes a deterministic ODE system.- Type:
brainstate.typing.PyTree
See also
DiffEqModuleContainer that owns and updates
DiffEqStateinstances.IndependentIntegrationMixin that excludes a submodule’s states from the main integrator.
- 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