1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 Header: FGAerodynamics.h
7 ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
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
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
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.
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.
27 --------------------------------------------------------------------------------
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
34 #ifndef FGAERODYNAMICS_H
35 #define FGAERODYNAMICS_H
37 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
42 # include <simgear/compiler.h>
43 # ifdef SG_HAVE_STD_INCLUDES
56 #include <math/FGFunction.h>
57 #include <math/FGColumnVector3.h>
58 #include <math/FGMatrix33.h>
59 #include <input_output/FGXMLFileRead.h>
61 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
63 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
65 #define ID_AERODYNAMICS "$Id$"
67 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
69 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
73 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
75 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
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
85 <alphalimits unit="{RAD | DEG}">
89 <hysteresis_limits unit="{RAD | DEG}">
97 </aero_ref_pt_shift_x>
101 <axis name="{LIFT | DRAG | SIDE | ROLL | PITCH | YAW}">
102 {force coefficient definitions}
104 {additional axis definitions}
108 Optionally two other coordinate systems may be used.<br><br>
109 1) Body coordinate system:
111 <axis name="{X | Y | Z}">
114 2) Axial-Normal coordinate system:
116 <axis name="{AXIAL | NORMAL}">
119 Systems may NOT be combined, or a load error will occur.
121 @author Jon S. Berndt, Tony Peden
125 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
127 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
129 class FGAerodynamics : public FGModel, public FGXMLFileRead
134 @param Executive a pointer to the parent executive object */
135 FGAerodynamics(FGFDMExec* Executive);
139 bool InitModel(void);
141 /** Runs the Aerodynamics model; called by the Executive
142 @return false if no error */
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);
152 /** Gets the total aerodynamic force vector.
153 @return a force vector reference. */
154 FGColumnVector3& GetForces(void) {return vForces;}
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);}
162 /** Gets the total aerodynamic moment vector.
163 @return a moment vector reference. */
164 FGColumnVector3& GetMoments(void) {return vMoments;}
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);}
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; }
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
179 double GetvFw(int axis) const { return vFw(axis); }
181 /** Retrieves the lift over drag ratio */
182 inline double GetLoD(void) const { return lod; }
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; }
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; }
193 double GetBI2Vel(void) const { return bi2vel; }
194 double GetCI2Vel(void) const { return ci2vel; }
196 inline void SetAlphaCLMax(double tt) { alphaclmax=tt; }
197 inline void SetAlphaCLMin(double tt) { alphaclmin=tt; }
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);
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
208 string GetCoefficientValues(string delimeter);
210 /** Calculates and returns the wind-to-body axis transformation matrix.
211 @return a reference to the wind-to-body transformation matrix.
213 FGMatrix33& GetTw2b(void);
215 /** Calculates and returns the body-to-wind axis transformation matrix.
216 @return a reference to the wind-to-body transformation matrix.
218 FGMatrix33& GetTb2w(void);
220 vector <FGFunction*> * GetCoeff(void) const { return Coeff; }
223 enum eAxisType {atNone, atLiftDrag, atAxialNormal, atBodyXYZ} axisType;
224 typedef map<string,int> AxisIndex;
226 FGFunction* AeroRPShift;
227 vector <FGFunction*> variables;
228 typedef vector <FGFunction*> CoeffArray;
230 FGColumnVector3 vFnative;
232 FGColumnVector3 vForces;
233 FGColumnVector3 vMoments;
234 FGColumnVector3 vDXYZcg;
235 FGColumnVector3 vDeltaRP;
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;
244 typedef double (FGAerodynamics::*PMF)(int) const;
245 void DetermineAxisSystem(void);
248 void Debug(int from);
251 } // namespace JSBSim
253 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%