]> git.mxchange.org Git - flightgear.git/commitdiff
Bug fix for JSBSim SF bug #115: P51D crashes when advance ratio goes through zero
authorBertrand Coconnier <bcoconni@users.sourceforge.net>
Mon, 23 May 2016 18:02:36 +0000 (20:02 +0200)
committerRoland Haeder <roland@mxchange.org>
Thu, 22 Sep 2016 21:27:35 +0000 (23:27 +0200)
src/FDM/JSBSim/models/FGAerodynamics.cpp

index e50ecb85167a88912fa6cec2ccb1437d03d64769..4aadccf61dc978fe873687b8e30258a1c09a37fb 100644 (file)
@@ -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)));