In this notebook we will compute the pressure profile from the temperature profile with data for the martian atmosphere.
The figure below is a combination of daytime temperature measurements (in Kelvin) from the Mars orbiter (lines), i.e. from above the atmosphere, and from the Mars rover (dots), i.e. from the ground. The rover measures accurately up to a height of about $6$ km, the orbiter measures accurately above a height of about $3$ km.
Image Credit: NASA/JPL/Goddard/ASU/Cornell
Let us first derive the key equation that allows us to compute the pressure profile. We know that the pressure, $p(z)$, changes with height according to the "local weight" of the atmosphere \begin{equation} \frac{dp}{dz}=-\rho(z)\,g, \label{eq:1} \end{equation} where $z$ is the height above ground, $\rho$ is the local density and $g$ is the gravitational constant. We assume that $g$ does not vary much for the heights considered here. In other words, $z$ is much smaller than the radius of the planet.
Using the ideal gas law, we can substitute \begin{equation} \rho(z)=\frac{p(z)\,M}{R\,T(z)} \label{eq:2} \end{equation} into the above equation. Here, $M$ is the molecular weight of the (local) atmosphere, assumed to be well-mixed and therefore to be constant with respect to height, $R$ is the ideal gas constant and $T$ the temperature. Plugging \eqref{eq:2} into \eqref{eq:1} yields an ordinary differential equation for the pressure \begin{equation} \frac{dp}{dz}=-\frac{p(z)\,M}{R\,T(z)}g. \end{equation} Separation of variables and integration from the ground up to a height $z$ gives \begin{equation} p(z)=p_0\,\exp\left[ -\int_0^z \frac{d\hat z}{H(\hat z)} \right] \label{eq:3} \end{equation} with the scale height $H(z)=RT(z)/(gM)$.
For constant $T$, the scale height $H$ gives the length over which the pressure decreases by a factor of $e$. NASA states that $H=11.1$ km but that depends on daytime and nighttime.
Next, we approximate the temperature data points in the figure above by the following fit ($z$ in km) \begin{equation} T(z)=234.0-2.25z+14e^{-2z}. \end{equation} Computing the pressure at a given height $z$ relative to that on the ground then comes down to computing the integral \eqref{eq:3}. This integral cannot be solved analytically. Hence, we resort to Simpson's rule. Essentially, we need to calculate \begin{equation} \int_0^z \frac{d\hat z}{T(\hat z)} \end{equation} for some given value of $z$.
We use the values for $g$ and $M$ found on NASA's web site and we are interested in the pressure relative to the ground at a height of $15$ km. The calculation using Simpson's rule is donw below.
import numpy as np
R = 8.314 # universal gas constant
g = 3.71 # gravitational constant on Mars (at ground)
M = 0.04334 # mean molecular weight near ground (on Mars) in kg/mole
z0 = 0.0 # defining the interval (ground level)
z1 = 15.0 # defining the interval (height; in km)
N = 100 # defining the amount of points for Simpson's rule
h = (z1-z0)/(N-1) # defining the length of each interval
# computing the integral
F=0;
for i in range(N):
z = z0 + i*h
f = 1/(234.0-2.25*z+14.0*np.exp(-2.0*z))
if (i==0) or (i==N-1): # if we are at the left or right end of the main
# interval
F = F + f
else:
if i%2==0: # if we are at an "even" point
F = F + 4*f
else: # if we are at an "odd" point
F = F + 2*f
integral = (1000.0*h/3)*(-g*M/R)*F # evaluating the integral
# (factor 1000 due to km to m conversion)
# computing the change in pressure
percentage = 100*np.exp(integral) # pressure at z1 compared to z0 in percent
print("Integral value %f, change in pressure in percent is %f" % (integral, percentage))
Integral value -1.332386, change in pressure in percent is 26.384705