Download or view MarsAtmosphere.frink in plain text format
/** This is an improved, simplified model of Mars's atmosphere by Alan Eliasen
based on NASA's Mars-GRAM observations model. (The old version has been
moved to MarsAtmosphereOld.frink )
It is intended to fit the data with a minimum number of parameters but with
a very good fit to observed data.
If you want the version with the full un-truncated coefficients, that is
in MarsAtmosphereFull.frink
The equations are produced by parsing multiple Mars-GRAM data files by
MarsAtmosherePlot.frink . It is calibrated between the latitudes of
-30 to +30 degrees.
It is fitted on data from -5 to 170 km altitude so those should be
considered the limits of validity, but the exponential fits on pressure and
density seem to be quite linear over the range of the data so you might be
justified in trying to extrapolate beyond that.
*/
class MarsAtmosphere
{
/** Calculate the temperature at a given altitude. This is a piecewise
polynomial fit of degree 6 in two pieces. Temperature is a curve that
goes back and forth which is why this is the most complicated equation.
It has an r-value of 0.9992498 */
class temperature[altitude is length] :=
{
if altitude < 75000 m
return 5.28263e-22 K m^-5 altitude^5 +
-1.08433e-16 K m^-4 altitude^4 +
8.19905e-12 K m^-3 altitude^3 +
-2.44401e-7 K m^-2 altitude^2 +
4.53041e-4 K m^-1 altitude +
218.955 K
else
return 2.46395e-22 K m^-5 altitude^5 +
-1.50891e-16 K m^-4 altitude^4 +
3.56144e-11 K m^-3 altitude^3 +
-4.01715e-6 K m^-2 altitude^2 +
0.215221 K m^-1 altitude +
-4225.62 K
}
/** Calculate the pressure at a given altitude. This is an exponential
piecewise fit in two pieces. It has an r-value of 0.999974. */
class pressure[altitude is length] :=
{
if altitude < 15000 m
return 575.497 e^(-9.11710e-5 m^-1 altitude) kg m^-1 s^-2
else
return 887.544 e^(-1.24149e-4 m^-1 altitude) kg m^-1 s^-2
}
/** Calculate the atmospheric density at a given altitude. This is an
exponential piecewise fit in two pieces. It has an r-value of
0.99963887. */
class density[altitude is length] :=
{
if altitude < 40000 m
return 0.0143300 e^(-9.35232e-5 m^-1 altitude) kg m^-3
else
return 0.0395351 e^(-1.27446e-4 m^-1 altitude) kg m^-3
}
/** Convenience method to return [temperature, pressure, density] for the
specified altitude. This is to match the old model. */
class getTPD[altitude is length] :=
{
return [temperature[altitude], pressure[altitude], density[altitude]]
}
}
Download or view MarsAtmosphere.frink in plain text format
This is a program written in the programming language Frink.
For more information, view the Frink
Documentation or see More Sample Frink Programs.
Alan Eliasen was born 20139 days, 7 hours, 1 minutes ago.