Space Science Blog

Bringing You The Future Of Science and Technology

EFFECTS OF GRAVITY AT ALTITUDE


In this tutorial we will use Python and Matplotlib to explore the effects of altitude on the forces of gravity. This is because the gravitational force above the Earth's surface is proportional to 1/R2, where R is your distance from the center of the Earth.

Artificial Intelligence | DIY Electronics Projects | Game Design Workshop | Random Generators | Planetary Science | Rocket Science


Categories

Art and Web Design

Contact me for information about rates and availability.


Latest Articles

 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 constants and one variable. The universal gravitational constant (6.67408 * 10-11) cannot be changed and Earth'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.8 km in radius.

When calculating the altitude of spacecraft and satellites, don't forget to add this distance (converted to meters) to the altitude of the spacecraft above the Earth's surface. Also consider that the Earth is not a perfect sphere, but rather appears to be squashed, with more mass distributed around the equator. This means that the gravitational attraction is greater above the equator than at the poles. Due to its squashed appearance, Earth is called an oblate spheroid.

ge = G * Me / d2
G = 6.67408-11
Me = 5.9824 kg
Re = 6378.8 km

In this tutorial, we will create a Python program to calculate our weight, or the weight of a flying object, at any point above the surface of the Earth. To do this, we will need to know the weight of the object at sea level, measured in pounds (lbs). Our program will convert the weight of the object into its respective mass, which we will then use to determine its weight in the sky above the Earth's surface.

Before we begin, let us try to understand a little more about gravity on Earth. As we learned in school, the standard acceleration of gravity at sea level (g0) equals 9.80665 m/sec2. How do we know this? We can use the above equations to calculate gravity at sea level (substituting d for Re).

ge = 6.67408-11 * 5.9824 / 6378.82
ge = 9.80877157717 m/sec2

The above equation can be used to calculate the gravitational acceleration on any planetary body, including the moon, as described in my Planetary Weight Calculator tutorial. We do this simply by substituting Earth's mass and radius with those of the planetary body under investigation.

We can perform these calculations in Python, as shown in the code below:

>>> G = 6.67408 * 10**-11 # Universal gravitational constant >>> mass_earth = 5.98 * 10**24 # mass of Earth in kilograms >>> radius_earth = 6378.8 * 10**3 # distance from center of Earth to its surface, converted to meters >>> gravity_earth = G * mass_earth / radius_earth**2 # calculates gravitational acceleration at sea level >>> gravity_earth 9.80877157717


Now that we have figured out how to calculate the gravitational acceleration at sea level, the next step is to calculate gravity at any distance above the Earth's surface. To do this, we create a new variable called object_altitude. Before we can call this variable, we will need to get the altitude (in kilometers) from the user, which we will store in another variable named altitude. To accomplish this, we will need to call upon Python's input function (the input function is a built-in function). Note that altitude is a floating point number and not an integer.

>>> altitude = float(input("Enter your altitude in kilometers:")) >>> object_altitude = radius_earth + (altitude * 1000) # (altitude * 1000) converts altitude from kilometers to meters >>> gravity_altitude = G * mass_earth / object_altitude**2 # calculates gravitational acceleration based on the altitude given


Next we will convert the weight of an object to its mass, using the standard acceleration of gravity at sea level (g0). This will allow us to then calculate the weight of the object at the given altitude. To do this, we need to create another variable, named normal_weight, and we will again call on the input function to retrieve the weight of the object and assign it to our variable.

Once we have obtained the weight of the object, at sea level, we can convert from weight to mass by dividing the weight by the gravitational acceleration at sea level. Lastly, we can convert the object's mass back to weight, at the altitude provided by multiplying its mass by the gravity_altitude variable we just created.

>>> normal_weight = float(input("Enter your weight in pounds:")) >>> mass = normal_weight / gravity_earth # calculates mass based on weight given in pounds >>> calculated_weight = mass * gravity_altitude # calculates your weight at the altitude given




 Complete Code


The following Python script will allow you to to calculate your weight at any altitude above Earth. Create a new Python file, name it weight_calculator_altitude.py, copy and paste the below code, then save and run. You can also download the Python sorce code from my GitHub repository at: github.com/johnathan-nicolosi/PlanetaryScience/.


######################################################## # # # Effects of Gravity at Altitude # # Written by Johnathan Nicolosi # # June 13, 2018 # # # ######################################################## # Declare Constants G = 6.67408 * 10**-11 # Universal gravitational constant mass_earth = 5.98 * 10**24 # mass of Earth in kilograms radius_earth = 6378.8 * 10**3 # distance from center of Earth to its surface, in meters # Prints program title print("Effects of Gravity at Altitude") # Retrieves weight of object from user normal_weight = float(input("Enter your weight in pounds:")) # Converts from weight to mass mass = normal_weight / 9.81 # calculates mass based on weight given in pounds # Retrieves altitude of object from user altitude = float(input("Enter your altitude in kilometers:")) # Calculates weight of object at altitude specified object_altitude = radius_earth + (altitude * 1000) # calculates the distance from the center of the earth gravity_altitude = G * mass_earth / object_altitude**2 # calculates gravitational acceleration based on the altitude given calculated_weight = mass * gravity_altitude # calculates your weight at the altitude given # Prints mass, altitude and weight of object to console 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")



Johnathan Nicolosi - 13 Jun 2018