058 Four Planets

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

Numerical solutions of the four coupled

differential equations of a planetary system using the 4th order


Runge-Kutta method

Submitted by
Rakib Chowdhury
Registration no: 2017132058
Session: 2017-18
Course no: PHY428

A project work submitted to the Department of Physics as a


partial fulfillment of the requirement for the degree of
Bachelor of Science (B. Sc.)

Approved as to style and content by


Anock Somadder
Associate Professor

Department of Physics
School of Physical Sciences
Shahjalal University of Science and Technology
Sylhet, Bangladesh

January, 2023
Acknowledgement

i
Abstract
In this study, the trajectory taken by Mercury, Venus, Earth, and Mars as they orbit the Sun has
been analyzed. The four coupled differential equations have been constructed from Newton's law
of gravitation and Kepler's law of planetary motion for the solution of the system using the fourth-
order Runge-Kutta method.The trajectory of the planets found after analyzing is an elliptical route
which is identical to the known information about our solar system.

ii
Table of Contents

1.Introduction ............................................................................................................. 1

2.Theory ..................................................................................................................... 2

3.Methodology ........................................................................................................... 4

3.1 4th Order Method Runge Kutta Method ........................................................ 4

3.2 Initial conditions ............................................................................................ 6

3.3 Discretized Equations .................................................................................... 6

4.Results and Discussion ........................................................................................... 8

5.Conclusion ............................................................................................................ 10

References ................................................................................................................ 11

iii
1. Introduction
The Greeks were knowledgeable with the five planets (Mercury, Venus, Mars, Jupiter, and Saturn)
from ancient times. In general, they considered that the sun and planets revolved around the Earth,
which they considered to be the center of the universe. Aristarchus of Samos, a Greek astronomer
who lived from 310 to 250 BC, said once every 24 hours, the Earth rotates on its axis and orbits
the sun with the other planets once every year about the year 280 BC. This was a radical break
from the geocentric theory [1]. The contemporary people of Aristarchus did not take the
aforementioned statement seriously. They were fully committed to the notion that Earth was the
center of the cosmos. This misguided perspective persisted uncontested for up to eighteen hundred
years, at which point a Polish Aristarchus' idea was reintroduced by the monk Nicholas Copernicus
(1473–1543) as a tenable explanation for the planets' apparent motion. Although Galileo referred
to Copernicus as "the restorer and confirmer," Copernicus is recognized in scientific history as the
creator of the heliocentric theory for our solar system [1]. Johannes Kepler (1571–1630), another
brilliant astronomer in history, was challenged with furthering Copernicus's discoveries. Kepler
asserted that planets dictate eccentric rather than circular orbits based on the experimental findings
of another outstanding Danish astronomer, Tycho Brahe (1546-1601) which were exactly in line
with their apparent velocity around the sun. Newton attempted to provide answers to two basic
problems using Kepler's empirical findings as a starting point. In the first place, what drives the
planets to orbit the sun, and in the second, why are their orbits elliptical. Newton discovered the
idea of universal gravitation in his endeavor to find solutions to these two aspects [2]. All of the
planets in our solar system orbit it on elliptic routes because the sun defines motion around a
reference origin and is neither static nor fixed. Understanding the basic planetary motion formula
in the system of Cartesian coordinates is the easiest technique to determine such elliptical
movements (orbits) [2].

For the best understanding of our circumstance, consider the figure below:

Figure 1: Cartesian coordinate representation of two entities experiencing gravitational attraction.

1
In this project, we will develop the planetary motion equations assuming that the planets' masses
can be approximately translated to point masses. This is a logical example of how far apart the
planets are in the solar system [2]. There are two factors at play in this seasonal change in the
Sun's apparent motion. The Earth's orbit is not a complete circle; rather, it is elliptical, with the
Sun being closer to one end. In an elliptical orbit, the Earth's speed varies from a minimum at its
greatest distance to a maximum at its closest approach to the Sun. The Earth's equator's angle
with respect to the plane of the planet's rotation around the sun is the second cause of the yearly
variation. In addition to rotating on its axis, the Earth also moves in the same direction (or sense)
around the Sun. The Earth rotates around the Sun, therefore if we choose a location on Earth in
which the Sun is overhead, that location will need to turn a little bit more in order to return to
having the Sun overhead once more. One rotation of the Earth around the sun requires a little bit
more than one turn of the earth in relation to the stars. The angle made by the Earth's rotation
around the Sun in one day is what is meant by the phrase "a little bit." This angle (360 degrees
divided by 365 days) equals, on average, little under one degree each day. It takes the Earth
nearly four minutes to rotate at this tiny angle. If this minor variation were constant, there would
be no cause for alarm, but it is not. Remembering the elliptical journey taken by the Earth
encircling the sun. As the Earth approaches closer to the Sun, its orbital speed quickens. Since
the Earth is farther from the Sun in July than it is in January, the Earth is travelling through space
more quickly in January. As a result, from October to April, the Earth must revolve somewhat
more each day in order to return to a specific location and face the Sun once more.

