SlideShare ist ein Scribd-Unternehmen logo
1 von 6
Sultan LeMarc
Computational Physics

30/03/2012

The Two Dimensional Gravitational Problem
Objective
The aim of this project is to model the two-dimensional gravitational problem
by a program using the C++ language. The objective of this program is to read,
in two dimensions, the initial positions, velocities and masses of two bodies
and use Newton’s law of universal gravitation to calculate the two-dimensional
forces on each body.
It follows this by using Newton’s second law to calculate the acceleration of
the bodies in a given time frame in order to establish their movements of the
bodies. A file is generated by the program with the positions of both bodies at
each time step over a whole time period, which is then used to plot the paths
of the two bodies.
The two-body gravitational problem concerns the motion of two point masses
that interact only with each other due to gravity. Such models are
approximated commonly in the Universe, for example the Earth’s orbit around
the Sun, the moon’s orbit around the Earth, and two starts orbiting each other.
Newton’s Law of Universal Gravitation:
Newton published his work on the law of gravity in 1967, introducing the law
of universal gravitation, which states that every particle in the Universe
attracts every other particle with a force that is directly proportional to the
product of their masses and inversely proportional to the square of the
distance between them (Serway, 2010).
For two bodies, of masses m1 and m2(kg), separated by a distance r (m), the
magnitude of the gravitational force, in Newtons (N), is:

where G is a constant called the universal gravitational constant. In SI units, it’s
value is:
This is often referred to as the inverse-square law, as the force varies as the
inverse square of the separation of the bodies.
As the constant G is used throughout the program, it is declared as a fixed
variable by const double G=6.67300E-11.
The program makes use of 1D arrays of size [2] for the two-dimensional
components of positionpos_m[2], velocity vel_m[2], acceleration acc_m[2],
and force gforce_m[2]. Each mass is allocated an array for each of these
variables.
In order to find the distance that separates the two bodies, r, from the initial x
and y positions, the change in each component is used in:

This is coded as:

dx = pos_m2[0]-pos_m1[0]
dy = pos_m2[1]-pos_m1[1]
r = sqrt ((dx*dx)+(dy*dy))

This allows the gravitational force acting on each body by the other along the
line of action to be found. The two dimensional components of this force is
found using trigonometric principles. First, the program finds the angle
between the line of action and the x-axis by:

This is coded as angle=atan2(dy,dx);
This angle is then used to resolve the components of the calculated force:

Newton’s third law, which states that if two bodies interact, the force F12
exerted by body 1 on body 2 is equal in magnitude and opposite in direction to
the force F21 exerted by body 2 on body 1:

Therefore the program implements this by equating the component forces of
body 2 as the negative equivalents of the component forces of body 1:
gforce_m1[0] = F*cos(angle);
gforce_m1[1] = F*sin(angle);
gforce_m2[0] = -F*cos(angle);
gforce_m2[1] = -F*sin(angle);
The two dimensional acceleration is found from these forces by using
Newton’s second law, which states that the acceleration of an object is directly
proportional to the net force acting on it and inversely proportional to its mass
(Serway, 2010):
This is applied for each component of the forces for both bodies by:
ax1 = Fx1/m1:acc_m1[0] = gforce_m1[0]/m1;
ay1 = Fy1/m1:acc_m1[1] = gforce_m1[1]/m1
ax2= Fx2/m2: acc_m2[0] = gforce_m2[0]/m2;
ay2 = Fy2/m2: acc_m2[1] = gforce_m2[1]/m2;
The acceleration is used to find the change in velocity of each body in a given
time step, but first the time step ∆t is determined from the calculated period T.
The program assumes that the motion is an orbit. The period of the orbit is
determined by the consideration of orbital energy conservation, which
requires that the sum of kinetic and potential energies be constant at all points
in the motion. The equation for orbital energy conservation, also known as
“Vis-Viva” is:

wherevr is the relative velocity given by:

This is coded as:dv[0] = vel_m2[0]-vel_m1[0];
dv[1] = vel_m2[1]-vel_m1[1];
rel_vel = sqrt((dv[0]*dv[0])+(dv[1]*dv[1]));
The program uses this value to find orbital energy by:
orb_energy = (0.5*rel_vel*rel_vel)-(G*(m1+m2)/r);

This orbital energy acts as the condition which defines the type of orbit
experienced by the bodies:
 ϵ < 0: Elliptical orbit
This corresponds to the minimum and maximum values of r for an
elliptical orbit where the distances of closest and farthest approach are
equal to r0/1-ε.
 ϵ = 0: Parabolic orbit
