Loading [MathJax]/jax/output/HTML-CSS/jax.js

Solar system simulation

Overview

In this exercise you will set-up a simulation of the solar system in Fortran and use Python to analyse the output. Solar system modelling is still an active research area, and recent examples of where it has been used are studying whether there are outer planets (planet X), or the effects of tidal forces on the 11 / 22 year Solar cycle.

You will download the files from GitHub, compile the code, set-up and run the model, and analyse the output file using Python.

Download the practical sheet here and work through it:

The above animation shows a computer simulation of the 8 planets and pluto orbiting around the sun.

Here is some theory covering the main points of what you will be doing.
Newton's Law of Gravitation

In order to simulate the orbits of the planets, we make use of Newton's Law of Gravitation and treat each body as a point mass. This enables us to calculate the force on each body in each dimension.

More info on Newton's Law of gravitation...
Newton's 2nd Law of Motion

For the motion of the planets we apply Newton's 2nd Law of motion, which states that the force applied to a mass is equal to its acceleration multiplied by its mass. Hence, Newton's Second Law of Motion enables us to use the force calculated from Newton's Law of Gravitation to the motion that the bodies take in space.

More info on Newton's 2nd Law...
Code to simulate planetary orbits

The main Fortran file is contained within the solar_system.f90 file. If interested you can take a look at this file by opening it within a text editor.

More info on solar_system.f90...

There is another file called namelist.in. This is the input file that you can edit. You will have to be careful how you edit and save the file as the program expects the input to be in a certain format.

More info on namelist.in...

The data generated lend naturally to Fourier analysis because they are periodic. We will now cover some fundamentals of Fourier analysis

Fourier series

The Fourier series is a powerful concept in the analysis of waves. Fourier methods are used in many different situations, such as in seismology, many topics in physics, spectroscopy and acoustics.

Harmonic waves are those that are described by trigonometric functions: sines and cosines. We know how to deal with these functions mathematically, but other functions such as square waves, or saw-tooth waves (so called aharmonic functions) are more problematic. However, it turns out that we can build up any periodic function by adding lots of sines and cosine functions together.

Lets say for example we have a periodic wave that looks like a saw-tooth pattern. The animation below shows that starting with a sine wave of the same period and adding sine waves of higher frequencies (and lower amplitudes) we may eventually build up something similar to a saw-tooth wave.

Another example is given here, this time a saw-tooth wave is represented by the first 5 harmonic functions (source: Wikipedia).

Similarly see the representation of a square wave below. We can build up a square wave by adding sine functions of different amplitudes together.

The above animation shows the approximation of a square wave by the sum of 6 harmonic functions (source: Wikipedia).

Advanced info...
Fourier Transform

The a_n and b_n coefficients in the Fourier series tell us the frequencies of harmonic oscillations that are present in a time-series; however, the frequencies are integer multiples of the frequency of the original wave. In general we need a representation that can have a continuum of frequency values. This is called the Fourier Transform.

Python has functions that enable us to do these Fourier Transforms easily.

Information on what the Fourier Transform is...
Initialisation data for the solar system (for fun - if you like to hack around)

If you would like to initialize the model with different data the positions and velocities (Ephemeris data) of the planets at different times can be retrieved by email from the JPL Horizons system . Click on the link to send an email, you will need to do it for each planet in turn.

Click here to see the contents of the email you send to JPL...

When you send the email, click on the tab below to see the reply you will get from the JPL Horizons system.

Click here to see the reply email...

Note that the file namelist.in above already has the 3d position and velocity data for all the planets. You may want to use initialisation data for a different date, in which case generate the Ephemeris data for all planets (as described above) and put the numbers \left(X,Y,Z, VX,VY,VZ\right), in the namelist.in file. The first element of each array is the Sun, the second Mercury, then Venus and so on.