]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGPropeller.cpp
Encapsulate the interpolstion version of FGEnvironment and fix some bugs
[flightgear.git] / src / FDM / JSBSim / FGPropeller.cpp
index 5804117fce13ea9f88f7c1378675ad0b62ee47b6..da3fbd41d5a80847342fb8950d0cbafcc78a2231 100644 (file)
@@ -38,6 +38,8 @@ INCLUDES
 #include "FGPropeller.h"
 #include "FGFCS.h"
 
+namespace JSBSim {
+
 static const char *IdSrc = "$Id$";
 static const char *IdHdr = ID_PROPELLER;
 
@@ -56,6 +58,7 @@ FGPropeller::FGPropeller(FGFDMExec* exec, FGConfigFile* Prop_cfg) : FGThruster(e
   int rows, cols;
 
   MaxPitch = MinPitch = P_Factor = Sense = Pitch = 0.0;
+  GearRatio = 1.0;
 
   Name = Prop_cfg->GetValue("NAME");
   Prop_cfg->GetNextConfigLine();
@@ -68,6 +71,8 @@ FGPropeller::FGPropeller(FGFDMExec* exec, FGConfigFile* Prop_cfg) : FGThruster(e
       Diameter /= 12.0;
     } else if (token == "NUMBLADES") {
       *Prop_cfg >> numBlades;
+    } else if (token == "GEARRATIO") {
+      *Prop_cfg >> GearRatio;
     } else if (token == "MINPITCH") {
       *Prop_cfg >> MinPitch;
     } else if (token == "MAXPITCH") {
@@ -127,7 +132,7 @@ FGPropeller::~FGPropeller()
 double FGPropeller::Calculate(double PowerAvailable)
 {
   double J, C_Thrust, omega;
-  double Vel = fdmex->GetTranslation()->GetvAeroUVW(eU);
+  double Vel = fdmex->GetTranslation()->GetAeroUVW(eU);
   double rho = fdmex->GetAtmosphere()->GetDensity();
   double RPS = RPM/60.0;
   double alpha, beta;
@@ -154,9 +159,16 @@ double FGPropeller::Calculate(double PowerAvailable)
   }
 
   Thrust = C_Thrust*RPS*RPS*Diameter*Diameter*Diameter*Diameter*rho;
-  vFn(1) = Thrust;
   omega = RPS*2.0*M_PI;
 
+  // Check for windmilling.
+  double radius = Diameter * 0.375; // 75% of radius
+  double windmill_cutoff = tan(Pitch * 1.745329E-2) * omega * radius;
+  if (Vel > windmill_cutoff)
+    Thrust = -Thrust;
+
+  vFn(1) = Thrust;
+
   // The Ixx value and rotation speed given below are for rotation about the
   // natural axis of the engine. The transform takes place in the base class
   // FGForce::GetBodyForces() function.
@@ -167,9 +179,15 @@ double FGPropeller::Calculate(double PowerAvailable)
 
   if (omega <= 5) omega = 1.0;
 
-  ExcessTorque = PowerAvailable / omega;
+  ExcessTorque = PowerAvailable / omega * GearRatio;
   RPM = (RPS + ((ExcessTorque / Ixx) / (2.0 * M_PI)) * deltaT) * 60.0;
 
+                               // The friction from the engine should
+                               // stop it somewhere; I chose an
+                               // arbitrary point.
+  if (RPM < 5.0)
+    RPM = 0;
+
   vMn = fdmex->GetRotation()->GetPQR()*vH + vTorque*Sense;
 
   return Thrust; // return thrust in pounds
@@ -183,10 +201,11 @@ double FGPropeller::GetPowerRequired(void)
 
   double cPReq, RPS = RPM / 60.0;
 
-  double J = fdmex->GetTranslation()->GetvAeroUVW(eU) / (Diameter * RPS);
+  double J = fdmex->GetTranslation()->GetAeroUVW(eU) / (Diameter * RPS);
   double rho = fdmex->GetAtmosphere()->GetDensity();
 
   if (MaxPitch == MinPitch) { // Fixed pitch prop
+    Pitch = MinPitch;
     cPReq = cPower->GetValue(J);
   } else {                    // Variable pitch prop
     double advance = fdmex->GetFCS()->GetPropAdvance(ThrusterNumber);
@@ -201,7 +220,7 @@ double FGPropeller::GetPowerRequired(void)
       else if (Pitch > MaxPitch)  Pitch = MaxPitch;
 
     } else {
-      Pitch = MaxPitch - (MaxPitch - MinPitch) * advance;
+      Pitch = MinPitch + (MaxPitch - MinPitch) * advance;
     }
     cPReq = cPower->GetValue(J, Pitch);
   }
@@ -279,4 +298,4 @@ void FGPropeller::Debug(int from)
     }
   }
 }
-
+}