This corresponds to the escape velocity condition as a body is outside
the bounds of another body’s gravitational force when energy is
equivalent to zero i.e.
.
 ϵ > 0: Hyperbolic orbit
(MIT.edu)
In a parabolic or hyperbolic trajectory the motion is not periodic, and the
duration of the full trajectory is infinite. Therefore the programprints an error
message and aborts program upon the result of a parabolic or hyperbolic orbit
when testing for the orbital energy conditions.
The semi-major axis is half of the major axis of an ellipse which has a length
from the centre to the edge of the ellipse along its principle axes. The orbital
energy is used to find the semi-major axis, a, of the elliptical orbit:

This is coded by sm_axis = -(G*(m1+m2))/(2*orb_energy).
With the semi-major axis value, the period T of the orbit is determined through
Kepler’s third law, which states that the square of the orbital period of a planet
is directly proportional to the cube of the semi-major axis of its orbit:

For this the value of π is declared as a fixed variable to 8 significant figures:
const double pi = 3.1415926;
The calculation for T is coded as:
T = sqrt(fabs((4*pi*pi*sm_axis*sm_axis*sm_axis)/(G*(m1+m2))));
The program determines the time step ∆t according to this calculated period
by setting
.

Having established the time step, the new velocities are found by accumulating
the change in velocity, as related by acceleration and the time:
.
As with acceleration, this is done for each of the components of velocity for
both bodies:
vel_m1[0] += acc_m1[0]*dt;
vel_m1[1] += acc_m1[1]*dt;
vel_m2[0] += acc_m2[0]*dt;
vel_m2[1] += acc_m2[1]*dt;
Finally, the new positions of the bodies are calculated using the following
equation of motion:

where s is the displacement and u is the initial velocity. As the calculation takes
within a for loop where the new velocity after each time step becomes the
initial velocity for the next and likewise with position, it is coded as:
pos_m1[0] += ((vel_m1[0]*dt)+(0.5*acc_m1[0]*dt*dt));
pos_m1[1] += ((vel_m1[1]*dt)+(0.5*acc_m1[1]*dt*dt));
pos_m2[0] += ((vel_m2[0]*dt)+(0.5*acc_m2[0]*dt*dt));
pos_m2[1] += ((vel_m2[1]*dt)+(0.5*acc_m2[1]*dt*dt));
The program prints the positions of both bodies into a 2D array, position, of
size[1001][4] and writes a spread sheet file for excel which can then be
plotted.
Assumptions
 The bodies are point particles; their sizes are negligible centre-to-centre
distance is not considered.
 If orbital energy is less than zero then orbiting body has two turning
points, rmin and rmax. Body gets no closer than rminto central body and no
further than rmax due to conservation of angular momentum.
 The gravitational fields of the bodies are uniform.
 The motion of the bodies as a result of the interaction is closed and
periodic i.e. elliptical or circular orbits. Open orbits of parabolic or
hyperbolic give void readings.
 The two bodies are isolated from the Universe, therefore do not
experience gravitational force from any other body i.e. only one central
force acting.
 Centre of mass of the isolated system is not accelerated.
 The larger of the two masses is stationary and fixed at the origin of the
system.
Figure 1: Plot of X-Y positions of two masses, calculated by program.

Program input values:
Mass 1: 2E30
Initial Position: 0, 0
Initial Velocity: 0, 0
Mass 2: 6E24
Initial Position: 1.496E11, 0
Initial Velocity: 0, 29E3

Weitere ähnliche Inhalte

Was ist angesagt?

Universal Gravitation
Universal GravitationUniversal Gravitation
Universal Gravitation
ZBTHS
 
Gravitational Fields
Gravitational FieldsGravitational Fields
Gravitational Fields
Paula Mills
 
Earth 0205-response spectrum
Earth 0205-response spectrumEarth 0205-response spectrum
Earth 0205-response spectrum
tharwat sakr
 

Was ist angesagt? (20)

hw2
hw2hw2
hw2
 
Öncel Akademi: İstatistiksel Sismoloji
Öncel Akademi: İstatistiksel SismolojiÖncel Akademi: İstatistiksel Sismoloji
Öncel Akademi: İstatistiksel Sismoloji
 
Universal Gravitation
Universal GravitationUniversal Gravitation
Universal Gravitation
 
Accuracy of the internal multiple prediction when a time-saving method based ...
Accuracy of the internal multiple prediction when a time-saving method based ...Accuracy of the internal multiple prediction when a time-saving method based ...
Accuracy of the internal multiple prediction when a time-saving method based ...
 
