JSBSim Flight Dynamics Model 1.3.3 (16 Oct 2026)
An Open Source Flight Dynamics and Control Software Library in C++
Loading...
Searching...
No Matches
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.
 
 ~FGBuoyantForces () override
 Destructor.
 
std::string GetBuoyancyStrings (const std::string &delimeter)
 Gets the strings for the current set of gas cells.
 
std::string GetBuoyancyValues (const std::string &delimeter)
 Gets the coefficient values.
 
double GetForces (int idx) const
 Gets a component of the total Buoyant force vector.
 
const FGColumnVector3 & GetForces (void) const
 Gets the total Buoyant force vector.
 
double GetGasMass (void) const
 Gets the total gas mass.
 
const FGMatrix33 & GetGasMassInertia (void)
 Gets the total moments of inertia for the gas mass in the body frame.
 
const FGColumnVector3 & GetGasMassMoment (void)
 Gets the total moment from the gas mass.
 
double GetMoments (int idx) const
 Gets a component of the total Buoyancy moment vector.
 
const FGColumnVector3 & GetMoments (void) const
 Gets the total Buoyancy moment vector.
 
bool InitModel (void) override
 
bool Load (Element *element) override
 Loads the Buoyant forces model.
 
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.
 
- Public Member Functions inherited from FGModel
 FGModel (FGFDMExec *, const std::string &name)
 Constructor.
 
 ~FGModel () override
 Destructor.
 
virtual SGPath FindFullPathName (const SGPath &path) const
 
FGFDMExec * GetExec (void) const
 
const std::string & GetName (void) const
 
unsigned int GetRate (void) const
 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.
 
std::string GetFunctionValues (const std::string &delimeter) const
 Gets the function values.
 
std::shared_ptr< FGFunction > GetPreFunction (const std::string &name)
 Get one of the "pre" function.
 
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.
 

Public Attributes

FGGasCell::Inputs in
 

Additional Inherited Members

- Public Types inherited from FGJSBBase
enum  { eL = 1 , eM , eN }
 Moments L, M, N. More...
 
enum  { eP = 1 , eQ , eR }
 Rates P, Q, R. More...
 
enum  { eU = 1 , eV , eW }
 Velocities U, V, W. More...
 
enum  { eX = 1 , eY , eZ }
 Positions X, Y, Z. More...
 
enum  { ePhi = 1 , eTht , ePsi }
 Euler angles Phi, Theta, Psi. More...
 
enum  { eDrag = 1 , eSide , eLift }
 Stability axis forces, Drag, Side force, Lift. More...
 
enum  { eRoll = 1 , ePitch , eYaw }
 Local frame orientation Roll, Pitch, Yaw. More...
 
enum  { eNorth = 1 , eEast , eDown }
 Local frame position North, East, Down. More...
 
enum  { eLat = 1 , eLong , eRad }
 Locations Radius, Latitude, Longitude. More...
 
enum  {
  inNone = 0 , inDegrees , inRadians , inMeters ,
  inFeet
}
 Conversion specifiers. More...
 
- Static Public Member Functions inherited from FGJSBBase
static constexpr double CelsiusToFahrenheit (double celsius)
 Converts from degrees Celsius to degrees Fahrenheit.
 
static constexpr double CelsiusToKelvin (double celsius)
 Converts from degrees Celsius to degrees Kelvin.
 
static constexpr double CelsiusToRankine (double celsius)
 Converts from degrees Celsius to degrees Rankine.
 
static constexpr 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.
 
static bool EqualToRoundoff (double a, float b)
 Finite precision comparison.
 
static bool EqualToRoundoff (float a, double b)
 Finite precision comparison.
 
static bool EqualToRoundoff (float a, float b)
 Finite precision comparison.
 
static constexpr double FahrenheitToCelsius (double fahrenheit)
 Converts from degrees Fahrenheit to degrees Celsius.
 
static constexpr double FeetToMeters (double measure)
 Converts from feet to meters.
 
static const std::string & GetVersion (void)
 Returns the version number of JSBSim.
 
static constexpr double KelvinToCelsius (double kelvin)
 Converts from degrees Kelvin to degrees Celsius.
 
static constexpr double KelvinToFahrenheit (double kelvin)
 Converts from degrees Kelvin to degrees Fahrenheit.
 
static constexpr double KelvinToRankine (double kelvin)
 Converts from degrees Kelvin to degrees Rankine.
 
