X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FEnvironment%2Fatmosphere.hxx;h=1ee4e1b6beeaa58da610de8d854737f0b31f4bc5;hb=386aefe69358ce41a11c9afeb8f56e26758fe56b;hp=12df63327207cc2ebc314de0b75cfaa56c3cd36d;hpb=d9bfd5a425df1bad7e3c53a64adce871e299a6b9;p=flightgear.git diff --git a/src/Environment/atmosphere.hxx b/src/Environment/atmosphere.hxx index 12df63327..1ee4e1b6b 100644 --- a/src/Environment/atmosphere.hxx +++ b/src/Environment/atmosphere.hxx @@ -29,6 +29,7 @@ #include #include +#include using namespace std; @@ -50,8 +51,9 @@ namespace atmodel { SCD(mm, .0289644); // [kg/mole] molar mass of air (dry?) SCD(Rgas, 8.31432); // [J/K/mole] gas constant SCD(inch, 0.0254); // [m] definition of inch - SCD(foot, 12 * inch); // [m] + SCD(foot, 12 * inch); // [m] SCD(inHg, 101325.0 / 760 * 1000 * inch); // [Pa] definition of inHg + SCD(mbar, 100.); // [Pa] definition of millibar SCD(freezing, 273.15); // [K] centigrade - kelvin offset SCD(nm, 1852); // [m] nautical mile (NIST) SCD(sm, 5280*foot); // [m] nautical mile (NIST) @@ -66,19 +68,57 @@ namespace atmodel { +class ISA_layer { +public: + double height; + double temp; + double lapse; + ISA_layer(int, double h, double, double, double, double t, double, + double l=-1, double=0) + : height(h), // [meters] + temp(t), // [kelvin] + lapse(l) // [K/m] + {} +}; + +extern const ISA_layer ISA_def[]; + +std::pair PT_vs_hpt( + const double hh, + const double _p0 = atmodel::ISA::P0, + const double _t0 = atmodel::ISA::T0); + +double P_layer(const double height, const double href, + const double Pref, const double Tref, const double lapse ); + +double T_layer(const double height, const double href, + const double Pref, const double Tref, const double lapse ); + // The base class is little more than a namespace. // It has no constructor, no destructor, and no variables. class FGAtmo { public: - double p_vs_a(const double height); double a_vs_p(const double press, const double qnh = atmodel::ISA::P0); - double fake_t_vs_a_us(const double h_ft); + double fake_T_vs_a_us(const double h_ft, + const double Tsl = atmodel::ISA::T0) const; double fake_dp_vs_a_us(const double dpsl, const double h_ft); - double P_layer(const double height, const double href, - const double Pref, const double Tref, - const double lapse ); void check_one(const double height); - double qnh(const double field_ft, const double press_in); + +// Altimeter setting _in pascals_ +// ... caller gets to convert to inHg or millibars +// Field elevation in m +// Field pressure in pascals +// Valid for fields within the troposphere only. + double QNH(const double field_elev, const double field_press); +/** + * Invert the QNH calculation to get the field pressure from a metar + * report. Valid for fields within the troposphere only. + * @param field_elev field elevation in m + * @param qnh altimeter setting in pascals + * @return field pressure _in pascals_. Caller gets to convert to inHg + * or millibars + */ + static double fieldPressure(const double field_elev, const double qnh); };