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:
Fill in the function dx_dt in Pendulum.py to include the following terms of $\ddot{\theta}$:
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$.
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.
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.
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)$: