]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/models/propulsion/FGTurbine.cpp
Andreas Gaeb: fix #222 (JSBSIm reset problems)
[flightgear.git] / src / FDM / JSBSim / models / propulsion / FGTurbine.cpp
index b690d72f0cbf5e5b54cec99af18d763f1f1e3ceb..485c01c9421533e2ef9e81891888d37e561fc33d 100644 (file)
@@ -42,15 +42,16 @@ INCLUDES
 #include <iostream>
 #include <sstream>
 #include "FGTurbine.h"
-#include "FGState.h"
-#include "models/FGPropulsion.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.29 2010/08/31 04:01:32 jberndt Exp $";
 static const char *IdHdr = ID_TURBINE;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -112,13 +113,15 @@ void FGTurbine::ResetToIC(void)
 // 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;
   double qbar = Auxiliary->Getqbar();
-  dt = State->Getdt() * Propulsion->GetRate();
+  dt = FDMExec->GetDeltaT() * Propulsion->GetRate();
   ThrottlePos = FCS->GetThrottlePos(EngineNumber);
   if (ThrottlePos > 1.0) {
     AugmentCmd = ThrottlePos - 1.0;
@@ -145,7 +148,7 @@ double FGTurbine::Calculate(void)
 
   if (!Running && Cutoff && Starter) {
      if (phase == tpOff) phase = tpSpinUp;
-     }
+  }
 
   // start
   if ((Starter == true) || (qbar > 30.0)) {
@@ -169,9 +172,9 @@ double FGTurbine::Calculate(void)
     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();
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -223,7 +226,7 @@ double FGTurbine::Run()
 
   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);
@@ -388,7 +391,7 @@ double FGTurbine::Trim()
 
 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;
@@ -473,9 +476,6 @@ bool FGTurbine::Load(FGFDMExec* exec, Element *el)
       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;
     }
   }
 
@@ -539,12 +539,12 @@ void FGTurbine::bindmodel()
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 int FGTurbine::InitRunning(void) {
-  State->SuspendIntegration();
+  FDMExec->SuspendIntegration();
   Cutoff=false;
   Running=true;  
   N2=IdleN2;
   Calculate();
-  State->ResumeIntegration();
+  FDMExec->ResumeIntegration();
   return phase==tpRun;
 }