Debian Codegraph @

src/FDM/JSBSim/models/FGAerodynamics.h

raw symbols SCIP
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 ([email protected]) -------------
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
11 Software Foundation; either version 2 of the License, or (at your option) any
12 later 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
20 with this program; if not, write to the Free Software Foundation, Inc., 59
21 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
23 Further information about the GNU Lesser General Public License can also be
24 found on 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
50 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
51 FORWARD DECLARATIONS
52 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
53
54 namespace JSBSim {
55
56 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57 CLASS DOCUMENTATION
58 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
59
60 /** Encapsulates the aerodynamic calculations.
61 This class owns and contains the list of force/coefficients that define the
62 aerodynamic properties of an aircraft. Here also, such unique phenomena
63 as ground effect, aerodynamic reference point shift, and maximum lift curve
64 tailoff are handled.
65
66 <h3>Configuration File Format for \<aerodynamics> Section:</h3>
67 @code{.xml}
68 <aerodynamics>
69 <alphalimits unit="{RAD | DEG}">
70 <min> {number} </min>
71 <max> {number} </max>
72 </alphalimits>
73 <hysteresis_limits unit="{RAD | DEG}">
74 <min> {number} </min>
75 <max> {number} </max>
76 </hysteresis_limits>
77 <aero_ref_pt_shift_x>
78 <function>
79 {function contents}
80 </function>
81 </aero_ref_pt_shift_x>
82 <function>
83 {function contents}
84 </function>
85 <axis name="{LIFT | DRAG | SIDE | ROLL | PITCH | YAW}">
86 {force or moment definitions}
87 </axis>
88 {additional axis definitions}
89 </aerodynamics>
90 @endcode
91
92 Optionally two other coordinate systems may be used.<br><br>
93 1) Body coordinate system:
94 @code{.xml}
95 <axis name="{X | Y | Z}">
96 @endcode
97 <br>
98 2) Axial-Normal coordinate system:
99 @code{.xml}
100 <axis name="{AXIAL | NORMAL | SIDE}">
101 @endcode
102 <br>
103 Systems may NOT be combined, or a load error will occur.
104
105 @author Jon S. Berndt, Tony Peden
106 @version $Revision: 1.30 $
107 */
108
109 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
110 CLASS DECLARATION
111 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
112
113 class JSBSIM_API FGAerodynamics : public FGModel
114 {
115
116 public:
117 /** Constructor
118 @param Executive a pointer to the parent executive object */
119 FGAerodynamics(FGFDMExec* Executive);
120 /// Destructor
121 ~FGAerodynamics() override;
122
123 bool InitModel(void) override;
124
125 /** Runs the Aerodynamics model; called by the Executive
126 Can pass in a value indicating if the executive is directing the simulation to Hold.
127 @param Holding if true, the executive has been directed to hold the sim from
128 advancing time. Some models may ignore this flag, such as the Input
129 model, which may need to be active to listen on a socket for the
130 "Resume" command to be given.
131 @return false if no error */
132 bool Run(bool Holding) override;
133
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) override;
140
141 /** Gets the total aerodynamic force vector.
142 @return a force vector reference. */
143 const FGColumnVector3& GetForces(void) const {return vForces;}
144
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);}
150
151 /** Gets the total aerodynamic moment vector about the CG.
152 @return a moment vector reference. */
153 const FGColumnVector3& GetMoments(void) const {return vMoments;}
154
155 /** Gets the aerodynamic moment about the CG 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);}
159
160 /** Gets the total aerodynamic moment vector about the Moment Reference Center.
161 @return a moment vector reference. */
162 const FGColumnVector3& GetMomentsMRC(void) const {return vMomentsMRC;}
163
164 /** Gets the aerodynamic moment about the Moment Reference Center for an axis.
165 @return the moment about a single axis (as described also in the
166 similar call to GetForces(int n).*/
167 double GetMomentsMRC(int n) const {return vMomentsMRC(n);}
168
169 /** Retrieves the aerodynamic forces in the wind axes.
170 @return a reference to a column vector containing the wind axis forces. */
171 const FGColumnVector3& GetvFw(void) const { return vFw; }
172
173 /** Retrieves the aerodynamic forces in the wind axes, given an axis.
174 @param axis the axis to return the force for (eX, eY, eZ).
175 @return a reference to a column vector containing the requested wind
176 axis force. */
177 double GetvFw(int axis) const { return vFw(axis); }
178
179 /** Retrieves the aerodynamic forces in the stability axes.
180 @return a reference to a column vector containing the stability axis forces. */
181 FGColumnVector3 GetForcesInStabilityAxes(void) const;
182
183 /** Retrieves the aerodynamic forces in the stability axes, given an axis.
184 @param axis the axis to return the force for (eX, eY, eZ).
185 @return a reference to a column vector containing the requested stability
186 axis force. */
187 double GetForcesInStabilityAxes(int n) const { return GetForcesInStabilityAxes()(n); }
188
189 /** Gets the total aerodynamic moment vector about the CG in the stability axes.
190 @return a moment vector reference. */
191 FGColumnVector3 GetMomentsInStabilityAxes(void) const { return Tb2s*vMoments; }
192
193 /** Gets the aerodynamic moment about the CG for an axis.
194 @return the moment about a single axis (as described also in the
195 similar call to GetForces(int n).*/
196 double GetMomentsInStabilityAxes(int n) const { return GetMomentsInStabilityAxes()(n); }
197
198 /** Gets the total aerodynamic moment vector about the CG in the wind axes.
199 @return a moment vector reference. */
200 FGColumnVector3 GetMomentsInWindAxes(void) const { return in.Tb2w*vMoments; }
201
202 /** Gets the aerodynamic moment about the CG for an axis.
203 @return the moment about a single axis (as described also in the
204 similar call to GetForces(int n).*/
205 double GetMomentsInWindAxes(int n) const { return GetMomentsInWindAxes()(n); }
206
207 /** Retrieves the lift over drag ratio */
208 double GetLoD(void) const { return lod; }
209
210 /** Retrieves the square of the lift coefficient. */
211 double GetClSquared(void) const { return clsq; }
212 double GetAlphaCLMax(void) const { return alphaclmax; }
213 double GetAlphaCLMin(void) const { return alphaclmin; }
214
215 double GetHysteresisParm(void) const { return stall_hyst; }
216 double GetStallWarn(void) const { return impending_stall; }
217 double GetAlphaW(void) const { return alphaw; }
218
219 double GetBI2Vel(void) const { return bi2vel; }
220 double GetCI2Vel(void) const { return ci2vel; }
221
222 void SetAlphaCLMax(double tt) { alphaclmax=tt; }
223 void SetAlphaCLMin(double tt) { alphaclmin=tt; }
224
225 /** Gets the strings for the current set of aero functions.
226 @param delimeter either a tab or comma string depending on output type
227 @return a string containing the descriptive names for all aero functions */
228 std::string GetAeroFunctionStrings(const std::string& delimeter) const;
229
230 /** Gets the aero function values.
231 @param delimeter either a tab or comma string depending on output type
232 @return a string containing the numeric values for the current set of
233 aero functions */
234 std::string GetAeroFunctionValues(const std::string& delimeter) const;
235
236 std::vector <FGFunction*> * GetAeroFunctions(void) const { return AeroFunctions; }
237
238 struct Inputs {
239 double Alpha;
240 double Beta;
241 double Vt;
242 double Qbar;
243 double Wingarea;
244 double Wingspan;
245 double Wingchord;
246 double Wingincidence;
247 FGColumnVector3 RPBody;
248 FGMatrix33 Tb2w;
249 FGMatrix33 Tw2b;
250 } in;
251
252 private:
253 enum eAxisType {atNone, atWind, atBodyAxialNormal, atBodyXYZ, atStability} forceAxisType, momentAxisType;
254 typedef std::map<std::string,int> AxisIndex;
255 AxisIndex AxisIdx;
256 FGFunction* AeroRPShift;
257 typedef std::vector <FGFunction*> AeroFunctionArray;
258 AeroFunctionArray* AeroFunctions;
259 FGMatrix33 Ts2b, Tb2s;
260 FGColumnVector3 vFnative;
261 FGColumnVector3 vFw;
262 FGColumnVector3 vForces;
263 AeroFunctionArray* AeroFunctionsAtCG;
264 FGColumnVector3 vFnativeAtCG;
265 FGColumnVector3 vForcesAtCG;
266 FGColumnVector3 vMoments;
267 FGColumnVector3 vMomentsMRC;
268 FGColumnVector3 vMomentsMRCBodyXYZ;
269 FGColumnVector3 vDXYZcg;
270 FGColumnVector3 vDeltaRP;
271 double alphaclmax, alphaclmin;
272 double alphaclmax0, alphaclmin0;
273 double alphahystmax, alphahystmin;
274 double impending_stall, stall_hyst;
275 double bi2vel, ci2vel,alphaw;
276 double clsq, lod, qbar_area;
277
278 typedef double (FGAerodynamics::*PMF)(int) const;
279 void DetermineAxisSystem(Element* document);
280 void ProcessAxesNameAndFrame(FGAerodynamics::eAxisType& axisType,
281 const std::string& name, const std::string& frame,
282 Element* el, const std::string& validNames);
283 void bind(void);
284 void BuildStabilityTransformMatrices(void);
285
286 void Debug(int from) override;
287 };
288
289 } // namespace JSBSim
290
291 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
292 #endif