aeif_psc_delta_clopath#

class brainpy.state.aeif_psc_delta_clopath(in_size, V_peak=Quantity(33., "mV"), V_reset=Quantity(-60., "mV"), t_ref=Quantity(0., "ms"), g_L=Quantity(30., "nS"), C_m=Quantity(281., "pF"), E_L=Quantity(-70.6, "mV"), Delta_T=Quantity(2., "mV"), tau_w=Quantity(144., "ms"), tau_z=Quantity(40., "ms"), tau_V_th=Quantity(50., "ms"), V_th_max=Quantity(30.4, "mV"), V_th_rest=Quantity(-50.4, "mV"), tau_u_bar_plus=Quantity(7., "ms"), tau_u_bar_minus=Quantity(10., "ms"), tau_u_bar_bar=Quantity(500., "ms"), a=Quantity(4., "nS"), b=Quantity(80.5, "pA"), I_sp=Quantity(400., "pA"), I_e=Quantity(0., "pA"), A_LTD=0.00014, A_LTP=8e-05, theta_plus=Quantity(-45.3, "mV"), theta_minus=Quantity(-70.6, "mV"), A_LTD_const=True, delay_u_bars=Quantity(5., "ms"), u_ref_squared=60.0, gsl_error_tol=1e-06, t_clamp=Quantity(2., "ms"), V_clamp=Quantity(33., "mV"), V_initializer=Constant(value=-70.6 mV), w_initializer=Constant(value=0. pA), z_initializer=Constant(value=0. pA), V_th_initializer=Constant(value=-50.4 mV), u_bar_plus_initializer=Constant(value=-70.6 mV), u_bar_minus_initializer=Constant(value=-70.6 mV), u_bar_bar_initializer=Constant(value=-70.6 mV), spk_fun=ReluGrad(alpha=0.3, width=1.0), spk_reset='hard', ref_var=False, name=None)#

Adaptive exponential integrate-and-fire neuron with delta-shaped synaptic input and Clopath voltage traces.

This model extends the standard adaptive exponential integrate-and-fire (AdEx) neuron with additional state variables required for voltage-based Clopath plasticity. It implements delta-function postsynaptic currents (instantaneous voltage jumps), spike afterpotential dynamics, adaptive threshold, post-spike voltage clamping, and three low-pass filtered voltage traces (u_bar_plus, u_bar_minus, u_bar_bar) used by the Clopath learning rule.

1. Membrane and Adaptation Dynamics

The subthreshold membrane potential evolves according to:

\[C_m \frac{dV}{dt} = -g_L (V - E_L) + g_L \Delta_T \exp\!\left(\frac{V - V_{th}}{\Delta_T}\right) - w + z + I_e + I_{stim},\]

where \(V\) is the membrane potential, \(w\) is the adaptation current, \(z\) is the spike afterpotential current, \(V_{th}\) is the adaptive threshold, \(I_e\) is constant external current, and \(I_{stim}\) is the one-step delayed synaptic input. The exponential term provides the spike upstroke when \(\Delta_T > 0\).

Three auxiliary currents evolve as:

\[\begin{split}\tau_w \frac{dw}{dt} &= a (V - E_L) - w, \\ \tau_z \frac{dz}{dt} &= -z, \\ \tau_{V_{th}} \frac{dV_{th}}{dt} &= -(V_{th} - V_{th,rest}).\end{split}\]

The adaptation current \(w\) provides subthreshold coupling and spike-frequency adaptation. The afterpotential \(z\) creates a depolarizing transient following each spike. The adaptive threshold \(V_{th}\) relaxes toward \(V_{th,rest}\) between spikes and jumps to \(V_{th,max}\) upon spike emission.

2. Clopath Low-Pass Voltage Traces

Three filtered voltage variables are maintained for plasticity:

\[\begin{split}\tau_{u+} \frac{du_{bar+}}{dt} &= -u_{bar+} + V, \\ \tau_{u-} \frac{du_{bar-}}{dt} &= -u_{bar-} + V, \\ \tau_{u\bar{}} \frac{du_{bar\bar{}}}{dt} &= -u_{bar\bar{}} + u_{bar-}.\end{split}\]

These traces are first-order low-pass filters of the membrane voltage with different time constants. u_bar_plus and u_bar_minus filter \(V\) directly; u_bar_bar is a second-order filter (filters u_bar_minus). Delayed versions (delayed by delay_u_bars) are stored in ring buffers for use by Clopath synaptic plasticity rules.

3. Delta-Function Synaptic Input

