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
FGMassBalance Class Reference

Detailed Description

Models weight, balance and moment of inertia information.

Maintains a vector of point masses. Sums the contribution of all, and provides this to FGPropagate. Loads the <mass_balance> section of the aircraft configuration file. There can be any number of <pointmasses>. Each can also have a shape which - if present - causes an associated moment of inertia to be calculated based on the shape. Note that a cylinder is solid, a tube is hollow, a ball is solid and a sphere is hollow.

The inertia tensor must be specified in the structural frame (x axis positive aft, y axis positive out of the right wing and z axis upward). The sign of the inertia cross products are optional by JSBSim. if negated_crossproduct_inertia == "true", then define: ixy = -integral( x * y * dm ), ixz = -integral( x * z * dm ), iyz = -integral( y * z * dm ). else if negated_crossproduct_inertia == "false", then define: ixy = integral( x * y * dm ), ixz = integral( x * z * dm ), iyz = integral( y * z * dm ). default is negated_crossproduct_inertia = "true". We strongly recommend defining negated_crossproduct_inertia = "false", which is consistent with the specifications in the field of flight dynamics.

Configuration File Format for <mass_balance> Section:

<mass_balance negated_crossproduct_inertia="true|false">
<ixx unit="{SLUG*FT2 | KG*M2}"> {number} </ixx>
<iyy unit="{SLUG*FT2 | KG*M2}"> {number} </iyy>
<izz unit="{SLUG*FT2 | KG*M2}"> {number} </izz>
<ixy unit="{SLUG*FT2 | KG*M2}"> {number} </ixy>
<ixz unit="{SLUG*FT2 | KG*M2}"> {number} </ixz>
<iyz unit="{SLUG*FT2 | KG*M2}"> {number} </iyz>
<emptywt unit="{LBS | KG"> {number} </emptywt>
<location name="CG" unit="{IN | FT | M}">
<x> {number} </x>
<y> {number} </y>
<z> {number} </z>
</location>
[<pointmass name="{string}">
<form shape="{tube | cylinder | sphere | ball}">
<radius unit="{IN | FT | M}"> {number} </radius>
<length unit="{IN | FT | M}"> {number} </length>
</form>
<weight unit="{LBS | KG}"> {number} </weight>
<location name="{string}" unit="{IN | FT | M}">
<x> {number} </x>
<y> {number} </y>
<z> {number} </z>
</location>
</pointmass>
... other point masses ...]
</mass_balance>
@see Stevens and Lewis, "Flight Control & Simulation"
@see Bernard Etkin, " Dynamics Of Atmosferic Flight"
@see https://en.wikipedia.org/wiki/Moment_of_inertia#Inertia_tensor
@see https://www.mathworks.com/help/physmod/sm/ug/specify-custom-inertia.html

Definition at line 124 of file FGMassBalance.h.

#include <FGMassBalance.h>

+ Inheritance diagram for FGMassBalance:
+ Collaboration diagram for FGMassBalance:

Classes

struct  Inputs
 

Public Member Functions

 FGMassBalance (FGFDMExec *)
 
void AddPointMass (Element *el)
 
double GetDeltaXYZcg (int axis) const
 
const FGColumnVector3 & GetDeltaXYZcg (void) const
 
double GetEmptyWeight (void) const
 
const FGMatrix33 & GetJ (void) const
 Returns the inertia matrix expressed in the body frame.
 
const FGMatrix33 & GetJinv (void) const
 Returns the inverse of the inertia matrix expressed in the body frame.
 
double GetMass (void) const
 
void GetMassPropertiesReport (int i)
 
FGMatrix33 GetPointmassInertia (double mass_sl, const FGColumnVector3 &r) const
 Computes the inertia contribution of a pointmass.
 
const FGColumnVector3 & GetPointMassMoment (void)
 
double GetTotalPointMassWeight (void) const
 
double GetWeight (void) const
 
double GetXYZcg (int axis) const
 
