Harmonic motion

←Previous

Homework assignment

The following homework assignment will be due on Monday, 30.10..

Use the skeleton code Pendulum.py, DEq_Solver.py and Read_Type.py to implement the numerical simulation of a pendulum with friction, driving force and a switch between the linear approximation and the nonlinear pendulum. The state vector of the system is $\underline{x} = ( \theta, \omega )$.

The assignment consists of the following parts:

  1. Implementing the physics for the Euler case:

    Fill in the function dx_dt in Pendulum.py to include the following terms of $\ddot{\theta}$:

    1. The gravitational contribution, for both the linear case $-\frac{g}{l}\theta$ and
    2. the nonlinear case $-\frac{g}{l}\sin\theta$.
    3. The friction contribution $-q\frac{\mathrm{d}\theta}{\mathrm{d}t}$
    4. The driving force $F_D\sin(\Omega_Dt)$

    The function dx_dt should return a two-component numpy array, containing $\mathrm{d}\theta / \mathrm{d}t$ and $\mathrm{d}\omega / \mathrm{d}t$.

  2. Implementing the physics for the Euler-Cromer case:

    To implement the EulerCromer stepper, we need to pass information about the time step size to the physics code. This is done via the new function dx_dt_EC.

    Use your answer to Q.1 a)-d) to fill the function dx_dt_EC, and return the appropriate ${\mathrm{d}\underline{x}}/{\mathrm{d}t}$ array for the Euler-Cromer method.

  3. Implementing circular variables:

    The state variable $\theta$ should be normalized to the range $[-\pi,\pi]$. Implement such a limitation in the solve() function of DEq_Solver.py. Make use of circular_index which indicates where in the state vector the angular variable lies.

  4. Energy values:

    To show the energy balance of the system, fill in the T() and U() functions of Pendulum.py, to return the kinetic and potential energy of state $\underline x = (\theta,\omega)$:

    \[ T = E_\mathrm{kin} = \frac{m}{2}l^2\omega^2(t) \] \[ U = E_\mathrm{pot} = mgl[1-\cos\theta(t)] \approx \frac{m}{2}gl\theta^2(t) \]
    You can set $m=1$kg.

Frank Krauss and Daniel Maitre
Last modified: Tue Oct 3 14:43:58 BST 2017