Computational Methods Junior Honours : Checkpoint 4

 

Example code:

There is no example code for this checkpoint as the coding is relatively straightforwards.
Your solution for Checkpoint 3, Test1 should be a good starting point.

The main purpose of the checkpoint is to explore the system and demonstrate that the numerical simulation approach works for a system we know how to solve analytically before we apply it to systems that are not solvable.

Your task: Driven Damped Simple harmonic motion

o      Note that, unlike Scientific Programming checkpoint 4, your simulation will not implement this equation directly and so that checkpoint does not provide a good starting point for this exercise.

·       Review the summary of simple harmonic motion in the background notes.

·       Write a code to numerically integrate the equation of motion for a particle mass m subject to a damping force, a spring force and a sinusoidal driving force.

\begin{displaymath}
m\ddot{x} = -kx + F_D \cos (\omega_D t) -b \dot{x}\end{displaymath}

o      You should produce graphs of position and velocity against time.

o      Note that the particle position, velocity and acceleration can be expressed by a single number rather than a vector.

§       Use the x-component of your vectors to represent this

o      As usual you should write your code to read its initial state from an input file
Think what this file should contain. E.g. b, FD, m, k, ωD, ω0 , timestep and particle parameters

Study the spring system:

 

Advanced: