Sie sind auf Seite 1von 18

Limitations of an Euler method n-body simulation and

Shape of Sun-Earth orbits


Abstract:
A combination of the forward and backward Euler methods is used to model the
Sun-Earth and Sun-Jupiter-Earth systems as point masses in two dimensions. The
patterns in the orbital path of the Earth around the Sun are found and their cause is
hypothesised more specifically in the axes and centre location of the elliptical
orbit. The accuracy of the simulation is analysed in terms of its ability to reproduce
known behaviour the real orbit of the Earth and energy conservation. The cause of
oscillations in energy is postulated to be the desynchronization in the velocity and
position of the Earth due to the use of both the forward and backward Euler method.
Limitations in the implementation of the program are found and suggestions for
improvement are made.

Introduction
Gravitational interaction between massive objects/bodies such as stars and planets
is described by Newtons law of gravity; and paths taken by these objects resulting
from such gravitational interaction can be described by Newtons second law and
kinematics.

G M1 M2

F12= r 12 , where
F12
Newtons law of gravity is r 312 is the force of object 2

on object 1,
r 12
is the vector pointing from object 1 to object 2, (
r 12 =
r 12 ,) M1
and M2 are the masses of objects 1 and 2 respectively, and G = universal

gravitation constant = 6.67 1011 Nm2kg-2.

d v d r
The equations of motion are acceleration
a = v =
dt , velocity dt , where

r = position.

Given initial position and velocity conditions for all bodies, an analytic solution for
the paths of the bodies cannot be found in most cases. A numerical method that
can be used for solving such initial value problems is the Euler method, which is a
first-order technique. There are two types of Euler method, backward (implicit) and
forward (explicit). For example, in propagating the position of a body at time t n to its
position at time tn+1, the forward Euler method would use r (t ) = r (t ) + t
n+1 n
v (tn) (where t is some small time step), whereas the backward Euler method

would use r (tn+1) = r (tn) + t v (tn+1).

The problem being solved here carries simplifying assumptions on the


corresponding real system. Firstly, only the gravitational force is considered,
whereas in reality the orbital path is potentially additionally influenced by resistance
from an atmosphere. Secondly, bodies are treated as point masses, an assumption
that will be discussed later.

Since only the gravitational force is considered, there will be two types of energy
present in the n-body system kinetic and gravitational potential. The gravitational
G M 1 M 2
potential energy between body 1 and body 2 can be given by r 12 (by

assuming the gravitational potential energy is 0 when the bodies are infinite
distance apart), where M1 and M2 are the masses of bodies 1 and 2 respectively, and

r12 is the radius between the bodies. There are (n2 ) (n choose 2) gravitational

interactions in an n-body system, thus the total energy can be given by


n n j
G Mi M j
12 mi v 2i r ij , where each body is given an index from 1 to n.
i=1 j=1 i=1

Method
This program models a system in two dimensions on the x-y plane, where forces
only occur in the plane. The calculations could easily be extended for three or more
dimensions, however visualisation of such data would be difficult. The systems
analysed are part of the solar system, and thus can be approximated in a two-
dimensional model without much simplification. The program could also model as
many bodies as needed, though only two and three body systems are analysed
here.

The essential feature of the program is a loop that iterates through time, executing
once each t time step. Given the positions of all the bodies at the previous time
step, it will calculate for each body the x and y component of the net gravitational
force exerted on it (due to the other bodies) and therefore its acceleration. The
velocities of the bodies are then updated using the forward Euler method: v (tn+1)

= r (tn) + t a (tn), and the positions of the bodies are updated using the
backward Euler method: r (tn+1) = r (tn) + t v (tn+1), since v (tn+1) has just

been calculated. The initial conditions required for this program are thus the initial
positions and velocities of all bodies. A fixed time step was used (rather than an
adaptive one).

The output of the program is a static graph with vertical y-axis and horizontal x-axis,
showing all the positions the bodies took. Consecutive positions were joined linearly.

This was implemented using Python language, and was interpreted using iPython.
Graphs were generated using the mathplotlib.pyplot library.

SI units were not used:


1 mass unit (mu) = 1 solar mass = 2 1030 kg

