gemseo.problems.ode.oscillator_discipline module#
A harmonic oscillator.
In classical mechanics, the position \(x\) of a harmonic oscillator is described by the equation
with \(\omega \in \mathbb{R}_+^*\). This second-order Ordinary Differential Equation (ODE) has an analytical solution:
where \(\lambda\) and \(\mu\) are two constants defined by the initial conditions.
This solution can be re-written as a two-dimensional first-order ODE:
where \(v\) represents the velocity of the oscillator.
- class OscillatorDiscipline(omega, times, return_trajectories=False, final_state_names=mappingproxy({}), cache_inner_discipline_is_none=True)[source]#
Bases:
ODEDiscipline
A discipline representing a harmonic oscillator.
Initialize self. See help(type(self)) for accurate signature.
- Parameters:
omega (float) -- The positive angular velocity of the oscillator.
times (RealArray) -- Either the initial and final times or the times of interest where the state must be stored, including the initial and final times. When only initial and final times are provided, the times of interest are the instants chosen by the ODE solver to compute the state trajectories.
return_trajectories (bool) --
Whether to output both the trajectories of the state variables and their values at final time. Otherwise, output only their values at final time.
By default it is set to False.
final_state_names (Mapping[str, str]) --
The names of the state variables bound to their names at final time. If empty, use
"state_final"
for a state variable named"state"
.By default it is set to {}.
cache_inner_discipline_is_none --
The description is missing.
By default it is set to True.
- Raises:
ValueError -- If an expected state variable does not appear in
rhs_discipline
.