VanDerPolStep#

class brainmass.VanDerPolStep(in_size, mu=1.0, noise_x=None, noise_y=None, init_x=Uniform(low=0, high=0.05), init_y=Uniform(low=0, high=0.05), method='exp_euler')#

Van der Pol oscillator (two-dimensional form).

In the study of dynamical systems, the van der Pol oscillator (named for Dutch physicist Balthasar van der Pol) is a non-conservative, oscillating system with non-linear damping. It evolves in time according to the second-order differential equation

\[ {d^{2}x \over dt^{2}}-\mu (1-x^{2}){dx \over dt}+x=0 \]

where \(x\) is the position coordinate—which is a function of the time \(t\)— and \(\mu\) is a scalar parameter indicating the nonlinearity and the strength of the damping.

Implements the Van der Pol oscillator using the Liénard transformation that yields the planar system

\[\dot x = \mu\,\left(x - \tfrac{1}{3}x^3 - y\right) + I_x(t),\]
\[\dot y = \frac{1}{\mu}\,x + I_y(t),\]

where \(x\) is the state (often interpreted as position or activation), \(y\) is the auxiliary variable, and \(\mu > 0\) controls the nonlinearity and damping. The model exhibits a stable limit cycle for any \(\mu > 0\).

Another commonly used form based on the transformation \(y={\dot {x}}\) leads to:

\[ {\dot {x}}=y \]

\[ {\dot {y}}=\mu (1-x^{2})y-x \]

Parameters:
  • in_size (int | Sequence[int] | integer | Sequence[integer]) – Spatial shape of the node/population. Can be an int or a tuple of int. All parameters are broadcastable to this shape.

  • mu (Callable | Array | ndarray | bool | number | bool | int | float | complex | Quantity | Param) – Nonlinearity/damping parameter (dimensionless). Default is 1.0.

  • noise_x (Noise) – Additive noise process for the \(x\)-equation. If provided, called each update and added to x_inp. Default is None.

  • noise_y (Noise) – Additive noise process for the \(y\)-equation. If provided, called each update and added to y_inp. Default is None.

  • init_x (Callable) – Parameter for the state x. Default is braintools.init.Uniform(0, 0.05).

  • init_y (Callable) – Parameter for the state y. Default is braintools.init.Uniform(0, 0.05).

  • method (str) – Time stepping method. One of 'exp_euler' (exponential Euler; default) or any method supported under braintools.quad (e.g., 'rk4', 'midpoint', 'heun', 'euler').

Return type:

Any

x#

State container for \(x\) (dimensionless). Shape equals (batch?,) + in_size after init_state.

Type:

brainstate.HiddenState

y#

State container for \(y\) (dimensionless). Shape equals (batch?,) + in_size after init_state.

Type:

brainstate.HiddenState

Notes

  • Time derivatives returned by dx() and dy() carry unit 1/ms so that a step size dt with unit ms is consistent.

  • For method='exp_euler' the update uses brainstate.nn.exp_euler_step. Otherwise, it dispatches to the corresponding routine in braintools.quad.

References

  • van der Pol, B. (1926). On “relaxation-oscillations”. The London, Edinburgh, and Dublin Philosophical Magazine and Journal of Science, 2(11), 978–992.

  • Kaplan, D., & Glass, L. (1995). Understanding Nonlinear Dynamics. Springer (pp. 240–244).

derivative(state, t, x_inp, y_inp)[source]#

Vector field for ODE integrators.

This packs dx() and dy() into a single callable of the form f(state, t, x_inp, y_inp) to be used by braintools.quad integrators when method != 'exp_euler'.

Parameters:
  • state (tuple of array-like) – Current state as (x, y).

  • t (array-like or scalar) – Current time (ignored in the autonomous dynamics).

  • x_inp (array-like or scalar) – External input to x passed through to dx().

  • y_inp (array-like or scalar) – External input to y passed through to dy().

Returns:

Derivatives as (dx/dt, dy/dt) each with unit 1/ms.

Return type:

tuple of array-like

dx(x, y, inp)[source]#

Right-hand side for the state x.

Parameters:
  • x (array-like) – Current value of x (dimensionless).

  • y (array-like) – Current value of y (dimensionless), broadcastable to x.

  • inp (array-like or scalar) – External input to x (includes noise if enabled).

Returns:

Time derivative dx/dt with unit 1/ms.

Return type:

array-like

dy(y, x, inp=0.0)[source]#

Right-hand side for the state y.

Parameters:
  • y (array-like) – Current value of y (dimensionless).

  • x (array-like) – Current value of x (dimensionless), broadcastable to y.

  • inp (array-like or scalar, optional) – External input to y (includes noise if enabled). Default is 0..

Returns:

Time derivative dy/dt with unit 1/ms.

Return type:

array-like