Sei sulla pagina 1di 8

Numerical Solution of the Double Pendulum

by Reinaldo Baretti Machn

References:
1.http://en.wikipedia.org/wiki/Double_pendulum

2. Theoretical Physics. First Edition. [Paperback]

A S Kompaneyets

, pages 29, 61

3. Classical Mechanics 1st Edition by Herbert Goldstein (Hardcover - 1951)


4

An Introduction to Computer Simulation Methods: Applications to Physical Systems (3rd Edition) by Harvey Gould, Jan

Tobochnik and Wolfgang Christian

Abstract : A numerical code is developed to integrate the two coupled equations of motion describing the double pendulum
motion.

The masses m1 , m2 are held by rigid mass less chords L1 and L2 . We assume a friction free motion.
To write the Lagrangian start with the expression for the kinetic energy.

The Cartesian coordinates are

r1 = (x1 , y1 ) = L1 (sin1 , -cos1 )

(1)

r2 = ( x2 , y2 ) = ( L1 sin1 + L2 sin2 , - L1 cos1 - L2 cos2 )

(2)

The velocity components are


v1 = (dx1/dt , dy1/dt) = L1 1 ( cos1 , sin1 )

, 1(t) = d1 /dt ,

(3)

v2 = (dx2/dt , dy2/dt) = (L1 1 cos1 + L22 cos2 , L1 1sin1 +L22 sin2) ,2(t) = d2 /dt . (4)
The square of the velocities are
v12 = L1212
v22 = L1212 + L2222 + 2L1L2 1 2 cos(1- 2 )

(5)
. (6)

The kinetic energy is


T =(1/2)m1 L1212 + (1/2)m2 { L1212 + L2222 +2L1L2 1 2 cos(1- 2 ) }
The potential energies are

. (7)

V1 = -m1 g L1 cos1 , V2 = -m2 g ( L1cos1 + L2 cos2 )

. (8)

The Lagrangian is a function of , 1 , 2 , 1 , 2 .


L( 1,2 , 1 , 2 ) = T - V1 - V2
= (1/2)m1 L1212 + (1/2) m2 { L1212 + L2222 +2L1L2 1 2 cos(1- 2 ) }
+ m1 g L1 cos1 + m2 g ( L1cos1 + L2 cos2 )

. (9)

The equations of motion are


d ( L/ i) /dt = L/ i

, i=1,2

. (10)

The partial derivatives on the right hand side of (10) are


L/ 1 = m2 12 sin(2 - 1) L1 L2 - g L1( m1 +m2 ) sin(1)
L/ 2 = -m2 12 sin(2 - 1)L1 L2 -gm2 L2 sin(2)

MAXIMA code

The derivatives with respect to the angular velocities are


L/ 1 = m1 1 L12 +(m2/2) {22 L1 L2 cos(1- 2 ) + 21 L12 }

L/ 2 = (m2 /2) { 22 L22 + 21 L1 L2 cos(1- 2 ) }

MAXIMA code

, (13)

. (14)

(11)

(12)

The time derivatives are


