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