Ron Jensen: fixed a potential NaN and Segfault in JSBSim propeller code
The property /fdm/jsbsim/propulsion/engine/prop-induced-velocity_fps gives wrong answers, and can become NaN under certain conditions. When thrust is negative and forward velocity is small we can take the square root of a negative number. This could occur, for example, when using reverse thrusters on landing. The value comes out much too high when alpha is near 180, such as taxing with a tail wind.
This commit is contained in:
parent
a8d5ac90c6
commit
58e79013e3
1 changed files with 9 additions and 1 deletions
|
@ -228,7 +228,15 @@ double FGPropeller::Calculate(double EnginePower)
|
||||||
// Induced velocity in the propeller disk area. This formula is obtained
|
// Induced velocity in the propeller disk area. This formula is obtained
|
||||||
// from momentum theory - see B. W. McCormick, "Aerodynamics, Aeronautics,
|
// from momentum theory - see B. W. McCormick, "Aerodynamics, Aeronautics,
|
||||||
// and Flight Mechanics" 1st edition, eqn. 6.15 (propeller analysis chapter).
|
// and Flight Mechanics" 1st edition, eqn. 6.15 (propeller analysis chapter).
|
||||||
Vinduced = 0.5 * (-Vel + sqrt(Vel*Vel + 2.0*Thrust/(rho*Area)));
|
// Vinduced = 0.5 * (-Vel + sqrt(Vel*Vel + 2.0*Thrust/(rho*Area)))
|
||||||
|
// Since Thrust and Vel can both be negative we need to adjust this formula
|
||||||
|
// To handle sign (direction) separately from magnitude.
|
||||||
|
double Vel2sum = Vel*abs(Vel) + 2.0*Thrust/(rho*Area);
|
||||||
|
|
||||||
|
if( Vel2sum > 0.0)
|
||||||
|
Vinduced = 0.5 * (-Vel + sqrt(Vel2sum));
|
||||||
|
else
|
||||||
|
Vinduced = 0.5 * (-Vel - sqrt(-Vel2sum));
|
||||||
|
|
||||||
// P-factor is simulated by a shift of the acting location of the thrust.
|
// P-factor is simulated by a shift of the acting location of the thrust.
|
||||||
// The shift is a multiple of the angle between the propeller shaft axis
|
// The shift is a multiple of the angle between the propeller shaft axis
|
||||||
|
|
Loading…
Reference in a new issue