"where ω0 is known as the natural frequency of the undamped oscillator.\n",
"\n",
"The solutions to this equation take the following forms:\n",
"\n",
"$ x=exp(−γt/2)[acosh(pt)+bsinh(pt)] $ when $ γ>2ω_0 $ with $ p^2=(γ^2/4)−ω^2_0 $\n",
"\n",
"$ x=exp(−γt/2)[a+bt] $ when $ γ=2ω_0 $\n",
"\n",
"$ x=exp(−γt/2)[acos(ωt)+bsin(ωt)] $ when $ γ<2ω_0 $ with $ ω^2=ω^2_0−(γ^2/4)$\n",
"\n",
"where these three conditions are known as over damped, critically damped and under damped respectively.\n",
"\n",
"Note: Read these equations very carefully and note the locations of the parentheses.\n",
"\n",
"With the initial conditions that x=1 and $\\dot{x}$ =0 at t=0 the above constants, after some manipulation, become,\n",
"\n",
"a=1 b=$\\gamma$/2p when $\\gamma$>2ω$_0$\n",
"\n",
"a=1 b=$\\gamma$/2 when $\\gamma$=2ω$_0$\n",
"\n",
"a=1 b=$\\gamma$/2ω when $\\gamma$<2ω$_0$\n",
"\n",
"### Task\n",
"\n",
"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:\n",
"\n",
"- Ask for and read in the values of ω$_0$, $\\gamma$ and the number of points to plot on the graph from the terminal.\n",
"- Use a function of form shm(omega_zero,gamma,t) to calculate the displacement.\n",
"- Calculate and plot the amplitude and time to lists\n",
"- Plot the output via pyplot with suitable title and labels to axis"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6077b2ca",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
%% 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