]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/propulsion/FGPiston.cpp
resync JSBSim
[flightgear.git] / src / FDM / JSBSim / models / propulsion / FGPiston.cpp
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3  Module:       FGPiston.cpp
4  Author:       Jon S. Berndt, JSBSim framework
5                Dave Luff, Piston engine model
6                Ronald Jensen, Piston engine model
7  Date started: 09/12/2000
8  Purpose:      This module models a Piston engine
9
10  ------------- Copyright (C) 2000  Jon S. Berndt (jon@jsbsim.org) --------------
11
12  This program is free software; you can redistribute it and/or modify it under
13  the terms of the GNU Lesser General Public License as published by the Free Software
14  Foundation; either version 2 of the License, or (at your option) any later
15  version.
16
17  This program is distributed in the hope that it will be useful, but WITHOUT
18  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19  FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
20  details.
21
22  You should have received a copy of the GNU Lesser General Public License along with
23  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
24  Place - Suite 330, Boston, MA  02111-1307, USA.
25
26  Further information about the GNU Lesser General Public License can also be found on
27  the world wide web at http://www.gnu.org.
28
29 FUNCTIONAL DESCRIPTION
30 --------------------------------------------------------------------------------
31
32 This class descends from the FGEngine class and models a Piston engine based on
33 parameters given in the engine config file for this class
34
35 HISTORY
36 --------------------------------------------------------------------------------
37 09/12/2000  JSB  Created
38
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
40 INCLUDES
41 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
42
43 #include <iostream>
44 #include <sstream>
45
46 #include "FGPiston.h"
47 #include "FGPropeller.h"
48
49 using namespace std;
50
51 namespace JSBSim {
52
53 static const char *IdSrc = "$Id: FGPiston.cpp,v 1.65 2011/09/11 12:06:54 bcoconni Exp $";
54 static const char *IdHdr = ID_PISTON;
55
56 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57 CLASS IMPLEMENTATION
58 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
59
60 FGPiston::FGPiston(FGFDMExec* exec, Element* el, int engine_number, struct Inputs& input)
61   : FGEngine(exec, el, engine_number, input),
62   R_air(287.3),                  // Gas constant for air J/Kg/K
63   rho_fuel(800),                 // estimate
64   calorific_value_fuel(47.3e6),  // J/Kg
65   Cp_air(1005),                  // Specific heat (constant pressure) J/Kg/K
66   Cp_fuel(1700),
67   standard_pressure(101320.73)
68 {
69   Element *table_element;
70   string token;
71   string name="";
72
73   // Defaults and initializations
74
75   Type = etPiston;
76
77   // These items are read from the configuration file
78   // Defaults are from a Lycoming O-360, more or less
79
80   Cycles = 4;
81   IdleRPM = 600;
82   MaxRPM = 2800;
83   Displacement = 360;
84   SparkFailDrop = 1.0;
85   MaxHP = 200;
86   MinManifoldPressure_inHg = 6.5;
87   MaxManifoldPressure_inHg = 28.5;
88   ISFC = -1;
89   volumetric_efficiency = 0.85;
90   Bore = 5.125;
91   Stroke = 4.375;
92   Cylinders = 4;
93   CylinderHeadMass = 2; //kg
94   CompressionRatio = 8.5;
95   Z_airbox = -999;
96   Ram_Air_Factor = 1;
97   PeakMeanPistonSpeed_fps = 100;
98   FMEPDynamic= 18400;
99   FMEPStatic = 46500;
100   Cooling_Factor = 0.5144444;
101   StaticFriction_HP = 1.5;
102
103   // These are internal program variables
104
105   Lookup_Combustion_Efficiency = 0;
106   Mixture_Efficiency_Correlation = 0;
107   crank_counter = 0;
108   Magnetos = 0;
109   minMAP = 21950;
110   maxMAP = 96250;
111
112   ResetToIC();
113
114   // Supercharging
115   BoostSpeeds = 0;  // Default to no supercharging
116   BoostSpeed = 0;
117   Boosted = false;
118   BoostOverride = 0;
119   BoostManual = 0;
120   bBoostOverride = false;
121   bTakeoffBoost = false;
122   TakeoffBoost = 0.0;   // Default to no extra takeoff-boost
123   int i;
124   for (i=0; i<FG_MAX_BOOST_SPEEDS; i++) {
125     RatedBoost[i] = 0.0;
126     RatedPower[i] = 0.0;
127     RatedAltitude[i] = 0.0;
128     BoostMul[i] = 1.0;
129     RatedMAP[i] = 100000;
130     RatedRPM[i] = 2500;
131     TakeoffMAP[i] = 100000;
132   }
133   for (i=0; i<FG_MAX_BOOST_SPEEDS-1; i++) {
134     BoostSwitchAltitude[i] = 0.0;
135     BoostSwitchPressure[i] = 0.0;
136   }
137
138   // Read inputs from engine data file where present.
139
140   if (el->FindElement("minmp")) // Should have ELSE statement telling default value used?
141     MinManifoldPressure_inHg = el->FindElementValueAsNumberConvertTo("minmp","INHG");
142   if (el->FindElement("maxmp"))
143     MaxManifoldPressure_inHg = el->FindElementValueAsNumberConvertTo("maxmp","INHG");
144   if (el->FindElement("displacement"))
145     Displacement = el->FindElementValueAsNumberConvertTo("displacement","IN3");
146   if (el->FindElement("maxhp"))
147     MaxHP = el->FindElementValueAsNumberConvertTo("maxhp","HP");
148   if (el->FindElement("static-friction"))
149     StaticFriction_HP = el->FindElementValueAsNumberConvertTo("static-friction","HP");
150   if (el->FindElement("sparkfaildrop"))
151     SparkFailDrop = Constrain(0, 1 - el->FindElementValueAsNumber("sparkfaildrop"), 1);
152   if (el->FindElement("cycles"))
153     Cycles = el->FindElementValueAsNumber("cycles");
154   if (el->FindElement("idlerpm"))
155     IdleRPM = el->FindElementValueAsNumber("idlerpm");
156   if (el->FindElement("maxrpm"))
157     MaxRPM = el->FindElementValueAsNumber("maxrpm");
158   if (el->FindElement("maxthrottle"))
159     MaxThrottle = el->FindElementValueAsNumber("maxthrottle");
160   if (el->FindElement("minthrottle"))
161     MinThrottle = el->FindElementValueAsNumber("minthrottle");
162   if (el->FindElement("bsfc"))
163     ISFC = el->FindElementValueAsNumberConvertTo("bsfc", "LBS/HP*HR");
164   if (el->FindElement("volumetric-efficiency"))
165     volumetric_efficiency = el->FindElementValueAsNumber("volumetric-efficiency");
166   if (el->FindElement("compression-ratio"))
167     CompressionRatio = el->FindElementValueAsNumber("compression-ratio");
168   if (el->FindElement("bore"))
169     Bore = el->FindElementValueAsNumberConvertTo("bore","IN");
170   if (el->FindElement("stroke"))
171     Stroke = el->FindElementValueAsNumberConvertTo("stroke","IN");
172   if (el->FindElement("cylinders"))
173     Cylinders = el->FindElementValueAsNumber("cylinders");
174   if (el->FindElement("cylinder-head-mass"))
175     CylinderHeadMass = el->FindElementValueAsNumberConvertTo("cylinder-head-mass","KG");
176   if (el->FindElement("air-intake-impedance-factor"))
177     Z_airbox = el->FindElementValueAsNumber("air-intake-impedance-factor");
178   if (el->FindElement("ram-air-factor"))
179     Ram_Air_Factor  = el->FindElementValueAsNumber("ram-air-factor");
180   if (el->FindElement("cooling-factor"))
181     Cooling_Factor  = el->FindElementValueAsNumber("cooling-factor");
182   if (el->FindElement("dynamic-fmep"))
183     FMEPDynamic= el->FindElementValueAsNumberConvertTo("dynamic-fmep","PA");
184   if (el->FindElement("static-fmep"))
185     FMEPStatic = el->FindElementValueAsNumberConvertTo("static-fmep","PA");
186   if (el->FindElement("peak-piston-speed"))
187     PeakMeanPistonSpeed_fps  = el->FindElementValueAsNumber("peak-piston-speed");
188   if (el->FindElement("numboostspeeds")) { // Turbo- and super-charging parameters
189     BoostSpeeds = (int)el->FindElementValueAsNumber("numboostspeeds");
190     if (el->FindElement("boostoverride"))
191       BoostOverride = (int)el->FindElementValueAsNumber("boostoverride");
192     if (el->FindElement("boostmanual"))
193       BoostManual = (int)el->FindElementValueAsNumber("boostmanual");
194     if (el->FindElement("takeoffboost"))
195       TakeoffBoost = el->FindElementValueAsNumberConvertTo("takeoffboost", "PSI");
196     if (el->FindElement("ratedboost1"))
197       RatedBoost[0] = el->FindElementValueAsNumberConvertTo("ratedboost1", "PSI");
198     if (el->FindElement("ratedboost2"))
199       RatedBoost[1] = el->FindElementValueAsNumberConvertTo("ratedboost2", "PSI");
200     if (el->FindElement("ratedboost3"))
201       RatedBoost[2] = el->FindElementValueAsNumberConvertTo("ratedboost3", "PSI");
202     if (el->FindElement("ratedpower1"))
203       RatedPower[0] = el->FindElementValueAsNumberConvertTo("ratedpower1", "HP");
204     if (el->FindElement("ratedpower2"))
205       RatedPower[1] = el->FindElementValueAsNumberConvertTo("ratedpower2", "HP");
206     if (el->FindElement("ratedpower3"))
207       RatedPower[2] = el->FindElementValueAsNumberConvertTo("ratedpower3", "HP");
208     if (el->FindElement("ratedrpm1"))
209       RatedRPM[0] = el->FindElementValueAsNumber("ratedrpm1");
210     if (el->FindElement("ratedrpm2"))
211       RatedRPM[1] = el->FindElementValueAsNumber("ratedrpm2");
212     if (el->FindElement("ratedrpm3"))
213       RatedRPM[2] = el->FindElementValueAsNumber("ratedrpm3");
214     if (el->FindElement("ratedaltitude1"))
215       RatedAltitude[0] = el->FindElementValueAsNumberConvertTo("ratedaltitude1", "FT");
216     if (el->FindElement("ratedaltitude2"))
217       RatedAltitude[1] = el->FindElementValueAsNumberConvertTo("ratedaltitude2", "FT");
218     if (el->FindElement("ratedaltitude3"))
219       RatedAltitude[2] = el->FindElementValueAsNumberConvertTo("ratedaltitude3", "FT");
220   }
221
222   while((table_element = el->FindNextElement("table")) != 0) {
223     name = table_element->GetAttributeValue("name");
224     try {
225       if (name == "COMBUSTION") {
226         Lookup_Combustion_Efficiency = new FGTable(PropertyManager, table_element);
227       } else if (name == "MIXTURE") {
228         Mixture_Efficiency_Correlation = new FGTable(PropertyManager, table_element);
229       } else {
230         cerr << "Unknown table type: " << name << " in piston engine definition." << endl;
231       }
232     } catch (std::string str) {
233       throw("Error loading piston engine table:" + name + ". " + str);
234     }
235   }
236
237   StarterHP = sqrt(MaxHP) * 0.4;
238   displacement_SI = Displacement * in3tom3;
239   RatedMeanPistonSpeed_fps =  ( MaxRPM * Stroke) / (360); // AKA 2 * (RPM/60) * ( Stroke / 12) or 2NS
240
241   // Create IFSC to match the engine if not provided
242   if (ISFC < 0) {
243       double pmep = 29.92 - MaxManifoldPressure_inHg;
244       pmep *= inhgtopa  * volumetric_efficiency;
245       double fmep = (FMEPDynamic * RatedMeanPistonSpeed_fps * fttom + FMEPStatic);
246       double hp_loss = ((pmep + fmep) * displacement_SI * MaxRPM)/(Cycles*22371);
247       ISFC = ( 1.1*Displacement * MaxRPM * volumetric_efficiency *(MaxManifoldPressure_inHg / 29.92) ) / (9411 * (MaxHP+hp_loss-StaticFriction_HP));
248 // cout <<"FMEP: "<< fmep <<" PMEP: "<< pmep << " hp_loss: " <<hp_loss <<endl;
249   }
250   if ( MaxManifoldPressure_inHg > 29.9 ) {   // Don't allow boosting with a bogus number
251       MaxManifoldPressure_inHg = 29.9;
252   }
253   minMAP = MinManifoldPressure_inHg * inhgtopa;  // inHg to Pa
254   maxMAP = MaxManifoldPressure_inHg * inhgtopa;
255
256 // For throttle
257 /*
258  * Pm = ( Ze / ( Ze + Zi + Zt ) ) * Pa
259  * Where:
260  * Pm = Manifold Pressure
261  * Pa = Ambient Pressre
262  * Ze = engine impedance, Ze is effectively 1 / Mean Piston Speed
263  * Zi = airbox impedance
264  * Zt = throttle impedance
265  *
266  * For the calculation below throttle is fully open or Zt = 0
267  *
268  *
269  *
270  */
271   if(Z_airbox < 0.0){
272     double Ze=PeakMeanPistonSpeed_fps/RatedMeanPistonSpeed_fps; // engine impedence
273     Z_airbox = (standard_pressure *Ze / maxMAP) - Ze; // impedence of airbox
274   }
275   // Constant for Throttle impedence
276   Z_throttle=(PeakMeanPistonSpeed_fps/((IdleRPM * Stroke) / 360))*(standard_pressure/minMAP - 1) - Z_airbox; 
277   //  Z_throttle=(MaxRPM/IdleRPM )*(standard_pressure/minMAP+2); // Constant for Throttle impedence
278
279 // Default tables if not provided in the configuration file
280   if(Lookup_Combustion_Efficiency == 0) {
281     // First column is thi, second is neta (combustion efficiency)
282     Lookup_Combustion_Efficiency = new FGTable(12);
283     *Lookup_Combustion_Efficiency << 0.00 << 0.980;
284     *Lookup_Combustion_Efficiency << 0.90 << 0.980;
285     *Lookup_Combustion_Efficiency << 1.00 << 0.970;
286     *Lookup_Combustion_Efficiency << 1.05 << 0.950;
287     *Lookup_Combustion_Efficiency << 1.10 << 0.900;
288     *Lookup_Combustion_Efficiency << 1.15 << 0.850;
289     *Lookup_Combustion_Efficiency << 1.20 << 0.790;
290     *Lookup_Combustion_Efficiency << 1.30 << 0.700;
291     *Lookup_Combustion_Efficiency << 1.40 << 0.630;
292     *Lookup_Combustion_Efficiency << 1.50 << 0.570;
293     *Lookup_Combustion_Efficiency << 1.60 << 0.525;
294     *Lookup_Combustion_Efficiency << 2.00 << 0.345;
295   }
296
297     // First column is Fuel/Air Ratio, second is neta (mixture efficiency)
298   if( Mixture_Efficiency_Correlation == 0) {
299     Mixture_Efficiency_Correlation = new FGTable(15);
300     *Mixture_Efficiency_Correlation << 0.05000 << 0.00000;
301     *Mixture_Efficiency_Correlation << 0.05137 << 0.00862;
302     *Mixture_Efficiency_Correlation << 0.05179 << 0.21552;
303     *Mixture_Efficiency_Correlation << 0.05430 << 0.48276;
304     *Mixture_Efficiency_Correlation << 0.05842 << 0.70690;
305     *Mixture_Efficiency_Correlation << 0.06312 << 0.83621;
306     *Mixture_Efficiency_Correlation << 0.06942 << 0.93103;
307     *Mixture_Efficiency_Correlation << 0.07786 << 1.00000;
308     *Mixture_Efficiency_Correlation << 0.08845 << 1.00000;
309     *Mixture_Efficiency_Correlation << 0.09270 << 0.98276;
310     *Mixture_Efficiency_Correlation << 0.10120 << 0.93103;
311     *Mixture_Efficiency_Correlation << 0.11455 << 0.72414;
312     *Mixture_Efficiency_Correlation << 0.12158 << 0.45690;
313     *Mixture_Efficiency_Correlation << 0.12435 << 0.23276;
314     *Mixture_Efficiency_Correlation << 0.12500 << 0.00000;
315   }
316
317   string property_name, base_property_name;
318   base_property_name = CreateIndexedPropertyName("propulsion/engine", EngineNumber);
319   property_name = base_property_name + "/power-hp";
320   PropertyManager->Tie(property_name, &HP);
321   property_name = base_property_name + "/bsfc-lbs_hphr";
322   PropertyManager->Tie(property_name, &ISFC);
323   property_name = base_property_name + "/volumetric-efficiency";
324   PropertyManager->Tie(property_name, &volumetric_efficiency);
325   property_name = base_property_name + "/map-pa";
326   PropertyManager->Tie(property_name, &MAP);
327   property_name = base_property_name + "/map-inhg";
328   PropertyManager->Tie(property_name, &ManifoldPressure_inHg);
329   property_name = base_property_name + "/air-intake-impedance-factor";
330   PropertyManager->Tie(property_name, &Z_airbox);
331   property_name = base_property_name + "/ram-air-factor";
332   PropertyManager->Tie(property_name, &Ram_Air_Factor);
333   property_name = base_property_name + "/cooling-factor";
334   PropertyManager->Tie(property_name, &Cooling_Factor);
335   property_name = base_property_name + "/boost-speed";
336   PropertyManager->Tie(property_name, &BoostSpeed);
337   property_name = base_property_name + "/cht-degF";
338   PropertyManager->Tie(property_name, this, &FGPiston::getCylinderHeadTemp_degF);
339   property_name = base_property_name + "/engine-rpm";
340   PropertyManager->Tie(property_name, this, &FGPiston::getRPM);
341   property_name = base_property_name + "/oil-temperature-degF";
342   PropertyManager->Tie(property_name, this, &FGPiston::getOilTemp_degF);
343   property_name = base_property_name + "/oil-pressure-psi";
344   PropertyManager->Tie(property_name, this, &FGPiston::getOilPressure_psi);
345   property_name = base_property_name + "/egt-degF";
346   PropertyManager->Tie(property_name, this, &FGPiston::getExhaustGasTemp_degF);
347
348   // Set up and sanity-check the turbo/supercharging configuration based on the input values.
349   if (TakeoffBoost > RatedBoost[0]) bTakeoffBoost = true;
350   for (i=0; i<BoostSpeeds; ++i) {
351     bool bad = false;
352     if (RatedBoost[i] <= 0.0) bad = true;
353     if (RatedPower[i] <= 0.0) bad = true;
354     if (RatedAltitude[i] < 0.0) bad = true;  // 0.0 is deliberately allowed - this corresponds to unregulated supercharging.
355     if (i > 0 && RatedAltitude[i] < RatedAltitude[i - 1]) bad = true;
356     if (bad) {
357       // We can't recover from the above - don't use this supercharger speed.
358       BoostSpeeds--;
359       // TODO - put out a massive error message!
360       break;
361     }
362     // Now sanity-check stuff that is recoverable.
363     if (i < BoostSpeeds - 1) {
364       if (BoostSwitchAltitude[i] < RatedAltitude[i]) {
365         // TODO - put out an error message
366         // But we can also make a reasonable estimate, as below.
367         BoostSwitchAltitude[i] = RatedAltitude[i] + 1000;
368       }
369       BoostSwitchPressure[i] = GetStdPressure100K(BoostSwitchAltitude[i]) * psftopa;
370       //cout << "BoostSwitchAlt = " << BoostSwitchAltitude[i] << ", pressure = " << BoostSwitchPressure[i] << '\n';
371       // Assume there is some hysteresis on the supercharger gear switch, and guess the value for now
372       BoostSwitchHysteresis = 1000;
373     }
374     // Now work out the supercharger pressure multiplier of this speed from the rated boost and altitude.
375     RatedMAP[i] = standard_pressure + RatedBoost[i] * 6895;  // psi*6895 = Pa.
376     // Sometimes a separate BCV setting for takeoff or extra power is fitted.
377     if (TakeoffBoost > RatedBoost[0]) {
378       // Assume that the effect on the BCV is the same whichever speed is in use.
379       TakeoffMAP[i] = RatedMAP[i] + ((TakeoffBoost - RatedBoost[0]) * 6895);
380       bTakeoffBoost = true;
381     } else {
382       TakeoffMAP[i] = RatedMAP[i];
383       bTakeoffBoost = false;
384     }
385     BoostMul[i] = RatedMAP[i] / (GetStdPressure100K(RatedAltitude[i]) * psftopa);
386
387   }
388
389   if (BoostSpeeds > 0) {
390     Boosted = true;
391     BoostSpeed = 0;
392   }
393   bBoostOverride = (BoostOverride == 1 ? true : false);
394   bBoostManual   = (BoostManual   == 1 ? true : false);
395   Debug(0); // Call Debug() routine from constructor if needed
396 }
397
398 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
399
400 FGPiston::~FGPiston()
401 {
402   delete Lookup_Combustion_Efficiency;
403   delete Mixture_Efficiency_Correlation;
404   Debug(1); // Call Debug() routine from constructor if needed
405 }
406
407 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
408
409 void FGPiston::ResetToIC(void)
410 {
411   FGEngine::ResetToIC();
412
413   ManifoldPressure_inHg = in.Pressure * psftoinhg; // psf to in Hg
414   MAP = in.Pressure * psftopa;
415   TMAP = MAP;
416   double airTemperature_degK = RankineToKelvin(in.Temperature);
417   OilTemp_degK = airTemperature_degK;
418   CylinderHeadTemp_degK = airTemperature_degK;
419   ExhaustGasTemp_degK = airTemperature_degK;
420   EGT_degC = ExhaustGasTemp_degK - 273;
421   Thruster->SetRPM(0.0);
422   RPM = 0.0;
423   OilPressure_psi = 0.0;
424 }
425
426 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
427
428 void FGPiston::Calculate(void)
429 {
430   // Input values.
431
432   p_amb = in.Pressure * psftopa;
433   double p = in.TotalPressure * psftopa;
434   p_ram = (p - p_amb) * Ram_Air_Factor + p_amb;
435   T_amb = RankineToKelvin(in.Temperature);
436
437   RunPreFunctions();
438
439   RPM = Thruster->GetRPM() * Thruster->GetGearRatio();
440   MeanPistonSpeed_fps =  ( RPM * Stroke) / (360); // AKA 2 * (RPM/60) * ( Stroke / 12) or 2NS
441
442   IAS = in.Vc;
443
444   doEngineStartup();
445   if (Boosted) doBoostControl();
446   doMAP();
447   doAirFlow();
448   doFuelFlow();
449
450   //Now that the fuel flow is done check if the mixture is too lean to run the engine
451   //Assume lean limit at 22 AFR for now - thats a thi of 0.668
452   //This might be a bit generous, but since there's currently no audiable warning of impending
453   //cutout in the form of misfiring and/or rough running its probably reasonable for now.
454
455   //  if (equivalence_ratio < 0.668)
456   //    Running = false;
457
458   doEnginePower();
459   if (IndicatedHorsePower < 0.1250) Running = false;
460
461   doEGT();
462   doCHT();
463   doOilTemperature();
464   doOilPressure();
465
466   if (Thruster->GetType() == FGThruster::ttPropeller) {
467     ((FGPropeller*)Thruster)->SetAdvance(in.PropAdvance[EngineNumber]);
468     ((FGPropeller*)Thruster)->SetFeather(in.PropFeather[EngineNumber]);
469   }
470
471   LoadThrusterInputs();
472   Thruster->Calculate(HP * hptoftlbssec);
473
474   RunPostFunctions();
475 }
476
477 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
478
479 double FGPiston::CalcFuelNeed(void)
480 {
481   FuelExpended = FuelFlowRate * in.TotalDeltaT;
482   return FuelExpended;
483 }
484
485 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
486
487 int FGPiston::InitRunning(void)
488 {
489   Magnetos=3;
490   in.MixtureCmd[EngineNumber] = in.PressureRatio/1.3;
491   in.MixturePos[EngineNumber] = in.PressureRatio/1.3;
492   Thruster->SetRPM( 2.0*IdleRPM/Thruster->GetGearRatio() );
493   Running = true;
494   return 1;
495 }
496
497 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
498 /**
499  * Start or stop the engine.
500  */
501
502 void FGPiston::doEngineStartup(void)
503 {
504   // Check parameters that may alter the operating state of the engine.
505   // (spark, fuel, starter motor etc)
506   bool spark;
507   bool fuel;
508   // Check for spark
509   Magneto_Left = false;
510   Magneto_Right = false;
511   // Magneto positions:
512   // 0 -> off
513   // 1 -> left only
514   // 2 -> right only
515   // 3 -> both
516   if (Magnetos != 0) {
517     spark = true;
518   } else {
519     spark = false;
520   }  // neglects battery voltage, master on switch, etc for now.
521
522   if ((Magnetos == 1) || (Magnetos > 2)) Magneto_Left = true;
523   if (Magnetos > 1)  Magneto_Right = true;
524
525   // Assume we have fuel for now
526   fuel = !Starved;
527
528   // Check if we are turning the starter motor
529   if (Cranking != Starter) {
530     // This check saves .../cranking from getting updated every loop - they
531     // only update when changed.
532     Cranking = Starter;
533     crank_counter = 0;
534   }
535
536   if (Cranking) crank_counter++;  //Check mode of engine operation
537
538   if (!Running && spark && fuel) {  // start the engine if revs high enough
539     if (Cranking) {
540       if ((RPM > IdleRPM*0.8) && (crank_counter > 175)) // Add a little delay to startup
541         Running = true;                         // on the starter
542     } else {
543       if (RPM > IdleRPM*0.8)                            // This allows us to in-air start
544         Running = true;                         // when windmilling
545     }
546   }
547
548   // Cut the engine *power* - Note: the engine may continue to
549   // spin if the prop is in a moving airstream
550
551   if ( Running && (!spark || !fuel) ) Running = false;
552
553   // Check for stalling (RPM = 0).
554   if (Running) {
555     if (RPM == 0) {
556       Running = false;
557     } else if ((RPM <= IdleRPM *0.8 ) && (Cranking)) {
558       Running = false;
559     }
560   }
561 }
562
563 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
564
565 /**
566  * Calculate the Current Boost Speed
567  *
568  * This function calculates the current turbo/supercharger boost speed
569  * based on altitude and the (automatic) boost-speed control valve configuration.
570  *
571  * Inputs: p_amb, BoostSwitchPressure, BoostSwitchHysteresis
572  *
573  * Outputs: BoostSpeed
574  */
575
576 void FGPiston::doBoostControl(void)
577 {
578   if(BoostManual) {
579     if(BoostSpeed > BoostSpeeds-1) BoostSpeed = BoostSpeeds-1;
580     if(BoostSpeed < 0) BoostSpeed = 0;
581   } else {
582     if(BoostSpeed < BoostSpeeds - 1) {
583       // Check if we need to change to a higher boost speed
584       if(p_amb < BoostSwitchPressure[BoostSpeed] - BoostSwitchHysteresis) {
585         BoostSpeed++;
586       }
587     } if(BoostSpeed > 0) {
588       // Check if we need to change to a lower boost speed
589       if(p_amb > BoostSwitchPressure[BoostSpeed - 1] + BoostSwitchHysteresis) {
590         BoostSpeed--;
591       }
592     }
593   }
594 }
595
596 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
597
598 /**
599  * Calculate the manifold absolute pressure (MAP) in inches hg
600  *
601  * This function calculates manifold absolute pressure (MAP)
602  * from the throttle position, turbo/supercharger boost control
603  * system, engine speed and local ambient air density.
604  *
605  * Inputs: p_amb, Throttle,
606  *         MeanPistonSpeed_fps, dt
607  *
608  * Outputs: MAP, ManifoldPressure_inHg, TMAP
609  */
610
611 void FGPiston::doMAP(void)
612 {
613   double Zt = (1 - in.ThrottlePos[EngineNumber])*(1 - in.ThrottlePos[EngineNumber])*Z_throttle; // throttle impedence
614   double Ze= MeanPistonSpeed_fps > 0 ? PeakMeanPistonSpeed_fps/MeanPistonSpeed_fps : 999999; // engine impedence
615
616   double map_coefficient = Ze/(Ze+Z_airbox+Zt);
617
618   // Add a one second lag to manifold pressure changes
619   double dMAP=0;
620   if (in.TotalDeltaT > 0.0) 
621     dMAP = (TMAP - p_ram * map_coefficient) * in.TotalDeltaT;
622   else 
623     dMAP = (TMAP - p_ram * map_coefficient) / 120;
624
625   TMAP -=dMAP;
626
627   // Find the mean effective pressure required to achieve this manifold pressure
628   // Fixme: determine the HP consumed by the supercharger
629
630   PMEP = (TMAP - p_amb) * volumetric_efficiency; // Fixme: p_amb should be exhaust manifold pressure
631
632   if (Boosted) {
633     // If takeoff boost is fitted, we currently assume the following throttle map:
634     // (In throttle % - actual input is 0 -> 1)
635     // 99 / 100 - Takeoff boost
636     // In real life, most planes would be fitted with a mechanical 'gate' between
637     // the rated boost and takeoff boost positions.
638
639     bool bTakeoffPos = false;
640     if (bTakeoffBoost) {
641       if (in.ThrottlePos[EngineNumber] > 0.98) {
642         bTakeoffPos = true;
643       }
644     }
645     // Boost the manifold pressure.
646     double boost_factor = (( BoostMul[BoostSpeed] - 1 ) / RatedRPM[BoostSpeed] ) * RPM + 1;
647     MAP = TMAP * boost_factor;
648     // Now clip the manifold pressure to BCV or Wastegate setting.
649     if (bTakeoffPos) {
650       if (MAP > TakeoffMAP[BoostSpeed]) MAP = TakeoffMAP[BoostSpeed];
651     } else {
652       if (MAP > RatedMAP[BoostSpeed]) MAP = RatedMAP[BoostSpeed];
653     }
654   } else {
655       MAP = TMAP;
656   }
657
658   // And set the value in American units as well
659   ManifoldPressure_inHg = MAP / inhgtopa;
660 }
661
662 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
663 /**
664  * Calculate the air flow through the engine.
665  * Also calculates ambient air density
666  * (used in CHT calculation for air-cooled engines).
667  *
668  * Inputs: p_amb, R_air, T_amb, MAP, Displacement,
669  *   RPM, volumetric_efficiency,
670  *
671  * TODO: Model inlet manifold air temperature.
672  *
673  * Outputs: rho_air, m_dot_air
674  */
675
676 void FGPiston::doAirFlow(void)
677 {
678   double gamma = 1.3; // specific heat constants
679 // loss of volumentric efficiency due to difference between MAP and exhaust pressure
680 // Eq 6-10 from The Internal Combustion Engine - Charles Taylor Vol 1
681   double ve =((gamma-1)/gamma) +( CompressionRatio -(p_amb/MAP))/(gamma*( CompressionRatio - 1));
682
683   rho_air = p_amb / (R_air * T_amb);
684   double swept_volume = (displacement_SI * (RPM/60)) / 2;
685   double v_dot_air = swept_volume * volumetric_efficiency *ve;
686
687   double rho_air_manifold = MAP / (R_air * T_amb);
688   m_dot_air = v_dot_air * rho_air_manifold;
689
690 }
691
692 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
693 /**
694  * Calculate the fuel flow into the engine.
695  *
696  * Inputs: Mixture, thi_sea_level, p_amb, m_dot_air
697  *
698  * Outputs: equivalence_ratio, m_dot_fuel
699  */
700
701 void FGPiston::doFuelFlow(void)
702 {
703   double thi_sea_level = 1.3 * in.MixturePos[EngineNumber]; // Allows an AFR of infinity:1 to 11.3075:1
704   equivalence_ratio = thi_sea_level * 101325.0 / p_amb;
705 //  double AFR = 10+(12*(1-in.Mixture[EngineNumber]));// mixture 10:1 to 22:1
706 //  m_dot_fuel = m_dot_air / AFR;
707   m_dot_fuel = (m_dot_air * equivalence_ratio) / 14.7;
708   FuelFlowRate =  m_dot_fuel * 2.2046;  // kg to lb
709   if(Starved) // There is no fuel, so zero out the flows we've calculated so far
710   {
711     equivalence_ratio = 0.0;
712     FuelFlowRate = 0.0;
713     m_dot_fuel = 0.0;
714   }
715   FuelFlow_pph = FuelFlowRate  * 3600;  // seconds to hours
716   FuelFlow_gph = FuelFlow_pph / 6.0;    // Assumes 6 lbs / gallon
717 }
718
719 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
720 /**
721  * Calculate the power produced by the engine.
722  *
723  * Inputs: ManifoldPressure_inHg, p_amb, RPM, T_amb, ISFC,
724  *   Mixture_Efficiency_Correlation, Cycles, MaxHP, PMEP,
725  *   MeanPistonSpeed_fps
726  *
727  * Outputs: PctPower, HP, FMEP, IndicatedHorsePower
728  */
729
730 void FGPiston::doEnginePower(void)
731 {
732   IndicatedHorsePower = 0;
733   FMEP = 0;
734   if (Running) {
735     // FIXME: this needs to be generalized
736     double ME, percent_RPM, power;  // Convienience term for use in the calculations
737     ME = Mixture_Efficiency_Correlation->GetValue(m_dot_fuel/m_dot_air);
738
739     percent_RPM = RPM/MaxRPM;
740 // Guestimate engine friction losses from Figure 4.4 of "Engines: An Introduction", John Lumley
741     FMEP = (-FMEPDynamic * MeanPistonSpeed_fps * fttom - FMEPStatic);
742
743     power = 1;
744
745     if ( Magnetos != 3 ) power *= SparkFailDrop;
746
747
748     IndicatedHorsePower = (FuelFlow_pph / ISFC )* ME * power;
749
750   } else {
751     // Power output when the engine is not running
752     if (Cranking) {
753       if (RPM < 10) {
754         IndicatedHorsePower = StarterHP;
755       } else if (RPM < IdleRPM*0.8) {
756         IndicatedHorsePower = StarterHP + ((IdleRPM*0.8 - RPM) / 8.0);
757         // This is a guess - would be nice to find a proper starter moter torque curve
758       } else {
759         IndicatedHorsePower = StarterHP;
760       }
761     }
762   }
763
764   // Constant is (1/2) * 60 * 745.7
765   // (1/2) convert cycles, 60 minutes to seconds, 745.7 watts to hp.
766   double pumping_hp = ((PMEP + FMEP) * displacement_SI * RPM)/(Cycles*22371);
767
768   HP = IndicatedHorsePower + pumping_hp - StaticFriction_HP; //FIXME static friction should depend on oil temp and configuration
769 //  cout << "pumping_hp " <<pumping_hp << FMEP << PMEP <<endl;
770   PctPower = HP / MaxHP ;
771 //  cout << "Power = " << HP << "  RPM = " << RPM << "  Running = " << Running << "  Cranking = " << Cranking << endl;
772 }
773
774 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
775 /**
776  * Calculate the exhaust gas temperature.
777  *
778  * Inputs: equivalence_ratio, m_dot_fuel, calorific_value_fuel,
779  *   Cp_air, m_dot_air, Cp_fuel, m_dot_fuel, T_amb, PctPower
780  *
781  * Outputs: combustion_efficiency, ExhaustGasTemp_degK
782  */
783
784 void FGPiston::doEGT(void)
785 {
786   double delta_T_exhaust;
787   double enthalpy_exhaust;
788   double heat_capacity_exhaust;
789   double dEGTdt;
790
791   if ((Running) && (m_dot_air > 0.0)) {  // do the energy balance
792     combustion_efficiency = Lookup_Combustion_Efficiency->GetValue(equivalence_ratio);
793     enthalpy_exhaust = m_dot_fuel * calorific_value_fuel *
794                               combustion_efficiency * 0.30;
795     heat_capacity_exhaust = (Cp_air * m_dot_air) + (Cp_fuel * m_dot_fuel);
796     delta_T_exhaust = enthalpy_exhaust / heat_capacity_exhaust;
797     ExhaustGasTemp_degK = T_amb + delta_T_exhaust;
798   } else {  // Drop towards ambient - guess an appropriate time constant for now
799     combustion_efficiency = 0;
800     dEGTdt = (RankineToKelvin(in.Temperature) - ExhaustGasTemp_degK) / 100.0;
801     if (in.TotalDeltaT > 0.0)
802       delta_T_exhaust = dEGTdt * in.TotalDeltaT;
803     else
804       delta_T_exhaust = dEGTdt / 120;
805
806     ExhaustGasTemp_degK += delta_T_exhaust;
807   }
808 }
809
810 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
811 /**
812  * Calculate the cylinder head temperature.
813  *
814  * Inputs: T_amb, IAS, rho_air, m_dot_fuel, calorific_value_fuel,
815  *   combustion_efficiency, RPM, MaxRPM, Displacement, Cylinders
816  *
817  * Outputs: CylinderHeadTemp_degK
818  */
819
820 void FGPiston::doCHT(void)
821 {
822   double h1 = -95.0;
823   double h2 = -3.95;
824   double h3 = -140.0; // -0.05 * 2800 (default maxrpm)
825
826   double arbitary_area = Displacement/360.0;
827   double CpCylinderHead = 800.0;
828   double MassCylinderHead = CylinderHeadMass * Cylinders;
829
830   double temperature_difference = CylinderHeadTemp_degK - T_amb;
831   double v_apparent = IAS * Cooling_Factor;
832   double v_dot_cooling_air = arbitary_area * v_apparent;
833   double m_dot_cooling_air = v_dot_cooling_air * rho_air;
834   double dqdt_from_combustion =
835     m_dot_fuel * calorific_value_fuel * combustion_efficiency * 0.33;
836   double dqdt_forced = (h2 * m_dot_cooling_air * temperature_difference) +
837     (h3 * RPM * temperature_difference / MaxRPM);
838   double dqdt_free = h1 * temperature_difference * arbitary_area;
839   double dqdt_cylinder_head = dqdt_from_combustion + dqdt_forced + dqdt_free;
840
841   double HeatCapacityCylinderHead = CpCylinderHead * MassCylinderHead;
842
843   if (in.TotalDeltaT > 0.0)
844     CylinderHeadTemp_degK +=
845       (dqdt_cylinder_head / HeatCapacityCylinderHead) * in.TotalDeltaT;
846   else 
847     CylinderHeadTemp_degK +=
848       (dqdt_cylinder_head / HeatCapacityCylinderHead) / 120.0;
849 }
850
851 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
852 /**
853  * Calculate the oil temperature.
854  *
855  * Inputs: CylinderHeadTemp_degK, T_amb, OilPressure_psi.
856  *
857  * Outputs: OilTemp_degK
858  */
859
860 void FGPiston::doOilTemperature(void)
861 {
862   double target_oil_temp;        // Steady state oil temp at the current engine conditions
863   double time_constant;          // The time constant for the differential equation
864   double efficiency = 0.667;     // The aproximate oil cooling system efficiency // FIXME: may vary by engine
865
866 //  Target oil temp is interpolated between ambient temperature and Cylinder Head Tempurature
867 //  target_oil_temp = ( T_amb * efficiency ) + (CylinderHeadTemp_degK *(1-efficiency)) ;
868   target_oil_temp = CylinderHeadTemp_degK + efficiency * (T_amb - CylinderHeadTemp_degK) ;
869
870   if (OilPressure_psi > 5.0 ) {
871     time_constant = 5000 / OilPressure_psi; // Guess at a time constant for circulated oil.
872                                             // The higher the pressure the faster it reaches
873                                             // target temperature.  Oil pressure should be about
874                                             // 60 PSI yielding a TC of about 80.
875   } else {
876     time_constant = 1000;  // Time constant for engine-off; reflects the fact
877                            // that oil is no longer getting circulated
878   }
879
880   double dOilTempdt = (target_oil_temp - OilTemp_degK) / time_constant;
881
882   if (in.TotalDeltaT > 0.0)
883     OilTemp_degK += (dOilTempdt * in.TotalDeltaT);
884   else 
885     OilTemp_degK += (dOilTempdt / 120.0);
886 }
887
888 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
889 /**
890  * Calculate the oil pressure.
891  *
892  * Inputs: RPM, MaxRPM, OilTemp_degK
893  *
894  * Outputs: OilPressure_psi
895  */
896
897 void FGPiston::doOilPressure(void)
898 {
899   double Oil_Press_Relief_Valve = 60; // FIXME: may vary by engine
900   double Oil_Press_RPM_Max = MaxRPM * 0.75;    // 75% of max rpm FIXME: may vary by engine
901   double Design_Oil_Temp = 358;          // degK; FIXME: may vary by engine
902   double Oil_Viscosity_Index = 0.25;
903
904   OilPressure_psi = (Oil_Press_Relief_Valve / Oil_Press_RPM_Max) * RPM;
905
906   if (OilPressure_psi >= Oil_Press_Relief_Valve) {
907     OilPressure_psi = Oil_Press_Relief_Valve;
908   }
909
910   OilPressure_psi += (Design_Oil_Temp - OilTemp_degK) * Oil_Viscosity_Index * OilPressure_psi / Oil_Press_Relief_Valve;
911 }
912
913 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
914 //
915 // This is a local copy of the same function in FGStandardAtmosphere.
916
917 double FGPiston::GetStdPressure100K(double altitude) const
918 {
919   // Limit this equation to input altitudes of 100000 ft.
920   if (altitude > 100000.0) altitude = 100000.0;
921
922   double alt[5];
923   const double coef[5] = {  2116.217,
924                           -7.648932746E-2,
925                            1.0925498604E-6,
926                           -7.1135726027E-12,
927                            1.7470331356E-17 };
928
929   alt[0] = 1;
930   for (int pwr=1; pwr<=4; pwr++) alt[pwr] = alt[pwr-1]*altitude;
931
932   double press = 0.0;
933   for (int ctr=0; ctr<=4; ctr++) press += coef[ctr]*alt[ctr];
934   return press;
935 }
936
937 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
938
939 string FGPiston::GetEngineLabels(const string& delimiter)
940 {
941   std::ostringstream buf;
942
943   buf << Name << " Power Available (engine " << EngineNumber << " in ft-lbs/sec)" << delimiter
944       << Name << " HP (engine " << EngineNumber << ")" << delimiter
945       << Name << " equivalent ratio (engine " << EngineNumber << ")" << delimiter
946       << Name << " MAP (engine " << EngineNumber << " in inHg)" << delimiter
947       << Thruster->GetThrusterLabels(EngineNumber, delimiter);
948
949   return buf.str();
950 }
951
952 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
953
954 string FGPiston::GetEngineValues(const string& delimiter)
955 {
956   std::ostringstream buf;
957
958   buf << (HP * hptoftlbssec) << delimiter << HP << delimiter
959       << equivalence_ratio << delimiter << ManifoldPressure_inHg << delimiter
960       << Thruster->GetThrusterValues(EngineNumber, delimiter);
961
962   return buf.str();
963 }
964
965 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
966 //
967 //    The bitmasked value choices are as follows:
968 //    unset: In this case (the default) JSBSim would only print
969 //       out the normally expected messages, essentially echoing
970 //       the config files as they are read. If the environment
971 //       variable is not set, debug_lvl is set to 1 internally
972 //    0: This requests JSBSim not to output any messages
973 //       whatsoever.
974 //    1: This value explicity requests the normal JSBSim
975 //       startup messages
976 //    2: This value asks for a message to be printed out when
977 //       a class is instantiated
978 //    4: When this value is set, a message is displayed when a
979 //       FGModel object executes its Run() method
980 //    8: When this value is set, various runtime state variables
981 //       are printed out periodically
982 //    16: When set various parameters are sanity checked and
983 //       a message is printed out when they go out of bounds
984
985 void FGPiston::Debug(int from)
986 {
987   if (debug_lvl <= 0) return;
988
989   if (debug_lvl & 1) { // Standard console startup message output
990     if (from == 0) { // Constructor
991
992       cout << "\n    Engine Name: "         << Name << endl;
993       cout << "      MinManifoldPressure: " << MinManifoldPressure_inHg << endl;
994       cout << "      MaxManifoldPressure: " << MaxManifoldPressure_inHg << endl;
995       cout << "      MinMaP (Pa):         " << minMAP << endl;
996       cout << "      MaxMaP (Pa):         " << maxMAP << endl;
997       cout << "      Displacement: "        << Displacement             << endl;
998       cout << "      Bore: "                << Bore                     << endl;
999       cout << "      Stroke: "              << Stroke                   << endl;
1000       cout << "      Cylinders: "           << Cylinders                << endl;
1001       cout << "      Cylinders Head Mass: " <<CylinderHeadMass          << endl;
1002       cout << "      Compression Ratio: "   << CompressionRatio         << endl;
1003       cout << "      MaxHP: "               << MaxHP                    << endl;
1004       cout << "      Cycles: "              << Cycles                   << endl;
1005       cout << "      IdleRPM: "             << IdleRPM                  << endl;
1006       cout << "      MaxRPM: "              << MaxRPM                   << endl;
1007       cout << "      Throttle Constant: "   << Z_throttle               << endl;
1008       cout << "      ISFC: "                << ISFC                     << endl;
1009       cout << "      Volumetric Efficiency: " << volumetric_efficiency    << endl;
1010       cout << "      PeakMeanPistonSpeed_fps: " << PeakMeanPistonSpeed_fps << endl;
1011       cout << "      Intake Impedance Factor: " << Z_airbox << endl;
1012       cout << "      Dynamic FMEP Factor: " << FMEPDynamic << endl;
1013       cout << "      Static FMEP Factor: " << FMEPStatic << endl;
1014
1015       cout << endl;
1016       cout << "      Combustion Efficiency table:" << endl;
1017       Lookup_Combustion_Efficiency->Print();
1018       cout << endl;
1019
1020       cout << endl;
1021       cout << "      Mixture Efficiency Correlation table:" << endl;
1022       Mixture_Efficiency_Correlation->Print();
1023       cout << endl;
1024
1025     }
1026   }
1027   if (debug_lvl & 2 ) { // Instantiation/Destruction notification
1028     if (from == 0) cout << "Instantiated: FGPiston" << endl;
1029     if (from == 1) cout << "Destroyed:    FGPiston" << endl;
1030   }
1031   if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
1032   }
1033   if (debug_lvl & 8 ) { // Runtime state variables
1034   }
1035   if (debug_lvl & 16) { // Sanity checking
1036   }
1037   if (debug_lvl & 64) {
1038     if (from == 0) { // Constructor
1039       cout << IdSrc << endl;
1040       cout << IdHdr << endl;
1041     }
1042   }
1043 }
1044 } // namespace JSBSim