]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGAerodynamics.cpp
Fix stall widths for the "auxilliary" (reverse flow) stalls so they
[flightgear.git] / src / FDM / JSBSim / FGAerodynamics.cpp
index eaeaa194d13ef51bfe2551adf8f2e9fb21caf967..b052fe9230229825d0fd479e79a6255c01961b71 100644 (file)
@@ -37,16 +37,23 @@ INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 #include "FGAerodynamics.h"
+#include "FGPropagate.h"
+#include "FGAircraft.h"
+#include "FGState.h"
+#include "FGMassBalance.h"
 #include "FGFactorGroup.h"
-#include "FGCoefficient.h"
 #include "FGPropertyManager.h"
 
+namespace JSBSim {
+
 static const char *IdSrc = "$Id$";
 static const char *IdHdr = ID_AERODYNAMICS;
 
-const unsigned NAxes=6;                           
-const char* AxisNames[] = { "drag", "side-force", "lift", "rolling-moment",
-                            "pitching-moment","yawing-moment" }; 
+const unsigned NAxes=6;
+const char* AxisNames[] = { "drag", "side", "lift", "roll",
+                            "pitch","yaw" };
+const char* AxisNamesUpper[] = { "DRAG", "SIDE", "LIFT", "ROLL",
+                                 "PITCH","YAW" };
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 CLASS IMPLEMENTATION
@@ -65,12 +72,12 @@ FGAerodynamics::FGAerodynamics(FGFDMExec* FDMExec) : FGModel(FDMExec)
   AxisIdx["YAW"]   = 5;
 
   Coeff = new CoeffArray[6];
-  
+
   impending_stall = stall_hyst = 0.0;
   alphaclmin = alphaclmax = 0.0;
   alphahystmin = alphahystmax = 0.0;
   clsq = lod = 0.0;
-  alphaw = 0.0;  
+  alphaw = 0.0;
   bi2vel = ci2vel = 0.0;
   bind();
 
@@ -82,16 +89,16 @@ FGAerodynamics::FGAerodynamics(FGFDMExec* FDMExec) : FGModel(FDMExec)
 FGAerodynamics::~FGAerodynamics()
 {
   unsigned int i,j;
-  
+
   unbind();
-  
+
   for (i=0; i<6; i++) {
     for (j=0; j<Coeff[i].size(); j++) {
       delete Coeff[i][j];
     }
   }
   delete[] Coeff;
-  
+
   Debug(1);
 }
 
@@ -104,16 +111,16 @@ bool FGAerodynamics::Run(void)
 
   if (!FGModel::Run()) {
 
-    twovel = 2*Translation->GetVt();
-    if (twovel > 0) {
+    twovel = 2*Auxiliary->GetVt();
+    if (twovel != 0) {
       bi2vel = Aircraft->GetWingSpan() / twovel;
       ci2vel = Aircraft->Getcbar() / twovel;
-    }  
-    
-    alphaw = Translation->Getalpha() + Aircraft->GetWingIncidence();
-    
-    alpha = Translation->Getalpha();
-    
+    }
+
+    alphaw = Auxiliary->Getalpha() + Aircraft->GetWingIncidence();
+
+    alpha = Auxiliary->Getalpha();
+
     if (alphaclmax != 0) {
       if (alpha > 0.85*alphaclmax) {
         impending_stall = 10*(alpha/alphaclmax - 0.85);
@@ -121,15 +128,15 @@ bool FGAerodynamics::Run(void)
         impending_stall = 0;
       }
     }
-   
+
     if (alphahystmax != 0.0 && alphahystmin != 0.0) {
       if (alpha > alphahystmax) {
          stall_hyst = 1;
       } else if (alpha < alphahystmin) {
          stall_hyst = 0;
-      }    
+      }
     }
+
     vLastFs = vFs;
     vFs.InitMatrix();
 
@@ -141,26 +148,21 @@ bool FGAerodynamics::Run(void)
 
     //correct signs of drag and lift to wind axes convention
     //positive forward, right, down
-    if ( Translation->Getqbar() > 0) {
-      clsq = vFs(eLift) / (Aircraft->GetWingArea()*Translation->Getqbar());
+    if ( Auxiliary->Getqbar() > 0) {
+      clsq = vFs(eLift) / (Aircraft->GetWingArea()*Auxiliary->Getqbar());
       clsq *= clsq;
     }
     if ( vFs(eDrag)  > 0) {
       lod = vFs(eLift) / vFs(eDrag);
-    }  
-        
+    }
+
     //correct signs of drag and lift to wind axes convention
     //positive forward, right, down
     vFs(eDrag)*=-1; vFs(eLift)*=-1;
 
     vForces = State->GetTs2b()*vFs;
 
-    vDXYZcg(eX) = -(Aircraft->GetXYZrp(eX) 
-                      - MassBalance->GetXYZcg(eX))*inchtoft;
-    vDXYZcg(eY) =  (Aircraft->GetXYZrp(eY) 
-                      - MassBalance->GetXYZcg(eY))*inchtoft;
-    vDXYZcg(eZ) = -(Aircraft->GetXYZrp(eZ) 
-                      - MassBalance->GetXYZcg(eZ))*inchtoft;
+    vDXYZcg = MassBalance->StructuralToBody(Aircraft->GetXYZrp());
 
     vMoments = vDXYZcg*vForces; // M = r X F
 
@@ -214,13 +216,13 @@ bool FGAerodynamics::Load(FGConfigFile* AC_cfg)
   }
 
   bindModel();
