JSBSim Flight Dynamics Model 1.3.0 (09 Apr 2026)
An Open Source Flight Dynamics and Control Software Library in C++
Loading...
Searching...
No Matches
FGAerodynamics Class Reference

Detailed Description

Encapsulates the aerodynamic calculations.

This class owns and contains the list of force/coefficients that define the aerodynamic properties of an aircraft. Here also, such unique phenomena as ground effect, aerodynamic reference point shift, and maximum lift curve tailoff are handled.

Configuration File Format for <aerodynamics> Section:

<aerodynamics>
<alphalimits unit="{RAD | DEG}">
<min> {number} </min>
<max> {number} </max>
</alphalimits>
<hysteresis_limits unit="{RAD | DEG}">
<min> {number} </min>
<max> {number} </max>
</hysteresis_limits>
<aero_ref_pt_shift_x>
<function>
{function contents}
</function>
</aero_ref_pt_shift_x>
<function>
{function contents}
</function>
<axis name="{LIFT | DRAG | SIDE | ROLL | PITCH | YAW}">
{force or moment definitions}
</axis>
{additional axis definitions}
</aerodynamics>

Optionally two other coordinate systems may be used.

1) Body coordinate system:

<axis name="{X | Y | Z}">


2) Axial-Normal coordinate system:

<axis name="{AXIAL | NORMAL | SIDE}">


Systems may NOT be combined, or a load error will occur.

Author
Jon S. Berndt, Tony Peden
Version
Revision
1.30

Definition at line 113 of file FGAerodynamics.h.

#include <FGAerodynamics.h>

+ Inheritance diagram for FGAerodynamics:
+ Collaboration diagram for FGAerodynamics:

Classes

struct  Inputs
 

Public Member Functions

 FGAerodynamics (FGFDMExec *Executive)
 Constructor.
 
 ~FGAerodynamics () override
 Destructor.
 
std::vector< FGFunction * > * GetAeroFunctions (void) const
 
std::string GetAeroFunctionStrings (const std::string &delimeter) const
 Gets the strings for the current set of aero functions.
 
std::string GetAeroFunctionValues (const std::string &delimeter) const
 Gets the aero function values.
 
double GetAlphaCLMax (void) const
 
double GetAlphaCLMin (void) const
 
double GetAlphaW (void) const
 
double GetBI2Vel (void) const
 
double GetCI2Vel (void) const
 
double GetClSquared (void) const
 Retrieves the square of the lift coefficient.
 
double GetForces (int n) const
 Gets the aerodynamic force for an axis.
 
const FGColumnVector3GetForces (void) const
 Gets the total aerodynamic force vector.
 
double GetForcesInStabilityAxes (int n) const
 Retrieves the aerodynamic forces in the stability axes, given an axis.
 
FGColumnVector3 GetForcesInStabilityAxes (void) const
 Retrieves the aerodynamic forces in the stability axes.
 
double GetHysteresisParm (void) const
 
double GetLoD (void) const
 Retrieves the lift over drag ratio.
 
double GetMoments (int n) const
 Gets the aerodynamic moment about the CG for an axis.
 
const FGColumnVector3GetMoments (void) const
 Gets the total aerodynamic moment vector about the CG.
 
double GetMomentsInStabilityAxes (int n) const
 Gets the aerodynamic moment about the CG for an axis.
 
FGColumnVector3 GetMomentsInStabilityAxes (void) const
 Gets the total aerodynamic moment vector about the CG in the stability axes.
 
double GetMomentsInWindAxes (int n) const
 Gets the aerodynamic moment about the CG for an axis.
 
FGColumnVector3 GetMomentsInWindAxes (void) const
 Gets the total aerodynamic moment vector about the CG in the wind axes.
 
double GetMomentsMRC (int n) const
 Gets the aerodynamic moment about the Moment Reference Center for an axis.
 
const FGColumnVector3GetMomentsMRC (void) const
 Gets the total aerodynamic moment vector about the Moment Reference Center.
 
double GetStallWarn (void) const
 
double GetvFw (int axis) const
 Retrieves the aerodynamic forces in the wind axes, given an axis.
 
const FGColumnVector3GetvFw (void) const
 Retrieves the aerodynamic forces in the wind axes.
 
bool InitModel (void) override
 
bool Load (Element *element) override
 Loads the Aerodynamics model.
 
