You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Rough conversion factor from degrees to meters for latitude/longitude via nautical miles (1 degree ~ 60 nautical miles; 1 nautical mile ~ 1852 meters)
74
74
pubconstDEGREES_TO_METERS:f64 = 60.0*1852.0;
75
-
/// Sea-level atmospheric pressure in pascals
76
-
pubconstSEA_LEVEL_PRESSURE:f64 = 101325.0;// Pa, standard sea-level pressure
77
-
/// Temperature lapse rate in Kelvin per meter
78
-
pubconstTEMPERATURE_LAPSE_RATE:f64 = 0.00976;// K/m, standard temperature lapse rate in the troposphere
79
-
/// Constant-pressure specific heat
80
-
pubconstCONSTANT_PRESSURE_SPECIFIC_HEAT:f64 = 1004.68506;// J/(kg·K), specific heat at constant pressure for dry air
81
-
/// Sea level standard temperature in Kelvin
82
-
pubconstSEA_LEVEL_STANDARD_TEMPERATURE:f64 = 288.15;// K, standard sea-level temperature
83
-
/// Molar mass of dry air in kg/mol
84
-
pubconstMOLAR_MASS_DRY_AIR:f64 = 0.02896968;// kg/mol, molar mass of dry air
85
-
/// Universal gas constant in J/(mol·K)
86
-
pubconstUNIVERSAL_GAS_CONSTANT:f64 = 8.314462618;// J/(mol·K), universal gas constant
87
-
/// Calculate the barometric altitude from pressure and temperature
75
+
/// Atmospheric pressure at sea level in Pascals ($P_0$)
76
+
pubconstSEA_LEVEL_PRESSURE:f64 = 101325.0;
77
+
/// Standard temperature at sea level in Kelvin ($T_0$)
78
+
pubconstSEA_LEVEL_TEMPERATURE:f64 = 288.15;
79
+
/// Molar mass of dry air in kg/mol ($M$)
80
+
pubconstMOLAR_MASS_DRY_AIR:f64 = 0.0289644;
81
+
/// Universal gas constant in J/(mol·K) ($R_0$)
82
+
pubconstUNIVERSAL_GAS_CONSTANT:f64 = 8.314462618;
83
+
/// Standard lapse rate in K/m ($L$)
84
+
pubconstSTANDARD_LAPSE_RATE:f64 = 0.0065;
85
+
/// Calculate a barometric altitude from a measured pressure
88
86
///
89
-
/// This function calculates the barometric altitude using the barometric formula, which relates
90
-
/// the pressure at a given altitude to the pressure at sea level. The formula is based on the
91
-
/// assumption of an isothermal atmosphere and the ideal gas law.
92
-
///
93
-
/// # Arguments
94
-
/// - `pressure` - The atmospheric pressure at the given altitude in pascals
87
+
/// This function calculates the altitude above sea level based on the measured pressure
88
+
/// using the barometric formula. The formula assumes a standard atmosphere and uses the
89
+
/// universal gas constant, standard lapse rate, and molar mass of dry air.
95
90
///
91
+
/// # Parameters
92
+
/// - `pressure` - The measured pressure in Pascals
96
93
/// # Returns
97
-
/// The barometric altitude in meters
98
-
pubfnbarometric_altitude(pressure:f64) -> f64{
99
-
let exponent:f64 = -((UNIVERSAL_GAS_CONSTANT*TEMPERATURE_LAPSE_RATE) / (G0*MOLAR_MASS_DRY_AIR));
0 commit comments