Pendulum Example PDF

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Nonlinear Second Order ODE

Pendulum Example
Consider the two-dimensional dynamics problem of a planar body of mass m
swinging freely under the influence of gravity. As shown, the body is pinned at
point O and has a mass center located at C. The angle θ defines the angular
position coordinate.

• O
L
•C

Applying the principles of Newtonian dynamics (MCE 263),

M O  I O  I O  mgL sin 

where I O is the mass moment of inertia of the body about point O and L is the
distance between points O and C. This gives the following equation of motion

d 2
 K sin   0 (1)
dt 2
where K = mgL/IO . Notice that this ODE is nonlinear (why?), but for the case of
small oscillations we can make the assumption sinθ ≈θ to get the linearized
equation of motion

d 2
 K  0 (2)
dt 2
Note that the solution to the linearized equation is given by

  A sin K t  B cos K t (3)


where A and B are arbitrary constants. These constants are actually related to the
appropriate initial conditions by A   (0) / K , B  (0)

Next we wish to solve the nonlinear equation (1). Following our standard
procedures to set up a numerical MATLAB solution, we let x   , x   to
1 2

develop the two first-order equations

 x1   x2 

 x   K sin x 
 2  1

The MATLAB solution to this system is given by the following code.

% MCE 372 Engineering Analysis Example Code


% Solution of Nonlinear Pendulum Problem
function main
% Run Two Cases with Different Initial Positions
clc;clear all;clf
g=9.81;m=100;L=1;Io=50;
K=m*g*L/Io;
xo=[pi/3,0];
[t,x]=ode45(@DE2,[0:0.01:5],xo);
plot(t,x(:,1),'k--','Linewidth',1.5)
xlabel('Time(t)'),ylabel('Angular Motion, \theta (rad)'),grid on
title('Numerical Solution of d^2\theta/dt^2+Ksin\theta=0')
axis([0,5,-1.5,2])
hold on
xo=[pi/10,0];
[t,x]=ode45(@DE2,[0:0.01:5],xo);
plot(t,x(:,1),'k-','Linewidth',1.5)
% Plot Linearized Solution of Previous Two Cases
to=pi/3,td=0;
T=0:0.05:5;
th=td*sin(sqrt(K)*T)+to*cos(sqrt(K)*T);
plot(T,th,'r*','Linewidth',1)
to=pi/10,td=0;
T=0:0.2:5;
th=td*sin(sqrt(K)*T)+to*cos(sqrt(K)*T);
plot(T,th,'b*','Linewidth',1)
legend('\theta(0) = \pi/3','\theta(0) = \pi/10'...
,'Linear \theta(0) = \pi/3','Linear \theta(0) = \pi/10')
function dxdt=DE2(t,x)
g=9.81;m=100;L=1;Io=50;
K=m*g*L/Io;
dxdt=[x(2);-K*sin(x(1))];
Notice that the code develops and plots two solutions for different initial angles
π/3 and π/10 with zero initial velocity. The code also computes and plots the
linearized solution given by relation (3). The graphical code output is shown
below

Numerical Solution of d2/dt 2+Ksin=0


2
(0) = /3
(0) = /10
1.5
Linear (0) = /3
Linear (0) = /10
1
Angular Motion,  (rad)

0.5

-0.5

-1

-1.5
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
Time(t)

For the case with the small initial angle  (0)   /10 (radians)  18 (degrees) , the
linear and nonlinear results are about the same. However, for the case
 (0)   / 3(radians)  60 (degrees) the two solutions show increasing differences
as time goes on. The linearized responses have a fixed period and frequency for
this free oscillation case, independent of the initial conditions, while the nonlinear
response shows dependency on the initial conditions.

You might also like