Fulltext01 PDF
Fulltext01 PDF
Fulltext01 PDF
Department of Mechanics
School of Engineering Sciences
KTH Royal Institute of Technology
Stockholm, Sweden
Abstract
- Douglas Adams
Contents
Contents v
1 Introduction 1
1.1 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.3 Problem Formulations . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3.1 Double Pendulum in 2D . . . . . . . . . . . . . . . . . . . . . 2
1.3.2 Double Pendulum in 3D . . . . . . . . . . . . . . . . . . . . . 3
1.3.3 Planet in Keplerian Orbit . . . . . . . . . . . . . . . . . . . . 4
2 Theory 5
2.1 Newtonian Mechanics . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.1.1 Newton’s Laws of Motion . . . . . . . . . . . . . . . . . . . . 5
2.1.2 Energy, Work and Conservative Fields . . . . . . . . . . . . . 6
2.1.3 Moment of Inertia . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1.4 Coordinate Transforms . . . . . . . . . . . . . . . . . . . . . . 8
2.2 Functionals and Variational Calculus . . . . . . . . . . . . . . . . . . 9
2.3 Lagrangian Mechanics . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.3.1 Lagrange’s Equations . . . . . . . . . . . . . . . . . . . . . . 13
2.3.2 Hamilton’s Variational Principle . . . . . . . . . . . . . . . . 13
2.3.3 Lagrange’s Equations from Hamilton’s Principle . . . . . . . 14
2.4 Stability of Dynamical Systems . . . . . . . . . . . . . . . . . . . . . 14
2.5 Orbital Mechanics . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.5.1 Kepler’s Laws . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.5.2 Mathematics of Ellipses . . . . . . . . . . . . . . . . . . . . . 17
2.5.3 Alternative Derivation of the Radius Vector of an Ellipse . . 22
3 Method 25
3.1 Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.2 General Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.3 Double Pendulum in 2D . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.3.1 Modelling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.3.2 Mechanical Analysis . . . . . . . . . . . . . . . . . . . . . . . 28
v
vi CONTENTS
4 Results 37
4.1 Double Pendulum in 2D . . . . . . . . . . . . . . . . . . . . . . . . . 37
4.1.1 Trajectory Plots . . . . . . . . . . . . . . . . . . . . . . . . . 38
4.1.2 Phase Portraits . . . . . . . . . . . . . . . . . . . . . . . . . . 38
4.2 Double Pendulum in 3D . . . . . . . . . . . . . . . . . . . . . . . . . 42
4.2.1 Trajectory Plot . . . . . . . . . . . . . . . . . . . . . . . . . . 42
4.2.2 Phase Portraits . . . . . . . . . . . . . . . . . . . . . . . . . . 43
4.3 Planet in Keplerian Orbit . . . . . . . . . . . . . . . . . . . . . . . . 45
4.3.1 Kepler’s First Law . . . . . . . . . . . . . . . . . . . . . . . . 45
4.3.2 Kepler’s Second Law . . . . . . . . . . . . . . . . . . . . . . . 46
4.3.3 Kepler’s Third Law . . . . . . . . . . . . . . . . . . . . . . . . 50
4.3.4 Phase Portraits . . . . . . . . . . . . . . . . . . . . . . . . . . 51
5 Discussion 53
5.1 Double Pendulum in 2D . . . . . . . . . . . . . . . . . . . . . . . . . 53
5.2 Double Pendulum in 3D . . . . . . . . . . . . . . . . . . . . . . . . . 54
5.3 Planet in Keplerian Orbit . . . . . . . . . . . . . . . . . . . . . . . . 54
6 Conclusions 57
6.1 Modelling with Lagrangian Mechanics . . . . . . . . . . . . . . . . . 57
6.2 Future Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Bibliography 59
A Maple code 61
A.1 Double Pendulum in 2D . . . . . . . . . . . . . . . . . . . . . 61
A.2 Double Pendulum in 3D . . . . . . . . . . . . . . . . . . . . . 63
A.3 Planet in Keplerian orbit . . . . . . . . . . . . . . . . . . . . 65
B Matlab code 67
B.1 Planet in Keplerian orbit . . . . . . . . . . . . . . . . . . . . 67
B.1.1 twobody.m . . . . . . . . . . . . . . . . . . . . . . . 67
B.1.2 areal_velocity.m . . . . . . . . . . . . . . . . . . . . 72
B.1.3 eccentric_anomaly.m . . . . . . . . . . . . . . . . . 74
Chapter 1
Introduction
1.1 Background
Analytical mechanics is a branch of classical mechanics which deals with new formu-
lations of classical mechanics, where the Lagrangian- and the Hamiltonian formu-
lation are among the most famous ones. This branch of mechanics evolved during
the latter part of the 18th century when mathematicians and physicists discovered
that the Newtonian formulation of classical mechanics did not suffice to solve cer-
tain types of mechanical problems. A new formulation of classical mechanics were
needed and in 1788 one of the most famous ones saw the light of day when the
French-Italian mathematician Joseph-Louis Lagrange published Mécanique analy-
tique containing what is nowadays known as the Lagrangian formulation of classical
mechanics.
With the implementation of Calculus of variations and Hamilton’s principle,
Lagrangian mechanics evolved into a powerful method which can be used to analyse
complex mechanical systems, especially when affected by conservative forces. With
the Lagrangian formulation, an approach based on energy instead of forces paved
the way for revolutionizing theories. Systems containing vast galaxies or microscopic
quantum particles can thus be analysed.
Along with the rise of computers during the middle part of the 20th century,
both previous and newly developed mathematical methods were utilized to take
advantage of the increase in computing power now at hand. The development of
analytical mechanics together with the usage of computers allowed for analysing
virtually any conceivable mechanical system.
1.2 Purpose
The objectives of this thesis are to model and analyse complex mechanical systems
by means of the Lagrangian formulation of classical mechanics with the aid of com-
puter assisted algebra, as well as to perform numerical verification of Kepler’s three
laws of planetary motion.
1
2 CHAPTER 1. INTRODUCTION
q1
’Problem 3.29
’Problem 3.27
The rigid rod OA of mass m and length ` is pivoted at O so that it may rotate
freely about a horizontal axis through O. A thin rod AB of negligible mass is
mounted at A by means of a ball bearing and may rotate freely about A. A particle
of mass m is attached to the rod at B. Choose some appropriate numerical values
of the parameters and calculate and plot the trajectory of the particle motion for
some initial conditions by means of the Sophia and Graphics packages.’
Apart from presenting the trajectory plot of the particle, various phase portraits
will also be presented and analysed.
4 CHAPTER 1. INTRODUCTION
b
q1
a c
Phase portraits for this system will also be analysed and discussed.
Chapter 2
Theory
This chapter introduces the models and underlying theory of classical and analytical
mechanics implemented in this thesis.
II. The change of motion is proportional to the applied force and takes place in
the direction of the straight line along which the force acts.
III. To every action there is an equal and contrary reaction; or, the mutual action
of any two bodies are always equal and oppositely directed along the same
straight line.’
These laws are the cornerstones of classical mechanics and by using them the equa-
tions of motion can be formulated for a given non-relativistic macroscopic system.
In general, it would be impossible obtain an analytical solution to the resulting
time-dependent differential equation or system of differential equations since they
are more than likely non-linear.
5
6 CHAPTER 2. THEORY
This is a very powerful result since one only have to solve (2.4) to determine if any
force field is conservative. Once a force field is known to be conservative, (2.8) can
be used to determine how much the potential energy has changed from one point to
another in the field. The fact that (2.8) only tells how large the change in potential
is allows you to define your zero point arbitrarily.
To connect the two components of a particles total energy the law of kinetic
energy [4, (9.12), p. 257] is used along with (2.8) to formulate an expression for the
total mechanical energy E as
T +V =E. (2.9)
Equation (2.9) provides a tool to relate the potential energy to the kinetic energy
as long as the particle moves in an conservative force field. Though, this is not the
entire story, when defining the kinetic energy (2.1) the moving object was viewed as
a particle i.e. all of its mass distributed in a single point. In reality when studying
solid objects one might have to consider that the distribution of mass is spread out
in space. This change of physical model results in amongst other things that the
expression for kinetic energy changes, as derived by Apazidis [5, pp. 215-220, 238-
240] from
m(v · v) m(vG · vG ) ω T IG ω
Tparticle = to Ttotal = TG + Trot = + , (2.10)
2 2 2
where vG is the velocity of the object’s centre of mass, ω is the object’s angular
velocity vector and IG is the inertia tensor with respect to the centre of mass G.
where Ω is the rigid body’s volume and dm is an infinitesimal mass element. These
equations are sufficient if the object rotates around one of the coordinate axis, but
in a more generalized case that requirement is not necessarily met.
8 CHAPTER 2. THEORY
It can be noted from (2.12) that Ixy = Iyx , Iyz = Izy and Izx = Ixz which together
with (2.11) can be written in a more compact form as the Inertia tensor, IO ,
Ixx Ixy Ixz
IO = Iyx Iyy Iyz . (2.13)
Izx Izy Izz
IQ = IG + md2 (2.14)
q
where d = x2G + yG 2 is the distance between the new axis of rotation Q and the
centre of mass. There exists an equivalent expression [5, p. 218] for the products of
inertia which is defined as
where Ix0 y0 is the product of inertia expressed in the centre of mass and xG , yG
is the distance from the centre of mass to the new coordinate system in x- and y-
direction, respectively.
1 0 0
T2 (β) = 0 1 0 (2.16)
sin(β) 0 cos(β)
cos(γ) sin(γ) 0
In the simplest case with only a rotation around one of the coordinate axis e.g.
around ê1 with the angle α, v can be expressed as
v 0 = T1 (α)v (2.17)
Z x2
F () = F [ϕ + η(x)] = f (ϕ(x) + η(x), ϕ0 (x) + η 0 (x), x)dx (2.20)
x1
φ2
φ(x)
φ1
x1 x2 x
Figure 2.1: The curve ϕ(x) makes the functional F [ϕ] an extremum and is contained
within a set of curves with the same endpoints.
2.3. LAGRANGIAN MECHANICS 11
The expression within brackets in (2.22) is called the functional derivative of f with
respect to ϕ and in order for ϕ to be a stationary function this expression must be
equal to zero for all variations η(x). This results in the differential equation
∂f d ∂f
− =0, (2.23)
∂ϕ dx ∂ϕ0
which is called Euler-Lagrange’s differential equation of variational calculus in one
dimension.
Generalized Coordinates
A set of coordinates that are independent and include the spatial constraints of the
system can be labeled as generalized coordinates. This concept can be exemplified
by a particle moving on the surface of a sphere with radius R, as in Figure 2.2.
y
z x
Figure 2.2: The xy-plane of a sphere showing the particle moving in a circular
motion on a circle with radius R from the origin.
’In general, the set of 3n space coordinates of the n-particle system will be replaced
by a set of (3n − Λ) generalized coordinates, as such
where r denotes the space coordinates, q the generalized coordinates and f the
degrees of freedom as a function of the number of particles n and the number of
constraints Λ.
In the example illustrated in Figure 2.2, n = 1 since one particle is considered
and Λ = 1 because the particle is constrained to the surface of the sphere. This
consequently results in the two generalized coordinates, q1 = θ and q2 = ϕ.
Configuration Space
Coordinate Path
q1 (t)
q2 (t)
q(t) = . , (2.25)
..
qn (t)
which describes the motion of the system. The coordinate path corresponds to the
configuration path by q(t) = χ(γ(t)) where χ is the coordinate function and γ is
the configuration path.[7]
1
A holonomic constraint is such that it may be expressed in the following form:
f (q1 , q2 , ..., qn , t) = 0, where {q1 , ..., qn } are the generalized coordinates of the system. [2]
2
A tuple is a finite ordered list of elements.
2.3. LAGRANGIAN MECHANICS 13
i=1
where Ki is the real, dynamic force and ṗi is the momentum of the i-th particle.
For a holonomically constrained system, the virtual displacements can be ex-
pressed as a function of the generalized coordinates. By defining the virtual displace-
ments in terms of generalized coordinates, the quantity δqk will be independent, in
contrast to δri from (2.26) which are dependent. As shown by Scheck [2, pp. 92-94],
replacing δri in (2.26) by δqk the following set of equations is obtained:
d ∂T ∂T
− = Qk , k = 1, 2, ..., 3n − Λ , (2.27)
dt ∂ q˙k ∂qk
where Qk is a quantity called generalized forces, T is the kinetic energy of the sys-
tem and Λ is the number of constraints.
Furthermore Sheck shows [2, p. 94] that if the generalized forces Qk are conser-
vative, they can be expressed as
∂
Qk = −V , (2.28)
∂qk
where V is the potential energy of the system, a function of the generalized coordi-
nates and time t. By introducing the Lagrangian function, L as
d ∂L ∂L
− =0, (2.30)
dt ∂ q˙k ∂qk
which are called Lagrange’s equations [2].
∂L d ∂L
− =0, k = 1, 2, ..., 3n − Λ . (2.32)
∂qk dt ∂ q˙k
This statement is proven analogously to (2.23) in Section 2.2 [2].
Phase Portrait
A phase portrait is a geometric representation of the trajectories of a dynamical
system when viewed in the phase plane.
Consider a single pendulum as in Figure 2.3.
L
g
=q
m
Figure 2.3: Single pendulum of a mass m and length L, with the angle θ as a
generalized coordinate q and g the acceleration due to gravity.
In the absence of friction and no external driving force, the pendulum is in a con-
servative force field due to g being the only acting acceleration. Since the system is
conservative, the total mechanical energy E defined as in (2.9) will be constant.
By defining the displacement angle θ from the y-axis as the generalized coordi-
nate q, it can be shown that the phase portrait for this system looks schematically
as in Figure 2.4 [8, pp. 168-170].
2.4. STABILITY OF DYNAMICAL SYSTEMS 15
.
q
Figure 2.4: Phase portrait of the single pendulum for different energy levels.
In Figure 2.4 the trajectories have been presented for different energy levels as con-
tours. The generalized coordinate q and its derivative with respect to time q̇ is
represented on the x-axis and y-axis respectively.
The physical interpretation of the phase portrait can be summarized as follows
[8, p. 170].
• The centre point (0, 0) is the stable equilibrium point where the pendulum is
at rest hanging vertically.
• Small orbits around the centre represent small oscillations about equilibrium,
i.e. the pendulum moves in a back-and-forth manner exhibiting periodic mo-
tion.
• As E increases, the pendulum will reach a state where the mass moves in a
continuous circular motion around the centre.
It is worth noting that even though the phase portrait generally has a strong con-
nection to the energy of the system, it is not necessary to generate the portrait as
a contour-plot for different energy levels. A set of data for q(t) and q̇(t) where t is
the time, is sufficient to generate the phase portraits and draw conclusions about
the stability of the system.
An attractor is defined as a region in the state space (i.e. a set of numerical
values) toward which the system tends to evolve. In contrast, a repellor is a region
that tends to repel the trajectories. If a system does not seem to behave in any
periodic manner and the number of degrees of freedom is greater than two, it can
usually be labelled as chaotic.
16 CHAPTER 2. THEORY
II. The line joining the planet to the sun sweeps out equal areas inside the ellipse
in equal time intervals. Therefore, the velocity at closest approach is greater
than the velocity at the furthest distance from the sun.
III. The square of the period of a planet is proportional to the cube of its mean
distance from the sun.’
Kepler’s first and second laws are illustrated in Figure 2.5.
The Second Law indicates that vp > va which can be realized by stating that in
order for the two grey-colored area segments in Figure 2.5 to be equal, the velocity
of the orbiting planet near the perihelion must be greater than the velocity near the
aphelion.
3
The prevalent definition of Kepler’s Third Law is normally formulated as ’The square of the
period of a planet is proportional to the cube of the semi-major axis of its orbit.’
2.5. ORBITAL MECHANICS 17
Figure 2.6: Ellipse with a polar coordinate system in its right focus.
To derive an expression for the radius r(θ) and the sector area A(θ), one would
first have to consider an ellipse with a Cartesian coordinate system centred in the
ellipses’ centre. The eccentricity e is defined [10] as
s
a
e≡ 1− , (2.33)
b
from which it is possible to derive the following equations relating the semi-major
and semi-minor axis, as well as the distance c between the foci and the centre to
the eccentricity,
p
b = a 1 − e2 (2.34)
c = ae . (2.35)
18 CHAPTER 2. THEORY
Inserting a polar coordinate system in the right focus as shown in Figure 2.6 results
in the coordinate transform defined as
x = r(θ) cos(θ) + c
(
(2.36)
y = r(θ) sin(θ) .
An ellipse centred in origo is defined as
2 2
x y
+ =1 (2.37)
a b
and by inserting (2.36) into (2.37) an expression for the ellipse with respect to the
polar coordinate system can be formulated as
2 2
r cos(θ) + c r sin(θ)
+ = 1. (2.38)
a b
Expanding (2.38) and inserting relations (2.34) and (2.35), the following expression
is obtained
a(1 − e2 )
r(θ) = . (2.41)
1 + e cos(θ)
To calculate the area A(θ), the area integral I is evaluated over the entire region
Ω covered by the ellipse,
ZZ ZZ
I= dA = {dA = dxdy} = dxdy , (2.42)
Ω Ω
r(θ)2
Z θ Z r(θ) Z θ
A(θ) = I = rdrdθ = dθ . (2.43)
0 0 0 2
If (2.41) and (2.43) are combined it is possible to calculate the radius as well as the
area from the right focus for an arbitrary ellipse with eccentricity e. The case when
the polar coordinate system is placed in the right focus, one would have to redo the
calculations from equation (2.36) down to equation (2.41). Though in that case it
2.5. ORBITAL MECHANICS 19
where tP is the time elapsed from the periapsis to position P in the orbit, a is
the semi-major axis, e is the eccentricity and ε is the eccentric anomaly. The
gravitational parameter µ is defined [9, p. 26] as
µ = G(m1 + m2 ) , (2.45)
where G is the universal constant of gravitation and m1 , m2 is the mass of the two
particles.
The derivation of (2.44) will not be shown here. For an in depth derivation,
Chapter 2 in Orbital Mechanics and Astrodynamics by Hintz, G. [9, pp. 23-53] is
highly recommended.
As can be seen in (2.44) the eccentric anomaly ε is required to determine the
time to a specific point in the orbit. When the true anomaly θ is known it is possible
to derive an expression for ε as a function of θ. The true- and eccentric anomalies
is defined in Figure 2.7 below.
20 CHAPTER 2. THEORY
Consider the ellipse in Figure 2.7 with a polar coordinate system in its right
focus and a Cartesian coordinate system in its centre. The vector F P 4 which runs
from focus F to the arbitrary point P on the ellipse is thus written as
!
r(θ) cos(θ) + ae
FP = , (2.46)
r(θ) sin(θ)
where r(θ) is the radius defined in (2.41), a is the semi-major axis and e is the
eccentricity defined in (2.33).
Next step is to multiply the y-component by a/b as a way to stretch the ellipse
in the y-direction, thus making it into a circle. Introduce the vector CQ which is
written as
4
A vector will in this section be defined in bold where the letters define the point it begin and
end at respectively.
2.5. ORBITAL MECHANICS 21
!
r(θ) cos(θ) + ae
CQ = = {Insert (2.41)} =
b r(θ) sin(θ)
a
!
a (1 − e2 )√
cos(θ) + e + e2 cos(θ)
= . (2.47)
1 + e cos(θ) 1 − e2 sin(θ)
Using the result in (2.47) it is possible to formulate an expression for the eccentric
anomaly as
√
sin(ε) 1 − e2 sin(θ)
tan(ε) = = . (2.48)
cos(ε) (1 − e2 ) cos(θ) + e + e2 cos(θ)
By introduction of the Weierstrass substitution which according to Spivak is
’The worlds sneakiest substitution’ [11, pp. 382-383], the following relations hold
true.
Let
2t
sin(x) =
1 + t2
x
t = tan , then 2 . (2.49)
2 cos(x) = 1 − t
1 + t2
Equation (2.48) is evaluated with the Weierstrass substitution (2.49), beginning
with the left hand side of the equal sign and moving on to the right hand side after
that. This gives
2t
sin(ε) 2 tan 2ε
1+t2
= = , (2.50)
cos(ε) 1−t2 1 − tan2 2ε
1+t2
√ √
1 − e2 sin(θ) 1 − e2 1+t
2t
2
= 2 , (2.51)
(1 − e2 ) cos(θ) + e + e2 cos(θ) 1−t2
(1 − e ) 1+t2 + e + e2 1−t
2
2
1+t
which after some algebra becomes
q
2 1−e
1+e tan θ
2
... = . (2.52)
1− 1−e
1+e tan2 θ
2
By inserting (2.55) into Kepler’s equation (2.44) an expression for the time it takes
from periapsis to a specific point in the orbit can be calculated as a function of the
true anomaly, s
a3
tp (θ) = (ε(θ) − e sin(ε(θ))) . (2.56)
µ
r2
r1
focus 1 θ
f
x
focus 2
f ≡ 2c êx , (2.57)
r2 = f + r1 . (2.58)
r1 + r2 = 2a (2.59)
2.5. ORBITAL MECHANICS 23
||r2 ||2 = ||f + r1 ||2 ⇐⇒ r22 = 4c2 + 4cr1 cos(θ) + r12 , (2.60)
which after utilization of the conjugate rule and (2.59), (2.61) can be simplified into
2 (a − r1 ) 2a = 4c (c + r1 cos(θ)) . (2.61)
By reformulating (2.35) as
c
e= (2.62)
a
and after inserting (2.62) into a rewritten form of (2.61) it results in
r1 c c r1 r1 r1
1− = + cos(θ) ⇐⇒ 1 − = e2 + e cos(θ) . (2.63)
a a a a a a
a 1 − e2
r1 (θ) = , (2.64)
1 + e cos(θ)
Method
This chapter describes the methods used to model and solve the three mechanical
problems presented in Section 1.3.
3.1 Software
To model, solve and present the mechanical problems various software were used.
This section briefly describes these programs and their respective area of application.
By using Maple and Sophia the rigid body problems studied in this thesis were
constructed and solved efficiently for the generalized coordinates at different time
25
26 CHAPTER 3. METHOD
Matlab
Matlab is primarily a program intended for numerical computing and visualization
through graphs and plots. By importing the solutions from Maple into Matlab
for the different mechanical problems, various graphs were created to present data.
Using Matlab’s animation functions, video sequences of the analysed mechanical
systems were recorded.
Blender
Blender is a free and open source 3D animation software developed and maintained
by the Blender Foundation. Blender is primarily used in this thesis as a tool to
visualize trajectories and motions of the studied problems, but it is also used to
render some of the images in this report.
IV. Solve the generalized coordinates and their respective derivatives numerically
using a Fehlberg fourth-fifth order Runge-Kutta method [12].
When the abovementioned steps have been completed, the problem can be further
analysed and visualized using Matlab and Blender.
The following sections in this chapter presents the method applied to each prob-
lem in a more thorough manner.
3.3. DOUBLE PENDULUM IN 2D 27
O
z
x
q1
3.3.1 Modelling
The double pendulum consists of two bars OA and AB of masses m1 and m2 and
lengths `1 and `2 respectively. The bars can rotate freely without friction in the
vertical xy-plane. The system exists in a conservative force field with standard
gravitational acceleration g.
A fixed reference frame N as well as two rotating Cartesian coordinate systems
A and B are defined as in Figure 3.1. Both A and B rotates around their respective
third-axis, i.e. around êA B
3 and ê3 . The generalized coordinates are q1 and q2 ,
28 CHAPTER 3. METHOD
where q1 is defined as the angle between bar OA and the y-axis of N . The second
coordinate q2 are defined as the angle between bar AB and the êA
2 -axis.
Kinetic Energy
The system consists of two rigid objects, namely bar OA and bar AB. In order to
calculate the kinetic energy for the bars as proposed by (2.10), the velocity vector
of the centre of masses are required.
The velocity vector for bar OA is
h i
vA
1 =
1
2 `1 q̇1 0 0 (3.1)
and for bar AB
h i
vB
2 = 2 `2 (q̇1
1
+ q̇2 ) + `1 cos (q2 )q̇1 `1 sin (q2 )q̇1 0 , (3.2)
where (3.1) is defined in the A-frame and (3.2) in the B-frame. This is denoted by
the use of superscripted A and B.
The moments of inertia for the bars are
1
I1 = m1 `21 (3.3)
3
and
1
I2 =
m2 `22 , (3.4)
12
for bar OA and AB respectively. Equation (3.3) has been derived using the parallel
axis theorem (2.14) and it represents the moment of inertia about the end of the
bar located in O. Equation (3.4) is the moment of inertia about the centre of mass
for bar AB, which is located in the middle of the bar. Note that both bars are
presumed to have negligible thickness and uniformly distributed mass.
Since the endpoint of the bar is fixed in O, the contribution to the kinetic energy
of the system will only depend on the rotational motion and I1 is determined as
in (3.3). The bar AB will however experience both translational and rotational
motion. By using (2.10) the kinetic energy for the bars is
1
T1 = I1 q̇12 (3.5)
2
3.3. DOUBLE PENDULUM IN 2D 29
and
1 1
T2 = I2 (q̇1 + q̇2 )2 + m2 (v B B
2 · v2 ) . (3.6)
2 2
Potential Energy
The reference level for the conservative force field is set to be the x-axis of the N -
frame and the potential energy for the two bars are therefore defined by the vertical
displacement of the centre of masses with regard to this level.
By analysing the geometry of the system, the potential energy for bar OA is
calculated to
1
V1 = − m1 `1 g cos (q1 ) (3.7)
2
and for bar AB to
1
V2 = −m2 g `1 cos (q1 ) + `2 cos (q1 ) cos (q2 ) . (3.8)
2
Lagrangian
In order to determine the Lagrangian L for this system, (2.29) is utilized by sum-
mation of the energy contributions for the two bars.
The Lagrangian for the double pendulum in 2D is
L = T1 + T2 − (V1 + V2 ) , (3.9)
where T1 , T2 , V1 and V2 are defined by (3.5)-(3.8).
3.4.1 Modelling
The double pendulum consists of two bars, bar OA with mass m and bar AB with
negligible mass. At the end of bar AB at point B, a particle with mass m is located.
The length of both bars are `. The bar OA may rotate freely without friction about
a horizontal axis through O and bar AB may rotate freely about A. The system
exists in a conservative force field with standard gravitational acceleration g.
A fixed reference frame N as well as three rotating frames A, B and C are
Cartesian coordinate systems and are defined as in Figure 3.2. The origin of N is
3.4. DOUBLE PENDULUM IN 3D 31
Kinetic Energy
The system consists of two rigid objects namely the bars OA and AB. In order to
calculate and present the trajectory for the particle located in B, the motion of the
two bars must be considered.
The bar OA will only experience rotational motion about the fixed point O.
The kinetic energy for bar OA can therefore be calculated as
1
T1 = I1 q̇12 , (3.10)
2
by applying (2.10). The moment of inertia-term I1 in (3.10), has been derived using
the parallel axis theorem (2.14) resulting in
1
I1 = m`2 . (3.11)
3
Since the bar AB is considered massless, the second contribution to the kinetic
energy of the system consists of the motion of the particle in B, which naturally
is dependent on the motion of the two bars. As calculated in Appendix A.2, the
velocity vector of the particle is
h i
v C2 = `(cos (q2 )q̇1 + cos (q3 )q̇1 + q̇3 ) `(sin (q2 ) sin (q3 )q̇1 + cos (q3 )q̇2 ) −` sin (q3 )q̇1
(3.12)
which is a vector defined in frame C.
By applying (2.10), the kinetic energy T2 for the particle can be derived as
1
T2 = m(v C2 · v C2 ) . (3.13)
2
32 CHAPTER 3. METHOD
Potential Energy
The reference level for the conservative force field is set to be the y-axis of the N -
frame and the potential energy for the bar OA and the particle in B are therefore
defined by the vertical displacement of the centre of masses with regard to this level.
The potential energy for the bar OA is
1
V1 = − m`g cos (q1 ) , (3.14)
2
which can be realized by inspecting the geometry in Figure 3.2.
In order to define the potential energy for the particle, the position vector to the
point B 1 with regard to the fixed N -frame is required. Using the Sophia-package,
this position vector is derived to
−` [cos (q2 ) sin (q1 ) cos (q3 ) + cos (q1 ) sin (q3 ) + sin (q1 )]
which is the displacement of the particle with regards to the reference level. The
potential energy for the particle is therefore
V2 = mg r N C · êN
z . (3.16)
Lagrangian
In order to determine the Lagrangian L for this system, (2.29) is utilized by sum-
mation of the energy contributions for the bar OA and the particle.
The Lagrangian for the double pendulum in 3D is
L = T1 + T2 − (V1 + V2 ) , (3.17)
where T1 , T2 , V1 and V2 are defined by (3.10), (3.13), (3.14) and (3.16) respectively.
1
Note that the point B coincides with the origin of the C-frame.
3.5. PLANET IN KEPLERIAN ORBIT 33
3.5.1 Modelling
When studying planetary motion it is possible to formulate different kinds of math-
ematical models depending on what the purpose of the study is. In this case an
analysis of a planet orbiting around a significant heavier object, e.g. a star, is per-
formed. Since both objects exerts an equal but opposite gravitational force on each
other (in accordance with Newtons third law motion) and the mass of a star [13] is
many orders of magnitude greater than the mass of a planet, approximating the star
as stationary in space is reasonable. The system is also considered to only consist
of particles since the effect of the rigid body’s rotation plays a minor part in the
objects motion on a planetary scale.
To allow for easier visualization as well as interpretation of the result from the
forthcoming analysis the systems’ parameters have been chosen to other values than
the astronomical ones. Mass of the star and mass of the orbiting planet is denoted
m1 and m2 respectively. The particle corresponding to the planet orbits frictionless
throughout space and the sole force acting on the two particles is gravity described
by Newton’s law of universal gravitation [2, p. 8],
mi mk
Fki = −G r̂ik , (3.18)
kri − rk k2
34 CHAPTER 3. METHOD
where Fki is the gravitational force between the two particles (i and k) and G is the
universal gravitational constant. The distance between the two particles is denoted
kri − rk k whereas r̂ik is the unit vector from particle i to k and mi , mk is the
particles respective mass.
A fixed reference polar coordinate system has been inserted with the star fixated
in its centre as shown in Figure 3.3. The generalized coordinates are q1 and q2 , where
q1 is defined as the radius to the planet and q2 is defined as the angle θ measured
from the line between the star and periapsis.
1 1
T = m2 (v1A · v1A ) = m2 (q12 q̇22 + q̇12 ) . (3.20)
2 2
Potential Energy
The potential energy function for a particle in a gravitational field is derived by
using the relations between mechanical work and potential energy from Section
2.1.2 and by solving (2.4) for the scalar field V with (3.18) as prevailing vector field.
An expression for the gravitational potential function is derived as
mi mk
V (r) = −G , (3.21)
r
where r = kri − rk k is the distance between particles i and k. By using (3.21)
with the aid of the generalized coordinates an expression for the total amount of
potential energy in the two body system can be formulated as
mi mk
V = −G . (3.22)
q1
Lagrangian
The Lagrangian of this system is formulated by insertion of (3.20) and (3.22) into
(2.29) resulting in
L=T −V . (3.23)
3.5. PLANET IN KEPLERIAN ORBIT 35
Results
This chapter presents the results of the analysed problems described in Section 1.3.
Table 4.2 shows the initial conditions for the generalized coordinates and their
derivatives for the two different cases A and B.
Initial Conditions
Case q1 (0) [rad] q̇1 (0) [rad/s] q2 (0) [rad] q̇2 (0) [rad/s]
A 1 0 1.5 0
B 1.1 0 1.4 0
Table 4.2: Initial conditions for the 2D pendulum in case A and case B.
Note that the parameters in Table 4.1 are defining properties in both cases.
The different initial conditions will alter the motion of the double pendulum as
time progresses. The resulting differences between the cases are presented later in
this section in the form of trajectory plots and phase portraits.
37
38 CHAPTER 4. RESULTS
0 0
-0.5 -0.5
-1 -1
-1.5 -1.5
-2 -2
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2
(a) Trajectory for point B, case A. (b) Trajectory for point B, case B.
Figure 4.1: Trajectory plots for point B for t : 0 → 10 s, for the different cases A
and B.
4 4
2 2
0 0
-2 -2
-4 -4
-6 -6
-1.5 -1 -0.5 0 0.5 1 1.5 -1.5 -1 -0.5 0 0.5 1 1.5
Figure 4.2: Phase portraits for the generalized coordinate q1 (t) for t : 0 → 100 s,
for the different cases A and B.
4.1. DOUBLE PENDULUM IN 2D 39
The phase portraits for the generalized coordinate q2 are presented in Figure 4.3,
where 4.3a and 4.3b describes case A and B respectively.
15 15
10 10
5 5
0 0
-5 -5
-10 -10
-15 -15
-20 -20
-70 -60 -50 -40 -30 -20 -10 0 10 20 30 -70 -60 -50 -40 -30 -20 -10 0 10 20 30
Figure 4.3: Phase portraits for the generalized coordinate q2 (t) for t : 0 → 100 s,
for the different cases A and B.
Note that the x-axis (generalized coordinate as a function of time) in the phase
portraits is not restricted to an interval of ±2π. The values of around −65 rad in
Figure 4.3b can be interpreted as a rotational motion of the bar AB in a clockwise
manner for a large number of consecutive revolutions.
40 CHAPTER 4. RESULTS
Figure 4.4 shows a sequence in which both cases A (blue) and B (green) are pre-
sented simultaneously.
4
1.5
3 10
1
2
5
0.5 1
(a) 0
0
-1
0
-0.5 -5
-2
-1 -3
-10
-1.5 -4
-5 -15
-2
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2 -1.5 -1 -0.5 0 0.5 1 1.5 -2 0 2 4 6 8 10 12 14
2 5
15
4
1.5
3 10
1
2
5
0.5 1
(b) 0
0
-1
0
-0.5 -5
-2
-1 -3
-10
-1.5 -4
-5 -15
-2
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2 -1.5 -1 -0.5 0 0.5 1 1.5 -2 0 2 4 6 8 10 12 14
2 5
15
Angular velocity [rad/s]
Angular velocity [rad/s]
Spatial coordinate [m]
4
1.5
3 10
1
2
5
0.5 1
(c) 0
0
-1
0
-0.5 -5
-2
-1 -3
-10
-1.5 -4
-5 -15
-2
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2 -1.5 -1 -0.5 0 0.5 1 1.5 -2 0 2 4 6 8 10 12 14
2 5
15
Angular velocity [rad/s]
Angular velocity [rad/s]
Spatial coordinate [m]
4
1.5
3 10
1
2
5
0.5 1
(d) 0
0
-1
0
-0.5 -5
-2
-1 -3
-10
-1.5 -4
-5 -15
-2
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2 -1.5 -1 -0.5 0 0.5 1 1.5 -2 0 2 4 6 8 10 12 14
2 5
15
Angular velocity [rad/s]
4
1.5
3 10
1
2
5
0.5 1
(e) 0
0
-1
0
-0.5 -5
-2
-1 -3
-10
-1.5 -4
-5 -15
-2
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2 -1.5 -1 -0.5 0 0.5 1 1.5 -2 0 2 4 6 8 10 12 14
Spatial coordinate [m] Angle [rad] Angle [rad]
Figure 4.4: Geometric configuration, Phase portraits for q1 (t) and Phase portraits
for q2 (t), in left, middle and right column respectively. Time after start of simula-
tion: (a) ∆t = 4.2 s; (b) ∆t = 4.5 s; (c) ∆t = 4.9 s; (d) ∆t = 5.1 s; (e) ∆t = 6.5
s.
4.1. DOUBLE PENDULUM IN 2D 41
The left column of subfigures shows the simulated geometric configuration of both
double pendulums, and the middle and right column shows the phase portraits
for q1 and q2 respectively. The rows indicate various times after the start of the
simulation sequence.
Figure 4.5 shows the phase portraits for both coordinates and cases, A in blue
and B in green.
3 10
2
5
1
0 0
-1
-5
-2
-3
-10
-4
-5 -15
Figure 4.5: Phase portraits for the generalized coordinate q1 (t) and q2 (t)
for t : 0 → 10 s, for both cases A and B.
42 CHAPTER 4. RESULTS
0.5
-0.5
-1
-1.5
-2
1
0.5 2
0 1
0
-0.5
-1
-1 -2
Figure 4.6: Trajectory of the particle with initial conditions and parameters defined
in Table 4.3.
4.2. DOUBLE PENDULUM IN 3D 43
From Figure 4.6 it can be noted that with the aforementioned initial conditions and
parameters the particle will follow an irregular and virtually chaotic trajectory.
10 200
5 100
0 0
-5 -100
-10 -200
-15 -300
-2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5 0 5 10 15 20 25 30 35
20
15
10
-5
-10
-15
-20
-25
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
Phase portraits for the three generalized coordinates q1 , q2 and q3 is generated for
a time interval of 100 seconds and is presented in Figure 4.8 below.
1400
10
1200
1000
5
800
0 600
400
-5
200
0
-10
-200
-15 -400
-3 -2 -1 0 1 2 3 -100 -80 -60 -40 -20 0 20 40
20
10
-10
-20
-30
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
Figure 4.8: Phase portraits for the generalized coordinates for t : 0 → 100 s.
Note that the angle which correspond to the generalized coordinate q2 in Figure 4.8b
is not restricted to an interval of ±2π. Instead an angle which is greater or lesser
than ±2π can be interpreted as consecutive revolutions in the same direction. To
exemplify, q2 reaches values around −100 rad which corresponds to a large number
of consecutive clockwise revolutions.
4.3. PLANET IN KEPLERIAN ORBIT 45
To verify this, different initial conditions have been used in the numerical equation
solver described in Section 3.5.2 producing different orbits for the planet. The
equation for an ellipse with its centre in (h, k) is given by
2 2
x−h y−k
+ =1 (4.1)
a b
where a is the semi-major axis and b is the semi-minor axis. By inserting the coor-
dinates of an arbitrarily selected point in the orbit into (4.1) along with respective
semi-major and semi-minor axis lengths it should equal to one in case the orbit is
an ellipse.
Results obtained when entering different initial conditions in the numerical solver
can be found in Table 4.5 below.
2 2
Initial conditions (a, b) (h, k) x−h
a + y−k
b
q1 (0) = 0.34, q2 (0) = 0 a = 1.4698 h = −1.1298 min = 1, max = 1
q̇1 (0) = 0, q̇2 (0) = 75 b = 0.9401 k=0 mean = 1, median =1
q1 (0) = 0.40, q2 (0) = 0 a = 2.5510 h = −2.1510 min = 1, max = 1
q̇1 (0) = 0, q̇2 (0) = 60 b = 1.3714 k=0 mean = 1, median =1
q1 (0) = 0.50, q2 (0) = 0 a = 0.4545 h = 0.0455 min = 1, max = 1
q̇1 (0) = 0, q̇2 (0) = 30 b = 0.4523 k=0 mean = 1, median =1
q1 (0) = 0.20, q2 (0) = 0 a = 2.3656 h = −2.1656 min = 1, max = 1
q̇1 (0) = 0, q̇2 (0) = 173 b = 0.9520 k=0 mean = 1, median =1
Table 4.5: Verification of Kepler’s first law for different initial conditions with pa-
rameter values m1 = 250, m2 = 1 and G = 0.5. Analysis is performed on all of the
calculated x- and y- coordinates (≈ 10000 points).
46 CHAPTER 4. RESULTS
As can be seen in the rightmost column in Table 4.5, when testing different initial
conditions the planet follows an elliptical orbit since the left hand side of (4.1)
always equals to one. Kepler’s first law can therefore be considered to be valid.
The line joining the planet to the sun sweeps out equal areas
inside the ellipse in equal time intervals. Therefore, the velocity
at closest approach is greater than the velocity at the furthest
distance from the sun.
Three different methods was used to verify the validity of Kepler’s second law. Two
of the three methods involved the use of Kepler’s equation (2.44) and the sector
area of an ellipse (2.43) derived in Section 2.5.2 whilst the third method used the
sector velocity.
Figure 4.9 shows that the predetermined area was selected to π/12 area units.
t 2 = 0.0608 s t 1 = 0.0605 s
Figure 4.9: Numerical verification of the validity of Kepler’s second law of planetary
motion.
As seen in Figure 4.9 the radius vector swept A1 during ∆t1 = 0.0605 s, and A2
during ∆t2 = 0.0608 s.
When performing the aforementioned method, area swept by the radius vector as a
function of elapsed time since periapsis is obtained and presented in Figure 4.10.
4.5
3.5
Swept area [area unit]
2.5
1.5
Evaluation of (4.2) for each discrete time results in the sector velocity as a function
of elapsed time since periapsis, as shown in Figure 4.11 below.
4.3. PLANET IN KEPLERIAN ORBIT 49
4.3439
Sector velocity [(area unit)/s]
4.3438
4.3437
4.3436
4.3435
4.3434
4.3433
0 0.2 0.4 0.6 0.8 1
Elapsed time since periapsis [s]
Figure 4.11: Sector velocity of the radius vector as a function of elapsed time since
periapsis.
Figure 4.11 confirms the conclusions drawn from Figure 4.10, i.e. Kepler’s second
law of planetary motion is valid.
dA r2
= θ̇ , (4.3)
dt 2
which by using the generalized coordinates defined in Section 3.5.1 can be written
as
dA q2
= 1 q̇2 . (4.4)
dt 2
By inserting the numerically computed values for the generalized coordinates ob-
tained from the Lagrange equations into (4.4), the sector velocity can be calculated
as a function of the discrete time steps.
50 CHAPTER 4. RESULTS
When calculating the sector velocity using (4.4) Figure 4.12 below is obtained.
4.339
4.338
Sector velocity [(area unit)/s]
4.337
4.336
4.335
4.334
4.333
4.332
4.331
4.33
0 0.2 0.4 0.6 0.8 1
Elapsed time since periapsis [s]
Figure 4.12: Sector velocity of the radius vector as a function of elapsed time since
periapsis.
This method results in a sector velocity of ~4.335 area units per second. The sector
velocity has now been utilized to verify Kepler’s second law of planetary motion.
To verify the validity of Kepler’s third law of planetary motion one first consider
Kepler’s equation (2.44). By inserting an eccentric anomaly of E(θ) = 2π, (2.44)
simplifies to s
a3
tp (θ = 2π) = 2π , (4.5)
µ
4.3. PLANET IN KEPLERIAN ORBIT 51
70
10
60
5
50
0 40
30
-5
20
-10
10
-15 0
0 0.5 1 1.5 2 2.5 3 0 2 4 6 8 10 12 14 16
Figure 4.13: Phase portraits for the generalized coordinates for t : 0 → 2.5 s.
It can be noted from Figure 4.13a that the generalized coordinate q1 which corre-
sponds to the radius as well as q2 which corresponds to the true anomaly exhibits
periodic patterns. This is expected from a planet moving in a stable Keplerian
orbit.
Chapter 5
Discussion
53
54 CHAPTER 5. DISCUSSION
higher energy level for case B, which can also be noted by inspecting the phase
portrait for q1 at row (a) in Figure 4.4. The case B (green) trajectory follows the
case A (blue) rather closely, aside from being located farther away from the origin
and thus generating a larger phase space which can be seen both in Figure 4.2 or
Figure 4.5a. By further examining the sequence it is possible to pinpoint when the
two cases start to behave differently. From t = 0 to t = 4.2 seconds, i.e. row (a)
in Figure 4.4, both phase portraits trace similar trajectories. Between 4.5 and 4.9
seconds the motion of the two pendulums differ largely, as can be seen in the phase
portraits at rows (b) and (c). The last row, (e), shows the state of the pendulums
after 6.5 seconds and the difference between the cases are distinct. The trajectory
in case A (blue) for q2 seem to be attracted to a region of around 13 rad whilst the
trajectory in case B (green) seem to be in a quasi-periodic orbit, visible in Figure
4.5b.
The sequence in Figure 4.4 indicates that the double pendulum is sensitive to
initial conditions and the effects can be seen after a few seconds.
The main reason as to why these changes in values were made was to minimize
the effects of numerical errors. The floating point precision of Matlab is 16 dec-
imals which means that to remain within acceptable accuracy one would have to
change the Sun’s mass roughly 1014 kg. To circumvent these types of computational
problems occurring when working with values on an astronomical scale, the possi-
bility to change into- and perform the calculations in the astronomical system of
units [14] exists. In this system of units, the base for length is the astronomical unit
(au) which corresponds to the distance from the Sun to Earth, instead of meter as
in the SI-system. Another example is that instead of kg, the IAU-system use one
solar mass as its base for mass.
Figure 4.13 shows the phase portraits for the generalized coordinates q1 and
q2 corresponding to the radius and the true anomaly respectively. Both phase
portraits demonstrate a periodic behaviour of the coordinates which have to be the
case when a planet orbits in a Keplerian orbit. An object which follows e.g. a
hyperbolic trajectory will not exhibit any periodic behaviour since its orbit is not
bound to the larger body. It will thus not obey Kepler’s laws of planetary motion.
The results obtained when verifying Kepler’s first law of planetary motion were
conclusive. The planet followed an elliptical orbit regardless of initial conditions. It
is worth to note that the reason as to why q2 (0) and q̇1 (0) have been kept equal to
zero for all different cases (as shown in Table 4.5) solely has to do with programming
issues. It turned out to be problematic to determine the length of the semi-major
and semi-minor axis from a discrete set of data points when the ellipse was tilted.
Instead it was decided that only initial conditions which kept the major and minor
axis parallel to the coordinate system were to be used.
Kepler’s second law of planetary motion was verified by several different methods,
each with its own strengths and weaknesses. The first method involved an iterative
process where the elapsed area during small changes in time were summed up to a
predetermined value. This process was repeated at a later stage in the orbit and
the two elapsed times were compared. The discrepancy between the two calculated
times as seen in Figure 4.9, are most likely due to numerical errors. Since the input
to (2.43) are discrete values it is possible that the calculated areas ends up either
slightly bigger or smaller than the predetermined value of π/12. This results in a
difference in the calculated time since A1 and A2 may differ in size. To minimize
this error a smaller time step can be used when solving the Lagrange equations.
As shown in Section 4.3.2 the second method used was to plot the swept area as
a function of elapsed time by means of Kepler’s equation. As expected, this process
resulted in a linear function (see Figure 4.10) which after differentiation proved that
56 CHAPTER 5. DISCUSSION
the sector velocity is constant for all times (see Figure 4.11). This method resulted
in a sector velocity of approximately 4.344 area units per second.
The third and final method used to verify Kepler’s second law involved utilizing
an analytically derived expression for the sector velocity. Insertion of the generalized
coordinates computed by Maple into (4.4) resulted in the plot shown in Figure 4.12
with the constant sector velocity of approximately 4.335 area units per second.
A discrepancy in the result between the last two methods can be noted. The
reason for this has to do with the accuracy of the two different methods used. It is
expected that the last method (i.e. the analytical) is the most accurate of the two
since it rests firmly on an analytical foundation whereas the second method requires
more numerical calculations.
Conclusions
This chapter draws conclusions based on the results presented in Chapter 4 and the
discussions presented in Chapter 5.
57
58 CHAPTER 6. CONCLUSIONS
The Pendulums
A crucial difference between the two pendulums is the additional degree of freedom
introduced in the 3D problem. This has a large influence on, not only the actual
motion of the pendulum but also on the characteristic signature of the system as
can be seen in the phase portraits. While 2D problems with two degrees of freedom
is at most non-periodic, 3D problems with three degrees of freedom may be chaotic.
The fact that a dynamical system can be chaotic and thus sensitive to initial con-
ditions, provides an explanation as to why the complex motion arises. By analysing
the phase portraits, certain behavioural aspects of the system can be interpreted.
In order to compare and qualitatively discuss the differences between the pen-
dulums, additional tools not used in this thesis is required.
Keplerian Orbit
The use of Lagrangian mechanics when analysing Kepler’s three laws of planetary
motion was not necessary in the two-body problem since there exists an analytical
solution. The need for Lagrangian mechanics arises when considering an unre-
stricted three-body problem, though it is also here one of the largest drawbacks of
the Lagrangian formulation arises. In order to model a system with three bodies,
one would have to define three generalized coordinates for each body resulting in a
total of 9 Lagrange equations to solve.
[3] Matthews PC. Vector Calculus. 1st ed. Springer Undergraduate Mathematics
Series. Springer-Verlag London; 1998. 7th printing 2005.
[4] Apazidis N. Mekanik. 1, Statik och partikeldynamik. 2nd ed. Lund: Lund :
Studentlitteratur; 2013.
[5] Apazidis N. Mekanik. 2, Partikelsystem, stel kropp och analytisk mekanik. 1st
ed. Lund: Lund : Studentlitteratur; 2012.
[6] Arfken GB, Weber HJ, Harris FE. Mathematical Methods for Physicists. 7th ed.
Boston: Academic Press; 2013. Available from: http://www.sciencedirect.
com/science/article/pii/B978012384654900030X.
[8] Strogatz SH. Nonlinear dynamics and chaos : with applications to physics,
biology, chemistry and engineering. 2nd ed. Cambridge, Massachusetts.: West-
View Press; 2000.
[9] Hintz GR. Orbital Mechanics and Astrodynamics - Techniques and Tools for
Space Missions. 1st ed. Springer International Publishing; 2015.
[11] Spivak M. Calculus. 3rd ed. Houston, Texas: Pubish or Perish, Inc.; 1994.
59
60 BIBLIOGRAPHY
[13] Williams DR. "Sun Fact Sheet". NASA Goddard Space Flight Center; 2016.
[Accessed 19th April 2017]. [Online]. Available from: https://nssdc.gsfc.
nasa.gov/planetary/factsheet/sunfact.html.
[14] IAU. "Measuring the Universe: The IAU and astronomical units". International
Astronomical Union; 2017. [Accessed 9th May 2017]. [Online]. Available from:
https://www.iau.org/public/themes/measuring/.
[15] Williams DR. "Jupiter Fact Sheet". NASA Goddard Space Flight Center; 2016.
[Accessed 11th May 2017]. [Online]. Available from: https://nssdc.gsfc.
nasa.gov/planetary/factsheet/jupiterfact.html.
Maple code
61
> # ––––––– III. Euler-Lagrange equations ––––––– #
> L := subs(q1t=u1,q2t=u2,L):
> L__q1 := diff(L,q1):
> L__q2 := diff(L,q2):
> L__u1 := diff(L,u1):
> L__u2 := diff(L,u2):
> L__u1_t := &dt L__u1:
> L__u2_t := &dt L__u2:
> eq1 := L__u1_t-L__q1=0:
> eq1 := subs(q1t=u1,q2t=u2,eq1):
> eq2 := L__u2_t-L__q2=0:
> eq2 := subs(q1t=u1,q2t=u2,eq2):
> kde := {q1t=u1,q2t=u2}:
> eq1 := {u1t=solve(eq1,u1t)}:
> eq2 := {u2t=solve(eq2,u2t)}:
> eqs := eq1 union eq2 union kde:
> # ––––––– IV. Solver ––––––– #
> eqst := subs(toTimeFunction,eqs):
> eqst := subs(param,eqst):
> ff := dsolve(eqst union InitCond,{q1(t),q2(t),u1(t),u2(t)},type=numeric,
maxfun=500000):
> numberOfPoints := 720:
> integrationTime := 30:
> _plot := odeplot (ff,[[t,q1(t)],[t,q2(t)],[t,u1(t)],[t,u2(t)]],0..
integrationTime , numpoints = numberOfPoints):
> gg := dsolve(eqst union InitCond,{q1(t),q2(t),u1(t),u2(t)},type=numeric,
maxfun=500000,output=Array([seq((1/100*i),i=0..10000)])):
> gg := gg(2,1):
Matlab code
% ------------------------ %
% ---- Phase Portrait ---- %
% ------------------------ %
figure
plot(A(:,2),A(:,4),'Color',[0 0.447 0.8])
title('Phase Portrait: q_1(t)','FontSize',20)
xlabel('$$ q_1(t) $$','Interpreter','LaTex','FontSize',16)
ylabel('$$ \dot{q}_1(t) $$','Interpreter','LaTex','FontSize',16)
grid on
figure
plot(A(:,3),A(:,5),'Color',[0 0.447 0.8])
title('Phase Portrait: q_2(t)','FontSize',20)
xlabel('$$ q_2(t) $$','Interpreter','LaTex','FontSize',16)
ylabel('$$ \dot{q}_2(t) $$','Interpreter','LaTex','FontSize',16)
grid on
67
% ----------------------------- %
% ----- Kepler, First law ----- %
% ----------------------------- %
% Ellipse dimensions
a = (max(x)+min(x))/2-min(x);
b = (max(y)-min(y))/2;
e = sqrt(1-(b/a)^2);
h = (max(x)-a);
k = (max(y)-b);
ellipse_analysis = [min(ellipse)
max(ellipse)
mean(ellipse)
median(ellipse)]; % [Min, max, mean, median]-values
ellipse_analysis2 = [min(ellipse2)
max(ellipse2)
mean(ellipse2)
median(ellipse2)]; % [Min, max, mean, median]-values
% ---------------------------- %
% ---- Kepler, Second law ---- %
% ---------------------------- %
% Physical parameters
M = 250;
m = 1;
G = 5e-1;
mu = G*(M+m);
% --------------------------- %
% ---- Various variables ---- %
% --------------------------- %
% Radius for both bodies, center loc. for planet (Used in plot)
radius = 0.035;
radius2 = 0.075;
center = [x y];
theta = linspace(0,2*pi);
% Find index of one complete orbit
tmp = abs(A(:,3)-2*pi);
[idx idx] = min(tmp);
% -------------------------- %
% ---- Plot environment ---- %
% -------------------------- %
figure
% Plot the trajectory of the orbit
trajectory = plot(x,y,'k');
hold on
% Legend: Planet
X = -2.2 + radius.*cos(theta);
Y = -1.2 + radius.*sin(theta);
legend_planet=fill(X,Y,[255 0 0]/255);
text(-2.13, -1.2,'- Orbiting Planet')
% Legend: Sun
X = -0.6 + radius2.*cos(theta);
Y = -1.2 + radius2.*sin(theta);
legend_sun=fill(X,Y,[255 255 0]/255);
set(legend_sun,'EdgeColor','r');
text(-0.48, -1.2,'- Sun')
% Semi-major/minor axis
line_major = line([min(x) max(x)],[0 0],'Color',[160 160 160]/255,...
'LineWidth',1.3,'LineStyle','--');
line_minor = line([x(find(y==min(y))) x(find(y==max(y)))],[min(y) max(y)],...
'Color',[160 160 160]/255,'LineWidth',1.3,'LineStyle','--');
% ------------------------- %
% ---- Animation-block ---- %
% ------------------------- %
% Null variables/strings
area = 0; area2 = 0; j = 0; k = 0; l = 0;
time1 = '0'; time2 = '0'; time_orbit = '0';
% Draw circles
X = center(i,1)+radius.*cos(theta); % Create X values for the circle
Y = center(i,2)+radius.*sin(theta);
planet=fill(X,Y,[255 0 0]/255);
set(planet,'EdgeColor','None');
% Coordinates for the radius-line.
XR = linspace(0,r(A(i,3))*cos(A(i,3)));
YR = linspace(0,r(A(i,3))*sin(A(i,3)));
% ------------------- %
% ---- Kepler II ---- %
% ------------------- %
% Ellipse dimensions
a = (max(x)+min(x))/2-min(x);
b = max(y);
e = sqrt(1-(b/a)^2);
% Physical parameters
M = 250;
m = 1;
G = 5e-1;
mu = G*(M+m);
arealvelocity = abs(A(:,2).^2.*A(:,5))/2;
theta = 0:0.01:2*pi;
for i = 1:length(theta)
Area(i) = integral(rad,0,theta(i));
time(i) = tp(theta(i));
end
P = polyfit(time,Area,1);
figure
plot(time,Area,'b',time,polyval(P,time)+0.3,'r-','LineWidth',1.5)
title('Swept area as a function of elapsed time')
legend(['Calculated data'],['Reference line: A = ',num2str(P(1),'%.2f'),'t + 0.3'])
grid on
xlabel('Elapsed time since periapsis [s]')
ylabel('Swept area [area unit]')
for i = 1:length(theta)-1
Area_vel(i) = (Area(i+1)-Area(i))/(time(i+1)-time(i));
end
figure
plot(time(1:end-1),Area_vel,'b','LineWidth',1.5)
axis([0 1 4.3433 4.344])
grid on
title('Areal velocity as a function of elapsed time since periapsis')
xlabel('Elapsed time since periapsis [s]')
ylabel('Areal velocity [(area unit)/s]')
figure
plot(A(1:4001,1),arealvelocity(1:4001),'b','LineWidth',1.5)
axis([0 1 4.33 4.34])
grid on
title('Areal velocity as a function of elapsed time since periapsis')
xlabel('Elapsed time since periapsis [s]')
ylabel('Areal velocity [(area unit)/s]')
74 APPENDIX B. MATLAB CODE
B.1.3 eccentric_anomaly.m