Incoming synaptic spikes cause instantaneous voltage jumps:

\[V \leftarrow V + \sum_k J_k \delta(t - t_k^{\mathrm{spike}}),\]

where \(J_k\) is the synaptic weight from presynaptic neuron \(k\). Delta inputs are summed from the delta_inputs dictionary and applied at the beginning of each accepted RKF45 substep (but only when the neuron is neither refractory nor clamped).

4. Spike Detection and Reset

Spike detection threshold depends on \(\Delta_T\):

  • If \(\Delta_T > 0\): threshold is V_peak (exponential blowup detector).

  • If \(\Delta_T = 0\): threshold is the dynamic V_th (standard IF threshold).

Upon threshold crossing, the following spike-triggered updates occur:

\[\begin{split}V &\leftarrow V_{\mathrm{clamp}}, \\ w &\leftarrow w + b, \\ z &\leftarrow I_{sp}, \\ V_{th} &\leftarrow V_{th,max}, \\ \text{clamp\_step\_count} &\leftarrow \lceil t_{\mathrm{clamp}} / dt \rceil + 1.\end{split}\]

5. Post-Spike Clamping and Refractory Period

The model implements a two-stage reset:

  1. Clamping stage (duration t_clamp): voltage is held at V_clamp, and adaptation dynamics are frozen (dw/dt = 0). At the end of clamping (when clamp_step_count reaches 1 during substep integration), voltage is reset to V_reset and the refractory period begins.

  2. Refractory stage (duration t_ref): voltage is clamped to V_reset, but adaptation dynamics continue (dw/dt != 0). Spike detection is disabled during both clamping and refractory.

This two-stage mechanism reproduces NEST’s spike handling order and allows modeling of realistic action potential waveforms with controlled overshoot.

6. Numerical Integration

The continuous-time dynamics are integrated using an adaptive Runge-Kutta-Fehlberg 4(5) solver (RKF45) with local error control. The integrator maintains a persistent step size (integration_step) that adapts based on local truncation error estimates. During refractory or clamping, the effective voltage used in the right-hand side is replaced with V_reset or V_clamp, but state integration continues.

