]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/propulsion/FGTurboProp.h
Merge branch 'next' of http://git.gitorious.org/fg/flightgear into next
[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.14 2011/03/10 01:35:25 dpculp 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);
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 (Throttle); }
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 dt;               ///< Simulator time slice
166   double N1_factor;        ///< factor to tie N1 and throttle
167   double N2_factor;        ///< factor to tie N2 and throttle
168   double Throttle;         ///< FCS-supplied throttle position
169   double TAT;              ///< total air temperature (deg C)
170   bool Stalled;            ///< true if engine is compressor-stalled
171   bool Seized;             ///< true if inner spool is seized
172   bool Overtemp;           ///< true if EGT exceeds limits
173   bool Fire;               ///< true if engine fire detected
174   bool Reversed;
175   bool Cutoff;
176   int Ignition;
177
178   double EPR;
179   double OilPressure_psi;
180   double OilTemp_degK;
181   double InletPosition;
182   double NozzlePosition;
183
184   double Ielu_max_torque;      // max propeller torque (before ielu intervent)
185   bool Ielu_intervent;
186   double OldThrottle;
187
188   double BetaRangeThrottleEnd; // coef (0-1) where is end of beta-range
189   double ReverseMaxPower;      // coef (0-1) multiplies max throttle on reverse
190
191   double Idle_Max_Delay;       // time delay for exponential
192   double MaxPower;             // max engine power [HP]
193   double StarterN1;            // rotates of generator maked by starter [%]
194   double MaxStartingTime;      // maximal time for start [s] (-1 means not used)
195   double RPM;                  // shaft RPM
196   double Velocity;
197   double rho;
198   double PSFC;                 // Power specific fuel comsumption [lb/(HP*hr)] at best efficiency
199
200   double HP;                   // engine power output
201
202   double StartTime;            // engine starting time [s] (0 when start button pushed)
203
204   double  ITT_Delay;           // time delay for exponential growth of ITT
205   double  Eng_ITT_degC;
206   double  Eng_Temperature;     // temperature inside engine
207
208   bool EngStarting;            // logicaly output - TRUE if engine is starting
209   bool GeneratorPower;
210   int Condition;
211   int thrusterType;            // the attached thruster
212
213   double Off(void);
214   double Run(void);
215   double SpinUp(void);
216   double Start(void);
217
218   void SetDefaults(void);
219   bool Load(FGFDMExec *exec, Element *el);
220   void bindmodel(void);
221   void Debug(int from);
222
223   FGTable* ITT_N1;             // ITT temperature depending on throttle command
224   FGTable* EnginePowerRPM_N1;
225   FGTable* EnginePowerVC;
226 };
227 }
228 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
229 #endif