JSBSim Flight Dynamics Model  1.1.11 (13 Feb 2022)
An Open Source Flight Dynamics and Control Software Library in C++
FGTurbine.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 
3  Header: FGTurbine.h
4  Author: David Culp
5  Date started: 03/11/2003
6 
7  ------------- Copyright (C) 2003 David Culp (daveculp@cox.net)----------
8 
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU Lesser General Public License as published by the Free Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  version.
13 
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
17  details.
18 
19  You should have received a copy of the GNU Lesser General Public License along with
20  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21  Place - Suite 330, Boston, MA 02111-1307, USA.
22 
23  Further information about the GNU Lesser General Public License can also be found on
24  the world wide web at http://www.gnu.org.
25 
26 HISTORY
27 --------------------------------------------------------------------------------
28 03/11/2003 DPC Created, based on FGTurbine
29 09/22/2003 DPC Added starting, stopping, new framework
30 04/29/2004 DPC Renamed from FGSimTurbine to FGTurbine
31 
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
33 SENTRY
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
35 
36 #ifndef FGTURBINE_H
37 #define FGTURBINE_H
38 
39 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
40 INCLUDES
41 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
42 
43 #include "FGEngine.h"
44 
45 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
46 FORWARD DECLARATIONS
47 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
48 
49 namespace JSBSim {
50 
51 class Element;
52 class FGFunction;
53 
54 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
55 CLASS DOCUMENTATION
56 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
57 
169 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
170 CLASS DECLARATION
171 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
172 
173 class FGTurbine : public FGEngine
174 {
175 public:
180  FGTurbine(FGFDMExec* Executive, Element *el, int engine_number, struct Inputs& input);
182  ~FGTurbine();
183 
184  enum phaseType { tpOff, tpRun, tpSpinUp, tpStart, tpStall, tpSeize, tpTrim };
185 
186  void Calculate(void);
187  double CalcFuelNeed(void);
188  double GetPowerAvailable(void);
195  double Seek(double* var, double target, double accel, double decel);
196 
197  phaseType GetPhase(void) { return phase; }
198 
199  bool GetOvertemp(void) const {return Overtemp; }
200  bool GetInjection(void) const {return Injection;}
201  bool GetFire(void) const { return Fire; }
202  bool GetAugmentation(void) const {return Augmentation;}
203  bool GetReversed(void) const { return Reversed; }
204  bool GetCutoff(void) const { return Cutoff; }
205  int GetIgnition(void) const {return Ignition;}
206 
207  double GetInlet(void) const { return InletPosition; }
208  double GetNozzle(void) const { return NozzlePosition; }
209  double GetBleedDemand(void) const {return BleedDemand;}
210  double GetN1(void) const {return N1;}
211  double GetN2(void) const {return N2;}
212  double GetEPR(void) const {return EPR;}
213  double GetEGT(void) const {return EGT_degC;}
214 
215  double GetMaxN1(void) const {return MaxN1;}
216  double GetMaxN2(void) const {return MaxN2;}
217  double getOilPressure_psi () const {return OilPressure_psi;}
218  double getOilTemp_degF (void) {return KelvinToFahrenheit(OilTemp_degK);}
219  double GetInjectionTimer(void) const {return InjectionTimer;}
220  double GetInjWaterNorm(void) const {return InjWaterNorm;}
221  double GetInjN1increment(void) const {return InjN1increment;}
222  double GetInjN2increment(void) const {return InjN2increment;}
223 
224  void SetInjection(bool injection) {Injection = injection;}
225  void SetIgnition(int ignition) {Ignition = ignition;}
226  void SetAugmentation(bool augmentation) {Augmentation = augmentation;}
227  void SetPhase( phaseType p ) { phase = p; }
228  void SetEPR(double epr) {EPR = epr;}
229  void SetBleedDemand(double bleedDemand) {BleedDemand = bleedDemand;}
230  void SetReverse(bool reversed) { Reversed = reversed; }
231  void SetCutoff(bool cutoff) { Cutoff = cutoff; }
232  void SetMaxN1(double maxn1) {MaxN1 = maxn1;}
233  void SetMaxN2(double maxn2) {MaxN2 = maxn2;}
234  void SetInjectionTimer(double injtimer) {InjectionTimer = injtimer;}
235  void SetInjWaterNorm(double injwater) {InjWaterNorm = injwater;}
236  void SetInjN1increment(double injN1inc) {InjN1increment = injN1inc;}
237  void SetInjN2increment(double injN2inc) {InjN2increment = injN2inc;}
238 
239  int InitRunning(void);
240  void ResetToIC(void);
241 
242  std::string GetEngineLabels(const std::string& delimiter);
243  std::string GetEngineValues(const std::string& delimiter);
244 
245 private:
246 
247  phaseType phase;
248  double MilThrust;
249  double MaxThrust;
250  double BypassRatio;
251  double TSFC;
252  double ATSFC;
253  double IdleN1;
254  double IdleN2;
255  double IgnitionN1;
256  double IgnitionN2;
257  double N1;
258  double N2;
259  double N2norm;
260  double MaxN1;
261  double MaxN2;
262  double IdleFF;
263  double N1_factor;
264  double N2_factor;
265  double ThrottlePos;
266  double AugmentCmd;
267  double N1_spinup;
268  double N2_spinup;
269  double N1_start_rate;
270  double N2_start_rate;
271  double N1_spindown;
272  double N2_spindown;
273  bool Stalled;
274  bool Seized;
275  bool Overtemp;
276  bool Fire;
277  bool Injection;
278  bool Augmentation;
279  bool Reversed;
280  bool Cutoff;
281  bool disableWindmill;
282  int Injected;
283  int Ignition;
284  int Augmented;
285  int AugMethod;
286  double EGT_degC;
289  double EPR;
290  double OilPressure_psi;
291  double OilTemp_degK;
292  double BleedDemand;
293  double InletPosition;
294  double NozzlePosition;
295  double correctedTSFC;
296  double InjectionTimer;
297  double InjectionTime;
298  double InjWaterNorm;
299  double InjN1increment;
300  double InjN2increment;
301 
302  double Off(void);
303  double Run();
304  double SpinUp(void);
305  double Start(void);
306  double Stall(void);
307  double Seize(void);
308  double Trim();
309 
310  FGFunction *IdleThrustLookup;
311  FGFunction *MilThrustLookup;
312  FGFunction *MaxThrustLookup;
313  FGFunction *InjectionLookup;
314  FGFDMExec* FDMExec;
315  FGParameter *N1SpoolUp;
316  FGParameter *N1SpoolDown;
317  FGParameter *N2SpoolUp;
318  FGParameter *N2SpoolDown;
319 
320  bool Load(FGFDMExec *exec, Element *el);
321  void bindmodel(FGPropertyManager* pm);
322  void Debug(int from);
323 
324  friend class FGSpoolUp;
325 };
326 
327 class FGSpoolUp : public FGParameter
328 {
329 public:
330  FGSpoolUp(FGTurbine* _turb, double BPR, double factor)
331  : turb(_turb), delay(factor * 90.0 / (BPR + 3.0)) {}
332  string GetName(void) const { return string(); };
333  double GetValue(void) const {
334  // adjust acceleration for N2 and atmospheric density
335  double n = std::min(1.0, turb->N2norm + 0.1);
336  return delay / (1 + 3 * (1-n)*(1-n)*(1-n) + (1 - turb->in.DensityRatio));
337  }
338 private:
339  FGTurbine* turb;
340  double delay;
341 };
342 }
343 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
344 #endif
JSBSim::FGFDMExec
Encapsulates the JSBSim simulation executive.
Definition: FGFDMExec.h:185
JSBSim::FGFunction
Represents a mathematical function.
Definition: FGFunction.h:752
JSBSim::FGJSBBase::KelvinToFahrenheit
static constexpr double KelvinToFahrenheit(double kelvin)
Converts from degrees Kelvin to degrees Fahrenheit.
Definition: FGJSBBase.h:195
JSBSim::FGParameter
Represents various types of parameters.
Definition: FGParameter.h:58
JSBSim::FGTurbine::ResetToIC
void ResetToIC(void)
Resets the Engine parameters to the initial conditions.
Definition: FGTurbine.cpp:101
JSBSim::FGTurbine::FGTurbine
FGTurbine(FGFDMExec *Executive, Element *el, int engine_number, struct Inputs &input)
Constructor.
Definition: FGTurbine.cpp:59
JSBSim::FGTurbine::CalcFuelNeed
double CalcFuelNeed(void)
The fuel need is calculated based on power levels and flow rate for that power level.
Definition: FGTurbine.cpp:397
JSBSim::FGTurbine::Calculate
void Calculate(void)
Calculates the thrust of the engine, and other engine functions.
Definition: FGTurbine.cpp:122
JSBSim::FGEngine::Inputs
Definition: FGEngine.h:106
JSBSim::FGSpoolUp
Definition: FGTurbine.h:327
JSBSim::FGTurbine::~FGTurbine
~FGTurbine()
Destructor.
Definition: FGTurbine.cpp:86
JSBSim::FGEngine
Base class for all engines.
Definition: FGEngine.h:103
JSBSim::FGTurbine::Seek
double Seek(double *var, double target, double accel, double decel)
A lag filter.
Definition: FGTurbine.cpp:416
JSBSim::FGTurbine
This class models a turbine engine.
Definition: FGTurbine.h:173
JSBSim::FGPropertyManager
Definition: FGPropertyManager.h:373
JSBSim::Element
Definition: FGXMLElement.h:143