]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/propulsion/FGTurboProp.h
Sync. w. JSBSim cvs
[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
31 //JVK (mark)
32
33 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
34 SENTRY
35 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
36
37 #ifndef FGTURBOPROP_H
38 #define FGTURBOPROP_H
39
40 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
41 INCLUDES
42 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
43
44 #include <vector>
45 #include "FGEngine.h"
46 #include "input_output/FGXMLElement.h"
47 #include "math/FGTable.h"
48
49 #define ID_TURBOPROP "$Id$"
50
51 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
52 FORWARD DECLARATIONS
53 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
54
55 namespace JSBSim {
56
57 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
58 CLASS DOCUMENTATION
59 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
60
61 /** Turboprop engine model.  For an example of this model in use see the file:
62     engine/engtm601.xml
63  <h3>Configuration parameters:</h3>
64 <pre>
65 milthrust   [LBS]
66 idlen1      [%]
67 maxn1       [%]
68 betarangeend[%]
69     if ThrottleCmd < betarangeend/100.0 then engine power=idle, propeller pitch
70     is controled by ThrottleCmd (between MINPITCH and  REVERSEPITCH).
71     if ThrottleCmd > betarangeend/100.0 then engine power increases up to max reverse power
72 reversemaxpower [%]
73     max engine power in reverse mode
74 maxpower    [HP]
75 psfc power specific fuel consumption [pph/HP] for N1=100%
76 n1idle_max_delay [-] time constant for N1 change
77 maxstartenginetime [sec]
78     after this time the automatic starting cycle is interrupted when the engine
79     doesn't start (0=automatic starting not present)
80 startern1   [%]
81     when starting starter spin up engine to this spin
82 ielumaxtorque [lb.ft]
83     if torque>ielumaxtorque limiters decrease the throttle
84     (ielu = Integrated Electronic Limiter Unit)
85 itt_delay [-] time constant for ITT change
86     (ITT = Inter Turbine Temperature)
87 </pre>
88 */
89
90 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
91 CLASS DECLARATION
92 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
93
94 class FGTurboProp : public FGEngine
95 {
96 public:
97   /** Constructor
98       @param Executive pointer to executive structure
99       @param el pointer to the XML element representing the turbine engine
100       @param engine_number engine number*/
101   FGTurboProp(FGFDMExec* Executive, Element *el, int engine_number);
102   /// Destructor
103   ~FGTurboProp();
104
105   enum phaseType { tpOff, tpRun, tpSpinUp, tpStart, tpStall, tpSeize, tpTrim };
106
107   double Calculate(void);
108   double CalcFuelNeed(void);
109
110   inline double GetPowerAvailable(void) const {return (Eng_HP * hptoftlbssec);}
111   inline double GetPowerAvailable_HP(void) const {return (Eng_HP);}
112   inline double GetPropRPM(void) const {return (Prop_RPM);}
113   inline double GetThrottleCmd(void) const {return (ThrottleCmd);}
114   inline 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 ThrottleCmd;      ///< FCS-supplied throttle position
169   double TAT;              ///< total air temperature (deg C)
170   double PowerAvailable;
171   bool Stalled;            ///< true if engine is compressor-stalled
172   bool Seized;             ///< true if inner spool is seized
173   bool Overtemp;           ///< true if EGT exceeds limits
174   bool Fire;               ///< true if engine fire detected
175   bool Reversed;
176   bool Cutoff;
177   int Ignition;
178
179   double EPR;
180   double OilPressure_psi;
181   double OilTemp_degK;
182   double InletPosition;
183   double NozzlePosition;
184
185   double Ielu_max_torque;      // max propeller torque (before ielu intervent)
186   bool Ielu_intervent;
187   double OldThrottle;
188
189   double BetaRangeThrottleEnd; // coef (0-1) where is end of beta-range
190   double ReverseMaxPower;      // coef (0-1) multiplies max throttle on reverse
191
192   double Idle_Max_Delay;       // time delay for exponencial
193   double MaxPower;             // max engine power [HP]
194   double StarterN1;            // rotates of generator maked by starter [%]
195   double MaxStartingTime;      // maximal time for start [s] (-1 means not used)
196   double Prop_RPM;             // propeller RPM
197   double Velocity;
198   double rho;
199   double PSFC;                 // Power specific fuel comsumption [lb/(HP*hr)] at best efficiency
200
201   double Eng_HP;               // current engine power
202
203   double StartTime;            // engine strating time [s] (0 when start button pushed)
204
205   double  ITT_Delay;           // time delay for exponencial grow of ITT
206   double  Eng_ITT_degC;
207   double  Eng_Temperature;     // temperature inside engine
208
209   bool EngStarting;            // logicaly output - TRUE if engine is starting
210   bool GeneratorPower;
211   int Condition;
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