From ac8ea7a2e66f9aed710c6cd4343515c2be43a1c5 Mon Sep 17 00:00:00 2001 From: Bertrand Coconnier Date: Mon, 23 May 2016 20:02:36 +0200 Subject: [PATCH] Bug fix for JSBSim SF bug #115: P51D crashes when advance ratio goes through zero --- src/FDM/JSBSim/models/FGAerodynamics.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/FDM/JSBSim/models/FGAerodynamics.cpp b/src/FDM/JSBSim/models/FGAerodynamics.cpp index e50ecb851..4aadccf61 100644 --- a/src/FDM/JSBSim/models/FGAerodynamics.cpp +++ b/src/FDM/JSBSim/models/FGAerodynamics.cpp @@ -50,7 +50,7 @@ using namespace std; namespace JSBSim { -IDENT(IdSrc,"$Id: FGAerodynamics.cpp,v 1.58 2016/05/22 17:02:13 bcoconni Exp $"); +IDENT(IdSrc,"$Id: FGAerodynamics.cpp,v 1.59 2016/05/23 17:23:36 bcoconni Exp $"); IDENT(IdHdr,ID_AERODYNAMICS); /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -147,6 +147,13 @@ bool FGAerodynamics::Run(bool Holding) unsigned int axis_ctr; const double twovel=2*in.Vt; + // Calculate lift coefficient squared + // Make sure that aero/cl-squared is computed with the current qbar + if ( in.Qbar > 0) { + clsq = (vFw(eLift) + vFwAtCG(eLift))/ (in.Wingarea*in.Qbar); + clsq *= clsq; + } + RunPreFunctions(); // calculate some oft-used quantities for speed @@ -248,12 +255,6 @@ bool FGAerodynamics::Run(bool Holding) exit(-1); } - // Calculate lift coefficient squared - if ( in.Qbar > 0) { - clsq = (vFw(eLift) + vFwAtCG(eLift))/ (in.Wingarea*in.Qbar); - clsq *= clsq; - } - // Calculate lift Lift over Drag if ( fabs(vFw(eDrag) + vFwAtCG(eDrag)) > 0.0) lod = fabs( (vFw(eLift) + vFwAtCG(eLift))/ (vFw(eDrag) + vFwAtCG(eDrag))); -- 2.39.5