JSBSim Flight Dynamics Model  1.2.0 (05 Nov 2023)
An Open Source Flight Dynamics and Control Software Library in C++
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. More...
 
 ~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. More...
 
std::string GetAeroFunctionValues (const std::string &delimeter) const
 Gets the aero function values. More...
 
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. More...
 
const FGColumnVector3GetForces (void) const
 Gets the total aerodynamic force vector. More...
 
double GetForcesInStabilityAxes (int n) const
 Retrieves the aerodynamic forces in the stability axes, given an axis. More...
 
FGColumnVector3 GetForcesInStabilityAxes (void) const
 Retrieves the aerodynamic forces in the stability axes. More...
 
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. More...
 
const FGColumnVector3GetMoments (void) const
 Gets the total aerodynamic moment vector about the CG. More...
 
double GetMomentsInStabilityAxes (int n) const
 Gets the aerodynamic moment about the CG for an axis. More...
 
FGColumnVector3 GetMomentsInStabilityAxes (void) const
 Gets the total aerodynamic moment vector about the CG in the stability axes. More...
 
double GetMomentsInWindAxes (int n) const
 Gets the aerodynamic moment about the CG for an axis. More...
 
FGColumnVector3 GetMomentsInWindAxes (void) const
 Gets the total aerodynamic moment vector about the CG in the wind axes. More...
 
double GetMomentsMRC (int n) const
 Gets the aerodynamic moment about the Moment Reference Center for an axis. More...
 
const FGColumnVector3GetMomentsMRC (void) const
 Gets the total aerodynamic moment vector about the Moment Reference Center. More...
 
double GetStallWarn (void) const
 
double GetvFw (int axis) const
 Retrieves the aerodynamic forces in the wind axes, given an axis. More...
 
const FGColumnVector3GetvFw (void) const
 Retrieves the aerodynamic forces in the wind axes. More...
 
bool InitModel (void) override
 
bool Load (Element *element) override
 Loads the Aerodynamics model. More...
 
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. More...
 
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 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

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

◆ FGAerodynamics()

FGAerodynamics ( FGFDMExec Executive)

Constructor.

Parameters
Executivea pointer to the parent executive object

Definition at line 51 of file FGAerodynamics.cpp.

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

Member Function Documentation

◆ 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 544 of file FGAerodynamics.cpp.

545 {
546  string AeroFunctionStrings = "";
547  bool firstime = true;
548  unsigned int axis, sd;
549 
550  for (axis = 0; axis < 6; axis++) {
551  for (sd = 0; sd < AeroFunctions[axis].size(); sd++) {
552  if (firstime) {
553  firstime = false;
554  } else {
555  AeroFunctionStrings += delimeter;
556  }
557  AeroFunctionStrings += AeroFunctions[axis][sd]->GetName();
558  }
559  }
560 
561  string FunctionStrings = FGModelFunctions::GetFunctionStrings(delimeter);
562 
563  if (!FunctionStrings.empty()) {
564  if (!AeroFunctionStrings.empty()) {
565  AeroFunctionStrings += delimeter + FunctionStrings;
566  } else {
567  AeroFunctionStrings = FunctionStrings;
568  }
569  }
570 
571  return AeroFunctionStrings;
572 }
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 576 of file FGAerodynamics.cpp.

577 {
578  ostringstream buf;
579 
580  for (unsigned int axis = 0; axis < 6; axis++) {
581  for (unsigned int sd = 0; sd < AeroFunctions[axis].size(); sd++) {
582  if (buf.tellp() > 0) buf << delimeter;
583  buf << AeroFunctions[axis][sd]->GetValue();
584  }
585  }
586 
587  string FunctionValues = FGModelFunctions::GetFunctionValues(delimeter);
588 
589  if (!FunctionValues.empty()) {
590  if (!buf.str().empty()) {
591  buf << delimeter << FunctionValues;
592  } else {
593  buf << FunctionValues;
594  }
595  }
596 
597  return buf.str();
598 }
std::string GetFunctionValues(const std::string &delimeter) const
Gets the function values.
+ Here is the call graph for this function:

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

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

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

