JSBSim Flight Dynamics Model  1.1.11 (13 Feb 2022)
An Open Source Flight Dynamics and Control Software Library in C++
FGPropulsion Class Reference

Detailed Description

Propulsion management class.

The Propulsion class is the container for the entire propulsion system, which is comprised of engines, and tanks. Once the Propulsion class gets the config file, it reads in the <propulsion> section. Then:

  1. The appropriate engine type instance is created
  2. At least one tank object is created, and is linked to an engine.

At Run time each engine's Calculate() method is called.

Configuration File Format:

<propulsion>
<engine file="{string}">
... see FGEngine, FGThruster, and class for engine type ...
</engine>
... more engines ...
<tank type="{FUEL | OXIDIZER}">
... see FGTank ...
</tank>
... more tanks ...
<dump-rate unit="{LBS/MIN | KG/MIN}"> {number} </dump-rate>
<refuel-rate unit="{LBS/MIN | KG/MIN}"> {number} </refuel-rate>
</propulsion>
Author
Jon S. Berndt
See also
FGEngine FGTank

Definition at line 99 of file FGPropulsion.h.

#include <FGPropulsion.h>

+ Inheritance diagram for FGPropulsion:
+ Collaboration diagram for FGPropulsion:

Public Member Functions

 FGPropulsion (FGFDMExec *)
 Constructor.
 
 ~FGPropulsion () override
 Destructor.
 
const FGMatrix33CalculateTankInertias (void)
 
void DoRefuel (double time_slice)
 
void DumpFuel (double time_slice)
 
SGPath FindFullPathName (const SGPath &path) const override
 
int GetActiveEngine (void) const
 
int GetCutoff (void) const
 
FGEngineGetEngine (unsigned int index) const
 Retrieves an engine object pointer from the list of engines. More...
 
double GetForces (int n) const
 
const FGColumnVector3GetForces (void) const
 
bool GetFuelFreeze (void) const
 
double GetMoments (int n) const
 
const FGColumnVector3GetMoments (void) const
 
unsigned int GetNumEngines (void) const
 Retrieves the number of engines defined for the aircraft.
 
int GetnumSelectedFuelTanks (void) const
 Returns the number of fuel tanks currently actively supplying fuel.
 
int GetnumSelectedOxiTanks (void) const
 Returns the number of oxidizer tanks currently actively supplying oxidizer.
 
unsigned int GetNumTanks (void) const
 Retrieves the number of tanks defined for the aircraft.
 
std::string GetPropulsionStrings (const std::string &delimiter) const
 
std::string GetPropulsionTankReport ()
 
std::string GetPropulsionValues (const std::string &delimiter) const
 
int GetStarter (void) const
 
bool GetSteadyState (void)
 Loops the engines until thrust output steady (used for trimming)
 
FGTankGetTank (unsigned int index) const
 Retrieves a tank object pointer from the list of tanks. More...
 
const FGColumnVector3GetTanksMoment (void)
 
double GetTanksWeight (void) const
 
bool InitModel (void) override
 
void InitRunning (int n)
 Sets up the engines as running.
 
bool Load (Element *el) override
 Loads the propulsion system (engine[s] and tank[s]). More...
 
bool Run (bool Holding) override
 Executes the propulsion model. More...
 
void SetActiveEngine (int engine)
 
void SetCutoff (int setting=0)
 
void SetFuelFreeze (bool f)
 
void SetMagnetos (int setting)
 
void SetStarter (int setting)
 
double Transfer (int source, int target, double amount)
 
- Public Member Functions inherited from FGModel
 FGModel (FGFDMExec *)
 Constructor.
 
 ~FGModel () override
 Destructor.
 
FGFDMExecGetExec (void)
 
const std::string & GetName (void)
 
unsigned int GetRate (void)
 Get the output rate for the model in frames.
 
void SetPropertyManager (FGPropertyManager *fgpm)
 
void SetRate (unsigned int tt)
 Set the ouput rate for the model in frames.
 
- Public Member Functions inherited from FGModelFunctions
std::string GetFunctionStrings (const std::string &delimeter) const
 Gets the strings for the current set of functions. More...
 
