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