]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/FGAerodynamics.h
sync. with JSBSim v. 2.0
[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 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 General Public License for more
17  details.
18
19  You should have received a copy of the GNU 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 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 coefficients that define the
77     aerodynamic properties of this aircraft. Here also, such unique phenomena
78     as ground effect and maximum lift curve tailoff are handled.
79     @config
80     <pre>
81     \<AERODYNAMICS>
82        \<AXIS NAME="{LIFT|DRAG|SIDE|ROLL|PITCH|YAW}">
83          {Coefficient definitions}
84        \</AXIS>
85        {Additional axis definitions}
86     \</AERODYNAMICS> </pre>
87
88     @author Jon S. Berndt, Tony Peden
89     $Id$
90 */
91
92 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
93 CLASS DECLARATION
94 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
95
96 class FGAerodynamics : public FGModel {
97
98 public:
99   /** Constructor
100       @param Executive a pointer to the parent executive object */
101   FGAerodynamics(FGFDMExec* Executive);
102   /// Destructor
103   ~FGAerodynamics();
104
105   /** Runs the Aerodynamics model; called by the Executive
106       @return false if no error */
107   bool Run(void);
108
109   /** Loads the Aerodynamics model.
110       The Load function for this class expects the XML parser to
111       have found the AERODYNAMICS keyword in the configuration file.
112       @param element pointer to the current XML element for aerodynamics parameters.
113       @return true if successful */
114   bool Load(Element* element);
115
116   /** Gets the total aerodynamic force vector.
117       @return a force vector reference. */
118   FGColumnVector3& GetForces(void) {return vForces;}
119
120   /** Gets the aerodynamic force for an axis.
121       @param n Axis index. This could be 0, 1, or 2, or one of the
122                axis enums: eX, eY, eZ.
123       @return the force acting on an axis */
124   double GetForces(int n) const {return vForces(n);}
125
126   /** Gets the total aerodynamic moment vector.
127       @return a moment vector reference. */
128   FGColumnVector3& GetMoments(void) {return vMoments;}
129
130   /** Gets the aerodynamic moment for an axis.
131       @return the moment about a single axis (as described also in the
132               similar call to GetForces(int n).*/
133   double GetMoments(int n) const {return vMoments(n);}
134
135   FGColumnVector3& GetvLastFs(void) { return vLastFs; }
136   double GetvLastFs(int axis) const { return vLastFs(axis); }
137   FGColumnVector3& GetvFs(void) { return vFs; }
138   double GetvFs(int axis) const { return vFs(axis); }
139   inline double GetLoD(void) const { return lod; }
140   inline double GetClSquared(void) const { return clsq; }
141   inline double GetAlphaCLMax(void) const { return alphaclmax; }
142   inline double GetAlphaCLMin(void) const { return alphaclmin; }
143
144   inline double GetAlphaHystMax(void) const { return alphahystmax; }
145   inline double GetAlphaHystMin(void) const { return alphahystmin; }
146   inline double GetHysteresisParm(void) const { return stall_hyst; }
147   inline double GetStallWarn(void) const { return impending_stall; }
148   double GetAlphaW(void) const { return alphaw; }
149
150   double GetBI2Vel(void) const { return bi2vel; }
151   double GetCI2Vel(void) const { return ci2vel; }
152
153   inline void SetAlphaCLMax(double tt) { alphaclmax=tt; }
154   inline void SetAlphaCLMin(double tt) { alphaclmin=tt; }
155
156   /** Gets the strings for the current set of coefficients.
157       @param delimeter either a tab or comma string depending on output type
158       @return a string containing the descriptive names for all coefficients */
159   string GetCoefficientStrings(string delimeter);
160
161   /** Gets the coefficient values.
162       @param delimeter either a tab or comma string depending on output type
163       @return a string containing the numeric values for the current set of
164       coefficients */
165   string GetCoefficientValues(string delimeter);
166
167   void bind(void);
168   void unbind(void);
169
170 private:
171   typedef map<string,int> AxisIndex;
172   AxisIndex AxisIdx;
173   vector <FGFunction*> variables;
174   typedef vector <FGFunction*> CoeffArray;
175   CoeffArray* Coeff;
176   FGColumnVector3 vFs;
177   FGColumnVector3 vForces;
178   FGColumnVector3 vMoments;
179   FGColumnVector3 vLastFs;
180   FGColumnVector3 vDXYZcg;
181   double alphaclmax, alphaclmin;
182   double alphahystmax, alphahystmin;
183   double impending_stall, stall_hyst;
184   double bi2vel, ci2vel,alphaw;
185   double clsq, lod, qbar_area;
186
187   typedef double (FGAerodynamics::*PMF)(int) const;
188
189   void Debug(int from);
190 };
191
192 } // namespace JSBSim
193
194 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
195 #endif
196