Chaotic Productions LLC

Bringing You The Future Of Design and Technology

PLANETARY SCIENCE USING PYTHON


In this tutorial we will explore the solar system using Python and popular data science libraries NumPy and Matplotlib, to perform various functions and to visualize planetary data.

Conspiracies | Game Design | Illustrations | Random Generators | Science and Technology | Secret History | Tutorials


Effects of Gravity at Altitude

The planetary weight calculator allows you to calculate your weight while on the planet's surface and assumes that the surface of the planet is of uniform distance from its center. These equations therefore will not accurately reflect the weight of objects in space around Earth, or other planetary body.

Gravity is affected by only two variables and one constant. The universal gravitational constant (6.67408 * 10-11) cannot be changed and the planet's mass (5.98 * 1024) stays pretty much the same, therefore only your distance from the center of the Earth can be changed. Earth's surface is approximately 6378 * 102 km in altitude. When calculating the altitude of spacecraft and satellites, don't forget to add this distance to the distance of the spacecraft above the Earth's surface.

ge = G * Me / d2

The following Python script will allow you to to calculate your weight at any altitude above Earth.

G = 6.67408 * 10**-11 #Universal gravitational constant
mass_earth = 5.98 * 10**24 # mass of Earth in kilograms
distance_surface = 6.378 * 10**6 #distance from center of Earth to its surface, in kilometers

print("Calculate your weight at various altitudes on Earth")

normal_weight = float(input("Enter your weight in pounds:"))

mass = normal_weight / 9.8 #calculates mass based on weight given in pounds

altitude = float(input("Enter your altitude in kilometers:"))

distance_earth = distance_surface + (altitude * 1000) #calculates the distance from the center of the earth
gravity = G * mass_earth / distance_earth**2 #calculates gravitational acceleration based on the altitude given
calculated_weight = mass * gravity #calculates your weight at the altitude given

print("Your mass is:", "%.2f" % mass)
print("The gravitational force at this altitude is:", "%.2f" % gravity, "m/s^2")
print("Your weight at this altitude is:", "%.0f" % calculated_weight, "lbs")



Putting It All Together

The following python code can be cloned or downloaded from my Github repository at: https://github.com/johnathan-nicolosi/RocketScience

##########################################
# universal gravitational constant
G = 6.67408 * 10**-11 #Newton-meter^2/kilogram^2
##########################################
# The mass for each celestial body (in kilograms)
mass_earth = 5.98 * 10**24
mass_mercury = 3.30 * 10**23
mass_venus = 4.87 * 10**24
mass_mars = 6.42 * 10**23
mass_jupiter = 1.90 * 10**27
mass_saturn = 5.69 * 10**26
mass_uranus = 8.68 * 10**25
mass_neptune = 1.02 * 10**26
mass_sun = 1.99 * 10**30
mass_moon = 7.35 * 10**22
##########################################

# The radius of each celestial body (in kilometers)
radius_earth = 6378 * 10**3
radius_mercury = 2439 * 10**3
radius_venus = 6051 * 10**3
radius_mars = 3393 * 10**3
radius_jupiter = 71492 * 10**3
radius_saturn = 60268 * 10**3
radius_uranus = 25559 * 10**3
radius_neptune = 24764 * 10**3
radius_sun = 696000 * 10**3
radius_moon = 1738 * 10**3
##########################################

# The gravitational acceleration vector of each celestial body (in Newtons)
gravity_earth = G * mass_earth / radius_earth**2
gravity_mercury = G * mass_mercury / radius_mercury**2
gravity_venus = G * mass_venus / radius_venus**2
gravity_mars = G * mass_mars / radius_mars**2
gravity_jupiter = G * mass_jupiter / radius_jupiter**2
gravity_saturn = G * mass_saturn / radius_saturn**2
gravity_uranus = G * mass_uranus / radius_uranus**2
gravity_neptune = G * mass_neptune / radius_neptune**2
gravity_sun = G * mass_sun / radius_sun**2
gravity_moon = G * mass_moon / radius_moon**2
##########################################

print("Determine your weight on each planet")
normal_weight = float(input("Enter your weight in pounds (lbs):"))
mass = normal_weight * 0.4536
newton_lbf = mass * 0.22480894309971
force = mass * gravity_earth
print("")
print("Your mass is:", "%.2f" % mass, "kg")
print("The force exerted by your mass is:", "%.1f" % force, "N")
print("")

weight_earth = newton_lbf * gravity_earth
print("Your mass is:", "%.2f" % mass, "kg")
print("")
print("Your weight on Earth is:", "%.0f" % weight_earth, "lbs")
print("Earth's gravitational acceleration is: ", "%.1f" % gravity_earth)

weight_mercury = newton_lbf * gravity_mercury
print("Your weight on Mercury is:", "%.0f" % weight_mercury, "lbs")
print("Mercury's gravitational acceleration is: ", "%.1f" % gravity_mercury)

weight_venus = newton_lbf * gravity_venus
print("Your weight on Venus is:", "%.0f" % weight_venus, "lbs")
print("Venus' gravitational acceleration is: ", "%.1f" % gravity_venus)

weight_mars = newton_lbf * gravity_mars
print("Your weight on Mars is:", "%.0f" % weight_mars, "lbs")
print("Mars' gravitational acceleration is: ", "%.1f" % gravity_mars)

weight_jupiter = newton_lbf * gravity_jupiter
print("Your weight on Jupiter is:", "%.0f" % weight_jupiter, "lbs")
print("Jupiter's gravitational acceleration is: ", "%.1f" % gravity_jupiter)

weight_saturn = newton_lbf * gravity_saturn
print("Your weight on Saturn is:", "%.0f" % weight_saturn, "lbs")
print("Saturn's gravitational acceleration is: ", "%.1f" % gravity_saturn)

weight_uranus = newton_lbf * gravity_uranus
print("Your weight on Uranus is:", "%.0f" % weight_uranus, "lbs")
print("Uranus's gravitational acceleration is: ", "%.1f" % gravity_uranus)

weight_neptune = newton_lbf * gravity_neptune
print("Your weight on Neptune is:", "%.0f" % weight_neptune, "lbs")
print("Neptune's gravitational acceleration is: ", "%.1f" % gravity_neptune)

weight_sun = newton_lbf * gravity_sun
print("Your weight on the Sun is:", "%.0f" % weight_sun, "lbs")
print("Sun's gravitational acceleration is: ", "%.1f" % gravity_sun)

weight_moon = newton_lbf * gravity_moon
print("Your weight on the Moon is:", "%.0f" % weight_moon, "lbs")
print("Moon's gravitational acceleration is: ", "%.1f" % gravity_moon)



Johnathan Nicolosi - 13 Jun 2018