const FGColumnVector3 & GetXYZcg (void) const
 Returns the coordinates of the center of gravity expressed in the structural frame.
 
bool InitModel (void) override
 
bool Load (Element *el) override
 
bool Run (bool Holding) override
 Runs the Mass Balance model; called by the Executive Can pass in a value indicating if the executive is directing the simulation to Hold.
 
void SetAircraftBaseInertias (const FGMatrix33 &BaseJ)
 
void SetBaseCG (const FGColumnVector3 &CG)
 
void SetEmptyWeight (double EW)
 
FGColumnVector3 StructuralToBody (const FGColumnVector3 &r) const
 Conversion from the structural frame to the body frame.
 
- 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

struct JSBSim::FGMassBalance::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

◆ FGMassBalance()

FGMassBalance ( FGFDMExec *  fdmex)
explicit

Definition at line 59 of file FGMassBalance.cpp.

60 : FGModel(fdmex, "FGMassBalance")
61{
62 Weight = EmptyWeight = Mass = 0.0;
63
64 vbaseXYZcg.InitMatrix();
65 vXYZcg.InitMatrix();
66 vLastXYZcg.InitMatrix();
67 vDeltaXYZcg.InitMatrix();
68 baseJ.InitMatrix();
69 mJ.InitMatrix();
70 mJinv.InitMatrix();
71 pmJ.InitMatrix();
72 Propagate = fdmex->GetPropagate();
73
74 bind();
75
76 Debug(0);
77}
void InitMatrix(void)
Initialize the matrix.
FGModel(FGFDMExec *, const std::string &name)
Constructor.
Definition FGModel.cpp:59

◆ ~FGMassBalance()

Definition at line 81 of file FGMassBalance.cpp.

82{
83 for(auto pm: PointMasses) delete pm;
84
85 Debug(1);
86}

Member Function Documentation

◆ AddPointMass()

void AddPointMass ( Element *  el)

Definition at line 269 of file FGMassBalance.cpp.

270{
271 Element* loc_element = el->FindElement("location");
272 string pointmass_name = el->GetAttributeValue("name");
273 if (!loc_element) {
274 XMLLogException err(el);
275 err << "Pointmass " << pointmass_name << " has no location." << endl;
276 throw err;
277 }
278
279 double w = el->FindElementValueAsNumberConvertTo("weight", "LBS");
280 FGColumnVector3 vXYZ = loc_element->FindElementTripletConvertTo("IN");
281
282 PointMass *pm = new PointMass(w, vXYZ);
283 pm->SetName(pointmass_name);
284
285 Element* form_element = el->FindElement("form");
286 if (form_element) {
287 double radius=0, length=0;
288 string shape = form_element->GetAttributeValue("shape");
289 Element* radius_element = form_element->FindElement("radius");
290 Element* length_element = form_element->FindElement("length");
291 if (radius_element) radius = form_element->FindElementValueAsNumberConvertTo("radius", "FT");
292 if (length_element) length = form_element->FindElementValueAsNumberConvertTo("length", "FT");
293 if (shape == "tube") {
294 pm->SetPointMassShapeType(PointMass::esTube);
295 pm->SetRadius(radius);
296 pm->SetLength(length);
297 pm->CalculateShapeInertia();
298 } else if (shape == "cylinder") {
299 pm->SetPointMassShapeType(PointMass::esCylinder);
300 pm->SetRadius(radius);
301 pm->SetLength(length);
302 pm->CalculateShapeInertia();
303 } else if (shape == "sphere") {
304 pm->SetPointMassShapeType(PointMass::esSphere);
305 pm->SetRadius(radius);
306 pm->CalculateShapeInertia();
307 } else if (shape == "ball") {
308 pm->SetPointMassShapeType(PointMass::esBall);
309 pm->SetRadius(radius);
310 pm->CalculateShapeInertia();
311 } else {
312 }
313 }
314 else {
315 pm->SetPointMassShapeType(PointMass::esUnspecified);
316 pm->SetPointMassMoI(ReadInertiaMatrix(el));
317 }
318
319 pm->bind(PropertyManager.get(), PointMasses.size());
320 PointMasses.push_back(pm);
321}

