In this exercise you will set-up a simulation of the solar system in MATLAB and use Fourier Methods to analyse the output. If you are interested in making this part of your project please get in touch with me. For example you may be interested in researching the effects of tidal forces on the sun or the dynamics of binary star systems or the effects of black holes on solar systems.
The following files can be downloaded and put into your working directory in MATLAB:
Download the practical sheet here and work through it:
The above animation shows a computer simulation in MATLAB of the 8 planets and pluto orbiting around the sun.
In order to simulate the orbits of the planets, we make use of Newton's Law of Gravitation and treat each body as point masses. This enables us to calculate the force on each body in each dimension.
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.
Take a look at the solve_solar_system.m
file, taking care to read the comments and follow roughly what the code does.
There is another m-file called animate_solar_system.m
. After running solve_solar_system.m
you can then run this m-file to see an animation of the solar system.
The data generated lend naturally to Fourier analysis because they are periodic. We will now cover some fundamentals of Fourier analysis
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).
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.
MATLAB has functions fft
and ifft
that enable us to do these Fourier Transforms.
fft
- Fast Fourier Transform ifft
- inverse Fast Fourier Transform 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.
When you send the email, click on the tab below to see the reply you will get from the JPL Horizons system.
Note that the MATLAB file solve_solar_system.m
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 solve_solar_system.m
file (lines 101 to 119). The first element of each array is the Sun, the second Mercury, then Venus and so on.