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