A python code to calculate planetary orbits in a three-body gravitational system. The code can demonstrate how one planet affects the orbit of another planet. As an example, Earth, Jupiter, Sun system is analyzed.
The code is available in Jupyter notebook (or IPython notebook) format and python script format (suitable for running with spyder).
The code uses matplotlib to create the orbital motion animation. The package ffmpeg is required to run the animation. It can be installed using the Anaconda terminal:
conda install -c menpo ffmpeg
The video is embedded in the Jupyter notebook using html5. The vidoe can also exported as mp4.
The effect of Jupiter on Earth's orbit can be visualized using the Earth-Jupiter-Sun system notebook. The mass of Jupiter was taken to be 500 times its original mass. The effect on Earth's orbit due to the presence of this "Super Jupiter" can be easily noticed from the orbital animation.
Earth-Jupiter-Sun system.