{% import macros as m with context %} .. _harmonic_game: Week 3: Harmonic Oscillator ============================================================================================================= {{ m.embed_game('week3_harmonic') }} .. topic:: Controls :class: margin :kbd:`p` Start the simulation :kbd:`r` Reset the game .. rubric:: Run locally :gitref:`../irlc/lectures/lec03/lecture_03_harmonic.py` What you see ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The example show the Harmonic Oscillator (see (:cite:t:`herlau`, Subsection 11.1.2)) example. There is no control signal, :math:`u(t) = 0`, so the system just oscillates forever. How it works ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The bead has a position and a velocity which form the two coordinates of the state .. math:: \mathbf{x}(t) = \begin{bmatrix}\text{position} \\ \text{velocity} \end{bmatrix} = \begin{bmatrix} x_1(t) \\ x_2(t) \end{bmatrix} The dynamics of the environment is then governed by the differential equation: .. math:: \dot{\mathbf x} = \begin{bmatrix}0 & 1 \\ -\frac{k}{m} & 0 \end{bmatrix}\mathbf{x}