Parameters:
  • in_size (int or tuple of int) – Population shape. Scalar for 1D populations, tuple for multi-dimensional arrays.

  • V_peak (ArrayLike, default: 33.0 * u.mV) – Spike detection threshold when Delta_T > 0. Must satisfy V_peak > V_th_rest. Shape: scalar or broadcastable to in_size.

  • V_reset (ArrayLike, default: -60.0 * u.mV) – Reset potential after clamping ends. Must satisfy V_reset < V_peak. Shape: scalar or broadcastable to in_size.

  • t_ref (ArrayLike, default: 0.0 * u.ms) – Absolute refractory period duration (non-negative). Default of 0 ms matches NEST defaults. Shape: scalar or broadcastable to in_size.

  • g_L (ArrayLike, default: 30.0 * u.nS) – Leak conductance (must be positive). Shape: scalar or broadcastable to in_size.

  • C_m (ArrayLike, default: 281.0 * u.pF) – Membrane capacitance (must be positive). Shape: scalar or broadcastable to in_size.

  • E_L (ArrayLike, default: -70.6 * u.mV) – Leak reversal potential. Shape: scalar or broadcastable to in_size.

  • Delta_T (ArrayLike, default: 2.0 * u.mV) – Exponential slope factor (non-negative). Set to 0 for non-exponential IF model. Shape: scalar or broadcastable to in_size.

  • tau_w (ArrayLike, default: 144.0 * u.ms) – Adaptation current time constant (must be positive). Shape: scalar or broadcastable to in_size.

  • tau_z (ArrayLike, default: 40.0 * u.ms) – Spike afterpotential time constant (must be positive). Shape: scalar or broadcastable to in_size.

  • tau_V_th (ArrayLike, default: 50.0 * u.ms) – Adaptive threshold time constant (must be positive). Shape: scalar or broadcastable to in_size.

  • V_th_max (ArrayLike, default: 30.4 * u.mV) – Threshold value immediately after spike. Must satisfy V_th_max >= V_th_rest. Shape: scalar or broadcastable to in_size.

  • V_th_rest (ArrayLike, default: -50.4 * u.mV) – Resting threshold value (asymptotic value between spikes). Must satisfy V_th_rest <= V_peak. Shape: scalar or broadcastable to in_size.

  • tau_u_bar_plus (ArrayLike, default: 7.0 * u.ms) – Time constant for u_bar_plus trace (must be positive). Shape: scalar or broadcastable to in_size.

  • tau_u_bar_minus (ArrayLike, default: 10.0 * u.ms) – Time constant for u_bar_minus trace (must be positive). Shape: scalar or broadcastable to in_size.

  • tau_u_bar_bar (ArrayLike, default: 500.0 * u.ms) – Time constant for u_bar_bar trace (must be positive). Shape: scalar or broadcastable to in_size.

  • a (ArrayLike, default: 4.0 * u.nS) – Subthreshold adaptation coupling strength. Shape: scalar or broadcastable to in_size.

  • b (ArrayLike, default: 80.5 * u.pA) – Spike-triggered adaptation increment. Shape: scalar or broadcastable to in_size.

  • I_sp (ArrayLike, default: 400.0 * u.pA) – Spike afterpotential current reset value (sets z on spike). Shape: scalar or broadcastable to in_size.

  • I_e (ArrayLike, default: 0.0 * u.pA) – Constant external current. Shape: scalar or broadcastable to in_size.

  • A_LTD (ArrayLike, default: 1.4e-4) – Clopath depression amplitude (dimensionless). Used in delayed-buffer bookkeeping for compatibility. Shape: scalar or broadcastable to in_size.

  • A_LTP (ArrayLike, default: 8.0e-5) – Clopath potentiation amplitude (dimensionless). Used in delayed-buffer bookkeeping for compatibility. Shape: scalar or broadcastable to in_size.

  • theta_plus (ArrayLike, default: -45.3 * u.mV) – Clopath potentiation voltage threshold. Shape: scalar or broadcastable to in_size.

  • theta_minus (ArrayLike, default: -70.6 * u.mV) – Clopath depression voltage threshold. Shape: scalar or broadcastable to in_size.

  • A_LTD_const (bool, default: True) – If True, LTD amplitude is constant. If False, LTD scales with u_bar_bar**2 / u_ref_squared (homeostatic).

  • delay_u_bars (ArrayLike, default: 5.0 * u.ms) – Delay for Clopath u-bar traces (ring buffer delay). Rounded to nearest integer multiple of dt. Shape: scalar or broadcastable to in_size.

  • u_ref_squared (ArrayLike, default: 60.0) – Clopath LTD homeostatic reference (dimensionless, must be positive). Only used when A_LTD_const=False. Shape: scalar or broadcastable to in_size.

  • gsl_error_tol (ArrayLike, default: 1e-6) – RKF45 local error tolerance (must be positive). Smaller values increase accuracy and decrease step size. Shape: scalar or broadcastable to in_size.

  • t_clamp (ArrayLike, default: 2.0 * u.ms) – Spike clamping duration (non-negative). Shape: scalar or broadcastable to in_size.

  • V_clamp (ArrayLike, default: 33.0 * u.mV) – Clamped voltage immediately after spike. Shape: scalar or broadcastable to in_size.

  • V_initializer (Callable, default: braintools.init.Constant(-70.6 * u.mV)) – Initializer for membrane potential. Must return values with voltage units.

  • w_initializer (Callable, default: braintools.init.Constant(0.0 * u.pA)) – Initializer for adaptation current. Must return values with current units.

  • z_initializer (Callable, default: braintools.init.Constant(0.0 * u.pA)) – Initializer for spike afterpotential current. Must return values with current units.

  • V_th_initializer (Callable, default: braintools.init.Constant(-50.4 * u.mV)) – Initializer for adaptive threshold. Must return values with voltage units.

  • u_bar_plus_initializer (Callable, default: braintools.init.Constant(-70.6 * u.mV)) – Initializer for u_bar_plus trace. Must return values with voltage units.

  • u_bar_minus_initializer (Callable, default: braintools.init.Constant(-70.6 * u.mV)) – Initializer for u_bar_minus trace. Must return values with voltage units.

  • u_bar_bar_initializer (Callable, default: braintools.init.Constant(-70.6 * u.mV)) – Initializer for u_bar_bar trace. Must return values with voltage units.

  • spk_fun (Callable, default: braintools.surrogate.ReluGrad()) – Surrogate gradient function for differentiable spike generation during training.

  • spk_reset (str, default: 'hard') – Spike reset mode. ‘hard’ (stop_gradient) matches NEST behavior; ‘soft’ (V -= V_th) preserves gradients.

  • ref_var (bool, default: False) – If True, expose refractory state variable indicating whether neuron is refractory or clamped.

  • name (str, optional) – Name for this neuron instance.

