The harmonic oscillator is omnipresent in physics. Although you may think of this as being related to springs, it, or an equivalent mathematical representation, appears in just about any problem where a mode is sitting near its potential energy minimum. At that point, ∂xV(x)=0, and the first non-zero term (aside from a constant) in the potential energy is that of a harmonic oscillator. In a solid, sound modes (phonons) are built on a picture of coupled harmonic oscillators, and in relativistic field theory the fundamental interactions are also built on coupled oscillators positioned infinitesimally close to one another in space. The phenomena of a resonance of an oscillator driven at a fixed frequency plays out repeatedly in atomic, nuclear and high-energy physics, when quantum mechanically the evolution of a state oscillates according to e−iEt and exciting discrete quantum states has very similar mathematics as exciting discrete states of an oscillator.
The potential energy for a single particle as a function of its position x can be written as a Taylor expansion about some point b (we are considering a one-dimensional problem here)
V(x)=V(b)+(x−b)dV(x)dx|b+12!(x−b)2d2V(x)dx2|b+13!(x−b)3V(x)(3)|b+⋯
If the position b is at the minimum of the resonance, the first two non-zero terms of the potential are
V(x)≈V(b)+12!(x−b)2d2V(x)dx2|b,=V(b)+12k(x−b)2, k≡d2V(x)dx2|b,F=−dV(x)dx=−k(x−b).
Our equation of motion is, with the only force given by the one-dimensional spring force,
md2xdt2=−kx.
Defining the natural frequency ω20=k/m we can rewrite this equation as
d2xdt2=−ω20x.
We call this a natural frequency since it is defined by the constants that describe our system, the spring constant k and the mass m of the object.
We can as usual split this equation of motion into one equation for the derivative of the velocity and
dvdt=−ω20x,
and
dxdt=v.
The solution to the equations of motion is given by
x(t)=Acos(ω0t)+Bsin(ω0t),
where A and B are in general complex constants to be determined by the initial conditions.
Inserting the solution into the equation of motion we have
d2xdt2=−ω20x,
we have
d2xdt2=−Aω20cos(ω0t)−Bω20sin(ω0t),
and the right-hand side is just −ω20x(t). Thus, inserting the solution into the differential equation shows that we obtain the same original differential equation.
Let us assume that our initial time $t_0=0$s and that the initial position x(t0)=x0 and that v0=0 (we skip units here). This gives us
x(t=0)=x0=A,
and it leaves B undetermined. Taking the derivative of x we obtain the velocity
v(t)=−Aω0sin(ω0t)+Bω0cos(ω0t),
and with
v(t=0)=0=B,
we see that our solution with these initial conditions becomes
x(t)=x0cos(ω0t).
From our first homework (exercise 1) we have that (we switch to ω instead of ω0)
cos(ωt)=∞∑n=0(−1)n(ωt)2n(2n)!,
and
sin(ωt)=∞∑n=0(−1)n(ωt)2n+1(2n+1)!,
and that we could write
exp(±ıωt)=cos(ωt)+±ısin(ωt).
This means (show this) that we can write our solution in terms of new constant C and D as
x(t)=Cexp(ıωt)+Dexp(−ıωt).
To see the relation between these two forms we note that we can write our original solution x(t)=Acos(ωt)+Bsin(ωt) as
x(t)=(C+D)cos(ωt)+ı(C−D)sin(ωt),
meaning that we have A=C+D and B=ı(C−D).
We can also rewrite the solution in a simpler way. We define a new constant A=√B21+B22 which can be thought as the hypotenuse of a right-angle triangle with sides B1 and B2 and B1=Acos(δ) and B2=Asin(δ).
We have then
x(t)=A[B1Acos(ωt)+B2Asin(ωt)],
which becomes
x(t)=A[cos(δ)cos(ωt)+sin(δ)sin(ωt)],
and using the trigonometric relations for addition of angles we have
x(t)=Acos(ωt−δ),
where δ is a so-called phase shift.
Our energy is given by the kinetic energy and the harmonic oscillator potential energy, that is we have (for a one-dimensional harmonic oscillator potential)
E=12mv2+12kx2.
We assume that we have initial conditions v0=0 (no kinetic energy) and x(t=0)=x0. With these initial conditions we have
x(t)=x0cos(ω0t),
and the velocity is given by
v(t)=−x0ω0sin(ω0t),
The energy is conserved (as we have discussed before) and at t=t0=0 we have thus
E0=12kx20.
At a time t≠0 we have
E(t)=12mv2+12kx2=12mx20ω20sin2(ω0t)+12kx20cos2(ω0t),
Recalling that ω20=k/m we get
E(t)=12kx20sin2(ω0t)+12kx20cos2(ω0t)=12kx20=E0.
Energy is thus conserved
Note: Figure to be inserted.
We consider a pendulum of length l attached to the roof.
The pendulum consists of a rod and a small object attached to the rod. The mass of this object is m and it is the motion of this object we are concerned with. The distance from the object to the roof is r and we have |r|=l.
The angle between the y-axis and the rod is ϕ. The forces at play are the gravitational force and a tension force from the rod to the object. The net for is
Fnet=T+G=Tsin(ϕ)e1+Tcos(ϕ)e2−mge2,
and with
r=lsin(ϕ)e1+lcos(ϕ)e2,
the equation of motion becomes
md2rdt2=T+G=Tsin(ϕ)e1+Tcos(ϕ)e2−mge2.
Using the chain rule we can find the first derivative of r
drdt=ldϕdtcos(ϕ)e1−ldϕdtsin(ϕ)e2,
and thereafter the second derivative in the x-direction as
d2rdt2e1=ld2ϕdt2cos(ϕ)−l(dϕdt)2sin(ϕ),
and in the y direction
d2rdt2e2=−ld2ϕdt2sin(ϕ)−l(dϕdt)2cos(ϕ).
We can now set up the equations of motion in the x and y directions and get for the x-direction
mld2ϕdt2cos(ϕ)−ml(dϕdt)2sin(ϕ)=Tsin(ϕ),
and for the y-direction
−mld2ϕdt2sin(ϕ)−ml(dϕdt)2cos(ϕ)=Tcos(ϕ)−mg.
This looks ugly!
Let us rewrite
mld2ϕdt2cos(ϕ)=[ml(dϕdt)2+T]sin(ϕ),
and
−mld2ϕdt2sin(ϕ)+mg=[ml(dϕdt)2+Tcos(ϕ)].
Still not so nice.
How can we simplify the above equations, rewritten here
mld2ϕdt2cos(ϕ)=[ml(dϕdt)2+T]sin(ϕ),
and
−mld2ϕdt2sin(ϕ)+mg=[ml(dϕdt)2+T]cos(ϕ).
We multiply the first equation with cosϕ and the second one with sinϕ and then subtract the two equations. We get then
−mld2ϕdt2(cos(ϕ))2−mld2ϕdt2(sin(ϕ))2+mgsin(ϕ)=0,
leading to
mld2ϕdt2=−mgsin(ϕ).
We are almost there.
We divide by m and l and we have the famous non-linear in ϕ (due to the sine function) equation for the pendulumn
d2ϕdt2=−glsin(ϕ).
Introducing the natural frequency ω20=g/l we can rewrite the equation as
d2ϕdt2=−ω20sin(ϕ).
If we now assume that the angle is very small, we can approximate sin(ϕ)≈ϕ and we have essentially the same equation as we had for harmonic oscillations, that is
d2ϕdt2=−ω20ϕ.
The solution to this equation is again given by
ϕ(t)=Acos(ω0t)+Bsin(ω0t).
For the general case, we have to resort to numerical solutions.
We consider only the case where the damping force is proportional to the velocity. This is counter to dragging friction, where the force is proportional in strength to the normal force and independent of velocity, and is also inconsistent with wind resistance, where the magnitude of the drag force is proportional the square of the velocity. Rolling resistance does seem to be mainly proportional to the velocity. However, the main motivation for considering damping forces proportional to the velocity is that the math is more friendly. This is because the differential equation is linear, i.e. each term is of order x, ˙x, ¨x⋯, or even terms with no mention of x, and there are no terms such as x2 or x¨x. The equations of motion for a spring with damping force −b˙x are
m¨x+b˙x+kx=0.
Let us first study the numerical solution, thereafter we switch to the analytical analysis.
We study first the case without additional friction term and scale our equation in terms of a dimensionless time τ.
Let us remind ourselves about the differential equation we want to solve (the general case with damping due to friction)
md2xdt2+bdxdt+kx(t)=0.
We divide by m and introduce ω20=√k/m and obtain
d2xdt2+bmdxdt+ω20x(t)=0.
Thereafter we introduce a dimensionless time τ=tω0 (check that the dimensionality is correct) and rewrite our equation as
d2xdτ2+bmω0dxdτ+x(τ)=0,
which gives us
d2xdτ2+bmω0dxdτ+x(τ)=0.
We then define γ=b/(2mω0) and rewrite our equations as
d2xdτ2+2γdxdτ+x(τ)=0.
This is the equation we will code below. The first version employs the Euler-Cromer method.
# Common imports
import numpy as np
import pandas as pd
from math import *
import matplotlib.pyplot as plt
import os
# Where to save the figures and data files
PROJECT_ROOT_DIR = "Results"
FIGURE_ID = "Results/FigureFiles"
DATA_ID = "DataFiles/"
if not os.path.exists(PROJECT_ROOT_DIR):
os.mkdir(PROJECT_ROOT_DIR)
if not os.path.exists(FIGURE_ID):
os.makedirs(FIGURE_ID)
if not os.path.exists(DATA_ID):
os.makedirs(DATA_ID)
def image_path(fig_id):
return os.path.join(FIGURE_ID, fig_id)
def data_path(dat_id):
return os.path.join(DATA_ID, dat_id)
def save_fig(fig_id):
plt.savefig(image_path(fig_id) + ".png", format='png')
from pylab import plt, mpl
plt.style.use('seaborn')
mpl.rcParams['font.family'] = 'serif'
DeltaT = 0.001
#set up arrays
tfinal = 20 # in dimensionless time
n = ceil(tfinal/DeltaT)
# set up arrays for t, v, and x
t = np.zeros(n)
v = np.zeros(n)
x = np.zeros(n)
# Initial conditions as simple one-dimensional arrays of time
x0 = 1.0
v0 = 0.0
x[0] = x0
v[0] = v0
gamma = 0.0
# Start integrating using Euler-Cromer's method
for i in range(n-1):
# Set up the acceleration
# Here you could have defined your own function for this
a = -2*gamma*v[i]-x[i]
# update velocity, time and position
v[i+1] = v[i] + DeltaT*a
x[i+1] = x[i] + DeltaT*v[i+1]
t[i+1] = t[i] + DeltaT
# Plot position as function of time
fig, ax = plt.subplots()
#ax.set_xlim(0, tfinal)
ax.set_ylabel('x[m]')
ax.set_xlabel('t[s]')
ax.plot(t, x)
fig.tight_layout()
save_fig("BlockEulerCromer")
plt.show()
When setting up the value of γ we see that for γ=0 we get the simple oscillatory motion with no damping. Choosing γ<1 leads to the classical underdamped case with oscillatory motion, but where the motion comes to an end.
Choosing γ=1 leads to what normally is called critical damping and γ>1 leads to critical overdamping. Try it out and try also to change the initial position and velocity. Setting γ=1 yields a situation, as discussed below in connection with the analytical solution, where the solution approaches quickly zero and does not oscillate. With zero initial velocity it will never cross zero.
Let us now focus on the analytical solution.
Just to make the solution a bit less messy, we rewrite this equation as
¨x+2β˙x+ω20x=0, β≡b/2m, ω0≡√k/m.
Both β and ω have dimensions of inverse time. To find solutions (see appendix C in the text) you must make an educated guess at the form of the solution. To do this, first realize that the solution will need an arbitrary normalization A because the equation is linear. Secondly, realize that if the form is
x=Aert
that each derivative simply brings out an extra power of r. This means that the Aert factors out and one can simply solve for an equation for r. Plugging this form into Eq. (4),
r2+2βr+ω20=0.
Because this is a quadratic equation there will be two solutions,
r=−β±√β2−ω20.
We refer to the two solutions as r1 and r2 corresponding to the + and − roots. As expected, there should be two arbitrary constants involved in the solution,
x=A1er1t+A2er2t,
where the coefficients A1 and A2 are determined by initial conditions.
The roots listed above, √ω20−β20, will be imaginary if the damping is small and β<ω0. In that case, r is complex and the factor ert will have some oscillatory behavior. If the roots are real, there will only be exponentially decaying solutions. There are three cases:
x=A1e−βteiω′t+A2e−βte−iω′t, ω′≡√ω20−β2=(A1+A2)e−βtcosω′t+i(A1−A2)e−βtsinω′t.
Here we have made use of the identity eiω′t=cosω′t+isinω′t. Because the constants are arbitrary, and because the real and imaginary parts are both solutions individually, we can simply consider the real part of the solution alone:
x=B1e−βtcosω′t+B2e−βtsinω′t,ω′≡√ω20−β2.
In this case the two terms involving r1 and r2 are identical because ω′=0. Because we need to arbitrary constants, there needs to be another solution. This is found by simply guessing, or by taking the limit of ω′→0 from the underdamped solution. The solution is then
x=Ae−βt+Bte−βt.
The critically damped solution is interesting because the solution approaches zero quickly, but does not oscillate. For a problem with zero initial velocity, the solution never crosses zero. This is a good choice for designing shock absorbers or swinging doors.
x=A1exp−(β+√β2−ω20)t+A2exp−(β−√β2−ω20)t
This solution will also never pass the origin more than once, and then only if the initial velocity is strong and initially toward zero.
Given b, m and ω0, find x(t) for a particle whose initial position is x=0 and has initial velocity v0 (assuming an underdamped solution).
The solution is of the form,
x=e−βt[A1cos(ω′t)+A2sinω′t],˙x=−βx+ω′e−βt[−A1sinω′t+A2cosω′t].ω′≡√ω20−β2, β≡b/2m.
From the initial conditions, A1=0 because x(0)=0 and ω′A2=v0. So
x=v0ω′e−βtsinω′t.
Here, we consider the force
F=−kx−b˙x+F0cosωt,
which leads to the differential equation
¨x+2β˙x+ω20x=(F0/m)cosωt.
Consider a single solution with no arbitrary constants, which we will call a {\it particular solution}, xp(t). It should be emphasized that this is {\bf A} particular solution, because there exists an infinite number of such solutions because the general solution should have two arbitrary constants. Now consider solutions to the same equation without the driving term, which include two arbitrary constants. These are called either {\it homogenous solutions} or {\it complementary solutions}, and were given in the previous section, e.g. Eq. (9) for the underdamped case. The homogenous solution already incorporates the two arbitrary constants, so any sum of a homogenous solution and a particular solution will represent the {\it general solution} of the equation. The general solution incorporates the two arbitrary constants A and B to accommodate the two initial conditions. One could have picked a different particular solution, i.e. the original particular solution plus any homogenous solution with the arbitrary constants Ap and Bp chosen at will. When one adds in the homogenous solution, which has adjustable constants with arbitrary constants A′ and B′, to the new particular solution, one can get the same general solution by simply adjusting the new constants such that A′+Ap=A and B′+Bp=B. Thus, the choice of Ap and Bp are irrelevant, and when choosing the particular solution it is best to make the simplest choice possible.
To find a particular solution, one first guesses at the form,
xp(t)=Dcos(ωt−δ),
and rewrite the differential equation as
D{−ω2cos(ωt−δ)−2βωsin(ωt−δ)+ω20cos(ωt−δ)}=F0mcos(ωt).
One can now use angle addition formulas to get
D{(−ω2cosδ+2βωsinδ+ω20cosδ)cos(ωt)+(−ω2sinδ−2βωcosδ+ω20sinδ)sin(ωt)}=F0mcos(ωt).
Both the cos and sin terms need to equate if the expression is to hold at all times. Thus, this becomes two equations
D{−ω2cosδ+2βωsinδ+ω20cosδ}=F0m−ω2sinδ−2βωcosδ+ω20sinδ=0.
After dividing by cosδ, the lower expression leads to
tanδ=2βωω20−ω2.
Using the identities tan2+1=csc2 and sin2+cos2=1, one can also express sinδ and cosδ,
sinδ=2βω√(ω20−ω2)2+4ω2β2,cosδ=(ω20−ω2)√(ω20−ω2)2+4ω2β2
Inserting the expressions for cosδ and sinδ into the expression for D,
D=F0/m√(ω20−ω2)2+4ω2β2.
For a given initial condition, e.g. initial displacement and velocity, one must add the homogenous solution then solve for the two arbitrary constants. However, because the homogenous solutions decay with time as e−βt, the particular solution is all that remains at large times, and is therefore the steady state solution. Because the arbitrary constants are all in the homogenous solution, all memory of the initial conditions are lost at large times, t>>1/β.
The amplitude of the motion, D, is linearly proportional to the driving force (F0/m), but also depends on the driving frequency ω. For small β the maximum will occur at ω=ω0. This is referred to as a resonance. In the limit β→0 the amplitude at resonance approaches infinity.
Here, we derive the same expressions as in Equations (13) and (16) but express the driving forces as
F(t)=F0eiωt,
rather than as F0cosωt. The real part of F is the same as before. For the differential equation,
¨x+2β˙x+ω20x=F0meiωt,
one can treat x(t) as an imaginary function. Because the operations d2/dt2 and d/dt are real and thus do not mix the real and imaginary parts of x(t), Eq. (17) is effectively 2 equations. Because eωt=cosωt+isinωt, the real part of the solution for x(t) gives the solution for a driving force F0cosωt, and the imaginary part of x corresponds to the case where the driving force is F0sinωt. It is rather easy to solve for the complex x in this case, and by taking the real part of the solution, one finds the answer for the cosωt driving force.
We assume a simple form for the particular solution
xp=Deiωt,
where D is a complex constant.
From Eq. (17) one inserts the form for xp above to get
D{−ω2+2iβω+ω20}eiωt=(F0/m)eiωt,D=F0/m(ω20−ω2)+2iβω.
The norm and phase for D=|D|e−iδ can be read by inspection,
|D|=F0/m√(ω20−ω2)2+4β2ω2, tanδ=2βωω20−ω2.
This is the same expression for δ as before. One then finds xp(t),
xp(t)=ℜ(F0/m)eiωt−iδ√(ω20−ω2)2+4β2ω2=(F0/m)cos(ωt−δ)√(ω20−ω2)2+4β2ω2.
This is the same answer as before. If one wished to solve for the case where F(t)=F0sinωt, the imaginary part of the solution would work
xp(t)=ℑ(F0/m)eiωt−iδ√(ω20−ω2)2+4β2ω2=(F0/m)sin(ωt−δ)√(ω20−ω2)2+4β2ω2.
Consider the damped and driven harmonic oscillator worked out above. Given F0,m,β and ω0, solve for the complete solution x(t) for the case where F=F0sinωt with initial conditions x(t=0)=0 and v(t=0)=0. Assume the underdamped case.
The general solution including the arbitrary constants includes both the homogenous and particular solutions,
x(t)=F0msin(ωt−δ)√(ω20−ω2)2+4β2ω2+Acosω′te−βt+Bsinω′te−βt.
The quantities δ and ω′ are given earlier in the section, ω′=√ω20−β2,δ=tan−1(2βω/(ω20−ω2). Here, solving the problem means finding the arbitrary constants A and B. Satisfying the initial conditions for the initial position and velocity:
x(t=0)=0=−ηsinδ+A,v(t=0)=0=ωηcosδ−βA+ω′B,η≡F0m1√(ω20−ω2)2+4β2ω2.
The problem is now reduced to 2 equations and 2 unknowns, A and B. The solution is
A=ηsinδ, B=−ωηcosδ+βηsinδω′.
From the previous two sections, the particular solution for a driving force, F=F0cosωt, is
xp(t)=F0/m√(ω20−ω2)2+4ω2β2cos(ωt−δ),δ=tan−1(2βωω20−ω2).
If one fixes the driving frequency ω and adjusts the fundamental frequency ω0=√k/m, the maximum amplitude occurs when ω0=ω because that is when the term from the denominator (ω20−ω2)2+4ω2β2 is at a minimum. This is akin to dialing into a radio station. However, if one fixes ω0 and adjusts the driving frequency one minimize with respect to ω, e.g. set
ddω[(ω20−ω2)2+4ω2β2]=0,
and one finds that the maximum amplitude occurs when ω=√ω20−2β2. If β is small relative to ω0, one can simply state that the maximum amplitude is
xmax≈F02mβω0.
4ω2β2(ω20−ω2)2+4ω2β2=12.
For small damping this occurs when ω=ω0±β, so the FWHM≈2β. For the purposes of tuning to a specific frequency, one wants the width to be as small as possible. The ratio of ω0 to FWHM is known as the {\it quality} factor, or Q factor,
Q≡ω02β.