Mathematical Modeling For Planetary Motion Using Python's PyGame Module, Matplotlib and Linux Shell Scripting
Mathematical Modeling For Planetary Motion Using Python's PyGame Module, Matplotlib and Linux Shell Scripting
ISSN No:-2456-2165
Abstract:- In this research paper a model of the solar However, it is not practical to determine the movements
system for computing the orbits of all 8 planets true to its of the majority of planets in the cosmos through analytical
astronomical value and scale using python programming computation or direct observation. Observation through
language is developed. The motion is visualised using telescopes necessitates precise and expensive equipment as
Pygame and Matplotlib library. Iteration is utilized to well as long periods of observation, and the complexity of the
depict and update the position of the planets during the realistic system means that this problem has no analytical
process, and also develop a model to generate the date, solutions. With the advancement of computational power
time, and place of all solar and lunar eclipses from 2001 over the last few decades, an increasing number of physicists
to 2100 by importing python modules related to have begun to use computational tools to solve equations,
astronomy. The model's validity and accuracy are perform integrals, invert matrices, simulate various physical
demonstrated by the study and application of Kepler’s processes, and so on. This research paper describes how to
Laws Of Planetary Motion throughout the procedure and simulate the motion of the Sun and eight planets using a
modelling. computational method. In addition it also explains how to
generate the date, time, and place of all solar and lunar
Keywords:- Planetary Motion, Mathematical Modeling, eclipses from 2001 to 2100 using Python.
Python Modules for Astronomy, Modelling of The Solar &
Lunar Eclipses, Simulation of the Solar System, 3D plot for II. PROBLEM STATEMENT
the projectile on a planet, Solar and Lunar eclipses from 2001
to 2100. During my research at IIT Bombay, NCAIR I realized
there are various software packages that are built to aid
I. INTRODUCTION physics learning and teaching and they have specific modules
and solve a number of problems. There are specialized
Astronomers are keen to follow the motions of the physics packages which consists of a training simulation
planets as they revolve around the Sun since the discovery of software and instructional materials that help students
modern science. People could only see the star formations understand and explore the fundamental laws of physics and
with their naked eyes before the invention of telescopes, so mathematical methods of investigation of the movement of
they can only see stars close to the Earth's orbit. Following celestial bodies. In contrast, the mathematical modelling
that, the invention of telescopes made it possible for mankind software allow users to build mathematical models of
to see distant planets clearly. These studies led to the physical problems and obtain corresponding solutions. I also
development of Newton's law of universal gravitation and initially tried modelling the planetary motion using Maple
Kepler's laws, which offer mathematical explanations of Software. However, I later learnt the Python Computing
planets' orbits. language from scratch and decided to model the various
motions on Python itself.
IJISRT22OCT039 www.ijisrt.com 64
Volume 7, Issue 10, Octomber – 2022 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165
Researched about the time module in python and imported
it for various programs to calculate the time of execution
of the programs
Created a virtual rock papers and scissors game by
importing the random function from the math module.
IJISRT22OCT039 www.ijisrt.com 65
Volume 7, Issue 10, Octomber – 2022 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165
library with Python. PyEphem can also compute the angular
separation between two objects in the sky, determine the
constellation in which an object lies, and find the times an
object rises, transits, and sets.
During this project I have worked on so many models Fig 5:- Recursion to Calculate Factorial
that could give me clarity on how the entire research would
work collaboratively. In my research there are some modules In computer science, recursion is a method of solving a
we have customized and used to track planetary motion. computational problem where the solution depends on
solutions to smaller instances of the same problem. Recursion
A. Predicting all Lunar Eclipses : solves such recursive problems by using functions that call
The Python program that calculates the date and time themselves from within their own code. The approach can be
for all the lunar eclipses between 2001 and 2100. applied to many types of problems, and recursion is one of
the central ideas of computer science.
To make this scenario work we have used ephem library
which is freely available. Since its first release in 1998, C. Recursion to generate Fibonacci Series:
PyEphem has given Python programmers the ability to Generating the first 'n' terms of the Fibonacci series
compute planet, comet, asteroid, and Earth satellite positions. using the process of Recursion. The goal of this program is to
It wraps the “libastro” C library that powers the XEphem further comprehend the complex process of Recursion in
astronomy application for UNIX — whose author Elwood python.
Downey generously gave permission for PyEphem to use his
IJISRT22OCT039 www.ijisrt.com 66
Volume 7, Issue 10, Octomber – 2022 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165
Fig 6:- Recursion to generate Fibonacci Series In computer science, recursion is a method of solving a
computational problem where the solution depends on
In computer science, recursion is a method of solving a solutions to smaller instances of the same problem. Recursion
computational problem where the solution depends on solves such recursive problems by using functions that call
solutions to smaller instances of the same problem. Recursion themselves from within their own code. The approach can be
solves such recursive problems by using functions that call applied to many types of problems, and recursion is one of
themselves from within their own code. The approach can be the central ideas of computer science.
applied to many types of problems, and recursion is one of
the central ideas of computer science F. Calculating-Root-by-Newton-Raphson Method:
In numerical analysis, Newton's method, also known as
D. Recursion for Power Function: the Newton–Raphson method, named after Isaac Newton and
Using recursion to calculate the value of a number 'a' Joseph Raphson, is a root-finding algorithm which produces
raised to another number 'b'. This program was designed to successively better approximations to the roots (or zeroes) of
understand Recursion better. a real-valued function. The most basic version starts with a
single-variable function f defined for a real variable x, the
function's derivative f′, and an initial guess x0 for a root of f.
IJISRT22OCT039 www.ijisrt.com 67
Volume 7, Issue 10, Octomber – 2022 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165
G. Calculating time taken for a Newton Raphson Method I. Calculating time taken for a Bisection Method program to
program to execute: execute:
This program calculates the time at the start of the This program calculates the time at the start of the
program and at the end of it. It then subtracts both to return program and at the end of it. It then subtracts both to return
the time taken for the program to the run. The program taken the time taken for the program to the run. The program taken
is the program for calculating the root of a given function by is the program for calculating the root of a given function by
Newton Raphson method. the Bisection method.
H. 2D Plotting:
A program designed to plot the graph for three different
functions on the same plot. The functions are: 1) sin(x) 2)
sin(x)+cos(x) 3) sin(x)*cos(x).
J. Prime-Number-Calculator:
This program consists of two different programs that
Fig 11:- 2D data plotting using matplotlib python library calculate the prime number that is closest to and is less than
a given number ‘n’. ‘n’ is inputted from the user. The first
The three functions were plotted by importing the program checks for non-prime numbers until the number n
matplotlib library. itself whereas the second one checks until the square root of
the number. We then compare the time taken for both
programs to execute.
IJISRT22OCT039 www.ijisrt.com 68
Volume 7, Issue 10, Octomber – 2022 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165
Not only was the mass of the sun considered in
modelling the orbit, but also the mass of other planets was
factored in as an average.
ACKNOWLEDGMENT
IJISRT22OCT039 www.ijisrt.com 69
Volume 7, Issue 10, Octomber – 2022 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165
REFERENCES
IJISRT22OCT039 www.ijisrt.com 70