braincell.quad module#

Numerical integrators for BrainCell.

Exposes get_integrator() plus every canonical solver name registered in braincell.quad._registry.

Note

This __init__.py deliberately performs side-effect imports of every _<backend>.py module. Each backend self-registers into the integrator registry at import time via @register_integrator. Do not lazily defer these imports — unresolved solver names would surface as ValueError: unknown integrator from get_integrator() at first call instead of at import time.

braincell.quad provides a mechanism to define coupled ordinary differential equations (ODEs) and solve them using various numerical integration methods. The integration methods are categorized into exponential integrators, Runge-Kutta methods, and implicit methods.

Defining Coupled ODEs#

DiffEqState

A brainstate state that participates in numerical integration.

DiffEqModule

Mixin marking a module as integrable by braincell.quad.

IndependentIntegration

Mixin that opts a submodule out of its parent's integration loop.

Integrator Registry#

IntegratorEntry

A single registered integrator and its metadata.

IntegratorRegistry

Mutable, observable registry of integrator step functions.

get_integrator

Resolve a numerical integrator from a string name or a callable.

get_registry

Return the process-wide IntegratorRegistry singleton.

register_integrator

Decorator: register the wrapped function in the global registry.

all_integrators

Backwards-compatible mapping view of the integrator registry.

Exponential Integrators#

exp_euler_step(target, *args)

Advance one step with the (coupled) exponential Euler method.

exp_exp_euler_step(target, t, dt, *args)

Advance a cell with exponential cable and exponential Euler channels.

ind_exp_euler_step(target, *args[, ...])

Advance each DiffEqState independently with exponential Euler.

Runge-Kutta Integrators#

euler_step(target, *args)

Advance one step with the explicit (forward) Euler method.

midpoint_step(target, *args)

Advance one step with the explicit midpoint (modified Euler) method.

rk2_step(target, *args)

Advance one step with a generic second-order Runge-Kutta method.

heun2_step(target, *args)

Advance one step with Heun's second-order Runge-Kutta method.

ralston2_step(target, *args)

Advance one step with Ralston's second-order Runge-Kutta method.

rk3_step(target, *args)

Advance one step with the classical third-order Runge-Kutta method.

heun3_step(target, *args)

Advance one step with Heun's third-order Runge-Kutta method.

ssprk3_step(target, *args)

Advance one step with the Strong-Stability-Preserving RK3 method.

ralston3_step(target, *args)

Advance one step with Ralston's third-order Runge-Kutta method.

rk4_step(target, *args)

Advance one step with the classical fourth-order Runge-Kutta method.

ralston4_step(target, *args)

Advance one step with Ralston's fourth-order Runge-Kutta method.

Implicit Integrators#

backward_euler_step(target, *args[, ...])

Advance one step with the linearised backward (implicit) Euler method.

implicit_euler_step(target, t, dt, *args)

Advance one step with the implicit (backward) Euler method.

implicit_exp_euler_step(target, t, dt, *args)

Advance a cell with implicit Euler voltage and exponential Euler channels.

implicit_rk4_step(target, t, dt, *args)

Advance a cell with implicit Euler voltage and explicit RK4 channels.

Other Integrators#

cn_exp_euler_step(target, t, dt, *args)

Advance a cell with Crank-Nicolson voltage and exponential Euler channels.

cn_rk4_step(target, t, dt, *args)

Advance a cell with Crank-Nicolson voltage and explicit RK4 channels.

splitting_step(target, t, dt, *args)

Advance a multi-compartment cell with operator-splitting.

staggered_step(target, *args)

Advance a multi-compartment cell by one staggered time step.