JSBSim Flight Dynamics Model  1.1.11 (13 Feb 2022)
An Open Source Flight Dynamics and Control Software Library in C++
FGAerodynamics.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 
3  Header: FGAerodynamics.h
4  Author: Jon S. Berndt
5  Date started: 09/13/00
6 
7  ------------- Copyright (C) 1999 Jon S. Berndt (jon@jsbsim.org) -------------
8 
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU Lesser General Public License as published by the Free
11  Software Foundation; either version 2 of the License, or (at your option) any
12  later version.
13 
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
17  details.
18 
19  You should have received a copy of the GNU Lesser General Public License along
20  with this program; if not, write to the Free Software Foundation, Inc., 59
21  Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 
23  Further information about the GNU Lesser General Public License can also be
24  found on the world wide web at http://www.gnu.org.
25 
26 HISTORY
27 --------------------------------------------------------------------------------
28 09/13/00 JSB Created
29 
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31 SENTRY
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
33 
34 #ifndef FGAERODYNAMICS_H
35 #define FGAERODYNAMICS_H
36 
37 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38 INCLUDES
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40 
41 #include <string>
42 #include <vector>
43 #include <map>
44 
45 #include "FGModel.h"
46 #include "math/FGFunction.h"
47 #include "math/FGColumnVector3.h"
48 #include "math/FGMatrix33.h"
49 
50 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
51 FORWARD DECLARATIONS
52 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
53 
54 namespace JSBSim {
55 
56 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57 CLASS DOCUMENTATION
58 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
59 
109 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
110 CLASS DECLARATION
111 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
112 
113 class FGAerodynamics : public FGModel
114 {
115 
116 public:
119  FGAerodynamics(FGFDMExec* Executive);
121  ~FGAerodynamics() override;
122 
123  bool InitModel(void) override;
124 
132  bool Run(bool Holding) override;
133 
139  bool Load(Element* element) override;
140 
143  const FGColumnVector3& GetForces(void) const {return vForces;}
144 
149  double GetForces(int n) const {return vForces(n);}
150 
153  const FGColumnVector3& GetMoments(void) const {return vMoments;}
154 
158  double GetMoments(int n) const {return vMoments(n);}
159 
162  const FGColumnVector3& GetMomentsMRC(void) const {return vMomentsMRC;}
163 
167  double GetMomentsMRC(int n) const {return vMomentsMRC(n);}
168 
171  const FGColumnVector3& GetvFw(void) const { return vFw; }
172 
177  double GetvFw(int axis) const { return vFw(axis); }
178 
182 
187  double GetForcesInStabilityAxes(int n) const { return GetForcesInStabilityAxes()(n); }
188 
191  FGColumnVector3 GetMomentsInStabilityAxes(void) const { return Tb2s*vMoments; }
192 
196  double GetMomentsInStabilityAxes(int n) const { return GetMomentsInStabilityAxes()(n); }
197 
200  FGColumnVector3 GetMomentsInWindAxes(void) const { return in.Tb2w*vMoments; }
201 
205  double GetMomentsInWindAxes(int n) const { return GetMomentsInWindAxes()(n); }
206 
208  double GetLoD(void) const { return lod; }
209 
211  double GetClSquared(void) const { return clsq; }
212  double GetAlphaCLMax(void) const { return alphaclmax; }
213  double GetAlphaCLMin(void) const { return alphaclmin; }
214 
215  double GetHysteresisParm(void) const { return stall_hyst; }
216  double GetStallWarn(void) const { return impending_stall; }
217  double GetAlphaW(void) const { return alphaw; }
218 
219  double GetBI2Vel(void) const { return bi2vel; }
220  double GetCI2Vel(void) const { return ci2vel; }
221 
222  void SetAlphaCLMax(double tt) { alphaclmax=tt; }
223  void SetAlphaCLMin(double tt) { alphaclmin=tt; }
224 
228  std::string GetAeroFunctionStrings(const std::string& delimeter) const;
229 
234  std::string GetAeroFunctionValues(const std::string& delimeter) const;
235 
236  std::vector <FGFunction*> * GetAeroFunctions(void) const { return AeroFunctions; }
237 
238  struct Inputs {
239  double Alpha;
240  double Beta;
241  double Vt;
242  double Qbar;
243  double Wingarea;
244  double Wingspan;
245  double Wingchord;
246  double Wingincidence;
247  FGColumnVector3 RPBody;
248  FGMatrix33 Tb2w;
249  FGMatrix33 Tw2b;
250  } in;
251 
252 private:
253  enum eAxisType {atNone, atWind, atBodyAxialNormal, atBodyXYZ, atStability} forceAxisType, momentAxisType;
254  typedef std::map<std::string,int> AxisIndex;
255  AxisIndex AxisIdx;
256  FGFunction* AeroRPShift;
257  typedef std::vector <FGFunction*> AeroFunctionArray;
258  AeroFunctionArray* AeroFunctions;
259  FGMatrix33 Ts2b, Tb2s;
260  FGColumnVector3 vFnative;
261  FGColumnVector3 vFw;
262  FGColumnVector3 vForces;
263  AeroFunctionArray* AeroFunctionsAtCG;
264  FGColumnVector3 vFnativeAtCG;
265  FGColumnVector3 vForcesAtCG;
266  FGColumnVector3 vMoments;
267  FGColumnVector3 vMomentsMRC;
268  FGColumnVector3 vMomentsMRCBodyXYZ;
269  FGColumnVector3 vDXYZcg;
270  FGColumnVector3 vDeltaRP;
271  double alphaclmax, alphaclmin;
272  double alphaclmax0, alphaclmin0;
273  double alphahystmax, alphahystmin;
274  double impending_stall, stall_hyst;
275  double bi2vel, ci2vel,alphaw;
276  double clsq, lod, qbar_area;
277 
278  typedef double (FGAerodynamics::*PMF)(int) const;
279  void DetermineAxisSystem(Element* document);
280  void ProcessAxesNameAndFrame(FGAerodynamics::eAxisType& axisType,
281  const string& name, const string& frame,
282  Element* el, const string& validNames);
283  void bind(void);
284  void BuildStabilityTransformMatrices(void);
285 
286  void Debug(int from) override;
287 };
288 
289 } // namespace JSBSim
290 
291 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
292 #endif
JSBSim::FGAerodynamics::GetForces
const FGColumnVector3 & GetForces(void) const
Gets the total aerodynamic force vector.
Definition: FGAerodynamics.h:143
JSBSim::FGFDMExec
Encapsulates the JSBSim simulation executive.
Definition: FGFDMExec.h:185
JSBSim::FGAerodynamics::GetForcesInStabilityAxes
double GetForcesInStabilityAxes(int n) const
Retrieves the aerodynamic forces in the stability axes, given an axis.
Definition: FGAerodynamics.h:187
JSBSim::FGAerodynamics::Inputs
Definition: FGAerodynamics.h:238
JSBSim::FGFunction
Represents a mathematical function.
Definition: FGFunction.h:752
JSBSim::FGColumnVector3
This class implements a 3 element column vector.
Definition: FGColumnVector3.h:63
JSBSim::FGAerodynamics
Encapsulates the aerodynamic calculations.
Definition: FGAerodynamics.h:113
JSBSim::FGModel
Base class for all scheduled JSBSim models.
Definition: FGModel.h:68
JSBSim::FGAerodynamics::GetForces
double GetForces(int n) const
Gets the aerodynamic force for an axis.
Definition: FGAerodynamics.h:149
JSBSim::FGAerodynamics::GetMomentsInWindAxes
double GetMomentsInWindAxes(int n) const
Gets the aerodynamic moment about the CG for an axis.
Definition: FGAerodynamics.h:205
JSBSim::FGAerodynamics::GetvFw
double GetvFw(int axis) const
Retrieves the aerodynamic forces in the wind axes, given an axis.
Definition: FGAerodynamics.h:177
JSBSim::FGAerodynamics::GetvFw
const FGColumnVector3 & GetvFw(void) const
Retrieves the aerodynamic forces in the wind axes.
Definition: FGAerodynamics.h:171
JSBSim::FGAerodynamics::~FGAerodynamics
~FGAerodynamics() override
Destructor.
Definition: FGAerodynamics.cpp:92
JSBSim::FGAerodynamics::Run
bool Run(bool Holding) override
Runs the Aerodynamics model; called by the Executive Can pass in a value indicating if the executive ...
Definition: FGAerodynamics.cpp:132
JSBSim::FGMatrix33
Handles matrix math operations.
Definition: FGMatrix33.h:69
JSBSim::FGAerodynamics::GetForcesInStabilityAxes
FGColumnVector3 GetForcesInStabilityAxes(void) const
Retrieves the aerodynamic forces in the stability axes.
Definition: FGAerodynamics.cpp:320
JSBSim::FGAerodynamics::GetMomentsInWindAxes
FGColumnVector3 GetMomentsInWindAxes(void) const
Gets the total aerodynamic moment vector about the CG in the wind axes.
Definition: FGAerodynamics.h:200
JSBSim::FGAerodynamics::Load
bool Load(Element *element) override
Loads the Aerodynamics model.
Definition: FGAerodynamics.cpp:331
JSBSim::FGAerodynamics::GetLoD
double GetLoD(void) const
Retrieves the lift over drag ratio.
Definition: FGAerodynamics.h:208
JSBSim::FGAerodynamics::GetMomentsInStabilityAxes
double GetMomentsInStabilityAxes(int n) const
Gets the aerodynamic moment about the CG for an axis.
Definition: FGAerodynamics.h:196
JSBSim::FGAerodynamics::GetMomentsMRC
const FGColumnVector3 & GetMomentsMRC(void) const
Gets the total aerodynamic moment vector about the Moment Reference Center.
Definition: FGAerodynamics.h:162
JSBSim::FGAerodynamics::GetAeroFunctionValues
std::string GetAeroFunctionValues(const std::string &delimeter) const
Gets the aero function values.
Definition: FGAerodynamics.cpp:549
JSBSim::FGAerodynamics::GetMoments
double GetMoments(int n) const
Gets the aerodynamic moment about the CG for an axis.
Definition: FGAerodynamics.h:158
JSBSim::FGAerodynamics::GetAeroFunctionStrings
std::string GetAeroFunctionStrings(const std::string &delimeter) const
Gets the strings for the current set of aero functions.
Definition: FGAerodynamics.cpp:517
JSBSim::FGAerodynamics::GetMomentsInStabilityAxes
FGColumnVector3 GetMomentsInStabilityAxes(void) const
Gets the total aerodynamic moment vector about the CG in the stability axes.
Definition: FGAerodynamics.h:191
JSBSim::FGAerodynamics::GetMoments
const FGColumnVector3 & GetMoments(void) const
Gets the total aerodynamic moment vector about the CG.
Definition: FGAerodynamics.h:153
JSBSim::FGAerodynamics::GetMomentsMRC
double GetMomentsMRC(int n) const
Gets the aerodynamic moment about the Moment Reference Center for an axis.
Definition: FGAerodynamics.h:167
JSBSim::Element
Definition: FGXMLElement.h:143
JSBSim::FGAerodynamics::GetClSquared
double GetClSquared(void) const
Retrieves the square of the lift coefficient.
Definition: FGAerodynamics.h:211
JSBSim::FGAerodynamics::FGAerodynamics
FGAerodynamics(FGFDMExec *Executive)
Constructor.
Definition: FGAerodynamics.cpp:51