Parameter Mapping

The table below maps BrainPy parameters to their mathematical symbols and NEST equivalents:

Parameter

Default

Math Symbol

Description

in_size

(required)

Population shape

V_peak

33 mV

\(V_\mathrm{peak}\)

Spike detection threshold for \(\Delta_T > 0\)

V_reset

-60 mV

\(V_\mathrm{reset}\)

Reset potential

t_ref

0 ms

\(t_\mathrm{ref}\)

Absolute refractory duration

g_L

30 nS

\(g_\mathrm{L}\)

Leak conductance

C_m

281 pF

\(C_\mathrm{m}\)

Membrane capacitance

E_L

-70.6 mV

\(E_\mathrm{L}\)

Leak reversal potential

Delta_T

2 mV

\(\Delta_T\)

Exponential slope factor

tau_w

144 ms

\(\tau_w\)

Adaptation time constant

tau_z

40 ms

\(\tau_z\)

Spike afterpotential time constant

tau_V_th

50 ms

\(\tau_{V_{th}}\)

Adaptive threshold time constant

V_th_max

30.4 mV

\(V_{th,\mathrm{max}}\)

Threshold value immediately after spike

V_th_rest

-50.4 mV

\(V_{th,\mathrm{rest}}\)

Resting threshold value

tau_u_bar_plus

7 ms

\(\tau_{u+}\)

Time constant of u_bar_plus

tau_u_bar_minus

10 ms

\(\tau_{u-}\)

Time constant of u_bar_minus

tau_u_bar_bar

500 ms

\(\tau_{u\bar{}}\)

Time constant of u_bar_bar

a

4 nS

\(a\)

Subthreshold adaptation strength

b

80.5 pA

\(b\)

Spike-triggered adaptation increment

I_sp

400 pA

\(I_{sp}\)

Spike afterpotential current reset value

I_e

0 pA

\(I_\mathrm{e}\)

Constant external current

A_LTD

1.4e-4

\(A_\mathrm{LTD}\)

Clopath depression amplitude

A_LTP

8.0e-5

\(A_\mathrm{LTP}\)

Clopath potentiation amplitude

theta_plus

-45.3 mV

\(\theta_+\)

Clopath potentiation threshold

theta_minus

-70.6 mV

\(\theta_-\)

Clopath depression threshold

A_LTD_const

True

If False, homeostatic LTD scaling

delay_u_bars

5 ms

Delay for Clopath u-bar buffers

u_ref_squared

60

\(u_\mathrm{ref}^2\)

Clopath LTD homeostatic reference

gsl_error_tol

1e-6

RKF45 local error tolerance

t_clamp

2 ms

\(t_\mathrm{clamp}\)

Spike clamping duration

V_clamp

33 mV

\(V_\mathrm{clamp}\)

Clamped voltage after spike

V_initializer

Constant(E_L)

Membrane voltage initializer

w_initializer

Constant(0 pA)

Adaptation current initializer

z_initializer

Constant(0 pA)

Spike afterpotential initializer

V_th_initializer

Constant(-50.4 mV)

Adaptive threshold initializer

u_bar_plus_initializer

Constant(-70.6 mV)

u_bar_plus initializer

u_bar_minus_initializer

Constant(-70.6 mV)

u_bar_minus initializer

u_bar_bar_initializer

Constant(-70.6 mV)

u_bar_bar initializer

spk_fun

ReluGrad()

Surrogate spike function

spk_reset

'hard'

Reset mode ('hard' or 'soft')

ref_var

False

If True, expose refractory indicator

V#

Membrane potential (mV). Shape: (*in_size,).

Type:

brainstate.HiddenState

w#

Adaptation current (pA). Shape: (*in_size,).

Type:

brainstate.HiddenState

z#

Spike afterpotential current (pA). Shape: (*in_size,).

Type:

brainstate.HiddenState

V_th#

Adaptive threshold (mV). Shape: (*in_size,).

Type:

brainstate.HiddenState

u_bar_plus#

Clopath low-pass filtered voltage trace (mV). Shape: (*in_size,).

Type:

brainstate.HiddenState

u_bar_minus#

Clopath low-pass filtered voltage trace (mV). Shape: (*in_size,).

Type:

brainstate.HiddenState

u_bar_bar#

Clopath second-order filtered voltage trace (mV). Shape: (*in_size,).

Type:

brainstate.HiddenState

refractory_step_count#

Remaining refractory time steps (int32). Shape: (*in_size,).

Type:

