]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/models/propulsion/FGTurbine.cpp
Upgrade to JSBSim 1.0-prerelease
[flightgear.git] / src / FDM / JSBSim / models / propulsion / FGTurbine.cpp
index be8dc8a1908db918f6f0a76d0c0d5299ec1beb3e..6c4a7818c4a14a39d599e26f53315546479d8e60 100644 (file)
@@ -68,6 +68,7 @@ FGTurbine::FGTurbine(FGFDMExec* exec, Element *el, int engine_number)
   Augmented = AugMethod = Injected = 0;
   BypassRatio = BleedDemand = 0.0;
   IdleThrustLookup = MilThrustLookup = MaxThrustLookup = InjectionLookup = 0;
+  N1_spinup = 1.0; N2_spinup = 3.0; 
 
   ResetToIC();
 
@@ -91,6 +92,7 @@ FGTurbine::~FGTurbine()
 void FGTurbine::ResetToIC(void)
 {
   N1 = N2 = 0.0;
+  N2norm = 0.0;
   correctedTSFC = TSFC;
   ThrottlePos = AugmentCmd = 0.0;
   InletPosition = NozzlePosition = 1.0;
@@ -107,6 +109,8 @@ void FGTurbine::ResetToIC(void)
 
 double FGTurbine::Calculate(void)
 {
+  double thrust;
+
   TAT = (Auxiliary->GetTotalTemperature() - 491.69) * 0.5555556;
   dt = State->Getdt() * Propulsion->GetRate();
   ThrottlePos = FCS->GetThrottlePos(EngineNumber);
@@ -144,19 +148,19 @@ double FGTurbine::Calculate(void)
   if (Seized) phase = tpSeize;
 
   switch (phase) {
-    case tpOff:    Thrust = Off(); break;
-    case tpRun:    Thrust = Run(); break;
-    case tpSpinUp: Thrust = SpinUp(); break;
-    case tpStart:  Thrust = Start(); break;
-    case tpStall:  Thrust = Stall(); break;
-    case tpSeize:  Thrust = Seize(); break;
-    case tpTrim:   Thrust = Trim(); break;
-    default: Thrust = Off();
+    case tpOff:    thrust = Off(); break;
+    case tpRun:    thrust = Run(); break;
+    case tpSpinUp: thrust = SpinUp(); break;
+    case tpStart:  thrust = Start(); break;
+    case tpStall:  thrust = Stall(); break;
+    case tpSeize:  thrust = Seize(); break;
+    case tpTrim:   thrust = Trim(); break;
+    default: thrust = Off();
   }
 
-  Thrust = Thruster->Calculate(Thrust); // allow thruster to modify thrust (i.e. reversing)
+  thrust = Thruster->Calculate(thrust); // allow thruster to modify thrust (i.e. reversing)
 
-  return Thrust;
+  return thrust;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -183,7 +187,9 @@ double FGTurbine::Off(void)
 double FGTurbine::Run()
 {
   double idlethrust, milthrust, thrust;
-  double N2norm;   // 0.0 = idle N2, 1.0 = maximum N2
+  double spoolup;                        // acceleration in pct/sec
+  double sigma = Atmosphere->GetDensityRatio();
+  double T = Atmosphere->GetTemperature();
 
   idlethrust = MilThrust * IdleThrustLookup->GetValue();
   milthrust = (MilThrust - idlethrust) * MilThrustLookup->GetValue();
@@ -191,8 +197,13 @@ double FGTurbine::Run()
   Running = true;
   Starter = false;
 
-  N2 = Seek(&N2, IdleN2 + ThrottlePos * N2_factor, delay, delay * 3.0);
-  N1 = Seek(&N1, IdleN1 + ThrottlePos * N1_factor, delay, delay * 2.4);
+  // adjust acceleration for N2 and atmospheric density
+  double n = N2norm + 0.1;
+  if (n > 1) n = 1; 
+  spoolup = delay / (1 + 3 * (1-n)*(1-n)*(1-n) + (1 - sigma));
+  
+  N2 = Seek(&N2, IdleN2 + ThrottlePos * N2_factor, spoolup, spoolup * 3.0);
+  N1 = Seek(&N1, IdleN1 + ThrottlePos * N1_factor, spoolup, spoolup * 2.4);
   N2norm = (N2 - IdleN2) / N2_factor;
   thrust = idlethrust + (milthrust * N2norm * N2norm);
   EGT_degC = TAT + 363.1 + ThrottlePos * 357.1;
@@ -200,7 +211,7 @@ double FGTurbine::Run()
   OilTemp_degK = Seek(&OilTemp_degK, 366.0, 1.2, 0.1);
 
   if (!Augmentation) {
-    correctedTSFC = TSFC * (0.84 + (1-N2norm)*(1-N2norm));
+    correctedTSFC = TSFC * sqrt(T/389.7) * (0.84 + (1-N2norm)*(1-N2norm));
     FuelFlow_pph = Seek(&FuelFlow_pph, thrust * correctedTSFC, 1000.0, 100000);
     if (FuelFlow_pph < IdleFF) FuelFlow_pph = IdleFF;
     NozzlePosition = Seek(&NozzlePosition, 1.0 - N2norm, 0.8, 0.8);
@@ -253,8 +264,8 @@ double FGTurbine::SpinUp(void)
 {
   Running = false;
   FuelFlow_pph = 0.0;
-  N2 = Seek(&N2, 25.18, 3.0, N2/2.0);
-  N1 = Seek(&N1, 5.21, 1.0, N1/2.0);
+  N2 = Seek(&N2, 25.18, N2_spinup, N2/2.0);
+  N1 = Seek(&N1, 5.21, N1_spinup, N1/2.0);
   EGT_degC = Seek(&EGT_degC, TAT, 11.7, 7.3);
   OilPressure_psi = N2 * 0.62;
   OilTemp_degK = Seek(&OilTemp_degK, TAT + 273.0, 0.2, 0.2);
@@ -326,7 +337,7 @@ double FGTurbine::Seize(void)
 
 double FGTurbine::Trim()
 {
-    double idlethrust, milthrust, thrust, tdiff, N2norm;
+    double idlethrust, milthrust, thrust, tdiff;
     idlethrust = MilThrust * IdleThrustLookup->GetValue();
     milthrust = (MilThrust - idlethrust) * MilThrustLookup->GetValue();
     N2 = IdleN2 + ThrottlePos * N2_factor;
@@ -361,7 +372,10 @@ double FGTurbine::Trim()
 
 double FGTurbine::CalcFuelNeed(void)
 {
-  return FuelFlow_pph /3600 * State->Getdt() * Propulsion->GetRate();
+  double dT = State->Getdt() * 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;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -391,8 +405,8 @@ double FGTurbine::Seek(double *var, double target, double accel, double decel) {
 
 bool FGTurbine::Load(FGFDMExec* exec, Element *el)
 {
-  char property_prefix[80];
-  snprintf(property_prefix, 80, "propulsion/engine[%u]/", EngineNumber);
+  string property_name, property_prefix;
+  property_prefix = CreateIndexedPropertyName("propulsion/engine", EngineNumber);
 
   if (el->FindElement("milthrust"))
     MilThrust = el->FindElementValueAsNumberConvertTo("milthrust","LBS");
@@ -414,6 +428,10 @@ bool FGTurbine::Load(FGFDMExec* exec, Element *el)
     MaxN1 = el->FindElementValueAsNumber("maxn1");
   if (el->FindElement("maxn2"))
     MaxN2 = el->FindElementValueAsNumber("maxn2");
+  if (el->FindElement("n1spinup"))
+    N1_spinup = el->FindElementValueAsNumber("n1spinup");
+  if (el->FindElement("n2spinup"))
+    N2_spinup = el->FindElementValueAsNumber("n2spinup");
   if (el->FindElement("augmented"))
     Augmented = (int)el->FindElementValueAsNumber("augmented");
   if (el->FindElement("augmethod"))
@@ -447,7 +465,7 @@ bool FGTurbine::Load(FGFDMExec* exec, Element *el)
 
   // Pre-calculations and initializations
 
-  delay = 60.0 / (BypassRatio + 3.0);
+  delay = 90.0 / (BypassRatio + 3.0);
   N1_factor = MaxN1 - IdleN1;
   N2_factor = MaxN2 - IdleN2;
   OilTemp_degK = (Auxiliary->GetTotalTemperature() - 491.69) * 0.5555556 + 273.0;
@@ -487,16 +505,14 @@ string FGTurbine::GetEngineValues(string delimeter)
 
 void FGTurbine::bindmodel()
 {
-  char property_name[80];
-
-  snprintf(property_name, 80, "propulsion/engine[%u]/n1", EngineNumber);
-  PropertyManager->Tie( property_name, &N1);
-  snprintf(property_name, 80, "propulsion/engine[%u]/n2", EngineNumber);
-  PropertyManager->Tie( property_name, &N2);
-  snprintf(property_name, 80, "propulsion/engine[%u]/thrust", EngineNumber);
-  PropertyManager->Tie( property_name, this, &FGTurbine::GetThrust);
-  snprintf(property_name, 80, "propulsion/engine[%u]/injection_cmd", EngineNumber);
-  PropertyManager->Tie( property_name, (FGTurbine*)this, 
+  string property_name, base_property_name;
+  base_property_name = CreateIndexedPropertyName("propulsion/engine", EngineNumber);
+  property_name = base_property_name + "/n1";
+  PropertyManager->Tie( property_name.c_str(), &N1);
+  property_name = base_property_name + "/n2";
+  PropertyManager->Tie( property_name.c_str(), &N2);
+  property_name = base_property_name + "/injection_cmd";
+  PropertyManager->Tie( property_name.c_str(), (FGTurbine*)this, 
                         &FGTurbine::GetInjection, &FGTurbine::SetInjection);
 }