diff --git a/src/FDM/YASim/FGFDM.cpp b/src/FDM/YASim/FGFDM.cpp index e0249222c..9b5128c62 100644 --- a/src/FDM/YASim/FGFDM.cpp +++ b/src/FDM/YASim/FGFDM.cpp @@ -601,7 +601,12 @@ void FGFDM::parseWing(const XMLAttributes* a, const char* type, Airplane* airpla const char* flowregime = a->getValue("flow"); if (!strcmp(flowregime,"TRANSONIC")) { w->setFlowRegime(FLOW_TRANSONIC); - w->setCriticalMachNumber(attrf(a, "mcrit", 0.6f)); + const float mcrit = attrf(a,"mcrit", 0.6f); + if ( (mcrit > 0.0f) && (mcrit <= 1.0f)) { + w->setCriticalMachNumber(mcrit); + } else { + SG_LOG(SG_FLIGHT, SG_ALERT, "YASim warning: invalid input for critical mach number. Defaulting to mcrit=0.6."); + } } } else { w->setFlowRegime(FLOW_SUBSONIC); diff --git a/src/FDM/YASim/Surface.cpp b/src/FDM/YASim/Surface.cpp index a4a4e13aa..7566d57b4 100644 --- a/src/FDM/YASim/Surface.cpp +++ b/src/FDM/YASim/Surface.cpp @@ -182,12 +182,20 @@ void Surface::calcForce(const float* v, const float rho, float mach, float* out, float pg_correction {1}; float wavedrag {0}; if (_flow == FLOW_TRANSONIC) { - pg_correction = Math::polynomial(pg_coefficients, mach); + if (mach < 0.8f) { + pg_correction = 1.0f/sqrt(1.0f-(mach*mach)); + } + if ((mach >= 0.8f) && (mach < 1.2f)) { + pg_correction = Math::polynomial(pg_coefficients, mach); + } + if (mach >= 1.2f) { + pg_correction = 2.0f/(((mach*mach)-1.0f)*YASIM_PI); + } out[2] *= pg_correction; // Add mach dependent wave drag (Perkins and Hage) if (mach > _Mcrit) { - wavedrag = 9.5f * Math::pow(mach-_Mcrit, 2.8f) + 0.00193f; + wavedrag = 9.5f * Math::pow((mach > 1.0f ? 1.0f : mach)-_Mcrit, 2.8f) + 0.00193f; out[0] += wavedrag; } } diff --git a/src/FDM/YASim/Surface.hpp b/src/FDM/YASim/Surface.hpp index c3b771416..a6dd14c2f 100644 --- a/src/FDM/YASim/Surface.hpp +++ b/src/FDM/YASim/Surface.hpp @@ -135,10 +135,9 @@ private: float _alpha {0}; FlowRegime _flow{FLOW_SUBSONIC}; - float _Mcrit {1.0f}; + float _Mcrit {0.6f}; - std::vector pg_coefficients {1, -0.163f, 5.877f, -39.157f, 104.694f, - -111.838f, 46.749f, -5.313f}; + std::vector pg_coefficients {-1.7671f, 0.4495f, 10.3423f, -6.9237f}; SGPropertyNode* _fxN; SGPropertyNode* _fyN;