d{ L/ 1 }/dt = m1 (1 ') L12 + m2{ 2 ' L1 L2 cos(1- 2 ) -2 L1 L2 (1 -2)sin(1- 2 ) + 1' L12 } ( 15 )
where i ' = di /dt = d2 i /dt2 .

d{ L/ 2 }/dt =m2 { 2 ' L22 + 1 ' L1 L2 cos(1- 2 ) -1 L1 L2 (1 - 2) sin (1- 2 ) }


*********

( 16 )

***********

Rewrite (15) and (16) as


1 ' ( m1 L12 +m2 L12 ) + 2 ' m2 L1 L2 cos(1- 2 ) = L/ 1 + m2 1 L1 L2 (1 - 2) sin (1- 2 ) ,
F1 (1,2 , 1 , 2 )

(17)

1 ' m2 L1 L2 cos(1- 2 ) + 2 ' m2 L22 = L/ 2 + m2 1 L1 L2 (1 - 2) sin (1- 2 )


F2 (1,2 , 1 , 2 )

,
. (18)

Solving the equations for the accelerations


1 ' = {F1 m2 L22 - F2 m2 L1 L2 cos(1- 2 )}/[( m1 L12 +m2 L12 ) m2 L22 - (m2 L1 L2 cos(1- 2) )2 ] ,(19)
2 ' ={( m1 L12 +m2 L12 )F2 -m2 L1 L2 cos(1- 2 ) F1 }/[( m1 L12 +m2 L12 ) m2 L22 - (m2 L1 L2 cos(1- 2) )2 ] . (20)
For the purpose of the numerical calculations we re label the right hand side of (19 ) and (20)
d2 1 /dt2 = G1(1, 2 , 1 , 2 )

(21)

d2 2 /dt2 = G2(1, 2 , 1 , 2 )

(22)

The finite difference solutions of (21) and (22) are


1 ( tn) = 2 1( tn-1) - 1 ( tn-2) + ( t )2 G1 ( tn-1)

(23)

2 ( tn) = 2 2( tn-1) - 2 ( tn-2) + ( t )2 G2 ( tn-1)

(24)

In the example given below the initial conditions will always be 1 (0) = 0 , d1(0)/dt=0 ; 2 (0) 0 ,
d2 (0)/dt =0. The only non zero initial condition is the displacement of the second pendulum.

Unless special cases are assumed there will be various time scales .
The time scale arise from possible combinations of the ratio of the masses and the length of the pendulum,
tscale ~ ( mi/mj ) 1/2 [ Lk2 /( Ln g) ]1/2

. (25)

In the simple case where m1 = m2 , and L1 = L2 = L


tscale ~ ( L/G)1/2

(26)

The choice of t in the numerical integration has to be much smaller than the smallest time scale.
EXAMPLES:
Parameters and initial conditions
1. m1 = m2 = .2 kg , L1 = L2 = 1. , 1 (0)= 0. , 2 (0) = /4 , 1 (0)= 0, 2 (0)= 0 .

Fig 1. 1 and 2 .

Fig 2. Oscillation of the kinetic energies.


2. Very different masses
m1 =5.0 m2 = .1 kg , L1 = L2 = 1. , 1 (0)= 0. , 2 (0) = /4 , 1 (0)= 0, 2 (0)= 0 .

Fig 3. Same length but very different masses.

FORTRAN code
c Double pendulum 30 jun 2011
real L1, L2 ,m1,m2
data g,z10,z11,z20/9.80,0.,0.,.4/
data w1,w2/0.,0./
data m1,m2,L1,L2/.3,.3,1.,1./
dLdz1(z1,z2,w1,w2)=m2*w1*w2*L1*L2*sin(z2-z1)-g*L1*(m1+m2)*sin(z1)
dLdz2(z1,z2,w1,w2)=-m2*w1*w2*L1*L2*sin(z2-z1)-g*m2*L2*sin(z2)
F1(z1,z2,w1,w2)= dLdz1(z1,z2,w1,w2)+ m2*w1*L1*L2*(w1 - w2)
$ *sin(z1- z2)
F2(z1,z2,w1,w2)=dLdz2(z1,z2,w1,w2)+m2*w1*L1*L2*(w1-w2)*sin(z1-z2)
den(z1,z2)=m2*L2**2*(m1*L1**2+m2*L1**2)- (m2*L1*L2*cos(z1-z2))**2
G1(z1,z2,w1,w2)=(F1(z1,z2,w1,w2)*m2*L2**2 - F2(z1,z2,w1,w2)*m2*L1*
$ L2*cos(z1- z2))/den(z1,z2)
G2(z1,z2,w1,w2)=((m1*L1**2+m2*L1**2)*F2(z1,z2,w1,w2) -m2*L1*L2*
$ cos(z1- z2)*F1(z1,z2,w1,w2) )/den(z1,z2)
pi=2.*asin(1.)
z21=z20
ts1=((m1/m2)*(L1**2/(L2*g)))**.5
ts2=((m2/m1)*(L2**2/(L1*g)))**.5
tsmall=amin1(ts1,ts2)
tlarge=amax1(ts1,ts2)

dt=tsmall/100.
tf=6.*tlarge
nstep=int(tf/dt)
kp=int(float(nstep)/100.)
kount=kp
print*,'tf,dt,nstep=',tf,dt,nstep
print*,' '
print 100,0.,z10,z20
do 10 i=2,nstep
t=dt*float(i)
z12=2.*z11-z10+dt**2*G1(z11,z21,w1,w2)
z22=2.*z21-z20+dt**2*G2(z11,z21,w1,w2)
c print*,'dt,z11,z21=',dt,z11,z21
c print*,'G1,G2=',G1(z11,z21,w1,w2),G2(z11,z21,w1,w2)
if(i.eq.kount)then
print 100,t,z12,z22
kount=kount+kp
endif
w1=(z12-z11)/dt
w2=(z22-z21)/dt
z10=z11
z11=z12
z20=z21
z21=z22
10 continue
100 format('t,theta1(rad),theta2=',3(3x,e10.3))
stop
end

Potrebbero piacerti anche