{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"\n",
"\n",
"# Martian Atmosphere\n",
"\n",
"### Examples - Thermodynamics\n",
"\n",
"By Magnus A. Gjennestad, Vegard Hagen, Aksel Kvaal, Morten Vassvik, Trygve B. Wiig and Peter Berg\n",
"\n",
"Last edited: March 15th 2018 \n",
"___"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In this notebook we will compute the pressure profile from the temperature profile with data for the martian atmosphere."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Temperature Profile"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The figure below is a combination of daytime \n",
"temperature measurements (in Kelvin) from the Mars orbiter (lines), i.e. from\n",
"above the atmosphere, and from the Mars rover (dots), i.e. from the ground. The rover measures accurately \n",
"up to a height of about $6$ km, the orbiter measures accurately above a height of about $3$ km.\n",
"\n",
"\n",
"\n",
"Image Credit: NASA/JPL/Goddard/ASU/Cornell "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Pressure Profile"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let us first derive the key equation that allows us to compute the pressure profile. \n",
"We know that the pressure, $p(z)$, changes with height according to the \"local weight\" \n",
"of the atmosphere\n",
"\\begin{equation}\n",
"\\frac{dp}{dz}=-\\rho(z)\\,g,\n",
"\\label{eq:1}\n",
"\\end{equation}\n",
"where $z$ is the height above ground, $\\rho$ is the local density and $g$ is the gravitational constant.\n",
"We assume that $g$ does not vary much for the heights considered here. In other words,\n",
"$z$ is much smaller than the radius of the planet. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Using the ideal gas law, we can substitute\n",
"\\begin{equation}\n",
"\\rho(z)=\\frac{p(z)\\,M}{R\\,T(z)}\n",
"\\label{eq:2}\n",
"\\end{equation}\n",
"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.\n",
"Plugging \\eqref{eq:2} into \\eqref{eq:1} yields an ordinary differential equation for the pressure\n",
"\\begin{equation}\n",
"\\frac{dp}{dz}=-\\frac{p(z)\\,M}{R\\,T(z)}g.\n",
"\\end{equation}\n",
"Separation of variables and integration from the ground up to a height $z$ gives\n",
"\\begin{equation}\n",
"p(z)=p_0\\,\\exp\\left[ -\\int_0^z \\frac{d\\hat z}{H(\\hat z)} \\right]\n",
"\\label{eq:3}\n",
"\\end{equation}\n",
"with the __scale height__ $H(z)=RT(z)/(gM)$."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For constant $T$, the scale height $H$ gives the length over which the pressure decreases by a factor \n",
"of $e$. NASA states that $H=11.1$ km but that depends on daytime and nighttime.\n",
"\n",
"Next, we approximate the temperature data points in the figure above by the following fit\n",
"($z$ in km)\n",
"\\begin{equation}\n",
"T(z)=234.0-2.25z+14e^{-2z}.\n",
"\\end{equation}\n",
"Computing the pressure at a given height $z$ relative to that on the ground then comes down \n",
"to computing the integral \\eqref{eq:3}. This integral cannot be solved analytically. Hence, we resort \n",
"to __Simpson's rule__. Essentially, we need to calculate\n",
"\\begin{equation}\n",
"\\int_0^z \\frac{d\\hat z}{T(\\hat z)} \n",
"\\end{equation}\n",
"for some given value of $z$."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We use the values for $g$ and $M$ found on [NASA's web site](http://nssdc.gsfc.nasa.gov/planetary/factsheet/marsfact.html)\n",
"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."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Integral value -1.332386, change in pressure in percent is 26.384705\n"
]
}
],
"source": [
"R = 8.314 # universal gas constant\n",
"g = 3.71 # gravitational constant on Mars (at ground)\n",
"M = 0.04334 # mean molecular weight near ground (on Mars) in kg/mole\n",
"\n",
"z0 = 0.0 # defining the interval (ground level)\n",
"z1 = 15.0 # defining the interval (height; in km)\n",
"N = 100 # defining the amount of points for Simpson's rule\n",
"h = (z1-z0)/(N-1) # defining the length of each interval\n",
"\n",
"# computing the integral\n",
"F=0; \n",
"\n",
"for i in range(N):\n",
" z = z0 + i*h\n",
" f = 1/(234.0-2.25*z+14.0*np.exp(-2.0*z))\n",
" if (i==0) or (i==N-1): # if we are at the left or right end of the main\n",
" # interval\n",
" F = F + f\n",
" else:\n",
" if i%2==0: # if we are at an \"even\" point\n",
" F = F + 4*f\n",
" else: # if we are at an \"odd\" point\n",
" F = F + 2*f\n",
"\n",
" \n",
"integral = (1000.0*h/3)*(-g*M/R)*F # evaluating the integral \n",
" # (factor 1000 due to km to m conversion) \n",
"\n",
"# computing the change in pressure \n",
"percentage = 100*np.exp(integral) # pressure at z1 compared to z0 in percent\n",
"\n",
"print(\"Integral value %f, change in pressure in percent is %f\" % (integral, percentage))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.4"
}
},
"nbformat": 4,
"nbformat_minor": 1
}