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