Clamp Mach to avoid beta singularity

This commit is contained in:
SiboVG 2024-10-09 22:56:55 +02:00
parent 56aee518e7
commit a5eae08456

View File

@ -287,17 +287,16 @@ public class FlightConditions implements Cloneable, ChangeSource, Monitorable {
/**
* Calculate the beta value (compressibility factor/Prandtl-Glauert correction factor) for the given Mach number.
* Source: "Active Guidance and Dynamic Flight Mechanics for Model Rockets", David Ketchledge (1993)
* @param mach the Mach number.
* @return the beta value.
*/
private static double calculateBeta(double mach) {
if (mach < 0.8) {
if (mach < 0.99999) {
return MathUtil.safeSqrt(1 - mach * mach);
} else if (mach < 1.1)
// Because beta reaches infinity for M=1, we clamp the factor to 0.6 in the transonic region (Mach 0.8-1.1)
return 0.6; // sqrt(1 - 0.8^2)
else {
} else if (mach < 1.00001) {
// Clamp to avoid singularity near Mach 1
return MathUtil.safeSqrt(1 - 0.99999 * 0.99999);
} else {
return MathUtil.safeSqrt(mach * mach - 1);
}
}