Ch06 ssm
Ch06 ssmCh06 ssm
Ch06 ssm
 
Ch07 ssm
Ch07 ssmCh07 ssm
Ch07 ssm
 
Gravitational Fields
Gravitational FieldsGravitational Fields
Gravitational Fields
 
Ch04 ssm
Ch04 ssmCh04 ssm
Ch04 ssm
 
Chap9
Chap9Chap9
Chap9
 
Principles of soil dynamics 3rd edition das solutions manual
Principles of soil dynamics 3rd edition das solutions manualPrinciples of soil dynamics 3rd edition das solutions manual
Principles of soil dynamics 3rd edition das solutions manual
 
Coordinate systems
Coordinate systemsCoordinate systems
Coordinate systems
 
Sensor Fusion Study - Ch9. Optimal Smoothing [Hayden]
Sensor Fusion Study - Ch9. Optimal Smoothing [Hayden]Sensor Fusion Study - Ch9. Optimal Smoothing [Hayden]
Sensor Fusion Study - Ch9. Optimal Smoothing [Hayden]
 
Ch09 ssm
Ch09 ssmCh09 ssm
Ch09 ssm
 
JC A Level H2 Physics Dynamics Notes
JC A Level H2 Physics Dynamics NotesJC A Level H2 Physics Dynamics Notes
JC A Level H2 Physics Dynamics Notes
 
Work and Energy
Work and EnergyWork and Energy
Work and Energy
 
kuramoto
kuramotokuramoto
kuramoto
 
1.1.1 gravitational fields
1.1.1   gravitational fields1.1.1   gravitational fields
1.1.1 gravitational fields
 
Earth 0205-response spectrum
Earth 0205-response spectrumEarth 0205-response spectrum
Earth 0205-response spectrum
 
Work ,energy and power
Work ,energy and powerWork ,energy and power
Work ,energy and power
 
Work energy theorem summary 7 may 2015
Work energy theorem summary 7 may 2015Work energy theorem summary 7 may 2015
Work energy theorem summary 7 may 2015
 

Ähnlich wie Computational Physics - modelling the two-dimensional gravitational problem by C++.

Study Unit Ill Engineerin M Part4 an1cs By And.docx
Study Unit Ill Engineerin M Part4 an1cs By And.docxStudy Unit Ill Engineerin M Part4 an1cs By And.docx
Study Unit Ill Engineerin M Part4 an1cs By And.docx
hanneloremccaffery
 
Modelling and Simulations
Modelling and SimulationsModelling and Simulations
Modelling and Simulations
Minjie Lu
 

Ähnlich wie Computational Physics - modelling the two-dimensional gravitational problem by C++. (20)

PART I.2 - Physical Mathematics
PART I.2 - Physical MathematicsPART I.2 - Physical Mathematics
PART I.2 - Physical Mathematics
 
dynamics chapt 1 .pptx
dynamics chapt 1 .pptxdynamics chapt 1 .pptx
dynamics chapt 1 .pptx
 
Study Unit Ill Engineerin M Part4 an1cs By And.docx
Study Unit Ill Engineerin M Part4 an1cs By And.docxStudy Unit Ill Engineerin M Part4 an1cs By And.docx
Study Unit Ill Engineerin M Part4 an1cs By And.docx
 
CollidingParticles.pdf
CollidingParticles.pdfCollidingParticles.pdf
CollidingParticles.pdf
 
Physics formulas list
Physics formulas listPhysics formulas list
Physics formulas list
 
Modelling and Simulations
Modelling and SimulationsModelling and Simulations
Modelling and Simulations
 
Kinetics of particle
Kinetics of particleKinetics of particle
Kinetics of particle
 
A Rapid Location Independent Full Tensor Gravity Algorithm
A Rapid Location Independent Full Tensor Gravity AlgorithmA Rapid Location Independent Full Tensor Gravity Algorithm
A Rapid Location Independent Full Tensor Gravity Algorithm
 
dynamics chapter 2.pptx
dynamics chapter 2.pptxdynamics chapter 2.pptx
dynamics chapter 2.pptx
 
Quantum Assignment Help
Quantum Assignment HelpQuantum Assignment Help
Quantum Assignment Help
 
Quantum state
Quantum stateQuantum state
Quantum state
 
Formula Book [Physics+chemistry+Maths].pdf
Formula Book [Physics+chemistry+Maths].pdfFormula Book [Physics+chemistry+Maths].pdf
Formula Book [Physics+chemistry+Maths].pdf
 