1 length unit = 1 Astronomical Unit (AU) = 1.496 1011 m

1 time unit = 1 day

Thus the universal gravitation constant was calculated in these units to be


11 30 2
6.6708 10 2 10 86400
G= 11 3 = 3.01214 10-4 AU3mu-1days-2
(1.496 10 )

These units were used to minimise round-off error to ensure the numbers appearing
in the program were not too small. It is a random error.

Results and Analysis


Restrictions on minimum distance between bodies

The Shell Theorem says that the gravitational field generated by a uniform
spherically-symmetric body is equivalent to that generated by a point mass at the
centre of the sphere. Also, the gravitational force experienced by an extended mass
can only be approximated by the force experienced by a point mass located at its
centre of mass; the accuracy of this approximation requires the spherical symmetry
of the body and the size of the body be at least an order of magnitude smaller than
the distance between the bodies exerting and experiencing the force.

Thus, the bodies modelled need to have approximately uniform density and
spherical symmetry in order to produce realistic results. This is satisfied for large
objects such as the Sun, Earth and Jupiter, however not so for smaller ones that
may take non-spherically-symmetric shapes (e.g. comet).
The bodies also need to be far apart for an additional reason: Newtonian gravity is
an inadequate description for the behaviour of bodies when strong gravitational
force is involved this could be due to either the proximity of bodies or their large
mass. (Newtonian gravity is also inaccurate when bodies are moving very fast, or
the gravitational field is changing quickly, however these concerns are less relevant
here.) The largest body in these simulations is the Sun, which has a diameter of
approximately 0.01 AU; thus any simulation subsequent to bodies passing within
0.1AU of the Sun should be considered inaccurate. This is a liberal constraint as
Newtonian gravity fails to model aspects of Mercurys orbit with an average radius
of 0.4AU.

Reproducing known behaviour

A preliminary measure of the accuracy of the simulation is whether the generated


path shape of the bodies for a given set of initial conditions agree with the shape
determined by experiment. This can be done by using initial conditions
corresponding to the real orbit of Earth. The Earth moves around the Sun in an
approximately circular orbit of radius 1AU and period 365.25 days, and thus has an
2
average speed of 365.25 AU day-1. Placing the Sun at the origin with no initial

speed, it was found that giving the Earth an initial position on the circle of radius
2
1AU around the Sun with 365.25 AU day-1 speed perpendicular to the direction of

the Sun, caused the Earth to indeed traverse a circular path around the Sun. This
occurred for both clockwise and anti-clockwise traversal. (See Appendix 1)

However, in a frame where the Earth has a circular orbit around the Sun at the
origin, it is not physically possible for the Sun to remain perfectly stationary as the
moving Earth will exert a gravitational force on it. Indeed, the simulations show an
initially stationary Sun moves in the direction of the initial velocity of Earth with
small circular motions. This effect is amplified in a two-body simulation with the Sun
and Jupiter. The exact mechanism for this behaviour is unclear, however
heuristically, it appears that the gravitational force of the planet pulls the Sun in the
direction that it initially travels (with a larger gravitational force resulting from a
larger mass pulling the Sun in that direction faster.)
The familiar behaviour of two bodies rotating around the barycentre of the system
can also be reproduced. (See Appendix 2)

Thus, the simulation produces behaviour that is physically plausible and consistent
with experiment.

Shape of Sun-Earth orbits


On these grounds, the shape of the orbit of a smaller body around a significantly
larger one can be examined using the Sun-Earth system. Using simulations for this
purpose has advantage over using analytic methods (i.e. Lagrangian and Effective
Potential) as the following additional details can be discovered (as well as not
requiring the stationary Sun assumption).

Since the speed acquired by an initially stationary Sun is small enough that the
overall shape of the Earths orbit is unaffected, the Sun was set to be stationary at
the origin in the following analysis for simplicity. Furthermore, since the system
consists of two bodies, one of which is always initially located at the origin, it is
rotationally symmetric the path diagram produced for some initial position and
velocity conditions on the Earth that are rotated by x around the origin with
respect to some unrotated initial conditions will be the path diagram produced by
the unrotated initial conditions, rotated by x. (e.g. ) Thus it suffices to analyse the
system with the Earths initial position always at (1,0)AU.

