]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/models/propulsion/FGPropeller.cpp
Merge branch 'next' of git://gitorious.org/fg/flightgear into next
[flightgear.git] / src / FDM / JSBSim / models / propulsion / FGPropeller.cpp
index f83f961b8e7aea224b62c5dab8fb1e1cd62ae11e..64ae655748a2a5718eed2a7a9649147434b48627 100644 (file)
@@ -48,7 +48,7 @@ using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGPropeller.cpp,v 1.32 2010/10/21 03:27:40 jberndt Exp $";
+static const char *IdSrc = "$Id: FGPropeller.cpp,v 1.34 2011/06/16 14:54:06 jentron Exp $";
 static const char *IdHdr = ID_PROPELLER;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -102,8 +102,7 @@ FGPropeller::FGPropeller(FGFDMExec* exec, Element* prop_element, int num)
     ConstantSpeed = (int)prop_element->FindElementValueAsNumber("constspeed");
   if (prop_element->FindElement("reversepitch"))
     ReversePitch = prop_element->FindElementValueAsNumber("reversepitch");
-  for (int i=0; i<2; i++) {
-    table_element = prop_element->FindNextElement("table");
+  while(table_element = prop_element->FindNextElement("table")) {
     name = table_element->GetAttributeValue("name");
     try {
       if (name == "C_THRUST") {
@@ -121,6 +120,9 @@ FGPropeller::FGPropeller(FGFDMExec* exec, Element* prop_element, int num)
       throw("Error loading propeller table:" + name + ". " + str);
     }
   }
+  if( (cPower == 0) || (cThrust == 0)){
+      cerr << "Propeller configuration must contain C_THRUST and C_POWER tables!" << endl;
+  }
 
   local_element = prop_element->GetParent()->FindElement("sense");
   if (local_element) {
@@ -132,7 +134,7 @@ FGPropeller::FGPropeller(FGFDMExec* exec, Element* prop_element, int num)
     P_Factor = local_element->GetDataAsNumber();
   }
   if (P_Factor < 0) {
-    cerr << "P-Factor value in config file must be greater than zero" << endl;
+    cerr << "P-Factor value in propeller configuration file must be greater than zero" << endl;
   }
   if (prop_element->FindElement("ct_factor"))
     SetCtFactor( prop_element->FindElementValueAsNumber("ct_factor") );
@@ -185,23 +187,22 @@ FGPropeller::~FGPropeller()
 // We must be getting the aerodynamic velocity here, NOT the inertial velocity.
 // We need the velocity with respect to the wind.
 //
-// Note that PowerAvailable is the excess power available after the drag of the
-// propeller has been subtracted. At equilibrium, PowerAvailable will be zero -
-// indicating that the propeller will not accelerate or decelerate.
 // Remembering that Torque * omega = Power, we can derive the torque on the
 // propeller and its acceleration to give a new RPM. The current RPM will be
 // used to calculate thrust.
 //
 // Because RPM could be zero, we need to be creative about what RPM is stated as.
 
-double FGPropeller::Calculate(double PowerAvailable)
+double FGPropeller::Calculate(double EnginePower)
 {
-  double omega, alpha, beta;
+  double omega, alpha, beta, PowerAvailable;
 
   double Vel = fdmex->GetAuxiliary()->GetAeroUVW(eU);
   double rho = fdmex->GetAtmosphere()->GetDensity();
   double RPS = RPM/60.0;
 
+  PowerAvailable = EnginePower - GetPowerRequired();
+
   // Calculate helical tip Mach
   double Area = 0.25*Diameter*Diameter*M_PI;
   double Vtip = RPS * Diameter * M_PI;
@@ -425,10 +426,25 @@ void FGPropeller::Debug(int from)
       cout << "      Maximum Pitch  = " << MaxPitch << endl;
       cout << "      Minimum RPM  = " << MinRPM << endl;
       cout << "      Maximum RPM  = " << MaxRPM << endl;
+// Tables are being printed elsewhere...
 //      cout << "      Thrust Coefficient: " <<  endl;
 //      cThrust->Print();
 //      cout << "      Power Coefficient: " <<  endl;
 //      cPower->Print();
+//      cout << "      Mach Thrust Coefficient: " <<  endl;
+//      if(CtMach)
+//      {
+//          CtMach->Print();
+//      } else {
+//          cout << "        NONE" <<  endl;
+//      }
+//      cout << "      Mach Power Coefficient: " <<  endl;
+//      if(CpMach)
+//      {
+//          CpMach->Print();
+//      } else {
+//          cout << "        NONE" <<  endl;
+//      }
     }
   }
   if (debug_lvl & 2 ) { // Instantiation/Destruction notification