DiffEqState#

class braincell.quad.DiffEqState#

Marker mixin for a state that participates in numerical integration.

A DiffEqState is the unit of work consumed by every solver in braincell.quad. It contributes two slots — derivative and diffusion — that the surrounding solver writes during one ODE/SDE step:

  • derivative is 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\).

  • diffusion is the SDE noise coefficient \(g(t, y)\). It stays None for plain ODE systems.

This class is a brainstate.mixin.Mixin, not a brainstate.State. It carries no storage and cannot be instantiated; DiffEqState(value) raises TypeError. Mixing it into something that is not a brainstate.State yields an object no solver will accept. Use state() to allocate, or name DiffEqSingleState / DiffEqGroupState explicitly.

Separating the marker from the storage layout is what lets the two concrete classes be siblings. Solver state selection goes through isinstance(value, DiffEqState) (see braincell.quad._util.split_diffeq_states()), which stays True for both.

Variables:
  • derivative (brainstate.typing.PyTree) – Time derivative (or SDE drift) of the state. Set inside DiffEqModule.compute_derivative(). Must carry units that satisfy unit(derivative) * unit(dt) == unit(value).

  • diffusion (brainstate.typing.PyTree) – Optional SDE diffusion coefficient. None denotes a deterministic ODE system.

See also

DiffEqSingleState

Concrete ungrouped state, used by SingleCompartment.

DiffEqGroupState

Concrete grouped state, used by Cell.

DiffEqModule

Container 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