Branch data Line data Source code
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 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.19 2010/08/21 18:08:46 jberndt 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 : :
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 : : <h3>Configuration File Format:</h3>
86 : : @code
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 : : <maxn1> {number} </maxn1>
97 : : <maxn2> {number} </maxn2>
98 : : <augmented> {0 | 1} </augmented>
99 : : <augmethod> {0 | 1 | 2} </augmethod>
100 : : <injected> {0 | 1} </injected>
101 : : <injection-time> {number} </injection-time>
102 : : </turbine_engine>
103 : : @endcode
104 : :
105 : : <h3>Definition of the turbine engine configuration file parameters:</h3>
106 : :
107 : : <pre>
108 : : milthrust - Maximum thrust, static, at sea level.
109 : : maxthrust - Afterburning thrust, static, at sea level.
110 : : bypassratio - Ratio of bypass air flow to core air flow.
111 : : bleed - Thrust reduction factor due to losses (0.0 to 1.0).
112 : : tsfc - Thrust-specific fuel consumption at cruise, lbm/hr/lbf
113 : : atsfc - Afterburning TSFC, lbm/hr/lbf
114 : : idlen1 - Fan rotor rpm (% of max) at idle
115 : : idlen2 - Core rotor rpm (% of max) at idle
116 : : maxn1 - Fan rotor rpm (% of max) at full throttle
117 : : maxn2 - Core rotor rpm (% of max) at full throttle
118 : : augmented
119 : : 0 = afterburner not installed
120 : : 1 = afterburner installed
121 : : augmethod
122 : : 0 = afterburner activated by property /engines/engine[n]/augmentation
123 : : 1 = afterburner activated by pushing throttle above 99% position
124 : : 2 = throttle range is expanded in the FCS, and values above 1.0 are afterburner range
125 : : injected
126 : : 0 = Water injection not installed
127 : : 1 = Water injection installed
128 : : injection-time - Time, in seconds, of water injection duration
129 : : </pre>
130 : :
131 : : <h3>NOTES:</h3>
132 : : <pre>
133 : : Bypass ratio is used only to estimate engine acceleration time. The
134 : : effect of bypass ratio on engine efficiency is already included in
135 : : the TSFC value. Feel free to set this parameter (even for turbojets) to
136 : : whatever value gives a desired spool-up rate. Default value is 0.
137 : :
138 : : The bleed factor is multiplied by thrust to give a resulting thrust
139 : : after losses. This can represent losses due to bleed, or any other cause.
140 : : Default value is 0. A common value would be 0.04.
141 : :
142 : : Nozzle position, for variable area exhaust nozzles, is provided for users
143 : : needing to drive a nozzle gauge or animate a virtual nozzle.
144 : :
145 : : This model can only be used with the "direct" thruster. See the file:
146 : : /engine/direct.xml
147 : : </pre>
148 : : @author David P. Culp
149 : : @version "$Id: FGTurbine.h,v 1.19 2010/08/21 18:08:46 jberndt Exp $"
150 : : */
151 : :
152 : : /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
153 : : CLASS DECLARATION
154 : : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
155 : :
156 : : class FGTurbine : public FGEngine
157 : : {
158 : : public:
159 : : /** Constructor
160 : : @param Executive pointer to executive structure
161 : : @param el pointer to the XML element representing the turbine engine
162 : : @param engine_number engine number */
163 : : FGTurbine(FGFDMExec* Executive, Element *el, int engine_number);
164 : : /// Destructor
165 : : ~FGTurbine();
166 : :
167 : : enum phaseType { tpOff, tpRun, tpSpinUp, tpStart, tpStall, tpSeize, tpTrim };
168 : :
169 : : void Calculate(void);
170 : : double CalcFuelNeed(void);
171 : : double GetPowerAvailable(void);
172 : : /** A lag filter.
173 : : Used to control the rate at which values are allowed to change.
174 : : @param var a pointer to a variable of type double
175 : : @param target the desired (target) value
176 : : @param accel the rate, per second, the value may increase
177 : : @param decel the rate, per second, the value may decrease */
178 : : double Seek(double* var, double target, double accel, double decel);
179 : :
180 : : phaseType GetPhase(void) { return phase; }
181 : :
182 : : bool GetOvertemp(void) const {return Overtemp; }
183 : 0 : bool GetInjection(void) const {return Injection;}
184 : : bool GetFire(void) const { return Fire; }
185 : : bool GetAugmentation(void) const {return Augmentation;}
186 : : bool GetReversed(void) const { return Reversed; }
187 : : bool GetCutoff(void) const { return Cutoff; }
188 : : int GetIgnition(void) const {return Ignition;}
189 : :
190 : : double GetInlet(void) const { return InletPosition; }
191 : : double GetNozzle(void) const { return NozzlePosition; }
192 : : double GetBleedDemand(void) const {return BleedDemand;}
193 : : double GetN1(void) const {return N1;}
194 : : double GetN2(void) const {return N2;}
195 : : double GetEPR(void) const {return EPR;}
196 : : double GetEGT(void) const {return EGT_degC;}
197 : :
198 : : double getOilPressure_psi () const {return OilPressure_psi;}
199 : : double getOilTemp_degF (void) {return KelvinToFahrenheit(OilTemp_degK);}
200 : :
201 : 0 : void SetInjection(bool injection) {Injection = injection;}
202 : : void SetIgnition(int ignition) {Ignition = ignition;}
203 : : void SetAugmentation(bool augmentation) {Augmentation = augmentation;}
204 : : void SetPhase( phaseType p ) { phase = p; }
205 : : void SetEPR(double epr) {EPR = epr;}
206 : : void SetBleedDemand(double bleedDemand) {BleedDemand = bleedDemand;}
207 : : void SetReverse(bool reversed) { Reversed = reversed; }
208 : 0 : void SetCutoff(bool cutoff) { Cutoff = cutoff; }
209 : : int InitRunning(void);
210 : : void ResetToIC(void);
211 : :
212 : : std::string GetEngineLabels(const std::string& delimiter);
213 : : std::string GetEngineValues(const std::string& delimiter);
214 : :
215 : : private:
216 : :
217 : : phaseType phase; ///< Operating mode, or "phase"
218 : : double MilThrust; ///< Maximum Unaugmented Thrust, static @ S.L. (lbf)
219 : : double MaxThrust; ///< Maximum Augmented Thrust, static @ S.L. (lbf)
220 : : double BypassRatio; ///< Bypass Ratio
221 : : double TSFC; ///< Thrust Specific Fuel Consumption (lbm/hr/lbf)
222 : : double ATSFC; ///< Augmented TSFC (lbm/hr/lbf)
223 : : double IdleN1; ///< Idle N1
224 : : double IdleN2; ///< Idle N2
225 : : double N1; ///< N1
226 : : double N2; ///< N2
227 : : double N2norm; ///< N2 normalized (0=idle, 1=max)
228 : : double MaxN1; ///< N1 at 100% throttle
229 : : double MaxN2; ///< N2 at 100% throttle
230 : : double IdleFF; ///< Idle Fuel Flow (lbm/hr)
231 : : double delay; ///< Inverse spool-up time from idle to 100% (seconds)
232 : : double dt; ///< Simulator time slice
233 : : double N1_factor; ///< factor to tie N1 and throttle
234 : : double N2_factor; ///< factor to tie N2 and throttle
235 : : double ThrottlePos; ///< FCS-supplied throttle position
236 : : double AugmentCmd; ///< modulated afterburner command (0.0 to 1.0)
237 : : double TAT; ///< total air temperature (deg C)
238 : : double N1_spinup; ///< N1 spin up rate from starter (per second)
239 : : double N2_spinup; ///< N2 spin up rate from starter (per second)
240 : : bool Stalled; ///< true if engine is compressor-stalled
241 : : bool Seized; ///< true if inner spool is seized
242 : : bool Overtemp; ///< true if EGT exceeds limits
243 : : bool Fire; ///< true if engine fire detected
244 : : bool Injection;
245 : : bool Augmentation;
246 : : bool Reversed;
247 : : bool Cutoff;
248 : : int Injected; ///< = 1 if water injection installed
249 : : int Ignition;
250 : : int Augmented; ///< = 1 if augmentation installed
251 : : int AugMethod; ///< = 0 if using property /engine[n]/augmentation
252 : : ///< = 1 if using last 1% of throttle movement
253 : : ///< = 2 if using FCS-defined throttle
254 : : double EGT_degC;
255 : : double EPR;
256 : : double OilPressure_psi;
257 : : double OilTemp_degK;
258 : : double BleedDemand;
259 : : double InletPosition;
260 : : double NozzlePosition;
261 : : double correctedTSFC;
262 : : double InjectionTimer;
263 : : double InjectionTime;
264 : :
265 : : double Off(void);
266 : : double Run();
267 : : double SpinUp(void);
268 : : double Start(void);
269 : : double Stall(void);
270 : : double Seize(void);
271 : : double Trim();
272 : :
273 : : FGFunction *IdleThrustLookup;
274 : : FGFunction *MilThrustLookup;
275 : : FGFunction *MaxThrustLookup;
276 : : FGFunction *InjectionLookup;
277 : :
278 : : bool Load(FGFDMExec *exec, Element *el);
279 : : void bindmodel(void);
280 : : void Debug(int from);
281 : :
282 : : };
283 : : }
284 : : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
285 : : #endif
286 : :
|