◆ 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  string current_func_name = function_element->GetAttributeValue("name");
376  bool apply_at_cg = false;
377  if (function_element->HasAttribute("apply_at_cg")) {
378  if (function_element->GetAttributeValue("apply_at_cg") == "true") apply_at_cg = true;
379  }
380  if (!apply_at_cg) {
381  try {
382  ca.push_back( new FGFunction(FDMExec, function_element) );
383  } catch (const string& str) {
384  cerr << endl << axis_element->ReadFrom()
385  << endl << fgred << "Error loading aerodynamic function in "
386  << current_func_name << ":" << str << " Aborting." << reset << endl;
387  return false;
388  }
389  } else {
390  try {
391  ca_atCG.push_back( new FGFunction(FDMExec, function_element) );
392  } catch (const string& str) {
393  cerr << endl << axis_element->ReadFrom()
394  << endl << fgred << "Error loading aerodynamic function in "
395  << current_func_name << ":" << str << " Aborting." << reset << endl;
396  return false;
397  }
398  }
399  function_element = axis_element->FindNextElement("function");
400  }
401  AeroFunctions[AxisIdx[axis]] = ca;
402  AeroFunctionsAtCG[AxisIdx[axis]] = ca_atCG;
403  axis_element = document->FindNextElement("axis");
404  }
405 
406  PostLoad(document, FDMExec); // Perform base class Post-Load
407 
408  return true;
409 }
static char fgred[6]
red text
Definition: FGJSBBase.h:167
static char reset[5]
resets text properties
Definition: FGJSBBase.h:157
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 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 132 of file FGAerodynamics.cpp.

