]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/propulsion/FGPiston.cpp
Merge branch 'next' into comm-subsystem
[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.67 2011/09/25 23:56:11 jentron 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 + "/oil-temperature-degF";
340   PropertyManager->Tie(property_name, this, &FGPiston::getOilTemp_degF);
341   property_name = base_property_name + "/oil-pressure-psi";
342   PropertyManager->Tie(property_name, this, &FGPiston::getOilPressure_psi);
343   property_name = base_property_name + "/egt-degF";
344   PropertyManager->Tie(property_name, this, &FGPiston::getExhaustGasTemp_degF);
345
346   // Set up and sanity-check the turbo/supercharging configuration based on the input values.
347   if (TakeoffBoost > RatedBoost[0]) bTakeoffBoost = true;
348   for (i=0; i<BoostSpeeds; ++i) {
349     bool bad = false;
350     if (RatedBoost[i] <= 0.0) bad = true;
351     if (RatedPower[i] <= 0.0) bad = true;
352     if (RatedAltitude[i] < 0.0) bad = true;  // 0.0 is deliberately allowed - this corresponds to unregulated supercharging.
353     if (i > 0 && RatedAltitude[i] < RatedAltitude[i - 1]) bad = true;
354     if (bad) {
355       // We can't recover from the above - don't use this supercharger speed.
356       BoostSpeeds--;
357       // TODO - put out a massive error message!
358       break;
359     }
360     // Now sanity-check stuff that is recoverable.
361     if (i < BoostSpeeds - 1) {
362       if (BoostSwitchAltitude[i] < RatedAltitude[i]) {
363         // TODO - put out an error message
364         // But we can also make a reasonable estimate, as below.
365         BoostSwitchAltitude[i] = RatedAltitude[i] + 1000;
366       }
367       BoostSwitchPressure[i] = GetStdPressure100K(BoostSwitchAltitude[i]) * psftopa;
368       //cout << "BoostSwitchAlt = " << BoostSwitchAltitude[i] << ", pressure = " << BoostSwitchPressure[i] << '\n';
369       // Assume there is some hysteresis on the supercharger gear switch, and guess the value for now
370       BoostSwitchHysteresis = 1000;
371     }
372     // Now work out the supercharger pressure multiplier of this speed from the rated boost and altitude.
373     RatedMAP[i] = standard_pressure + RatedBoost[i] * 6895;  // psi*6895 = Pa.
374     // Sometimes a separate BCV setting for takeoff or extra power is fitted.
375     if (TakeoffBoost > RatedBoost[0]) {
376       // Assume that the effect on the BCV is the same whichever speed is in use.
377       TakeoffMAP[i] = RatedMAP[i] + ((TakeoffBoost - RatedBoost[0]) * 6895);
378       bTakeoffBoost = true;
379     } else {
380       TakeoffMAP[i] = RatedMAP[i];
381       bTakeoffBoost = false;
382     }
383     BoostMul[i] = RatedMAP[i] / (GetStdPressure100K(RatedAltitude[i]) * psftopa);
384
385   }
386
387   if (BoostSpeeds > 0) {
388     Boosted = true;
389     BoostSpeed = 0;
390   }
391   bBoostOverride = (BoostOverride == 1 ? true : false);
392   bBoostManual   = (BoostManual   == 1 ? true : false);
393   Debug(0); // Call Debug() routine from constructor if needed
394 }
395
396 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
397
398 FGPiston::~FGPiston()
399 {
400   delete Lookup_Combustion_Efficiency;
401   delete Mixture_Efficiency_Correlation;
402   Debug(1); // Call Debug() routine from constructor if needed
403 }
404
405 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
406
407 void FGPiston::ResetToIC(void)
408 {
409   FGEngine::ResetToIC();
410
411   ManifoldPressure_inHg = in.Pressure * psftoinhg; // psf to in Hg
412   MAP = in.Pressure * psftopa;
413   TMAP = MAP;
414   double airTemperature_degK = RankineToKelvin(in.Temperature);
415   OilTemp_degK = airTemperature_degK;
416   CylinderHeadTemp_degK = airTemperature_degK;
417   ExhaustGasTemp_degK = airTemperature_degK;
418   EGT_degC = ExhaustGasTemp_degK - 273;
419   Thruster->SetRPM(0.0);
420   RPM = 0.0;
421   OilPressure_psi = 0.0;
422 }
423
424 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
425
426 void FGPiston::Calculate(void)
427 {
428   // Input values.
429
430   p_amb = in.Pressure * psftopa;
431   double p = in.TotalPressure * psftopa;
432   p_ram = (p - p_amb) * Ram_Air_Factor + p_amb;
433   T_amb = RankineToKelvin(in.Temperature);
434
435   RunPreFunctions();
436
437 /* The thruster controls the engine RPM because it encapsulates the gear ratio and other transmission variables */
438   RPM = Thruster->GetEngineRPM();
439
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   if (!Starved) FuelUsedLbs += FuelExpended; 
483   return FuelExpended;
484 }
485
486 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
487
488 int FGPiston::InitRunning(void)
489 {
490   Magnetos=3;
491   in.MixtureCmd[EngineNumber] = in.PressureRatio/1.3;
492   in.MixturePos[EngineNumber] = in.PressureRatio/1.3;
493   Thruster->SetRPM( 2.0*IdleRPM/Thruster->GetGearRatio() );
494   Running = true;
495   return 1;
496 }
497
498 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
499 /**
500  * Start or stop the engine.
501  */
502
503 void FGPiston::doEngineStartup(void)
504 {
505   // Check parameters that may alter the operating state of the engine.
506   // (spark, fuel, starter motor etc)
507   bool spark;
508   bool fuel;
509   // Check for spark
510   Magneto_Left = false;
511   Magneto_Right = false;
512   // Magneto positions:
513   // 0 -> off
514   // 1 -> left only
515   // 2 -> right only
516   // 3 -> both
517   if (Magnetos != 0) {
518     spark = true;
519   } else {
520     spark = false;
521   }  // neglects battery voltage, master on switch, etc for now.
522
523   if ((Magnetos == 1) || (Magnetos > 2)) Magneto_Left = true;
524   if (Magnetos > 1)  Magneto_Right = true;
525
526   // Assume we have fuel for now
527   fuel = !Starved;
528
529   // Check if we are turning the starter motor
530   if (Cranking != Starter) {
531     // This check saves .../cranking from getting updated every loop - they
532     // only update when changed.
533     Cranking = Starter;
534     crank_counter = 0;
535   }
536
537   if (Cranking) crank_counter++;  //Check mode of engine operation
538
539   if (!Running && spark && fuel) {  // start the engine if revs high enough
540     if (Cranking) {
541       if ((RPM > IdleRPM*0.8) && (crank_counter > 175)) // Add a little delay to startup
542         Running = true;                         // on the starter
543     } else {
544       if (RPM > IdleRPM*0.8)                            // This allows us to in-air start
545         Running = true;                         // when windmilling
546     }
547   }
548
549   // Cut the engine *power* - Note: the engine may continue to
550   // spin if the prop is in a moving airstream
551
552   if ( Running && (!spark || !fuel) ) Running = false;
553
554   // Check for stalling (RPM = 0).
555   if (Running) {
556     if (RPM == 0) {
557       Running = false;
558     } else if ((RPM <= IdleRPM *0.8 ) && (Cranking)) {
559       Running = false;
560     }
561   }
562 }
563
564 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
565
566 /**
567  * Calculate the Current Boost Speed
568  *
569  * This function calculates the current turbo/supercharger boost speed
570  * based on altitude and the (automatic) boost-speed control valve configuration.
571  *
572  * Inputs: p_amb, BoostSwitchPressure, BoostSwitchHysteresis
573  *
574  * Outputs: BoostSpeed
575  */
576
577 void FGPiston::doBoostControl(void)
578 {
579   if(BoostManual) {
580     if(BoostSpeed > BoostSpeeds-1) BoostSpeed = BoostSpeeds-1;
581     if(BoostSpeed < 0) BoostSpeed = 0;
582   } else {
583     if(BoostSpeed < BoostSpeeds - 1) {
584       // Check if we need to change to a higher boost speed
585       if(p_amb < BoostSwitchPressure[BoostSpeed] - BoostSwitchHysteresis) {
586         BoostSpeed++;
587       }
588     } if(BoostSpeed > 0) {
589       // Check if we need to change to a lower boost speed
590       if(p_amb > BoostSwitchPressure[BoostSpeed - 1] + BoostSwitchHysteresis) {
591         BoostSpeed--;
592       }
593     }
594   }
595 }
596
597 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
598
599 /**
600  * Calculate the manifold absolute pressure (MAP) in inches hg
601  *
602  * This function calculates manifold absolute pressure (MAP)
603  * from the throttle position, turbo/supercharger boost control
604  * system, engine speed and local ambient air density.
605  *
606  * Inputs: p_amb, Throttle,
607  *         MeanPistonSpeed_fps, dt
608  *
609  * Outputs: MAP, ManifoldPressure_inHg, TMAP
610  */
611
612 void FGPiston::doMAP(void)
613 {
614   double Zt = (1 - in.ThrottlePos[EngineNumber])*(1 - in.ThrottlePos[EngineNumber])*Z_throttle; // throttle impedence
615   double Ze= MeanPistonSpeed_fps > 0 ? PeakMeanPistonSpeed_fps/MeanPistonSpeed_fps : 999999; // engine impedence
616
617   double map_coefficient = Ze/(Ze+Z_airbox+Zt);
618
619   // Add a one second lag to manifold pressure changes
620   double dMAP=0;
621   if (in.TotalDeltaT > 0.0) 
622     dMAP = (TMAP - p_ram * map_coefficient) * in.TotalDeltaT;
623   else 
624     dMAP = (TMAP - p_ram * map_coefficient) / 120;
625
626   TMAP -=dMAP;
627
628   // Find the mean effective pressure required to achieve this manifold pressure
629   // Fixme: determine the HP consumed by the supercharger
630
631   PMEP = (TMAP - p_amb) * volumetric_efficiency; // Fixme: p_amb should be exhaust manifold pressure
632
633   if (Boosted) {
634     // If takeoff boost is fitted, we currently assume the following throttle map:
635     // (In throttle % - actual input is 0 -> 1)
636     // 99 / 100 - Takeoff boost
637     // In real life, most planes would be fitted with a mechanical 'gate' between
638     // the rated boost and takeoff boost positions.
639
640     bool bTakeoffPos = false;
641     if (bTakeoffBoost) {
642       if (in.ThrottlePos[EngineNumber] > 0.98) {
643         bTakeoffPos = true;
644       }
645     }
646     // Boost the manifold pressure.
647     double boost_factor = (( BoostMul[BoostSpeed] - 1 ) / RatedRPM[BoostSpeed] ) * RPM + 1;
648     MAP = TMAP * boost_factor;
649     // Now clip the manifold pressure to BCV or Wastegate setting.
650     if (bTakeoffPos) {
651       if (MAP > TakeoffMAP[BoostSpeed]) MAP = TakeoffMAP[BoostSpeed];
652     } else {
653       if (MAP > RatedMAP[BoostSpeed]) MAP = RatedMAP[BoostSpeed];
654     }
655   } else {
656       MAP = TMAP;
657   }
658
659   // And set the value in American units as well
660   ManifoldPressure_inHg = MAP / inhgtopa;
661 }
662
663 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
664 /**
665  * Calculate the air flow through the engine.
666  * Also calculates ambient air density
667  * (used in CHT calculation for air-cooled engines).
668  *
669  * Inputs: p_amb, R_air, T_amb, MAP, Displacement,
670  *   RPM, volumetric_efficiency,
671  *
672  * TODO: Model inlet manifold air temperature.
673  *
674  * Outputs: rho_air, m_dot_air
675  */
676
677 void FGPiston::doAirFlow(void)
678 {
679   double gamma = 1.3; // specific heat constants
680 // loss of volumentric efficiency due to difference between MAP and exhaust pressure
681 // Eq 6-10 from The Internal Combustion Engine - Charles Taylor Vol 1
682   double ve =((gamma-1)/gamma) +( CompressionRatio -(p_amb/MAP))/(gamma*( CompressionRatio - 1));
683
684   rho_air = p_amb / (R_air * T_amb);
685   double swept_volume = (displacement_SI * (RPM/60)) / 2;
686   double v_dot_air = swept_volume * volumetric_efficiency *ve;
687
688   double rho_air_manifold = MAP / (R_air * T_amb);
689   m_dot_air = v_dot_air * rho_air_manifold;
690
691 }
692
693 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
694 /**
695  * Calculate the fuel flow into the engine.
696  *
697  * Inputs: Mixture, thi_sea_level, p_amb, m_dot_air
698  *
699  * Outputs: equivalence_ratio, m_dot_fuel
700  */
701
702 void FGPiston::doFuelFlow(void)
703 {
704   double thi_sea_level = 1.3 * in.MixturePos[EngineNumber]; // Allows an AFR of infinity:1 to 11.3075:1
705   equivalence_ratio = thi_sea_level * 101325.0 / p_amb;
706 //  double AFR = 10+(12*(1-in.Mixture[EngineNumber]));// mixture 10:1 to 22:1
707 //  m_dot_fuel = m_dot_air / AFR;
708   m_dot_fuel = (m_dot_air * equivalence_ratio) / 14.7;
709   FuelFlowRate =  m_dot_fuel * 2.2046;  // kg to lb
710   if(Starved) // There is no fuel, so zero out the flows we've calculated so far
711   {
712     equivalence_ratio = 0.0;
713     FuelFlowRate = 0.0;
714     m_dot_fuel = 0.0;
715   }
716   FuelFlow_pph = FuelFlowRate  * 3600;  // seconds to hours
717   FuelFlow_gph = FuelFlow_pph / 6.0;    // Assumes 6 lbs / gallon
718 }
719
720 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
721 /**
722  * Calculate the power produced by the engine.
723  *
724  * Inputs: ManifoldPressure_inHg, p_amb, RPM, T_amb, ISFC,
725  *   Mixture_Efficiency_Correlation, Cycles, MaxHP, PMEP,
726  *   MeanPistonSpeed_fps
727  *
728  * Outputs: PctPower, HP, FMEP, IndicatedHorsePower
729  */
730
731 void FGPiston::doEnginePower(void)
732 {
733   IndicatedHorsePower = 0;
734   FMEP = 0;
735   if (Running) {
736     // FIXME: this needs to be generalized
737     double ME, percent_RPM, power;  // Convienience term for use in the calculations
738     ME = Mixture_Efficiency_Correlation->GetValue(m_dot_fuel/m_dot_air);
739
740     percent_RPM = RPM/MaxRPM;
741 // Guestimate engine friction losses from Figure 4.4 of "Engines: An Introduction", John Lumley
742     FMEP = (-FMEPDynamic * MeanPistonSpeed_fps * fttom - FMEPStatic);
743
744     power = 1;
745
746     if ( Magnetos != 3 ) power *= SparkFailDrop;
747
748
749     IndicatedHorsePower = (FuelFlow_pph / ISFC )* ME * power;
750
751   } else {
752     // Power output when the engine is not running
753     if (Cranking) {
754       if (RPM < 10) {
755         IndicatedHorsePower = StarterHP;
756       } else if (RPM < IdleRPM*0.8) {
757         IndicatedHorsePower = StarterHP + ((IdleRPM*0.8 - RPM) / 8.0);
758         // This is a guess - would be nice to find a proper starter moter torque curve
759       } else {
760         IndicatedHorsePower = StarterHP;
761       }
762     }
763   }
764
765   // Constant is (1/2) * 60 * 745.7
766   // (1/2) convert cycles, 60 minutes to seconds, 745.7 watts to hp.
767   double pumping_hp = ((PMEP + FMEP) * displacement_SI * RPM)/(Cycles*22371);
768
769   HP = IndicatedHorsePower + pumping_hp - StaticFriction_HP; //FIXME static friction should depend on oil temp and configuration
770 //  cout << "pumping_hp " <<pumping_hp << FMEP << PMEP <<endl;
771   PctPower = HP / MaxHP ;
772 //  cout << "Power = " << HP << "  RPM = " << RPM << "  Running = " << Running << "  Cranking = " << Cranking << endl;
773 }
774
775 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
776 /**
777  * Calculate the exhaust gas temperature.
778  *
779  * Inputs: equivalence_ratio, m_dot_fuel, calorific_value_fuel,
780  *   Cp_air, m_dot_air, Cp_fuel, m_dot_fuel, T_amb, PctPower
781  *
782  * Outputs: combustion_efficiency, ExhaustGasTemp_degK
783  */
784
785 void FGPiston::doEGT(void)
786 {
787   double delta_T_exhaust;
788   double enthalpy_exhaust;
789   double heat_capacity_exhaust;
790   double dEGTdt;
791
792   if ((Running) && (m_dot_air > 0.0)) {  // do the energy balance
793     combustion_efficiency = Lookup_Combustion_Efficiency->GetValue(equivalence_ratio);
794     enthalpy_exhaust = m_dot_fuel * calorific_value_fuel *
795                               combustion_efficiency * 0.30;
796     heat_capacity_exhaust = (Cp_air * m_dot_air) + (Cp_fuel * m_dot_fuel);
797     delta_T_exhaust = enthalpy_exhaust / heat_capacity_exhaust;
798     ExhaustGasTemp_degK = T_amb + delta_T_exhaust;
799   } else {  // Drop towards ambient - guess an appropriate time constant for now
800     combustion_efficiency = 0;
801     dEGTdt = (RankineToKelvin(in.Temperature) - ExhaustGasTemp_degK) / 100.0;
802     if (in.TotalDeltaT > 0.0)
803       delta_T_exhaust = dEGTdt * in.TotalDeltaT;
804     else
805       delta_T_exhaust = dEGTdt / 120;
806
807     ExhaustGasTemp_degK += delta_T_exhaust;
808   }
809 }
810
811 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
812 /**
813  * Calculate the cylinder head temperature.
814  *
815  * Inputs: T_amb, IAS, rho_air, m_dot_fuel, calorific_value_fuel,
816  *   combustion_efficiency, RPM, MaxRPM, Displacement, Cylinders
817  *
818  * Outputs: CylinderHeadTemp_degK
819  */
820
821 void FGPiston::doCHT(void)
822 {
823   double h1 = -95.0;
824   double h2 = -3.95;
825   double h3 = -140.0; // -0.05 * 2800 (default maxrpm)
826
827   double arbitary_area = Displacement/360.0;
828   double CpCylinderHead = 800.0;
829   double MassCylinderHead = CylinderHeadMass * Cylinders;
830
831   double temperature_difference = CylinderHeadTemp_degK - T_amb;
832   double v_apparent = IAS * Cooling_Factor;
833   double v_dot_cooling_air = arbitary_area * v_apparent;
834   double m_dot_cooling_air = v_dot_cooling_air * rho_air;
835   double dqdt_from_combustion =
836     m_dot_fuel * calorific_value_fuel * combustion_efficiency * 0.33;
837   double dqdt_forced = (h2 * m_dot_cooling_air * temperature_difference) +
838     (h3 * RPM * temperature_difference / MaxRPM);
839   double dqdt_free = h1 * temperature_difference * arbitary_area;
840   double dqdt_cylinder_head = dqdt_from_combustion + dqdt_forced + dqdt_free;
841
842   double HeatCapacityCylinderHead = CpCylinderHead * MassCylinderHead;
843
844   if (in.TotalDeltaT > 0.0)
845     CylinderHeadTemp_degK +=
846       (dqdt_cylinder_head / HeatCapacityCylinderHead) * in.TotalDeltaT;
847   else 
848     CylinderHeadTemp_degK +=
849       (dqdt_cylinder_head / HeatCapacityCylinderHead) / 120.0;
850 }
851
852 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
853 /**
854  * Calculate the oil temperature.
855  *
856  * Inputs: CylinderHeadTemp_degK, T_amb, OilPressure_psi.
857  *
858  * Outputs: OilTemp_degK
859  */
860
861 void FGPiston::doOilTemperature(void)
862 {
863   double target_oil_temp;        // Steady state oil temp at the current engine conditions
864   double time_constant;          // The time constant for the differential equation
865   double efficiency = 0.667;     // The aproximate oil cooling system efficiency // FIXME: may vary by engine
866
867 //  Target oil temp is interpolated between ambient temperature and Cylinder Head Tempurature
868 //  target_oil_temp = ( T_amb * efficiency ) + (CylinderHeadTemp_degK *(1-efficiency)) ;
869   target_oil_temp = CylinderHeadTemp_degK + efficiency * (T_amb - CylinderHeadTemp_degK) ;
870
871   if (OilPressure_psi > 5.0 ) {
872     time_constant = 5000 / OilPressure_psi; // Guess at a time constant for circulated oil.
873                                             // The higher the pressure the faster it reaches
874                                             // target temperature.  Oil pressure should be about
875                                             // 60 PSI yielding a TC of about 80.
876   } else {
877     time_constant = 1000;  // Time constant for engine-off; reflects the fact
878                            // that oil is no longer getting circulated
879   }
880
881   double dOilTempdt = (target_oil_temp - OilTemp_degK) / time_constant;
882
883   if (in.TotalDeltaT > 0.0)
884     OilTemp_degK += (dOilTempdt * in.TotalDeltaT);
885   else 
886     OilTemp_degK += (dOilTempdt / 120.0);
887 }
888
889 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
890 /**
891  * Calculate the oil pressure.
892  *
893  * Inputs: RPM, MaxRPM, OilTemp_degK
894  *
895  * Outputs: OilPressure_psi
896  */
897
898 void FGPiston::doOilPressure(void)
899 {
900   double Oil_Press_Relief_Valve = 60; // FIXME: may vary by engine
901   double Oil_Press_RPM_Max = MaxRPM * 0.75;    // 75% of max rpm FIXME: may vary by engine
902   double Design_Oil_Temp = 358;          // degK; FIXME: may vary by engine
903   double Oil_Viscosity_Index = 0.25;
904
905   OilPressure_psi = (Oil_Press_Relief_Valve / Oil_Press_RPM_Max) * RPM;
906
907   if (OilPressure_psi >= Oil_Press_Relief_Valve) {
908     OilPressure_psi = Oil_Press_Relief_Valve;
909   }
910
911   OilPressure_psi += (Design_Oil_Temp - OilTemp_degK) * Oil_Viscosity_Index * OilPressure_psi / Oil_Press_Relief_Valve;
912 }
913
914 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
915 //
916 // This is a local copy of the same function in FGStandardAtmosphere.
917
918 double FGPiston::GetStdPressure100K(double altitude) const
919 {
920   // Limit this equation to input altitudes of 100000 ft.
921   if (altitude > 100000.0) altitude = 100000.0;
922
923   double alt[5];
924   const double coef[5] = {  2116.217,
925                           -7.648932746E-2,
926                            1.0925498604E-6,
927                           -7.1135726027E-12,
928                            1.7470331356E-17 };
929
930   alt[0] = 1;
931   for (int pwr=1; pwr<=4; pwr++) alt[pwr] = alt[pwr-1]*altitude;
932
933   double press = 0.0;
934   for (int ctr=0; ctr<=4; ctr++) press += coef[ctr]*alt[ctr];
935   return press;
936 }
937
938 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
939
940 string FGPiston::GetEngineLabels(const string& delimiter)
941 {
942   std::ostringstream buf;
943
944   buf << Name << " Power Available (engine " << EngineNumber << " in ft-lbs/sec)" << delimiter
945       << Name << " HP (engine " << EngineNumber << ")" << delimiter
946       << Name << " equivalent ratio (engine " << EngineNumber << ")" << delimiter
947       << Name << " MAP (engine " << EngineNumber << " in inHg)" << delimiter
948       << Thruster->GetThrusterLabels(EngineNumber, delimiter);
949
950   return buf.str();
951 }
952
953 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
954
955 string FGPiston::GetEngineValues(const string& delimiter)
956 {
957   std::ostringstream buf;
958
959   buf << (HP * hptoftlbssec) << delimiter << HP << delimiter
960       << equivalence_ratio << delimiter << ManifoldPressure_inHg << delimiter
961       << Thruster->GetThrusterValues(EngineNumber, delimiter);
962
963   return buf.str();
964 }
965
966 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
967 //
968 //    The bitmasked value choices are as follows:
969 //    unset: In this case (the default) JSBSim would only print
970 //       out the normally expected messages, essentially echoing
971 //       the config files as they are read. If the environment
972 //       variable is not set, debug_lvl is set to 1 internally
973 //    0: This requests JSBSim not to output any messages
974 //       whatsoever.
975 //    1: This value explicity requests the normal JSBSim
976 //       startup messages
977 //    2: This value asks for a message to be printed out when
978 //       a class is instantiated
979 //    4: When this value is set, a message is displayed when a
980 //       FGModel object executes its Run() method
981 //    8: When this value is set, various runtime state variables
982 //       are printed out periodically
983 //    16: When set various parameters are sanity checked and
984 //       a message is printed out when they go out of bounds
985
986 void FGPiston::Debug(int from)
987 {
988   if (debug_lvl <= 0) return;
989
990   if (debug_lvl & 1) { // Standard console startup message output
991     if (from == 0) { // Constructor
992
993       cout << "\n    Engine Name: "         << Name << endl;
994       cout << "      MinManifoldPressure: " << MinManifoldPressure_inHg << endl;
995       cout << "      MaxManifoldPressure: " << MaxManifoldPressure_inHg << endl;
996       cout << "      MinMaP (Pa):         " << minMAP << endl;
997       cout << "      MaxMaP (Pa):         " << maxMAP << endl;
998       cout << "      Displacement: "        << Displacement             << endl;
999       cout << "      Bore: "                << Bore                     << endl;
1000       cout << "      Stroke: "              << Stroke                   << endl;
1001       cout << "      Cylinders: "           << Cylinders                << endl;
1002       cout << "      Cylinders Head Mass: " <<CylinderHeadMass          << endl;
1003       cout << "      Compression Ratio: "   << CompressionRatio         << endl;
1004       cout << "      MaxHP: "               << MaxHP                    << endl;
1005       cout << "      Cycles: "              << Cycles                   << endl;
1006       cout << "      IdleRPM: "             << IdleRPM                  << endl;
1007       cout << "      MaxRPM: "              << MaxRPM                   << endl;
1008       cout << "      Throttle Constant: "   << Z_throttle               << endl;
1009       cout << "      ISFC: "                << ISFC                     << endl;
1010       cout << "      Volumetric Efficiency: " << volumetric_efficiency    << endl;
1011       cout << "      PeakMeanPistonSpeed_fps: " << PeakMeanPistonSpeed_fps << endl;
1012       cout << "      Intake Impedance Factor: " << Z_airbox << endl;
1013       cout << "      Dynamic FMEP Factor: " << FMEPDynamic << endl;
1014       cout << "      Static FMEP Factor: " << FMEPStatic << endl;
1015
1016       cout << endl;
1017       cout << "      Combustion Efficiency table:" << endl;
1018       Lookup_Combustion_Efficiency->Print();
1019       cout << endl;
1020
1021       cout << endl;
1022       cout << "      Mixture Efficiency Correlation table:" << endl;
1023       Mixture_Efficiency_Correlation->Print();
1024       cout << endl;
1025
1026     }
1027   }
1028   if (debug_lvl & 2 ) { // Instantiation/Destruction notification
1029     if (from == 0) cout << "Instantiated: FGPiston" << endl;
1030     if (from == 1) cout << "Destroyed:    FGPiston" << endl;
1031   }
1032   if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
1033   }
1034   if (debug_lvl & 8 ) { // Runtime state variables
1035   }
1036   if (debug_lvl & 16) { // Sanity checking
1037   }
1038   if (debug_lvl & 64) {
1039     if (from == 0) { // Constructor
1040       cout << IdSrc << endl;
1041       cout << IdHdr << endl;
1042     }
1043   }
1044 }
1045 } // namespace JSBSim