# Barometric formula

The barometric formula, sometimes called the exponential atmosphere or isothermal atmosphere, is a formula used to model how the pressure (or density) of the air changes with altitude. The pressure drops approximately by 11.3 Pa per meter in first 1000 meters above sea level.

## Pressure equations

Pressure as a function of the height above the sea level

There are two different equations for computing pressure at various height regimes below 86 km (or 278,400 feet). The first equation is used when the value of standard temperature lapse rate is not equal to zero:

${\displaystyle {P}=P_{b}\cdot \left[{\frac {T_{b}}{T_{b}+L_{b}\cdot (h-h_{b})}}\right]^{\textstyle {\frac {g_{0}\cdot M}{R^{*}\cdot L_{b}}}}}$

The second equation is used when standard temperature lapse rate equals zero:

${\displaystyle P=P_{b}\cdot \exp \left[{\frac {-g_{0}\cdot M\cdot (h-h_{b})}{R^{*}\cdot T_{b}}}\right]}$

where:

${\displaystyle P_{b}}$ = static pressure (Pa)
${\displaystyle T_{b}}$ = standard temperature (K)
${\displaystyle L_{b}}$ = standard temperature lapse rate (K/m) in ISA
${\displaystyle h}$ = height above sea level (m)
${\displaystyle h_{b}}$ = height at bottom of layer b (meters; e.g., h1 = 11 000 m)
${\displaystyle R^{*}}$ = universal gas constant: 8.3144598 J/mol/K
${\displaystyle g_{0}}$ = gravitational acceleration: 9.80665 m/s2
${\displaystyle M}$ = molar mass of Earth's air: 0.0289644 kg/mol

Or converted to imperial units:[1]

where

${\displaystyle P_{b}}$ = static pressure (inches of mercury, inHg)
${\displaystyle T_{b}}$ = standard temperature (K)
${\displaystyle L_{b}}$ = standard temperature lapse rate (K/ft) in ISA
${\displaystyle h}$ = height above sea level (ft)
${\displaystyle h_{b}}$ = height at bottom of layer b (feet; e.g., h1 = 36,089 ft)
${\displaystyle R^{*}}$ = universal gas constant; using feet, kelvins, and (SI) moles: 8.9494596×104 lb·ft2/(lb-mol·K·s2)
${\displaystyle g_{0}}$ = gravitational acceleration: 32.17405 ft/s2
${\displaystyle M}$ = molar mass of Earth's air: 28.9644 lb/lb-mol

The value of subscript b ranges from 0 to 6 in accordance with each of seven successive layers of the atmosphere shown in the table below. In these equations, g0, M and R* are each single-valued constants, while P, L, T, and h are multivalued constants in accordance with the table below. The values used for M, g0, and R* are in accordance with the U.S. Standard Atmosphere, 1976, and the value for R* in particular does not agree with standard values for this constant.[2] The reference value for Pb for b = 0 is the defined sea level value, P0 = 101 325 Pa or 29.92126 inHg. Values of Pb of b = 1 through b = 6 are obtained from the application of the appropriate member of the pair equations 1 and 2 for the case when h = hb+1.[2]

Subscript b Height above sea level Static pressure Standard temperature
(K)
Temperature lapse rate
(m) (ft) (Pa) (inHg) (K/m) (K/ft)
0 0 0 101 325.00 29.92126 288.15 -0.0065 -0.0019812
1 11 000 36,089 22 632.10 6.683245 216.65 0.0 0.0
2 20 000 65,617 5474.89 1.616734 216.65 0.001 0.0003048
3 32 000 104,987 868.02 0.2563258 228.65 0.0028 0.00085344
4 47 000 154,199 110.91 0.0327506 270.65 0.0 0.0
5 51 000 167,323 66.94 0.01976704 270.65 -0.0028 -0.00085344
6 71 000 232,940 3.96 0.00116833 214.65 -0.002 -0.0006096

