braincell.quad.exp_euler_step#
- braincell.quad.exp_euler_step(target, *args)[source]#
Advance one step with the (coupled) exponential Euler method.
The exponential Euler method targets semi-linear ODEs of the form
\[\frac{dy}{dt} = A(y_n)\, y + g(t, y),\]where the local Jacobian \(A(y_n) = \partial f / \partial y\) is treated implicitly via the matrix exponential while the residual \(g\) is held frozen at \(y_n\). The update reads
\[y_{n+1} = y_n + \Delta t \, \varphi_1(\Delta t \, A)\, f(t_n, y_n), \qquad \varphi_1(z) = \frac{e^{z} - 1}{z}.\]Equivalently, with \(A\) the local linearization,
\[y_{n+1} = A^{-1}\!\left(e^{\Delta t A} - I\right) f(t_n, y_n) + y_n.\]Because the linear part is integrated exactly, the scheme is A-stable for the local linearization and remains accurate where forward Euler would blow up. It is the workhorse explicit-style integrator for Hodgkin-Huxley type membranes.
Unlike
ind_exp_euler_step(), this routine treats the entire state vector as a single coupled block: it builds the dense local Jacobian over allDiffEqStateleaves, computes its matrix exponential, and applies it in one shot. That captures cross-state coupling exactly to first order in \(\Delta t\) but costs \(O(M^3)\) per step in the state dimension \(M\).- Parameters:
target (
DiffEqModule) – The neuron model to advance. Must be anHHTypedNeuronsubclass — currentlySingleCompartment(states are stacked along[n_neuron, n_state]) orbraincell.Cell(states are concatenated along[n_neuron, n_compartment * n_state]).*args – Extra positional arguments forwarded to
target’spre_integral(),compute_derivative(), andpost_integral()hooks (typically the input current for this step).
- Returns:
target’s differential states are updated in place.- Return type:
None
- Raises:
AssertionError – If target is not an
HHTypedNeuron.ValueError – If target is an
HHTypedNeuronof an unsupported subtype.
See also
ind_exp_euler_stepState-by-state variant that linearizes each
DiffEqStateindependently.backward_euler_stepLinearized backward Euler counterpart.
Notes
The current time and step size are read from the active
brainstate.environcontext.Examples
>>> import brainstate >>> import brainunit as u >>> from braincell.quad import exp_euler_step >>> with brainstate.environ.context(t=0. * u.ms, dt=0.025 * u.ms): ... exp_euler_step(my_neuron, input_current)