pykoop.dynamic_models.DuffingOscillator

class DuffingOscillator(alpha=1, beta=-1, delta=0.1)

Bases: ContinuousDynamicModel

Duffing oscillator model.

Equation is \ddot{x} + \delta \dot{x} + \beta x + \alpha x^3 = u(t) where usually u(t) = a \cos(\omega t).

Parameters:
__init__(alpha=1, beta=-1, delta=0.1)

Instantiate DuffingOscillator.

Parameters:
  • alpha (float) – Coefficient of cubic term.

  • beta (float) – Coefficient of linear term.

  • delta (float) – Coefficient of first derivative.

Return type:

None

Methods

__init__([alpha, beta, delta])

Instantiate DuffingOscillator.

f(t, x, u)

Implement differential equation.

g(t, x)

Implement output equation.

simulate(t_range, t_step, x0, u, **kwargs)

Simulate the model using numerical integration.

f(t, x, u)

Implement differential equation.

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

  • x (np.ndarray) – State.

  • u (np.ndarray) – Input.

Returns:

Time derivative of 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, **kwargs)

Simulate the model using numerical integration.

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 (Callable[[float], np.ndarray]) – Input function of time.

  • **kwargs (dict) – Keyword arguments for integrate.solve_ivp().

Returns:

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

Return type:

Tuple[np.ndarray, np.ndarray]