bool Run (bool Holding) override
 Runs the Aerodynamics model; called by the Executive Can pass in a value indicating if the executive is directing the simulation to Hold.
 
void SetAlphaCLMax (double tt)
 
void SetAlphaCLMin (double tt)
 
- Public Member Functions inherited from FGModel
 FGModel (FGFDMExec *)
 Constructor.
 
 ~FGModel () override
 Destructor.
 
virtual SGPath FindFullPathName (const SGPath &path) const
 
FGFDMExecGetExec (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< FGFunctionGetPreFunction (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.
 
void disableHighLighting (void)
 Disables highlighting in the console output.
 

Public Attributes

struct JSBSim::FGAerodynamics::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 const std::string & GetVersion (void)
 Returns the version number of JSBSim.
 
static constexpr double KelvinToFahrenheit (double kelvin)
 Converts from degrees Kelvin to degrees Fahrenheit.
 
static constexpr double CelsiusToRankine (double celsius)
 Converts from degrees Celsius to degrees Rankine.
 
static constexpr double RankineToCelsius (double rankine)
 Converts from degrees Rankine to degrees Celsius.
 
static constexpr double KelvinToRankine (double kelvin)
 Converts from degrees Kelvin to degrees Rankine.
 
static constexpr double RankineToKelvin (double rankine)
 Converts from degrees Rankine to degrees Kelvin.
 
static constexpr double FahrenheitToCelsius (double fahrenheit)
 Converts from degrees Fahrenheit to degrees Celsius.
 
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 KelvinToCelsius (double kelvin)
 Converts from degrees Kelvin to degrees Celsius.
 
static constexpr double FeetToMeters (double measure)
 Converts from feet to meters.
 
static bool EqualToRoundoff (double a, double b)
 Finite precision comparison.
 
static bool EqualToRoundoff (float a, float b)
 Finite precision comparison.
 
static bool EqualToRoundoff (float a, double b)
 Finite precision comparison.
 
static bool EqualToRoundoff (double a, float b)
 Finite precision comparison.
 
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.
 
- 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< 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 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.
 
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

◆ FGAerodynamics()

FGAerodynamics ( FGFDMExec Executive)

Constructor.

Parameters
Executivea pointer to the parent executive object

Definition at line 53 of file FGAerodynamics.cpp.

53 : FGModel(FDMExec)
54{
55 Name = "FGAerodynamics";
56
57 AxisIdx["DRAG"] = 0;
58 AxisIdx["SIDE"] = 1;
59 AxisIdx["LIFT"] = 2;
60 AxisIdx["ROLL"] = 3;
61 AxisIdx["PITCH"] = 4;
62 AxisIdx["YAW"] = 5;
63
64 AxisIdx["AXIAL"] = 0;
65 AxisIdx["NORMAL"] = 2;
66
67 AxisIdx["X"] = 0;
68 AxisIdx["Y"] = 1;
69 AxisIdx["Z"] = 2;
70
71 forceAxisType = atNone;
72 momentAxisType = atNone;
73
74 AeroFunctions = new AeroFunctionArray[6];
75 AeroFunctionsAtCG = new AeroFunctionArray[6];
76
77 impending_stall = stall_hyst = 0.0;
78 alphaclmin = alphaclmax = 0.0;
79 alphaclmin0 = alphaclmax0 = 0.0;
80 alphahystmin = alphahystmax = 0.0;
81 clsq = lod = 0.0;
82 alphaw = 0.0;
83 bi2vel = ci2vel = 0.0;
84 AeroRPShift = 0;
85 vDeltaRP.InitMatrix();
86
87 bind();
88
89 Debug(0);
90}
FGModel(FGFDMExec *)
Constructor.
Definition FGModel.cpp:58

◆ ~FGAerodynamics()

~FGAerodynamics ( )
override

Destructor.

Definition at line 94 of file FGAerodynamics.cpp.

95{
96 unsigned int i,j;
97
98 for (i=0; i<6; i++)
99 for (j=0; j<AeroFunctions[i].size(); j++)
100 delete AeroFunctions[i][j];
101 for (i=0; i<6; i++)
102 for (j=0; j<AeroFunctionsAtCG[i].size(); j++)
103 delete AeroFunctionsAtCG[i][j];
104
105 delete[] AeroFunctions;
106 delete[] AeroFunctionsAtCG;
107
108 delete AeroRPShift;
109
110 Debug(1);
111}

Member Function Documentation

◆ GetAeroFunctions()

std::vector< FGFunction * > * GetAeroFunctions ( void  ) const
inline

Definition at line 236 of file FGAerodynamics.h.

236{ return AeroFunctions; }

◆ GetAeroFunctionStrings()

string GetAeroFunctionStrings ( const std::string &  delimeter) const

Gets the strings for the current set of aero functions.

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

Definition at line 535 of file FGAerodynamics.cpp.

536{
537 string AeroFunctionStrings = "";
538 bool firstime = true;
539 unsigned int axis, sd;
540
541 for (axis = 0; axis < 6; axis++) {
542 for (sd = 0; sd < AeroFunctions[axis].size(); sd++) {
543 if (firstime) {
544 firstime = false;
545 } else {
546 AeroFunctionStrings += delimeter;
547 }
548 AeroFunctionStrings += AeroFunctions[axis][sd]->GetName();
549 }
550 }
551
552 string FunctionStrings = FGModelFunctions::GetFunctionStrings(delimeter);
553
554 if (!FunctionStrings.empty()) {
555 if (!AeroFunctionStrings.empty()) {
556 AeroFunctionStrings += delimeter + FunctionStrings;
557 } else {
558 AeroFunctionStrings = FunctionStrings;
559 }
560 }
561
562 return AeroFunctionStrings;
563}
std::string GetFunctionStrings(const std::string &delimeter) const
Gets the strings for the current set of functions.
+ Here is the call graph for this function:

◆ GetAeroFunctionValues()

string GetAeroFunctionValues ( const std::string &  delimeter) const

Gets the aero function values.

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

Definition at line 567 of file FGAerodynamics.cpp.

568{
569 ostringstream buf;
570
571 for (unsigned int axis = 0; axis < 6; axis++) {
572 for (unsigned int sd = 0; sd < AeroFunctions[axis].size(); sd++) {
573 if (buf.tellp() > 0) buf << delimeter;
574 buf << AeroFunctions[axis][sd]->GetValue();
575 }
576 }
577
578 string FunctionValues = FGModelFunctions::GetFunctionValues(delimeter);
579
580 if (!FunctionValues.empty()) {
581 if (!buf.str().empty()) {
582 buf << delimeter << FunctionValues;
583 } else {
584 buf << FunctionValues;
585 }
586 }
587
588 return buf.str();
589}
std::string GetFunctionValues(const std::string &delimeter) const
Gets the function values.
+ Here is the call graph for this function:

◆ GetAlphaCLMax()

double GetAlphaCLMax ( void  ) const
inline

Definition at line 212 of file FGAerodynamics.h.

212{ return alphaclmax; }

◆ GetAlphaCLMin()

double GetAlphaCLMin ( void  ) const
inline

Definition at line 213 of file FGAerodynamics.h.

213{ return alphaclmin; }

◆ GetAlphaW()

double GetAlphaW ( void  ) const
inline

Definition at line 217 of file FGAerodynamics.h.

217{ return alphaw; }

◆ GetBI2Vel()

double GetBI2Vel ( void  ) const
inline

Definition at line 219 of file FGAerodynamics.h.

219{ return bi2vel; }

◆ GetCI2Vel()

double GetCI2Vel ( void  ) const
inline

Definition at line 220 of file FGAerodynamics.h.

220{ return ci2vel; }

◆ GetClSquared()

double GetClSquared ( void  ) const
inline

Retrieves the square of the lift coefficient.

Definition at line 211 of file FGAerodynamics.h.

211{ return clsq; }

◆ GetForces() [1/2]

double GetForces ( int  n) const
inline

Gets the aerodynamic force for an axis.

Parameters
nAxis index. This could be 0, 1, or 2, or one of the axis enums: eX, eY, eZ.
Returns
the force acting on an axis

Definition at line 149 of file FGAerodynamics.h.

149{return vForces(n);}

◆ GetForces() [2/2]

const FGColumnVector3 & GetForces ( void  ) const
inline

Gets the total aerodynamic force vector.

Returns
a force vector reference.

Definition at line 143 of file FGAerodynamics.h.

143{return vForces;}

◆ GetForcesInStabilityAxes() [1/2]

double GetForcesInStabilityAxes ( int  n) const
inline

Retrieves the aerodynamic forces in the stability axes, given an axis.

Parameters
axisthe axis to return the force for (eX, eY, eZ).
Returns
a reference to a column vector containing the requested stability axis force.

Definition at line 187 of file FGAerodynamics.h.

187{ return GetForcesInStabilityAxes()(n); }
FGColumnVector3 GetForcesInStabilityAxes(void) const
Retrieves the aerodynamic forces in the stability axes.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetForcesInStabilityAxes() [2/2]

FGColumnVector3 GetForcesInStabilityAxes ( void  ) const

Retrieves the aerodynamic forces in the stability axes.

Returns
a reference to a column vector containing the stability axis forces.

Definition at line 320 of file FGAerodynamics.cpp.

321{
322 FGColumnVector3 vFs = Tb2s*vForces;
323 // Need sign flips since drag is positive and lift is positive in stability axes
324 vFs(eDrag) *= -1; vFs(eLift) *= -1;
325
326 return vFs;
327}

◆ GetHysteresisParm()

double GetHysteresisParm ( void  ) const
inline

Definition at line 215 of file FGAerodynamics.h.

215{ return stall_hyst; }

◆ GetLoD()

double GetLoD ( void  ) const
inline

Retrieves the lift over drag ratio.

Definition at line 208 of file FGAerodynamics.h.

208{ return lod; }

◆ GetMoments() [1/2]

double GetMoments ( int  n) const
inline

Gets the aerodynamic moment about the CG for an axis.

Returns
the moment about a single axis (as described also in the similar call to GetForces(int n).

Definition at line 158 of file FGAerodynamics.h.

158{return vMoments(n);}

◆ GetMoments() [2/2]

const FGColumnVector3 & GetMoments ( void  ) const
inline

Gets the total aerodynamic moment vector about the CG.

Returns
a moment vector reference.

Definition at line 153 of file FGAerodynamics.h.

153{return vMoments;}

◆ GetMomentsInStabilityAxes() [1/2]

double GetMomentsInStabilityAxes ( int  n) const
inline

Gets the aerodynamic moment about the CG for an axis.

Returns
the moment about a single axis (as described also in the similar call to GetForces(int n).

Definition at line 196 of file FGAerodynamics.h.

196{ return GetMomentsInStabilityAxes()(n); }
FGColumnVector3 GetMomentsInStabilityAxes(void) const
Gets the total aerodynamic moment vector about the CG in the stability axes.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetMomentsInStabilityAxes() [2/2]

FGColumnVector3 GetMomentsInStabilityAxes ( void  ) const
inline

Gets the total aerodynamic moment vector about the CG in the stability axes.

Returns
a moment vector reference.

Definition at line 191 of file FGAerodynamics.h.

191{ return Tb2s*vMoments; }

◆ GetMomentsInWindAxes() [1/2]

double GetMomentsInWindAxes ( int  n) const
inline

Gets the aerodynamic moment about the CG for an axis.

Returns
the moment about a single axis (as described also in the similar call to GetForces(int n).

Definition at line 205 of file FGAerodynamics.h.

205{ return GetMomentsInWindAxes()(n); }
FGColumnVector3 GetMomentsInWindAxes(void) const
Gets the total aerodynamic moment vector about the CG in the wind axes.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetMomentsInWindAxes() [2/2]

FGColumnVector3 GetMomentsInWindAxes ( void  ) const
inline

Gets the total aerodynamic moment vector about the CG in the wind axes.

Returns
a moment vector reference.

Definition at line 200 of file FGAerodynamics.h.

200{ return in.Tb2w*vMoments; }

◆ GetMomentsMRC() [1/2]

double GetMomentsMRC ( int  n) const
inline

Gets the aerodynamic moment about the Moment Reference Center for an axis.

Returns
the moment about a single axis (as described also in the similar call to GetForces(int n).

Definition at line 167 of file FGAerodynamics.h.

167{return vMomentsMRC(n);}

◆ GetMomentsMRC() [2/2]

const FGColumnVector3 & GetMomentsMRC ( void  ) const
inline

Gets the total aerodynamic moment vector about the Moment Reference Center.

Returns
a moment vector reference.

Definition at line 162 of file FGAerodynamics.h.

162{return vMomentsMRC;}

◆ GetStallWarn()

double GetStallWarn ( void  ) const
inline

Definition at line 216 of file FGAerodynamics.h.

216{ return impending_stall; }

◆ GetvFw() [1/2]

double GetvFw ( int  axis) const
inline

Retrieves the aerodynamic forces in the wind axes, given an axis.

Parameters
axisthe axis to return the force for (eX, eY, eZ).
Returns
a reference to a column vector containing the requested wind axis force.

Definition at line 177 of file FGAerodynamics.h.

177{ return vFw(axis); }

◆ GetvFw() [2/2]

const FGColumnVector3 & GetvFw ( void  ) const
inline

Retrieves the aerodynamic forces in the wind axes.

Returns
a reference to a column vector containing the wind axis forces.

Definition at line 171 of file FGAerodynamics.h.

171{ return vFw; }

◆ InitModel()

bool InitModel ( void  )
overridevirtual

Reimplemented from FGModelFunctions.

Definition at line 115 of file FGAerodynamics.cpp.

116{
117 if (!FGModel::InitModel()) return false;
118
119 impending_stall = stall_hyst = 0.0;
120 alphaclmin = alphaclmin0;
121 alphaclmax = alphaclmax0;
122 alphahystmin = alphahystmax = 0.0;
123 clsq = lod = 0.0;
124 alphaw = 0.0;
125 bi2vel = ci2vel = 0.0;
126 AeroRPShift = 0;
127 vDeltaRP.InitMatrix();
128 vForces.InitMatrix();
129 vMoments.InitMatrix();
130 return true;
131}

◆ Load()

bool Load ( Element element)
overridevirtual

Loads the Aerodynamics model.

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

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

Reimplemented from FGModel.

Definition at line 331 of file FGAerodynamics.cpp.

332{
333 string axis;
334 string scratch_unit="";
335 Element *temp_element, *axis_element, *function_element;
336
337 Name = "Aerodynamics Model: " + document->GetAttributeValue("name");
338
339 // Perform base class Pre-Load
340 if (!FGModel::Upload(document, true))
341 return false;
342
343 DetermineAxisSystem(document); // Determine if Lift/Side/Drag, etc. is used.
344
345 Debug(2);
346
347 if ((temp_element = document->FindElement("alphalimits"))) {
348 scratch_unit = temp_element->GetAttributeValue("unit");
349 if (scratch_unit.empty()) scratch_unit = "RAD";
350 alphaclmin0 = temp_element->FindElementValueAsNumberConvertFromTo("min", scratch_unit, "RAD");
351 alphaclmax0 = temp_element->FindElementValueAsNumberConvertFromTo("max", scratch_unit, "RAD");
352 alphaclmin = alphaclmin0;
353 alphaclmax = alphaclmax0;
354 }
355
356 if ((temp_element = document->FindElement("hysteresis_limits"))) {
357 scratch_unit = temp_element->GetAttributeValue("unit");
358 if (scratch_unit.empty()) scratch_unit = "RAD";
359 alphahystmin = temp_element->FindElementValueAsNumberConvertFromTo("min", scratch_unit, "RAD");
360 alphahystmax = temp_element->FindElementValueAsNumberConvertFromTo("max", scratch_unit, "RAD");
361 }
362
363 if ((temp_element = document->FindElement("aero_ref_pt_shift_x"))) {
364 function_element = temp_element->FindElement("function");
365 AeroRPShift = new FGFunction(FDMExec, function_element);
366 }
367
368 axis_element = document->FindElement("axis");
369 while (axis_element) {
370 AeroFunctionArray ca;
371 AeroFunctionArray ca_atCG;
372 axis = axis_element->GetAttributeValue("name");
373 function_element = axis_element->FindElement("function");
374 while (function_element) {
375 try {
376 if (function_element->HasAttribute("apply_at_cg") &&
377 function_element->GetAttributeValue("apply_at_cg") == "true")
378 ca_atCG.push_back(new FGFunction(FDMExec, function_element));
379 else
380 ca.push_back(new FGFunction(FDMExec, function_element));
381 } catch (BaseException& e) {
382 string current_func_name = function_element->GetAttributeValue("name");
383 FGXMLLogging log(axis_element, LogLevel::ERROR);
384 log << LogFormat::RED << "\nError loading aerodynamic function in "
385 << current_func_name << ":" << e.what() << " Aborting.\n" << LogFormat::RESET;
386 return false;
387 }
388 function_element = axis_element->FindNextElement("function");
389 }
390 AeroFunctions[AxisIdx[axis]] = ca;
391 AeroFunctionsAtCG[AxisIdx[axis]] = ca_atCG;
392 axis_element = document->FindNextElement("axis");
393 }
394
395 PostLoad(document, FDMExec); // Perform base class Post-Load
396
397 return true;
398}
bool Upload(Element *el, bool preLoad)
Uploads this model in memory.
Definition FGModel.cpp:111
+ Here is the call graph for this function:

◆ Run()

bool Run ( bool  Holding)
overridevirtual

Runs the Aerodynamics 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 134 of file FGAerodynamics.cpp.

135{
136
137 if (FGModel::Run(Holding)) return true;
138 if (Holding) return false; // if paused don't execute
139
140 unsigned int axis_ctr;
141 const double twovel=2*in.Vt;
142
143 // The lift coefficient squared (property aero/cl-squared) is computed before
144 // the aero functions are called to make sure that they use the same value for
145 // qbar.
146 if ( in.Qbar > 1.0) {
147 // Skip the computation if qbar is close to zero to avoid huge values for
148 // aero/cl-squared when a non-null lift coincides with a very small aero
149 // velocity (i.e. when qbar is close to zero).
150 clsq = vFw(eLift) / (in.Wingarea*in.Qbar);
151 clsq *= clsq;
152 }
153
154 RunPreFunctions();
155
156 // calculate some oft-used quantities for speed
157
158 if (twovel != 0) {
159 bi2vel = in.Wingspan / twovel;
160 ci2vel = in.Wingchord / twovel;
161 }
162 alphaw = in.Alpha + in.Wingincidence;
163 qbar_area = in.Wingarea * in.Qbar;
164
165 if (alphaclmax != 0) {
166 if (in.Alpha > 0.85*alphaclmax) {
167 impending_stall = 10*(in.Alpha/alphaclmax - 0.85);
168 } else {
169 impending_stall = 0;
170 }
171 }
172
173 if (alphahystmax != 0.0 && alphahystmin != 0.0) {
174 if (in.Alpha > alphahystmax) {
175 stall_hyst = 1;
176 } else if (in.Alpha < alphahystmin) {
177 stall_hyst = 0;
178 }
179 }
180
181 vFw.InitMatrix();
182 vFnative.InitMatrix();
183 vFnativeAtCG.InitMatrix();
184
185 BuildStabilityTransformMatrices();
186
187 for (axis_ctr = 0; axis_ctr < 3; ++axis_ctr) {
188 AeroFunctionArray::iterator f;
189
190 AeroFunctionArray* array = &AeroFunctions[axis_ctr];
191 for (f=array->begin(); f != array->end(); ++f) {
192 // Tell the Functions to cache values, so when the function values are
193 // being requested for output, the functions do not get calculated again
194 // in a context that might have changed, but instead use the values that
195 // have already been calculated for this frame.
196 (*f)->cacheValue(true);
197 vFnative(axis_ctr+1) += (*f)->GetValue();
198 }
199
200 array = &AeroFunctionsAtCG[axis_ctr];
201 for (f=array->begin(); f != array->end(); ++f) {
202 (*f)->cacheValue(true); // Same as above
203 vFnativeAtCG(axis_ctr+1) += (*f)->GetValue();
204 }
205 }
206
207 switch (forceAxisType) {
208 case atBodyXYZ: // Forces already in body axes; no manipulation needed
209 vForces = vFnative;
210 vForcesAtCG = vFnativeAtCG;
211 break;
212 case atWind: // Copy forces into wind axes
213 vFnative(eDrag)*=-1; vFnative(eLift)*=-1;
214 vForces = in.Tw2b*vFnative;
215
216 vFnativeAtCG(eDrag)*=-1; vFnativeAtCG(eLift)*=-1;
217 vForcesAtCG = in.Tw2b*vFnativeAtCG;
218 break;
219 case atBodyAxialNormal: // Convert native forces into Axial|Normal|Side system
220 vFnative(eX)*=-1; vFnative(eZ)*=-1;
221 vForces = vFnative;
222
223 vFnativeAtCG(eX)*=-1; vFnativeAtCG(eZ)*=-1;
224 vForcesAtCG = vFnativeAtCG;
225 break;
226 case atStability: // Convert from stability axes to both body and wind axes
227 vFnative(eDrag) *= -1; vFnative(eLift) *= -1;
228 vForces = Ts2b*vFnative;
229
230 vFnativeAtCG(eDrag) *= -1; vFnativeAtCG(eLift) *= -1;
231 vForcesAtCG = Ts2b*vFnativeAtCG;
232 break;
233 default:
234 {
235 LogException err;
236 err << "\n A proper axis type has NOT been selected. Check "
237 << "your aerodynamics definition.\n";
238 throw err;
239 }
240 }
241 // Calculate aerodynamic reference point shift, if any. The shift takes place
242 // in the structual axis. That is, if the shift is positive, it is towards the
243 // back (tail) of the vehicle. The AeroRPShift function should be
244 // non-dimensionalized by the wing chord. The calculated vDeltaRP will be in
245 // feet.
246 if (AeroRPShift) vDeltaRP(eX) = AeroRPShift->GetValue()*in.Wingchord;
247
248 vDXYZcg(eX) = in.RPBody(eX) - vDeltaRP(eX); // vDeltaRP is given in the
249 vDXYZcg(eY) = in.RPBody(eY) + vDeltaRP(eY); // structural frame.
250 vDXYZcg(eZ) = in.RPBody(eZ) - vDeltaRP(eZ);
251
252 vMomentsMRC.InitMatrix();
253
254 for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) {
255 AeroFunctionArray* array = &AeroFunctions[axis_ctr+3];
256 for (AeroFunctionArray::iterator f=array->begin(); f != array->end(); ++f) {
257 // Tell the Functions to cache values, so when the function values are
258 // being requested for output, the functions do not get calculated again
259 // in a context that might have changed, but instead use the values that
260 // have already been calculated for this frame.
261 (*f)->cacheValue(true);
262 vMomentsMRC(axis_ctr+1) += (*f)->GetValue();
263 }
264 }
265
266 // Transform moments to bodyXYZ if the moments are specified in stability or
267 // wind axes
268 vMomentsMRCBodyXYZ.InitMatrix();
269 switch (momentAxisType) {
270 case atBodyXYZ:
271 vMomentsMRCBodyXYZ = vMomentsMRC;
272 break;
273 case atStability:
274 vMomentsMRCBodyXYZ = Ts2b*vMomentsMRC;
275 break;
276 case atWind:
277 vMomentsMRCBodyXYZ = in.Tw2b*vMomentsMRC;
278 break;
279 default:
280 {
281 LogException err;
282 err << "\n A proper axis type has NOT been selected. Check "
283 << "your aerodynamics definition.\n";
284 throw err;
285 }
286 }
287
288 vMoments = vMomentsMRCBodyXYZ + vDXYZcg*vForces; // M = r X F
289
290 // Now add the "at CG" values to base forces - after the moments have been
291 // transferred.
292 vForces += vForcesAtCG;
293
294 // Note that we still need to convert to wind axes here, because it is used in
295 // the L/D calculation, and we still may want to look at Lift and Drag.
296 //
297 // JSB 4/27/12 - After use, convert wind axes to produce normal lift and drag
298 // values - not negative ones!
299 //
300 // As a clarification, JSBSim assumes that drag and lift values are defined in
301 // wind axes - BUT with a 180 rotation about the Y axis. That is, lift and
302 // drag will be positive up and aft, respectively, so that they are reported
303 // as positive numbers. However, the wind axes themselves assume that the X
304 // and Z forces are positive forward and down. Same applies to the stability
305 // axes.
306 vFw = in.Tb2w * vForces;
307 vFw(eDrag) *= -1; vFw(eLift) *= -1;
308
309 // Calculate Lift over Drag
310 if ( fabs(vFw(eDrag)) > 0.0)
311 lod = fabs( vFw(eLift) / vFw(eDrag));
312
313 RunPostFunctions();
314
315 return false;
316}
double GetValue(void) const override
Retrieves the value of the function object.
virtual bool Run(bool Holding)
Runs the model; called by the Executive.
Definition FGModel.cpp:90
+ Here is the call graph for this function:

◆ SetAlphaCLMax()

void SetAlphaCLMax ( double  tt)
inline

Definition at line 222 of file FGAerodynamics.h.

222{ alphaclmax=tt; }

◆ SetAlphaCLMin()

void SetAlphaCLMin ( double  tt)
inline

Definition at line 223 of file FGAerodynamics.h.

223{ alphaclmin=tt; }

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