static constexpr double RankineToCelsius (double rankine)
 Converts from degrees Rankine to degrees Celsius.
 
static constexpr double RankineToKelvin (double rankine)
 Converts from degrees Rankine to degrees Kelvin.
 
static constexpr double sign (double num)
 
- Static Public Attributes inherited from FGJSBBase
static short debug_lvl = 1
 
- Protected Member Functions inherited from FGModel
bool Upload (Element *el, bool preLoad)
 Uploads this model in memory.
 
- Static Protected Member Functions inherited from FGJSBBase
static std::string CreateIndexedPropertyName (const std::string &Property, int index)
 
- Protected Attributes inherited from FGModel
bool enabled = true
 
unsigned int exe_ctr
 
FGFDMExec * FDMExec
 
std::string Name
 
std::shared_ptr< FGPropertyManager > PropertyManager
 
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 degtorad = M_PI / 180.
 
static constexpr double fpstokts = 1.0 / ktstofps
 
static constexpr double fttom = 0.3048
 
static constexpr double hptoftlbssec = 550.0
 
static constexpr double in3tom3 = inchtoft*inchtoft*inchtoft/m3toft3
 
static constexpr double inchtoft = 1.0/12.0
 
static constexpr double inhgtopa = 3386.38
 
static const std::string JSBSim_version = JSBSIM_VERSION " " __DATE__ " " __TIME__
 
static constexpr double kgtolb = 2.20462
 
static constexpr double kgtoslug = 0.06852168
 
static constexpr double ktstofps = 1852./(3600*fttom)
 
static constexpr double lbtoslug = 1.0/slugtolb
 
static constexpr double m3toft3 = 1.0/(fttom*fttom*fttom)
 
static const std::string needed_cfg_version = "2.0"
 
static constexpr double psftoinhg = 0.014138
 
static constexpr double psftopa = 47.88
 
static constexpr double radtodeg = 180. / M_PI
 
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.
 

Constructor & Destructor Documentation

◆ FGBuoyantForces()

FGBuoyantForces ( FGFDMExec *  Executive)

Constructor.

Parameters
Executivea pointer to the parent executive object

Definition at line 52 of file FGBuoyantForces.cpp.

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

◆ ~FGBuoyantForces()

~FGBuoyantForces ( )
override

Destructor.

Definition at line 66 of file FGBuoyantForces.cpp.

67{
68 for (unsigned int i=0; i<Cells.size(); i++) delete Cells[i];
69 Cells.clear();
70
71 Debug(1);
72}

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 181 of file FGBuoyantForces.cpp.

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

◆ 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 211 of file FGBuoyantForces.cpp.

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

◆ 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 140 of file FGBuoyantForces.cpp.

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

◆ 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 164 of file FGBuoyantForces.cpp.

165{
166 size_t size = Cells.size();
167
168 if (size == 0) return gasCellJ;
169
170 gasCellJ.InitMatrix();
171
172 for (unsigned int i=0; i < size; i++) {
173 gasCellJ += Cells[i]->GetInertia();
174 }
175
176 return gasCellJ;
177}
+ 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 153 of file FGBuoyantForces.cpp.

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

◆ 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;}

◆ InitModel()

bool InitModel ( void  )
overridevirtual

Reimplemented from FGModelFunctions.

Definition at line 76 of file FGBuoyantForces.cpp.

77{
78 if (!FGModel::InitModel()) return false;
79
80 vTotalForces.InitMatrix();
81 vTotalMoments.InitMatrix();
82
83 return true;
84}

◆ 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 112 of file FGBuoyantForces.cpp.

113{
114 Element *gas_cell_element;
115
116 Debug(2);
117
118 // Perform base class Pre-Load
119 if (!FGModel::Upload(document, true))
120 return false;
121
122 gas_cell_element = document->FindElement("gas_cell");
123 while (gas_cell_element) {
124 NoneDefined = false;
125 Cells.push_back(new FGGasCell(FDMExec, gas_cell_element, Cells.size(), in));
126 gas_cell_element = document->FindNextElement("gas_cell");
127 }
128
129 PostLoad(document, FDMExec);
130
131 if (!NoneDefined) {
132 bind();
133 }
134
135 return true;
136}
bool Upload(Element *el, bool preLoad)
Uploads this model in memory.
Definition FGModel.cpp:123
+ 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 88 of file FGBuoyantForces.cpp.

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

Member Data Documentation

◆ in

Definition at line 167 of file FGBuoyantForces.h.


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