2. Theory
According to the Newton’s law of gravitational force we obtain the following:
𝐺𝑀𝑚
𝐹= (2.1)
𝑟2

Now we will consider the our solar system with Mercury, Venus, Earth, Mars and Sun in 2
dimensions.

Where, G = gravitational constant

M = mass of sun = 2×1030 Kg

m = mass of planets

r = distance between the planets and the Sun

F = gravitational force

2
Figure 2: Representation of Earth and Sun system in elliptic route.

Now,

𝐹𝑥 = 𝐹 cos 𝜃 (2.2)

𝐹𝑦 = 𝐹 sin 𝜃 (2.3)

From the figure 2,


𝑦
𝑠𝑖𝑛 𝜃 = 𝑟 (2.4)

𝑥
𝑐𝑜𝑠 𝜃 = (2.5)
𝑟

Along the x axis the motion,


𝐺𝑀𝑚 𝑥
m.𝑎𝑥 = - .𝑟 (2.6)
𝑟2

𝑑2 𝑥 𝐺𝑀𝑥 𝐺𝑀
or, 𝑑𝑡 2 = - = - (𝑥 2+𝑦 2𝑥)3/2 (2.7)
𝑟3

We know,
𝑑𝑥
= 𝑣𝑥 (2.8)
𝑑𝑡

From equation (2.7) and (2.8), we get,


𝑑𝑣𝑥 𝐺𝑀
= − (𝑥 2+𝑦 2𝑥)3/2 (2.9)
𝑑𝑡

Similarly, along the y axis the motion,


𝐺𝑀𝑚 𝑥𝑦
m.𝑎𝑦 = - . (2.10)
𝑟2 𝑟

3
𝑑2 𝑦 𝐺𝑀𝑦 𝐺𝑀𝑦
or, =- = - (𝑥 2+𝑦 2)3/2 (2.11)
𝑑𝑡 2 𝑟3

We know,
𝑑𝑦
= 𝑣𝑦 (2.12)
𝑑𝑡

From equation (2.11) and (2.12), we get,


𝑑𝑣𝑦 𝐺𝑀𝑦
= − (𝑥 2+𝑦 2)3/2 (2.13)
𝑑𝑡

So, the four coupled differential equations:


𝑑𝑥
= 𝑣𝑥 , (2.14)
𝑑𝑡

𝑑𝑣𝑥 𝐺𝑀
= − (𝑥 2+𝑦 2𝑥)3/2 , (2.15)
𝑑𝑡

𝑑𝑦
= 𝑣𝑦 , (2.16)
𝑑𝑡

𝑑𝑣𝑦 𝐺𝑀𝑦
= − (𝑥 2+𝑦 2)3/2 , (2.17)
𝑑𝑡

3. Methodology
4th Order Runge Kutta is used to solve the four coupled differential equations. We took the initial
conditions of the planets Mercury, Venus, Earth and Mars at perihelion and then discretize the four
coupled equations. After that, we solve the discretized equations in python through coding.

3.1 4th Order Runge Kutta Method


The traditional fourth-order Runge-Kutta formula is by far the most often employed, known as the
"Classic Runge-Kutta Method.". The right side of each step in the fourth order Runge Kutta
method must be evaluated four times. It is true that fourth-order Runge-Kutta is typically better
than second-order, but you should understand that this is more of a statement about modern science
than about rigorous mathematics. In other words, it exhibits the kinds of problems that
contemporary scientists want to tackle. In terms of ODE integrators, fourth-order Runge-Kutta is
not only the first word but also, for many scientific users, the last word. In fact, you can do quite
a bit if you combine this old workhorse with an adjustable step size method [5].

4
Let's say that an initial value problem is defined as follows:
𝑑𝑦
= 𝑓(𝑥, 𝑦) (3.1.1)
𝑑𝑥

𝑦(𝑥0 ) = 𝑦0 (3.1.2)

Here, we want to make an approximation of the unknown (scalar or vector) time-dependent


𝑑𝑦
function y, where, being a function of both x and y, is the rate at which y changes. Initially
𝑑𝑥
when, 𝑥 = 𝑥0 the equivalent value of y is 𝑦0 [5]. The initial condition 𝑥0 , 𝑦0 and the function ‘f’
are given. Now by taking the step size h > 0 we get:
1
𝑦𝑛+1 = 𝑦𝑛 + 6 (𝑘1 + 2𝑘2 + 2𝑘3 + 𝑘4 )ℎ (3.1.3)

