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;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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") {
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) {
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") );
// 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;
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