◆ GetDeltaXYZcg() [1/2]

double GetDeltaXYZcg ( int  axis) const
inline

Definition at line 151 of file FGMassBalance.h.

151{return vDeltaXYZcg(axis);}

◆ GetDeltaXYZcg() [2/2]

const FGColumnVector3 & GetDeltaXYZcg ( void  ) const
inline

Definition at line 150 of file FGMassBalance.h.

150{return vDeltaXYZcg;}

◆ GetEmptyWeight()

double GetEmptyWeight ( void  ) const
inline

Definition at line 145 of file FGMassBalance.h.

145{return EmptyWeight;}

◆ GetJ()

const FGMatrix33 & GetJ ( void  ) const
inline

Returns the inertia matrix expressed in the body frame.

Definition at line 195 of file FGMassBalance.h.

195{return mJ;}

◆ GetJinv()

const FGMatrix33 & GetJinv ( void  ) const
inline

Returns the inverse of the inertia matrix expressed in the body frame.

Definition at line 197 of file FGMassBalance.h.

197{return mJinv;}

◆ GetMass()

double GetMass ( void  ) const
inline

Definition at line 143 of file FGMassBalance.h.

143{return Mass;}

◆ GetMassPropertiesReport()

void GetMassPropertiesReport ( int  i)

Definition at line 439 of file FGMassBalance.cpp.

440{
441 FGLogging out(LogLevel::STDOUT);
442 out << endl << LogFormat::BLUE << LogFormat::BOLD
443 << " Mass Properties Report (English units: lb, in, slug-ft^2)"
444 << LogFormat::RESET << endl;
445 out << " " << LogFormat::UNDERLINE_ON << " Mass CG-X CG-Y"
446 << " CG-Z Ixx Iyy Izz"
447 << " Ixy Ixz Iyz" << LogFormat::UNDERLINE_OFF << endl;
448 out << fixed << setprecision(1);
449 out << setw(34) << left << " Base Vehicle " << right << setw(12) << EmptyWeight
450 << setw(8) << vbaseXYZcg(eX) << setw(8) << vbaseXYZcg(eY) << setw(8) << vbaseXYZcg(eZ)
451 << setw(12) << baseJ(1,1) << setw(12) << baseJ(2,2) << setw(12) << baseJ(3,3)
452 << setw(12) << baseJ(1,2) << setw(12) << baseJ(1,3) << setw(12) << baseJ(2,3) << endl;
453
454 for (unsigned int i=0;i<PointMasses.size();i++) {
455 PointMass* pm = PointMasses[i];
456 double pmweight = pm->GetPointMassWeight();
457 out << left << setw(4) << i << setw(30) << pm->GetName()
458 << right << setw(12) << pmweight << setw(8) << pm->GetLocation()(eX)
459 << setw(8) << pm->GetLocation()(eY) << setw(8) << pm->GetLocation()(eZ)
460 << setw(12) << pm->GetPointMassMoI(1,1) << setw(12) << pm->GetPointMassMoI(2,2) << setw(12) << pm->GetPointMassMoI(3,3)
461 << setw(12) << pm->GetPointMassMoI(1,2) << setw(12) << pm->GetPointMassMoI(1,3) << setw(12) << pm->GetPointMassMoI(2,3) << endl;
462 }
463
464 const string tank_report = FDMExec->GetPropulsionTankReport();
465
466 if (!tank_report.empty()) {
467 out << "\n " << setw(34) << left << LogFormat::UNDERLINE_ON << LogFormat::BOLD
468 << "Tanks Content" << LogFormat::RESET << endl
469 << tank_report;
470 }
471
472 out << " " << LogFormat::UNDERLINE_ON << setw(136) << " " << LogFormat::UNDERLINE_OFF << endl;
473 out << LogFormat::BOLD << left << setw(34) << " Total: " << right << setw(12) << Weight
474 << setw(8) << vXYZcg(eX)
475 << setw(8) << vXYZcg(eY)
476 << setw(8) << vXYZcg(eZ)
477 << setw(12) << mJ(1,1)
478 << setw(12) << mJ(2,2)
479 << setw(12) << mJ(3,3)
480 << setw(12) << mJ(1,2)
481 << setw(12) << mJ(1,3)
482 << setw(12) << mJ(2,3)
483 << LogFormat::NORMAL << endl;
484}

◆ GetPointmassInertia()

FGMatrix33 GetPointmassInertia ( double  mass_sl,
const FGColumnVector3 &  r 
) const
inline

Computes the inertia contribution of a pointmass.

Computes and returns the inertia matrix of a pointmass of mass slugs at the given vector r in the structural frame. The units should be for the mass in slug and the vector in the structural frame as usual in inches.

Parameters
mass_slthe mass of this single pointmass given in slugs
rthe location of this single pointmass in the structural frame

Definition at line 161 of file FGMassBalance.h.

162 {
163 FGColumnVector3 v = StructuralToBody( r );
164 FGColumnVector3 sv = mass_sl*v;
165 double xx = sv(1)*v(1);
166 double yy = sv(2)*v(2);
167 double zz = sv(3)*v(3);
168 double xy = -sv(1)*v(2);
169 double xz = -sv(1)*v(3);
170 double yz = -sv(2)*v(3);
171 return FGMatrix33( yy+zz, xy, xz,
172 xy, xx+zz, yz,
173 xz, yz, xx+yy );
174 }
FGColumnVector3 StructuralToBody(const FGColumnVector3 &r) const
Conversion from the structural frame to the body frame.

◆ GetPointMassMoment()

const FGColumnVector3 & GetPointMassMoment ( void  )

Definition at line 337 of file FGMassBalance.cpp.

338{
339 PointMassCG.InitMatrix();
340
341 for (auto pm: PointMasses)
342 PointMassCG += pm->Weight * pm->Location;
343
344 return PointMassCG;
345}

◆ GetTotalPointMassWeight()

double GetTotalPointMassWeight ( void  ) const

Definition at line 325 of file FGMassBalance.cpp.

326{
327 double PM_total_weight = 0.0;
328
329 for(auto pm: PointMasses)
330 PM_total_weight += pm->Weight;
331
332 return PM_total_weight;
333}

◆ GetWeight()

double GetWeight ( void  ) const
inline

Definition at line 144 of file FGMassBalance.h.

144{return Weight;}

◆ GetXYZcg() [1/2]

double GetXYZcg ( int  axis) const
inline

Definition at line 149 of file FGMassBalance.h.

149{return vXYZcg(axis);}

◆ GetXYZcg() [2/2]

const FGColumnVector3 & GetXYZcg ( void  ) const
inline

Returns the coordinates of the center of gravity expressed in the structural frame.

Definition at line 148 of file FGMassBalance.h.

148{return vXYZcg;}

◆ InitModel()

bool InitModel ( void  )
overridevirtual

Reimplemented from FGModelFunctions.

Definition at line 90 of file FGMassBalance.cpp.

91{
92 if (!FGModel::InitModel()) return false;
93
94 // No CG seen yet. Not zero: a CG at the origin of the structural frame is valid.
95 vLastXYZcg.InitMatrix(std::numeric_limits<double>::quiet_NaN());
96 vDeltaXYZcg.InitMatrix();
97
98 return true;
99}

◆ Load()

bool Load ( Element *  el)
overridevirtual

Reimplemented from FGModel.

Definition at line 135 of file FGMassBalance.cpp.

