]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGTurbine.cpp
Fix stall widths for the "auxilliary" (reverse flow) stalls so they
[flightgear.git] / src / FDM / JSBSim / FGTurbine.cpp
index 909413f8b3afe6f34c194d61fc4dcbdf74824525..d43031b38252f26c9e64c9b2d07439f10f57273a 100644 (file)
@@ -113,21 +113,19 @@ double FGTurbine::Calculate(void)
   if (Stalled) phase = tpStall;
   if (Seized) phase = tpSeize;
 
-  double CT = 0.0;
   switch (phase) {
     case tpOff:    Thrust = Off(); break;
-    case tpRun:    Thrust = Run(CT); 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(CT); break;
+    case tpTrim:   Thrust = Trim(); break;
     default: Thrust = Off();
   }
 
-  Thruster->SetThrustCoefficient(CT);
-
-  return Thruster->Calculate(Thrust);
+  // The thruster can modify the thrust, eg. thrust reverser
+  return Thrust = Thruster->Calculate(Thrust);
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -150,13 +148,12 @@ double FGTurbine::Off(void)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-double FGTurbine::Run(double &TC)
+double FGTurbine::Run(void)
 {
   double idlethrust, milthrust, thrust;
   double N2norm;   // 0.0 = idle N2, 1.0 = maximum N2
-
-  idlethrust = ThrustTables[0]->TotalValue();
-  milthrust = (1.0 - idlethrust) * ThrustTables[1]->TotalValue();
+  idlethrust = MilThrust * ThrustTables[0]->TotalValue();
+  milthrust = (MilThrust - idlethrust) * ThrustTables[1]->TotalValue();
 
   Running = true;
   Starter = false;
@@ -164,19 +161,18 @@ double FGTurbine::Run(double &TC)
   N2 = Seek(&N2, IdleN2 + ThrottlePos * N2_factor, delay, delay * 3.0);
   N1 = Seek(&N1, IdleN1 + ThrottlePos * N1_factor, delay, delay * 2.4);
   N2norm = (N2 - IdleN2) / N2_factor;
-  TC = idlethrust + (milthrust * N2norm * N2norm);
-  thrust = TC * MilThrust;
+  thrust = idlethrust + (milthrust * N2norm * N2norm);
   EGT_degC = TAT + 363.1 + ThrottlePos * 357.1;
   OilPressure_psi = N2 * 0.62;
   OilTemp_degK = Seek(&OilTemp_degK, 366.0, 1.2, 0.1);
 
   if (!Augmentation) {
-    double correctedTSFC = TSFC + TSFC - (N2norm * TSFC);
+    double correctedTSFC = TSFC * (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);
-    TC = TC * (1.0 - BleedDemand);
-    EPR = 1.0 + TC;
+    thrust = thrust * (1.0 - BleedDemand);
+    EPR = 1.0 + thrust/MilThrust;
   }
 
   if (AugMethod == 1) {
@@ -185,8 +181,7 @@ double FGTurbine::Run(double &TC)
   }
 
   if ((Augmented == 1) && Augmentation && (AugMethod < 2)) {
-    TC = ThrustTables[2]->TotalValue();
-    thrust = TC * MaxThrust;
+    thrust = MaxThrust * ThrustTables[2]->TotalValue();
     FuelFlow_pph = Seek(&FuelFlow_pph, thrust * ATSFC, 5000.0, 10000.0);
     NozzlePosition = Seek(&NozzlePosition, 1.0, 0.8, 0.8);
   }
@@ -194,9 +189,8 @@ double FGTurbine::Run(double &TC)
   if (AugMethod == 2) {
     if (AugmentCmd > 0.0) {
       Augmentation = true;
-      double tdiff = ThrustTables[2]->TotalValue() - TC;
-      TC += (tdiff * AugmentCmd);
-      thrust = TC * MaxThrust;
+      double tdiff = (MaxThrust * ThrustTables[2]->TotalValue()) - thrust;
+      thrust += (tdiff * AugmentCmd);
       FuelFlow_pph = Seek(&FuelFlow_pph, thrust * ATSFC, 5000.0, 10000.0);
       NozzlePosition = Seek(&NozzlePosition, 1.0, 0.8, 0.8);
     } else {
@@ -205,8 +199,7 @@ double FGTurbine::Run(double &TC)
   }
 
   if ((Injected == 1) && Injection) {
-    TC = TC * ThrustTables[3]->TotalValue();
-    thrust = thrust * ThrustTables[3]->TotalValue();
+     thrust = thrust * ThrustTables[3]->TotalValue();
   }
 
   ConsumeFuel();
@@ -244,6 +237,7 @@ double FGTurbine::Start(void)
       EGT_degC = Seek(&EGT_degC, TAT + 363.1, 21.3, 7.3);
       FuelFlow_pph = Seek(&FuelFlow_pph, IdleFF, 103.7, 103.7);
       OilPressure_psi = N2 * 0.62;
+      ConsumeFuel();
       }
     else {
       phase = tpRun;
@@ -269,6 +263,7 @@ double FGTurbine::Stall(void)
   FuelFlow_pph = IdleFF;
   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
 
   return 0.0;
@@ -282,6 +277,7 @@ double FGTurbine::Seize(void)
     N2 = 0.0;
     N1 = Seek(&N1, qbar/20.0, 0, N1/15.0);
     FuelFlow_pph = IdleFF;
+    ConsumeFuel();
     OilPressure_psi = 0.0;
     OilTemp_degK = Seek(&OilTemp_degK, TAT + 273.0, 0, 0.2);
     Running = false;
@@ -290,20 +286,17 @@ double FGTurbine::Seize(void)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-double FGTurbine::Trim(double &TC)
+double FGTurbine::Trim(void)
 {
     double idlethrust, milthrust, thrust, tdiff;
-    idlethrust = ThrustTables[0]->TotalValue();;
-    milthrust = (1.0 - TC) * ThrustTables[1]->TotalValue();
-    TC = (idlethrust + (milthrust * ThrottlePos * ThrottlePos))
+    idlethrust = MilThrust * ThrustTables[0]->TotalValue();;
+    milthrust = (MilThrust - idlethrust) * ThrustTables[1]->TotalValue();
+    thrust = (idlethrust + (milthrust * ThrottlePos * ThrottlePos))
           * (1.0 - BleedDemand);
     if (AugmentCmd > 0.0) {
-      tdiff = ThrustTables[2]->TotalValue() - TC;
-      TC += (tdiff * AugmentCmd);
-      thrust = TC * MaxThrust;
-
-     } else
-      thrust = TC * MilThrust;
+      tdiff = (MaxThrust * ThrustTables[2]->TotalValue()) - thrust;
+      thrust += (tdiff * AugmentCmd);
+    } 
 
     return thrust;
 }
@@ -427,26 +420,26 @@ bool FGTurbine::Load(FGConfigFile *Eng_cfg)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-string FGTurbine::GetEngineLabels(void)
+string FGTurbine::GetEngineLabels(string delimeter)
 {
   std::ostringstream buf;
 
-  buf << Name << "_N1[" << EngineNumber << "], "
-      << Name << "_N2[" << EngineNumber << "], "
-      << Thruster->GetThrusterLabels(EngineNumber);
+  buf << Name << "_N1[" << EngineNumber << "]" << delimeter
+      << Name << "_N2[" << EngineNumber << "]" << delimeter
+      << Thruster->GetThrusterLabels(EngineNumber, delimeter);
 
   return buf.str();
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-string FGTurbine::GetEngineValues(void)
+string FGTurbine::GetEngineValues(string delimeter)
 {
   std::ostringstream buf;
 
-  buf << N1 << ", "
-      << N2 << ", "
-      << Thruster->GetThrusterValues(EngineNumber);
+  buf << N1 << delimeter
+      << N2 << delimeter
+      << Thruster->GetThrusterValues(EngineNumber, delimeter);
 
   return buf.str();
 }
@@ -457,10 +450,12 @@ void FGTurbine::bindmodel()
 {
   char property_name[80];
 
-  snprintf(property_name, 80, "propulsion/n1[%u]", EngineNumber);
+  snprintf(property_name, 80, "propulsion/engine[%u]/n1", EngineNumber);
   PropertyManager->Tie( property_name, &N1);
-  snprintf(property_name, 80, "propulsion/n2[%u]", EngineNumber);
+  snprintf(property_name, 80, "propulsion/engine[%u]/n2", EngineNumber);
   PropertyManager->Tie( property_name, &N2);
+  snprintf(property_name, 80, "propulsion/engine[%u]/fuel-flow", EngineNumber);
+  PropertyManager->Tie( property_name, &FuelFlow_pph);
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -469,10 +464,12 @@ void FGTurbine::unbind()
 {
   char property_name[80];
 
-  snprintf(property_name, 80, "propulsion/n1[%u]", EngineNumber);
+  snprintf(property_name, 80, "propulsion/engine[%u]/n1", EngineNumber);
   PropertyManager->Untie(property_name);
-  snprintf(property_name, 80, "propulsion/n2[%u]", EngineNumber);
+  snprintf(property_name, 80, "propulsion/engine[%u]/n2", EngineNumber);
   PropertyManager->Untie(property_name);
+  snprintf(property_name, 80, "propulsion/engine[%u]/fuel-flow", EngineNumber);
+  PropertyManager->Untie( property_name);
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%