]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/FGAerodynamics.h
Sync. w. JSB CVS as of 15/01/2007
[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
59 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
60 DEFINITIONS
61 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
62
63 #define ID_AERODYNAMICS "$Id$"
64
65 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
66 FORWARD DECLARATIONS
67 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
68
69 namespace JSBSim {
70
71 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
72 CLASS DOCUMENTATION
73 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
74
75 /** Encapsulates the aerodynamic calculations.
76     This class owns and contains the list of force/coefficients that define the
77     aerodynamic properties of an aircraft. Here also, such unique phenomena
78     as ground effect, aerodynamic reference point shift, and maximum lift curve
79     tailoff are handled.
80
81     @code
82     <aerodynamics>
83        <axis name="{LIFT|DRAG|SIDE|ROLL|PITCH|YAW}">
84          {force coefficient definitions}
85        </axis>
86        {additional axis definitions}
87     </aerodynamics>
88     @endcode
89
90     @author Jon S. Berndt, Tony Peden
91     @Id $Revision$
92 */
93
94 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
95 CLASS DECLARATION
96 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
97
98 class FGAerodynamics : public FGModel {
99
100 public:
101   /** Constructor
102       @param Executive a pointer to the parent executive object */
103   FGAerodynamics(FGFDMExec* Executive);
104   /// Destructor
105   ~FGAerodynamics();
106
107   /** Runs the Aerodynamics model; called by the Executive
108       @return false if no error */
109   bool Run(void);
110
111   /** Loads the Aerodynamics model.
112       The Load function for this class expects the XML parser to
113       have found the aerodynamics keyword in the configuration file.
114       @param element pointer to the current XML element for aerodynamics parameters.
115       @return true if successful */
116   bool Load(Element* element);
117
118   /** Gets the total aerodynamic force vector.
119       @return a force vector reference. */
120   FGColumnVector3& GetForces(void) {return vForces;}
121
122   /** Gets the aerodynamic force for an axis.
123       @param n Axis index. This could be 0, 1, or 2, or one of the
124                axis enums: eX, eY, eZ.
125       @return the force acting on an axis */
126   double GetForces(int n) const {return vForces(n);}
127
128   /** Gets the total aerodynamic moment vector.
129       @return a moment vector reference. */
130   FGColumnVector3& GetMoments(void) {return vMoments;}
131
132   /** Gets the aerodynamic moment for an axis.
133       @return the moment about a single axis (as described also in the
134               similar call to GetForces(int n).*/
135   double GetMoments(int n) const {return vMoments(n);}
136
137   /** Retrieves the aerodynamic forces in the stability axes.
138       @return a reference to a column vector containing the stability axis forces. */
139   FGColumnVector3& GetvFs(void) { return vFs; }
140
141   /** Retrieves the aerodynamic forces in the stability axes, given an axis.
142       @param axis the axis to return the force for (eX, eY, eZ).
143       @return a reference to a column vector containing the requested stability
144       axis force. */
145   double GetvFs(int axis) const { return vFs(axis); }
146
147   /** Retrieves the lift over drag ratio */
148   inline double GetLoD(void) const { return lod; }
149
150   /** Retrieves the square of the lift coefficient. */
151   inline double GetClSquared(void) const { return clsq; }
152   inline double GetAlphaCLMax(void) const { return alphaclmax; }
153   inline double GetAlphaCLMin(void) const { return alphaclmin; }
154
155   inline double GetHysteresisParm(void) const { return stall_hyst; }
156   inline double GetStallWarn(void) const { return impending_stall; }
157   double GetAlphaW(void) const { return alphaw; }
158
159   double GetBI2Vel(void) const { return bi2vel; }
160   double GetCI2Vel(void) const { return ci2vel; }
161
162   inline void SetAlphaCLMax(double tt) { alphaclmax=tt; }
163   inline void SetAlphaCLMin(double tt) { alphaclmin=tt; }
164
165   /** Gets the strings for the current set of coefficients.
166       @param delimeter either a tab or comma string depending on output type
167       @return a string containing the descriptive names for all coefficients */
168   string GetCoefficientStrings(string delimeter);
169
170   /** Gets the coefficient values.
171       @param delimeter either a tab or comma string depending on output type
172       @return a string containing the numeric values for the current set of
173       coefficients */
174   string GetCoefficientValues(string delimeter);
175
176 private:
177   typedef map<string,int> AxisIndex;
178   AxisIndex AxisIdx;
179   FGFunction* AeroRPShift;
180   vector <FGFunction*> variables;
181   typedef vector <FGFunction*> CoeffArray;
182   CoeffArray* Coeff;
183   FGColumnVector3 vFs;
184   FGColumnVector3 vForces;
185   FGColumnVector3 vMoments;
186   FGColumnVector3 vLastFs;
187   FGColumnVector3 vDXYZcg;
188   FGColumnVector3 vDeltaRP;
189   double alphaclmax, alphaclmin;
190   double alphahystmax, alphahystmin;
191   double impending_stall, stall_hyst;
192   double bi2vel, ci2vel,alphaw;
193   double clsq, lod, qbar_area;
194
195   typedef double (FGAerodynamics::*PMF)(int) const;
196   void bind(void);
197   void unbind(void);
198
199   void Debug(int from);
200 };
201
202 } // namespace JSBSim
203
204 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
205 #endif
206