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 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
46 #include "math/FGFunction.h"
47 #include "math/FGColumnVector3.h"
48 #include "math/FGMatrix33.h"
49 #include "input_output/FGXMLFileRead.h"
51 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
55 #define ID_AERODYNAMICS "$Id$"
57 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
63 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
65 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
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
75 <alphalimits unit="{RAD | DEG}">
79 <hysteresis_limits unit="{RAD | DEG}">
87 </aero_ref_pt_shift_x>
91 <axis name="{LIFT | DRAG | SIDE | ROLL | PITCH | YAW}">
92 {force coefficient definitions}
94 {additional axis definitions}
98 Optionally two other coordinate systems may be used.<br><br>
99 1) Body coordinate system:
101 <axis name="{X | Y | Z}">
104 2) Axial-Normal coordinate system:
106 <axis name="{AXIAL | NORMAL}">
109 Systems may NOT be combined, or a load error will occur.
111 @author Jon S. Berndt, Tony Peden
115 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
117 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
119 class FGAerodynamics : public FGModel, public FGXMLFileRead
124 @param Executive a pointer to the parent executive object */
125 FGAerodynamics(FGFDMExec* Executive);
129 bool InitModel(void);
131 /** Runs the Aerodynamics model; called by the Executive
132 @return false if no error */
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);
142 /** Gets the total aerodynamic force vector.
143 @return a force vector reference. */
144 FGColumnVector3& GetForces(void) {return vForces;}
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);}
152 /** Gets the total aerodynamic moment vector.
153 @return a moment vector reference. */
154 FGColumnVector3& GetMoments(void) {return vMoments;}
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);}
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; }
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
169 double GetvFw(int axis) const { return vFw(axis); }
171 /** Retrieves the lift over drag ratio */
172 inline double GetLoD(void) const { return lod; }
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; }
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; }
183 double GetBI2Vel(void) const { return bi2vel; }
184 double GetCI2Vel(void) const { return ci2vel; }
186 inline void SetAlphaCLMax(double tt) { alphaclmax=tt; }
187 inline void SetAlphaCLMin(double tt) { alphaclmin=tt; }
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;
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
198 std::string GetCoefficientValues(const std::string& delimeter) const;
200 /** Calculates and returns the wind-to-body axis transformation matrix.
201 @return a reference to the wind-to-body transformation matrix.
203 FGMatrix33& GetTw2b(void);
205 /** Calculates and returns the body-to-wind axis transformation matrix.
206 @return a reference to the wind-to-body transformation matrix.
208 FGMatrix33& GetTb2w(void);
210 std::vector <FGFunction*> * GetCoeff(void) const { return Coeff; }
213 enum eAxisType {atNone, atLiftDrag, atAxialNormal, atBodyXYZ} axisType;
214 typedef std::map<std::string,int> AxisIndex;
216 FGFunction* AeroRPShift;
217 std::vector <FGFunction*> variables;
218 typedef vector <FGFunction*> CoeffArray;
220 FGColumnVector3 vFnative;
222 FGColumnVector3 vForces;
223 FGColumnVector3 vMoments;
224 FGColumnVector3 vDXYZcg;
225 FGColumnVector3 vDeltaRP;
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;
234 typedef double (FGAerodynamics::*PMF)(int) const;
235 void DetermineAxisSystem(void);
238 void Debug(int from);
241 } // namespace JSBSim
243 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%