136{
137 string element_name = "";
138
139 Name = "Mass Properties Model: " + document->GetAttributeValue("name");
140
141 // Perform base class Pre-Load
142 if (!FGModel::Upload(document, true))
143 return false;
144
145 SetAircraftBaseInertias(ReadInertiaMatrix(document));
146 if (document->FindElement("emptywt")) {
147 EmptyWeight = document->FindElementValueAsNumberConvertTo("emptywt", "LBS");
148 }
149
150 Element *element = document->FindElement("location");
151 while (element) {
152 element_name = element->GetAttributeValue("name");
153 if (element_name == "CG") vbaseXYZcg = element->FindElementTripletConvertTo("IN");
154 element = document->FindNextElement("location");
155 }
156
157// Find all POINTMASS elements that descend from this METRICS branch of the
158// config file.
159
160 element = document->FindElement("pointmass");
161 while (element) {
162 AddPointMass(element);
163 element = document->FindNextElement("pointmass");
164 }
165
166 double ChildFDMWeight = 0.0;
167 for (size_t fdm=0; fdm<FDMExec->GetFDMCount(); fdm++) {
168 if (FDMExec->GetChildFDM(fdm)->mated) ChildFDMWeight += FDMExec->GetChildFDM(fdm)->exec->GetMassBalance()->GetWeight();
169 }
170
171 Weight = EmptyWeight + in.TanksWeight + GetTotalPointMassWeight()
172 + in.GasMass*slugtolb + ChildFDMWeight;
173
174 Mass = lbtoslug*Weight;
175
176 PostLoad(document, FDMExec);
177
178 Debug(2);
179 return true;
180}
size_t GetFDMCount(void) const
Gets the number of child FDMs.
Definition FGFDMExec.h:426
auto GetChildFDM(int i) const
Gets a particular child FDM.
Definition FGFDMExec.h:428
static constexpr double slugtolb
Note that definition of lbtoslug by the inverse of slugtolb and not to a different constant you can a...
Definition FGJSBBase.h:283
bool Upload(Element *el, bool preLoad)
Uploads this model in memory.
Definition FGModel.cpp:123

◆ Run()

bool Run ( bool  Holding)
overridevirtual

Runs the Mass Balance 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 184 of file FGMassBalance.cpp.

185{
186 double denom, k1, k2, k3, k4, k5, k6;
187 double Ixx, Iyy, Izz, Ixy, Ixz, Iyz;
188
189 if (FGModel::Run(Holding)) return true;
190 if (Holding) return false;
191
192 RunPreFunctions();
193
194 double ChildFDMWeight = 0.0;
195 for (size_t fdm=0; fdm<FDMExec->GetFDMCount(); fdm++) {
196 if (FDMExec->GetChildFDM(fdm)->mated) ChildFDMWeight += FDMExec->GetChildFDM(fdm)->exec->GetMassBalance()->GetWeight();
197 }
198
199 Weight = EmptyWeight + in.TanksWeight + GetTotalPointMassWeight()
200 + in.GasMass*slugtolb + ChildFDMWeight;
201
202 Mass = lbtoslug*Weight;
203
204// Calculate new CG
205
206 vXYZcg = (EmptyWeight*vbaseXYZcg
207 + GetPointMassMoment()
208 + in.TanksMoment
209 + in.GasMoment) / Weight;
210
211 // Track frame-by-frame delta CG, and move the EOM-tracked location
212 // by this amount.
213 if (std::isnan(vLastXYZcg(eX))) vLastXYZcg = vXYZcg;
214 vDeltaXYZcg = vXYZcg - vLastXYZcg;
215 vDeltaXYZcgBody = StructuralToBody(vLastXYZcg) - StructuralToBody(vXYZcg);
216 vLastXYZcg = vXYZcg;
217
218 // Compensate displacements of the structural frame when the mass distribution
219 // is modified while the aircraft is in contact with the ground.
220 if (FDMExec->GetHoldDown() || in.WOW)
221 Propagate->NudgeBodyLocation(vDeltaXYZcgBody);
222
223// Calculate new total moments of inertia
224
225 // At first it is the base configuration inertia matrix ...
226 mJ = baseJ;
227 // ... with the additional term originating from the parallel axis theorem.
228 mJ += GetPointmassInertia( lbtoslug * EmptyWeight, vbaseXYZcg );
229 // Then add the contributions from the additional pointmasses.
230 mJ += CalculatePMInertias();
231 mJ += in.TankInertia;
232 mJ += in.GasInertia;
233
234 Ixx = mJ(1,1);
235 Iyy = mJ(2,2);
236 Izz = mJ(3,3);
237 Ixy = -mJ(1,2);
238 Ixz = -mJ(1,3);
239 Iyz = -mJ(2,3);
240
241// Calculate inertia matrix inverse (ref. Stevens and Lewis, "Flight Control &
242// Simulation")
243
244 k1 = (Iyy*Izz - Iyz*Iyz);
245 k2 = (Iyz*Ixz + Ixy*Izz);
246 k3 = (Ixy*Iyz + Iyy*Ixz);
247
248 denom = 1.0/(Ixx*k1 - Ixy*k2 - Ixz*k3 );
249 k1 = k1*denom;
250 k2 = k2*denom;
251 k3 = k3*denom;
252 k4 = (Izz*Ixx - Ixz*Ixz)*denom;
253 k5 = (Ixy*Ixz + Iyz*Ixx)*denom;
254 k6 = (Ixx*Iyy - Ixy*Ixy)*denom;
255
256 mJinv = { k1, k2, k3,
257 k2, k4, k5,
258 k3, k5, k6 };
259
260 RunPostFunctions();
261
262 Debug(0);
263
264 return false;
265}
bool GetHoldDown(void) const
Gets the value of the property forces/hold-down.
Definition FGFDMExec.h:621
FGMatrix33 GetPointmassInertia(double mass_sl, const FGColumnVector3 &r) const
Computes the inertia contribution of a pointmass.
virtual bool Run(bool Holding)
Runs the model; called by the Executive.
Definition FGModel.cpp:101
+ Here is the call graph for this function:

