]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/propulsion/FGTurboProp.h
Sync. w. JSB CVS as of 15/01/2007
[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.
62
63 */
64
65 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
66 CLASS DECLARATION
67 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
68
69 class FGTurboProp : public FGEngine
70 {
71 public:
72   /** Constructor
73       @param Executive pointer to executive structure
74       @param el pointer to the XML element representing the turbine engine
75       @param engine_number engine number*/
76   FGTurboProp(FGFDMExec* Executive, Element *el, int engine_number);
77   /// Destructor
78   ~FGTurboProp();
79
80   enum phaseType { tpOff, tpRun, tpSpinUp, tpStart, tpStall, tpSeize, tpTrim };
81
82   double Calculate(void);
83   double CalcFuelNeed(void);
84
85   inline double GetPowerAvailable(void) const {return (Eng_HP * hptoftlbssec);}
86   inline double GetPowerAvailable_HP(void) const {return (Eng_HP);}
87   inline double GetPropRPM(void) const {return (Prop_RPM);}
88   inline double GetThrottleCmd(void) const {return (ThrottleCmd);}
89   inline bool GetIeluIntervent(void) const { return Ielu_intervent; }
90
91   double Seek(double* var, double target, double accel, double decel);
92   double ExpSeek(double* var, double target, double accel, double decel);
93
94   phaseType GetPhase(void) const { return phase; }
95
96   bool GetOvertemp(void) const {return Overtemp; }
97   bool GetFire(void) const { return Fire; }
98   bool GetReversed(void) const { return Reversed; }
99   bool GetCutoff(void) const { return Cutoff; }
100   int GetIgnition(void) const {return Ignition;}
101
102   double GetInlet(void) const { return InletPosition; }
103   double GetNozzle(void) const { return NozzlePosition; }
104   double GetN1(void) const {return N1;}
105   double GetN2(void) const {return N2;}
106   double GetEPR(void) const {return EPR;}
107   double GetITT(void) const {return Eng_ITT_degC;}
108   double GetEngStarting(void) const { return EngStarting; }
109
110   double getOilPressure_psi () const {return OilPressure_psi;}
111   double getOilTemp_degF (void) {return KelvinToFahrenheit(OilTemp_degK);}
112
113   inline bool GetGeneratorPower(void) const { return GeneratorPower; }
114   inline int GetCondition(void) const { return Condition; }
115
116   void SetIgnition(int ignition) {Ignition = ignition;}
117   void SetPhase( phaseType p ) { phase = p; }
118   void SetEPR(double epr) {EPR = epr;}
119   void SetReverse(bool reversed) { Reversed = reversed; }
120   void SetCutoff(bool cutoff) { Cutoff = cutoff; }
121
122   inline void SetGeneratorPower(bool gp) { GeneratorPower=gp; }
123   inline void SetCondition(bool c) { Condition=c; }
124
125   string GetEngineLabels(string delimeter);  // added from Turbine 0.9.6
126   string GetEngineValues(string delimeter);  // added from Turbine 0.9.6
127
128 private:
129
130   phaseType phase;         ///< Operating mode, or "phase"
131   double MilThrust;        ///< Maximum Unaugmented Thrust, static @ S.L. (lbf)
132   double IdleN1;           ///< Idle N1
133   double IdleN2;           ///< Idle N2
134   double N1;               ///< N1
135   double N2;               ///< N2
136   double MaxN1;            ///< N1 at 100% throttle
137   double MaxN2;            ///< N2 at 100% throttle
138   double IdleFF;           ///< Idle Fuel Flow (lbm/hr)
139   double delay;            ///< Inverse spool-up time from idle to 100% (seconds)
140   double dt;               ///< Simulator time slice
141   double N1_factor;        ///< factor to tie N1 and throttle
142   double N2_factor;        ///< factor to tie N2 and throttle
143   double ThrottleCmd;      ///< FCS-supplied throttle position
144   double TAT;              ///< total air temperature (deg C)
145   bool Stalled;            ///< true if engine is compressor-stalled
146   bool Seized;             ///< true if inner spool is seized
147   bool Overtemp;           ///< true if EGT exceeds limits
148   bool Fire;               ///< true if engine fire detected
149   bool Reversed;
150   bool Cutoff;
151   int Ignition;
152
153   double EPR;
154   double OilPressure_psi;
155   double OilTemp_degK;
156   double InletPosition;
157   double NozzlePosition;
158
159   double Ielu_max_torque;      // max propeller torque (before ielu intervent)
160   bool Ielu_intervent;
161   double OldThrottle;
162
163   double BetaRangeThrottleEnd; // coef (0-1) where is end of beta-range
164   double ReverseMaxPower;      // coef (0-1) multiplies max throttle on reverse
165
166   double Idle_Max_Delay;       // time delay for exponencial
167   double MaxPower;             // max engine power [HP]
168   double StarterN1;                // rotates of generator maked by starter [%]
169   double MaxStartingTime;            // maximal time for start [s] (-1 means not used)
170   double Prop_RPM;             // propeller RPM
171   double Velocity;
172   double rho;
173   double PSFC;                 // Power specific fuel comsumption [lb/(HP*hr)] at best efficiency
174
175   double Eng_HP;               // current engine power
176
177   double StartTime;                // engine strating time [s] (0 when start button pushed)
178
179   double  ITT_Delay;             // time delay for exponencial grow of ITT
180   double  Eng_ITT_degC;
181   double  Eng_Temperature;     // temperature inside engine
182
183   bool EngStarting;            // logicaly output - TRUE if engine is starting
184   bool GeneratorPower;
185   int Condition;
186
187   double Off(void);
188   double Run(void);
189   double SpinUp(void);
190   double Start(void);
191
192   void SetDefaults(void);
193   bool Load(FGFDMExec *exec, Element *el);
194   void bindmodel(void);
195   void unbind(void);
196   void Debug(int from);
197
198   FGTable* ITT_N1; // ITT temperature depending on throttle command
199   FGTable* EnginePowerRPM_N1;
200   FGTable* EnginePowerVC;
201 };
202 }
203 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
204 #endif