]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/FGAerodynamics.h
Sync. with JSBSim CVS
[flightgear.git] / src / FDM / JSBSim / models / 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 (jsb@hal-pc.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 Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  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 with
20  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21  Place - Suite 330, Boston, MA  02111-1307, USA.
22
23  Further information about the GNU Lesser General Public License can also be found on
24  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 <vector>
42 #include <map>
43
44 #include "FGModel.h"
45 #include <math/FGFunction.h>
46 #include <math/FGColumnVector3.h>
47 #include <math/FGMatrix33.h>
48 #include <input_output/FGXMLFileRead.h>
49
50 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
51 DEFINITIONS
52 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
53
54 #define ID_AERODYNAMICS "$Id$"
55
56 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57 FORWARD DECLARATIONS
58 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
59
60 namespace JSBSim {
61
62 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
63 CLASS DOCUMENTATION
64 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
65
66 /** Encapsulates the aerodynamic calculations.
67     This class owns and contains the list of force/coefficients that define the
68     aerodynamic properties of an aircraft. Here also, such unique phenomena
69     as ground effect, aerodynamic reference point shift, and maximum lift curve
70     tailoff are handled.
71
72     @code
73     <aerodynamics>
74        <alphalimits unit="{RAD | DEG}">
75          <min> {number} </min>
76          <max> {number} </max>
77        </alphalimits>
78        <hysteresis_limits unit="{RAD | DEG}">
79          <min> {number} </min>
80          <max> {number} </max>
81        </hysteresis_limits>
82        <aero_ref_pt_shift_x>  
83          <function>
84            {function contents}
85          </function> 
86        </aero_ref_pt_shift_x>  
87        <function>
88          {function contents}
89        </function>
90        <axis name="{LIFT | DRAG | SIDE | ROLL | PITCH | YAW}">
91          {force coefficient definitions}
92        </axis>
93        {additional axis definitions}
94     </aerodynamics>
95     @endcode
96
97     Optionally two other coordinate systems may be used.<br><br>
98     1) Body coordinate system:
99     @code
100        <axis name="{X | Y | Z}">
101     @endcode
102     <br>
103     2) Axial-Normal coordinate system:
104     @code
105        <axis name="{AXIAL | NORMAL}">
106     @endcode
107     <br>
108     Systems may NOT be combined, or a load error will occur.
109
110     @author Jon S. Berndt, Tony Peden
111     @version $Revision$
112 */
113
114 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
115 CLASS DECLARATION
116 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
117
118 class FGAerodynamics : public FGModel, public FGXMLFileRead
119 {
120
121 public:
122   /** Constructor
123       @param Executive a pointer to the parent executive object */
124   FGAerodynamics(FGFDMExec* Executive);
125   /// Destructor
126   ~FGAerodynamics();
127
128   bool InitModel(void);
129
130   /** Runs the Aerodynamics model; called by the Executive
131       @return false if no error */
132   bool Run(void);
133
134   /** Loads the Aerodynamics model.
135       The Load function for this class expects the XML parser to
136       have found the aerodynamics keyword in the configuration file.
137       @param element pointer to the current XML element for aerodynamics parameters.
138       @return true if successful */
139   bool Load(Element* element);
140
141   /** Gets the total aerodynamic force vector.
142       @return a force vector reference. */
143   FGColumnVector3& GetForces(void) {return vForces;}
144
145   /** Gets the aerodynamic force for an axis.
146       @param n Axis index. This could be 0, 1, or 2, or one of the
147                axis enums: eX, eY, eZ.
148       @return the force acting on an axis */
149   double GetForces(int n) const {return vForces(n);}
150
151   /** Gets the total aerodynamic moment vector.
152       @return a moment vector reference. */
153   FGColumnVector3& GetMoments(void) {return vMoments;}
154
155   /** Gets the aerodynamic moment for an axis.
156       @return the moment about a single axis (as described also in the
157               similar call to GetForces(int n).*/
158   double GetMoments(int n) const {return vMoments(n);}
159
160   /** Retrieves the aerodynamic forces in the wind axes.
161       @return a reference to a column vector containing the wind axis forces. */
162   FGColumnVector3& GetvFw(void) { return vFw; }
163
164   /** Retrieves the aerodynamic forces in the wind axes, given an axis.
165       @param axis the axis to return the force for (eX, eY, eZ).
166       @return a reference to a column vector containing the requested wind
167       axis force. */
168   double GetvFw(int axis) const { return vFw(axis); }
169
170   /** Retrieves the lift over drag ratio */
171   inline double GetLoD(void) const { return lod; }
172
173   /** Retrieves the square of the lift coefficient. */
174   inline double GetClSquared(void) const { return clsq; }
175   inline double GetAlphaCLMax(void) const { return alphaclmax; }
176   inline double GetAlphaCLMin(void) const { return alphaclmin; }
177
178   inline double GetHysteresisParm(void) const { return stall_hyst; }
179   inline double GetStallWarn(void) const { return impending_stall; }
180   double GetAlphaW(void) const { return alphaw; }
181
182   double GetBI2Vel(void) const { return bi2vel; }
183   double GetCI2Vel(void) const { return ci2vel; }
184
185   inline void SetAlphaCLMax(double tt) { alphaclmax=tt; }
186   inline void SetAlphaCLMin(double tt) { alphaclmin=tt; }
187
188   /** Gets the strings for the current set of coefficients.
189       @param delimeter either a tab or comma string depending on output type
190       @return a string containing the descriptive names for all coefficients */
191   string GetCoefficientStrings(string delimeter);
192
193   /** Gets the coefficient values.
194       @param delimeter either a tab or comma string depending on output type
195       @return a string containing the numeric values for the current set of
196       coefficients */
197   string GetCoefficientValues(string delimeter);
198
199   /** Calculates and returns the wind-to-body axis transformation matrix.
200       @return a reference to the wind-to-body transformation matrix.
201       */
202   FGMatrix33& GetTw2b(void);
203
204   /** Calculates and returns the body-to-wind axis transformation matrix.
205       @return a reference to the wind-to-body transformation matrix.
206       */
207   FGMatrix33& GetTb2w(void);
208
209   vector <FGFunction*> * GetCoeff(void) const { return Coeff; }
210
211 private:
212   enum eAxisType {atNone, atLiftDrag, atAxialNormal, atBodyXYZ} axisType;
213   typedef map<string,int> AxisIndex;
214   AxisIndex AxisIdx;
215   FGFunction* AeroRPShift;
216   vector <FGFunction*> variables;
217   typedef vector <FGFunction*> CoeffArray;
218   CoeffArray* Coeff;
219   FGColumnVector3 vFnative;
220   FGColumnVector3 vFw;
221   FGColumnVector3 vForces;
222   FGColumnVector3 vMoments;
223   FGColumnVector3 vDXYZcg;
224   FGColumnVector3 vDeltaRP;
225   FGMatrix33 mTw2b;
226   FGMatrix33 mTb2w;
227   double alphaclmax, alphaclmin;
228   double alphahystmax, alphahystmin;
229   double impending_stall, stall_hyst;
230   double bi2vel, ci2vel,alphaw;
231   double clsq, lod, qbar_area;
232
233   typedef double (FGAerodynamics::*PMF)(int) const;
234   void DetermineAxisSystem(void);
235   void bind(void);
236
237   void Debug(int from);
238 };
239
240 } // namespace JSBSim
241
242 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
243 #endif
244