std::string GetFunctionValues (const std::string &delimeter) const
 Gets the function values. More...
 
FGFunctionGetPreFunction (const std::string &name)
 Get one of the "pre" function. More...
 
bool Load (Element *el, FGFDMExec *fdmex, std::string prefix="")
 
void PostLoad (Element *el, FGFDMExec *fdmex, std::string prefix="")
 
void PreLoad (Element *el, FGFDMExec *fdmex, std::string prefix="")
 
void RunPostFunctions (void)
 
void RunPreFunctions (void)
 
- Public Member Functions inherited from FGJSBBase
 FGJSBBase ()
 Constructor for FGJSBBase.
 
virtual ~FGJSBBase ()
 Destructor for FGJSBBase.
 
void PutMessage (const Message &msg)
 Places a Message structure on the Message queue. More...
 
void PutMessage (const std::string &text)
 Creates a message with the given text and places it on the queue. More...
 
void PutMessage (const std::string &text, bool bVal)
 Creates a message with the given text and boolean value and places it on the queue. More...
 
void PutMessage (const std::string &text, int iVal)
 Creates a message with the given text and integer value and places it on the queue. More...
 
void PutMessage (const std::string &text, double dVal)
 Creates a message with the given text and double value and places it on the queue. More...
 
int SomeMessages (void) const
 Reads the message on the queue (but does not delete it). More...
 
void ProcessMessage (void)
 Reads the message on the queue and removes it from the queue. More...
 
MessageProcessNextMessage (void)
 Reads the next message on the queue and removes it from the queue. More...
 
void disableHighLighting (void)
 Disables highlighting in the console output.
 

Public Attributes

struct FGEngine::Inputs in
 

Additional Inherited Members

- Public Types inherited from FGJSBBase
enum  { eL = 1, eM, eN }
 Moments L, M, N.
 
enum  { eP = 1, eQ, eR }
 Rates P, Q, R.
 
enum  { eU = 1, eV, eW }
 Velocities U, V, W.
 
enum  { eX = 1, eY, eZ }
 Positions X, Y, Z.
 
enum  { ePhi = 1, eTht, ePsi }
 Euler angles Phi, Theta, Psi.
 
enum  { eDrag = 1, eSide, eLift }
 Stability axis forces, Drag, Side force, Lift.
 
enum  { eRoll = 1, ePitch, eYaw }
 Local frame orientation Roll, Pitch, Yaw.
 
enum  { eNorth = 1, eEast, eDown }
 Local frame position North, East, Down.
 
enum  { eLat = 1, eLong, eRad }
 Locations Radius, Latitude, Longitude.
 
enum  {
  inNone = 0, inDegrees, inRadians, inMeters,
  inFeet
}
 Conversion specifiers.
 
- Static Public Member Functions inherited from FGJSBBase
static const std::string & GetVersion (void)
 Returns the version number of JSBSim. More...
 
static constexpr double KelvinToFahrenheit (double kelvin)
 Converts from degrees Kelvin to degrees Fahrenheit. More...
 
static constexpr double CelsiusToRankine (double celsius)
 Converts from degrees Celsius to degrees Rankine. More...
 
static constexpr double RankineToCelsius (double rankine)
 Converts from degrees Rankine to degrees Celsius. More...
 
static constexpr double KelvinToRankine (double kelvin)
 Converts from degrees Kelvin to degrees Rankine. More...
 
static constexpr double RankineToKelvin (double rankine)
 Converts from degrees Rankine to degrees Kelvin. More...
 
static constexpr double FahrenheitToCelsius (double fahrenheit)
 Converts from degrees Fahrenheit to degrees Celsius. More...
 
static constexpr double CelsiusToFahrenheit (double celsius)
 Converts from degrees Celsius to degrees Fahrenheit. More...
 
static constexpr double CelsiusToKelvin (double celsius)
 Converts from degrees Celsius to degrees Kelvin. More...
 
static constexpr double KelvinToCelsius (double kelvin)
 Converts from degrees Kelvin to degrees Celsius. More...
 
