### Categories

### Art and Web Design

Contact me for information about rates and availability.

### Latest Articles

### Gravitational Acceleration

In this section, we will explore the gravitational forces of the Sun and planets using Python and then learn how to plot these features for comparison using Matplotlib. For this tutorial we will be storing the mass and radius of each planet as a list of intergers and then calculating the gravitational acceleration (g_{p}) and gravitational parameters (μ) for each planet.

Planetary Body (p) | Mass (m) | Radius (r) | Gravity (g_{p}) |
---|---|---|---|

Mercury | 3.30 x 10^{23} kg |
2439 km | 3.7 N |

Venus | 4.87 x 10^{24} kg |
6051 km | 8.9 N |

Earth | 5.98 x 10^{24} kg |
6378 km | 9.8 N |

Mars | 6.42 x 10^{23} kg |
3393 km | 3.7 N |

Jupiter | 1.90 x 10^{27} kg |
71492 km | 24.8 N |

Saturn | 5.69 x 10^{26} kg |
60268 km | 10.5 N |

Uranus | 8.68 x 10^{25} kg |
25559 km | 8.9 N |

Neptune | 1.02 x 10^{26} kg |
24764 km | 11.1 N |

Sun | 1.99 x 10^{30} kg |
696000 km | 274.2 N |

Moon | 7.35 x 10^{22} kg |
1738 km | 1.6 N |

The gravitational fields of each celestial body in our solar system can agaib be visualized using

*Matplotlib*.

import matplotlib.pyplot as plt

solar_system_bodies = ['Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn', 'Uranus', 'Neptune', 'Sun', 'Moon']

# The mass for each celestial body (in kilograms)

mass_mercury = 3.30 * 10**23

mass_venus = 4.87 * 10**24

mass_earth = 5.98 * 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_mercury = 2439 * 10**3

radius_venus = 6051 * 10**3

radius_earth = 6378 * 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_mercury = gravitational_constant * mass_mercury / radius_mercury**2

gravity_venus = gravitational_constant * mass_venus / radius_venus**2

gravity_earth = gravitational_constant * mass_earth / radius_earth**2

gravity_mars = gravitational_constant * mass_mars / radius_mars**2

gravity_jupiter = gravitational_constant * mass_jupiter / radius_jupiter**2

gravity_saturn = gravitational_constant * mass_saturn / radius_saturn**2

gravity_uranus = gravitational_constant * mass_uranus / radius_uranus**2

gravity_neptune = gravitational_constant * mass_neptune / radius_neptune**2

gravity_sun = gravitational_constant * mass_sun / radius_sun**2

gravity_moon = gravitational_constant * mass_moon / radius_moon**2

# Create a list of the gravitational fields of each planet

gravity_planets = [gravity_mercury, gravity_venus, gravity_earth, gravity_mars, gravity_jupiter, gravity_saturn, gravity_uranus, gravity_neptune, gravity_sun, gravity_moon]

plt.figure(2)

plt.barh( solar_system_bodies, gravity_planets, color=(0.1, 0.1, 0.1, 0.1), edgecolor='blue')

plt.xlabel('Gravity (N)')

plt.ylabel('Planets')

plt.title('Gravitational Field of each solar body')

plt.show()

solar_system_bodies = ['Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn', 'Uranus', 'Neptune', 'Sun', 'Moon']

# The mass for each celestial body (in kilograms)

mass_mercury = 3.30 * 10**23

mass_venus = 4.87 * 10**24

mass_earth = 5.98 * 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_mercury = 2439 * 10**3

radius_venus = 6051 * 10**3

radius_earth = 6378 * 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_mercury = gravitational_constant * mass_mercury / radius_mercury**2

gravity_venus = gravitational_constant * mass_venus / radius_venus**2

gravity_earth = gravitational_constant * mass_earth / radius_earth**2

gravity_mars = gravitational_constant * mass_mars / radius_mars**2

gravity_jupiter = gravitational_constant * mass_jupiter / radius_jupiter**2

gravity_saturn = gravitational_constant * mass_saturn / radius_saturn**2

gravity_uranus = gravitational_constant * mass_uranus / radius_uranus**2

gravity_neptune = gravitational_constant * mass_neptune / radius_neptune**2

gravity_sun = gravitational_constant * mass_sun / radius_sun**2

gravity_moon = gravitational_constant * mass_moon / radius_moon**2

# Create a list of the gravitational fields of each planet

gravity_planets = [gravity_mercury, gravity_venus, gravity_earth, gravity_mars, gravity_jupiter, gravity_saturn, gravity_uranus, gravity_neptune, gravity_sun, gravity_moon]

plt.figure(2)

plt.barh( solar_system_bodies, gravity_planets, color=(0.1, 0.1, 0.1, 0.1), edgecolor='blue')

plt.xlabel('Gravity (N)')

plt.ylabel('Planets')

plt.title('Gravitational Field of each solar body')

plt.show()

This graph quickly tells us that the sun is the dominate gravitational force in the solar system, but it makes it harder to compare the terrestrial inner planets and the gaseous outter planets. If we remove the sun and moon from these equations, the remaining data becomes more meaningful.

Before we can calculate our weight on other planets, let's first take a moment to talk about weight on Earth and how we calculate it. Like most people, you probably stand on a scale to calculate your weight, but scientists have to do it the hard way and calculate their weight by multiplying their mass by the gravitational acceleration of Earth.

w

_{e}= m * g

_{e}

# Calculate weight on earth

weight_earth = mass * gravity_earth

weight_earth = mass * gravity_earth

What if you do not know the object's mass, but you know it's weight? You can simply calculate for mass by multiplying the object's weight (on Earth) by 0.4536.

# Calculate mass by multiplying the object's weight by 0.4536

mass = weight * 0.4536

mass = weight * 0.4536

We will calculate the gravitational force of each planetary boy in Python by adding the above data lists or dictionaries In order to derive your mass from your weight, simply divide your weight (as determined by a digital or analog scale) by Earth's gravitational parameter of 9.8.

m = w/9.8

In the following code, we will store the gravitational parameters calculated earlier as a dictionary. This will allow us to retrieve the data and perform calculations on it using our scripts. The user will be asked to enter the weight of an object (in lbs). The user's input can then be used to calculate the object's weight on any planetary body by calculating its mass (kg).

# Gravitational parameters represent the amount of gravitational acceleration centered on each body in space

gravitational_parameter = {

'Mercury': gravity_mercury,

'Venus': gravity_venus,

'Earth': gravity_earth,

'Mars': gravity_mars,

'Jupiter': gravity_jupiter,

'Saturn': gravity_saturn,

'Uranus': gravity_uranus,

'Neptune': gravity_neptune,

'Sun': gravity_sun,

'Moon': gravity_moon

}

# to obtain an object's mass, user must enter it's weight (in pounds)

weight = int(input("Enter weight of object (in lbs):"))

planet mass = weight / gravitational_parameter

gravitational_parameter = {

'Mercury': gravity_mercury,

'Venus': gravity_venus,

'Earth': gravity_earth,

'Mars': gravity_mars,

'Jupiter': gravity_jupiter,

'Saturn': gravity_saturn,

'Uranus': gravity_uranus,

'Neptune': gravity_neptune,

'Sun': gravity_sun,

'Moon': gravity_moon

}

# to obtain an object's mass, user must enter it's weight (in pounds)

weight = int(input("Enter weight of object (in lbs):"))

planet mass = weight / gravitational_parameter

Johnathan
Nicolosi - 13 June 2018