]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGPiston.cpp
JSBSim updates. This update changes the file format, so an update of the base
[flightgear.git] / src / FDM / JSBSim / FGPiston.cpp
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3  Module:       FGPiston.cpp
4  Author:       Jon S. Berndt, JSBSim framework
5                Dave Luff, Piston engine model
6  Date started: 09/12/2000
7  Purpose:      This module models a Piston engine
8
9  ------------- Copyright (C) 2000  Jon S. Berndt (jsb@hal-pc.org) --------------
10
11  This program is free software; you can redistribute it and/or modify it under
12  the terms of the GNU General Public License as published by the Free Software
13  Foundation; either version 2 of the License, or (at your option) any later
14  version.
15
16  This program is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
19  details.
20
21  You should have received a copy of the GNU General Public License along with
22  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
23  Place - Suite 330, Boston, MA  02111-1307, USA.
24
25  Further information about the GNU General Public License can also be found on
26  the world wide web at http://www.gnu.org.
27
28 FUNCTIONAL DESCRIPTION
29 --------------------------------------------------------------------------------
30
31 This class descends from the FGEngine class and models a Piston engine based on
32 parameters given in the engine config file for this class
33
34 HISTORY
35 --------------------------------------------------------------------------------
36 09/12/2000  JSB  Created
37
38 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39 INCLUDES
40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
41
42 #include "FGPiston.h"
43 #include "FGPropulsion.h"
44
45 static const char *IdSrc = "$Id$";
46 static const char *IdHdr = ID_PISTON;
47
48 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
49 CLASS IMPLEMENTATION
50 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
51
52 FGPiston::FGPiston(FGFDMExec* exec, FGConfigFile* Eng_cfg) : FGEngine(exec),
53   R_air(287.3),
54   rho_fuel(800),                 // estimate
55   calorific_value_fuel(47.3e6),
56   Cp_air(1005),
57   Cp_fuel(1700)
58 {
59   string token;
60
61   MinManifoldPressure_inHg = 6.5;
62   MaxManifoldPressure_inHg = 28.5;
63   Displacement = 360;
64   MaxHP = 200;
65   Cycles = 2;
66   IdleRPM = 600;
67
68   Name = Eng_cfg->GetValue("NAME");
69   Eng_cfg->GetNextConfigLine();
70   while (Eng_cfg->GetValue() != string("/FG_PISTON")) {
71     *Eng_cfg >> token;
72     if      (token == "MINMP") *Eng_cfg >> MinManifoldPressure_inHg;
73     else if (token == "MAXMP") *Eng_cfg >> MaxManifoldPressure_inHg;
74     else if (token == "DISPLACEMENT") *Eng_cfg >> Displacement;
75     else if (token == "MAXHP") *Eng_cfg >> MaxHP;
76     else if (token == "CYCLES") *Eng_cfg >> Cycles;
77     else if (token == "IDLERPM") *Eng_cfg >> IdleRPM;
78     else if (token == "MAXTHROTTLE") *Eng_cfg >> MaxThrottle;
79     else if (token == "MINTHROTTLE") *Eng_cfg >> MinThrottle;
80     else cerr << "Unhandled token in Engine config file: " << token << endl;
81   }
82
83   Type = etPiston;
84   crank_counter = 0;
85   EngineNumber = 0;
86   OilTemp_degK = 298;
87   ManifoldPressure_inHg = Atmosphere->GetPressure() * psftoinhg; // psf to in Hg
88
89   dt = State->Getdt();
90
91   // Initialisation
92   volumetric_efficiency = 0.8;  // Actually f(speed, load) but this will get us running
93
94   // First column is thi, second is neta (combustion efficiency)
95   Lookup_Combustion_Efficiency = new FGTable(12);
96   *Lookup_Combustion_Efficiency << 0.00 << 0.980;
97   *Lookup_Combustion_Efficiency << 0.90 << 0.980;
98   *Lookup_Combustion_Efficiency << 1.00 << 0.970;
99   *Lookup_Combustion_Efficiency << 1.05 << 0.950;
100   *Lookup_Combustion_Efficiency << 1.10 << 0.900;
101   *Lookup_Combustion_Efficiency << 1.15 << 0.850;
102   *Lookup_Combustion_Efficiency << 1.20 << 0.790;
103   *Lookup_Combustion_Efficiency << 1.30 << 0.700;
104   *Lookup_Combustion_Efficiency << 1.40 << 0.630;
105   *Lookup_Combustion_Efficiency << 1.50 << 0.570;
106   *Lookup_Combustion_Efficiency << 1.60 << 0.525;
107   *Lookup_Combustion_Efficiency << 2.00 << 0.345;
108
109   Power_Mixture_Correlation = new FGTable(13);
110   *Power_Mixture_Correlation << (14.7/1.6) << 78.0;
111   *Power_Mixture_Correlation << 10 <<  86.0;
112   *Power_Mixture_Correlation << 11 <<  93.5;
113   *Power_Mixture_Correlation << 12 <<  98.0;
114   *Power_Mixture_Correlation << 13 << 100.0;
115   *Power_Mixture_Correlation << 14 <<  99.0;
116   *Power_Mixture_Correlation << 15 <<  96.4;
117   *Power_Mixture_Correlation << 16 <<  92.5;
118   *Power_Mixture_Correlation << 17 <<  88.0;
119   *Power_Mixture_Correlation << 18 <<  83.0;
120   *Power_Mixture_Correlation << 19 <<  78.5;
121   *Power_Mixture_Correlation << 20 <<  74.0;
122   *Power_Mixture_Correlation << (14.7/0.6) << 58;
123
124   Debug(0); // Call Debug() routine from constructor if needed
125 }
126
127 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
128
129 FGPiston::~FGPiston()
130 {
131   Debug(1); // Call Debug() routine from constructor if needed
132 }
133
134 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
135
136 double FGPiston::Calculate(double PowerRequired)
137 {
138   ConsumeFuel();
139
140   Throttle = FCS->GetThrottlePos(EngineNumber);
141   Mixture = FCS->GetMixturePos(EngineNumber);
142
143   //
144   // Input values.
145   //
146
147   p_amb = Atmosphere->GetPressure() * 48;              // convert from lbs/ft2 to Pa
148   p_amb_sea_level = Atmosphere->GetPressureSL() * 48;
149   T_amb = Atmosphere->GetTemperature() * (5.0 / 9.0);  // convert from Rankine to Kelvin
150
151   RPM = Propulsion->GetThruster(EngineNumber)->GetRPM();
152     
153   IAS = Auxiliary->GetVcalibratedKTS();
154
155     doEngineStartup();
156     doManifoldPressure();
157     doAirFlow();
158     doFuelFlow();
159
160   //Now that the fuel flow is done check if the mixture is too lean to run the engine
161   //Assume lean limit at 22 AFR for now - thats a thi of 0.668
162   //This might be a bit generous, but since there's currently no audiable warning of impending
163   //cutout in the form of misfiring and/or rough running its probably reasonable for now.
164   if (equivalence_ratio < 0.668)
165     Running = false;
166
167   doEnginePower();
168     doEGT();
169     doCHT();
170     doOilTemperature();
171     doOilPressure();
172
173   PowerAvailable = (HP * hptoftlbssec) - PowerRequired;
174   return PowerAvailable;
175 }
176
177 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
178 /**
179  * Start or stop the engine.
180  */
181
182 void FGPiston::doEngineStartup(void)
183 {
184   // Check parameters that may alter the operating state of the engine. 
185   // (spark, fuel, starter motor etc)
186   bool spark;
187   bool fuel;
188
189   // Check for spark
190   Magneto_Left = false;
191   Magneto_Right = false;
192   // Magneto positions:
193   // 0 -> off
194   // 1 -> left only
195   // 2 -> right only
196   // 3 -> both
197   if (Magnetos != 0) {
198     spark = true;
199   } else {
200     spark = false;
201   }  // neglects battery voltage, master on switch, etc for now.
202   
203   if ((Magnetos == 1) || (Magnetos > 2)) Magneto_Left = true;
204   if (Magnetos > 1)  Magneto_Right = true;
205
206   // Assume we have fuel for now
207   fuel = !Starved;
208
209   // Check if we are turning the starter motor
210   if (Cranking != Starter) {
211     // This check saves .../cranking from getting updated every loop - they
212     // only update when changed.
213     Cranking = Starter;
214     crank_counter = 0;
215   }
216
217   if (Cranking) crank_counter++;  //Check mode of engine operation
218   
219   if (!Running && spark && fuel) {  // start the engine if revs high enough
220     if (Cranking) {
221       if ((RPM > 450) && (crank_counter > 175)) // Add a little delay to startup
222         Running = true;                         // on the starter
223     } else {
224       if (RPM > 450)                            // This allows us to in-air start
225         Running = true;                         // when windmilling
226     }
227   }
228
229   // Cut the engine *power* - Note: the engine may continue to
230   // spin if the prop is in a moving airstream
231
232   if ( Running && (!spark || !fuel) ) Running = false;
233
234   // Check for stalling (RPM = 0).
235   if (Running) { 
236     if (RPM == 0) {
237       Running = false;
238     } else if ((RPM <= 480) && (Cranking)) {
239       Running = false;
240     }
241   }
242 }
243
244 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
245
246 /**
247  * Calculate the nominal manifold pressure in inches hg
248  *
249  * This function calculates nominal manifold pressure directly
250  * from the throttle position, and does not adjust it for the
251  * difference between the pressure at sea level and the pressure
252  * at the current altitude (that adjustment takes place in
253  * {@link #doEnginePower}).
254  *
255  * TODO: changes in MP should not be instantaneous -- introduce
256  * a lag between throttle changes and MP changes, to allow pressure
257  * to build up or disperse.
258  *
259  * Inputs: MinManifoldPressure_inHg, MaxManifoldPressure_inHg, Throttle
260  *
261  * Outputs: ManifoldPressure_inHg
262  */
263
264 void FGPiston::doManifoldPressure(void)
265 {
266   if (Running || Cranking) {
267     ManifoldPressure_inHg = MinManifoldPressure_inHg +
268             (Throttle * (MaxManifoldPressure_inHg - MinManifoldPressure_inHg));
269   } else {
270     ManifoldPressure_inHg = Atmosphere->GetPressure() * psftoinhg; // psf to in Hg
271   }  
272 }
273
274 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
275 /**
276  * Calculate the air flow through the engine.
277  *
278  * At this point, ManifoldPressure_inHg still represents the sea-level
279  * MP, not adjusted for altitude.
280  *
281  * Inputs: p_amb, R_air, T_amb, ManifoldPressure_inHg, Displacement,
282  *   RPM, volumetric_efficiency
283  *
284  * Outputs: rho_air, m_dot_air
285  */
286
287 void FGPiston::doAirFlow(void)
288 {
289   rho_air = p_amb / (R_air * T_amb);
290   double rho_air_manifold = rho_air * ManifoldPressure_inHg / 29.6;
291   double displacement_SI = Displacement * in3tom3;
292   double swept_volume = (displacement_SI * (RPM/60)) / 2;
293   double v_dot_air = swept_volume * volumetric_efficiency;
294   m_dot_air = v_dot_air * rho_air_manifold;
295 }
296
297 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
298 /**
299  * Calculate the fuel flow into the engine.
300  *
301  * Inputs: Mixture, thi_sea_level, p_amb_sea_level, p_amb, m_dot_air
302  *
303  * Outputs: equivalence_ratio, m_dot_fuel
304  */
305
306 void FGPiston::doFuelFlow(void)
307 {
308   double thi_sea_level = 1.3 * Mixture;
309   equivalence_ratio = thi_sea_level * p_amb_sea_level / p_amb;
310   m_dot_fuel = m_dot_air / 14.7 * equivalence_ratio;
311   FuelFlow_gph = m_dot_fuel
312     * 3600                      // seconds to hours
313     * 2.2046                    // kg to lb
314     / 6.6;                      // lb to gal_us of kerosene
315 }
316
317 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
318 /**
319  * Calculate the power produced by the engine.
320  *
321  * Currently, the JSBSim propellor model does not allow the
322  * engine to produce enough RPMs to get up to a high horsepower.
323  * When tested with sufficient RPM, it has no trouble reaching
324  * 200HP.
325  *
326  * Inputs: ManifoldPressure_inHg, p_amb, p_amb_sea_level, RPM, T_amb, 
327  *   equivalence_ratio, Cycles, MaxHP
328  *
329  * Outputs: Percentage_Power, HP
330  */
331
332 void FGPiston::doEnginePower(void)
333 {
334   ManifoldPressure_inHg *= p_amb / p_amb_sea_level;
335   if (Running) {        
336     double ManXRPM = ManifoldPressure_inHg * RPM;
337         // FIXME: this needs to be generalized
338     Percentage_Power = (6e-9 * ManXRPM * ManXRPM) + (8e-4 * ManXRPM) - 1.0;
339     double T_amb_degF = (T_amb * 1.8) - 459.67;
340     double T_amb_sea_lev_degF = (288 * 1.8) - 459.67; 
341     Percentage_Power =
342       Percentage_Power + ((T_amb_sea_lev_degF - T_amb_degF) * 7 /120);
343     double Percentage_of_best_power_mixture_power =
344       Power_Mixture_Correlation->GetValue(14.7 / equivalence_ratio);
345     Percentage_Power =
346       Percentage_Power * Percentage_of_best_power_mixture_power / 100.0;
347     if (Percentage_Power < 0.0)
348       Percentage_Power = 0.0;
349     else if (Percentage_Power > 100.0)
350       Percentage_Power = 100.0;
351     HP = Percentage_Power * MaxHP / 100.0;
352   } else {  
353     // Power output when the engine is not running
354     if (Cranking) {
355       if (RPM < 10) {
356         HP = 3.0;       // This is a hack to prevent overshooting the idle rpm in the first time step
357                     // It may possibly need to be changed if the prop model is changed.
358       } else if (RPM < 480) {
359         HP = 3.0 + ((480 - RPM) / 10.0);  
360         // This is a guess - would be nice to find a proper starter moter torque curve
361       } else {
362         HP = 3.0;
363       }
364     } else {
365       // Quick hack until we port the FMEP stuff
366       if (RPM > 0.0)
367         HP = -1.5;
368       else
369         HP = 0.0;
370     }
371   }
372 }
373
374 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
375 /**
376  * Calculate the exhaust gas temperature.
377  *
378  * Inputs: equivalence_ratio, m_dot_fuel, calorific_value_fuel, 
379  *   Cp_air, m_dot_air, Cp_fuel, m_dot_fuel, T_amb, Percentage_Power
380  *
381  * Outputs: combustion_efficiency, ExhaustGasTemp_degK
382  */
383
384 void FGPiston::doEGT(void)
385 {
386   double delta_T_exhaust;
387   double enthalpy_exhaust;
388   double heat_capacity_exhaust;
389   double dEGTdt;
390
391   if ((Running) && (m_dot_air > 0.0)) {  // do the energy balance
392     combustion_efficiency = Lookup_Combustion_Efficiency->GetValue(equivalence_ratio);
393     enthalpy_exhaust = m_dot_fuel * calorific_value_fuel * 
394                               combustion_efficiency * 0.33;
395     heat_capacity_exhaust = (Cp_air * m_dot_air) + (Cp_fuel * m_dot_fuel);
396     delta_T_exhaust = enthalpy_exhaust / heat_capacity_exhaust;
397     ExhaustGasTemp_degK = T_amb + delta_T_exhaust;
398     ExhaustGasTemp_degK *= 0.444 + ((0.544 - 0.444) * Percentage_Power / 100.0);
399   } else {  // Drop towards ambient - guess an appropriate time constant for now
400     dEGTdt = (298.0 - ExhaustGasTemp_degK) / 100.0;
401     delta_T_exhaust = dEGTdt * dt;
402     ExhaustGasTemp_degK += delta_T_exhaust;
403   }
404 }
405
406 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
407 /**
408  * Calculate the cylinder head temperature.
409  *
410  * Inputs: T_amb, IAS, rho_air, m_dot_fuel, calorific_value_fuel,
411  *   combustion_efficiency, RPM
412  *
413  * Outputs: CylinderHeadTemp_degK
414  */
415
416 void FGPiston::doCHT(void)
417 {
418   double h1 = -95.0;
419   double h2 = -3.95;
420   double h3 = -0.05;
421
422   double arbitary_area = 1.0;
423   double CpCylinderHead = 800.0;
424   double MassCylinderHead = 8.0;
425
426   double temperature_difference = CylinderHeadTemp_degK - T_amb;
427   double v_apparent = IAS * 0.5144444;
428   double v_dot_cooling_air = arbitary_area * v_apparent;
429   double m_dot_cooling_air = v_dot_cooling_air * rho_air;
430   double dqdt_from_combustion = 
431     m_dot_fuel * calorific_value_fuel * combustion_efficiency * 0.33;
432   double dqdt_forced = (h2 * m_dot_cooling_air * temperature_difference) + 
433     (h3 * RPM * temperature_difference);
434   double dqdt_free = h1 * temperature_difference;
435   double dqdt_cylinder_head = dqdt_from_combustion + dqdt_forced + dqdt_free;
436     
437   double HeatCapacityCylinderHead = CpCylinderHead * MassCylinderHead;
438     
439   CylinderHeadTemp_degK +=
440     (dqdt_cylinder_head / HeatCapacityCylinderHead) * dt;
441 }
442
443 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
444 /**
445  * Calculate the oil temperature.
446  *
447  * Inputs: Percentage_Power, running flag.
448  *
449  * Outputs: OilTemp_degK
450  */
451
452 void FGPiston::doOilTemperature(void)
453 {
454   double idle_percentage_power = 2.3;        // approximately
455   double target_oil_temp;        // Steady state oil temp at the current engine conditions
456   double time_constant;          // The time constant for the differential equation
457
458   if (Running) {
459     target_oil_temp = 363;
460     time_constant = 500;        // Time constant for engine-on idling.
461     if (Percentage_Power > idle_percentage_power) {
462       time_constant /= ((Percentage_Power / idle_percentage_power) / 10.0); // adjust for power 
463     }
464   } else {
465     target_oil_temp = 298;
466     time_constant = 1000;  // Time constant for engine-off; reflects the fact
467                            // that oil is no longer getting circulated
468   }
469
470   double dOilTempdt = (target_oil_temp - OilTemp_degK) / time_constant;
471
472   OilTemp_degK += (dOilTempdt * dt);
473 }
474
475 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
476 /**
477  * Calculate the oil pressure.
478  *
479  * Inputs: RPM
480  *
481  * Outputs: OilPressure_psi
482  */
483
484 void FGPiston::doOilPressure(void)
485 {
486   double Oil_Press_Relief_Valve = 60; // FIXME: may vary by engine
487   double Oil_Press_RPM_Max = 1800;    // FIXME: may vary by engine
488   double Design_Oil_Temp = 358;       // degK; FIXME: may vary by engine
489   double Oil_Viscosity_Index = 0.25;
490
491   OilPressure_psi = (Oil_Press_Relief_Valve / Oil_Press_RPM_Max) * RPM;
492
493   if (OilPressure_psi >= Oil_Press_Relief_Valve) {
494     OilPressure_psi = Oil_Press_Relief_Valve;
495   }
496
497   OilPressure_psi += (Design_Oil_Temp - OilTemp_degK) * Oil_Viscosity_Index;
498 }
499
500 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
501 //
502 //    The bitmasked value choices are as follows:
503 //    unset: In this case (the default) JSBSim would only print
504 //       out the normally expected messages, essentially echoing
505 //       the config files as they are read. If the environment
506 //       variable is not set, debug_lvl is set to 1 internally
507 //    0: This requests JSBSim not to output any messages
508 //       whatsoever.
509 //    1: This value explicity requests the normal JSBSim
510 //       startup messages
511 //    2: This value asks for a message to be printed out when
512 //       a class is instantiated
513 //    4: When this value is set, a message is displayed when a
514 //       FGModel object executes its Run() method
515 //    8: When this value is set, various runtime state variables
516 //       are printed out periodically
517 //    16: When set various parameters are sanity checked and
518 //       a message is printed out when they go out of bounds
519
520 void FGPiston::Debug(int from)
521 {
522   if (debug_lvl <= 0) return;
523
524   if (debug_lvl & 1) { // Standard console startup message output
525     if (from == 0) { // Constructor
526
527       cout << "\n    Engine Name: "         << Name << endl;
528       cout << "      MinManifoldPressure: " << MinManifoldPressure_inHg << endl;
529       cout << "      MaxManifoldPressure: " << MaxManifoldPressure_inHg << endl;
530       cout << "      Displacement: "        << Displacement             << endl;
531       cout << "      MaxHP: "               << MaxHP                    << endl;
532       cout << "      Cycles: "              << Cycles                   << endl;
533       cout << "      IdleRPM: "             << IdleRPM                  << endl;
534       cout << "      MaxThrottle: "         << MaxThrottle              << endl;
535       cout << "      MinThrottle: "         << MinThrottle              << endl;
536
537       cout << endl;
538       cout << "      Combustion Efficiency table:" << endl;
539       Lookup_Combustion_Efficiency->Print();
540       cout << endl;
541
542       cout << endl;
543       cout << "      Power Mixture Correlation table:" << endl;
544       Power_Mixture_Correlation->Print();
545       cout << endl;
546
547     }
548   }
549   if (debug_lvl & 2 ) { // Instantiation/Destruction notification
550     if (from == 0) cout << "Instantiated: FGPiston" << endl;
551     if (from == 1) cout << "Destroyed:    FGPiston" << endl;
552   }
553   if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
554   }
555   if (debug_lvl & 8 ) { // Runtime state variables
556   }
557   if (debug_lvl & 16) { // Sanity checking
558   }
559   if (debug_lvl & 64) {
560     if (from == 0) { // Constructor
561       cout << IdSrc << endl;
562       cout << IdHdr << endl;
563     }
564   }
565 }
566
567 double
568 FGPiston::CalcFuelNeed(void)
569 {
570   return FuelFlow_gph / 3600 * State->Getdt() * Propulsion->GetRate();
571 }