133 {
134 
135  if (FGModel::Run(Holding)) return true;
136  if (Holding) return false; // if paused don't execute
137 
138  unsigned int axis_ctr;
139  const double twovel=2*in.Vt;
140 
141  // The lift coefficient squared (property aero/cl-squared) is computed before
142  // the aero functions are called to make sure that they use the same value for
143  // qbar.
144  if ( in.Qbar > 1.0) {
145  // Skip the computation if qbar is close to zero to avoid huge values for
146  // aero/cl-squared when a non-null lift coincides with a very small aero
147  // velocity (i.e. when qbar is close to zero).
148  clsq = vFw(eLift) / (in.Wingarea*in.Qbar);
149  clsq *= clsq;
150  }
151 
152  RunPreFunctions();
153 
154  // calculate some oft-used quantities for speed
155 
156  if (twovel != 0) {
157  bi2vel = in.Wingspan / twovel;
158  ci2vel = in.Wingchord / twovel;
159  }
160  alphaw = in.Alpha + in.Wingincidence;
161  qbar_area = in.Wingarea * in.Qbar;
162 
163  if (alphaclmax != 0) {
164  if (in.Alpha > 0.85*alphaclmax) {
165  impending_stall = 10*(in.Alpha/alphaclmax - 0.85);
166  } else {
167  impending_stall = 0;
168  }
169  }
170 
171  if (alphahystmax != 0.0 && alphahystmin != 0.0) {
172  if (in.Alpha > alphahystmax) {
173  stall_hyst = 1;
174  } else if (in.Alpha < alphahystmin) {
175  stall_hyst = 0;
176  }
177  }
178 
179  vFw.InitMatrix();
180  vFnative.InitMatrix();
181  vFnativeAtCG.InitMatrix();
182 
183  BuildStabilityTransformMatrices();
184 
185  for (axis_ctr = 0; axis_ctr < 3; ++axis_ctr) {
186  AeroFunctionArray::iterator f;
187 
188  AeroFunctionArray* array = &AeroFunctions[axis_ctr];
189  for (f=array->begin(); f != array->end(); ++f) {
190  // Tell the Functions to cache values, so when the function values are
191  // being requested for output, the functions do not get calculated again
192  // in a context that might have changed, but instead use the values that
193  // have already been calculated for this frame.
194  (*f)->cacheValue(true);
195  vFnative(axis_ctr+1) += (*f)->GetValue();
196  }
197 
198  array = &AeroFunctionsAtCG[axis_ctr];
199  for (f=array->begin(); f != array->end(); ++f) {
200  (*f)->cacheValue(true); // Same as above
201  vFnativeAtCG(axis_ctr+1) += (*f)->GetValue();
202  }
203  }
204 
205  switch (forceAxisType) {
206  case atBodyXYZ: // Forces already in body axes; no manipulation needed
207  vForces = vFnative;
208  vForcesAtCG = vFnativeAtCG;
209  break;
210  case atWind: // Copy forces into wind axes
211  vFnative(eDrag)*=-1; vFnative(eLift)*=-1;
212  vForces = in.Tw2b*vFnative;
213 
214  vFnativeAtCG(eDrag)*=-1; vFnativeAtCG(eLift)*=-1;
215  vForcesAtCG = in.Tw2b*vFnativeAtCG;
216  break;
217  case atBodyAxialNormal: // Convert native forces into Axial|Normal|Side system
218  vFnative(eX)*=-1; vFnative(eZ)*=-1;
219  vForces = vFnative;
220 
221  vFnativeAtCG(eX)*=-1; vFnativeAtCG(eZ)*=-1;
222  vForcesAtCG = vFnativeAtCG;
223  break;
224  case atStability: // Convert from stability axes to both body and wind axes
225  vFnative(eDrag) *= -1; vFnative(eLift) *= -1;
226  vForces = Ts2b*vFnative;
227 
228  vFnativeAtCG(eDrag) *= -1; vFnativeAtCG(eLift) *= -1;
229  vForcesAtCG = Ts2b*vFnativeAtCG;
230  break;
231  default:
232  {
233  stringstream s;
234  s << " A proper axis type has NOT been selected. Check "
235  << "your aerodynamics definition.";
236  cerr << endl << s.str() << endl;
237  throw BaseException(s.str());
238  }
239  }
240  // Calculate aerodynamic reference point shift, if any. The shift takes place
241  // in the structual axis. That is, if the shift is positive, it is towards the
242  // back (tail) of the vehicle. The AeroRPShift function should be
243  // non-dimensionalized by the wing chord. The calculated vDeltaRP will be in
244  // feet.
245  if (AeroRPShift) vDeltaRP(eX) = AeroRPShift->GetValue()*in.Wingchord;
246 
247  vDXYZcg(eX) = in.RPBody(eX) - vDeltaRP(eX); // vDeltaRP is given in the
248  vDXYZcg(eY) = in.RPBody(eY) + vDeltaRP(eY); // structural frame.
249  vDXYZcg(eZ) = in.RPBody(eZ) - vDeltaRP(eZ);
250 
251  vMomentsMRC.InitMatrix();
252 
253  for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) {
254  AeroFunctionArray* array = &AeroFunctions[axis_ctr+3];
255  for (AeroFunctionArray::iterator f=array->begin(); f != array->end(); ++f) {
256  // Tell the Functions to cache values, so when the function values are
257  // being requested for output, the functions do not get calculated again
258  // in a context that might have changed, but instead use the values that
259  // have already been calculated for this frame.
260  (*f)->cacheValue(true);
261  vMomentsMRC(axis_ctr+1) += (*f)->GetValue();
262  }
263  }
264 
265  // Transform moments to bodyXYZ if the moments are specified in stability or
266  // wind axes
267  vMomentsMRCBodyXYZ.InitMatrix();
268  switch (momentAxisType) {
269  case atBodyXYZ:
270  vMomentsMRCBodyXYZ = vMomentsMRC;
271  break;
272  case atStability:
273  vMomentsMRCBodyXYZ = Ts2b*vMomentsMRC;
274  break;
275  case atWind:
276  vMomentsMRCBodyXYZ = in.Tw2b*vMomentsMRC;
277  break;
278  default:
279  {
280  stringstream s;
281  s << " A proper axis type has NOT been selected. Check "
282  << "your aerodynamics definition.";
283  cerr << endl << s.str() << endl;
284  throw BaseException(s.str());
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.
Definition: FGFunction.cpp:960
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: