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)
- __init__(t_step, mu)
Instantiate
DiscreteVanDerPol
.
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:
- Returns:
Time and state at every timestep. Each timestep is one row.
- Return type:
Tuple[np.ndarray, np.ndarray]