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