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 "math/FGTable.h"
48 
49 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
50 FORWARD DECLARATIONS
51 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
52 
53 namespace JSBSim {
54 
55 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
56 CLASS DOCUMENTATION
57 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
58 
59 /** Turboprop engine model.  For an example of this model in use see the file:
60     engine/engtm601.xml
61  <h3>Configuration parameters:</h3>
62 <pre>
63 milthrust   [LBS]
64 idlen1      [%]
65 maxn1       [%]
66 betarangeend[%]
67     if ThrottleCmd < betarangeend/100.0 then engine power=idle, propeller pitch
68     is controled by ThrottleCmd (between MINPITCH and  REVERSEPITCH).
69     if ThrottleCmd > betarangeend/100.0 then engine power increases up to max reverse power
70 reversemaxpower [%]
71     max engine power in reverse mode
72 maxpower    [HP]
73 psfc power specific fuel consumption [pph/HP] for N1=100%
74 n1idle_max_delay [-] time constant for N1 change
75 maxstartenginetime [sec]
76     after this time the automatic starting cycle is interrupted when the engine
77     doesn't start (0=automatic starting not present)
78 startern1   [%]
79     when starting starter spin up engine to this spin
80 ielumaxtorque [lb.ft]
81     if torque>ielumaxtorque limiters decrease the throttle
82     (ielu = Integrated Electronic Limiter Unit)
83 itt_delay [-] time constant for ITT change
84     (ITT = Inter Turbine Temperature)
85 </pre>
86 */
87 
88 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
89 CLASS DECLARATION
90 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
91 
92 class FGTurboProp : public FGEngine
93 {
94 public:
95   /** Constructor
96       @param Executive pointer to executive structure
97       @param el pointer to the XML element representing the turbine engine
98       @param engine_number engine number*/
99   FGTurboProp(FGFDMExec* Executive, Element *el, int engine_number, struct Inputs& input);
100   /// Destructor
101   ~FGTurboProp();
102 
103   enum phaseType { tpOff, tpRun, tpSpinUp, tpStart, tpTrim };
104 
105   void Calculate(void);
106   double CalcFuelNeed(void);
107 
GetPowerAvailable(void)108   double GetPowerAvailable(void) const { return (HP * hptoftlbssec); }
GetRPM(void)109   double GetRPM(void) const { return RPM; }
GetIeluThrottle(void)110   double GetIeluThrottle(void) const { return (ThrottlePos); }
GetIeluIntervent(void)111   bool GetIeluIntervent(void) const { return Ielu_intervent; }
112 
113   double Seek(double* var, double target, double accel, double decel);
114   double ExpSeek(double* var, double target, double accel, double decel);
115 
GetPhase(void)116   phaseType GetPhase(void) const { return phase; }
117 
GetReversed(void)118   bool GetReversed(void) const { return Reversed; }
GetCutoff(void)119   bool GetCutoff(void) const { return Cutoff; }
120 
GetN1(void)121   double GetN1(void) const {return N1;}
GetITT(void)122   double GetITT(void) const {return Eng_ITT_degC;}
GetEngStarting(void)123   double GetEngStarting(void) const { return EngStarting; }
124 
getOilPressure_psi()125   double getOilPressure_psi () const {return OilPressure_psi;}
getOilTemp_degF(void)126   double getOilTemp_degF (void) {return KelvinToFahrenheit(OilTemp_degK);}
127 
GetGeneratorPower(void)128   inline bool GetGeneratorPower(void) const { return GeneratorPower; }
GetCondition(void)129   inline int GetCondition(void) const { return Condition; }
130 
SetPhase(phaseType p)131   void SetPhase( phaseType p ) { phase = p; }
SetReverse(bool reversed)132   void SetReverse(bool reversed) { Reversed = reversed; }
SetCutoff(bool cutoff)133   void SetCutoff(bool cutoff) { Cutoff = cutoff; }
134 
SetGeneratorPower(bool gp)135   inline void SetGeneratorPower(bool gp) { GeneratorPower=gp; }
SetCondition(bool c)136   inline void SetCondition(bool c) { Condition=c; }
137   int InitRunning(void);
138   std::string GetEngineLabels(const std::string& delimiter);
139   std::string GetEngineValues(const std::string& delimiter);
140 
141 private:
142 
143   phaseType phase;         ///< Operating mode, or "phase"
144   double IdleN1;           ///< Idle N1
145   double N1;               ///< N1
146   double MaxN1;            ///< N1 at 100% throttle
147   double delay;            ///< Inverse spool-up time from idle to 100% (seconds)
148   double N1_factor;        ///< factor to tie N1 and throttle
149   double ThrottlePos;      ///< FCS-supplied throttle position, modified locally
150   bool Reversed;
151   bool Cutoff;
152 
153   double OilPressure_psi;
154   double OilTemp_degK;
155 
156   double Ielu_max_torque;      // max propeller torque (before ielu intervent)
157   bool Ielu_intervent;
158   double OldThrottle;
159 
160   double BetaRangeThrottleEnd; // coef (0-1) where is end of beta-range
161   double ReverseMaxPower;      // coef (0-1) multiplies max throttle on reverse
162 
163   double Idle_Max_Delay;       // time delay for exponential
164   double MaxPower;             // max engine power [HP]
165   double StarterN1;            // rotates of generator maked by starter [%]
166   double MaxStartingTime;      // maximal time for start [s] (-1 means not used)
167   double RPM;                  // shaft RPM
168   double PSFC;                 // Power specific fuel comsumption [lb/(HP*hr)] at best efficiency
169   double CombustionEfficiency;
170 
171   double HP;                   // engine power output
172 
173   double StartTime;            // engine starting time [s] (0 when start button pushed)
174 
175   double  ITT_Delay;           // time delay for exponential growth of ITT
176   double  Eng_ITT_degC;
177   double  Eng_Temperature;     // temperature inside engine
178 
179   bool EngStarting;            // logicaly output - TRUE if engine is starting
180   bool GeneratorPower;
181   int Condition;
182   int thrusterType;            // the attached thruster
183 
184   double Off(void);
185   double Run(void);
186   double SpinUp(void);
187   double Start(void);
188 
189   void SetDefaults(void);
190   bool Load(FGFDMExec *exec, Element *el);
191   void bindmodel(FGPropertyManager* pm);
192   void Debug(int from);
193 
194   FGTable* ITT_N1;             // ITT temperature depending on throttle command
195   FGTable* EnginePowerRPM_N1;
196   FGParameter* EnginePowerVC;
197   FGTable* CombustionEfficiency_N1;
198 };
199 }
200 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
201 #endif
202