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: FGAerodynamics.h,v 1.23 2011/05/20 03:18:36 jberndt Exp $"
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 or moment 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 | SIDE}">
109 Systems may NOT be combined, or a load error will occur.
111 @author Jon S. Berndt, Tony Peden
112 @version $Revision: 1.23 $
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 Can pass in a value indicating if the executive is directing the simulation to Hold.
133 @param Holding if true, the executive has been directed to hold the sim from
134 advancing time. Some models may ignore this flag, such as the Input
135 model, which may need to be active to listen on a socket for the
136 "Resume" command to be given.
137 @return false if no error */
138 bool Run(bool Holding);
140 /** Loads the Aerodynamics model.
141 The Load function for this class expects the XML parser to
142 have found the aerodynamics keyword in the configuration file.
143 @param element pointer to the current XML element for aerodynamics parameters.
144 @return true if successful */
145 bool Load(Element* element);
147 /** Gets the total aerodynamic force vector.
148 @return a force vector reference. */
149 const FGColumnVector3& GetForces(void) const {return vForces;}
151 /** Gets the aerodynamic force for an axis.
152 @param n Axis index. This could be 0, 1, or 2, or one of the
153 axis enums: eX, eY, eZ.
154 @return the force acting on an axis */
155 double GetForces(int n) const {return vForces(n);}
157 /** Gets the total aerodynamic moment vector.
158 @return a moment vector reference. */
159 const FGColumnVector3& GetMoments(void) const {return vMoments;}
161 /** Gets the aerodynamic moment for an axis.
162 @return the moment about a single axis (as described also in the
163 similar call to GetForces(int n).*/
164 double GetMoments(int n) const {return vMoments(n);}
166 /** Retrieves the aerodynamic forces in the wind axes.
167 @return a reference to a column vector containing the wind axis forces. */
168 const FGColumnVector3& GetvFw(void) const { return vFw; }
170 /** Retrieves the aerodynamic forces in the wind axes, given an axis.
171 @param axis the axis to return the force for (eX, eY, eZ).
172 @return a reference to a column vector containing the requested wind
174 double GetvFw(int axis) const { return vFw(axis); }
176 /** Retrieves the lift over drag ratio */
177 double GetLoD(void) const { return lod; }
179 /** Retrieves the square of the lift coefficient. */
180 double GetClSquared(void) const { return clsq; }
181 double GetAlphaCLMax(void) const { return alphaclmax; }
182 double GetAlphaCLMin(void) const { return alphaclmin; }
184 double GetHysteresisParm(void) const { return stall_hyst; }
185 double GetStallWarn(void) const { return impending_stall; }
186 double GetAlphaW(void) const { return alphaw; }
188 double GetBI2Vel(void) const { return bi2vel; }
189 double GetCI2Vel(void) const { return ci2vel; }
191 void SetAlphaCLMax(double tt) { alphaclmax=tt; }
192 void SetAlphaCLMin(double tt) { alphaclmin=tt; }
194 /** Gets the strings for the current set of aero functions.
195 @param delimeter either a tab or comma string depending on output type
196 @return a string containing the descriptive names for all aero functions */
197 std::string GetAeroFunctionStrings(const std::string& delimeter) const;
199 /** Gets the aero function values.
200 @param delimeter either a tab or comma string depending on output type
201 @return a string containing the numeric values for the current set of
203 std::string GetAeroFunctionValues(const std::string& delimeter) const;
205 /** Calculates and returns the wind-to-body axis transformation matrix.
206 @return a reference to the wind-to-body transformation matrix.
208 FGMatrix33& GetTw2b(void);
210 /** Calculates and returns the body-to-wind axis transformation matrix.
211 @return a reference to the wind-to-body transformation matrix.
213 FGMatrix33& GetTb2w(void);
215 std::vector <FGFunction*> * GetAeroFunctions(void) const { return AeroFunctions; }
218 enum eAxisType {atNone, atLiftDrag, atAxialNormal, atBodyXYZ} axisType;
219 typedef std::map<std::string,int> AxisIndex;
221 FGFunction* AeroRPShift;
222 typedef vector <FGFunction*> AeroFunctionArray;
223 AeroFunctionArray* AeroFunctions;
224 FGColumnVector3 vFnative;
226 FGColumnVector3 vForces;
227 FGColumnVector3 vMoments;
228 FGColumnVector3 vDXYZcg;
229 FGColumnVector3 vDeltaRP;
232 double alphaclmax, alphaclmin;
233 double alphahystmax, alphahystmin;
234 double impending_stall, stall_hyst;
235 double bi2vel, ci2vel,alphaw;
236 double clsq, lod, qbar_area;
238 typedef double (FGAerodynamics::*PMF)(int) const;
239 void DetermineAxisSystem(void);
242 void Debug(int from);
245 } // namespace JSBSim
247 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%