1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5 Date started: 03/11/2003
7 ------------- Copyright (C) 2003 David Culp (davidculp2@comcast.net)----------
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
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
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.
23 Further information about the GNU General Public License can also be found on
24 the world wide web at http://www.gnu.org.
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
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
39 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
41 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
45 #include "FGConfigFile.h"
46 #include "FGCoefficient.h"
48 #define ID_TURBINE "$Id$"
50 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
52 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
56 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
58 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
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.
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
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.
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.
82 Ignition is assumed to be on anytime the Cutoff control is set to false,
83 therefore a seperate ignition system is not modeled.
85 Configuration File Format
87 \<FG_TURBINE NAME="<name>">
90 BYPASSRATIO \<bypass ratio>
91 TSFC \<thrust specific fuel consumption>
92 ATSFC \<afterburning thrust specific fuel consumption>
103 Definition of the turbine engine configuration file parameters:
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!]
118 0 == afterburner not installed
119 1 == afterburner installed
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]
126 0 == Water injection not installed
127 1 == Water injection installed
129 @author David P. Culp
133 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
135 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
137 class FGTurbine : public FGEngine
141 @param Executive pointer to executive structure
142 @param Eng_cfg pointer to engine config file instance
143 @param engine_number engine number*/
144 FGTurbine(FGFDMExec* Executive, FGConfigFile* Eng_cfg, int engine_number);
148 enum phaseType { tpOff, tpRun, tpSpinUp, tpStart, tpStall, tpSeize, tpTrim };
150 double Calculate(void);
151 double CalcFuelNeed(void);
152 double GetPowerAvailable(void);
153 double Seek(double* var, double target, double accel, double decel);
155 phaseType GetPhase(void) { return phase; }
157 bool GetOvertemp(void) {return Overtemp; }
158 bool GetInjection(void) {return Injection;}
159 bool GetFire(void) { return Fire; }
160 bool GetAugmentation(void) {return Augmentation;}
161 bool GetReversed(void) { return Reversed; }
162 bool GetCutoff(void) { return Cutoff; }
163 int GetIgnition(void) {return Ignition;}
165 double GetInlet(void) { return InletPosition; }
166 double GetNozzle(void) { return NozzlePosition; }
167 double GetBleedDemand(void) {return BleedDemand;}
168 double GetN1(void) {return N1;}
169 double GetN2(void) {return N2;}
170 double GetEPR(void) {return EPR;}
171 double GetEGT(void) {return EGT_degC;}
173 double getOilPressure_psi () const {return OilPressure_psi;}
174 double getOilTemp_degF (void) {return KelvinToFahrenheit(OilTemp_degK);}
176 void SetInjection(bool injection) {Injection = injection;}
177 void SetIgnition(int ignition) {Ignition = ignition;}
178 void SetAugmentation(bool augmentation) {Augmentation = augmentation;}
179 void SetPhase( phaseType p ) { phase = p; }
180 void SetEPR(double epr) {EPR = epr;}
181 void SetBleedDemand(double bleedDemand) {BleedDemand = bleedDemand;}
182 void SetReverse(bool reversed) { Reversed = reversed; }
183 void SetCutoff(bool cutoff) { Cutoff = cutoff; }
185 string GetEngineLabels(void);
186 string GetEngineValues(void);
190 typedef vector<FGCoefficient*> CoeffArray;
191 CoeffArray ThrustTables;
193 phaseType phase; ///< Operating mode, or "phase"
194 double MilThrust; ///< Maximum Unaugmented Thrust, static @ S.L. (lbf)
195 double MaxThrust; ///< Maximum Augmented Thrust, static @ S.L. (lbf)
196 double BypassRatio; ///< Bypass Ratio
197 double TSFC; ///< Thrust Specific Fuel Consumption (lbm/hr/lbf)
198 double ATSFC; ///< Augmented TSFC (lbm/hr/lbf)
199 double IdleN1; ///< Idle N1
200 double IdleN2; ///< Idle N2
203 double MaxN1; ///< N1 at 100% throttle
204 double MaxN2; ///< N2 at 100% throttle
205 double IdleFF; ///< Idle Fuel Flow (lbm/hr)
206 double delay; ///< Inverse spool-up time from idle to 100% (seconds)
207 double dt; ///< Simulator time slice
208 double N1_factor; ///< factor to tie N1 and throttle
209 double N2_factor; ///< factor to tie N2 and throttle
210 double ThrottlePos; ///< FCS-supplied throttle position
211 double AugmentCmd; ///< modulated afterburner command (0.0 to 1.0)
212 double TAT; ///< total air temperature (deg C)
213 bool Stalled; ///< true if engine is compressor-stalled
214 bool Seized; ///< true if inner spool is seized
215 bool Overtemp; ///< true if EGT exceeds limits
216 bool Fire; ///< true if engine fire detected
221 int Injected; ///< = 1 if water injection installed
223 int Augmented; ///< = 1 if augmentation installed
224 int AugMethod; ///< = 0 if using property /engine[n]/augmentation
225 ///< = 1 if using last 1% of throttle movement
226 ///< = 2 if using FCS-defined throttle
229 double OilPressure_psi;
232 double InletPosition;
233 double NozzlePosition;
243 void SetDefaults(void);
244 bool Load(FGConfigFile *ENG_cfg);
245 void bindmodel(void);
247 void Debug(int from);
251 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%