brainstate.ShortTermState

clamp_step_count#

Remaining clamping time steps (int32). Shape: (*in_size,).

Type:

brainstate.ShortTermState

integration_step#

Current RKF45 adaptive step size (ms). Shape: (*in_size,).

Type:

brainstate.ShortTermState

I_stim#

One-step delayed synaptic current (pA). Shape: (*in_size,).

Type:

brainstate.ShortTermState

delayed_u_bar_plus_buffer#

Ring buffer for delayed u_bar_plus (mV). Shape: (delay_steps, *in_size).

Type:

brainstate.ShortTermState

delayed_u_bar_minus_buffer#

Ring buffer for delayed u_bar_minus (mV). Shape: (delay_steps, *in_size).

Type:

brainstate.ShortTermState

delayed_u_bars_idx#

Current ring buffer write index (int32). Scalar.

Type:

brainstate.ShortTermState

delayed_u_bars_steps#

Total ring buffer size (int32). Scalar.

Type:

brainstate.ShortTermState

last_spike_time#

Last spike time (ms). Shape: (*in_size,).

Type:

brainstate.ShortTermState

refractory#

Boolean indicator: True if neuron is refractory or clamped. Only present if ref_var=True. Shape: (*in_size,).

Type:

brainstate.ShortTermState, optional

Raises:

ValueError

  • If V_reset >= V_peak. - If Delta_T < 0. - If V_th_max < V_th_rest or V_peak < V_th_rest. - If C_m <= 0, t_ref < 0, t_clamp < 0, or any time constant <= 0. - If u_ref_squared <= 0 or gsl_error_tol <= 0. - If (V_peak - V_th_rest) / Delta_T exceeds overflow limit (when Delta_T > 0). - If delay_u_bars maps to fewer than 1 delay buffer entry. - If delay_u_bars is spatially heterogeneous (delay steps must be uniform). - If numerical instability is detected during integration (voltage or adaptation out of bounds).

Notes

Implementation Details:

  • RKF45 integration: Uses adaptive-step Runge-Kutta-Fehlberg 4(5) with error control. Step size is persisted across time steps to improve stability. Minimum step size is 1e-8 ms; maximum iteration count is 100000 per dt to prevent infinite loops.

  • Refractory/clamping precedence: During integration, if clamp_step_count > 0, voltage is clamped to V_clamp and adaptation dynamics freeze. If refractory_step_count > 0 (and not clamped), voltage is clamped to V_reset but adaptation continues. Both conditions disable spike detection.

  • Delta input timing: Delta voltage jumps are applied at the start of each accepted substep, but only when the neuron is neither refractory nor clamped. This matches NEST’s per-substep spike delivery.

  • Spike timing convention: last_spike_time is set to t + dt upon spike emission (end of current time step), matching NEST’s convention.

  • Clopath buffer bookkeeping: This implementation maintains delayed u_bar_plus and u_bar_minus buffers even without a dedicated Clopath synapse model, ensuring state-level compatibility with NEST for future plasticity extensions. The delayed traces are updated at the end of each update() call.

  • Overflow protection: The exponential term is guarded against overflow when Delta_T > 0. If (V_peak - V_th_rest) / Delta_T would cause exp(...) to exceed max(float64) / 1e20, an error is raised during initialization.

Usage:

This model is designed for voltage-based plasticity studies and detailed spike waveform modeling. Use Delta_T > 0 for exponential IF dynamics (rapid spike upstroke) or Delta_T = 0 for standard IF with dynamic threshold. The t_clamp and V_clamp parameters control the spike overshoot and allow modeling realistic action potential shapes. For basic AdEx simulations without Clopath plasticity, consider using the simpler aeif_psc_delta or aeif_psc_exp models (if available).

See also

aeif_psc_delta

Simplified AdEx without Clopath traces or clamping.

aeif_psc_exp

AdEx with exponential postsynaptic currents.

clopath_synapse

Voltage-based STDP synapse (NEST reference).

References

Examples

Simulate a single neuron with step current input:

>>> import brainpy.state as bst
>>> import brainstate as bs
>>> import saiunit as u
>>> import matplotlib.pyplot as plt
>>>
>>> # Create neuron population
>>> neuron = bst.aeif_psc_delta_clopath(in_size=1, I_e=300*u.pA)
>>>
>>> # Simulate for 100 ms
>>> with bs.environ.context(dt=0.1*u.ms):
...     neuron.init_state()
...     times, voltages = [], []
...     for t in range(1000):
...         spike = neuron.update()
...         times.append(t * 0.1)
...         voltages.append(float(neuron.V.value / u.mV))
>>>
>>> # Plot membrane potential
>>> plt.plot(times, voltages)
>>> plt.xlabel('Time (ms)')
>>> plt.ylabel('Voltage (mV)')
>>> plt.show()

