Carroll - Ostlie 02.15

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

HALLEY’S COMET: NUMERICAL CALCULATION OF ORBIT

Link to: physicspages home page.


To leave a comment or report an error, please use the auxiliary blog.
Reference: Carroll, Bradley W. & Ostlie, Dale A. (2007), An Introduc-
tion to Modern Astrophysics, 2nd Edition; Pearson Education - Chapter 2,
Problem 2.15.
Post date: 25 Apr 2015.
We can use Kepler’s laws to generate numerical solutions for orbits on
a computer. Carroll & Ostlie provide a program called Orbit (in Fortran
or C++) that produces textual output that can be input to a spreadsheet or
graphing program. However, this is a bit primitive, so I decided to imple-
ment a similar routine in Maple, since Maple has built-in plotting features.
The idea is to simulate a complete orbit of a planet by calculating its
distance r from the focus of the ellipse (essentially, the distance from the
Sun) as a function of the angle θ from perihelion. The equation of an ellipse
is:

a 1 − e2

r= (1)
1 + e cos θ
Given the planet’s period P we can calculate its semimajor axis a from
Kepler’s third law:

4π 2 3
P2 = a (2)
GM
so the equation 1 becomes
1/3
1 − e2

GM P 2

r= (3)
4π 2 1 + e cos θ
To use this formula in a numerical solution, we need to know how much
θ changes for a given time increment dt. We can use Kepler’s second law
in the form

dA L
= (4)
dt 2µ
which gives the rate at which area is swept out in terms of the constant total
angular momentum L and reduced mass µ. The angular momentum is
1
HALLEY’S COMET: NUMERICAL CALCULATION OF ORBIT 2

q
L = µ GM a (1 − e2 ) (5)
The area increment dA is given in terms of dθ by

r dθ 2 1 2
dA = πr = r dθ (6)
2πr 2

so we get
p
L GM a (1 − e2 )
dθ = 2 dt = (7)
µr r2
The numerical solution divides the period P up into n equal time intervals
dt, and starts with r at perihelion and θ = 0. We then use the value of r to
calculate dθ, add this to the current value of θ and calculate the next value
of r from 3. We then use the new value of r to get the next dθ and so on
until we’ve covered a complete period.
The Maple code for doing this is:
[code language=java]
with(plots):
G := 0.6673e-10;
AU := 0.14959787066e12;
M__sun := 0.19891e31;
yr := 31558145.0;
rad2deg := 180/Pi;
secsYear := 365.25*(3600*24);
orbit := proc (M__strsun, a__AU, e, n)
local M__star, a, P, dt, t, theta, LoM, r, i, dtheta;
M__star := M__strsun*M__sun;
a := a__AU*AU;
P := sqrt(4*Pi^2*a^3/(G*M__star));
dt := P/(n-1);
t := Array(0 .. n, (i) -> i*dt);
r := Array(0 .. n, datatype = float);
theta := Array(0 .. n, datatype = float);
theta[0] := 0.;
LoM := sqrt(G*M__star*a*(1-e^2));
for i from 0 to n-1 do
r[i] := a*(1-e^2)/(1+e*cos(theta[i]));
dtheta := LoM*dt/r[i]^2;
theta[i+1] := evalf(theta[i]+dtheta);
if 0 < i and 1.0 < r[i]/AU and r[i-1]/AU < 1.0 then
HALLEY’S COMET: NUMERICAL CALCULATION OF ORBIT 3

print("Passes 1 AU at t = ", evalf(t[i]/secsYear))


end if
end do;
r[n] := a*(1-e^2)/(1+e*cos(theta[n]));
theta := theta*rad2deg;
r := r/AU;
print(polarplot(r, theta, angularunit = degrees));
print(plot(t/secsYear, r, labels = ["t (years)", "r (AU)"]))
end proc;
[/code]

The code pretty much just implements the algorithm given above. The
Maple procedure orbit on line 8 takes as its arguments the mass of the
central star in solar masses, the semimajor axis of the planet in AU, the
eccentricity e and the number of time steps n. It then converts these quan-
tities into SI units using the conversion factors given at the start, creates
arrays for the time t, the radius r and the angle θ, calculates L/µ (as LoM),
and then enters a for loop to calculate r and dθ for each time increment.
The ’if’ statement finds the time at which the planet crosses from r < 1 AU
to r > 1 AU and prints this out.
After the loop, we calculate the final value of r, convert θ and r to degrees
and AU, respectively, and print out a couple of plots. The first plot is a polar
plot of r as a function of θ, so it shows the elliptical orbit. The second plot
graphs r as a function of t (the latter in years) for one complete period.
For Halley’s comet, P = 76 years and e = 0.9673 from which we find
a = 17.943 AU. If we input these values (along with M__strsun = 1 since
the central star is the Sun), and choose n = 10000 time increments, we
get the time at which the comet first crosses r = 1 AU after perihelion as
t = 0.1064 years or around 39 days. The plots are as follows:
HALLEY’S COMET: NUMERICAL CALCULATION OF ORBIT 4
HALLEY’S COMET: NUMERICAL CALCULATION OF ORBIT 5

P INGBACKS
Pingback: Halley’s comet: an application of Kepler’s laws
Pingback: Elliptical orbits: numerical simulation
Pingback: Oppositions of Mars: numerical calculation

You might also like