static constexpr double FeetToMeters (double measure)
 Converts from feet to meters. More...
 
static double PitotTotalPressure (double mach, double p)
 Compute the total pressure in front of the Pitot tube. More...
 
static double MachFromImpactPressure (double qc, double p)
 Compute the Mach number from the differential pressure (qc) and the static pressure. More...
 
static double VcalibratedFromMach (double mach, double p)
 Calculate the calibrated airspeed from the Mach number. More...
 
static double MachFromVcalibrated (double vcas, double p)
 Calculate the Mach number from the calibrated airspeed.Based on the formulas in the US Air Force Aircraft Performance Flight Testing Manual (AFFTC-TIH-99-01). More...
 
static bool EqualToRoundoff (double a, double b)
 Finite precision comparison. More...
 
static bool EqualToRoundoff (float a, float b)
 Finite precision comparison. More...
 
static bool EqualToRoundoff (float a, double b)
 Finite precision comparison. More...
 
static bool EqualToRoundoff (double a, float b)
 Finite precision comparison. More...
 
static constexpr double Constrain (double min, double value, double max)
 Constrain a value between a minimum and a maximum value.
 
static constexpr double sign (double num)
 
static double GaussianRandomNumber (void)
 
- Static Public Attributes inherited from FGJSBBase
static char highint [5] = {27, '[', '1', 'm', '\0' }
 highlights text
 
static char halfint [5] = {27, '[', '2', 'm', '\0' }
 low intensity text
 
static char normint [6] = {27, '[', '2', '2', 'm', '\0' }
 normal intensity text
 
static char reset [5] = {27, '[', '0', 'm', '\0' }
 resets text properties
 
static char underon [5] = {27, '[', '4', 'm', '\0' }
 underlines text
 
static char underoff [6] = {27, '[', '2', '4', 'm', '\0' }
 underline off
 
static char fgblue [6] = {27, '[', '3', '4', 'm', '\0' }
 blue text
 
static char fgcyan [6] = {27, '[', '3', '6', 'm', '\0' }
 cyan text
 
static char fgred [6] = {27, '[', '3', '1', 'm', '\0' }
 red text
 
static char fggreen [6] = {27, '[', '3', '2', 'm', '\0' }
 green text
 
static char fgdef [6] = {27, '[', '3', '9', 'm', '\0' }
 default text
 
static short debug_lvl = 1
 
- Protected Member Functions inherited from FGModel
bool Upload (Element *el, bool preLoad)
 Uploads this model in memory. More...
 
- Static Protected Member Functions inherited from FGJSBBase
static std::string CreateIndexedPropertyName (const std::string &Property, int index)
 
- Protected Attributes inherited from FGModel
unsigned int exe_ctr
 
FGFDMExecFDMExec
 
std::string Name
 
FGPropertyManagerPropertyManager
 
unsigned int rate
 
- Protected Attributes inherited from FGModelFunctions
FGPropertyReader LocalProperties
 
std::vector< FGFunction * > PostFunctions
 
std::vector< FGFunction * > PreFunctions
 
- Static Protected Attributes inherited from FGJSBBase
static Message localMsg
 
static std::queue< MessageMessages
 
static unsigned int messageId = 0
 
static constexpr double radtodeg = 180. / M_PI
 
static constexpr double degtorad = M_PI / 180.
 
static constexpr double hptoftlbssec = 550.0
 
static constexpr double psftoinhg = 0.014138
 
static constexpr double psftopa = 47.88
 
static constexpr double ktstofps = 1.68781
 
static constexpr double fpstokts = 1.0 / ktstofps
 
static constexpr double inchtoft = 1.0/12.0
 
static constexpr double fttom = 0.3048
 
static constexpr double m3toft3 = 1.0/(fttom*fttom*fttom)
 
static constexpr double in3tom3 = inchtoft*inchtoft*inchtoft/m3toft3
 
static constexpr double inhgtopa = 3386.38
 
static constexpr double slugtolb = 32.174049
 Note that definition of lbtoslug by the inverse of slugtolb and not to a different constant you can also get from some tables will make lbtoslug*slugtolb == 1 up to the magnitude of roundoff. More...
 
