project hgs24
TRANSCRIPT
The Trojan Asteroids
Abstract
The circular restricted three body problem is investigated numerically near the points of stable
equilibrium preceding and trailing Jupiter (L4 and L5). The Runge-Kutta Fehlberg (4,5) routine was
implemented to solve the motion of the Trojan asteroids in the Sun-Jupiter system. We found that
an asteroid initially placed at L4 will remain fixed in this stable position. Asteroids were also shown
to undergo libration about L4 for small radial separations from the stability position. The resulting
orbits were characteristically shaped like either a tadpole or a horseshoe. The effect of varying the
mass of the planet on the stability of the asteroid’s orbits was also examined. We discovered that a
threshold mass exists (∼ 0.04M) above which asteroids quickly become unstable. Furthermore, it
was found that resonant behaviour occurs for planet masses near 0.0137M and 0.025M. Finally,
a relationship between the libration amplitude and the planet mass was derived for smaller masses
than Jupiter.
1 Introduction
Whilst attempting to solve the three body problem, Lagrange [1772] discovered that if two bodies move
in circular, coplanar orbits around their centre of mass then there exist five stationary points for a third
body of negligible mass. Two of these stationary points, L4 and L5, are theoretically stable [Dermott
and Murray, 1999] and have been shown to be stable for the Trojan asteroids of the Sun-Jupiter system
thus validating Lagrange’s theory.
An analysis of the behaviour of Trojan asteroids around these two stationary points is presented
here. We model the Sun-Jupiter-Trojan system according to the circular restricted three body problem
(CRTBP) described above with the asteroid acting as the negligible mass. Also, for convenience, we
work in the co-rotating frame of the Sun and Jupiter and consider only the plane of their rotation. This
simplifies the problem so that we now only have an asteroid moving under the influence of the Sun,
Jupiter and the centrifugal’s combined static potential rather than a potential that depends on time.
As we shall see later this means that the Hamiltonian is a constant of motion in this frame. From the
Euler-Lagrange equations (see appendix A), we find that the equation of motion of the asteroid is,
d2~x
dt2= −GMs(~x− ~xs)
| ~x− ~xs |3− GMj(~x− ~xj)
| ~x− ~xj |3− 2(~Ω× d~x
dt)− ~Ω× (~Ω× ~x) (1)
where ~x is the position of the asteroid; ~xs and Ms are the fixed position and mass of the Sun; ~xj and Mj
1
The Trojan Asteroids
are the fixed position and mass of Jupiter; and Ω is the angular velocity of the frame.
Currently, this differential equation is non-integrable so we computed the path of a Trojan asteroid
numerically. This was done using an adaptive Runge-Kutta-Fehlberg integrator. It was then demon-
strated that the asteroids stayed fixed at the Lagrange point L4 to show that there were no numerical
instabilities propagating during the computation. The next step was to vary the initial positions of the
asteroid near Lagrange point L4 and plot the subsequent motion after a few hundred orbits of Jupiter.
Lastly, the behaviour of the resulting orbits was investigated for a range of planetary masses.
2 Analysis
2.1 The Model
Although the actual motion of Jupiter and the Sun is elliptic, important results that are inherent to all
restricted three body problems can be found by simplifying the situation to that of circular motion. In
the circular restricted three body problem the motion of the two massive bodies (the Sun and Jupiter)
is solved. Their orbits are circular and coplanar around their centre of mass with constant angular
frequency, Ω, which is given by Kepler’s law:
Ω2R3 = G(Ms +Mj). (2)
All that is left to solve is the motion of the asteroid. Working in the co-rotating frame of the bodies
about the barycentre, the motion is that of an asteroid moving in a non-centralised static potential. The
positions of the Sun and Jupiter are given by,
~xs =
(− Mj
M +MjR, 0, 0
)(3)
~xj =
(M
M +MjR, 0, 0
)(4)
where R is the distance between the Sun and Jupiter. Using numerical techniques, we solved the trajectory
of the asteroid after initially positioning it near one of stable points (due to the symmetry of the problem
it does not matter whether we place an asteroid around L4 or L5). The positions of these two points in
Cartesian coordinates [Nelson, n.d.] are given exactly by,
L4,5 =
(1
2
M −Mj
M +MjR,±
√3
2R, 0
). (5)
2.2 Numerical Integration
We used an adaptive step Runge-Kutta-Fehlberg method (RKF45) in order to keep the results to a
specified accuracy with minimum computational effort. This scheme is known as an excellent general
2
The Trojan Asteroids
purpose integrator as long as the integration is not over a long period of time. It was useful here because
the characteristic time-scale of the asteroid varies along its path. At certain times, the asteriod may
decelerate and therefore would require less steps to keep below the predetermined accuracy. If there are
less steps to integrate over, the computation time is decreased.
2.3 Units
To reduce the effect of round-off errors and to get optimum accuracy in our results we used units ap-
propriate to the scale of the system i.e. quantities were scaled so that they were of order unity. The
lengths were measured in astronomical units (AU), time was measured in years (yrs)/. and masses were
measured in solar mass units (M). In these solar system units the gravitational constant is 4π2.
3 Implementation
The integrating program was implemented with c++. Output was written to a data file specified in the
code. Gnuplot was then used to interpret the data file graphically. The program itself was set up to use
a RKF45 routine which was provided by the Gnu Science Library (GSL). The GSL routine required that
the two 2nd order equations of motion (see equation 1) were reduced to four 1st order equations. The
Sun, Jupiter and the asteroid existed only in global variables and not as classes due to the small scope of
the program. All non-integer variables were stored as double precision floating point numbers. This was
to ensure that round-off errors did not interfere with the integration scheme and could therefore be safely
discounted if/when an apparent computational error was encountered. The program has the following
structure:
• The global variables are first initialized by the user within the program. These variables include
the initial position and velocity components of the asteroid, the masses of Jupiter and the Sun, the
integration parameters and the sample frequency. Command line arguments were not used because
the initial conditions of the asteroid were in terms of the L4 position and therefore were calculated
by the program. The sample frequency was typically set to one because although a higher frequency
would cut the computation time, the resolution of the orbit would decrease.
• When the program runs, the GSL RKF45 routine solves the motion of the asteroid in steps until
the maximum period of integration, tmax, is reached. The state of the asteroid i.e. its position,
velocity and Hamiltonian is printed printed at every step (if the sample frequency is 1).
• Another program was implemented which varies the mass of the planet orbiting the Sun and prints
out the time and the range of wander (a.k.a. the libration amplitude) of the asteroid. The wander is
calculated as the average of the arc distance between wanderlead and L4 and between wandertrail
and L4.1 At every step, the position of the asteroid is checked; if the asteroid is further than
1The arc distance is the length of arc between two points on the circumference of the circle centred on the barycentre
with radius L4.
3
The Trojan Asteroids
wanderlead/wandertrail then these are updated. After the integration, the value of wander is
calculated to get an accurate measure of the libration amplitude. The mass and wander are then
printed to file and the loop over planet mass continues.
See appendix C for a listing of all the relevant source code and gnuplot files.
4 Results and Discussion
4.1 Stability at L4/L5
In order to test whether any there were any computational errors propagating through the program, an
asteroid was placed at the L4 stability point and the trajectory was solved for a few hundred orbits of
Jupiter around the Sun. It is important that the system has long term stability because the Trojan
asteroids can have orbital periods about L4 that are of the order of ten times Jupiter’s orbital period. We
found that the libration amplitude is of the order of 10−12AU confirming the analytically solved Lagrange
point positions. The error can be attributed to both the integrator which is set up so that the absolute
error is maintained at 10−12 and round-off due to finite precision arithmetic at every step.
The Hamiltonian was also calculated at every integration step and printed to a data file. We found
that energy is indeed conserved with an accuracy determined by finite precision round-off error. Also, it
should be noted that the asteroid must be performing extremely small orbits about the L4 stability point
because the error in energy is three orders of magnitude less than the range of wander.
4.2 Truncation Error
Due to a non-zero step size in the integration scheme we cannot perfectly calculate the trajectory at
each step, which leads to truncation error. This can be reduced by shortening the step size but then
the number steps and therefore the computation time increases. Also, by decreasing the step size the
round-off error associated with finite precision arithmetic is increased for each step.
The adaptive step method we used kept the truncation error below a certain error threshold and
took the number of steps necessary in order to preserve this accuracy. The error threshold was chosen
to be 10−12. Error accumulation, however, persists so we checked whether this had a substantial effect
on the conserved energy. Figure 1 shows that during the integration, the energy increases linearly with
time. This confirmed our suspicion that error would accumulate but we can also see that over 10000 yrs
the energy only deviates by an order of 10−10AU2 yrs−2. As quantities were of the order unity, this
means our program was running very accurately. Figure 1 also compares the error propagation between
orbits that resulted from different initial conditions. We see that more error was propagating in the larger
amplitude orbits. This was expected because these orbits were travelling faster and therefore required
more steps in order to keep below the error threshold.
4
The Trojan Asteroids
0
1e-11
2e-11
3e-11
4e-11
5e-11
6e-11
7e-11
8e-11
0 2 4 6 8 10
En
erg
y p
er
un
it M
ass /
(A
U2)(
ye
ars
-2)
Time / 1000*years
Figure 1: The propagation of error in the conserved energy as time progresses in the asteroid’s orbit.
The further from L4 an asteroid is placed initially, the more error propagates. Black: parameters are the
same as those figure 3. Red: parameters are the same as those for figure 4. Blue: parameters are the
same as those for figure 5. Purple: parameters are the same as those for the horseshoe orbit in figure 6.
4.3 Tadpole and Horseshoe Orbits
After establishing the long term stability of our program, we set the initial position of an asteroid to
positions very close to the L4 point in order to investigate the stability. We worked in the co-rotating
centre of mass frame with the Sun positioned on the x-axis on the left and Jupiter positioned on the
x-axis on the right. The resulting motion of the asteroid is best shown in figure 2. For this plot the
asteroid was placed away from the L4 point in the radial direction from the origin and the integration
was over 300 years (enough for just over two orbits around L4).
Starting from it’s initial position the centrifugal force on the asteroid is larger than the combined
potential of the Sun and Jupiter. The asteroid therefore accelerates radially away from the centre of
mass until the coriolis force dominates (as it has a velocity now in the rotating frame) which causes the
asteroid to move in a curve back to the initial radius. As the asteroid slows down at this radius, the
centrifugal term dominates again and the motion repeats. This explains the motion along the small arcs
within the larger orbit around the stability point. The longer period motion that gives rise to the tadpole
shape is due to the asteroid’s periodic approaches to Jupiter and is known as libration.
We see from figure 2 that the asteroid is bound in a tadpole shaped region around the L4 point inside
which it librates. This implies that the position is stable at least for small distances from the L4 position.
Another plot of an asteroid starting with the same initial conditions but integrated over a longer period
of 1000 years, shown in figure 3, confirms that the orbit is stable. Note that there is a smaller tadpole
5
The Trojan Asteroids
shaped region about the L4 point where the asteroid does not cross into. In fact, we know that it will
never cross into this region because the boundary curve is a zero velocity curve [Dermott and Murray,
1999]. Motion within this region would require a complex velocity in order to conserve the Hamiltonian
(see appendix B). As the asteroid is initially at rest in figures 2 and 3, the zero velocity curve must pass
through its initial position.
3
3.5
4
4.5
5
5.5
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5
y /
AU
x / AU
Figure 2: A tadpole orbit librating about the L4 equilibrium point (denoted by the red cross). The initial
position is denoted by the blue box. Parameters for this plot are given in table 1.
0
1
2
3
4
5
6
-6 -4 -2 0 2 4 6
y /
AU
x / AU
Figure 3: This is the same orbit as in figure 2 but zoomed out to include the Sun and Jupiter (denoted
by the filled circles). All the Lagrange points are shown here except L5as red crosses. Parameters for this
plot are given in table 1.
6
The Trojan Asteroids
0
1
2
3
4
5
6
-6 -4 -2 0 2 4 6
y /
AU
x / AU
Figure 4: A tadpole orbit around L4. The larger initial radial separation caused the tadpole orbit to
librate at a higher amplitude. The parameters are given on table 1.
To investigate the stability of orbits further we increased the radial separation of the initial position
of the asteroid from L4. It was found that the angular separation between the leading and trailing edges
of the tadpole orbit and L4 increased.2 If we consider the Hamiltonian, this behaviour can be partly
explained. By increasing the radial separation we have moved the zero velocity curve to the new position.
This corresponds to decreasing the Hamiltonian of the system so that less of the potential hill around L4
is accessible by the asteroid. With a larger forbidden region around L4, the asteroid is forced to librate
at higher amplitudes. Again, this only partially explains the problem because we have not addressed the
issue of stability. In the case of figure 4, where the radial separation was 0.01×L4 the orbit was stable for
10000 yrs. Due to the equations being non-integrable, we cannot find analytical conditions for stability.
Nevertheless, we find empirically that for small radial separations (much less than 0.01×L4) the orbits
are stable. An example of an unstable orbit resulting from a radial separation that was too large is shown
in figure 5.
2The angular separation is defined here as the angle between lines that begin at the barycentre and end at the positions
of interest.
7
The Trojan Asteroids
-6
-4
-2
0
2
4
6
-6 -4 -2 0 2 4 6
y /
AU
x / AU
Figure 5: An example of instability arising from an initial radial separation that is too large. Parameters
are given on table 1.
-6
-4
-2
0
2
4
6
-6 -4 -2 0 2 4 6
y /
AU
x / AU
Figure 6: A horseshoe orbit librating about the L4 and L5 equilibrium positions. Just over one orbit is
shown here. After 550 yrs the orbit becomes unstable. Parameters for this plot are given in table 1.
By introducing an initial velocity to the asteroid, we were able to find a horseshoe shaped orbit
8
The Trojan Asteroids
shown in figure 6. This was difficult because a high radial separation was required and therefore orbits
were mostly unstable. We could not, in fact, find a horseshoe orbit that was stable after 10000 yrs. After
∼ 550 yrs, the orbit shown in figure 6 became unstable.
Figure Planet x /AU y /AU x /AU yrs−1 y /AU yrs−1 Integration
Mass / M Period / yrs
2 0.001 1.005*L4[x] 1.005*L4[y] 0 0 300
3 0.001 1.005*L4[x] 1.005*L4[y] 0 0 1000
4 0.001 1.01*L4[x] 1.01*L4[y] 0 0 1000
5 0.001 1.015*L4[x] 1.015*L4[y] 0 0 771
6 0.001 1.01*L4[x] 1.01*L4[y] -0.004*L4[x] 0.004*L4[y] 330
L4 0.001 2.59 4.5 N/A N/A N/A
Table 1: The relevant parameters and initial conditions for the figures in section 4. The Lagrange point
L4 is also shown here for the Jupiter-Sun system. The program ran for 1–2 seconds for integrations of
up to 1000 yrs.
4.4 Wander vs. Planet Mass: Initial Separation in the Azimuthal Direction
After finding initial conditions for which the asteroid’s orbit is stable over 10000 yrs we could investigate
the effect of varying the mass of the planet on the libration amplitude (see section 3 for a definition of the
amplitude). It should be noted here that if an asteroid was recognised as unstable during the integration
the range of wander was set to 20 AU . This means that the peaks in figures 7 and 8 correspond to
unstable orbits.
We considered two types of separation from L4; radial and azimuthal. Firstly, the asteroid was
initially placed at a small anti-clockwise arc separation from L4 at each planetary mass. The resulting
plot is shown in figure 7. From the plot we see that up to 0.0236 M the libration amplitude stays
constant. This is because at such small arc separations, the orbit of the asteroid will lie very close to the
zero velocity curve. For a zero velocity curve the position of maximum wander from L4 occurs on the
circle centred at the origin and passing through L4. Thus if the initial position lies on the arc, the zero
velocity curve will also pass through there and the position of maximum wander will lie there also. This
explains the constant behaviour because the initial arc separation does not change.
Surprisingly, for planetary masses around 0.025 M there is a resonance. Dermott and Murray
[1999] hint at why this is the case. At a planet mass of ∼ 0.025 M (which is approximate for small
amplitude separations) the periods of the small amplitude oscillation and the large amplitude libration
of the asteroid are in a simple numerical ratio of 1 : 2. Such relationships in celestial dynamics either
cause stability or resonance.
Another feature of the plot in figure 7 is the threshold mass at 0.0407 M. Above this planetary mass
an asteroid seemed unable to sustain a stable orbit. Theoretically, the threshold mass can be determined
if we linearise the Hamiltonian in terms of small quantities that oscillate [Cornish, n.d.]. In order for the
frequencies to be real we find that the planet mass must be lower than a threshold mass of 0.04 M. The
threshold value we found (0.0407 M) differed from this by 1.75% which is quite accurate.
9
The Trojan Asteroids
0
5
10
15
20
0 0.01 0.02 0.03 0.04
Ra
ng
e o
f W
an
de
r /
AU
Mass of Planet / Solar Masses
Figure 7: The libration amplitude plotted against the planet mass for an asteroid with an azimuthal
initial separation of (π/64)R. The integration period was 1000 yrs for each mass. There were 400 equal
steps in mass from 0.0002 M to 0.045 M. The time to compute the data for this graph was 45 s.
4.5 Wander vs. Planet Mass: Initial Separation in the Radial Direction
The second type of separation we considered was a radial separation from L4. Two additional resonances
were found around planetary masses of 0.0137 M and 0.036 M (see figure 8). Evaluating the asteroid’s
periods of oscillation shows us that these correspond to commensurabilities of 1:3 and 2:3 respectively.
Another difference with the azimuthal case was observed at low mass ratios where the libration
amplitude was not constant. Rather, as shown in figure 9, it followed the relationship,
A = a1(Mj − a2)−a3 + a4 (6)
with parameters:
a1 = 0.056± 0.001 AU Ma3
a2 = (5.96± 0.09)× 10−5 M
a3 = 0.503± 0.002
a4 = 0.226± 0.005
where A is the libration amplitude and a1, a2, a3 and a4 were found using Gnuplot’s fit function.3 We
3The fit function uses an implementation of the nonlinear least-squares (NLLS) Marquardt-Levenberg algorithm.
10
The Trojan Asteroids
can compare this with the ratio of the semi-major and semi-minor axes of the associated zero velocity
curve given by Dermott and Murray [1999]:
a
b=
1√3
(1 +
M
Mj
)− 12
. (7)
By noting that Mj << M and also that we are only interested in masses within one order of magnitude
of Jupiter’s mass we see that our derived relationship is close to the analytical result. We also see that
the zero velocity curves give a good indication of the motion for small amplitude librations about the
equilibrium point L4.
0
5
10
15
20
0 0.01 0.02 0.03 0.04
Ra
ng
e o
f W
an
de
r /
AU
Mass of Planet / Solar Masses
Figure 8: The libration amplitude plotted against the planet mass for a radial initial separation of 0.005R.
The mass loop parameters are the same as those in figure 7. The time to compute the data for this graph
was 61 s.
11
The Trojan Asteroids
0
1
2
3
4
5
6
0 0.001 0.002 0.003 0.004 0.005
Ra
ng
e o
f W
an
de
r /
AU
Mass of Planet / Solar Masses
Data0.0559(M-5.96e-05)
-0.503+0.266
Figure 9: This is the same plot as in figure 8 but zoomed in on the low planet masses. The data are
represented by the black line and the curve fitted by Gnuplot is represented by the red line.
5 Conclusions
By simplifying the two body problem to that of circular, coplanar orbits about a common centre of
mass we were able to model the motion of the Trojan asteroids about the Lagrange point L4 with little
difficulty. Asteroids that were initially placed at the stability position in the Sun-Jupiter system remained
there over a period of 10000 yrs with deviations from equilibrium of 10−12 AU . The Hamiltonian was
also conserved down to floating point error showing excellent stability in the program.
For small initial separations from L4 we saw that the asteroid librates about the stability point in
a tadpole orbit. Horseshoe orbits were also observed in which the asteroid librates about L4 and L5.
Plotting the energy against time we find that the energy is conserved very well. Truncation error does
accumulate to linearly increase the energy but after 10000 yrs the energy only rises by ∼ 10−10. For
large enough separations, the motion does not remain near the stability points and escapes to become a
satellite of the Sun.
Varying the mass of the planet for small initial separations from L4 gave rise to a number of subtle
features. Resonances were observed in both azimuthal and radial initial separations that correspond
to commensurabilities in the asteroid’s orbital frequencies. We found that 1 : 2 resonances occur for
both types of initial separation and an additional two resonances occur for the radial initial separation
(1 : 3 and 2 : 3). Another feature that appears when varying the mass is the existence of a threshold
mass. Above this mass, the asteroids cannot sustain a stable orbit about L4. The two types of initial
separation were found to have different threshold masses. For the radial separation, the threshold mass
was 0.0396 M, which differed by 1.00% from the analytic result (0.04 M). The threshold mass for an
12
The Trojan Asteroids
initial azimuthal separation was 0.0407 M, differing by 1.75%.
A relationship between the libration amplitude and the planet mass for masses within one order of
magnitude of Jupiter’s was derived. For azimuthal separations, the libration amplitude stayed constant
over this range of masses. For radial separations, the relationship was approximately:
A ∝ (Mj)− 1
2 .
This is close to the dependence of the zero velocity curve’s semi-major axis on the planet mass. Thus we
can see that for small amplitude librations about L4 the shape of the tadpole orbit is determined largely
by the shape of the zero velocity curve.
6 Further Work
Jupiter is thought to have initially formed as a small rock which grew into its current size via adiabatic
accretion [Kumar, 1972]. In our investigation on the effect of planet mass with the libration amplitude
we placed the asteroid at the same initial separation for a number of masses. To further this we could
have examined the effect of mass accretion on the migration of the Trojan asteroids. We should find a
different relationship between the range of wander and the planet mass [Fleming and Hamilton, 2000].
In addition, it would be interesting to see the effect of varying the initial separation of the asteroid on
this relationship.
A Equations of Motion in Corotating Frame
To find the equations of motion in the co-rotating frame we start with the Lagrangian:
L =m
2
∣∣∣∣d~rdt + ~ω × ~r∣∣∣∣2 − U(r).
The canonical momentum is found by using the identity:
∣∣∣∣d~rdt + ~ω × ~r∣∣∣∣2 =
(d~r
dt
)2
+ 2~ω ·(~r × d~r
dt
)+ ω2r2 − (~ω · ~r)2 (8)
which then implies that the canonical momentum is:
~p =∂L
∂(d~r/dt)
= m
(d~r
dt+ ~ω × ~r
).
13
The Trojan Asteroids
Now we use the Euler Lagrange equations,
d~p
dt− ∂L
∂~r= 0
with,
∂L
∂~r= −∇U(r)−m
(~ω × d~r
dt+ ~ω × (~ω × ~r)
)
and,
d~p
dt= m
(d2~r
dt2+d~ω
dt× ~r + ~ω × d~r
dt
)
to get the equations of motion:
md2~r
dt2= −∇U(r)−m
(d~ω
dt× ~r + 2~ω × d~r
dt+ ~ω × (~ω × ~r)
). (9)
B The Hamiltonian
The Hamiltonian is defined as:
H ≡ ~p · d~rdt− L
= m
((d~r
dt
)2
+d~r
dt· (~ω × ~r)
)− m
2
∣∣∣∣d~rdt + ~ω × ~r∣∣∣∣2 + U(r).
We then use the equation 8 to simplify H to:
H =m
2
(d~r
dt
)2
− m
2ω2r2 + (~ω · ~r)2 + U(r).
In our problem, the rotation axis is perpendicular to the plane in which the Sun and Jupiter both orbit.
We can therefore set (~ω · ~r)2 = 0 to get the conserved energy for our asteroid:
H =m
2
(d~r
dt
)2
− m
2ω2r2 + U(r). (10)
The Hamiltonian is a constant of motion. If we want to find the zero velocity curve we just set the
velocity to zero in equation 10 and solve for r and θ.
14
The Trojan Asteroids
C Source code
Listing 1: Makefile. The Makefile required to compile and link the code on the PWF.
1 # MAKEFILE FOR simple C++ programming
2
3 CFLAGS = -g -pedantic -Wall -I/ux/physics/part_2/c++ -I/usr/include/ -I/usr/include
4
5
6 LIBS = /ux/physics/part_2/c++/cavlib/cavlib.a -lgsl -lgslcblas -lfftw3
7
8 CXX = g++
9
10 .PHONY: clean
11 clean:
12 rm *.o
13
14 %: %.cc
15 $(CXX) $(CFLAGS) -o $@ $< $(LIBS)
Listing 2: trojan.cc. The source code for the program that solves the motion of an asteroid in the
CRTBP.
1 #include <stdio.h>
2 #include <iostream>
3 #include <fstream>
4 #include <cmath>
5
6 #include <gsl/gsl_errno.h>
7 #include <gsl/gsl_odeiv.h>
8 #include "cavlib/constants.hh"
9
10 struct Param
11
12 double ms;
13 double mj;
14 double xs;
15 double xj;
16 double R;
17 double omega;
18 ;
19
20 int calc_derivs (double t, const double y[], double dydt[], void *params)
21
22 Param p = *(Param*) (params);
23 double ms = p.ms;
24 double mj = p.mj;
25 double xs = p.xs;
15
The Trojan Asteroids
26 double xj = p.xj;
27 double omega = p.omega;
28
29 dydt[0] = y[2];
30 dydt[1] = y[3];
31 dydt[2] = 2*omega*y[3] + omega*omega*y[0]-(4*C::pi*C::pi)*(((ms*(y[0]-xs))/pow(sqrt((y[0]-xs)*(y
[0]-xs)+y[1]*y[1]), 3))+((mj*(y[0]-xj))/pow(sqrt((y[0]-xj)*(y[0]-xj)+y[1]*y[1]), 3)));
32
33 dydt[3] = -2*omega*y[2] + y[1]*(omega*omega-(4*C::pi*C::pi)*((ms/pow(sqrt((y[0]-xs)*(y[0]-xs)+y[1]*
y[1]), 3))+(mj/pow(sqrt((y[0]-xj)*(y[0]-xj)+y[1]*y[1]), 3))));
34
35 return GSL_SUCCESS;
36
37
38 void print_state( double t, double x, double vx, double y, double vy, double E, std::ofstream& f )
39
40 f << t << "\t" << x << "\t" << vx << "\t" << y << "\t" << vy << "\t" << E << "\n";
41
42
43 void print_posn( double x, double y, std::ofstream& f )
44
45 f << x << "\t" << y << "\n\n\n";
46
47
48 int main (void)
49
50 std::ofstream f;
51 f.precision(16);
52
53 //DATA FILE
54 f.open( "data_orbit" );
55
56 const int n_equations = 4;
57 double y[n_equations];
58
59 time_t t1, t2;
60 double dt;
61
62 Param p;
63
64 const gsl_odeiv_step_type * step_type = gsl_odeiv_step_rkf45;
65
66 gsl_odeiv_step * gsl_step = gsl_odeiv_step_alloc (step_type, n_equations);
67 gsl_odeiv_control * gsl_control = gsl_odeiv_control_y_new (1e-12, 0.0);
68 gsl_odeiv_evolve * gsl_evolve = gsl_odeiv_evolve_alloc (n_equations);
69 gsl_odeiv_system sys = calc_derivs, NULL, n_equations, &p;
70
16
The Trojan Asteroids
71 //TWO BODY PARAMETERS (AU, Mo, years, G=4*pi^2)
72 double R = 5.2;
73 double ms = 1;
74 double mj = 0.001;
75 double xs = -mj*R/(mj+ms);
76 double xj = ms*R/(mj+ms);
77 double omega = sqrt(4*C::pi*C::pi * (ms+mj) / pow( R, 3 ));
78
79 //LAGRANGE POINTS
80 double L1[2] = R*(1-cbrt(mj/(3*(ms+mj)))), 0;
81 double L2[2] = R*(1+cbrt(mj/(3*(ms+mj)))), 0;
82 double L3[2] = -R*(1+cbrt(5*mj/(12*(ms+mj)))), 0;
83 double L4[2] = (R/2)*((ms-mj)/(ms+mj)), R*(sqrt(3))/2;
84 double L5[2] = (R/2)*((ms-mj)/(ms+mj)), -R*(sqrt(3))/2;
85
86 //INITIAL CONDITIONS OF ASTEROID
87 y[0] = 1.01*L4[0]; //sqrt(L4[0]*L4[0]+L4[1]*L4[1])*cos(atan(L4[1]/L4[0]) + C::pi/8);
88 y[1] = 1.01*L4[1]; //sqrt(L4[0]*L4[0]+L4[1]*L4[1])*sin(atan(L4[1]/L4[0]) + C::pi/8);
89 y[2] = 0; //-0.004*L4[0];
90 y[3] = 0; //0.004*L4[1];
91
92 p.R = R;
93 p.ms = ms;
94 p.mj = mj;
95 p.xs = xs;
96 p.xj = xj;
97 p.omega = omega;
98
99 //INTEGRATION PARAMETERS
100 double t = 0;
101 double tmax = 10000;
102
103 //STEP SIZE AND SAMPLE FREQ.
104 double h = 1e-12;
105 int sample_every = 1;
106
107 //PRINT POSITIONS OF SUN, PLANET & LAGRANGE POINTS
108 print_posn(p.xs, 0, f );
109 print_posn(p.xj, 0, f );
110 print_posn(L1[0], L1[1], f );
111 print_posn(L2[0], L2[1], f );
112 print_posn(L3[0], L3[1], f );
113 print_posn(L4[0], L4[1], f );
114 print_posn(L5[0], L5[1], f );
115
116 //INITIALISE ENERGY
117 double E0 = -(4*C::pi*C::pi)*((ms/(sqrt(pow(y[0]-xs, 2)+pow(y[1], 2)))) + (mj/(sqrt(pow(y[0]-xj, 2)
17
The Trojan Asteroids
+pow(y[1], 2))))) - 0.5*omega*omega*(y[0]*y[0]+y[1]*y[1]) + 0.5*(y[2]*y[2]+y[3]*y[3]);
118
119 int j=0;
120
121 time (&t1);
122
123 //THE INTEGRATOR
124 while (t < tmax)
125
126 int status = gsl_odeiv_evolve_apply (gsl_evolve, gsl_control, gsl_step, &sys, &t, tmax, &h,
y);
127
128 //ENERGY EVALUATED AT EVERY STEP
129 double E = -(4*C::pi*C::pi)*((ms/(sqrt(pow(y[0]-xs, 2)+pow(y[1], 2)))) + (mj/(sqrt(pow(y
[0]-xj, 2)+pow(y[1], 2))))) - 0.5*omega*omega*(y[0]*y[0]+y[1]*y[1]) + 0.5*(y[2]*y[2]+y
[3]*y[3]);
130
131 if (status != GSL_SUCCESS)
132 break;
133
134 //STATE OF THE ASTEROID IS PRINTED
135 if (j%sample_every == 0)
136
137 print_state(t, y[0], y[1], y[2], y[3], E, f);
138
139
140 //THE PERCENTAGE COMPLETE IS PRINTED TO CONSOLE
141 if (j%(sample_every) == 0)
142
143 printf( "%f%% complete \r" , (t/tmax)*100);
144
145
146 j++;
147
148 //THESE ENSURE UNSTABLE ORBITS STOP INTEGRATION
149 if (sqrt(y[0]*y[0]+y[1]*y[1]) > 7.5)
150 break;
151
152 if (sqrt(y[0]*y[0]+y[1]*y[1]) < 2.5)
153 break;
154
155
156 time (&t2);
157 dt = difftime (t2, t1);
158 std::cout << "Run-time: " << dt << " seconds \n";
159
160 f.close();
18
The Trojan Asteroids
161
162 gsl_odeiv_evolve_free (gsl_evolve);
163 gsl_odeiv_control_free (gsl_control);
164 gsl_odeiv_step_free (gsl_step);
165
166 return 0;
167
Listing 3: orbit.gnu. The gnuplot file that plots the orbit of the asteroid.
1 set term postscript eps enhanced color "Arial" 12 solid size 8cm,6cm
2 set output ’motion.eps’
3
4 #SUN
5 set style line 5 lt 9 lw 0 pt 7 ps 4 lc rgb "black"
6
7 #PLANET
8 set style line 4 lt 12 lw 0 pt 7 ps 2 lc rgb "black"
9
10 #LAGRANGE POINTS
11 set style line 2 lt 2 lw 1 pt 2 ps 2 lc rgb "red"
12
13 #INITIAL POINT
14 set style line 3 lt 5 lw 2 pt 4 ps 1 lc rgb "blue"
15 set style line 6 lt 5 lw 2 pt 1 ps 1 lc rgb "blue"
16
17 #PARTICLE PATH
18 set style line 1 lt 1 lw 1 pt 0 ps 0.5 lc rgb "black"
19
20 set size ratio -1
21 set xlabel "x / AU"
22 set ylabel "y / AU"
23 set xrange [-6:6]
24 set yrange [-6:6]
25 set nokey
26
27 plot ’data_orbit’ index 0 u 1:2 w p ls 5 , \
28 ’data_orbit’ index 1 u 1:2 w p ls 4 , \
29 ’data_orbit’ index 7 u 2:3 w l ls 1 , \
30 ’data_orbit’ index 7 every 1::::1 u 2:3 w p ls 3 , \
31 ’data_orbit’ index 7 every 1::::1 u 2:3 w p ls 6 , \
32 ’data_orbit’ index 2 u 1:2 w p ls 2 , \
33 ’data_orbit’ index 3 u 1:2 w p ls 2 , \
34 ’data_orbit’ index 4 u 1:2 w p ls 2 , \
35 ’data_orbit’ index 5 u 1:2 w p ls 2 , \
36 ’data_orbit’ index 6 u 1:2 w p ls 2
37 # ’data_orbit’ index 7 every 10 u 2:3:(2*$4):(2*$5) w vector lt 11 lw 2
19
The Trojan Asteroids
Listing 4: evt.gnu. The gnuplot file that plots the graph of energy vs. time.
1 set term postscript eps enhanced color "Arial" 12 solid size 8cm,6cm
2 set output ’plot_evt.eps’
3
4 set xlabel ’Time / 1000*years’
5 set ylabel ’Energy per unit Mass / (AU 2)(years -2)’
6 set size ratio -1
7 set xrange [0:10]
8 set yrange [-0.5e-15:8e-11]
9 set nokey
10
11 set style line 1 lt 1 lw 1 pt 1 ps 0.5 lc rgb "black"
12 set style line 2 lt 1 lw 1 pt 1 ps 0.5 lc rgb "red"
13 set style line 3 lt 1 lw 1 pt 1 ps 0.5 lc rgb "blue"
14 set style line 4 lt 1 lw 1 pt 1 ps 0.5 lc rgb "purple"
15 set style line 5 lt 1 lw 1 pt 1 ps 0.5 lc rgb "green"
16
17
18
19 plot ’data_orbit_m0-001_p0-005_t10000’ u ($1/1000):6 w l ls 1 ,\
20 ’data_orbit_m0-001_p0-01_t10000’ u ($1/1000):6 w l ls 2 ,\
21 ’data_orbit’ u ($1/1000):6 w l ls 3 ,\
22 ’data_orbit_m0-001_p0-005_v0-008az_t10000’ u ($1/1000):6 w l ls 4
23 # ’data_orbit’ u 1:6 w l ls 3
24
25 set term wxt
Listing 5: wander.cc. The source code for the program that varies the planet mass and finds the libration
amplitude.
1 #include <stdio.h>
2 #include <iostream>
3 #include <fstream>
4 #include <cmath>
5 #include <ctime>
6 #include <gsl/gsl_errno.h>
7 #include <gsl/gsl_odeiv.h>
8 #include "cavlib/constants.hh"
9
10 struct Param
11
12 double ms;
13 double mj;
14 double xs;
15 double xj;
16 double R;
17 double omega;
20
The Trojan Asteroids
18 ;
19
20 int calc_derivs (double t, const double y[], double dydt[], void *params)
21
22 Param p = *(Param*) (params);
23 double ms = p.ms;
24 double mj = p.mj;
25 double xs = p.xs;
26 double xj = p.xj;
27 double omega = p.omega;
28
29 dydt[0] = y[2];
30 dydt[1] = y[3];
31 dydt[2] = 2*omega*y[3] + omega*omega*y[0] - (4*C::pi*C::pi)*(((ms*(y[0]-xs))/pow(sqrt((y[0]-xs)*(y
[0]-xs)+y[1]*y[1]), 3))
32 + ((mj*(y[0]-xj))/pow(sqrt((y[0]-xj)*(y[0]-
xj)+y[1]*y[1]), 3)));
33
34 dydt[3] = -2*omega*y[2] + y[1]*(omega*omega - (4*C::pi*C::pi)*((ms/pow(sqrt((y[0]-xs)*(y[0]-xs)+y
[1]*y[1]), 3))
35 + (mj/pow(sqrt((y[0]-xj)*(y[0]-xj)+y[1]*y
[1]), 3))));
36 return GSL_SUCCESS;
37
38
39
40 void print_wander( double M, double wander, std::ofstream& f )
41
42 f << M << "\t" << wander << "\n";
43
44
45
46 int main (void)
47
48 std::ofstream f;
49 f.precision(22);
50
51 //DATA FILE
52 f.open( "data_w" );
53
54 time_t t1, t2;
55 double dt;
56
57 const int n_equations = 4;
58 double y[n_equations];
59
60 Param p;
21
The Trojan Asteroids
61
62 const gsl_odeiv_step_type * step_type = gsl_odeiv_step_rkf45;
63
64 gsl_odeiv_step * gsl_step = gsl_odeiv_step_alloc (step_type, n_equations);
65 gsl_odeiv_control * gsl_control = gsl_odeiv_control_y_new (1e-12, 0.0);
66 gsl_odeiv_evolve * gsl_evolve = gsl_odeiv_evolve_alloc (n_equations);
67 gsl_odeiv_system sys = calc_derivs, NULL, n_equations, &p;
68
69 //SUN & JUPITER SYSTEM (AU, Mo, years, G=4*pi^2)
70 p.R = 5.2;
71 p.ms = 1;
72
73 //MASS LOOP PARAMETERS
74 double nsteps = 200;
75 double initialmj = 0.0002;
76 double finalmj = 0.045;
77 double step = (finalmj - initialmj) / (nsteps);
78
79 int j = 0;
80 time (&t1);
81
82 //LAGRANGE POINTS
83 double L4[2] = (p.R/2)*((p.ms-p.mj)/(p.ms+p.mj)), p.R*(sqrt(3))/2;
84
85 for ( double mj = initialmj; mj <= finalmj; mj += step )
86
87 //SUN & JUPITER SYSTEM
88 p.mj = mj;
89 p.xs = -p.mj*p.R/(p.mj+p.ms);
90 p.xj = p.ms*p.R/(p.mj+p.ms);
91 p.omega = sqrt(4*C::pi*C::pi * (p.ms+p.mj) / pow( p.R, 3 ));
92
93 //INITIAL CONDITIONS
94 y[0] = 0.5025*p.R + p.xs; //p.R*cos(C::pi/3 + C::pi/64) + p.xs;
95 y[1] = 1.005*L4[1]; //p.R*sin(C::pi/3 + C::pi/64);
96 y[2] = 0;
97 y[3] = 0;
98
99 //INTEGRATION PARAMETERS
100 double t = 0;
101 double tmax = 1000;
102 double h = 1e-12;
103
104 //CREATE WANDER VARIABLES
105 double wanderlead = acos((L4[0]*y[0]+L4[1]*y[1])/(sqrt(pow(L4[0], 2) + pow(L4[1], 2))*sqrt(
pow(y[0], 2) + pow(y[1], 2))))*sqrt(pow(L4[0], 2) + pow(L4[1], 2));
106 double wandertrail = acos((L4[0]*y[0]+L4[1]*y[1])/(sqrt(pow(L4[0], 2) + pow(L4[1], 2))*sqrt
22
The Trojan Asteroids
(pow(y[0], 2) + pow(y[1], 2))))*sqrt(pow(L4[0], 2) + pow(L4[1], 2));
107
108 //THIS IS REQUIRED BECAUSE 0 WANDER IS PRONE TO FLOATING POINT ERROR
109 if ((L4[0]*y[0]+L4[1]*y[1])/(sqrt(pow(L4[0], 2) + pow(L4[1], 2))*sqrt(pow(y[0], 2) + pow(y
[1], 2)))
110 >= 1)
111
112 wanderlead = 0;
113 wandertrail = 0;
114
115
116 //THE INTEGRATOR
117 while (t < tmax)
118
119 if (acos((L4[0]*y[0]+L4[1]*y[1])/(sqrt(pow(L4[0], 2) + pow(L4[1], 2))*sqrt(pow(y
[0], 2) + pow(y[1], 2))))*sqrt(pow(L4[0], 2) + pow(L4[1], 2)) > wandertrail &&
y[0]-L4[0]>0)
120
121 wandertrail = acos((L4[0]*y[0]+L4[1]*y[1])/(sqrt(pow(L4[0], 2) + pow(L4[1],
2))*sqrt(pow(y[0], 2) + pow(y[1], 2))))*sqrt(pow(L4[0], 2) + pow(L4
[1], 2));
122
123
124 if (acos((L4[0]*y[0]+L4[1]*y[1])/(sqrt(pow(L4[0], 2) + pow(L4[1], 2))*sqrt(pow(y
[0], 2) + pow(y[1], 2))))*sqrt(pow(L4[0], 2) + pow(L4[1], 2)) > wanderlead &&
y[0]-L4[0]<0)
125
126 wanderlead = acos((L4[0]*y[0]+L4[1]*y[1])/(sqrt(pow(L4[0], 2) + pow(L4[1],
2))*sqrt(pow(y[0], 2) + pow(y[1], 2))))*sqrt(pow(L4[0], 2) + pow(L4
[1], 2));
127
128
129 int status = gsl_odeiv_evolve_apply (gsl_evolve, gsl_control, gsl_step, &sys, &t,
tmax, &h, y);
130
131 if (status != GSL_SUCCESS)
132 break;
133
134 //THESE ENSURE UNSTABLE ORBITS STOP INTEGRATION
135 if ((wanderlead+wandertrail)/2 > C::pi*sqrt(L4[0]*L4[0]+L4[1]*L4[1]))
136
137 wanderlead = 20;
138 wandertrail = 20;
139 break;
140
141 if (sqrt(y[0]*y[0]+y[1]*y[1]) < 2.5)
142
23
The Trojan Asteroids
143 wanderlead = 20;
144 wandertrail = 20;
145 break;
146
147
148
149 j++;
150 time (&t2);
151 dt = difftime (t2, t1);
152 double i = 100.0*j/nsteps;
153 double k = (nsteps*dt/j)-dt;
154
155 //SECOND REMAINING PRINTED TO CONSOLE
156 printf( "%f%% %f seconds remaining \r" , i , k );
157
158 //PLANET MASS AND WANDER IS PRINTED
159 print_wander(mj, (wanderlead+wandertrail)/2, f);
160
161
162 std::cout << "total time " << dt << " seconds \n";
163
164 gsl_odeiv_evolve_free (gsl_evolve);
165 gsl_odeiv_control_free (gsl_control);
166 gsl_odeiv_step_free (gsl_step);
167
168 f.close();
169
170 return 0;
171
Listing 6: wander.gnu. The gnuplot file that plots the libration amplitude against the planetary mass.
1 set term postscript eps enhanced color "Arial" 12 solid size 8cm,6cm
2 set output ’plot_w.eps’
3
4 set xlabel ’Mass of Planet / Solar Masses’
5 set ylabel ’Range of Wander / AU’
6 set size ratio 1
7 set xrange [0:0.01]
8 set yrange [0:*]
9 set key
10
11
12 set style line 1 lt 1 lw 2 pt 1 ps 1 lc rgb "black"
13 set style line 2 lt 1 lw 1 pt 1 ps 1 lc rgb "red"
14 set style line 3 lt 1 lw 1 pt 1 ps 1 lc rgb "blue"
15 set style line 4 lt 1 lw 1 pt 1 ps 1 lc rgb "green"
24
The Trojan Asteroids
16
17 f(x) = a*(x+b)**c + d
18 a = 1; b = 1; c = -1; d = 1
19
20 fit f(x) ’data_w’ using 1:2 via a, b, c, d
21
22 plot ’data_w’ u 1:2 title ’Data’ w l ls 1 ,\
23 f(x) title ’0.0559(M-5.96e-05) -0.503+0.266’ w l ls 2
24
25 set term wxt
References
Lagrange, J.L. (1772). Essai sur le probleme des trois corps (Essay on the problem of three bodies),
Academie Royale des Sciences de Paris, 9.
Murray, C.D. and Dermott, S.F. (1999). Solar System Dynamics. Cambridge: Cambridge University
Press.
Nelson, E.R. (n.d.). Full Derivation of All the Lagrange Points. [online] Available at:
http://www.harker.org/uploaded/faculty/ericn/pdf/LagrangePoints.pdf. [Accessed 10
April 2011].
Cornish, N.J. (n.d.). The Lagrange Points. http://map.gsfc.nasa.gov/ContentMedia/lagrange.pdf.
[Accessed 29 Mar 2011].
Kumar, S.S. (1972). ”On the Formation of Jupiter”, Astrophysics and Space Science, 16, 52-54.
Fleming, H. J. and Hamilton, D. P. (2000). On the origin of the Trojan asteroids: Effects of Jupiters
mass accretion and radial migration. Icarus 148, 479–493.
25