X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FEnvironment%2Fatmosphere.cxx;h=b7130aea3e9a4a65cce7c4831cfaa49df985972c;hb=1edffd1d10bbe30a418e88140df54791ced23649;hp=a15c943ed47aba514bddb6212459f38f9a85c3fc;hpb=a6db6d89ff41a619569e6433409e8bf62ff98499;p=flightgear.git diff --git a/src/Environment/atmosphere.cxx b/src/Environment/atmosphere.cxx index a15c943ed..b7130aea3 100644 --- a/src/Environment/atmosphere.cxx +++ b/src/Environment/atmosphere.cxx @@ -7,6 +7,7 @@ using namespace std; #include +#include const ISA_layer ISA_def[] = { // 0 1 2 3 4 5 6 7 8 @@ -108,7 +109,7 @@ pair PT_vs_hpt( } // Should never get here. - SG_LOG(SG_GENERAL, SG_ALERT, "PT_vs_hpt: ran out of layers"); + SG_LOG(SG_ENVIRONMENT, SG_ALERT, "PT_vs_hpt: ran out of layers for h=" << hh ); return make_pair(d0, d0); } @@ -222,7 +223,7 @@ void FGAtmoCache::check_model() { ////////////////////////////////////////////////////////////////////// -FGAltimeter::FGAltimeter() : kset(atmodel::ISA::P0), kft(0) +FGAltimeter::FGAltimeter() { cache(); } @@ -250,7 +251,7 @@ double FGAtmo::QNH(const double field_elev, const double field_press) { double rslt = field_press * pow(1. + ISA::lam0 * field_elev / ISA::T0 * prat, 1./nn); #if 0 - SG_LOG(SG_GENERAL, SG_ALERT, "QNH: elev: " << field_elev + SG_LOG(SG_ENVIRONMENT, SG_ALERT, "QNH: elev: " << field_elev << " press: " << field_press << " prat: " << prat << " rslt: " << rslt @@ -260,6 +261,21 @@ double FGAtmo::QNH(const double field_elev, const double field_press) { return rslt; } +// Invert the QNH calculation to get the field pressure from a metar +// report. +// field pressure _in pascals_ +// ... caller gets to convert to inHg or millibars +// Field elevation in m +// Altimeter setting (QNH) in pascals +// Valid for fields within the troposphere only. +double FGAtmo::fieldPressure(const double field_elev, const double qnh) +{ + using namespace atmodel; + static const double nn = ISA::lam0 * Rgas / g / mm; + const double pratio = pow(qnh / ISA::P0, nn); + return ISA::P0 * pow(pratio - field_elev * ISA::lam0 / ISA::T0, 1.0 / nn); +} + void FGAltimeter::dump_stack1(const double Tref) { using namespace atmodel; const int bs(200);