2000-11-03 23:02:47 +00:00
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2000-10-02 23:07:30 +00:00
|
|
|
|
|
|
|
Module: FGPropeller.cpp
|
|
|
|
Author: Jon S. Berndt
|
|
|
|
Date started: 08/24/00
|
|
|
|
Purpose: Encapsulates the propeller object
|
|
|
|
|
|
|
|
------------- Copyright (C) 2000 Jon S. Berndt (jsb@hal-pc.org) -------------
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU General Public License as published by the Free Software
|
|
|
|
Foundation; either version 2 of the License, or (at your option) any later
|
|
|
|
version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with
|
|
|
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
|
|
|
Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
Further information about the GNU General Public License can also be found on
|
|
|
|
the world wide web at http://www.gnu.org.
|
|
|
|
|
|
|
|
FUNCTIONAL DESCRIPTION
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
HISTORY
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
08/24/00 JSB Created
|
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2000-10-02 23:07:30 +00:00
|
|
|
INCLUDES
|
2000-11-03 23:02:47 +00:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
2000-10-02 23:07:30 +00:00
|
|
|
|
|
|
|
#include "FGPropeller.h"
|
2001-12-05 03:10:20 +00:00
|
|
|
#include "FGFCS.h"
|
2000-10-02 23:07:30 +00:00
|
|
|
|
2001-03-30 01:04:50 +00:00
|
|
|
static const char *IdSrc = "$Id$";
|
2000-10-14 02:10:10 +00:00
|
|
|
static const char *IdHdr = ID_PROPELLER;
|
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
CLASS IMPLEMENTATION
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
2000-10-02 23:07:30 +00:00
|
|
|
|
2001-12-13 04:48:34 +00:00
|
|
|
// 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
|
|
|
|
// helicopter.
|
2000-10-02 23:07:30 +00:00
|
|
|
|
2001-03-30 01:04:50 +00:00
|
|
|
FGPropeller::FGPropeller(FGFDMExec* exec, FGConfigFile* Prop_cfg) : FGThruster(exec)
|
|
|
|
{
|
|
|
|
string token;
|
|
|
|
int rows, cols;
|
|
|
|
|
2001-11-30 17:49:37 +00:00
|
|
|
MaxPitch = MinPitch = P_Factor = Sense = Pitch = 0.0;
|
2001-06-05 20:58:48 +00:00
|
|
|
|
2001-04-02 03:12:38 +00:00
|
|
|
Name = Prop_cfg->GetValue("NAME");
|
2001-03-30 01:04:50 +00:00
|
|
|
Prop_cfg->GetNextConfigLine();
|
2001-11-20 22:34:24 +00:00
|
|
|
while (Prop_cfg->GetValue() != string("/FG_PROPELLER")) {
|
2001-03-30 01:04:50 +00:00
|
|
|
*Prop_cfg >> token;
|
|
|
|
if (token == "IXX") {
|
|
|
|
*Prop_cfg >> Ixx;
|
|
|
|
} else if (token == "DIAMETER") {
|
|
|
|
*Prop_cfg >> Diameter;
|
|
|
|
Diameter /= 12.0;
|
|
|
|
} else if (token == "NUMBLADES") {
|
|
|
|
*Prop_cfg >> numBlades;
|
2001-06-05 20:58:48 +00:00
|
|
|
} else if (token == "MINPITCH") {
|
|
|
|
*Prop_cfg >> MinPitch;
|
|
|
|
} else if (token == "MAXPITCH") {
|
|
|
|
*Prop_cfg >> MaxPitch;
|
2001-12-05 03:10:20 +00:00
|
|
|
} else if (token == "MINRPM") {
|
|
|
|
*Prop_cfg >> MinRPM;
|
|
|
|
} else if (token == "MAXRPM") {
|
|
|
|
*Prop_cfg >> MaxRPM;
|
2001-03-30 01:04:50 +00:00
|
|
|
} else if (token == "C_THRUST") {
|
2001-06-05 20:58:48 +00:00
|
|
|
*Prop_cfg >> rows >> cols;
|
|
|
|
if (cols == 1) cThrust = new FGTable(rows);
|
2001-12-05 03:10:20 +00:00
|
|
|
else cThrust = new FGTable(rows, cols);
|
2001-06-05 20:58:48 +00:00
|
|
|
*cThrust << *Prop_cfg;
|
2001-03-30 01:04:50 +00:00
|
|
|
} else if (token == "C_POWER") {
|
2001-06-05 20:58:48 +00:00
|
|
|
*Prop_cfg >> rows >> cols;
|
|
|
|
if (cols == 1) cPower = new FGTable(rows);
|
2001-12-05 03:10:20 +00:00
|
|
|
else cPower = new FGTable(rows, cols);
|
2001-06-05 20:58:48 +00:00
|
|
|
*cPower << *Prop_cfg;
|
2001-03-30 01:04:50 +00:00
|
|
|
} else if (token == "EOF") {
|
2001-06-05 20:58:48 +00:00
|
|
|
cerr << " End of file reached" << endl;
|
|
|
|
break;
|
2001-03-30 01:04:50 +00:00
|
|
|
} else {
|
2001-06-05 20:58:48 +00:00
|
|
|
cerr << "Unhandled token in Propeller config file: " << token << endl;
|
2001-03-30 01:04:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-04-17 21:19:54 +00:00
|
|
|
Type = ttPropeller;
|
|
|
|
RPM = 0;
|
2001-12-07 17:10:17 +00:00
|
|
|
vTorque.InitMatrix();
|
2001-04-17 21:19:54 +00:00
|
|
|
|
2001-12-13 04:48:34 +00:00
|
|
|
Debug(0);
|
2001-03-30 01:04:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
FGPropeller::~FGPropeller()
|
2000-10-02 23:07:30 +00:00
|
|
|
{
|
2001-03-30 01:04:50 +00:00
|
|
|
if (cThrust) delete cThrust;
|
|
|
|
if (cPower) delete cPower;
|
2001-12-13 04:48:34 +00:00
|
|
|
Debug(1);
|
2001-03-30 01:04:50 +00:00
|
|
|
}
|
2000-10-02 23:07:30 +00:00
|
|
|
|
2001-03-30 01:04:50 +00:00
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
|
2001-11-20 22:34:24 +00:00
|
|
|
double FGPropeller::Calculate(double PowerAvailable)
|
2001-03-30 01:04:50 +00:00
|
|
|
{
|
2001-11-20 22:34:24 +00:00
|
|
|
double J, C_Thrust, omega;
|
2001-11-30 17:49:37 +00:00
|
|
|
double Vel = fdmex->GetTranslation()->GetvAeroUVW(eU);
|
2001-11-20 22:34:24 +00:00
|
|
|
double rho = fdmex->GetAtmosphere()->GetDensity();
|
|
|
|
double RPS = RPM/60.0;
|
|
|
|
double alpha, beta;
|
2001-03-30 01:04:50 +00:00
|
|
|
|
|
|
|
if (RPM > 0.10) {
|
2001-12-05 03:10:20 +00:00
|
|
|
J = Vel / (Diameter * RPS);
|
2001-03-30 01:04:50 +00:00
|
|
|
} else {
|
|
|
|
J = 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (MaxPitch == MinPitch) { // Fixed pitch prop
|
|
|
|
C_Thrust = cThrust->GetValue(J);
|
|
|
|
} else { // Variable pitch prop
|
|
|
|
C_Thrust = cThrust->GetValue(J, Pitch);
|
|
|
|
}
|
|
|
|
|
2001-11-06 22:33:05 +00:00
|
|
|
if (P_Factor > 0.0001) {
|
|
|
|
alpha = fdmex->GetTranslation()->Getalpha();
|
|
|
|
beta = fdmex->GetTranslation()->Getbeta();
|
2001-12-07 17:10:17 +00:00
|
|
|
SetActingLocationY( GetLocationY() + P_Factor*alpha*fabs(Sense)/Sense);
|
|
|
|
SetActingLocationZ( GetLocationZ() + P_Factor*beta*fabs(Sense)/Sense);
|
2001-11-06 22:33:05 +00:00
|
|
|
} else if (P_Factor < 0.000) {
|
|
|
|
cerr << "P-Factor value in config file must be greater than zero" << endl;
|
|
|
|
}
|
|
|
|
|
2001-03-30 01:04:50 +00:00
|
|
|
Thrust = C_Thrust*RPS*RPS*Diameter*Diameter*Diameter*Diameter*rho;
|
|
|
|
vFn(1) = Thrust;
|
|
|
|
omega = RPS*2.0*M_PI;
|
|
|
|
|
2001-11-09 04:38:53 +00:00
|
|
|
// 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.
|
|
|
|
|
2001-11-06 22:33:05 +00:00
|
|
|
vH(eX) = Ixx*omega*fabs(Sense)/Sense;
|
|
|
|
vH(eY) = 0.0;
|
|
|
|
vH(eZ) = 0.0;
|
|
|
|
|
2001-04-17 21:19:54 +00:00
|
|
|
if (omega <= 5) omega = 1.0;
|
2001-03-30 01:04:50 +00:00
|
|
|
|
2001-12-07 17:10:17 +00:00
|
|
|
ExcessTorque = PowerAvailable / omega;
|
|
|
|
RPM = (RPS + ((ExcessTorque / Ixx) / (2.0 * M_PI)) * deltaT) * 60.0;
|
2001-11-09 04:38:53 +00:00
|
|
|
|
2001-12-07 17:10:17 +00:00
|
|
|
vMn = fdmex->GetRotation()->GetPQR()*vH + vTorque*Sense;
|
2001-11-09 04:38:53 +00:00
|
|
|
|
2001-03-30 01:04:50 +00:00
|
|
|
return Thrust; // return thrust in pounds
|
2000-10-02 23:07:30 +00:00
|
|
|
}
|
|
|
|
|
2001-03-30 01:04:50 +00:00
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2000-10-02 23:07:30 +00:00
|
|
|
|
2001-11-20 22:34:24 +00:00
|
|
|
double FGPropeller::GetPowerRequired(void)
|
2000-10-02 23:07:30 +00:00
|
|
|
{
|
2001-03-30 01:04:50 +00:00
|
|
|
if (RPM <= 0.10) return 0.0; // If the prop ain't turnin', the fuel ain't burnin'.
|
|
|
|
|
2001-11-20 22:34:24 +00:00
|
|
|
double cPReq, RPS = RPM / 60.0;
|
2000-10-02 23:07:30 +00:00
|
|
|
|
2001-11-30 17:49:37 +00:00
|
|
|
double J = fdmex->GetTranslation()->GetvAeroUVW(eU) / (Diameter * RPS);
|
2001-11-20 22:34:24 +00:00
|
|
|
double rho = fdmex->GetAtmosphere()->GetDensity();
|
2001-03-30 01:04:50 +00:00
|
|
|
|
|
|
|
if (MaxPitch == MinPitch) { // Fixed pitch prop
|
|
|
|
cPReq = cPower->GetValue(J);
|
|
|
|
} else { // Variable pitch prop
|
2001-12-05 03:10:20 +00:00
|
|
|
double advance = fdmex->GetFCS()->GetPropAdvance(ThrusterNumber);
|
|
|
|
|
|
|
|
if (MaxRPM != MinRPM) { // fixed-speed prop
|
|
|
|
double rpmReq = MinRPM + (MaxRPM - MinRPM) * advance;
|
|
|
|
double dRPM = rpmReq - RPM;
|
|
|
|
|
|
|
|
Pitch -= dRPM / 10;
|
|
|
|
|
|
|
|
if (Pitch < MinPitch) Pitch = MinPitch;
|
|
|
|
else if (Pitch > MaxPitch) Pitch = MaxPitch;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
Pitch = MaxPitch - (MaxPitch - MinPitch) * advance;
|
|
|
|
}
|
2001-03-30 01:04:50 +00:00
|
|
|
cPReq = cPower->GetValue(J, Pitch);
|
|
|
|
}
|
|
|
|
|
|
|
|
PowerRequired = cPReq*RPS*RPS*RPS*Diameter*Diameter*Diameter*Diameter
|
|
|
|
*Diameter*rho;
|
2001-12-07 17:10:17 +00:00
|
|
|
vTorque(eX) = PowerRequired / ((RPM/60)*2.0*M_PI);
|
|
|
|
|
2001-03-30 01:04:50 +00:00
|
|
|
return PowerRequired;
|
2000-10-02 23:07:30 +00:00
|
|
|
}
|
2001-03-30 01:04:50 +00:00
|
|
|
|
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
2001-12-13 04:48:34 +00:00
|
|
|
FGColumnVector3 FGPropeller::GetPFactor()
|
|
|
|
{
|
|
|
|
double px=0.0, py, pz;
|
|
|
|
|
|
|
|
py = Thrust * Sense * (GetActingLocationY() - GetLocationY()) / 12.0;
|
|
|
|
pz = Thrust * Sense * (GetActingLocationZ() - GetLocationZ()) / 12.0;
|
|
|
|
|
|
|
|
return FGColumnVector3(px, py, pz);
|
|
|
|
}
|
|
|
|
|
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
// The bitmasked value choices are as follows:
|
|
|
|
// unset: In this case (the default) JSBSim would only print
|
|
|
|
// out the normally expected messages, essentially echoing
|
|
|
|
// the config files as they are read. If the environment
|
|
|
|
// variable is not set, debug_lvl is set to 1 internally
|
|
|
|
// 0: This requests JSBSim not to output any messages
|
|
|
|
// whatsoever.
|
|
|
|
// 1: This value explicity requests the normal JSBSim
|
|
|
|
// startup messages
|
|
|
|
// 2: This value asks for a message to be printed out when
|
|
|
|
// a class is instantiated
|
|
|
|
// 4: When this value is set, a message is displayed when a
|
|
|
|
// FGModel object executes its Run() method
|
|
|
|
// 8: When this value is set, various runtime state variables
|
|
|
|
// are printed out periodically
|
|
|
|
// 16: When set various parameters are sanity checked and
|
|
|
|
// a message is printed out when they go out of bounds
|
|
|
|
|
|
|
|
void FGPropeller::Debug(int from)
|
2001-03-30 01:04:50 +00:00
|
|
|
{
|
2001-12-13 04:48:34 +00:00
|
|
|
if (debug_lvl <= 0) return;
|
|
|
|
|
|
|
|
if (debug_lvl & 1) { // Standard console startup message output
|
|
|
|
if (from == 0) { // Constructor
|
|
|
|
cout << "\n Propeller Name: " << Name << endl;
|
|
|
|
cout << " IXX = " << Ixx << endl;
|
|
|
|
cout << " Diameter = " << Diameter << " ft." << endl;
|
|
|
|
cout << " Number of Blades = " << numBlades << endl;
|
|
|
|
cout << " Minimum Pitch = " << MinPitch << endl;
|
|
|
|
cout << " Maximum Pitch = " << MaxPitch << endl;
|
|
|
|
cout << " Thrust Coefficient: " << endl;
|
|
|
|
cThrust->Print();
|
|
|
|
cout << " Power Coefficient: " << endl;
|
|
|
|
cPower->Print();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (debug_lvl & 2 ) { // Instantiation/Destruction notification
|
|
|
|
if (from == 0) cout << "Instantiated: FGPropeller" << endl;
|
|
|
|
if (from == 1) cout << "Destroyed: FGPropeller" << endl;
|
|
|
|
}
|
|
|
|
if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
|
|
|
|
}
|
|
|
|
if (debug_lvl & 8 ) { // Runtime state variables
|
|
|
|
}
|
|
|
|
if (debug_lvl & 16) { // Sanity checking
|
|
|
|
}
|
2001-03-30 01:04:50 +00:00
|
|
|
}
|
|
|
|
|