X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FEnvironment%2Fatmosphere.hxx;h=466cba270e60eefe4bb71f47b42576e3c935d32c;hb=c6221b2c84f47041ef92aff2a2cfffee25b84a73;hp=68e64202de3e335dedde12a11f553ae7aa62fe4a;hpb=7e6bc192bad98454187ffe2b5521d28fe6b722a4;p=flightgear.git diff --git a/src/Environment/atmosphere.hxx b/src/Environment/atmosphere.hxx index 68e64202d..466cba270 100644 --- a/src/Environment/atmosphere.hxx +++ b/src/Environment/atmosphere.hxx @@ -28,13 +28,8 @@ #include #include -#ifdef SG_HAVE_STD_INCLUDES -# include -#else -# include -#endif - -using namespace std; +#include +#include /** * Model the atmosphere in a way consistent with the laws @@ -54,8 +49,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) @@ -70,19 +66,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); };