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 Lesser 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 Lesser General Public License for more
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.
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.
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 #define ID_TURBINE "$Id: FGTurbine.h,v 1.22 2011/08/04 13:45:42 jberndt Exp $"
47 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
49 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
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 <h3>Configuration File Format:</h3>
87 <turbine_engine name="{string}">
88 <milthrust unit="{LBS | N}"> {number} </milthrust>
89 <maxthrust unit="{LBS | N}"> {number} </maxthrust>
90 <bypassratio> {number} </bypassratio>
91 <bleed> {number} </bleed>
92 <tsfc> {number} </tsfc>
93 <atsfc> {number} </atsfc>
94 <idlen1> {number} </idlen1>
95 <idlen2> {number} </idlen2>
96 <n1spinup> {number} </n1spinup>
97 <n2spinup> {number} </n2spinup>
98 <maxn1> {number} </maxn1>
99 <maxn2> {number} </maxn2>
100 <augmented> {0 | 1} </augmented>
101 <augmethod> {0 | 1 | 2} </augmethod>
102 <injected> {0 | 1} </injected>
103 <injection-time> {number} </injection-time>
107 <h3>Definition of the turbine engine configuration file parameters:</h3>
110 milthrust - Maximum thrust, static, at sea level.
111 maxthrust - Afterburning thrust, static, at sea level.
112 bypassratio - Ratio of bypass air flow to core air flow.
113 bleed - Thrust reduction factor due to losses (0.0 to 1.0).
114 tsfc - Thrust-specific fuel consumption at cruise, lbm/hr/lbf
115 atsfc - Afterburning TSFC, lbm/hr/lbf
116 idlen1 - Fan rotor rpm (% of max) at idle
117 idlen2 - Core rotor rpm (% of max) at idle
118 n1spinup - Fan rotor rpm starter acceleration (default 1.0)
119 n2spinup - Core rotor rpm starter acceleration (default 3.0)
120 maxn1 - Fan rotor rpm (% of max) at full throttle
121 maxn2 - Core rotor rpm (% of max) at full throttle
123 0 = afterburner not installed
124 1 = afterburner installed
126 0 = afterburner activated by property /engines/engine[n]/augmentation
127 1 = afterburner activated by pushing throttle above 99% position
128 2 = throttle range is expanded in the FCS, and values above 1.0 are afterburner range
130 0 = Water injection not installed
131 1 = Water injection installed
132 injection-time - Time, in seconds, of water injection duration
137 Bypass ratio is used only to estimate engine acceleration time. The
138 effect of bypass ratio on engine efficiency is already included in
139 the TSFC value. Feel free to set this parameter (even for turbojets) to
140 whatever value gives a desired spool-up rate. Default value is 0.
142 The bleed factor is multiplied by thrust to give a resulting thrust
143 after losses. This can represent losses due to bleed, or any other cause.
144 Default value is 0. A common value would be 0.04.
146 Nozzle position, for variable area exhaust nozzles, is provided for users
147 needing to drive a nozzle gauge or animate a virtual nozzle.
149 This model can only be used with the "direct" thruster. See the file:
152 @author David P. Culp
153 @version "$Id: FGTurbine.h,v 1.22 2011/08/04 13:45:42 jberndt Exp $"
156 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
158 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
160 class FGTurbine : public FGEngine
164 @param Executive pointer to executive structure
165 @param el pointer to the XML element representing the turbine engine
166 @param engine_number engine number */
167 FGTurbine(FGFDMExec* Executive, Element *el, int engine_number, struct Inputs& input);
171 enum phaseType { tpOff, tpRun, tpSpinUp, tpStart, tpStall, tpSeize, tpTrim };
173 void Calculate(void);
174 double CalcFuelNeed(void);
175 double GetPowerAvailable(void);
177 Used to control the rate at which values are allowed to change.
178 @param var a pointer to a variable of type double
179 @param target the desired (target) value
180 @param accel the rate, per second, the value may increase
181 @param decel the rate, per second, the value may decrease */
182 double Seek(double* var, double target, double accel, double decel);
184 phaseType GetPhase(void) { return phase; }
186 bool GetOvertemp(void) const {return Overtemp; }
187 bool GetInjection(void) const {return Injection;}
188 bool GetFire(void) const { return Fire; }
189 bool GetAugmentation(void) const {return Augmentation;}
190 bool GetReversed(void) const { return Reversed; }
191 bool GetCutoff(void) const { return Cutoff; }
192 int GetIgnition(void) const {return Ignition;}
194 double GetInlet(void) const { return InletPosition; }
195 double GetNozzle(void) const { return NozzlePosition; }
196 double GetBleedDemand(void) const {return BleedDemand;}
197 double GetN1(void) const {return N1;}
198 double GetN2(void) const {return N2;}
199 double GetEPR(void) const {return EPR;}
200 double GetEGT(void) const {return EGT_degC;}
202 double getOilPressure_psi () const {return OilPressure_psi;}
203 double getOilTemp_degF (void) {return KelvinToFahrenheit(OilTemp_degK);}
205 void SetInjection(bool injection) {Injection = injection;}
206 void SetIgnition(int ignition) {Ignition = ignition;}
207 void SetAugmentation(bool augmentation) {Augmentation = augmentation;}
208 void SetPhase( phaseType p ) { phase = p; }
209 void SetEPR(double epr) {EPR = epr;}
210 void SetBleedDemand(double bleedDemand) {BleedDemand = bleedDemand;}
211 void SetReverse(bool reversed) { Reversed = reversed; }
212 void SetCutoff(bool cutoff) { Cutoff = cutoff; }
213 int InitRunning(void);
214 void ResetToIC(void);
216 std::string GetEngineLabels(const std::string& delimiter);
217 std::string GetEngineValues(const std::string& delimiter);
221 phaseType phase; ///< Operating mode, or "phase"
222 double MilThrust; ///< Maximum Unaugmented Thrust, static @ S.L. (lbf)
223 double MaxThrust; ///< Maximum Augmented Thrust, static @ S.L. (lbf)
224 double BypassRatio; ///< Bypass Ratio
225 double TSFC; ///< Thrust Specific Fuel Consumption (lbm/hr/lbf)
226 double ATSFC; ///< Augmented TSFC (lbm/hr/lbf)
227 double IdleN1; ///< Idle N1
228 double IdleN2; ///< Idle N2
231 double N2norm; ///< N2 normalized (0=idle, 1=max)
232 double MaxN1; ///< N1 at 100% throttle
233 double MaxN2; ///< N2 at 100% throttle
234 double IdleFF; ///< Idle Fuel Flow (lbm/hr)
235 double delay; ///< Inverse spool-up time from idle to 100% (seconds)
236 double N1_factor; ///< factor to tie N1 and throttle
237 double N2_factor; ///< factor to tie N2 and throttle
238 double ThrottlePos; ///< FCS-supplied throttle position - modified for local use!
239 double AugmentCmd; ///< modulated afterburner command (0.0 to 1.0)
240 double TAT; ///< total air temperature (deg C)
241 double N1_spinup; ///< N1 spin up rate from starter (per second)
242 double N2_spinup; ///< N2 spin up rate from starter (per second)
243 bool Stalled; ///< true if engine is compressor-stalled
244 bool Seized; ///< true if inner spool is seized
245 bool Overtemp; ///< true if EGT exceeds limits
246 bool Fire; ///< true if engine fire detected
251 int Injected; ///< = 1 if water injection installed
253 int Augmented; ///< = 1 if augmentation installed
254 int AugMethod; ///< = 0 if using property /engine[n]/augmentation
255 ///< = 1 if using last 1% of throttle movement
256 ///< = 2 if using FCS-defined throttle
259 double OilPressure_psi;
262 double InletPosition;
263 double NozzlePosition;
264 double correctedTSFC;
265 double InjectionTimer;
266 double InjectionTime;
276 FGFunction *IdleThrustLookup;
277 FGFunction *MilThrustLookup;
278 FGFunction *MaxThrustLookup;
279 FGFunction *InjectionLookup;
281 bool Load(FGFDMExec *exec, Element *el);
282 void bindmodel(void);
283 void Debug(int from);
287 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%