Astropy Units and Quantities

Exercise Solutions

Exercise 1

The James Webb Space Telescope (JWST) is in a halo orbit around the second Sun-Earth Lagrange (L2) point:

         ☀️                                  🌎        L2              (not to scale)

L2 is located at a distance from the Earth (opposite the Sun) of approximately:

$$ r \approx R \left(\frac{M_{earth}}{3 M_{sun}}\right) ^{(1/3)} $$

where $R$ is the Sun-Earth distance.

Calculate the Earth-L2 distance in kilometers and miles.

Hints:

In [ ]:
import astropy.units as u
from astropy import constants as const
In [ ]:
d_earth = u.au * (1. * const.M_earth / (3. * const.M_sun))**(1./3)
d_earth.to(u.km)
In [ ]:
d_earth.to(u.imperial.mile)

Exercise 2

The L2 point is about 1.5 million kilometers away from the Earth opposite the Sun. The total mass of the James Webb Space Telescope (JWST) is about 6500 kg.

Using the value you obtained above for the Earth-L2 distance, calculate the gravitational force in Newtons between:

  • JWST (at L2) and the Earth
  • JWST (at L2) and the Sun

Hint: the gravitational force between two masses separated by a distance r is:

$$ F_g = \frac{G m_1 m_2}{r^2} $$
In [ ]:
m_JWST = 6500. * u.kg
F = (const.G * const.M_earth * m_JWST) / d_earth**2
F.to(u.N)
In [ ]:
d_sun = d_earth + 1. * u.au
F = (const.G * const.M_sun * m_JWST) / d_sun**2
F.to(u.N)

Exercise 3

Calculate the Schwarzschild radius in units of solar radii of the Sgr A*, the Milky Way's supermassive black hole with $M = 4.31 \times 10^6 M_\odot$, given

$$r_\mathrm{s} = \frac{2 G M}{c^2}$$

Also calculate the angular size of the event horizon on the sky in microarcseconds, given the distance to the galactic center $d_{center} = 7.94$ kpc, given

$$\theta = \mathrm{arctan}\frac{2 r_\mathrm{s}}{d_{center}}$$
In [ ]:
# Schwarzschild radius:
bh_mass = 4.31e6 * u.Msun
r_s = 2 * const.G * bh_mass / const.c**2
print("Schwarzschild radius = ", r_s.to(u.Rsun))
In [ ]:
# Size on the sky given small angle approximation
import numpy as np
sgr_a_distance = 7940 * u.pc
angular_diameter = np.arctan(2 * r_s / sgr_a_distance)
angular_diameter.to(u.uarcsec)

Exercise 4

We can make a very rough estimate of the temperature of material in the vicinity of Sgr A* by assuming hydrostatic equilibrium, so that the thermal energy of the gas balances the gravitational force:

$$ kT \sim GM m_p /R $$

where $m_p$ is the mass of a proton and $R$ is the distance away from the black hole. Using Astropy constants and the properties of Sgr A* described in Example 3, compute the temperature of the gas required to balance the black hole's gravitation pull at 1 million Schwarzschild radii derived above. Use this equation:

$$ T = \frac{G M m_p}{10^6 r_s k} $$

Then use the Astropy units temperature equivalencies to find the energy of that gas.

In [ ]:
# Temperature calculation
radius = 1e6 * r_s
temperature = (const.G * bh_mass * const.m_p) / (radius * const.k_B)
temperature.to('K')
In [ ]:
# Energy calculation
temperature.to('keV', equivalencies=u.temperature_energy())
In [ ]: