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