static constexpr double lbtoslug = 1.0/slugtolb
 
static constexpr double kgtolb = 2.20462
 
static constexpr double kgtoslug = 0.06852168
 
static const std::string needed_cfg_version = "2.0"
 
static const std::string JSBSim_version = JSBSIM_VERSION " " __DATE__ " " __TIME__
 
static int gaussian_random_number_phase = 0
 

Member Function Documentation

◆ GetEngine()

FGEngine* GetEngine ( unsigned int  index) const
inline

Retrieves an engine object pointer from the list of engines.

Parameters
indexthe engine index within the vector container
Returns
the address of the specific engine, or zero if no such engine is available

Definition at line 133 of file FGPropulsion.h.

133  {
134  if (index < Engines.size()) return Engines[index];
135  else return 0L; }
+ Here is the caller graph for this function:

◆ GetTank()

FGTank* GetTank ( unsigned int  index) const
inline

Retrieves a tank object pointer from the list of tanks.

Parameters
indexthe tank index within the vector container
Returns
the address of the specific tank, or zero if no such tank is available

Definition at line 144 of file FGPropulsion.h.

144  {
145  if (index < Tanks.size()) return Tanks[index];
146  else return 0L; }

◆ Load()

bool Load ( Element el)
overridevirtual

Loads the propulsion system (engine[s] and tank[s]).

Characteristics of the propulsion system are read in from the config file.

Parameters
elpointer to an XML element that contains the engine information.
Returns
true if successfully loaded, otherwise false

Reimplemented from FGModel.

Definition at line 357 of file FGPropulsion.cpp.