Kane’s Method for Robotic Arm Dynamics: a Novel Approach
Kane’s Method for Robotic Arm Dynamics: a Novel ApproachKane’s Method for Robotic Arm Dynamics: a Novel Approach
Kane’s Method for Robotic Arm Dynamics: a Novel Approach
 
A Numerical Integration Scheme For The Dynamic Motion Of Rigid Bodies Using T...
A Numerical Integration Scheme For The Dynamic Motion Of Rigid Bodies Using T...A Numerical Integration Scheme For The Dynamic Motion Of Rigid Bodies Using T...
A Numerical Integration Scheme For The Dynamic Motion Of Rigid Bodies Using T...
 
Ap review total
Ap review totalAp review total
Ap review total
 
Dynamics
DynamicsDynamics
Dynamics
 
08 gravitation
08   gravitation08   gravitation
08 gravitation
 
MD_course.ppt
MD_course.pptMD_course.ppt
MD_course.ppt
 
1_PHYSICAL Quantities to define the laws of physics
1_PHYSICAL Quantities to define the laws of physics1_PHYSICAL Quantities to define the laws of physics
1_PHYSICAL Quantities to define the laws of physics
 
The Equation Based on the Rotational and Orbital Motion of the Planets
The Equation Based on the Rotational and Orbital Motion of the PlanetsThe Equation Based on the Rotational and Orbital Motion of the Planets
The Equation Based on the Rotational and Orbital Motion of the Planets
 

Kürzlich hochgeladen

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 

Kürzlich hochgeladen (20)

microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 

