DiffEqModule#
- class braincell.quad.DiffEqModule#
Mixin marking a module as integrable by
braincell.quad.Any class that mixes in
DiffEqModuleexposes the small interface that every numerical integrator inbraincell.quadrelies on:pre_integral()— invoked once at the start of each step, before any derivative is computed. Use it to refresh voltage-dependent rate constants, recompute synaptic input, or perform other one-time-per-step bookkeeping.compute_derivative()— required override that writesstate.derivative(and optionallystate.diffusion) for everyDiffEqStateowned by the module.post_integral()— invoked once at the end of each step, after the integrated values have been written back. Use it to clamp states, project onto manifolds, or fire post-step events.
Concrete subclasses include
braincell.SingleCompartmentandbraincell.Cell. Solvers receive aDiffEqModuleas theirtargetargument and readt/dtfrom the activebrainstate.environcontext.- Variables:
diffeq_state_merging (str) – How the module’s
DiffEqStateleaves are laid out when a solver flattens them into one array —'stack'(the default) gives[..., n_state],'concat'gives[..., n_compartment * n_state]. The host declares this because it is a property of the state layout the host allocated;exp_euler_step()reads it rather than inferring it from the concrete class.
See also
DiffEqStatePer-variable state container the solvers update.
IndependentIntegrationExcludes a submodule from the main solver.
- compute_derivative(*args, **kwargs)[source]#
Compute the derivative of the differential equation.
This method must be implemented by subclasses to define the specific differential equation for the system.
- Parameters:
- Returns:
This method should be overridden in subclasses.
- Return type:
NotImplemented
- Raises:
NotImplementedError – If this method is not overridden in a subclass.