gemseo.problems.ode.springs.spring_ode_discipline module#
The discipline for describing the motion of a single mass connected by springs.
- class SpringODEDiscipline(mass, left_stiffness, right_stiffness, times, left_position=0.0, right_position=0.0, state_names=('position', 'velocity'), state_dot_names=('position_dot', 'velocity_dot'), left_position_name='left_position', right_position_name='right_position', is_left_position_fixed=False, is_right_position_fixed=False, **ode_solver_options)[source]#
Bases:
ODEDiscipline
A discipline representing a mass connected by two springs.
Initialize self. See help(type(self)) for accurate signature.
- Parameters:
mass (float) -- The value of the mass.
left_stiffness (float) -- The stiffness of the spring on the left-hand side.
right_stiffness (float) -- The stiffness of the spring on the right-hand side.
times (RealArray) -- The times at which the solution must be evaluated.
left_position (float) --
The position of the other extremity of the spring to the left.
By default it is set to 0.0.
right_position (float) --
The position of the other extremity of the spring to the right.
By default it is set to 0.0.
state_names (Sequence[str]) --
The names of the state variables.
By default it is set to ('position', 'velocity').
state_dot_names (Sequence[str]) --
The names of the derivatives of the state variables relative to time.
By default it is set to ('position_dot', 'velocity_dot').
left_position_name (str) --
The names of the variable describing the motion of the mass to the left.
By default it is set to "left_position".
right_position_name (str) --
The names of the variable describing the motion of the mass to the right.
By default it is set to "right_position".
is_left_position_fixed (bool) --
Whether the other end of the spring to the left is fixed.
By default it is set to False.
is_right_position_fixed (bool) --
Whether the other end of the spring to the right is fixed.
By default it is set to False.
**ode_solver_options (Any) -- The options of the ODE solver.
- Raises:
ValueError -- If an expected state variable does not appear in
rhs_discipline
.
- static compute_analytic_mass_position(initial_position, initial_velocity, left_stiffness, right_stiffness, mass, times)[source]#
Compute the analytic position of the mass \(m\).
The equation describing the motion of the mass is
\[\begin{split}\left\{ \begin{cases} \dot{x} &= y \\ \dot{y} &= \frac{k_1 + k_2}{m} x \end{cases} \right.\end{split}\]where \(k_1\) and \(k_2\) are the stiffnesses of the springs.
If \(x(t=0) = x_0\) and \(y(t=0) = y_0\), then the general expression for the position \(x(t)\) at time \(t\) is
\[x(t) = \frac{1}{2}\big( x + \frac{y_0}{\omega} \big) \exp^{i\omega t} + \frac{1}{2}\big( x - \frac{y_0}{\omega} \big) \exp^{-i\omega t}\]with \(\omega = \frac{-k_1+k_2}{m}\).
- Parameters:
initial_position (float) -- The initial position.
initial_velocity (float) -- The initial velocity.
left_stiffness (float) -- The stiffness of the spring to the left.
right_stiffness (float) -- The stiffness of the spring to the right.
mass (float) -- The value of the mass.
times (RealArray) -- The time(s) at which the position of the mass should be evaluated.
- Returns:
The position(s) of the mass.
- Return type:
RealArray
- execution_statistics: ExecutionStatistics#
The execution statistics of the process.
- execution_status: ExecutionStatus#
The execution status of the process.
- jac: JacobianData#
The Jacobian matrices of the outputs.
The structure is
{output_name: {input_name: jacobian_matrix}}
.
- termination_event_disciplines: Iterable[Discipline]#
The disciplines defining the stopping conditions.