1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4 Author: Jiri "Javky" Javurek
5 based on SimTurbine and Turbine engine from David Culp
6 Date started: 05/14/2004
8 ------------- Copyright (C) 2004 (javky@email.cz)----------
10 This program is free software; you can redistribute it and/or modify it under
11 the terms of the GNU General Public License as published by the Free Software
12 Foundation; either version 2 of the License, or (at your option) any later
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 General Public License for more
20 You should have received a copy of the GNU 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.
24 Further information about the GNU General Public License can also be found on
25 the world wide web at http://www.gnu.org.
28 --------------------------------------------------------------------------------
33 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
46 #include <input_output/FGXMLElement.h>
47 #include <math/FGTable.h>
49 #define ID_TURBOPROP "$Id$"
51 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
57 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
61 /** Turboprop engine model.
65 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
67 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
69 class FGTurboProp : public FGEngine
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);
80 enum phaseType { tpOff, tpRun, tpSpinUp, tpStart, tpStall, tpSeize, tpTrim };
82 double Calculate(void);
83 double CalcFuelNeed(void);
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; }
91 double Seek(double* var, double target, double accel, double decel);
92 double ExpSeek(double* var, double target, double accel, double decel);
94 phaseType GetPhase(void) const { return phase; }
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;}
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; }
110 double getOilPressure_psi () const {return OilPressure_psi;}
111 double getOilTemp_degF (void) {return KelvinToFahrenheit(OilTemp_degK);}
113 inline bool GetGeneratorPower(void) const { return GeneratorPower; }
114 inline int GetCondition(void) const { return Condition; }
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; }
122 inline void SetGeneratorPower(bool gp) { GeneratorPower=gp; }
123 inline void SetCondition(bool c) { Condition=c; }
125 string GetEngineLabels(string delimeter); // added from Turbine 0.9.6
126 string GetEngineValues(string delimeter); // added from Turbine 0.9.6
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
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
154 double OilPressure_psi;
156 double InletPosition;
157 double NozzlePosition;
159 double Ielu_max_torque; // max propeller torque (before ielu intervent)
163 double BetaRangeThrottleEnd; // coef (0-1) where is end of beta-range
164 double ReverseMaxPower; // coef (0-1) multiplies max throttle on reverse
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
173 double PSFC; // Power specific fuel comsumption [lb/(HP*hr)] at best efficiency
175 double Eng_HP; // current engine power
177 double StartTime; // engine strating time [s] (0 when start button pushed)
179 double ITT_Delay; // time delay for exponencial grow of ITT
181 double Eng_Temperature; // temperature inside engine
183 bool EngStarting; // logicaly output - TRUE if engine is starting
192 void SetDefaults(void);
193 bool Load(FGFDMExec *exec, Element *el);
194 void bindmodel(void);
196 void Debug(int from);
198 FGTable* ITT_N1; // ITT temperature depending on throttle command
199 FGTable* EnginePowerRPM_N1;
200 FGTable* EnginePowerVC;
203 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%