Computational Physics - modelling the two-dimensional gravitational problem by C++.

  • 1. Sultan LeMarc Computational Physics 30/03/2012 The Two Dimensional Gravitational Problem Objective The aim of this project is to model the two-dimensional gravitational problem by a program using the C++ language. The objective of this program is to read, in two dimensions, the initial positions, velocities and masses of two bodies and use Newton’s law of universal gravitation to calculate the two-dimensional forces on each body. It follows this by using Newton’s second law to calculate the acceleration of the bodies in a given time frame in order to establish their movements of the bodies. A file is generated by the program with the positions of both bodies at each time step over a whole time period, which is then used to plot the paths of the two bodies. The two-body gravitational problem concerns the motion of two point masses that interact only with each other due to gravity. Such models are approximated commonly in the Universe, for example the Earth’s orbit around the Sun, the moon’s orbit around the Earth, and two starts orbiting each other. Newton’s Law of Universal Gravitation: Newton published his work on the law of gravity in 1967, introducing the law of universal gravitation, which states that every particle in the Universe attracts every other particle with a force that is directly proportional to the product of their masses and inversely proportional to the square of the distance between them (Serway, 2010). For two bodies, of masses m1 and m2(kg), separated by a distance r (m), the magnitude of the gravitational force, in Newtons (N), is: where G is a constant called the universal gravitational constant. In SI units, it’s value is: This is often referred to as the inverse-square law, as the force varies as the inverse square of the separation of the bodies. As the constant G is used throughout the program, it is declared as a fixed variable by const double G=6.67300E-11. The program makes use of 1D arrays of size [2] for the two-dimensional components of positionpos_m[2], velocity vel_m[2], acceleration acc_m[2],
  • 2. and force gforce_m[2]. Each mass is allocated an array for each of these variables. In order to find the distance that separates the two bodies, r, from the initial x and y positions, the change in each component is used in: This is coded as: dx = pos_m2[0]-pos_m1[0] dy = pos_m2[1]-pos_m1[1] r = sqrt ((dx*dx)+(dy*dy)) This allows the gravitational force acting on each body by the other along the line of action to be found. The two dimensional components of this force is found using trigonometric principles. First, the program finds the angle between the line of action and the x-axis by: This is coded as angle=atan2(dy,dx); This angle is then used to resolve the components of the calculated force: Newton’s third law, which states that if two bodies interact, the force F12 exerted by body 1 on body 2 is equal in magnitude and opposite in direction to the force F21 exerted by body 2 on body 1: Therefore the program implements this by equating the component forces of body 2 as the negative equivalents of the component forces of body 1: gforce_m1[0] = F*cos(angle); gforce_m1[1] = F*sin(angle); gforce_m2[0] = -F*cos(angle); gforce_m2[1] = -F*sin(angle); The two dimensional acceleration is found from these forces by using Newton’s second law, which states that the acceleration of an object is directly proportional to the net force acting on it and inversely proportional to its mass (Serway, 2010):
  • 3. This is applied for each component of the forces for both bodies by: ax1 = Fx1/m1:acc_m1[0] = gforce_m1[0]/m1; ay1 = Fy1/m1:acc_m1[1] = gforce_m1[1]/m1 ax2= Fx2/m2: acc_m2[0] = gforce_m2[0]/m2; ay2 = Fy2/m2: acc_m2[1] = gforce_m2[1]/m2; The acceleration is used to find the change in velocity of each body in a given time step, but first the time step ∆t is determined from the calculated period T. The program assumes that the motion is an orbit. The period of the orbit is determined by the consideration of orbital energy conservation, which requires that the sum of kinetic and potential energies be constant at all points in the motion. The equation for orbital energy conservation, also known as “Vis-Viva” is: wherevr is the relative velocity given by: This is coded as:dv[0] = vel_m2[0]-vel_m1[0]; dv[1] = vel_m2[1]-vel_m1[1]; rel_vel = sqrt((dv[0]*dv[0])+(dv[1]*dv[1])); The program uses this value to find orbital energy by: orb_energy = (0.5*rel_vel*rel_vel)-(G*(m1+m2)/r); This orbital energy acts as the condition which defines the type of orbit experienced by the bodies:  ϵ < 0: Elliptical orbit
  • 4. This corresponds to the minimum and maximum values of r for an elliptical orbit where the distances of closest and farthest approach are equal to r0/1-ε.  ϵ = 0: Parabolic orbit This corresponds to the escape velocity condition as a body is outside the bounds of another body’s gravitational force when energy is equivalent to zero i.e. .  ϵ > 0: Hyperbolic orbit (MIT.edu) In a parabolic or hyperbolic trajectory the motion is not periodic, and the duration of the full trajectory is infinite. Therefore the programprints an error message and aborts program upon the result of a parabolic or hyperbolic orbit when testing for the orbital energy conditions. The semi-major axis is half of the major axis of an ellipse which has a length from the centre to the edge of the ellipse along its principle axes. The orbital energy is used to find the semi-major axis, a, of the elliptical orbit: This is coded by sm_axis = -(G*(m1+m2))/(2*orb_energy). With the semi-major axis value, the period T of the orbit is determined through Kepler’s third law, which states that the square of the orbital period of a planet is directly proportional to the cube of the semi-major axis of its orbit: For this the value of π is declared as a fixed variable to 8 significant figures: const double pi = 3.1415926; The calculation for T is coded as: T = sqrt(fabs((4*pi*pi*sm_axis*sm_axis*sm_axis)/(G*(m1+m2)))); The program determines the time step ∆t according to this calculated period by setting . Having established the time step, the new velocities are found by accumulating the change in velocity, as related by acceleration and the time: .
  • 5. As with acceleration, this is done for each of the components of velocity for both bodies: vel_m1[0] += acc_m1[0]*dt; vel_m1[1] += acc_m1[1]*dt; vel_m2[0] += acc_m2[0]*dt; vel_m2[1] += acc_m2[1]*dt; Finally, the new positions of the bodies are calculated using the following equation of motion: where s is the displacement and u is the initial velocity. As the calculation takes within a for loop where the new velocity after each time step becomes the initial velocity for the next and likewise with position, it is coded as: pos_m1[0] += ((vel_m1[0]*dt)+(0.5*acc_m1[0]*dt*dt)); pos_m1[1] += ((vel_m1[1]*dt)+(0.5*acc_m1[1]*dt*dt)); pos_m2[0] += ((vel_m2[0]*dt)+(0.5*acc_m2[0]*dt*dt)); pos_m2[1] += ((vel_m2[1]*dt)+(0.5*acc_m2[1]*dt*dt)); The program prints the positions of both bodies into a 2D array, position, of size[1001][4] and writes a spread sheet file for excel which can then be plotted. Assumptions  The bodies are point particles; their sizes are negligible centre-to-centre distance is not considered.  If orbital energy is less than zero then orbiting body has two turning points, rmin and rmax. Body gets no closer than rminto central body and no further than rmax due to conservation of angular momentum.  The gravitational fields of the bodies are uniform.  The motion of the bodies as a result of the interaction is closed and periodic i.e. elliptical or circular orbits. Open orbits of parabolic or hyperbolic give void readings.  The two bodies are isolated from the Universe, therefore do not experience gravitational force from any other body i.e. only one central force acting.  Centre of mass of the isolated system is not accelerated.  The larger of the two masses is stationary and fixed at the origin of the system.
  • 6. Figure 1: Plot of X-Y positions of two masses, calculated by program. Program input values: Mass 1: 2E30 Initial Position: 0, 0 Initial Velocity: 0, 0 Mass 2: 6E24 Initial Position: 1.496E11, 0 Initial Velocity: 0, 29E3