## Density equations

The expressions for calculating density are nearly identical to calculating pressure. The only difference is the exponent in Equation 1.

There are two different equations for computing density at various height regimes below 86 geometric km (84 852 geopotential meters or 278 385.8 geopotential feet). The first equation is used when the value of standard temperature lapse rate is not equal to zero; the second equation is used when standard temperature lapse rate equals zero.

Equation 1:

${\displaystyle {\rho }=\rho _{b}\cdot \left[{\frac {T_{b}}{T_{b}+L_{b}\cdot (h-h_{b})}}\right]^{\left(1+{\frac {g_{0}\cdot M}{R^{*}\cdot L_{b}}}\right)}}$

Equation 2:

${\displaystyle {\rho }=\rho _{b}\cdot \exp \left[{\frac {-g_{0}\cdot M\cdot (h-h_{b})}{R^{*}\cdot T_{b}}}\right]}$

where

${\displaystyle {\rho }}$ = mass density (kg/m3)
${\displaystyle T}$ = standard temperature (K)
${\displaystyle L}$ = standard temperature lapse rate (see table below) (K/m) in ISA
${\displaystyle h}$ = height above sea level (geopotential meters)
${\displaystyle R^{*}}$ = universal gas constant for air: 8.3144598 N·m/(mol·K)
${\displaystyle g_{0}}$ = gravitational acceleration: 9.80665 m/s2
${\displaystyle M}$ = molar mass of Earth's air: 0.0289644 kg/mol

or, converted to English gravitational foot-pound-second units:[1]

${\displaystyle {\rho }}$ = mass density (slug/ft3)
${\displaystyle {T}}$ = standard temperature (K)
${\displaystyle {L}}$ = standard temperature lapse rate (K/ft)
${\displaystyle {h}}$ = height above sea level (geopotential feet)
${\displaystyle {R^{*}}}$ = universal gas constant: 8.9494596×104 ft2/(s·K)
${\displaystyle {g_{0}}}$ = gravitational acceleration: 32.17405 ft/s2
${\displaystyle {M}}$ = molar mass of Earth's air: 0.0289644 kg/mol

The value of subscript b ranges from 0 to 6 in accordance with each of seven successive layers of the atmosphere shown in the table below. The reference value for ρb for b = 0 is the defined sea level value, ρ0 = 1.2250 kg/m3 or 0.0023768908 slug/ft3. Values of ρb of b = 1 through b = 6 are obtained from the application of the appropriate member of the pair equations 1 and 2 for the case when h = hb+1.[2]

In these equations, g0, M and R* are each single-valued constants, while ρ, L, T and h are multi-valued constants in accordance with the table below. The values used for M, g0 and R* are in accordance with the U.S. Standard Atmosphere, 1976, and that the value for R* in particular does not agree with standard values for this constant.[2]