𝑥𝑛+1 = 𝑥𝑛 + ℎ (3.1.4)

For n = 0, 1, 2, 3, …..,

𝑘1 = 𝑓(𝑥𝑛 , 𝑦𝑛 ) (3.1.5)
ℎ 𝑘
𝑘2 = 𝑓 (𝑥𝑛 + 2 , 𝑦𝑛 + ℎ 21 ) (3.1.6)

ℎ 𝑘
𝑘3 = 𝑓 (𝑥𝑛 + 2 , 𝑦𝑛 + ℎ 22 ) (3.1.7)

𝑘4 = 𝑓(𝑥𝑛 + ℎ, 𝑦𝑛 + ℎ𝑘3 ) (3.1.8)

The definitions for the aforementioned equations vary but are equivalent in many texts [3] [6] [7]
[8] [9]. Here, 𝑦𝑛+1 approximates 𝑦(𝑥𝑛 + 1) using the RK4 method. and the subsequent value
𝑦𝑛+1 is produced by multiplying the current value 𝑦𝑛 by the four increments, which are each a
weighted average produced by multiplying the length of the interval, h, by the anticipated slope,
the differential equations right side contains the function f [10].

Figure 3: Slopes used for Classic Runge Kutta Method.

5
Using y, 𝑘1 represents the slope towards interval's beginning. 𝑘2 represents the slope along the
time period's midpoint using y and 𝑘1 . Similarly, using y and 𝑘2 , 𝑘3 represents the slope along
midpoint of the time period. 𝑘4 represents the slope towards end of the time period using y and 𝑘3
[10].

3.2 Initial Conditions


We need to set the initial conditions for solving the coupled equations (2.14), (2.15), (2.16) and
(2.17). The assumptions we take:

Figure 4: Assuming the planets at perihelion

In the above figure P represents planets and S represents Sun. In order to solve the equations’
(2.15) and (2.17) we need the initial values of (t, x, 𝑣𝑥 ) and (t, y, 𝑣𝑦 ). Considering the planet
Mercury, Venus, Earth and Mars at perihelion (e.g.) the point in the orbit of a planet which is
closest to the Sun the initial values:

𝒕 𝒙 𝒚 𝒗𝒙 𝒗𝒚
0 Minimum 0 0 Maximum speed
distance of P of the planet
from S

3.3 Discretized Equations


For Runge-Kutta 4th order,

𝑥 = 𝑥 + (𝑘1 + 2 × 𝑘2 + 2 × 𝑘3 + 𝑘4 )/6 (3.4.1)

𝑣𝑥 = 𝑣𝑥 + (𝑙1 + 2 × 𝑙2 + 2 × 𝑙3 + 𝑙4 )/6 (3.4.2)

𝑦 = 𝑦 + (𝑚1 + 2 × 𝑚2 + 2 × 𝑚3 + 𝑚4 )/6 (3.4.3)

𝑣𝑦 = 𝑣𝑦 + (𝑛1 + 2 × 𝑛2 + 2 × 𝑛3 + 𝑛4 )/6 (3.4.4)

6
Where,

𝑘1 = ℎ × 𝑓1 (𝑡, 𝑥, 𝑣𝑥 ) (3.4.5)

𝑙1 = ℎ × 𝑓2 (𝑡, 𝑥, 𝑣𝑥 ) (3.4.6)

𝑚1 = ℎ × 𝑔1 (𝑡, 𝑦, 𝑣𝑦 ) (3.4.7)

𝑛1 = ℎ × 𝑔2 (𝑡, 𝑦, 𝑣𝑦 ) (3.4.8)

And

𝑘2 = ℎ × 𝑓1 (𝑡 + ℎ/2, 𝑥 + 𝑘1 /2, 𝑣𝑥 + 𝑙1 /2) (3.4.9)

𝑙2 = ℎ × 𝑓2 (𝑡 + ℎ/2, 𝑥 + 𝑘1 /2, 𝑣𝑥 + 𝑙1 /2) (3.4.10)

𝑚2 = ℎ × 𝑔1 (𝑡 + ℎ/2, 𝑦 + 𝑚1 /2, 𝑣𝑦 + 𝑛1 /2) (3.4.11)

𝑛2 = ℎ × 𝑔2 (𝑡 + ℎ/2, 𝑦 + 𝑚1 /2, 𝑣𝑦 + 𝑛1 /2) (3.4.12)

Similarly, according to formula,

