JSBSim Flight Dynamics Model  1.0 (02 March 2017)
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 #define ID_TURBINE "$Id: FGTurbine.h,v 1.26 2015/09/27 10:07:53 bcoconni Exp $"
46 
47 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
48 FORWARD DECLARATIONS
49 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
50 
51 namespace JSBSim {
52 
53 class Element;
54 class FGFunction;
55 
56 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57 CLASS DOCUMENTATION
58 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
59 
158 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
159 CLASS DECLARATION
160 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
161 
162 class FGTurbine : public FGEngine
163 {
164 public:
169  FGTurbine(FGFDMExec* Executive, Element *el, int engine_number, struct Inputs& input);
171  ~FGTurbine();
172 
173  enum phaseType { tpOff, tpRun, tpSpinUp, tpStart, tpStall, tpSeize, tpTrim };
174 
175  void Calculate(void);
176  double CalcFuelNeed(void);
177  double GetPowerAvailable(void);
184  double Seek(double* var, double target, double accel, double decel);
185 
186  phaseType GetPhase(void) { return phase; }
187 
188  bool GetOvertemp(void) const {return Overtemp; }
189  bool GetInjection(void) const {return Injection;}
190  bool GetFire(void) const { return Fire; }
191  bool GetAugmentation(void) const {return Augmentation;}
192  bool GetReversed(void) const { return Reversed; }
193  bool GetCutoff(void) const { return Cutoff; }
194  int GetIgnition(void) const {return Ignition;}
195 
196  double GetInlet(void) const { return InletPosition; }
197  double GetNozzle(void) const { return NozzlePosition; }
198  double GetBleedDemand(void) const {return BleedDemand;}
199  double GetN1(void) const {return N1;}
200  double GetN2(void) const {return N2;}
201  double GetEPR(void) const {return EPR;}
202  double GetEGT(void) const {return EGT_degC;}
203 
204  double GetMaxN1(void) const {return MaxN1;}
205  double GetMaxN2(void) const {return MaxN2;}
206  double getOilPressure_psi () const {return OilPressure_psi;}
207  double getOilTemp_degF (void) {return KelvinToFahrenheit(OilTemp_degK);}
208  double GetInjectionTimer(void) const {return InjectionTimer;}
209  double GetInjWaterNorm(void) const {return InjWaterNorm;}
210  double GetInjN1increment(void) const {return InjN1increment;}
211  double GetInjN2increment(void) const {return InjN2increment;}
212 
213  void SetInjection(bool injection) {Injection = injection;}
214  void SetIgnition(int ignition) {Ignition = ignition;}
215  void SetAugmentation(bool augmentation) {Augmentation = augmentation;}
216  void SetPhase( phaseType p ) { phase = p; }
217  void SetEPR(double epr) {EPR = epr;}
218  void SetBleedDemand(double bleedDemand) {BleedDemand = bleedDemand;}
219  void SetReverse(bool reversed) { Reversed = reversed; }
220  void SetCutoff(bool cutoff) { Cutoff = cutoff; }
221  void SetMaxN1(double maxn1) {MaxN1 = maxn1;}
222  void SetMaxN2(double maxn2) {MaxN2 = maxn2;}
223  void SetInjectionTimer(double injtimer) {InjectionTimer = injtimer;}
224  void SetInjWaterNorm(double injwater) {InjWaterNorm = injwater;}
225  void SetInjN1increment(double injN1inc) {InjN1increment = injN1inc;}
226  void SetInjN2increment(double injN2inc) {InjN2increment = injN2inc;}
227 
228  int InitRunning(void);
229  void ResetToIC(void);
230 
231  std::string GetEngineLabels(const std::string& delimiter);
232  std::string GetEngineValues(const std::string& delimiter);
233 
234 private:
235 
236  phaseType phase;
237  double MilThrust;
238  double MaxThrust;
239  double BypassRatio;
240  double TSFC;
241  double ATSFC;
242  double IdleN1;
243  double IdleN2;
244  double N1;
245  double N2;
246  double N2norm;
247  double MaxN1;
248  double MaxN2;
249  double IdleFF;
250  double delay;
251  double N1_factor;
252  double N2_factor;
253  double ThrottlePos;
254  double AugmentCmd;
255  double N1_spinup;
256  double N2_spinup;
257  bool Stalled;
258  bool Seized;
259  bool Overtemp;
260  bool Fire;
261  bool Injection;
262  bool Augmentation;
263  bool Reversed;
264  bool Cutoff;
265  int Injected;
266  int Ignition;
267  int Augmented;
268  int AugMethod;
269  double EGT_degC;
272  double EPR;
273  double OilPressure_psi;
274  double OilTemp_degK;
275  double BleedDemand;
276  double InletPosition;
277  double NozzlePosition;
278  double correctedTSFC;
279  double InjectionTimer;
280  double InjectionTime;
281  double InjWaterNorm;
282  double InjN1increment;
283  double InjN2increment;
284 
285  double Off(void);
286  double Run();
287  double SpinUp(void);
288  double Start(void);
289  double Stall(void);
290  double Seize(void);
291  double Trim();
292 
293  FGFunction *IdleThrustLookup;
294  FGFunction *MilThrustLookup;
295  FGFunction *MaxThrustLookup;
296  FGFunction *InjectionLookup;
297  FGFDMExec* FDMExec;
298 
299  bool Load(FGFDMExec *exec, Element *el);
300  void bindmodel(FGPropertyManager* pm);
301  void Debug(int from);
302 
303 };
304 }
305 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
306 #endif
307 
~FGTurbine()
Destructor.
Definition: FGTurbine.cpp:87
static double KelvinToFahrenheit(double kelvin)
Converts from degrees Kelvin to degrees Fahrenheit.
Definition: FGJSBBase.h:197
double Seek(double *var, double target, double accel, double decel)
A lag filter.
Definition: FGTurbine.cpp:406
void Calculate(void)
Calculates the thrust of the engine, and other engine functions.
Definition: FGTurbine.cpp:115
This class models a turbine engine.
Definition: FGTurbine.h:162
void ResetToIC(void)
Resets the Engine parameters to the initial conditions.
Definition: FGTurbine.cpp:94
FGTurbine(FGFDMExec *Executive, Element *el, int engine_number, struct Inputs &input)
Constructor.
Definition: FGTurbine.cpp:62
double CalcFuelNeed(void)
The fuel need is calculated based on power levels and flow rate for that power level.
Definition: FGTurbine.cpp:387
Represents a mathematical function.
Definition: FGFunction.h:699
Base class for all engines.
Definition: FGEngine.h:121
Encapsulates the JSBSim simulation executive.
Definition: FGFDMExec.h:189