Subscript b Height Above Sea Level (h) Mass Density (${\displaystyle \rho }$) Standard Temperature (T')
(K)
Temperature Lapse Rate (L)
(m) (ft) (kg/m3) (slugs/ft3) (K/m) (K/ft)
0 0 0 1.2250 2.3768908 x 10−3 288.15 -0.0065 -0.0019812
1 11 000 36,089.24 0.36391 7.0611703 x 10−4 216.65 0.0 0.0
2 20 000 65,616.79 0.08803 1.7081572 x 10−4 216.65 0.001 0.0003048
3 32 000 104,986.87 0.01322 2.5660735 x 10−5 228.65 0.0028 0.00085344
4 47 000 154,199.48 0.00143 2.7698702 x 10−6 270.65 0.0 0.0
5 51 000 167,322.83 0.00086 1.6717895 x 10−6 270.65 -0.0028 -0.00085344
6 71 000 232,939.63 0.000064 1.2458989 x 10−7 214.65 -0.002 -0.0006096

## Derivation

The barometric formula can be derived fairly easily using the ideal gas law:

${\displaystyle \rho ={\frac {M\cdot P}{R^{*}\cdot T}}}$

When density is known:

${\displaystyle P={\frac {\rho \cdot {R^{*}}\cdot T}{M}}}$

And assuming that all pressure is hydrostatic:

${\displaystyle dP=-\rho g\,dz\,}$

Dividing the ${\displaystyle dP}$ by the ${\displaystyle P}$ expression we get:

${\displaystyle {\frac {dP}{P}}=-{\frac {Mg\,dz}{R^{*}T}}}$

Integrating this expression from the surface to the altitude z we get:

${\displaystyle P=P_{0}e^{-\int _{0}^{z}{Mgdz/R^{*}T}}\,}$

Assuming constant temperature, molar mass, and gravitational acceleration, we get the barometric formula:

${\displaystyle P=P_{0}e^{-Mgz/R^{*}T}\,}$

In this formulation, R* is the gas constant, and the term R*T/Mg gives the scale height (approximately equal to 8.4 km for the troposphere).

(For exact results, it should be remembered that atmospheres containing water do not behave as an ideal gas. See real gas or perfect gas or gas for further understanding.)

## Source code

Below is the C++ implementation of the US Standard Atmosphere version 1976. The calculations below 51 km are adopted from equations in Practical Meteorology[3] and the calculations above 51 km are adopted from Atmospheric Models at Rocket and Space Technology.[4] Some validation data is available at avs.org.

      float getStandardPressure(float altitude /* meters */)   // Returns result in Pascals
{
// Below 51 km: Practical Meteorology by Roland Stull, pg 12
// Above 51 km: http://www.braeunig.us/space/atmmodel.htm

altitude = altitude / 1000.0f;  // Convert m to km
float geopot_height = getGeopotential(altitude);

float t = getStandardTemperature(geopot_height);

if (geopot_height <= 11)
return  101325 * pow(288.15f / t, -5.255877f);
else if (geopot_height <= 20)
return 22632.06 * exp(-0.1577f * (geopot_height - 11));
else if (geopot_height <= 32)
return 5474.889f * pow(216.65f / t, 34.16319f);
else if (geopot_height <= 47)
return 868.0187f * pow(228.65f / t, 12.2011f);
else if (geopot_height <= 51)
return 110.9063f * exp(-0.1262f * (geopot_height - 47));
else if (geopot_height <= 71)
return 66.93887f * pow(270.65f / t, -12.2011f);
else if (geopot_height <= 84.85)
return 3.956420f * pow(214.65f / t, -17.0816f);

throw std::out_of_range("altitude must be less than 86 km.");
}

// geopot_height = earth_radius * altitude / (earth_radius + altitude) /// All in km
// Temperature is in kelvins = 273.15 + Celsius
float getStandardTemperature(float geopot_height)
{
// Standard atmospheric pressure
// Below 51 km: Practical Meteorology by Roland Stull, pg 12
// Above 51 km: http://www.braeunig.us/space/atmmodel.htm

if (geopot_height <= 11)          // Troposphere
return 288.15f - (6.5 * geopot_height);
else if (geopot_height <= 20)     // Stratosphere starts
return 216.65f;
else if (geopot_height <= 32)
return 196.65f + geopot_height;
else if (geopot_height <= 47)
return 228.65f + 2.8 * (geopot_height - 32);
else if (geopot_height <= 51)     // Mesosphere starts
return 270.65f;
else if (geopot_height <= 71)
return 270.65f - 2.8 * (geopot_height - 51);
else if (geopot_height <= 84.85)
return 214.65f - 2 * (geopot_height - 71);
// Thermosphere has high kinetic temperature (500 C to 2000 C) but temperature
// as measured by a thermometer would be very low because of almost vacuum.

throw std::out_of_range("geopot_height must be less than 84.85 km.");
}

float getGeopotential(float altitude_km)
{
constexpr float EARTH_RADIUS =  6356.766; // km