Laboratory 9 The Pendulum

MATLAB sessions: Laboratory 9
83
Laboratory 9
The Pendulum
(§4.7 of the Nagle/Saff/Snider text)
In this laboratory we model the motion of a (simple) pendulum with a second-order differential equation.
A mass m is attached to a rigid rod rotating around a fixed point. The rod makes an angle θ with the
downward positive vertical y-axis. Positive angles are oriented counter-clockwise, in the direction of the
positive x-axis.
The position of the mass m is (x, y) = (` sin θ, ` cos θ). The first
principle of mechanics states that the acceleration vector A is
the sum of all forces applied to the mass, namely the weight
qc
W, the tension in the rod T, and the friction force F opposite
x
@.
to the movement and proportional to the velocity of the mass.
.......
...............@
Thus
θ @`
µ
¡
A=W+F+T
(L9.1)
¡
@
...
...
.. ¡
@
I
.
...
with
..
@T
... ¡ A
....
.
.
.
.
· ¸
·
¸
µ ¶2 ·
¸
@ .........¡
.
d2 x
d2 θ cos θ
dθ
sin θ
....
@
@y
...¡
.
.
A=m 2
= m` 2
− m`
,
....
m
......
cos θ
dt y
dt − sin θ
dt
......¡
.......
.......
.
.
.
.
.
.
ª
........ ¡
........
· ¸
·
¸
· ¸
...........
F
............
..........................................................................
dθ cos θ
d x
0
=
−γ`
,
W
=
,
F
=
−γ
W
mg
dt y
dt − sin θ
y?
(g ' 9.8 m/s2 ' 32 f t/s2 ) and
· ¸ ·
¸
x
sin θ
T∝
∝
y
cos θ
?
(only ·the direction
of T is known, not the magnitude).
¸
cos θ
When taking the dot product of (L9.1) with
the contribution of T disappears (this amounts
− sin θ
to projecting (L9.1) onto a direction perpendicular to the direction of the rod, i.e., in the direction of A
or F). This yields
m`
d2 θ
dθ
= −mg sin θ − γ` ,
dt2
dt
or
d2 θ
dθ
+ c + ω 2 sin θ = 0
dt2
dt
(L9.2)
with c = γ/m and ω 2 = g/`. Clearly, equation (L9.2) is nonlinear, which makes it interesting to study
since no analytical solution is available.
Our objectives are as follows.
1. Determine the effect of variations in the parameters in the solution.
2. Determine the effect of “linearization” of the differential equation.
The Undamped Case
Let’s first assume that c = 0 (i.e., γ = 0). We solve the ODE (L9.2) subject to initial conditions
θ(0) = 45 degrees and θ0 (0) = 1 rad/s, assuming ` = 0.5 m. The ODE is first reduced to a set of two
first-order ODEs
dθ
dv
= v,
= −ω 2 sin θ
(L9.3)
dt
dt
with v(0) = θ0 (0) = 0.5 rad/s. A MATLAB implementation follows.
84
MATLAB sessions: Laboratory 9
function lab9ex1
g = 9.81;
l = 0.5;
omega = sqrt(g/l);
theta0 = ??; v0 = ??;
[t,Y] = ode45(@f,[0,20],[theta0,v0],[],omega);
theta = Y(:,1);
figure(1); plot(t,theta*180/pi,’b-’);
grid on
%----------------------------------------------function dYdt = f(t,Y,omega)
theta = Y(1); v = Y(2);
dYdt = [ ?? ; ?? ];
% gravitational accel. [m/s^2]
% pendulum length [m]
%
%
%
%
fill-in ICs
solve for 0<t<10
retrieve theta
theta in degrees
% fill-in ODE
50
40
30
20
10
0
−10
−20
−30
−40
−50
0
2
4
6
8
10
12
14
16
18
20
Figure L9a: Motion of a simple pendulum: θ = θ(t) (degrees).
1. From the graph in Fig. L9a answer the following questions.
(a) What is the period of the motion?
(b) Will the pendulum come to rest? Why?
(c) What is the maximal angle the pendulum makes with the vertical?
(d) Does the value of the mass m affect the plot?
2. Change the initial condition on the rate of change of θ to v(0) = 8.17 rd/s, v(0) = 8.175 rd/s, and
v(0) = 8.18 rd/s. Decide whether the behavior makes sense. How is the motion of the pendulum
modified compared to the previous situation? The following graph shows the case v(0) = 8.17 rd/s.
MATLAB sessions: Laboratory 9
85
200
150
100
50
0
−50
−100
−150
−200
0
2
4
6
8
10
12
14
16
18
20
3. Use the following options in ode45:
options = odeset(’Reltol’,1e-12,’AbsTol’,1e-12’);
[t,Y] = ode45(@f,[0,20],[theta0,v0],options,omega);
Redo question 2. What has changed in the numerical procedure?
4. Try some of the following variations on the initial conditions:
(a) θ(0) = π rad, θ0 (0) = 0 rad/s.
(b) θ(0) =
22
7
rad, θ0 (0) = 0 rad/s.
(c) θ(0) = π rad, θ0 (0) = 30 rad/s.
(d) θ(0) = 2π rad, θ0 (0) = 1 rad/s.
(e) θ(0) = 10π rad, θ0 (0) = 0 rad/s.
(f) θ(0) =
220
7
rad, θ0 (0) = 0 rad/s.
(g) θ(0) = −7π rad, θ0 (0) = 0.03 rad/s.
(h) θ(0) = −7π rad, θ0 (0) = 0.01 rad/s.
Comment on the behavior of the pendulum in each case. Are any of the behaviors realistic? Are
any of the behaviors not realistic? If so what is the explanation for the unrealistic behavior?
5. (a) Plot the quantity E = 12 m`
(b) Show analytically that
dE
dt
¡ dθ ¢2
dt
+ mg(1 − cos θ) as a function of time. What do you observe?
= 0.
(c) Plot v vs θ (phase plot). How does the curve behave?
86
MATLAB sessions: Laboratory 9
The Linearized Case
Let’s know examine what happens when we substitute θ for sin θ in (L9.2). The new equation for θ is
thus
d2 θ
+ ω 2 θ = 0.
(L9.4)
dt2
6. Modify the function implementing the ODE accordingly and plot both linearized and original
solutions together. Experiment with the following initial conditions and summarize what happens.
(a) θ(0) = 0 degree, θ0 (0) = 2 rad/s.
(b) θ(0) = 0 degree, θ0 (0) = 50 rad/s.
(c) θ(0) = 10 degrees, θ0 (0) = 8 rad/s.
(d) θ(0) = 45 degrees, θ0 (0) = 8.17 rad/s.
(e) θ(0) = 45 degrees, θ0 (0) = 8.18 rad/s.
(f) θ(0) = 180 degrees, θ0 (0) = 30 rad/s.
(g) θ(0) = 360 degrees, θ0 (0) = 0 rad/s.
For each case make a judgment whether the graph accurately describes the movement of the
pendulum. Which of the graphs exhibit significant discrepancies between original and linearized
cases? Can you explain why?
With Damping Present
Now consider a small damping coefficient c in the original “non-linearized” equation (L9.2) and observe
the effect.
7. First reduce the ODE (L9.2) to a system of two first-order ODEs similar to (L9.3). Modify the
example lab9ex1 accordingly.
function lab9ex2
g = ??; l = ??; m = ??; gamma = ??;
omega = ??; c = ??;
theta0 = ??; v0 = ??;
% pay attention to degrees vs radians
options = odeset(’Reltol’,??,’AbsTol’,??’);
[t,Y] = ode45(@f,[0,20],[theta0,v0],options,omega,c);
theta = Y(:,1);
figure(1); plot(t,??,’b-’); % theta in degrees
grid on
%--------------------------------------------function dYdt = f(t,Y,omega,c)
theta = Y(1); v = Y(2);
dYdt = [ ?? ; ?? ];
% fill-in ODE
Experiment with the following cases below, using m = 1, γ = 1, ` = 0.5, and g = 9.81. In each
case comment on the behavior of the pendulum and on the accuracy of the numerical simulation
(the figures show the angle θ in degrees as functions of time with tolerances set to 10−12 in odeset;
you may want to increase the accuracy to check whether the numerical solution obtained remains
the same).
MATLAB sessions: Laboratory 9
87
(a) θ(0) = 45 degrees, θ0 (0) = 1 rad/s.
50
40
30
20
10
0
−10
−20
−30
−40
0
2
4
6
8
10
12
14
16
18
20
10
12
14
16
18
20
10
12
14
16
18
20
(b) θ(0) = 180 degrees, θ0 (0) = 0 rad/s.
200
150
100
50
0
−50
−100
0
2
4
6
8
(c) θ(0) = 180 degrees, θ0 (0) = 10 rad/s.
550
500
450
400
350
300
250
200
150
0
2
4
6
8
88
MATLAB sessions: Laboratory 9
8. The Poe pendulum
(Poe’s Pendulum by Borelli, Coleman & Hobson, Mathematics Magazine, 58(2) (1985) 78-83)
Do problem 7 first. Assume that we have now a pendulum with a length increasing over time in
the form
` = `(t) = `0 (1 + αt)
where α is a positive constant. The ODE modelling the rate of change of θ now becomes
d2 θ
dθ
ω2
+
c
+
sin θ = 0
dt2
dt
1 + αt
(L9.5)
Compare the behavior of the Poe pendulum when α = 1 and for the values from problem 7. For
each of the 3 cases of initial values, plot the solution for the Poe pendulum compared to the solution
from problem 6. What is the general change in the frequency of oscillations? What happens if the
friction term c vanishes for the initial conditions θ(0) = 45 degrees, θ0 (0) = 1 rad/s? Make sure
that you integrate the differential equation over a sufficiently large time interval.