JSBSim Flight Dynamics Model  1.0 (02 March 2017)
An Open Source Flight Dynamics and Control Software Library in C++
FGPropulsion Class Reference

Propulsion management class. More...

#include <FGPropulsion.h>

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

Public Member Functions

 FGPropulsion (FGFDMExec *)
 Constructor.
 
 ~FGPropulsion ()
 Destructor.
 
const FGMatrix33CalculateTankInertias (void)
 
void DoRefuel (double time_slice)
 
void DumpFuel (double time_slice)
 
SGPath FindFullPathName (const SGPath &path) const
 
int GetActiveEngine (void) const
 
FGEngineGetEngine (unsigned int index) const
 Retrieves an engine object pointer from the list of engines. More...
 
const FGColumnVector3GetForces (void) const
 
double GetForces (int n) const
 
bool GetFuelFreeze (void) const
 
const FGColumnVector3GetMoments (void) const
 
double GetMoments (int n) 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
 
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)
 
void InitRunning (int n)
 Sets up the engines as running.
 
bool Load (Element *el)
 Loads the propulsion system (engine[s] and tank[s]). More...
 
bool Run (bool Holding)
 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.
 
virtual ~FGModel ()
 Destructor.
 
FGFDMExecGetExec (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, FGPropertyManager *PropertyManager, std::string prefix="")
 
void PostLoad (Element *el, FGPropertyManager *PropertyManager, std::string prefix="")
 
void PreLoad (Element *el, FGPropertyManager *PropertyManager, 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 disableHighLighting (void)
 Disables highlighting in the console output.
 
std::string GetVersion (void)
 Returns the version number of JSBSim. More...
 
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)
 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...
 

Public Attributes

struct FGEngine::Inputs in
 
- Public Attributes inherited from FGModel
std::string Name
 

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 double CelsiusToFahrenheit (double celsius)
 Converts from degrees Celsius to degrees Fahrenheit. More...
 
static double CelsiusToKelvin (double celsius)
 Converts from degrees Celsius to degrees Kelvin. More...
 
static double CelsiusToRankine (double celsius)
 Converts from degrees Celsius to degrees Rankine. More...
 
static double Constrain (double min, double value, double max)
 Constrain a value between a minimum and a maximum value.
 
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 double FahrenheitToCelsius (double fahrenheit)
 Converts from degrees Fahrenheit to degrees Celsius. More...
 
static double FeetToMeters (double measure)
 Converts from feet to meters. More...
 
static double GaussianRandomNumber (void)
 
static double KelvinToCelsius (double kelvin)
 Converts from degrees Kelvin to degrees Celsius. More...
 
static double KelvinToFahrenheit (double kelvin)
 Converts from degrees Kelvin to degrees Fahrenheit. More...
 
static double KelvinToRankine (double kelvin)
 Converts from degrees Kelvin to degrees Rankine. More...
 
static double MachFromVcalibrated (double vcas, double p, double psl, double rhosl)
 Calculate the Mach number from the calibrated airspeed. More...
 
static double PitotTotalPressure (double mach, double p)
 Compute the total pressure in front of the Pitot tube. More...
 
static double RankineToCelsius (double rankine)
 Converts from degrees Rankine to degrees Celsius. More...
 
static double RankineToKelvin (double rankine)
 Converts from degrees Rankine to degrees Kelvin. More...
 
static double sign (double num)
 
static double VcalibratedFromMach (double mach, double p, double psl, double rhosl)
 Calculate the calibrated airspeed from the Mach number. More...
 
- Static Public Attributes inherited from FGJSBBase
static short debug_lvl = 1
 
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
 
- Protected Member Functions inherited from FGJSBBase
void Debug (int)
 
- 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
 
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 const double degtorad = 0.017453292519943295769236907684886
 
static const double fpstokts = 1.0/ktstofps
 
static const double fttom = 0.3048
 
static int gaussian_random_number_phase = 0
 
static const double hptoftlbssec = 550.0
 
static const double in3tom3 = 1.638706E-5
 
static const double inchtoft = 0.08333333
 
static const double inhgtopa = 3386.38
 
static const std::string JSBSim_version = "1.0 " __DATE__ " " __TIME__
 
static const double kgtolb = 2.20462
 
static const double kgtoslug = 0.06852168
 
static const double ktstofps = 1.68781
 
static const double lbtoslug = 1.0/slugtolb
 
static Message localMsg
 
static const double m3toft3 = 1.0/(fttom*fttom*fttom)
 
static double Mair = 28.9645
 
static unsigned int messageId = 0
 
static std::queue< MessageMessages
 
static const std::string needed_cfg_version = "2.0"
 
static const double psftoinhg = 0.014138
 
static const double psftopa = 47.88
 
static const double radtodeg = 57.295779513082320876798154814105
 
static double Reng = 1716.56
 
static double Rstar = 1545.348
 
static const double SHRatio = 1.40
 
static const double slugtolb = 32.174049
 

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
Version
Id
FGPropulsion.h,v 1.37 2017/02/25 14:23:19 bcoconni Exp
See also
FGEngine FGTank

Definition at line 106 of file FGPropulsion.h.

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 140 of file FGPropulsion.h.

140  {
141  if (index < Engines.size()) return Engines[index];
142  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 151 of file FGPropulsion.h.

151  {
152  if (index < Tanks.size()) return Tanks[index];
153  else return 0L; }
+ Here is the caller graph for this function:

◆ Load()

bool Load ( Element el)
virtual

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 365 of file FGPropulsion.cpp.

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

◆ Run()

bool Run ( bool  Holding)
virtual

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 135 of file FGPropulsion.cpp.

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

The documentation for this class was generated from the following files: