{% 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/lec04/lecture_04_harmonic.py` What you see ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The example show the Harmonic Oscillator example simulated using RK4. 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)`. The position vector obey a linear differential equation, shown in the slide, and I then simply simulate that differential equation using RK4 as implemented in the exercises.