Network simulation with delta-function synaptic connections:

>>> import brainpy.state as bst
>>> import brainstate as bs
>>> import saiunit as u
>>>
>>> # Create excitatory and inhibitory populations
>>> exc = bst.aeif_psc_delta_clopath(in_size=100, I_e=200*u.pA)
>>> inh = bst.aeif_psc_delta_clopath(in_size=25, I_e=150*u.pA)
>>>
>>> # Create delta-function projection (instantaneous voltage jump)
>>> # Note: Requires appropriate projection class that adds delta inputs
>>> # exc_to_inh = bst.DeltaProj(exc, inh, weight=0.5*u.mV, prob=0.1)
>>>
>>> # Simulate network
>>> with bs.environ.context(dt=0.1*u.ms):
...     exc.init_state()
...     inh.init_state()
...     for t in range(10000):  # 1 second
...         exc_spikes = exc.update()
...         inh_spikes = inh.update()
get_spike(V=None)[source]#

Compute differentiable spike output using surrogate gradient function.

Applies the surrogate gradient function to a scaled voltage relative to the dynamic threshold. This produces a continuous approximation of discrete spikes, enabling gradient-based learning. The scaling factor (v_th - V_reset) normalizes the voltage range for the surrogate function.

Parameters:

V (ArrayLike, optional) – Membrane potential (mV). If None, uses current self.V.value. Shape: (*in_size,).

Returns:

spike – Differentiable spike signal (dimensionless, approximately in [0, 1] for most surrogate functions). Shape matches input V.

Return type:

ArrayLike

Notes

  • This method is primarily used during training with surrogate gradient descent.

  • During inference with update(), spikes are detected via hard threshold crossing (not this function).

  • The threshold used is the dynamic V_th (if available) or the resting V_th_rest otherwise.

  • The surrogate function is configured via the spk_fun parameter (default: ReluGrad).

See also

update

Hard spike detection and state integration.

init_state(**kwargs)[source]#

Initialize all state variables.

Allocates and initializes all neuron state variables using the configured initializers. This includes membrane dynamics states (V, w, z, V_th), Clopath voltage traces (u_bar_plus, u_bar_minus, u_bar_bar), refractory/clamping counters, RKF45 integration state, and delayed-buffer bookkeeping for Clopath plasticity.

Parameters:

**kwargs – Unused compatibility parameters accepted by the base-state API.

Notes

  • last_spike_time is initialized to -1e7 ms (far in the past) to indicate no prior spike.

  • refractory_step_count and clamp_step_count are initialized to 0 (not refractory/clamped).

  • integration_step is initialized to the current simulation time step (dt).

  • Clopath delay buffers are allocated with size ceil(delay_u_bars / dt) + 1.

  • If ref_var=True, an additional refractory boolean state is created.

Raises:
  • ValueError – If an initializer cannot be broadcast to requested shape.

  • TypeError – If initializer outputs have incompatible units/dtypes for the corresponding state variables.

See also

reset_state

Reset existing states to initial values.

update(x=Quantity(0., 'pA'))[source]#

Advance neuron state by one time step using adaptive RKF45 integration.

Integrates the neuron dynamics over the current simulation time step dt using an adaptive Runge-Kutta-Fehlberg 4(5) solver with local error control. Handles spike detection, post-spike reset, refractory period, voltage clamping, delta-function synaptic inputs, and Clopath trace updates. Returns binary spike output for the current time step.

Parameters:

x (ArrayLike, default: 0.0 * u.pA) – External input current for the current time step (pA). This is combined with synaptic currents from current_inputs dictionary. Shape: scalar or broadcastable to (*in_size,).

Returns:

spike – Binary spike indicator (1.0 if neuron spiked during this time step, 0.0 otherwise). Shape: (*in_size,).

Return type:

ArrayLike

Raises:

ValueError – If numerical instability is detected (voltage < -1000 mV or abs(adaptation) > 1e6 pA).

Notes

Integration is performed with an adaptive vectorized RKF45 loop, including in-loop spike/reset/adaptation events and optional multiple spikes per step. All arithmetic is unit-aware via saiunit.math.

See also

init_state

Initialize state variables before first update.

get_spike

Differentiable spike output for training.