JSBSim Flight Dynamics Model  1.0 (02 March 2017)
An Open Source Flight Dynamics and Control Software Library in C++
FGAerodynamics Class Reference

Encapsulates the aerodynamic calculations. More...

#include <FGAerodynamics.h>

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

Classes

struct  Inputs
 

Public Member Functions

 FGAerodynamics (FGFDMExec *Executive)
 Constructor. More...
 
 ~FGAerodynamics ()
 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. More...
 
const FGColumnVector3GetForces (void) const
 Gets the total aerodynamic force vector. More...
 
double GetForces (int n) const
 Gets the aerodynamic force for an axis. More...
 
double GetHysteresisParm (void) const
 
double GetLoD (void) const
 Retrieves the lift over drag ratio.
 
const FGColumnVector3GetMoments (void) const
 Gets the total aerodynamic moment vector about the CG. More...
 
double GetMoments (int n) const
 Gets the aerodynamic moment about the CG for an axis. More...
 
const FGColumnVector3GetMomentsMRC (void) const
 Gets the total aerodynamic moment vector about the Moment Reference Center. More...
 
double GetMomentsMRC (int n) const
 Gets the aerodynamic moment about the Moment Reference Center for an axis. More...
 
double GetStallWarn (void) const
 
const FGColumnVector3GetvFw (void) const
 Retrieves the aerodynamic forces in the wind axes. More...
 
double GetvFw (int axis) const
 Retrieves the aerodynamic forces in the wind axes, given an axis. More...
 
bool InitModel (void)
 
bool Load (Element *element)
 Loads the Aerodynamics model. More...
 
bool Run (bool Holding)
 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.
 
virtual ~FGModel ()
 Destructor.
 
virtual SGPath FindFullPathName (const SGPath &path) const
 
FGFDMExecGetExec (void)
 
unsigned int GetRate (void)
 Get the output rate for the model in frames.
 
void SetPropertyManager (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...
 
FGFunctionGetPreFunction (const std::string &name)
 Get one of the "pre" function. More...
 
bool Load (Element *el, FGPropertyManager *PropertyManager, std::string prefix="")
 
void PostLoad (Element *el, FGPropertyManager *PropertyManager, std::string prefix="")
 
void PreLoad (Element *el, FGPropertyManager *PropertyManager, 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.
 
std::string GetVersion (void)
 Returns the version number of JSBSim. More...
 
void PutMessage (const Message &msg)
 Places a Message structure on the Message queue. More...
 
void PutMessage (const std::string &text)
 Creates a message with the given text and places it on the queue. More...
 
void PutMessage (const std::string &text, bool bVal)
 Creates a message with the given text and boolean value and places it on the queue. More...
 
void PutMessage (const std::string &text, int iVal)
 Creates a message with the given text and integer value and places it on the queue. More...
 
void PutMessage (const std::string &text, double dVal)
 Creates a message with the given text and double value and places it on the queue. More...
 
int SomeMessages (void)
 Reads the message on the queue (but does not delete it). More...
 
void ProcessMessage (void)
 Reads the message on the queue and removes it from the queue. More...
 
MessageProcessNextMessage (void)
 Reads the next message on the queue and removes it from the queue. More...
 

Public Attributes

struct JSBSim::FGAerodynamics::Inputs in
 
- Public Attributes inherited from FGModel
std::string Name
 

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 double CelsiusToFahrenheit (double celsius)
 Converts from degrees Celsius to degrees Fahrenheit. More...
 
static double CelsiusToKelvin (double celsius)
 Converts from degrees Celsius to degrees Kelvin. More...
 
static double CelsiusToRankine (double celsius)
 Converts from degrees Celsius to degrees Rankine. More...
 
static 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. 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 double FahrenheitToCelsius (double fahrenheit)
 Converts from degrees Fahrenheit to degrees Celsius. More...
 
static double FeetToMeters (double measure)
 Converts from feet to meters. More...
 
static double GaussianRandomNumber (void)
 
static double KelvinToCelsius (double kelvin)
 Converts from degrees Kelvin to degrees Celsius. More...
 
static double KelvinToFahrenheit (double kelvin)
 Converts from degrees Kelvin to degrees Fahrenheit. More...
 
static double KelvinToRankine (double kelvin)
 Converts from degrees Kelvin to degrees Rankine. More...
 
static double MachFromVcalibrated (double vcas, double p, double psl, double rhosl)
 Calculate the Mach number from the calibrated airspeed. More...
 
static double PitotTotalPressure (double mach, double p)
 Compute the total pressure in front of the Pitot tube. More...
 
static double RankineToCelsius (double rankine)
 Converts from degrees Rankine to degrees Celsius. More...
 
static double RankineToKelvin (double rankine)
 Converts from degrees Rankine to degrees Kelvin. More...
 
static double sign (double num)
 
static double VcalibratedFromMach (double mach, double p, double psl, double rhosl)
 Calculate the calibrated airspeed from the Mach number. More...
 
- Static Public Attributes inherited from FGJSBBase
static short debug_lvl = 1
 
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
 
- Protected Member Functions inherited from FGJSBBase
void Debug (int)
 
- 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
 
FGPropertyManagerPropertyManager
 
unsigned int rate
 
- Protected Attributes inherited from FGModelFunctions
FGPropertyReader LocalProperties
 
std::vector< FGFunction * > PostFunctions
 
std::vector< FGFunction * > PreFunctions
 
- Static Protected Attributes inherited from FGJSBBase
static const double degtorad = 0.017453292519943295769236907684886
 
static const double fpstokts = 1.0/ktstofps
 
static const double fttom = 0.3048
 
static int gaussian_random_number_phase = 0
 
static const double hptoftlbssec = 550.0
 
static const double in3tom3 = 1.638706E-5
 
static const double inchtoft = 0.08333333
 
static const double inhgtopa = 3386.38
 
static const std::string JSBSim_version = "1.0 " __DATE__ " " __TIME__
 
static const double kgtolb = 2.20462
 
static const double kgtoslug = 0.06852168
 
static const double ktstofps = 1.68781
 
static const double lbtoslug = 1.0/slugtolb
 
static Message localMsg
 
static const double m3toft3 = 1.0/(fttom*fttom*fttom)
 
static double Mair = 28.9645
 
static unsigned int messageId = 0
 
static std::queue< MessageMessages
 
static const std::string needed_cfg_version = "2.0"
 
static const double psftoinhg = 0.014138
 
static const double psftopa = 47.88
 
static const double radtodeg = 57.295779513082320876798154814105
 
static double Reng = 1716.56
 
static double Rstar = 1545.348
 
static const double SHRatio = 1.40
 
static const double slugtolb = 32.174049
 

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.

<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 118 of file FGAerodynamics.h.

Constructor & Destructor Documentation

◆ FGAerodynamics()

FGAerodynamics ( FGFDMExec Executive)

Constructor.

Parameters
Executivea pointer to the parent executive object

Definition at line 61 of file FGAerodynamics.cpp.

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

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

437 {
438  string AeroFunctionStrings = "";
439  bool firstime = true;
440  unsigned int axis, sd;
441 
442  for (axis = 0; axis < 6; axis++) {
443  for (sd = 0; sd < AeroFunctions[axis].size(); sd++) {
444  if (firstime) {
445  firstime = false;
446  } else {
447  AeroFunctionStrings += delimeter;
448  }
449  AeroFunctionStrings += AeroFunctions[axis][sd]->GetName();
450  }
451  }
452 
453  string FunctionStrings = FGModelFunctions::GetFunctionStrings(delimeter);
454 
455  if (FunctionStrings.size() > 0) {
456  if (AeroFunctionStrings.size() > 0) {
457  AeroFunctionStrings += delimeter + FunctionStrings;
458  } else {
459  AeroFunctionStrings = FunctionStrings;
460  }
461  }
462 
463  return AeroFunctionStrings;
464 }
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:
+ Here is the caller 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 468 of file FGAerodynamics.cpp.

469 {
470  ostringstream buf;
471 
472  for (unsigned int axis = 0; axis < 6; axis++) {
473  for (unsigned int sd = 0; sd < AeroFunctions[axis].size(); sd++) {
474  if (buf.tellp() > 0) buf << delimeter;
475  buf << AeroFunctions[axis][sd]->GetValue();
476  }
477  }
478 
479  string FunctionValues = FGModelFunctions::GetFunctionValues(delimeter);
480 
481  if (FunctionValues.size() > 0) {
482  if (buf.str().size() > 0) {
483  buf << delimeter << FunctionValues;
484  } else {
485  buf << FunctionValues;
486  }
487  }
488 
489  return buf.str();
490 }
std::string GetFunctionValues(const std::string &delimeter) const
Gets the function values.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetClSquared()

double GetClSquared ( void  ) const
inline

Retrieves the square of the lift coefficient.

Definition at line 188 of file FGAerodynamics.h.

188 { return clsq; }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetForces() [1/2]

const FGColumnVector3& GetForces ( void  ) const
inline

Gets the total aerodynamic force vector.

Returns
a force vector reference.

Definition at line 148 of file FGAerodynamics.h.

148 {return vForces;}
+ Here is the caller graph for this function:

◆ GetForces() [2/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 154 of file FGAerodynamics.h.

154 {return vForces(n);}

◆ GetMoments() [1/2]

const FGColumnVector3& GetMoments ( void  ) const
inline

Gets the total aerodynamic moment vector about the CG.

Returns
a moment vector reference.

Definition at line 158 of file FGAerodynamics.h.

158 {return vMoments;}
+ Here is the caller graph for this function:

◆ GetMoments() [2/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 163 of file FGAerodynamics.h.

163 {return vMoments(n);}

◆ GetMomentsMRC() [1/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 167 of file FGAerodynamics.h.

167 {return vMomentsMRC;}

◆ GetMomentsMRC() [2/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 172 of file FGAerodynamics.h.

172 {return vMomentsMRC(n);}

◆ GetvFw() [1/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 176 of file FGAerodynamics.h.

176 { return vFw; }
+ Here is the caller graph for this function:

◆ GetvFw() [2/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 182 of file FGAerodynamics.h.

182 { return vFw(axis); }

◆ Load()

bool Load ( Element element)
virtual

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

304 {
305  string axis;
306  string scratch_unit="";
307  Element *temp_element, *axis_element, *function_element;
308 
309  Name = "Aerodynamics Model: " + document->GetAttributeValue("name");
310 
311  // Perform base class Pre-Load
312  if (!FGModel::Load(document))
313  return false;
314 
315  DetermineAxisSystem(document); // Determine if Lift/Side/Drag, etc. is used.
316 
317  Debug(2);
318 
319  if ((temp_element = document->FindElement("alphalimits"))) {
320  scratch_unit = temp_element->GetAttributeValue("unit");
321  if (scratch_unit.empty()) scratch_unit = "RAD";
322  alphaclmin0 = temp_element->FindElementValueAsNumberConvertFromTo("min", scratch_unit, "RAD");
323  alphaclmax0 = temp_element->FindElementValueAsNumberConvertFromTo("max", scratch_unit, "RAD");
324  alphaclmin = alphaclmin0;
325  alphaclmax = alphaclmax0;
326  }
327 
328  if ((temp_element = document->FindElement("hysteresis_limits"))) {
329  scratch_unit = temp_element->GetAttributeValue("unit");
330  if (scratch_unit.empty()) scratch_unit = "RAD";
331  alphahystmin = temp_element->FindElementValueAsNumberConvertFromTo("min", scratch_unit, "RAD");
332  alphahystmax = temp_element->FindElementValueAsNumberConvertFromTo("max", scratch_unit, "RAD");
333  }
334 
335  if ((temp_element = document->FindElement("aero_ref_pt_shift_x"))) {
336  function_element = temp_element->FindElement("function");
337  AeroRPShift = new FGFunction(PropertyManager, function_element);
338  }
339 
340  axis_element = document->FindElement("axis");
341  while (axis_element) {
342  AeroFunctionArray ca;
343  AeroFunctionArray ca_atCG;
344  axis = axis_element->GetAttributeValue("name");
345  function_element = axis_element->FindElement("function");
346  while (function_element) {
347  string current_func_name = function_element->GetAttributeValue("name");
348  bool apply_at_cg = false;
349  if (function_element->HasAttribute("apply_at_cg")) {
350  if (function_element->GetAttributeValue("apply_at_cg") == "true") apply_at_cg = true;
351  }
352  if (!apply_at_cg) {
353  try {
354  ca.push_back( new FGFunction(PropertyManager, function_element) );
355  } catch (const string& str) {
356  cerr << endl << fgred << "Error loading aerodynamic function in "
357  << current_func_name << ":" << str << " Aborting." << reset << endl;
358  return false;
359  }
360  } else {
361  try {
362  ca_atCG.push_back( new FGFunction(PropertyManager, function_element) );
363  } catch (const string& str) {
364  cerr << endl << fgred << "Error loading aerodynamic function in "
365  << current_func_name << ":" << str << " Aborting." << reset << endl;
366  return false;
367  }
368  }
369  function_element = axis_element->FindNextElement("function");
370  }
371  AeroFunctions[AxisIdx[axis]] = ca;
372  AeroFunctionsAtCG[AxisIdx[axis]] = ca_atCG;
373  axis_element = document->FindNextElement("axis");
374  }
375 
376  PostLoad(document, PropertyManager); // Perform base class Post-Load
377 
378  return true;
379 }
static char reset[5]
resets text properties
Definition: FGJSBBase.h:131
static char fgred[6]
red text
Definition: FGJSBBase.h:141
virtual bool Load(Element *el)
Loads this model.
Definition: FGModel.cpp:113
+ Here is the call graph for this function:

◆ Run()

bool Run ( bool  Holding)
virtual

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

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

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