Program 1 – Satellite In Orbit Simulation
Comp 170
Due: September
2, 2001
Write a flowchart and C++
program that will; conclude a satellite is in perfect orbit, conclude a
satellite will continue to travel away from the earth indefinitely, or report
the distance from earth and net velocity of a satellite each second until it
hits Earth’s surface.
Assumptions:
The satellite was propelled
into space for you.
The satellite will never
run out of propulsion fuel.
The satellite will maintain
its initial away velocity.
The satellite starts the
simulation with a net velocity of 0.
All friction with the
Earth’s atmosphere will be ignored.
Variables to collect from user:
|
Satellite away velocity |
Value set by user will
never change (meters / second) |
|
Mass of satellite |
Value set by user will
never change (kg) |
|
Distance from surface of
earth |
Value set by user will
change each second unless the satellite happens to be in perfect orbit
(meters) |
Constants:
|
Constant |
Value |
|
Radius of Earth |
6378000.14 (meters) |
|
Mass of Earth |
5.9736e+24 (kg) |
|
Universal Gravitational
Constant |
6.669531020394004e-11(Newtons) |
|
Earths Gravitational
Constant |
398411105034256.222944(Newtons
x Kg) |
Formulas:
Earth’s gravitational
force is measured in Newtons. It is a
measure of the amount of force the earth’s gravitational field is pulling on an
object. It is calculated as follows:
Earth’s
gravitational force = (earth’s gravitational constant * mass of satellite) /
Satellite distance from center of Earth2
Centripetal force is measured in Newtons. It is the centrally directed force exerted on a body moving in a
curved direction. In our scenario this
is the force working against the Earth’s gravitational force keeping a
satellite in orbit. It is calculated as
follows:
Centripetal
force = (mass of satellite * satellite away velocity2) / Satellite
distance from center of Earth
Net force is measured in Newtons. It is the difference between the centripetal force and Earth’s
gravitational force. 0 indicates a
prefect orbit. A positive value
indicates that too much centripetal force has been applied and the satellite
will continue to travel away from the earth indefinitely. A negative value indicates that not enough
centripetal force was applied and the satellite will eventually collide with
the surface of Earth.
Net
force = centripetal force - Earth’s gravitational force
Acceleration due to
gravity is measured in meters per
second squared. It is defined as “The
rate of change of velocity with respect to time.
Acceleration
due to gravity = |Net force| / Mass of
satellite
Net velocity is measured in meters per second. It is the measure of speed from a third
party’s prospective. It is the speed
the satellite is actually traveling toward or away from the earth.
Net
velocity = net velocity + acceleration due to gravity
Distance traveled in
last second is measured in
meters. It is how far the satellite
traveled during the previous second.
Distance
traveled in last second = (net velocity + previous net velocity) / 2
How it all works:
Imagine a man rowing up
stream in a canoe; we will call him Bob.
He has a velocity of 5 mph but the river is flowing in the opposite
direction at 4 miles per hour. A
heckler, named Tom, is on shore in a lawn chair with a radar gun. He yells to Bob “You are only going 1 mile
per hour.” Without looking up at Tom,
Bob yells back “Leave me alone, I know I am going 5 mph.” Frustrated Bob looses strength and slows
down to 4 mph. Tom now becomes
frightened because Bob appears to have stopped in the river right beside
him. Tom knows that he is not a match
for someone who can row a canoe at “1mph” so he begins to hurl rocks at Bob and
knocks him out. Bob, now not rowing at
all, begins to be pulled down stream at 4 mph.
Tom runs away because he knows that anyone who can row backward at 4 mph
would crush him with one blow.
Lesson #1 – Velocity is
relative to your prospective.
Lesson #2 – Bob and Tom are
idiots.
This assignment deals with
the same issues as Bob and Tom. We have
a satellite traveling at a given velocity; you are guaranteed that the
satellite will maintain this velocity.
We also have to deal with the Earth’s gravitational field pulling the
satellite toward its surface. You have
been given formulas above for the necessary calculations. You must recalculate the Earth’s
gravitational force, centripetal force, net force, net velocity, and distance
traveled during the last second for each second of the simulation. Do not forget to subtract out the distance
traveled during the last second from your distance from center of earth. Stop the simulation when the satellite
reaches the surface of the earth, is in perfect orbit, or you continues to
travel away from the earth indefinitely.
Note:
·
Use the “long double”
data type for all variables.
·
Use descriptive variable
names. The more descriptive you are the
more understandable your code will be.
·
Do not wait until the
last minute to ask questions.
·
Do your own work.
Step Length:
Allow the user to input the
time interval for the each step in the simulation. The simulation description
to this point assumes that each step represents 1 sec. You will need to slightly modify a couple of
the formulas to do this. Remember, the
smaller the time interval the more accurate the simulation.
Example Runs:
Satellite away velocity (meters/second):
7598.732779880941
Initial distance from surface of earth
(meters): 521999.86
Mass of satellite (kg): 10000
Step length (sec): 1
Perfect orbit
Satellite away velocity (meters/second): 9000
Initial distance from surface of earth
(meters): 5000000
Mass of satellite (kg): 7500
Step length (sec): 1
Escaping Earth's gravitational pull
Satellite away velocity (meters/second): 10
Initial distance from surface of earth
(meters): 100
Mass of satellite (kg): 800
Step length (sec): 1
Time (sec)
Altitude(meters) Velocity(meters/sec)
1 95.1031356128 9.7937287748
2 80.4125349317 19.5874725880
3 55.9281678787 29.3812615172
4 21.6499742996 39.1751256402
5 -22.4221360385 48.9690950363
Satellite away velocity (meters/second):
7598.73
Initial distance from surface of earth
(meters): 521999.86
Mass of satellite (kg): 10000
Step length (sec): 1
Time (sec)
Altitude(meters) Velocity(meters/sec)
1 521999.8599969391 0.0000061228
2 521999.8599877553 0.0000122456
3 521999.8599724481 0.0000183683
4 521999.8599510184 0.0000244911
5 521999.8599234661 0.0000306140
6 521999.8598897904 0.0000367368
7 521999.8598499922 0.0000428598
8 521999.8598040706 0.0000489827
9 521999.8597520264 0.0000551057
10 521999.8596938588 0.0000612288
.
.
.
11061 5922.0307479007 598.2863149720
11062 5323.3788412400 599.0174983497
11063 4723.9952584617 599.7496672059
11064 4123.8790133074 600.4828231026
11065 3523.0291179540 601.2169676047
11066 2921.4445830118 601.9521022806
11067 2319.1244175211 602.6882287014
11068 1716.0676289499 603.4253484415
11069 1112.2732231896 604.1634630784
11070 507.7402045541 604.9025741928
11071 -97.5324242264 605.6426833683