]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/propulsion/FGTurboProp.h
Better fix for a compilation problem with MSVC 2012
[flightgear.git] / src / FDM / JSBSim / models / propulsion / FGTurboProp.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3  Header:       FGTurboProp.h
4  Author:       Jiri "Javky" Javurek
5                based on SimTurbine and Turbine engine from David Culp
6  Date started: 05/14/2004
7
8  ------------- Copyright (C) 2004  (javky@email.cz)----------
9
10  This program is free software; you can redistribute it and/or modify it under
11  the terms of the GNU Lesser General Public License as published by the Free Software
12  Foundation; either version 2 of the License, or (at your option) any later
13  version.
14
15  This program is distributed in the hope that it will be useful, but WITHOUT
16  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17  FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
18  details.
19
20  You should have received a copy of the GNU Lesser General Public License along with
21  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22  Place - Suite 330, Boston, MA  02111-1307, USA.
23
24  Further information about the GNU Lesser General Public License can also be found on
25  the world wide web at http://www.gnu.org.
26
27 HISTORY
28 --------------------------------------------------------------------------------
29 05/14/2004  Created
30 02/08/2011  T. Kreitler, added rotor support
31
32 //JVK (mark)
33
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35 SENTRY
36 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
37
38 #ifndef FGTURBOPROP_H
39 #define FGTURBOPROP_H
40
41 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42 INCLUDES
43 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
44
45 #include <vector>
46 #include "FGEngine.h"
47 #include "input_output/FGXMLElement.h"
48 #include "math/FGTable.h"
49
50 #define ID_TURBOPROP "$Id: FGTurboProp.h,v 1.16 2011/08/04 13:45:42 jberndt Exp $"
51
52 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53 FORWARD DECLARATIONS
54 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
55
56 namespace JSBSim {
57
58 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59 CLASS DOCUMENTATION
60 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
61
62 /** Turboprop engine model.  For an example of this model in use see the file:
63     engine/engtm601.xml
64  <h3>Configuration parameters:</h3>
65 <pre>
66 milthrust   [LBS]
67 idlen1      [%]
68 maxn1       [%]
69 betarangeend[%]
70     if ThrottleCmd < betarangeend/100.0 then engine power=idle, propeller pitch
71     is controled by ThrottleCmd (between MINPITCH and  REVERSEPITCH).
72     if ThrottleCmd > betarangeend/100.0 then engine power increases up to max reverse power
73 reversemaxpower [%]
74     max engine power in reverse mode
75 maxpower    [HP]
76 psfc power specific fuel consumption [pph/HP] for N1=100%
77 n1idle_max_delay [-] time constant for N1 change
78 maxstartenginetime [sec]
79     after this time the automatic starting cycle is interrupted when the engine
80     doesn't start (0=automatic starting not present)
81 startern1   [%]
82     when starting starter spin up engine to this spin
83 ielumaxtorque [lb.ft]
84     if torque>ielumaxtorque limiters decrease the throttle
85     (ielu = Integrated Electronic Limiter Unit)
86 itt_delay [-] time constant for ITT change
87     (ITT = Inter Turbine Temperature)
88 </pre>
89 */
90
91 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
92 CLASS DECLARATION
93 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
94
95 class FGTurboProp : public FGEngine
96 {
97 public:
98   /** Constructor
99       @param Executive pointer to executive structure
100       @param el pointer to the XML element representing the turbine engine
101       @param engine_number engine number*/
102   FGTurboProp(FGFDMExec* Executive, Element *el, int engine_number, struct Inputs& input);
103   /// Destructor
104   ~FGTurboProp();
105
106   enum phaseType { tpOff, tpRun, tpSpinUp, tpStart, tpStall, tpSeize, tpTrim };
107
108   void Calculate(void);
109   double CalcFuelNeed(void);
110
111   double GetPowerAvailable(void) const { return (HP * hptoftlbssec); }
112   double GetRPM(void) const { return (RPM); }
113   double GetIeluThrottle(void) const { return (ThrottlePos); }
114   bool GetIeluIntervent(void) const { return Ielu_intervent; }
115
116   double Seek(double* var, double target, double accel, double decel);
117   double ExpSeek(double* var, double target, double accel, double decel);
118
119   phaseType GetPhase(void) const { return phase; }
120
121   bool GetOvertemp(void) const {return Overtemp; }
122   bool GetFire(void) const { return Fire; }
123   bool GetReversed(void) const { return Reversed; }
124   bool GetCutoff(void) const { return Cutoff; }
125   int GetIgnition(void) const {return Ignition;}
126
127   double GetInlet(void) const { return InletPosition; }
128   double GetNozzle(void) const { return NozzlePosition; }
129   double GetN1(void) const {return N1;}
130   double GetN2(void) const {return N2;}
131   double GetEPR(void) const {return EPR;}
132   double GetITT(void) const {return Eng_ITT_degC;}
133   double GetEngStarting(void) const { return EngStarting; }
134
135   double getOilPressure_psi () const {return OilPressure_psi;}
136   double getOilTemp_degF (void) {return KelvinToFahrenheit(OilTemp_degK);}
137
138   inline bool GetGeneratorPower(void) const { return GeneratorPower; }
139   inline int GetCondition(void) const { return Condition; }
140
141   void SetIgnition(int ignition) {Ignition = ignition;}
142   void SetPhase( phaseType p ) { phase = p; }
143   void SetEPR(double epr) {EPR = epr;}
144   void SetReverse(bool reversed) { Reversed = reversed; }
145   void SetCutoff(bool cutoff) { Cutoff = cutoff; }
146
147   inline void SetGeneratorPower(bool gp) { GeneratorPower=gp; }
148   inline void SetCondition(bool c) { Condition=c; }
149   int InitRunning(void);
150   std::string GetEngineLabels(const std::string& delimiter);
151   std::string GetEngineValues(const std::string& delimiter);
152
153 private:
154
155   phaseType phase;         ///< Operating mode, or "phase"
156   double MilThrust;        ///< Maximum Unaugmented Thrust, static @ S.L. (lbf)
157   double IdleN1;           ///< Idle N1
158   double IdleN2;           ///< Idle N2
159   double N1;               ///< N1
160   double N2;               ///< N2
161   double MaxN1;            ///< N1 at 100% throttle
162   double MaxN2;            ///< N2 at 100% throttle
163   double IdleFF;           ///< Idle Fuel Flow (lbm/hr)
164   double delay;            ///< Inverse spool-up time from idle to 100% (seconds)
165   double N1_factor;        ///< factor to tie N1 and throttle
166   double N2_factor;        ///< factor to tie N2 and throttle
167   double ThrottlePos;      ///< FCS-supplied throttle position, modified locally
168   double TAT;              ///< total air temperature (deg C)
169   bool Stalled;            ///< true if engine is compressor-stalled
170   bool Seized;             ///< true if inner spool is seized
171   bool Overtemp;           ///< true if EGT exceeds limits
172   bool Fire;               ///< true if engine fire detected
173   bool Reversed;
174   bool Cutoff;
175   int Ignition;
176
177   double EPR;
178   double OilPressure_psi;
179   double OilTemp_degK;
180   double InletPosition;
181   double NozzlePosition;
182
183   double Ielu_max_torque;      // max propeller torque (before ielu intervent)
184   bool Ielu_intervent;
185   double OldThrottle;
186
187   double BetaRangeThrottleEnd; // coef (0-1) where is end of beta-range
188   double ReverseMaxPower;      // coef (0-1) multiplies max throttle on reverse
189
190   double Idle_Max_Delay;       // time delay for exponential
191   double MaxPower;             // max engine power [HP]
192   double StarterN1;            // rotates of generator maked by starter [%]
193   double MaxStartingTime;      // maximal time for start [s] (-1 means not used)
194   double RPM;                  // shaft RPM
195   double Velocity;
196   double rho;
197   double PSFC;                 // Power specific fuel comsumption [lb/(HP*hr)] at best efficiency
198
199   double HP;                   // engine power output
200
201   double StartTime;            // engine starting time [s] (0 when start button pushed)
202
203   double  ITT_Delay;           // time delay for exponential growth of ITT
204   double  Eng_ITT_degC;
205   double  Eng_Temperature;     // temperature inside engine
206
207   bool EngStarting;            // logicaly output - TRUE if engine is starting
208   bool GeneratorPower;
209   int Condition;
210   int thrusterType;            // the attached thruster
211
212   double Off(void);
213   double Run(void);
214   double SpinUp(void);
215   double Start(void);
216
217   void SetDefaults(void);
218   bool Load(FGFDMExec *exec, Element *el);
219   void bindmodel(void);
220   void Debug(int from);
221
222   FGTable* ITT_N1;             // ITT temperature depending on throttle command
223   FGTable* EnginePowerRPM_N1;
224   FGTable* EnginePowerVC;
225 };
226 }
227 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
228 #endif