𝑘3 = ℎ × 𝑓1 (𝑡 + ℎ/2, 𝑥 + 𝑘2 /2, 𝑣𝑥 + 𝑙2 /2) (3.4.13)

𝑙3 = ℎ × 𝑓2 (𝑡 + ℎ/2, 𝑥 + 𝑘2 /2, 𝑣𝑥 + 𝑙2 /2) (3.4.14)

𝑚3 = ℎ × 𝑔1 (𝑡 + ℎ/2, 𝑦 + 𝑚2 /2, 𝑣𝑦 + 𝑛2 /2) (3.4.15)

𝑛3 = ℎ × 𝑔2 (𝑡 + ℎ/2, 𝑦 + 𝑚2 /2, 𝑣𝑦 + 𝑛2 /2) (3.4.16)

And,

𝑘4 = ℎ × 𝑓1 (𝑡 + ℎ, 𝑥 + 𝑘3 , 𝑣𝑥 + 𝑙3 ) (3.4.17)

𝑙4 = ℎ × 𝑓2 (𝑡 + ℎ, 𝑥 + 𝑘3 , 𝑣𝑥 + 𝑙3 ) (3.4.18)

𝑚4 = ℎ × 𝑔1 (𝑡 + ℎ, 𝑦 + 𝑚3 , 𝑣𝑦 + 𝑛3 ) (3.4.19)

𝑛4 = ℎ × 𝑔2 (𝑡 + ℎ, 𝑦 + 𝑚3 , 𝑣𝑦 + 𝑛3 ) (3.4.20)

7
4. Results and Discussion
For planet Mercury with the initial condition t = 0 to 𝑡𝑚𝑎𝑥 = 88 days at perihelion; by taking step
size h=1. The output:

Figure 5: Representation of trajectory for Mercury and Sun system.

Again, for planet Venus with the initial condition t = 0 to 𝑡𝑚𝑎𝑥 = 243 days at perihelion; by
taking step size h=1. The output:

Figure 6: Representation of trajectory for Venus and Sun system.

8
Again, for planet Earth with the initial condition t = 0 to 𝑡𝑚𝑎𝑥 = 365 days at perihelion; by taking
step size h=1. The output:

Figure 7: Representation of trajectory for Earth and Sun system.

Again, for planet Mars with the initial condition t = 0 to 𝑡𝑚𝑎𝑥 = 687 days at perihelion; by taking
step size h=1. The output:

Figure 8: Representation of trajectory for Mars and Sun system.

9
So, for the planets Mercury, Venus, Earth and Mars we get the following output at perihelion:

Figure 9: Trajectory of Mercury, Venus, Earth and Mars around Sun.

We can see from the analysis above that planets orbit the sun in an elliptic fashion. We determine
the route for various maximum times of various planets by solving the four coupled differential
equations in 4th Order Runge Kutta Method. Because the four planets require varying amounts of
time to complete their rotations around the sun, their maximum time varies. The earth completes
the trajectory every 365 days, and anything less than that results in an incomplete journey. The
same is true for Mercury, Venus, and Mars, whose respective total rotational velocities are 88,
243, and 687 days. The output is unaffected by the step size 'h’.

5. Conclusion
In the conclusion, it is clear that the Runge Kutta 4th result depicts an elliptic route for the four
planets' orbits around the sun. The radius of this elliptic route varies because the planets' perihelion
velocities and 𝑡𝑚𝑎𝑥 (time it takes for one revolution around the sun to complete). The closest
separation of the planets from the sun, or radius r also affects the trajectory.

10
References
[1] Cosmos, by Carl Sagan, Random House, New York, 1980.

[2] The Equations Of Planetary Motion And Their Solution, by Kyriacos Papadatos.

[3] An Introduction to Numerical Analysis (2nd ed.) byAtkinson, Kendall A. (1989).

[4] Numerical Analysis In Banking And Its Applications, by Elif Yildiran.

[5] Numerical Recipes: The Art of Scientific Computing (3rd ed.), Cambridge University Press.

[6] Solving ordinary differential equations I: Nonstiff problems, Berlin, New York, by Hairer,
Ernst; Nørsett, Syvert Paul; Wanner, Gerhard (1993).

[7] Introduction to Numerical Analysis (3rd ed.), Berlin, New York, by Stoer, Josef; Bulirsch,
Roland (2002).

[8] Computer Methods for Ordinary Differential Equations and Differential-Algebraic Equations,
Philadelphia, by Ascher, Uri M.; Petzold, Linda R. (1998).

[9]Numerical Methods for Ordinary Differential Equations, New York by Butcher, John C. (2008).

[10] An Introduction to Numerical Analysis, Cambridge University Press, ISBN 0-521-00794-1.

11

You might also like