]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGSimTurbine.h
Encapsulate the interpolstion version of FGEnvironment and fix some bugs
[flightgear.git] / src / FDM / JSBSim / FGSimTurbine.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3  Header:       FGSimTurbine.h
4  Author:       David Culp
5  Date started: 03/11/2003
6
7  ------------- Copyright (C) 2003  David Culp (davidculp2@comcast.net)----------
8
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU 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 General Public License for more
17  details.
18
19  You should have received a copy of the GNU 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 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
31 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
32 SENTRY
33 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
34
35 #ifndef FGSIMTURBINE_H
36 #define FGSIMTURBINE_H
37
38 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39 INCLUDES
40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
41
42 #include <vector>
43 #include "FGEngine.h"
44 #include "FGConfigFile.h"
45 #include "FGCoefficient.h"
46
47 #define ID_SIMTURBINE "$Id$"
48
49 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
50 FORWARD DECLARATIONS
51 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
52
53 namespace JSBSim {
54
55 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
56 CLASS DOCUMENTATION
57 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
58
59 /** This class models a turbine engine.  Based on Jon Berndt's FGTurbine module.
60     Here the term "phase" signifies the engine's mode of operation.  At any given
61     time the engine is in only one phase.  At simulator startup the engine will be
62     placed in the Trim phase in order to provide a simplified thrust value without
63     throttle lag.  When trimming is complete the engine will go to the Off phase,
64     unless the value FGEngine::Running has been previously set to true, in which
65     case the engine will go to the Run phase.  Once an engine is in the Off phase
66     the full starting procedure (or airstart) must be used to get it running.
67 <P>
68     - STARTING (on ground):
69       -# Set the control FGEngine::Starter to true.  The engine will spin up to
70          a maximum of about %25 N2 (%5.2 N1).  This simulates the action of a
71          pneumatic starter.
72       -# After reaching %15 N2 set the control FGEngine::Cutoff to false. If fuel
73          is available the engine will now accelerate to idle.  The starter will
74          automatically be set to false after the start cycle.
75 <P>
76     - STARTING (in air):
77       -# Increase speed to obtain a minimum of %15 N2.  If this is not possible,
78          the starter may be used to assist.
79       -# Place the control FGEngine::Cutoff to false.
80 <P>
81     Ignition is assumed to be on anytime the Cutoff control is set to false, 
82     therefore a seperate ignition system is not modeled.
83
84 Configuration File Format
85 <pre>
86 \<FG_SIMTURBINE NAME="<name>">
87   MILTHRUST   \<thrust>
88   MAXTHRUST   \<thrust>
89   BYPASSRATIO \<bypass ratio>
90   TSFC        \<thrust specific fuel consumption>
91   ATSFC       \<afterburning thrust specific fuel consumption>
92   IDLEN1      \<idle N1>
93   IDLEN2      \<idle N2>
94   MAXN1       \<max N1>
95   MAXN2       \<max N2>
96   AUGMENTED   \<0|1>
97   AUGMETHOD   \<0|1>
98   INJECTED    \<0|1>
99   ...
100 \</FG_SIMTURBINE>
101 </pre>
102 Definition of the turbine engine configuration file parameters:
103 <pre>
104 <b>MILTHRUST</b> - Maximum thrust, static, at sea level, lbf.
105 <b>MAXTHRUST</b> - Afterburning thrust, static, at sea level, lbf
106 [this value will be ignored when AUGMENTED is zero (false)].
107 <b>BYPASSRATIO</b> - Ratio of bypass air flow to core air flow.
108 <b>TSFC</b> - Thrust-specific fuel consumption, lbm/hr/lbf
109 [i.e. fuel flow divided by thrust].
110 <b>ATSFC</b> - Afterburning TSFC, lbm/hr/lbf
111 [this value will be ignored when AUGMENTED is zero (false)]
112 <b>IDLEN1</b> - Fan rotor rpm (% of max) at idle
113 <b>IDLEN2</b> - Core rotor rpm (% of max) at idle
114 <b>MAXN1</b> - Fan rotor rpm (% of max) at full throttle [not always 100!] 
115 <b>MAXN2</b> - Core rotor rpm (% of max) at full throttle [not always 100!]
116 <b>AUGMENTED</b>
117   0 == afterburner not installed
118   1 == afterburner installed
119 <b>AUGMETHOD</b>
120   0 == afterburner activated by property /engines/engine[n]/augmentation
121   1 == afterburner activated by pushing throttle above 99% position
122   [this item will be ignored when AUGMENTED == 0]
123 <b>INJECTED</b>
124   0 == Water injection not installed
125   1 == Water injection installed
126 </pre>
127     @author David P. Culp
128     @version "$Id$"
129 */
130
131 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
132 CLASS DECLARATION
133 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
134
135 class FGSimTurbine : public FGEngine
136 {
137 public:
138   /** Constructor
139       @param Executive pointer to executive structure
140       @param Eng_cfg pointer to engine config file instance */
141   FGSimTurbine(FGFDMExec* Executive, FGConfigFile* Eng_cfg);
142   /// Destructor
143   ~FGSimTurbine();
144
145   enum phaseType { tpOff, tpRun, tpSpinUp, tpStart, tpStall, tpSeize, tpTrim };
146
147   double Calculate(double PowerRequired);
148   double CalcFuelNeed(void);
149   double GetPowerAvailable(void);
150   double Seek(double* var, double target, double accel, double decel);
151
152   phaseType GetPhase(void) { return phase; }
153
154   bool GetOvertemp(void)  {return Overtemp; }
155   bool GetInjection(void) {return Injection;}
156   bool GetFire(void) { return Fire; }
157   bool GetAugmentation(void) {return Augmentation;}
158   bool GetReversed(void) { return Reversed; }
159   bool GetCutoff(void) { return Cutoff; }
160   int GetIgnition(void) {return Ignition;}
161
162   double GetInlet(void) { return InletPosition; }
163   double GetNozzle(void) { return NozzlePosition; } 
164   double GetBleedDemand(void) {return BleedDemand;}
165   double GetN1(void) {return N1;}
166   double GetN2(void) {return N2;}
167   double GetEPR(void) {return EPR;}
168   double GetEGT(void) {return EGT_degC;}
169
170   double getOilPressure_psi () const {return OilPressure_psi;}
171   double getOilTemp_degF (void) {return KelvinToFahrenheit(OilTemp_degK);}
172
173   void SetInjection(bool injection) {Injection = injection;}
174   void SetIgnition(int ignition) {Ignition = ignition;}
175   void SetAugmentation(bool augmentation) {Augmentation = augmentation;}
176   void SetPhase( phaseType p ) { phase = p; }
177   void SetEPR(double epr) {EPR = epr;}
178   void SetBleedDemand(double bleedDemand) {BleedDemand = bleedDemand;}
179   void SetReverse(bool reversed) { Reversed = reversed; }
180   void SetCutoff(bool cutoff) { Cutoff = cutoff; }
181
182 private:
183
184   typedef vector<FGCoefficient*> CoeffArray;
185   CoeffArray ThrustTables;
186
187   phaseType phase;         ///< Operating mode, or "phase"
188   double MilThrust;        ///< Maximum Unaugmented Thrust, static @ S.L. (lbf)
189   double MaxThrust;        ///< Maximum Augmented Thrust, static @ S.L. (lbf)
190   double BypassRatio;      ///< Bypass Ratio
191   double TSFC;             ///< Thrust Specific Fuel Consumption (lbm/hr/lbf)
192   double ATSFC;            ///< Augmented TSFC (lbm/hr/lbf)
193   double IdleN1;           ///< Idle N1
194   double IdleN2;           ///< Idle N2
195   double N1;               ///< N1
196   double N2;               ///< N2
197   double MaxN1;            ///< N1 at 100% throttle
198   double MaxN2;            ///< N2 at 100% throttle
199   double IdleFF;           ///< Idle Fuel Flow (lbm/hr)
200   double delay;            ///< Inverse spool-up time from idle to 100% (seconds)
201   double dt;               ///< Simulator time slice
202   double N1_factor;        ///< factor to tie N1 and throttle
203   double N2_factor;        ///< factor to tie N2 and throttle
204   double ThrottleCmd;      ///< FCS-supplied throttle position
205   double TAT;              ///< total air temperature (deg C)
206   bool Stalled;            ///< true if engine is compressor-stalled
207   bool Seized;             ///< true if inner spool is seized
208   bool Overtemp;           ///< true if EGT exceeds limits
209   bool Fire;               ///< true if engine fire detected
210   bool Injection;
211   bool Augmentation;
212   bool Reversed;
213   bool Cutoff;
214   int Injected;            ///< = 1 if water injection installed
215   int Ignition;
216   int Augmented;           ///< = 1 if augmentation installed
217   int AugMethod;           ///< = 0 if using property /engine[n]/augmentation
218                            ///< = 1 if using last 1% of throttle movement
219   double EGT_degC;
220   double EPR;
221   double OilPressure_psi;
222   double OilTemp_degK;
223   double BleedDemand;
224   double InletPosition;
225   double NozzlePosition;
226
227   double Off(void);
228   double Run(void);
229   double SpinUp(void);
230   double Start(void);
231   double Stall(void);
232   double Seize(void);
233   double Trim(void);
234
235   void SetDefaults(void);
236   bool Load(FGConfigFile *ENG_cfg);
237   void Debug(int from);
238
239 };
240 }
241 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
242 #endif
243