pykoop.dynamic_models.DiscreteVanDerPol

class DiscreteVanDerPol(t_step, mu)

Bases: DiscreteDynamicModel

Van der Pol oscillator.

Examples

Simulate Van der Pol oscillator

>>> t_step = 0.1
>>> vdp = pykoop.dynamic_models.DiscreteVanDerPol(t_step, 2)
>>> x0 = np.array([1, 0])
>>> t_range = (0, 10)
>>> u = 0.01 * np.cos(np.arange(*t_range, t_step))
>>> t, x = vdp.simulate(t_range, t_step, x0, u)
Parameters:
__init__(t_step, mu)

Instantiate DiscreteVanDerPol.

Parameters:
  • t_step (float) – Timestep (s)

  • mu (float) – Strength of nonlinearity.

Return type:

None

Methods

__init__(t_step, mu)

Instantiate DiscreteVanDerPol.

f(t, x, u)

Implement next-state equation.

g(t, x)

Implement output equation.

simulate(t_range, t_step, x0, u)

Simulate the model.

f(t, x, u)

Implement next-state equation.

Parameters:
  • t (float) – Time (s).

  • x (np.ndarray) – State.

  • u (np.ndarray) – Input.

Returns:

Next state.

Return type:

np.ndarray

g(t, x)

Implement output equation.

Parameters:
  • t (float) – Time (s).

  • x (np.ndarray) – State.

Returns:

Measurement of state.

Return type:

np.ndarray

simulate(t_range, t_step, x0, u)

Simulate the model.

Parameters:
  • t_range (Tuple[float, float]) – Start and stop times in a tuple.

  • t_step (float) – Timestep of output data.

  • x0 (np.ndarray) – Initial condition, shape (n, ).

  • u (np.ndarray) – Input array.

Returns:

Time and state at every timestep. Each timestep is one row.

Return type:

Tuple[np.ndarray, np.ndarray]