1. N-Body Simulation of Celestial Mechanics
Aaron Gruberg
July 31, 2014
Abstract
Newton’s second law was used to create a computational model for the motion of celestial bodies.
The equations of motion for a collection of point masses were used to calculate the gravitational force
on one point mass due to an additional point mass. The equations of motion for a collection of point
masses are:
mj
d2
r(t)j
dt2
=
i=j
Gmimj
| ri − rj |3 (ri − rj). (1)
Mass was measured in units of solar masses. Distance was measured in AUs. Time was measured in
1/2π years. Velocity was measured in 29.87km/s. This unit system allowed for G = 1. Initial conditions
for the position and velocity of all masses in Solar System Barycentric coordinates were taken from the
NASA Ephemeris. A system containing only the Sun and Mars was considered first. The equations of
motion were integrated using a 2nd-order leap frog method. The total energy of the Sun Mars system
was conserved. The energy oscillated sinusoidally. The angular momentum was conserved. Using initial
conditions from the NASA Ephemeris which were taken on November 1, 1988, the orbits of the remaining
planets were added to the system. An alternate set of initial conditions was used to model a binary star
system. Initial conditions from the Institute of Physics Belgrade were used to model a three-body system.
1
2. Figure 1: This is a plot of the change in energy over time of a system containing the Sun and Mars for varied
time step sizes. Every tenth data point was plotted to better show how the precision of the energy calculation
improved for varied time step sizes. Energy was conserved for all time step sizes. This means that for one
period, the initial energy was equal to the final energy. The total energy is constant. As the kinetic energy
increased, the potential energy decreased. The Sun Mars system was created by using a second order leap
frog method to integrate the differential equations of motion. Leap frog is a symplectic method and helps
to conserve the energy of a dynamic system.
Figure 2: This is a plot of the change in angular momentum over time of a Sun Mars system for varied time
step sizes. When time steps of seventy hours and forty-eight hours were used, angular momentum appeared
to be conserved. When a time step of twenty hours was used, the amplitude of angular momentum increased.
This increase in the positive and negative peaks of angular momentum was most visible when a time step
of three hours was used. It should be noted that the total angular momentum for the system was on the
order of 10−7
. The calculations for angular momentum were small because the units used were very large.
The change in amplitude angular momentum seems large in the plot using a three hour time step. This plot
shows that angular momentum was not perfectly conserved however, changes that occured were nearly zero.
2
3. Figure 3: This is the complete Solar System in the xy-plane integrated using intitial conditions from Novem-
ber 1, 1988 to May 2, 2014 for total time of 25.5 years. My final position for Mars was x = -0.2899, y =
-1.4387, z = -0.0229. In the Ephemeris, the final position of Mars was x = -1.3898, y = -0.7903, z = 0.017.
My final position for the Sun was x = 0.0020, y = -0.0015, -0.000069. In the Ephemeris, the final position
of the Sun was x = 0.00168, y = -0.00192, z = -0.000109. My final position for the Earth was x = 0.5619, y
= -0.8407, z = -0.000064. In the Ephemeris, the final position of the Earth was x = -0.7550, y = -0.667, z
= -0.00008356. This model of the Solar System made the assumption that the Sun and planets were alone
in a vaccuum. The Ephemeris accounts for other bodies that are nearby. This contributed to the error in
calculated position when it was compared to the Ephemeris.
Figure 4: This is the Solar System in the yz-plane.
3
4. Figure 5: This is a planet orbiting a binary star.
Figure 6: This is a planet with high initial velocity that is flung out of orbit.
4
5. Figure 7: This is a three body system with a figure eight trajectory. Initial conditions were taken from the
Institute of Physics Belgrade.
5