◆ SetAircraftBaseInertias()

void SetAircraftBaseInertias ( const FGMatrix33 &  BaseJ)
inline

Definition at line 198 of file FGMassBalance.h.

198{baseJ = BaseJ;}

◆ SetBaseCG()

void SetBaseCG ( const FGColumnVector3 &  CG)
inline

Definition at line 188 of file FGMassBalance.h.

188{vbaseXYZcg = vXYZcg = CG;}

◆ SetEmptyWeight()

void SetEmptyWeight ( double  EW)
inline

Definition at line 187 of file FGMassBalance.h.

187{ EmptyWeight = EW;}

◆ StructuralToBody()

FGColumnVector3 StructuralToBody ( const FGColumnVector3 &  r) const

Conversion from the structural frame to the body frame.

Converts the location given in the structural frame coordinate system to the body frame. The units of the structural frame are assumed to be in inches. The unit of the result is in ft.

Parameters
rvector coordinate in the structural reference frame (X positive aft, measurements in inches).
Returns
vector coordinate in the body frame, in feet.

Definition at line 365 of file FGMassBalance.cpp.

366{
367 // Under the assumption that in the structural frame the:
368 //
369 // - X-axis is directed afterwards,
370 // - Y-axis is directed towards the right,
371 // - Z-axis is directed upwards,
372 //
373 // (as documented in http://jsbsim.sourceforge.net/JSBSimCoordinates.pdf)
374 // we have to subtract first the center of gravity of the plane which
375 // is also defined in the structural frame:
376 //
377 // FGColumnVector3 cgOff = r - vXYZcg;
378 //
379 // Next, we do a change of units:
380 //
381 // cgOff *= inchtoft;
382 //
383 // And then a 180 degree rotation is done about the Y axis so that the:
384 //
385 // - X-axis is directed forward,
386 // - Y-axis is directed towards the right,
387 // - Z-axis is directed downward.
388 //
389 // This is needed because the structural and body frames are 180 degrees apart.
390
391 return FGColumnVector3(inchtoft*(vXYZcg(1)-r(1)),
392 inchtoft*(r(2)-vXYZcg(2)),
393 inchtoft*(vXYZcg(3)-r(3)));
394}

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