358 {
359  FGModelLoader ModelLoader(this);
360 
361  Debug(2);
362  ReadingEngine = false;
363  double FuelDensity = 6.0;
364 
365  Name = "Propulsion Model: " + el->GetAttributeValue("name");
366 
367  // Perform base class Pre-Load
368  if (!FGModel::Upload(el, true))
369  return false;
370 
371  // Process tank definitions first to establish the number of fuel tanks
372 
373  Element* tank_element = el->FindElement("tank");
374  while (tank_element) {
375  Tanks.push_back(new FGTank(FDMExec, tank_element, numTanks));
376  if (Tanks.back()->GetType() == FGTank::ttFUEL) {
377  FuelDensity = Tanks[numFuelTanks]->GetDensity();
378  numFuelTanks++;
379  }
380  else if (Tanks.back()->GetType() == FGTank::ttOXIDIZER) numOxiTanks++;
381  else {cerr << "Unknown tank type specified." << endl; return false;}
382  numTanks++;
383  tank_element = el->FindNextElement("tank");
384  }
385  numSelectedFuelTanks = numFuelTanks;
386  numSelectedOxiTanks = numOxiTanks;
387 
388  ReadingEngine = true;
389  Element* engine_element = el->FindElement("engine");
390  while (engine_element) {
391  if (!ModelLoader.Open(engine_element)) return false;
392 
393  try {
394  // Locate the thruster definition
395  Element* thruster_element = engine_element->FindElement("thruster");
396  if (!thruster_element || !ModelLoader.Open(thruster_element))
397  throw("No thruster definition supplied with engine definition.");
398 
399  if (engine_element->FindElement("piston_engine")) {
400  HavePistonEngine = true;
401  if (!IsBound) bind();
402  Element *element = engine_element->FindElement("piston_engine");
403  Engines.push_back(new FGPiston(FDMExec, element, numEngines, in));
404  } else if (engine_element->FindElement("turbine_engine")) {
405  HaveTurbineEngine = true;
406  if (!IsBound) bind();
407  Element *element = engine_element->FindElement("turbine_engine");
408  Engines.push_back(new FGTurbine(FDMExec, element, numEngines, in));
409  } else if (engine_element->FindElement("turboprop_engine")) {
410  HaveTurboPropEngine = true;
411  if (!IsBound) bind();
412  Element *element = engine_element->FindElement("turboprop_engine");
413  Engines.push_back(new FGTurboProp(FDMExec, element, numEngines, in));
414  } else if (engine_element->FindElement("rocket_engine")) {
415  HaveRocketEngine = true;
416  if (!IsBound) bind();
417  Element *element = engine_element->FindElement("rocket_engine");
418  Engines.push_back(new FGRocket(FDMExec, element, numEngines, in));
419  } else if (engine_element->FindElement("electric_engine")) {
420  HaveElectricEngine = true;
421  if (!IsBound) bind();
422  Element *element = engine_element->FindElement("electric_engine");
423  Engines.push_back(new FGElectric(FDMExec, element, numEngines, in));
424  } else {
425  cerr << engine_element->ReadFrom() << " Unknown engine type" << endl;
426  return false;
427  }
428  } catch (std::string& str) {
429  cerr << endl << fgred << str << reset << endl;
430  return false;
431  }
432 
433  numEngines++;
434 
435  engine_element = el->FindNextElement("engine");
436  }
437 
438  CalculateTankInertias();
439 
440  if (el->FindElement("dump-rate"))
441  DumpRate = el->FindElementValueAsNumberConvertTo("dump-rate", "LBS/MIN");
442  if (el->FindElement("refuel-rate"))
443  RefuelRate = el->FindElementValueAsNumberConvertTo("refuel-rate", "LBS/MIN");
444 
445  unsigned int i;
446  for (i=0; i<Engines.size(); i++) {
447  Engines[i]->SetFuelDensity(FuelDensity);
448  }
449 
450 
451  PostLoad(el, FDMExec);
452 
453  return true;
454 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Run()

bool Run ( bool  Holding)
overridevirtual

Executes the propulsion model.

The initial plan for the FGPropulsion class calls for Run() to be executed, calculating the power available from the engine. Can pass in a value indicating if the executive is directing the simulation to Hold.

Parameters
Holdingif true, the executive has been directed to hold the sim from advancing time. Some models may ignore this flag, such as the Input model, which may need to be active to listen on a socket for the "Resume" command to be given.
Returns
false if no error

Reimplemented from FGModel.

Definition at line 127 of file FGPropulsion.cpp.

128 {
129  unsigned int i;
130 
131  if (FGModel::Run(Holding)) return true;
132  if (Holding) return false;
133 
134  RunPreFunctions();
135 
136  vForces.InitMatrix();
137  vMoments.InitMatrix();
138 
139  for (i=0; i<numEngines; i++) {
140  Engines[i]->Calculate();
141  ConsumeFuel(Engines[i]);
142  vForces += Engines[i]->GetBodyForces(); // sum body frame forces
143  vMoments += Engines[i]->GetMoments(); // sum body frame moments
144  }
145 
146  TotalFuelQuantity = 0.0;
147  TotalOxidizerQuantity = 0.0;
148  for (i=0; i<numTanks; i++) {
149  Tanks[i]->Calculate( in.TotalDeltaT, in.TAT_c);
150  switch (Tanks[i]->GetType()) {
151  case FGTank::ttFUEL:
152  TotalFuelQuantity += Tanks[i]->GetContents();
153  break;
154  case FGTank::ttOXIDIZER:
155  TotalOxidizerQuantity += Tanks[i]->GetContents();
156  break;
157  default:
158  break;
159  }
160  }
161 
162  if (refuel.node() && refuel) DoRefuel( in.TotalDeltaT );
163  if (dump.node() && dump) DumpFuel( in.TotalDeltaT );
164 
165  RunPostFunctions();
166 
167  return false;
168 }
+ Here is the call graph for this function:

The documentation for this class was generated from the following files:
JSBSim::FGModel::Upload
bool Upload(Element *el, bool preLoad)
Uploads this model in memory.
Definition: FGModel.cpp:110
JSBSim::FGJSBBase::fgred
static char fgred[6]
red text
Definition: FGJSBBase.h:139
JSBSim::FGJSBBase::reset
static char reset[5]
resets text properties
Definition: FGJSBBase.h:129
JSBSim::FGModel::Run
virtual bool Run(bool Holding)
Runs the model; called by the Executive.
Definition: FGModel.cpp:89