JSBSim Flight Dynamics Model  1.2.0 (05 Nov 2023)
An Open Source Flight Dynamics and Control Software Library in C++
FGBuoyantForces Class Reference

Detailed Description

Encapsulates the Buoyant forces calculations.

This class owns and contains the list of force/coefficients that define the Buoyant properties of an air vehicle.

Here's an example of a gas cell specification:

<buoyant_forces>
<!-- Interface properties -->
<property>ballonets/in-flow-ft3ps[0]</property>
<gas_cell type="HYDROGEN">
<location unit="M">
<x> 18.8 </x>
<y> 0.0 </y>
<z> 0.0 </z>
</location>
<x_radius unit="M"> 22.86 </x_radius>
<y_radius unit="M"> 4.55 </y_radius>
<z_radius unit="M"> 4.55 </z_radius>
<max_overpressure unit="PA"> 340.0 </max_overpressure>
<valve_coefficient unit="M4*SEC/KG"> 0.015 </valve_coefficient>
</gas_cell>
... {other gas cells} ...
</buoyant_forces>

See FGGasCell for the full configuration file format for gas cells.

Author
Anders Gidenstam, Jon S. Berndt

Definition at line 98 of file FGBuoyantForces.h.

#include <FGBuoyantForces.h>

+ Inheritance diagram for FGBuoyantForces:
+ Collaboration diagram for FGBuoyantForces:

Public Member Functions

 FGBuoyantForces (FGFDMExec *Executive)
 Constructor. More...
 
 ~FGBuoyantForces () override
 Destructor.
 
std::string GetBuoyancyStrings (const std::string &delimeter)
 Gets the strings for the current set of gas cells. More...
 
std::string GetBuoyancyValues (const std::string &delimeter)
 Gets the coefficient values. More...
 
double GetForces (int idx) const
 Gets a component of the total Buoyant force vector. More...
 
const FGColumnVector3GetForces (void) const
 Gets the total Buoyant force vector. More...
 
double GetGasMass (void) const
 Gets the total gas mass. More...
 
const FGMatrix33GetGasMassInertia (void)
 Gets the total moments of inertia for the gas mass in the body frame. More...
 
const FGColumnVector3GetGasMassMoment (void)
 Gets the total moment from the gas mass. More...
 
double GetMoments (int idx) const
 Gets a component of the total Buoyancy moment vector. More...
 
const FGColumnVector3GetMoments (void) const
 Gets the total Buoyancy moment vector. More...
 
bool InitModel (void) override
 
bool Load (Element *element) override
 Loads the Buoyant forces model. More...
 
bool Run (bool Holding) override
 Runs the Buoyant forces model; called by the Executive Can pass in a value indicating if the executive is directing the simulation to Hold. More...
 
- Public Member Functions inherited from FGModel
 FGModel (FGFDMExec *)
 Constructor.
 
 ~FGModel () override
 Destructor.
 
virtual SGPath FindFullPathName (const SGPath &path) const
 
FGFDMExecGetExec (void)
 
const std::string & GetName (void)
 
unsigned int GetRate (void)
 Get the output rate for the model in frames.
 
bool InitModel (void) override
 
void SetPropertyManager (std::shared_ptr< 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...
 
std::shared_ptr< 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 disableHighLighting (void)
 Disables highlighting in the console output.
 

Public Attributes

FGGasCell::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 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 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
 
std::shared_ptr< FGPropertyManagerPropertyManager
 
unsigned int rate
 
- Protected Attributes inherited from FGModelFunctions
FGPropertyReader LocalProperties
 
std::vector< std::shared_ptr< FGFunction > > PostFunctions
 
std::vector< std::shared_ptr< FGFunction > > PreFunctions
 
- Static Protected Attributes inherited from FGJSBBase
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 fttom = 0.3048
 
static constexpr double ktstofps = 1852./(3600*fttom)
 
static constexpr double fpstokts = 1.0 / ktstofps
 
static constexpr double inchtoft = 1.0/12.0
 
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__
 

Constructor & Destructor Documentation

◆ FGBuoyantForces()

FGBuoyantForces ( FGFDMExec Executive)

Constructor.

Parameters
Executivea pointer to the parent executive object

Definition at line 51 of file FGBuoyantForces.cpp.

51  : FGModel(FDMExec)
52 {
53  Name = "FGBuoyantForces";
54 
55  NoneDefined = true;
56 
57  vTotalForces.InitMatrix();
58  vTotalMoments.InitMatrix();
59 
60  gasCellJ.InitMatrix();
61 
62  Debug(0);
63 }
void InitMatrix(void)
Initialize the matrix.
Definition: FGMatrix33.cpp:259
FGModel(FGFDMExec *)
Constructor.
Definition: FGModel.cpp:57
+ Here is the call graph for this function:

Member Function Documentation

◆ GetBuoyancyStrings()

string GetBuoyancyStrings ( const std::string &  delimeter)

Gets the strings for the current set of gas cells.

Parameters
delimetereither a tab or comma string depending on output type
Returns
a string containing the descriptive names for all parameters

Definition at line 182 of file FGBuoyantForces.cpp.

183 {
184  string CoeffStrings = "";
185 /*
186  bool firstime = true;
187  for (sd = 0; sd < variables.size(); sd++) {
188  if (firstime) {
189  firstime = false;
190  } else {
191  CoeffStrings += delimeter;
192  }
193  CoeffStrings += variables[sd]->GetName();
194  }
195 
196  for (axis = 0; axis < 6; axis++) {
197  for (sd = 0; sd < AeroFunctions[axis].size(); sd++) {
198  if (firstime) {
199  firstime = false;
200  } else {
201  CoeffStrings += delimeter;
202  }
203  CoeffStrings += AeroFunctions[axis][sd]->GetName();
204  }
205  }
206 */
207  return CoeffStrings;
208 }

◆ GetBuoyancyValues()

string GetBuoyancyValues ( const std::string &  delimeter)

Gets the coefficient values.

Parameters
delimetereither a tab or comma string depending on output type
Returns
a string containing the numeric values for the current set of parameters

Definition at line 212 of file FGBuoyantForces.cpp.

213 {
214  string SDValues = "";
215 /*
216  bool firstime = true;
217  for (sd = 0; sd < variables.size(); sd++) {
218  if (firstime) {
219  firstime = false;
220  } else {
221  SDValues += delimeter;
222  }
223  SDValues += variables[sd]->GetValueAsString();
224  }
225 
226  for (unsigned int axis = 0; axis < 6; axis++) {
227  for (unsigned int sd = 0; sd < AeroFunctions[axis].size(); sd++) {
228  if (firstime) {
229  firstime = false;
230  } else {
231  SDValues += delimeter;
232  }
233  SDValues += AeroFunctions[axis][sd]->GetValueAsString();
234  }
235  }
236 */
237  return SDValues;
238 }

◆ GetForces() [1/2]

double GetForces ( int  idx) const
inline

Gets a component of the total Buoyant force vector.

Returns
a component of the force vector in lbs.

Definition at line 132 of file FGBuoyantForces.h.

132 {return vTotalForces(idx);}

◆ GetForces() [2/2]

const FGColumnVector3& GetForces ( void  ) const
inline

Gets the total Buoyant force vector.

Returns
a force vector in lbs.

Definition at line 128 of file FGBuoyantForces.h.

128 {return vTotalForces;}

◆ GetGasMass()

double GetGasMass ( void  ) const

Gets the total gas mass.

The gas mass is part of the aircraft's inertia.

Returns
mass in slugs.

Definition at line 141 of file FGBuoyantForces.cpp.

142 {
143  double Gw = 0.0;
144 
145  for (unsigned int i = 0; i < Cells.size(); i++) {
146  Gw += Cells[i]->GetMass();
147  }
148 
149  return Gw;
150 }

◆ GetGasMassInertia()

const FGMatrix33 & GetGasMassInertia ( void  )

Gets the total moments of inertia for the gas mass in the body frame.

Returns
moments of inertia matrix in the body frame in slug ft2.

Definition at line 165 of file FGBuoyantForces.cpp.

166 {
167  size_t size = Cells.size();
168 
169  if (size == 0) return gasCellJ;
170 
171  gasCellJ.InitMatrix();
172 
173  for (unsigned int i=0; i < size; i++) {
174  gasCellJ += Cells[i]->GetInertia();
175  }
176 
177  return gasCellJ;
178 }
+ Here is the call graph for this function:

◆ GetGasMassMoment()

const FGColumnVector3 & GetGasMassMoment ( void  )

Gets the total moment from the gas mass.

Returns
a moment vector in the structural frame in lbs in.

Definition at line 154 of file FGBuoyantForces.cpp.

155 {
156  vXYZgasCell_arm.InitMatrix();
157  for (unsigned int i = 0; i < Cells.size(); i++) {
158  vXYZgasCell_arm += Cells[i]->GetMassMoment();
159  }
160  return vXYZgasCell_arm;
161 }

◆ GetMoments() [1/2]

double GetMoments ( int  idx) const
inline

Gets a component of the total Buoyancy moment vector.

Returns
a component of the moment vector in the body frame in lbs ft.

Definition at line 140 of file FGBuoyantForces.h.

140 {return vTotalMoments(idx);}

◆ GetMoments() [2/2]

const FGColumnVector3& GetMoments ( void  ) const
inline

Gets the total Buoyancy moment vector.

Returns
a moment vector in the body frame in lbs ft.

Definition at line 136 of file FGBuoyantForces.h.

136 {return vTotalMoments;}

◆ Load()

bool Load ( Element element)
overridevirtual

Loads the Buoyant forces model.

The Load function for this class expects the XML parser to have found the Buoyant_forces keyword in the configuration file.

Parameters
elementpointer to the current XML element for Buoyant forces parameters.
Returns
true if successful

Reimplemented from FGModel.

Definition at line 113 of file FGBuoyantForces.cpp.

114 {
115  Element *gas_cell_element;
116 
117  Debug(2);
118 
119  // Perform base class Pre-Load
120  if (!FGModel::Upload(document, true))
121  return false;
122 
123  gas_cell_element = document->FindElement("gas_cell");
124  while (gas_cell_element) {
125  NoneDefined = false;
126  Cells.push_back(new FGGasCell(FDMExec, gas_cell_element, Cells.size(), in));
127  gas_cell_element = document->FindNextElement("gas_cell");
128  }
129 
130  PostLoad(document, FDMExec);
131 
132  if (!NoneDefined) {
133  bind();
134  }
135 
136  return true;
137 }
bool Upload(Element *el, bool preLoad)
Uploads this model in memory.
Definition: FGModel.cpp:110
+ Here is the call graph for this function:

◆ Run()

bool Run ( bool  Holding)
overridevirtual

Runs the Buoyant forces model; called by the Executive 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 89 of file FGBuoyantForces.cpp.

90 {
91  if (FGModel::Run(Holding)) return true;
92  if (Holding) return false; // if paused don't execute
93  if (NoneDefined) return true;
94 
95  RunPreFunctions();
96 
97  vTotalForces.InitMatrix();
98  vTotalMoments.InitMatrix();
99 
100  for (unsigned int i=0; i<Cells.size(); i++) {
101  Cells[i]->Calculate(FDMExec->GetDeltaT());
102  vTotalForces += Cells[i]->GetBodyForces();
103  vTotalMoments += Cells[i]->GetMoments();
104  }
105 
106  RunPostFunctions();
107 
108  return false;
109 }
double GetDeltaT(void) const
Returns the simulation delta T.
Definition: FGFDMExec.h:547
virtual bool Run(bool Holding)
Runs the model; called by the Executive.
Definition: FGModel.cpp:89
+ Here is the call graph for this function:

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