Skip to content
Snippets Groups Projects
Commit 6f32910e authored by cprutean's avatar cprutean
Browse files

Upload New File

parent eb25d875
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id:ed4c83c4 tags:
## Checkpoint 3
### Background:
The damped simple harmonic oscillator satisfies the second order differential equation
$m\ddot{x} +b \dot{x} + kx=0$ where m is the mass of the oscillator, b is the coefficient of damping, and k is the spring constant.
Defining new constants
$\gamma$=b/m and $\omega_0^2$=k/m
we can re-write the differential equations as:
$\ddot{x} + \gamma \dot{x} + \omega_{0}^2x =0 $
where ω0 is known as the natural frequency of the undamped oscillator.
The solutions to this equation take the following forms:
$ x=exp(−γt/2)[acosh(pt)+bsinh(pt)] $ when $ γ>2ω_0 $ with $ p^2=(γ^2/4)−ω^2_0 $
$ x=exp(−γt/2)[a+bt] $ when $ γ=2ω_0 $
$ x=exp(−γt/2)[acos(ωt)+bsin(ωt)] $ when $ γ<2ω_0 $ with $ ω^2=ω^2_0−(γ^2/4)$
where these three conditions are known as over damped, critically damped and under damped respectively.
Note: Read these equations very carefully and note the locations of the parentheses.
With the initial conditions that x=1 and $\dot{x}$ =0 at t=0 the above constants, after some manipulation, become,
a=1 b=$\gamma$/2p when $\gamma$>2ω$_0$
a=1 b=$\gamma$/2 when $\gamma$=2ω$_0$
a=1 b=$\gamma$/2ω when $\gamma$<2ω$_0$
### Task
Write an interactive Python program to compute and display, using the pyplot function from Matplotlib, the solution for x against t for t in the range 0$\to 5\pi/ω_0$. Your program should:
- Ask for and read in the values of ω$_0$, $\gamma$ and the number of points to plot on the graph from the terminal.
- Use a function of form shm(omega_zero,gamma,t) to calculate the displacement.
- Calculate and plot the amplitude and time to lists
- Plot the output via pyplot with suitable title and labels to axis
%% Cell type:code id:6077b2ca tags:
``` python
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment