You are on page 1of 6

BS-(PHY)-02

Computational Physics
Task 4
Plotting Solar System up to Jupiter, using RK-2 method

Group Members:
Zainab[211001003]
M. Harees [211001010]

Instructor: Dr. Fazeel Mehmud


Data Files of 2002, April 01
I) Write down a C++ code that reads in initial
data from a file an array and integrates the
orbit of each planet using Euler’s (only for
planet Earth) and RK2 methods for 10 years.
Subsequent out put data of each step should
also be written in an output file.
The .cxx file of code is attached with the task,
submitted on google classroom.
II) Make a comparison of two methods for the
orbit or Earth.
Euler v/s RK2 (Earth)

Euler
Euler
Euler
RK2
RK2
Horizontal Distance from sun (Au)

RK2
1.0
0.5
0.0
−1.0 −0.5

−1.0 −0.5 0.0 0.5 1.0

Horizontal Distance from sun (Au)


III) Plot the orbits of all the planets in xy plane
in a single plot.
First we estimated data for 10 years, but this
caused a problem that the orbit of Jupiter was
incomplete in 10 years.

Solar System (time step=0.001 for 10 years


Verticle Distance with sun at origin (Au)

4
2
0
−2
−4

−4 −2 0 2 4

Horizontal distance with sun at origin (Au)


This is because Jupiter orbits the sun in around 12
earth years. Thus we estimated the orbits for 15
years.

SolarSystem; time−step=0.0001 years


Vertical distance with sun at origin (Au)

jupiter
mars
earth
venus
4

mercury
2
0
−2
−4

−4 −2 0 2 4

Horizontal distance with sun at origin (Au)


- First we get our concerned data of planets from
year 2002, April. We get the values of x,y,z and
vx, vy and vz for al planets and copied them in a
file which was further read in an array and stored
in it.
- Then we made a code for 10 years first, for all
planets but then we had to extend it for 15 years
due to the Jupiter-orbit problem.
- All orbits were quite reasonable except that of
Mercury; due to its high revolving speed, its
orbits gets more and more diverged from
accuracy, thus we took least possible time step of
0.0001 years to make its orbit less wobbling.
Time step less than this was too costly
computationally.

You might also like