Debian Codegraph @

src/FDM/JSBSim/models/propulsion/FGPiston.h

raw symbols SCIP
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 ([email protected]) --------------
8
9 This program is free software; you can redistribute it and/or modify it under
10 the terms of the GNU Lesser 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 Lesser General Public License for more
17 details.
18
19 You should have received a copy of the GNU Lesser 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 Lesser 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 11/01/2008 RKJ Modified piston engine model for more general use.
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 "math/FGTable.h"
44
45 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
46 DEFINITIONS
47 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
48
49 #define FG_MAX_BOOST_SPEEDS 3
50
51 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
52 FORWARD DECLARATIONS
53 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
54
55 namespace JSBSim {
56
57 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
58 CLASS DOCUMENTATION
59 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
60
61 /** Models a Supercharged Piston engine. Based on Dave Luff's model.
62
63 <h3>Configuration File Format:</h3>
64
65 @code
66 <piston_engine name="{string}">
67 <minmp unit="{INHG | PA | ATM}"> {number} </minmp>
68 <maxmp unit="{INHG | PA | ATM}"> {number} </maxmp>
69 <idlerpm> {number} </idlerpm>
70 <maxrpm> {number} </maxrpm>
71 <maxhp unit="{HP | WATTS}"> {number} </maxhp>
72 <displacement unit="{IN3 | LTR | CC}"> {number} </displacement>
73 <cycles> {number} </cycles>
74 <bore unit="{IN | M}"> {number} </bore>
75 <stroke unit="{IN | M}"> {number} </stroke>
76 <cylinders> {number} </cylinders>
77 <compression-ratio> {number} </compression-ratio>
78 <sparkfaildrop> {number} </sparkfaildrop>
79 <static-friction unit="{HP | WATTS}"> {number} </static-friction>
80 <air-intake-impedance-factor> {number} </air-intake-impedance-factor>
81 <ram-air-factor> {number} </ram-air-factor>
82 <cooling-factor> {number} </cooling-factor>
83 <man-press-lag> {number} </man-press-lag>
84 <starter-torque> {number} </starter-torque>
85 <starter-rpm> {number} </starter-rpm>
86 <cylinder-head-mass unit="{KG | LBS}"> {number} </cylinder-head-mass>
87 <bsfc unit="{LBS/HP*HR | "KG/KW*HR"}"> {number} </bsfc>
88 <volumetric-efficiency> {number} </volumetric-efficiency>
89 <dynamic-fmep unit="{INHG | PA | ATM}"> {number} </dynamic-fmep>
90 <static-fmep unit="{INHG | PA | ATM}"> {number} </static-fmep>
91 <numboostspeeds> {number} </numboostspeeds>
92 <boostoverride> {0 | 1} </boostoverride>
93 <boostmanual> {0 | 1} </boostmanual>
94 <boost-loss-factor> {number} </boost-loss-factor>
95 <ratedboost1 unit="{INHG | PA | ATM}"> {number} </ratedboost1>
96 <ratedpower1 unit="{HP | WATTS}"> {number} </ratedpower1>
97 <ratedrpm1> {number} </ratedrpm1>
98 <ratedaltitude1 unit="{FT | M}"> {number} </ratedaltitude1>
99 <ratedboost2 unit="{INHG | PA | ATM}"> {number} </ratedboost2>
100 <ratedpower2 unit="{HP | WATTS}"> {number} </ratedpower2>
101 <ratedrpm2> {number} </ratedrpm2>
102 <ratedaltitude2 unit="{FT | M}"> {number} </ratedaltitude2>
103 <ratedboost3 unit="{INHG | PA | ATM}"> {number} </ratedboost3>
104 <ratedpower3 unit="{HP | WATTS}"> {number} </ratedpower3>
105 <ratedrpm3> {number} </ratedrpm3>
106 <ratedaltitude3 unit="{FT | M}"> {number} </ratedaltitude3>
107 <takeoffboost unit="{INHG | PA | ATM}"> {number} </takeoffboost>
108 <oil-pressure-relief-valve-psi> {number} </oil-pressure-relief-valve=psi>
109 <design-oil-temp-degK> {number} </design-oil-temp-degK>
110 <oil-pressure-rpm-max> {number} </oil-pressure-rpm-max>
111 <oil-viscosity-index> {number} </oil-viscosity-index>
112 </piston_engine>
113 @endcode
114
115 <h3>Definition of the piston engine configuration file parameters:</h3>
116 Basic parameters:
117 - \b minmp - this value is the nominal idle manifold pressure at sea-level
118 without boost. Along with idlerpm, it determines throttle response slope.
119 - \b maxmp - this value is the nominal maximum manifold pressure at sea-level
120 without boost. Along with maxrpm it determines the resistance of the
121 aircraft intake system. Overridden by air-intake-impedance-factor
122 - \b man-press-lag - Delay in seconds for manifold pressure changes to take effect
123 - \b starter-torque - A value specifing the zero RPM torque in lb*ft the starter motor
124 provides. Current default value is 40% of the horse power value.
125 - \b starter-rpm - A value specifing the maximum RPM the unloaded starter motor
126 can achieve. Loads placed on the engine by the propeller and throttle will
127 further limit RPM achieved in practice.
128 - \b idlerpm - this value affects the throttle fall off and the engine stops
129 running if it is slowed below 80% of this value. The engine starts
130 running when it reaches 80% of this value.
131 - \b maxrpm - this value is used to calculate air-box resistance and BSFC. It
132 also affects oil pressure among other things.
133 - \b maxhp - this value is the nominal power the engine creates at maxrpm. It
134 will determine bsfc if that tag is not input. It also determines the
135 starter motor power.
136 - \b displacement - this value is used to determine mass air and fuel flow
137 which impacts engine power and cooling.
138 - \b cycles - Designate a 2 or 4 stroke engine. Currently only the 4 stroke
139 engine is supported.
140 - \b bore - cylinder bore is currently unused.
141 - \b stroke - piston stroke is used to determine the mean piston speed. Longer
142 strokes result in an engine that does not work as well at higher RPMs.
143 - \b compression-ratio - the compression ratio affects the change in volumetric
144 efficiency with altitude.
145 - \b sparkfaildrop - this is the percentage drop in horsepower for single
146 magneto operation.
147 - \b static-friction - this value is the power required to turn an engine that
148 is not running. Used to control and slow a windmilling propeller. Choose
149 a small percentage of maxhp.
150
151 Advanced parameters
152 - \b bsfc - Indicated Specific Fuel Consumption. The power produced per unit of
153 fuel. Higher numbers give worse fuel economy. This number may need to be
154 lowered slightly from actual BSFC numbers because some internal engine
155 losses are modeled separately. Typically between 0.3 and 0.5
156 - \b volumetric-efficiency - the nominal volumetric efficiency of the engine.
157 This is the primary way to control fuel flow Boosted engines may require
158 values above 1. Typical engines are 0.80 to 0.82
159 - \b air-intake-impedance-factor - this number is the pressure drop across the
160 intake system. Increasing it reduces available manifold pressure. Also a
161 property for run-time adjustment.
162 - \b ram-air-factor - this number creates increases manifold pressure with an
163 increase in dynamic pressure (aircraft speed).
164 Also a property for run-time adjustment.
165
166 Cooling control:
167 - \b cylinders - number of cylinders scales the cylinder head mass.
168 - \b cylinder-head-mass - the nominal mass of a cylinder head. A larger value
169 slows changes in engine temperature
170 - \b cooling-factor - this number models the efficiency of the aircraft cooling
171 system. Also a property for run-time adjustment.
172
173 Supercharge parameters:
174 - \b numboostspeed - zero (or not present) for a naturally-aspirated engine,
175 either 1, 2 or 3 for a boosted engine. This corresponds to the number of
176 supercharger speeds. Merlin XII had 1 speed, Merlin 61 had 2, a late
177 Griffon engine apparently had 3. No known engine more than 3, although
178 some German engines had continuously variable-speed superchargers.
179 - \b boostoverride - whether or not to clip output to the wastegate value
180 - \b boost-loss-factor - zero (or not present) for 'free' supercharging. A value entered
181 will be used as a multiplier to the power required to compress the input air. Typical
182 value should be 1.15 to 1.20.
183 - \b boostmanual - whether a multispeed supercharger will manually or
184 automatically shift boost speeds. On manual shifting the boost speeds is
185 accomplished by controlling the property propulsion/engine/boostspeed.
186 - \b takeoffboost - boost in psi above sea level ambient. Typically used for
187 takeoff, and emergency situations, generally for not more than five
188 minutes. This is a change in the boost control setting, not the actual
189 supercharger speed, and so would only give extra power below the rated altitude.
190 A typical takeoff boost for an early Merlin was about 12psi, compared
191 with a rated boost of 9psi.
192
193 When TAKEOFFBOOST is specified in the config file (and is above RATEDBOOST1),
194 the throttle position is interpreted as:
195 - 0 to 0.98 : idle manifold pressure to rated boost (where attainable)
196 - 0.99, 1.0 : takeoff boost (where attainable).
197
198 The next items are all appended with either 1, 2 or 3 depending on which
199 boostspeed they refer to:
200 - \b ratedboost[123] - the absolute rated boost above sea level ambient
201 (14.7 PSI, 29.92 inHg) for a given boost speed.
202
203 - \b ratedpower[123] - unused
204 - \b ratedrpm[123] - The rpm at which rated boost is developed
205 - \b ratedaltitude[123] - The altitude up to which the rated boost can be
206 maintained. Up to this altitude the boost is clipped to rated boost or
207 takeoffboost. Beyond this altitude the manifold pressure must drop,
208 since the supercharger is now at maximum unregulated output. The actual
209 pressure multiplier of the supercharger system is calculated at
210 initialization from this value.
211
212 @author Jon S. Berndt (Engine framework code and framework-related mods)
213 @author Dave Luff (engine operational code)
214 @author David Megginson (initial porting and additional code)
215 @author Ron Jensen (additional engine code)
216 @see Taylor, Charles Fayette, "The Internal Combustion Engine in Theory and Practice"
217 */
218
219 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
220 CLASS DECLARATION
221 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
222
223 class FGPiston : public FGEngine
224 {
225 public:
226 /// Constructor
227 FGPiston(FGFDMExec* exec, Element* el, int engine_number, struct Inputs& input);
228 /// Destructor
229 ~FGPiston();
230
231 std::string GetEngineLabels(const std::string& delimiter);
232 std::string GetEngineValues(const std::string& delimiter);
233
234 void Calculate(void);
235 double GetPowerAvailable(void) const {return (HP * hptoftlbssec);}
236 double CalcFuelNeed(void);
237
238 void ResetToIC(void);
239 void SetMagnetos(int magnetos) {Magnetos = magnetos;}
240
241 double GetEGT(void) const { return EGT_degC; }
242 int GetMagnetos(void) const {return Magnetos;}
243
244 double getExhaustGasTemp_degF(void) const {return KelvinToFahrenheit(ExhaustGasTemp_degK);}
245 double getManifoldPressure_inHg(void) const {return ManifoldPressure_inHg;}
246 double getCylinderHeadTemp_degF(void) const {return KelvinToFahrenheit(CylinderHeadTemp_degK);}
247 double getOilPressure_psi(void) const {return OilPressure_psi;}
248 double getOilTemp_degF (void) const {return KelvinToFahrenheit(OilTemp_degK);}
249 double getRPM(void) const {return RPM;}
250 double getAFR(void) const {return m_dot_fuel > 0.0 ? m_dot_air / m_dot_fuel : INFINITY;}
251
252 protected:
253
254 private:
255 int crank_counter = 0;
256
257 double IndicatedHorsePower = 0.0;
258 //double IndicatedPower;
259 double PMEP = 0.0;
260 double FMEP = 0.0;
261 double FMEPDynamic = 0.0;
262 double FMEPStatic = 0.0;
263 //double T_Intake;
264
265 void doEngineStartup(void);
266 void doBoostControl(void);
267 void doMAP(void);
268 void doAirFlow(void);
269 void doFuelFlow(void);
270 void doEnginePower(void);
271 void doEGT(void);
272 void doCHT(void);
273 void doOilPressure(void);
274 void doOilTemperature(void);
275 double GetStdPressure100K(double altitude) const;
276
277 int InitRunning(void);
278
279 //
280 // constants
281 //
282
283 const double R_air;
284 //const double rho_fuel; // kg/m^3
285 const double calorific_value_fuel; // J/Kg (approximate)
286 const double Cp_air; // J/KgK
287 const double Cp_fuel; // J/KgK
288 const double standard_pressure; //Pa
289
290
291 FGTable *Lookup_Combustion_Efficiency;
292 FGTable *Mixture_Efficiency_Correlation;
293
294 //
295 // Configuration
296 //
297 double MinManifoldPressure_inHg = 0.0; // Inches Hg
298 double MaxManifoldPressure_inHg = 0.0; // Inches Hg
299 //double MaxManifoldPressure_Percent; // MaxManifoldPressure / 29.92
300 double ManifoldPressureLag = 0.0; // Manifold Pressure delay in seconds.
301 double Displacement = 0.0; // cubic inches
302 double displacement_SI = 0.0; // cubic meters
303 double MaxHP = 0.0; // horsepower
304 double StaticFriction_HP = 0.0; // horsepower: amount subtracted from final engine power
305 double SparkFailDrop = 0.0; // drop of power due to spark failure
306 double Cycles = 0.0; // cycles/power stroke
307 double IdleRPM = 0.0; // revolutions per minute
308 double MaxRPM = 0.0; // revolutions per minute
309 double Bore = 0.0; // inches
310 double Stroke = 0.0; // inches
311 double Cylinders = 0.0; // number
312 double CylinderHeadMass = 0.0; // kilograms
313 double CompressionRatio = 0.0; // number
314 double Z_airbox = 0.0; // number representing intake impediance before the throttle
315 double Z_throttle = 0.0; // number representing slope of throttle impediance
316 double PeakMeanPistonSpeed_fps = 0.0; // ft/sec speed where intake valves begin to choke. Typically 33-50 fps
317 double RatedMeanPistonSpeed_fps = 0.0; // ft/sec derived from MaxRPM and stroke.
318 double Ram_Air_Factor = 0.0; // number
319
320 double StarterTorque = 0.0;// Peak Torque of the starter motor
321 double StarterRPM = 0.0; // Peak RPM of the starter motor
322 double StarterGain = 0.0; // control the torque of the starter motor.
323 int BoostSpeeds = 0; // Number of super/turbocharger boost speeds - zero implies no turbo/supercharging.
324 int BoostSpeed = 0; // The current boost-speed (zero-based).
325 bool Boosted = false; // Set true for boosted engine.
326 int BoostManual = 0; // The raw value read in from the config file - should be 1 or 0 - see description below.
327 bool bBoostManual = false; // Set true if pilot must manually control the boost speed.
328 int BoostOverride = 0; // The raw value read in from the config file - should be 1 or 0 - see description below.
329 bool bBoostOverride = false; // Set true if pilot override of the boost regulator was fitted.
330 // (Typically called 'war emergency power').
331 bool bTakeoffBoost = false; // Set true if extra takeoff / emergency boost above rated boost could be attained.
332 // (Typically by extra throttle movement past a mechanical 'gate').
333 double TakeoffBoost = 0.0; // Sea-level takeoff boost in psi. (if fitted).
334 double RatedBoost[FG_MAX_BOOST_SPEEDS] = {0.0, 0.0, 0.0}; // Sea-level rated boost in psi.
335 double RatedAltitude[FG_MAX_BOOST_SPEEDS] = {0.0, 0.0, 0.0}; // Altitude at which full boost is reached (boost regulation ends)
336 // and at which power starts to fall with altitude [ft].
337 double RatedRPM[FG_MAX_BOOST_SPEEDS] = {0.0, 0.0, 0.0}; // Engine speed at which the rated power for each boost speed is delivered [rpm].
338 double RatedPower[FG_MAX_BOOST_SPEEDS] = {0.0, 0.0, 0.0}; // Power at rated throttle position at rated altitude [HP].
339 double BoostSwitchAltitude[FG_MAX_BOOST_SPEEDS - 1] = {0.0, 0.0}; // Altitude at which switchover (currently assumed automatic)
340 // from one boost speed to next occurs [ft].
341 double BoostSwitchPressure[FG_MAX_BOOST_SPEEDS - 1] = {0.0, 0.0}; // Pressure at which boost speed switchover occurs [Pa]
342 double BoostMul[FG_MAX_BOOST_SPEEDS] = {0.0, 0.0, 0.0}; // Pressure multiplier of unregulated supercharger
343 double RatedMAP[FG_MAX_BOOST_SPEEDS] = {0.0, 0.0, 0.0}; // Rated manifold absolute pressure [Pa] (BCV clamp)
344 double TakeoffMAP[FG_MAX_BOOST_SPEEDS] = {0.0, 0.0, 0.0}; // Takeoff setting manifold absolute pressure [Pa] (BCV clamp)
345 double BoostSwitchHysteresis = 0.0; // Pa.
346 double BoostLossFactor = 0.0; // multiplier for HP consumed by the supercharger
347
348 double minMAP = 0.0; // Pa
349 double maxMAP = 0.0; // Pa
350 double MAP = 0.0; // Pa
351 double TMAP = 0.0; // Pa - throttle manifold pressure e.g. before the supercharger boost
352 double ISFC = 0.0; // Indicated specific fuel consumption [lbs/horsepower*hour
353
354 //
355 // Inputs (in addition to those in FGEngine).
356 //
357 double p_amb = 0.0; // Pascals
358 double p_ram = 0.0; // Pascals
359 double T_amb = 0.0; // degrees Kelvin
360 double RPM = 0.0; // revolutions per minute
361 double IAS = 0.0; // knots
362 double Cooling_Factor = 0.0; // normal
363 bool Magneto_Left = false;
364 bool Magneto_Right = false;
365 int Magnetos = 0;
366
367 double Oil_Press_Relief_Valve = 0.0;
368 double Oil_Press_RPM_Max = 0.0;
369 double Design_Oil_Temp = 0.0; // degK
370 double Oil_Viscosity_Index = 0.0;
371
372 //
373 // Outputs (in addition to those in FGEngine).
374 //
375 double rho_air = 0.0;
376 double volumetric_efficiency = 0.0;
377 double volumetric_efficiency_reduced = 0.0;
378 //double map_coefficient;
379 double m_dot_air = 0.0;
380 double v_dot_air = 0.0;
381 double equivalence_ratio = 0.0;
382 double m_dot_fuel = 0.0;
383 double HP = 0.0;
384 double BoostLossHP = 0.0;
385 double combustion_efficiency = 0.0;
386 double ExhaustGasTemp_degK = 0.0;
387 double EGT_degC = 0.0;
388 double ManifoldPressure_inHg = 0.0;
389 double CylinderHeadTemp_degK = 0.0;
390 double OilPressure_psi = 0.0;
391 double OilTemp_degK = 0.0;
392 double MeanPistonSpeed_fps = 0.0;
393
394 void Debug(int from);
395 };
396 }
397 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
398 #endif