]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGPiston.h
Expose the strut compression.
[flightgear.git] / src / FDM / JSBSim / FGPiston.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3  Header:       FGPiston.h
4  Author:       Jon S. Berndt
5  Date started: 09/12/2000
6
7  ------------- Copyright (C) 2000  Jon S. Berndt (jsb@hal-pc.org) --------------
8
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU General Public License as published by the Free Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  version.
13
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
17  details.
18
19  You should have received a copy of the GNU General Public License along with
20  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21  Place - Suite 330, Boston, MA  02111-1307, USA.
22
23  Further information about the GNU General Public License can also be found on
24  the world wide web at http://www.gnu.org.
25
26 HISTORY
27 --------------------------------------------------------------------------------
28 09/12/2000  JSB  Created
29 10/01/2001  DPM  Modified to use equations from Dave Luff's piston model.
30
31 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
32 SENTRY
33 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
34
35 #ifndef FGPISTON_H
36 #define FGPISTON_H
37
38 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39 INCLUDES
40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
41
42 #include "FGEngine.h"
43 #include "FGConfigFile.h"
44 #include "FGTable.h"
45
46 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
47 DEFINITIONS
48 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
49
50 #define ID_PISTON "$Id$";
51 #define FG_MAX_BOOST_SPEEDS 3
52
53 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
54 FORWARD DECLARATIONS
55 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
56
57 namespace JSBSim {
58
59 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
60 CLASS DOCUMENTATION
61 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
62
63 /** Models Dave Luff's Turbo/Supercharged Piston engine model.
64     Additional elements are required for a supercharged engine.  These can be
65     left off a non-supercharged engine, ie. the changes are all backward
66     compatible at present.
67
68     - NUMBOOSTSPEEDS - zero (or not present) for a naturally-aspirated engine,
69       either 1, 2 or 3 for a boosted engine.  This corresponds to the number of
70       supercharger speeds.  Merlin XII had 1 speed, Merlin 61 had 2, a late
71       Griffon engine apparently had 3.  No known engine more than 3, although
72       some German engines apparently had a continuously variable-speed
73       supercharger.
74
75     - BOOSTOVERRIDE - whether the boost pressure control system (either a boost
76       control valve for superchargers or wastegate for turbochargers) can be
77       overriden by the pilot.  During wartime this was commonly possible, and
78       known as "War Emergency Power" by the Brits.  1 or 0 in the config file.
79       This isn't implemented in the model yet though, there would need to be
80       some way of getting the boost control cutout lever position (on or off)
81       from FlightGear first.
82
83     - The next items are all appended with either 1, 2 or 3 depending on which
84       boost speed they refer to, eg RATEDBOOST1.  The rated values seems to have
85       been a common convention at the time to express the maximum continuously
86       available power, and the conditions to attain that power.
87
88     - RATEDBOOST[123] - the absolute rated boost above sea level ambient for a
89       given boost speed, in psi.  Eg the Merlin XII had a rated boost of 9psi,
90       giving approximately 42inHg manifold pressure up to the rated altitude.
91
92     - RATEDALTITUDE[123] - The altitude up to which rated boost can be
93       maintained.  Up to this altitude the boost is maintained constant for a
94       given throttle position by the BCV or wastegate.  Beyond this altitude the
95       manifold pressure must drop, since the supercharger is now at maximum
96       unregulated output.  The actual pressure multiplier of the supercharger
97       system is calculated at initialisation from this value.
98
99     - RATEDPOWER[123] - The power developed at rated boost at rated altitude at
100       rated rpm.
101
102     - RATEDRPM[123] - The rpm at which rated power is developed.
103
104     - TAKEOFFBOOST - Takeoff boost in psi above ambient.  Many aircraft had an
105       extra boost setting beyond rated boost, but not totally uncontrolled as in
106       the already mentioned boost-control-cutout, typically attained by pushing
107       the throttle past a mechanical 'gate' preventing its inadvertant use. This
108       was typically used for takeoff, and emergency situations, generally for
109       not more than five minutes.  This is a change in the boost control
110       setting, not the actual supercharger speed, and so would only give extra
111       power below the rated altitude.  When TAKEOFFBOOST is specified in the
112       config file (and is above RATEDBOOST1), then the throttle position is
113       interpreted as:
114
115     - 0 to 0.95 : idle manifold pressure to rated boost (where attainable)
116     - 0.96, 0.97, 0.98 : rated boost (where attainable).
117     - 0.99, 1.0 : takeoff boost (where attainable).
118
119     A typical takeoff boost for an earlyish Merlin was about 12psi, compared
120     with a rated boost of 9psi.
121
122     It is quite possible that other boost control settings could have been used
123     on some aircraft, or that takeoff/extra boost could have activated by other
124     means than pushing the throttle full forward through a gate, but this will
125     suffice for now.
126
127     Note that MAXMP is still the non-boosted max manifold pressure even for
128     boosted engines - effectively this is simply a measure of the pressure drop
129     through the fully open throttle.
130
131     @author Jon S. Berndt (Engine framework code and framework-related mods)
132     @author Dave Luff (engine operational code)
133     @author David Megginson (initial porting and additional code)
134     @version $Id$
135   */
136
137 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
138 CLASS DECLARATION
139 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
140
141 class FGPiston : public FGEngine
142 {
143 public:
144   /// Constructor
145   FGPiston(FGFDMExec* exec, FGConfigFile* Eng_cfg, int engine_number);
146   /// Destructor
147   ~FGPiston();
148
149   string GetEngineLabels(string delimeter);
150   string GetEngineValues(string delimeter);
151
152   double Calculate(void);
153   double GetPowerAvailable(void) {return PowerAvailable;}
154   double CalcFuelNeed(void);
155
156   void SetMagnetos(int magnetos) {Magnetos = magnetos;}
157
158   double  GetEGT(void) { return EGT_degC; }
159   int     GetMagnetos(void) {return Magnetos;}
160
161   double getExhaustGasTemp_degF(void) {return KelvinToFahrenheit(ExhaustGasTemp_degK);}
162   double getManifoldPressure_inHg(void) const {return ManifoldPressure_inHg;}
163   double getCylinderHeadTemp_degF(void) {return KelvinToFahrenheit(CylinderHeadTemp_degK);}
164   double getOilPressure_psi(void) const {return OilPressure_psi;}
165   double getOilTemp_degF (void) {return KelvinToFahrenheit(OilTemp_degK);}
166   double getRPM(void) {return RPM;}
167
168 private:
169   int crank_counter;
170
171   double BrakeHorsePower;
172   double SpeedSlope;
173   double SpeedIntercept;
174   double AltitudeSlope;
175   double PowerAvailable;
176
177   // timestep
178   double dt;
179
180   void doEngineStartup(void);
181   void doBoostControl(void);
182   void doMAP(void);
183   void doAirFlow(void);
184   void doFuelFlow(void);
185   void doEnginePower(void);
186   void doEGT(void);
187   void doCHT(void);
188   void doOilPressure(void);
189   void doOilTemperature(void);
190
191   //
192   // constants
193   //
194
195   const double R_air;
196   const double rho_fuel;    // kg/m^3
197   const double calorific_value_fuel;  // W/Kg (approximate)
198   const double Cp_air;      // J/KgK
199   const double Cp_fuel;     // J/KgK
200
201   FGTable *Lookup_Combustion_Efficiency;
202   FGTable *Power_Mixture_Correlation;
203
204   //
205   // Configuration
206   //
207   double MinManifoldPressure_inHg; // Inches Hg
208   double MaxManifoldPressure_inHg; // Inches Hg
209   double Displacement;             // cubic inches
210   double MaxHP;                    // horsepower
211   double Cycles;                   // cycles/power stroke
212   double IdleRPM;                  // revolutions per minute
213   int BoostSpeeds;      // Number of super/turbocharger boost speeds - zero implies no turbo/supercharging.
214   int BoostSpeed;       // The current boost-speed (zero-based).
215   bool Boosted;         // Set true for boosted engine.
216   int BoostOverride;    // The raw value read in from the config file - should be 1 or 0 - see description below.
217   bool bBoostOverride;  // Set true if pilot override of the boost regulator was fitted.
218               // (Typically called 'war emergency power').
219   bool bTakeoffBoost;   // Set true if extra takeoff / emergency boost above rated boost could be attained.
220               // (Typically by extra throttle movement past a mechanical 'gate').
221   double TakeoffBoost;  // Sea-level takeoff boost in psi. (if fitted).
222   double RatedBoost[FG_MAX_BOOST_SPEEDS];       // Sea-level rated boost in psi.
223   double RatedAltitude[FG_MAX_BOOST_SPEEDS];    // Altitude at which full boost is reached (boost regulation ends)
224                           // and at which power starts to fall with altitude [ft].
225   double RatedRPM[FG_MAX_BOOST_SPEEDS]; // Engine speed at which the rated power for each boost speed is delivered [rpm].
226   double RatedPower[FG_MAX_BOOST_SPEEDS];       // Power at rated throttle position at rated altitude [HP].
227   double BoostSwitchAltitude[FG_MAX_BOOST_SPEEDS - 1];  // Altitude at which switchover (currently assumed automatic)
228                               // from one boost speed to next occurs [ft].
229   double BoostSwitchPressure[FG_MAX_BOOST_SPEEDS - 1];  // Pressure at which boost speed switchover occurs [Pa]
230   double BoostMul[FG_MAX_BOOST_SPEEDS]; // Pressure multipier of unregulated supercharger
231   double RatedMAP[FG_MAX_BOOST_SPEEDS]; // Rated manifold absolute pressure [Pa] (BCV clamp)
232   double TakeoffMAP[FG_MAX_BOOST_SPEEDS];       // Takeoff setting manifold absolute pressure [Pa] (BCV clamp)
233   double BoostSwitchHysteresis; // Pa.
234
235   double minMAP;  // Pa
236   double maxMAP;  // Pa
237   double MAP;     // Pa
238
239   //
240   // Inputs (in addition to those in FGEngine).
241   //
242   double p_amb;              // Pascals
243   double p_amb_sea_level;    // Pascals
244   double T_amb;              // degrees Kelvin
245   double RPM;                // revolutions per minute
246   double IAS;                // knots
247   bool Magneto_Left;
248   bool Magneto_Right;
249   int Magnetos;
250
251   //
252   // Outputs (in addition to those in FGEngine).
253   //
254   double rho_air;
255   double volumetric_efficiency;
256   double m_dot_air;
257   double equivalence_ratio;
258   double m_dot_fuel;
259   double Percentage_Power;
260   double HP;
261   double combustion_efficiency;
262   double ExhaustGasTemp_degK;
263   double EGT_degC;
264   double ManifoldPressure_inHg;
265   double CylinderHeadTemp_degK;
266   double OilPressure_psi;
267   double OilTemp_degK;
268
269   void Debug(int from);
270 };
271 }
272 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
273 #endif