odeint#
- class brainpy.odeint(f=None, method=None, var_type=None, dt=None, name=None, show_code=False, state_delays=None, neutral_delays=None, **kwargs)[source]#
Numerical integration for ODEs.
Examples
>>> import brainpy as bp >>> import matplotlib.pyplot as plt >>> >>> a=0.7; b=0.8; tau=12.5; Vth=1.9 >>> V = 0; w = 0 # initial values >>> >>> @bp.odeint(method='rk4', dt=0.04) >>> def integral(V, w, t, Iext): >>> dw = (V + a - b * w) / tau >>> dV = V - V * V * V / 3 - w + Iext >>> return dV, dw >>> >>> hist_V = [] >>> for t in bp.math.arange(0, 100, integral.dt): >>> V, w = integral(V, w, t, 0.5) >>> hist_V.append(V) >>> plt.plot(bp.math.arange(0, 100, integral.dt), hist_V) >>> plt.show()
(
Source code
,png
,hires.png
,pdf
)- Parameters:
f (callable, function) – The derivative function.
method (str) – The shortcut name of the numerical integrator.
var_type (str) – The type of the variable defined in the equation.
dt (float) – The numerical integration precision.
name (str) – The integrator node.
state_delays (dict) – The state delay variable.
show_code (bool) – Show the formated code.
adaptive (bool) – The use adaptive mode.
tol (float) – The tolerence to adapt new step size.
- Returns:
integral – The numerical solver of f.
- Return type: