INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+#include <sstream>
+
#include "FGPropeller.h"
-#include "FGFCS.h"
+#include "FGPropagate.h"
+#include "FGAtmosphere.h"
+#include "FGAuxiliary.h"
+
+namespace JSBSim {
static const char *IdSrc = "$Id$";
static const char *IdHdr = ID_PROPELLER;
CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-// This class currently makes certain assumptions when calculating torque and
+// This class currently makes certain assumptions when calculating torque and
// p-factor. That is, that the axis of rotation is the X axis of the aircraft -
-// not just the X-axis of the engine/propeller. This may or may not work for a
+// not just the X-axis of the engine/propeller. This may or may not work for a
// helicopter.
-FGPropeller::FGPropeller(FGFDMExec* exec, FGConfigFile* Prop_cfg) : FGThruster(exec)
+FGPropeller::FGPropeller(FGFDMExec* exec, FGConfigFile* Prop_cfg, int num) : FGThruster(exec)
{
string token;
int rows, cols;
- MaxPitch = MinPitch = P_Factor = Sense = Pitch = 0.0;
+ MaxPitch = MinPitch = P_Factor = Sense = Pitch = Advance = 0.0;
+ GearRatio = 1.0;
Name = Prop_cfg->GetValue("NAME");
Prop_cfg->GetNextConfigLine();
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") {
RPM = 0;
vTorque.InitMatrix();
+ char property_name[80];
+ snprintf(property_name, 80, "propulsion/c-thrust[%u]", EngineNum);
+ PropertyManager->Tie( property_name, &ThrustCoeff );
+
Debug(0);
}
{
if (cThrust) delete cThrust;
if (cPower) delete cPower;
+
+ char property_name[80];
+ snprintf(property_name, 80, "propulsion/c-thrust[%u]", EngineNum);
+ PropertyManager->Untie( property_name );
+
Debug(1);
}
double FGPropeller::Calculate(double PowerAvailable)
{
- double J, C_Thrust, omega;
- double Vel = fdmex->GetTranslation()->GetvAeroUVW(eU);
+ double J, omega;
+ double Vel = fdmex->GetAuxiliary()->GetAeroUVW(eU);
double rho = fdmex->GetAtmosphere()->GetDensity();
double RPS = RPM/60.0;
double alpha, beta;
}
if (MaxPitch == MinPitch) { // Fixed pitch prop
- C_Thrust = cThrust->GetValue(J);
+ ThrustCoeff = cThrust->GetValue(J);
} else { // Variable pitch prop
- C_Thrust = cThrust->GetValue(J, Pitch);
+ ThrustCoeff = cThrust->GetValue(J, Pitch);
}
if (P_Factor > 0.0001) {
- alpha = fdmex->GetTranslation()->Getalpha();
- beta = fdmex->GetTranslation()->Getbeta();
- SetActingLocationY( GetLocationY() + P_Factor*alpha*fabs(Sense)/Sense);
- SetActingLocationZ( GetLocationZ() + P_Factor*beta*fabs(Sense)/Sense);
+ alpha = fdmex->GetAuxiliary()->Getalpha();
+ beta = fdmex->GetAuxiliary()->Getbeta();
+ SetActingLocationY( GetLocationY() + P_Factor*alpha*Sense);
+ SetActingLocationZ( GetLocationZ() + P_Factor*beta*Sense);
} else if (P_Factor < 0.000) {
cerr << "P-Factor value in config file must be greater than zero" << endl;
}
- Thrust = C_Thrust*RPS*RPS*Diameter*Diameter*Diameter*Diameter*rho;
- vFn(1) = Thrust;
+ Thrust = ThrustCoeff*RPS*RPS*Diameter*Diameter*Diameter*Diameter*rho;
omega = RPS*2.0*M_PI;
+ 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.
- vH(eX) = Ixx*omega*fabs(Sense)/Sense;
+ vH(eX) = Ixx*omega*Sense;
vH(eY) = 0.0;
vH(eZ) = 0.0;
if (omega <= 5) omega = 1.0;
- ExcessTorque = PowerAvailable / omega;
+ ExcessTorque = PowerAvailable / omega * GearRatio;
RPM = (RPS + ((ExcessTorque / Ixx) / (2.0 * M_PI)) * deltaT) * 60.0;
- vMn = fdmex->GetRotation()->GetPQR()*vH + vTorque*Sense;
+ // The friction from the engine should
+ // stop it somewhere; I chose an
+ // arbitrary point.
+ if (RPM < 5.0)
+ RPM = 0;
+
+ vMn = fdmex->GetPropagate()->GetPQR()*vH + vTorque*Sense;
return Thrust; // return thrust in pounds
}
double cPReq, RPS = RPM / 60.0;
- double J = fdmex->GetTranslation()->GetvAeroUVW(eU) / (Diameter * RPS);
+ double J = fdmex->GetAuxiliary()->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);
if (MaxRPM != MinRPM) { // fixed-speed prop
- double rpmReq = MinRPM + (MaxRPM - MinRPM) * advance;
+ double rpmReq = MinRPM + (MaxRPM - MinRPM) * Advance;
double dRPM = rpmReq - RPM;
Pitch -= dRPM / 10;
else if (Pitch > MaxPitch) Pitch = MaxPitch;
} else {
- Pitch = MaxPitch - (MaxPitch - MinPitch) * advance;
+ Pitch = MinPitch + (MaxPitch - MinPitch) * Advance;
}
cPReq = cPower->GetValue(J, Pitch);
}
PowerRequired = cPReq*RPS*RPS*RPS*Diameter*Diameter*Diameter*Diameter
*Diameter*rho;
- vTorque(eX) = PowerRequired / ((RPM/60)*2.0*M_PI);
+ vTorque(eX) = -Sense*PowerRequired / (RPS*2.0*M_PI);
return PowerRequired;
}
return FGColumnVector3(px, py, pz);
}
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+string FGPropeller::GetThrusterLabels(int id, string delimeter)
+{
+ std::ostringstream buf;
+
+ buf << Name << "_Torque[" << id << "]" << delimeter
+ << Name << "_PFactor_Pitch[" << id << "]" << delimeter
+ << Name << "_PFactor_Yaw[" << id << "]" << delimeter
+ << Name << "_Thrust[" << id << "]" << delimeter;
+ if (IsVPitch())
+ buf << Name << "_Pitch[" << id << "]" << delimeter;
+ buf << Name << "_RPM[" << id << "]";
+
+ return buf.str();
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+string FGPropeller::GetThrusterValues(int id, string delimeter)
+{
+ std::ostringstream buf;
+
+ FGColumnVector3 vPFactor = GetPFactor();
+ buf << vTorque(eX) << delimeter
+ << vPFactor(ePitch) << delimeter
+ << vPFactor(eYaw) << delimeter
+ << Thrust << delimeter;
+ if (IsVPitch())
+ buf << Pitch << delimeter;
+ buf << RPM;
+
+ return buf.str();
+}
+
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// The bitmasked value choices are as follows:
// unset: In this case (the default) JSBSim would only print
}
if (debug_lvl & 16) { // Sanity checking
}
+ if (debug_lvl & 64) {
+ if (from == 0) { // Constructor
+ cout << IdSrc << endl;
+ cout << IdHdr << endl;
+ }
+ }
+}
}
-