1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 Header: FGAerodynamics.h
7 ------------- Copyright (C) 1999 Jon S. Berndt (jon@jsbsim.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 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
45 #include "math/FGFunction.h"
46 #include "math/FGColumnVector3.h"
47 #include "math/FGMatrix33.h"
48 #include "input_output/FGXMLFileRead.h"
50 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
52 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
54 #define ID_AERODYNAMICS "$Id$"
56 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
58 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
62 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
64 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
66 /** Encapsulates the aerodynamic calculations.
67 This class owns and contains the list of force/coefficients that define the
68 aerodynamic properties of an aircraft. Here also, such unique phenomena
69 as ground effect, aerodynamic reference point shift, and maximum lift curve
74 <alphalimits unit="{RAD | DEG}">
78 <hysteresis_limits unit="{RAD | DEG}">
86 </aero_ref_pt_shift_x>
90 <axis name="{LIFT | DRAG | SIDE | ROLL | PITCH | YAW}">
91 {force coefficient definitions}
93 {additional axis definitions}
97 Optionally two other coordinate systems may be used.<br><br>
98 1) Body coordinate system:
100 <axis name="{X | Y | Z}">
103 2) Axial-Normal coordinate system:
105 <axis name="{AXIAL | NORMAL}">
108 Systems may NOT be combined, or a load error will occur.
110 @author Jon S. Berndt, Tony Peden
114 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
116 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
118 class FGAerodynamics : public FGModel, public FGXMLFileRead
123 @param Executive a pointer to the parent executive object */
124 FGAerodynamics(FGFDMExec* Executive);
128 bool InitModel(void);
130 /** Runs the Aerodynamics model; called by the Executive
131 @return false if no error */
134 /** Loads the Aerodynamics model.
135 The Load function for this class expects the XML parser to
136 have found the aerodynamics keyword in the configuration file.
137 @param element pointer to the current XML element for aerodynamics parameters.
138 @return true if successful */
139 bool Load(Element* element);
141 /** Gets the total aerodynamic force vector.
142 @return a force vector reference. */
143 FGColumnVector3& GetForces(void) {return vForces;}
145 /** Gets the aerodynamic force for an axis.
146 @param n Axis index. This could be 0, 1, or 2, or one of the
147 axis enums: eX, eY, eZ.
148 @return the force acting on an axis */
149 double GetForces(int n) const {return vForces(n);}
151 /** Gets the total aerodynamic moment vector.
152 @return a moment vector reference. */
153 FGColumnVector3& GetMoments(void) {return vMoments;}
155 /** Gets the aerodynamic moment for an axis.
156 @return the moment about a single axis (as described also in the
157 similar call to GetForces(int n).*/
158 double GetMoments(int n) const {return vMoments(n);}
160 /** Retrieves the aerodynamic forces in the wind axes.
161 @return a reference to a column vector containing the wind axis forces. */
162 FGColumnVector3& GetvFw(void) { return vFw; }
164 /** Retrieves the aerodynamic forces in the wind axes, given an axis.
165 @param axis the axis to return the force for (eX, eY, eZ).
166 @return a reference to a column vector containing the requested wind
168 double GetvFw(int axis) const { return vFw(axis); }
170 /** Retrieves the lift over drag ratio */
171 inline double GetLoD(void) const { return lod; }
173 /** Retrieves the square of the lift coefficient. */
174 inline double GetClSquared(void) const { return clsq; }
175 inline double GetAlphaCLMax(void) const { return alphaclmax; }
176 inline double GetAlphaCLMin(void) const { return alphaclmin; }
178 inline double GetHysteresisParm(void) const { return stall_hyst; }
179 inline double GetStallWarn(void) const { return impending_stall; }
180 double GetAlphaW(void) const { return alphaw; }
182 double GetBI2Vel(void) const { return bi2vel; }
183 double GetCI2Vel(void) const { return ci2vel; }
185 inline void SetAlphaCLMax(double tt) { alphaclmax=tt; }
186 inline void SetAlphaCLMin(double tt) { alphaclmin=tt; }
188 /** Gets the strings for the current set of coefficients.
189 @param delimeter either a tab or comma string depending on output type
190 @return a string containing the descriptive names for all coefficients */
191 string GetCoefficientStrings(string delimeter);
193 /** Gets the coefficient values.
194 @param delimeter either a tab or comma string depending on output type
195 @return a string containing the numeric values for the current set of
197 string GetCoefficientValues(string delimeter);
199 /** Calculates and returns the wind-to-body axis transformation matrix.
200 @return a reference to the wind-to-body transformation matrix.
202 FGMatrix33& GetTw2b(void);
204 /** Calculates and returns the body-to-wind axis transformation matrix.
205 @return a reference to the wind-to-body transformation matrix.
207 FGMatrix33& GetTb2w(void);
209 vector <FGFunction*> * GetCoeff(void) const { return Coeff; }
212 enum eAxisType {atNone, atLiftDrag, atAxialNormal, atBodyXYZ} axisType;
213 typedef map<string,int> AxisIndex;
215 FGFunction* AeroRPShift;
216 vector <FGFunction*> variables;
217 typedef vector <FGFunction*> CoeffArray;
219 FGColumnVector3 vFnative;
221 FGColumnVector3 vForces;
222 FGColumnVector3 vMoments;
223 FGColumnVector3 vDXYZcg;
224 FGColumnVector3 vDeltaRP;
227 double alphaclmax, alphaclmin;
228 double alphahystmax, alphahystmin;
229 double impending_stall, stall_hyst;
230 double bi2vel, ci2vel,alphaw;
231 double clsq, lod, qbar_area;
233 typedef double (FGAerodynamics::*PMF)(int) const;
234 void DetermineAxisSystem(void);
237 void Debug(int from);
240 } // namespace JSBSim
242 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%