The path diagrams in Appendix 3 show that when the Earth is given an initial
velocity perpendicular to the direction of the Sun (i.e. in the y direction), the semi-
major axis of the orbit is always along the x axis (and thus semi-minor parallel to
the y axis), regardless of the initial speed. If the initial speed (v i) is greater than the
critical speed for a circular orbit (vc), then the centre of the ellipse is to the left of
the origin, and if the vi < vc, the centre of the ellipse is to the right of the origin. A
heuristic explanation for this is that a high initial speed allows the Earth to travel
further away from the Sun before returning(, meaning the section of orbit path away
from the Earth is longer). Similarly, a low initial speed means the Earth cannot
travel as far from the Sun.

When the Earth is given an initial velocity with a non-zero x-component, the semi-
major axis of the orbit is no longer the x axis. What causes the direction of the semi-
major/minor axis is unclear and further investigation is required. (These preliminary
results show that for a given non-zero x-velocity-component, as the velocity-y-
component increases, the slope of the semi-major axis in the x-y plane decreases
and eventually becomes negative.)

Energy Conservation

Since we do not enforce energy conservation in the generation of the orbit path, the
extent to which our paths obey conservation of energy is a measure of the accuracy
of the program. The total energy of the modelled system can be calculated and
plotted with time. Periodic oscillations were found in all simulations, suggesting they
had a non-random cause. For circular orbits, those fluctuations in three-body Sun-
Jupiter-Earth systems were one order magnitude larger (10 -14) than those in the two-
body Sun-Earth system (10-15) (see Appendix 4). The cause of the energy oscillations
in the Sun-Earth system will be discussed here, with expected generalisation to
other systems. (The dependence of energy fluctuations on mass of the bodies in the
system, and whether there exists an upper limit on the fluctuations is a source of
further investigation.)

It was found that the period of the energy oscillations was approximately equal to
the period of Earths orbit. There were both peaks and dips in energy, with one peak
and dip per period, and magnitude of the peaks and dips were the same. If the
initial velocity of the Earth was perpendicular to the direction of the Sun, the energy
started at its average value. (Note that the following conclusions were drawn from
simulations with Earths initial position at (1,0)AU, however this can be generalised
to other cases using rotational symmetry as argued previously.) Furthermore, if v i >
vc, the energy dip occurs first, and if v i < vc, the energy peak occurs first.

This is consistent with the interpretation that an energy peak occurs when the Earth
approaches the Sun, and a dip occurs when the Earth leaves the Sun: If vi > vc, it
was found that the centre of the elliptical orbit path was to the left of origin, and
thus as the Earth moves anticlockwise (or indeed clockwise) around the ellipse from
the point (1,0)AU, its point of closest approach, it will move away from the Sun.
Whereas if if vi < vc and the centre of the ellipse is to the right of origin, the Earth
will approach the Sun as it leaves its initial position at (1,0)AU.

It is claimed that this is due to the nature of the backward Euler method creating
desynchronization between Earths velocity and radius. As stated, the positions of
bodies are updated as r (t ) = r (t ) + t v (t ), whereas the velocities of
n+1 n n+1

bodies are updated as v (t ) = r (t ) + t a (t ). This means that the


n+1 n n

velocity of Earth is always slightly ahead of where it should be based on its location
in orbit. This might cause the gravitational potential energy to decrease before the
kinetic energy increases when the Earth leaves the Sun, resulting in an energy dip.

This explanation is consistent with the observation that for a given set of initial
conditions, the energy oscillations decrease in magnitude if t is decreased the
velocity and position of the Earth are more synchronised. (See Appendix 5)
It was found that non-circular orbits could produce energy fluctuations orders of
magnitude larger than those found in circular ones (10 -10). It is postulated that this is
due to the larger variation of kinetic and gravitational potential energy around the
orbit; the fluctuations still arise from the same desynchronization mechanism.

