INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#include <vector>
+#include <iostream>
#include <sstream>
-
#include "FGTurbine.h"
+#include "FGThruster.h"
+#include "models/FGPropulsion.h"
+#include "models/FGAuxiliary.h"
+#include "models/FGAtmosphere.h"
+
+using namespace std;
namespace JSBSim {
-static const char *IdSrc = "$Id$";
+static const char *IdSrc = "$Id: FGTurbine.cpp,v 1.31 2011/03/03 12:16:26 jberndt Exp $";
static const char *IdHdr = ID_TURBINE;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
BypassRatio = BleedDemand = 0.0;
IdleThrustLookup = MilThrustLookup = MaxThrustLookup = InjectionLookup = 0;
N1_spinup = 1.0; N2_spinup = 3.0;
+ EPR = 1.0;
ResetToIC();
void FGTurbine::ResetToIC(void)
{
+
+ FGEngine::ResetToIC();
+
N1 = N2 = 0.0;
N2norm = 0.0;
correctedTSFC = TSFC;
Stalled = Seized = Overtemp = Fire = Augmentation = Injection = Reversed = false;
Cutoff = true;
phase = tpOff;
- EGT_degC = 0.0;
- OilTemp_degK = (Auxiliary->GetTotalTemperature() - 491.69) * 0.5555556 + 273.0;
+ TAT = (Auxiliary->GetTotalTemperature() - 491.69) * 0.5555556;
+ EGT_degC = TAT;
+ OilTemp_degK = TAT + 273.0;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// The main purpose of Calculate() is to determine what phase the engine should
// be in, then call the corresponding function.
-double FGTurbine::Calculate(void)
+void FGTurbine::Calculate(void)
{
double thrust;
+ RunPreFunctions();
+
TAT = (Auxiliary->GetTotalTemperature() - 491.69) * 0.5555556;
- dt = State->Getdt() * Propulsion->GetRate();
+ double qbar = Auxiliary->Getqbar();
+ dt = FDMExec->GetDeltaT() * Propulsion->GetRate();
ThrottlePos = FCS->GetThrottlePos(EngineNumber);
if (ThrottlePos > 1.0) {
AugmentCmd = ThrottlePos - 1.0;
if (!Running && Cutoff && Starter) {
if (phase == tpOff) phase = tpSpinUp;
- }
- if (!Running && !Cutoff && (N2 > 15.0)) phase = tpStart;
+ }
+
+ // start
+ if ((Starter == true) || (qbar > 30.0)) {
+ if (!Running && !Cutoff && (N2 > 15.0)) phase = tpStart;
+ }
+
if (Cutoff && (phase != tpSpinUp)) phase = tpOff;
if (dt == 0) phase = tpTrim;
if (Starved) phase = tpOff;
default: thrust = Off();
}
- thrust = Thruster->Calculate(thrust); // allow thruster to modify thrust (i.e. reversing)
+ Thruster->Calculate(thrust); // allow thruster to modify thrust (i.e. reversing)
- return thrust;
+ RunPostFunctions();
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if (!Augmentation) {
correctedTSFC = TSFC * sqrt(T/389.7) * (0.84 + (1-N2norm)*(1-N2norm));
- FuelFlow_pph = Seek(&FuelFlow_pph, thrust * correctedTSFC, 1000.0, 100000);
+ FuelFlow_pph = Seek(&FuelFlow_pph, thrust * correctedTSFC, 1000.0, 10000.0);
if (FuelFlow_pph < IdleFF) FuelFlow_pph = IdleFF;
NozzlePosition = Seek(&NozzlePosition, 1.0 - N2norm, 0.8, 0.8);
thrust = thrust * (1.0 - BleedDemand);
OilTemp_degK = Seek(&OilTemp_degK, TAT + 273.0, 0.2, 0.2);
EPR = 1.0;
NozzlePosition = 1.0;
+ if (Starter == false) phase = tpOff;
return 0.0;
}
double FGTurbine::Start(void)
{
+ double qbar = Auxiliary->Getqbar();
if ((N2 > 15.0) && !Starved) { // minimum 15% N2 needed for start
Cranking = true; // provided for sound effects signal
if (N2 < IdleN2) {
N2 = Seek(&N2, IdleN2, 2.0, N2/2.0);
N1 = Seek(&N1, IdleN1, 1.4, N1/2.0);
EGT_degC = Seek(&EGT_degC, TAT + 363.1, 21.3, 7.3);
- FuelFlow_pph = Seek(&FuelFlow_pph, IdleFF, 103.7, 103.7);
+ FuelFlow_pph = IdleFF * N2 / IdleN2;
OilPressure_psi = N2 * 0.62;
ConsumeFuel();
+ if ((Starter == false) && (qbar < 30.0)) phase = tpOff; // aborted start
}
else {
phase = tpRun;
N1 = Seek(&N1, qbar/10.0, 0, N1/10.0);
N2 = Seek(&N2, qbar/15.0, 0, N2/10.0);
ConsumeFuel();
- if (ThrottlePos < 0.01) phase = tpRun; // clear the stall with throttle
-
+ if (ThrottlePos < 0.01) {
+ phase = tpRun; // clear the stall with throttle to idle
+ Stalled = false;
+ }
return 0.0;
}
double qbar = Auxiliary->Getqbar();
N2 = 0.0;
N1 = Seek(&N1, qbar/20.0, 0, N1/15.0);
- FuelFlow_pph = IdleFF;
+ FuelFlow_pph = Cutoff ? 0.0 : IdleFF;
ConsumeFuel();
OilPressure_psi = 0.0;
OilTemp_degK = Seek(&OilTemp_degK, TAT + 273.0, 0, 0.2);
double FGTurbine::CalcFuelNeed(void)
{
- double dT = State->Getdt() * Propulsion->GetRate();
+ double dT = FDMExec->GetDeltaT() * Propulsion->GetRate();
FuelFlowRate = FuelFlow_pph / 3600.0; // Calculates flow in lbs/sec from lbs/hr
FuelExpended = FuelFlowRate * dT; // Calculates fuel expended in this time step
return FuelExpended;
MaxThrustLookup = new FGFunction(PropertyManager, function_element, property_prefix);
} else if (name == "Injection") {
InjectionLookup = new FGFunction(PropertyManager, function_element, property_prefix);
- } else {
- cerr << "Unknown function type: " << name << " in turbine definition." <<
- endl;
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-string FGTurbine::GetEngineLabels(string delimeter)
+string FGTurbine::GetEngineLabels(const string& delimiter)
{
std::ostringstream buf;
- buf << Name << "_N1[" << EngineNumber << "]" << delimeter
- << Name << "_N2[" << EngineNumber << "]" << delimeter
- << Thruster->GetThrusterLabels(EngineNumber, delimeter);
+ buf << Name << "_N1[" << EngineNumber << "]" << delimiter
+ << Name << "_N2[" << EngineNumber << "]" << delimiter
+ << Thruster->GetThrusterLabels(EngineNumber, delimiter);
return buf.str();
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-string FGTurbine::GetEngineValues(string delimeter)
+string FGTurbine::GetEngineValues(const string& delimiter)
{
std::ostringstream buf;
- buf << N1 << delimeter
- << N2 << delimeter
- << Thruster->GetThrusterValues(EngineNumber, delimeter);
+ buf << N1 << delimiter
+ << N2 << delimiter
+ << Thruster->GetThrusterValues(EngineNumber, delimiter);
return buf.str();
}
property_name = base_property_name + "/injection_cmd";
PropertyManager->Tie( property_name.c_str(), (FGTurbine*)this,
&FGTurbine::GetInjection, &FGTurbine::SetInjection);
+ property_name = base_property_name + "/seized";
+ PropertyManager->Tie( property_name.c_str(), &Seized);
+ property_name = base_property_name + "/stalled";
+ PropertyManager->Tie( property_name.c_str(), &Stalled);
+ property_name = base_property_name + "/bleed-factor";
+ PropertyManager->Tie( property_name.c_str(), (FGTurbine*)this, &FGTurbine::GetBleedDemand, &FGTurbine::SetBleedDemand);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
int FGTurbine::InitRunning(void) {
- State->SuspendIntegration();
+ FDMExec->SuspendIntegration();
Cutoff=false;
Running=true;
- N2=16.0;
+ N2=IdleN2;
Calculate();
- State->ResumeIntegration();
+ FDMExec->ResumeIntegration();
return phase==tpRun;
}