-
- FGInterface::set_Gamma_vert_rad(gamma);
- }
- }
-}
-// Reverse the VCAS formula to obtain the corresponding Mach number. For subsonic
-// speeds, the reversed formula has a closed form. For supersonic speeds, the
-// formula is reversed by the Newton-Raphson algorithm.
-
-double FGJSBsim::getMachFromVcas(double vcas)
-{
- double p=pressure->getDoubleValue();
- double psl=fdmex->GetAtmosphere()->GetPressureSL();
- double rhosl=fdmex->GetAtmosphere()->GetDensitySL();
-
- double pt = p + psl*(pow(1+vcas*vcas*rhosl/(7.0*psl),3.5)-1);
-
- if (pt/p < 1.89293)
- return sqrt(5.0*(pow(pt/p, 0.2857143) -1)); // Mach < 1
- else {
- // Mach >= 1
- double mach = sqrt(0.77666*pt/p); // Initial guess is based on a quadratic approximation of the Rayleigh formula
- double delta = 1.;
- double target = pt/(166.92158*p);
- int iter = 0;
-
- // Find the root with Newton-Raphson. Since the differential is never zero,
- // the function is monotonic and has only one root with a multiplicity of one.
- // Convergence is certain.
- while (delta > 1E-5 && iter < 10) {
- double m2 = mach*mach; // Mach^2
- double m6 = m2*m2*m2; // Mach^6
- delta = mach*m6/pow(7.0*m2-1.0,2.5) - target;
- double diff = 7.0*m6*(2.0*m2-1)/pow(7.0*m2-1.0,3.5); // Never zero when Mach >= 1
- mach -= delta/diff;
- iter++;