-  
+
   return true;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-string FGAerodynamics::GetCoefficientStrings(void)
+string FGAerodynamics::GetCoefficientStrings(string delimeter)
 {
   string CoeffStrings = "";
   bool firstime = true;
@@ -231,7 +233,7 @@ string FGAerodynamics::GetCoefficientStrings(void)
       if (firstime) {
         firstime = false;
       } else {
-        CoeffStrings += ", ";
+        CoeffStrings += delimeter;
       }
       CoeffStrings += Coeff[axis][sd]->GetCoefficientName();
     }
@@ -241,7 +243,7 @@ string FGAerodynamics::GetCoefficientStrings(void)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-string FGAerodynamics::GetCoefficientValues(void)
+string FGAerodynamics::GetCoefficientValues(string delimeter)
 {
   string SDValues = "";
   bool firstime = true;
@@ -251,7 +253,7 @@ string FGAerodynamics::GetCoefficientValues(void)
       if (firstime) {
         firstime = false;
       } else {
-        SDValues += ", ";
+        SDValues += delimeter;
       }
       SDValues += Coeff[axis][sd]->GetSDstring();
     }
@@ -287,7 +289,7 @@ void FGAerodynamics::bind(void)
   PropertyManager->Tie("forces/lod-norm", this,
                        &FGAerodynamics::GetLoD);
   PropertyManager->Tie("aero/cl-squared-norm", this,
-                       &FGAerodynamics::GetClSquared); 
+                       &FGAerodynamics::GetClSquared);
   PropertyManager->Tie("aero/alpha-max-deg", this,
                        &FGAerodynamics::GetAlphaCLMax,
                        &FGAerodynamics::SetAlphaCLMax,
@@ -311,7 +313,7 @@ void FGAerodynamics::bind(void)
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 void FGAerodynamics::bindModel(void)
-{ 
+{
   unsigned i,j;
   FGPropertyManager* node;
   string axis_node_name;
@@ -320,8 +322,8 @@ void FGAerodynamics::bindModel(void)
      node = node->GetNode( string(AxisNames[i]),true );
      for (j=0; j < Coeff[i].size(); j++) {
        Coeff[i][j]->bind(node);
-     } 
-     node = (FGPropertyManager*)node->getParent();                                         
+     }
+     node = (FGPropertyManager*)node->getParent();
   }
 }
 
@@ -341,7 +343,7 @@ void FGAerodynamics::unbind(void)
   PropertyManager->Untie("forces/fwy-aero-lbs");
   PropertyManager->Untie("forces/fwz-aero-lbs");
   PropertyManager->Untie("forces/lod-norm");
-  PropertyManager->Untie("aero/cl-squared-norm");  
+  PropertyManager->Untie("aero/cl-squared-norm");
   PropertyManager->Untie("aero/alpha-max-deg");
   PropertyManager->Untie("aero/alpha-min-deg");
   PropertyManager->Untie("aero/bi2vel");
@@ -353,11 +355,28 @@ void FGAerodynamics::unbind(void)
   for ( i=0; i<NAxes; i++ ) {
      for ( j=0; j < Coeff[i].size(); j++ ) {
        Coeff[i][j]->unbind();
-       
+
      }
   }
 }
 
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGAerodynamics::convert(void)
+{
+
+  for (int axis=0; axis<6; axis++) {
+    if (Coeff[axis].size()>0) {
+      cout << endl << "        <axis name=\"" << AxisNamesUpper[axis] << "\">" << endl;
+      for (int c=0; c<Coeff[axis].size(); c++) {
+        Coeff[axis][c]->convert();
+      }
+      cout << "        </axis>" << endl;
+    }
+  }
+
+}
+
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 //    The bitmasked value choices are as follows:
 //    unset: In this case (the default) JSBSim would only print
@@ -404,3 +423,4 @@ void FGAerodynamics::Debug(int from)
   }
 }
 
+} // namespace JSBSim