If the positions were instead updated using the forward Euler method, energy peaks
and troughs are not observed; there is an energy kick each time the Earth swings
past the Sun that is entirely unphysical. This is accompanied by an unstable orbit of
increasing radius. This potential for instability in implicit numerical methods such as
the forward Euler method make it unsatisfactory for modelling paths of bodies.
It may be supposed that energy fluctuations are due to inaccurate modelling of the
paths of the bodies (such that the correct path would produce a constant energy).
This can be used to estimate the discrepancy between our path and the correct
one. (Of course inaccurate body velocity may also be to blame, however since the
purpose of the simulation is to generate paths of bodies, we should conservatively
attribute all error in energy to error in path.) Also observe that energy is a function
of the distance between bodies, so we are unable to determine the correct path
using energy error alone.
An order-of-magnitude calculation shows that for Earths circular orbit,
G M1M2 G M1 M2
dE d
=
dr dr (
Kinetic Energy
r
= )
r2

r2 E 12 AU 2 4 1015 mu AU 2 day2
r= = 4 106 AU
G M 1 M 2 3 104 mu1 AU 3 day2 1 mu 3 106 mu

where r is taken to be the average radius of Earth from the Sun, 1AU. This scale of
discrepancy is negligible on the path diagrams generated, even for energy errors up
to 5 orders of magnitude larger.

The fluctuations in total energy do not grow noticeably, even up to 300,000 days,
which suggests that the resulting error in path is not cumulative. Thus it appears
safe to conclude that using the backward Euler method, inaccuracy of the program
revealed by energy non-conservation is negligible for the purposes of path
visualisation.

Note that this error should occur additionally to round-off error, since the
desynchronization of Earths velocity and radius acts equally on any velocity or
radius.

Another measure of the programs accuracy is its modelled stability of an orbit


known to be stable e.g. the Earths circular orbit around the Sun in a two-body
system. However, the stability of the orbit is difficult to determine precisely since
the movement of the Sun causes the orbit of the Earth to also move a simple
measure of the width of the paths traced out by successive orbits will not suffice.
The use of Galilean relativity to jump into the frame of the Sun may work (since the
Suns speed is low); this is matter for future investigation.

Limitations of program

The program fails to model the collision scenario, as well as behaviour when bodies
are in close proximity. Collisions cannot be modelled as the program treats the
bodies as point masses (and point particles cannot collide). This could be rectified
by assigning each point mass a radial size and joining two bodies together if their
distance apart is less than their joint radial size. This method can only be
dependable if the forces on the bodies are not so strong that the collision would
take place between time steps, and the bodies would only be modelled to jump
across each other on successive time steps this would require adaptive step size
(decreasing as the velocities of the bodies increase) to ensure. When initial
conditions should result in a collision, the current program would model unexpected
behaviour such as sudden change of direction. It is advisable to set an alert
triggered when the distance between any pair of objects drops below some
minimum, whereby the bodies can be assumed to have collided, and any
subsequent data must be discarded.

The inability of the program to model behaviour of bodies in close proximity is a


consequence of the same phenomenon if the bodies are so close that the strong
forces lead to a very high velocity, successive positions will be so far apart that
visible straight lines (joining the positions together) appear in the path diagram.
This can be similarly avoided using adaptive step size.

This program has an approximate computational complexity of n 2, where n=number


of bodies, since the force between all n bodies needs to be calculated. Thus
computational time will very quickly become restrictive for large n, however this
problem appears to be universal across n-body simulations. The simplicity of this
program even gives it an advantage over other methods such as Runge-Kutta 4,
which would require more computational time.

Conclusion
The shape of two-body orbits where one body was approximately stationary was
analysed using the Sun-Earth system, with the Earths initial position at (1,0)AU. It
was found that when the initial velocity of the Earth was perpendicular to the
direction of the Sun (i.e. the velocity was in the y direction), the elliptical orbit of the
Earth had semi-major axis along the x axis, whereas if the initial velocity had some
non-zero x component, the semi-major axis was tilted with respect to that direction.
Given that Earths initial velocity was in the y direction, if v i < vc, the centre of the
ellipse was to the right of the origin, and if v i > vc, the centre of the ellipse was to
the right of origin. These results hold under rotation of the co-ordinate system.

It was found that the program could reproduce the real Sun-Earth orbit. The
accuracy of the simulation was discussed with respect to energy conservation. It
was hypothesised that the shape of the energy graph was due to the effect of the
Euler method desynchronising the velocity and position of the bodies. It was found
that the error in the path diagram as revealed by energy non-conservation could be
deemed negligible. Other limitations of the program its simplifying assumptions,
inability to model collisions, and computational complexity were also briefly
discussed. The simulation can produce reasonable visualisations of the paths of
bodies when they are not in close proximity for t=0.01.

References
En.wikipedia.org. (2016). Newtonian limit. [online] Available at:
https://en.wikipedia.org/wiki/Newtonian_limit [Accessed 21 Oct. 2016].

En.wikipedia.org. (2016) Perturbation (astronomy). [online] Available at:


https://en.wikipedia.org/wiki/Perturbation_(astronomy) [Accessed 21 Oct. 2016].

En.wikipedia.org. (2016) Shell theorem. [online] Available at:


https://en.wikipedia.org/wiki/Shell_theorem [Accessed 21 Oct. 2016].

Zeltkevic, M. (1998). Forward and Backward Euler Methods. [online] Web.mit.edu.


Available at:
http://web.mit.edu/10.001/Web/Course_Notes/Differential_Equations_Notes/node3.ht
ml [Accessed 21 Oct. 2016].
Appendix 1:

2
Figure 1: Earth has initial position (1,0)AU, initial velocity (0, 365.25 ) AU day-1.

Sun has initial position (0,0)AU and initial velocity (0,0)AU day -1. t=0.01

Appendix 2:
Figure 2: Movement of Sun. Earth has initial position (1,0)AU, initial velocity (0,
2
365.25 )AU day-1. Sun has initial position (0,0)AU and initial velocity (0,0)AU day -1.

t=0.01

Figure 3: Barycentric orbit. Earth has initial position (1,0)AU, initial velocity (0,
2
365.25 )AU day-1. Sun has initial position (0,0)AU and initial velocity (0,-5 *10 -8)AU

day-1. t=0.01
Appendix 3:

Figure 4: Earth has initial position (1,0)AU, initial velocity (0, 0.02 )AU day-1. Sun
has initial position (0,0)AU and initial velocity (0,0)AU day -1. t=0.01
Figure 5: Earth has initial position (1,0)AU, initial velocity (0, 0.01 )AU day-1. Sun
has initial position (0,0)AU and initial velocity (0,0)AU day -1. t=0.01
Figure 6: Earth has initial position (1,0)AU, initial velocity (0.012, 0.012 )AU day-1.
Sun has initial position (0,0)AU and initial velocity (0,0)AU day -1. t=0.01

Appendix 4:

Figure 7: Earth has initial position (1,0)AU, initial velocity (0, 0.02 )AU day-1. Sun
has initial position (0,0)AU and initial velocity (0,0)AU day -1. t=0.01

The scale for the Total energy vs time graph is read as follows: If the y coordinate
of the graph is y, then it corresponds to energy y * 10 -14 3.0362 * 10-10.
2
Figure 8: Earth has initial position (1,0)AU, initial velocity (0, 365.25 ) AU day-1.

5.25
Jupiter has initial position (5.2,0)AU, initial velocity (0, 365.2512 ). Sun has initial

position (0,0)AU and initial velocity (0,0)AU day -1. t=0.01


Appendix 5:

Figure 9: Earth has initial position (1,0)AU, initial velocity (0, 0.02 )AU day-1. Sun
has initial position (0,0)AU and initial velocity (0,0)AU day -1. t=0.005
Figure 10: Velocity calculated using forward Euler method. Earth has initial position
(1,0)AU, initial velocity (0, 0.02 )AU day-1. Sun has initial position (0,0)AU and
initial velocity (0,0)AU day-1. t=0.01
Figure 11: Velocity calculated using forward Euler method. Earth has initial position
(1,0)AU, initial velocity (0, 0.02 )AU day-1. Sun has initial position (0,0)AU and
initial velocity (0,0)AU day-1. t=0.01

Das könnte Ihnen auch gefallen