]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGCoefficient.h
Initial revision
[flightgear.git] / src / FDM / JSBSim / FGCoefficient.h
1 /*******************************************************************************
2
3  Header:       FGCoefficient.h
4  Author:       Jon Berndt
5  Date started: 12/28/98
6
7  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
8
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU General Public License as published by the Free Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  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 General Public License for more
17  details.
18
19  You should have received a copy of the GNU 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.
22
23  Further information about the GNU General Public License can also be found on
24  the world wide web at http://www.gnu.org.
25
26 HISTORY
27 --------------------------------------------------------------------------------
28 12/28/98   JSB   Created
29
30 ********************************************************************************
31 SENTRY
32 *******************************************************************************/
33
34 #ifndef FGCOEFFICIENT_H
35 #define FGCOEFFICIENT_H
36
37 /*******************************************************************************
38 INCLUDES
39 *******************************************************************************/
40 #ifdef FGFS
41 #  include <Include/compiler.h>
42 #  include STL_STRING
43 #  ifdef FG_HAVE_STD_INCLUDES
44 #    include <fstream>
45 #  else
46 #    include <fstream.h>
47 #  endif
48    FG_USING_STD(string);
49 #else
50 #  include <string>
51 #  include <fstream>
52 #endif
53
54 /*******************************************************************************
55 DEFINES
56 *******************************************************************************/
57
58 using namespace std;
59
60 #define FG_QBAR         1
61 #define FG_WINGAREA     2
62 #define FG_WINGSPAN     4
63 #define FG_CBAR         8
64 #define FG_ALPHA       16
65 #define FG_ALPHADOT    32
66 #define FG_BETA        64
67 #define FG_BETADOT    128
68 #define FG_PITCHRATE  256
69 #define FG_ROLLRATE   512
70 #define FG_YAWRATE   1024
71 #define FG_ELEVATOR  2048
72 #define FG_AILERON   4096
73 #define FG_RUDDER    8192
74 #define FG_MACH     16384
75 #define FG_ALTITUDE 32768L
76
77 /*******************************************************************************
78 FORWARD DECLARATIONS
79 *******************************************************************************/
80 class FGFDMExec;
81 class FGState;
82 class FGAtmosphere;
83 class FGFCS;
84 class FGAircraft;
85 class FGTranslation;
86 class FGRotation;
87 class FGPosition;
88 class FGAuxiliary;
89 class FGOutput;
90
91 /*******************************************************************************
92 COMMENTS, REFERENCES,  and NOTES
93 *******************************************************************************/
94 /**
95 This class models the stability derivative coefficient lookup tables or 
96 equations. Note that the coefficients need not be calculated each delta-t.
97
98 The coefficient files are located in the axis subdirectory for each aircraft.
99 For instance, for the X-15, you would find subdirectories under the
100 aircraft/X-15/ directory named CLIFT, CDRAG, CSIDE, CROLL, CPITCH, CYAW. Under
101 each of these directories would be files named a, a0, q, and so on. The file
102 named "a" under the CLIFT directory would contain data for the stability
103 derivative modeling lift due to a change in alpha. See the FGAircraft.cpp file
104 for additional information. The coefficient files have the following format:
105
106 <name of coefficient>
107 <short description of coefficient with no embedded spaces>
108 <method used in calculating the coefficient: TABLE | EQUATION | VECTOR | VALUE>
109   <parameter identifier for table row (if required)>
110   <parameter identifier for table column (if required)>
111 <OR'ed list of parameter identifiers needed to turn this coefficient into a force>
112 <number of rows in table (if required)>
113 <number of columns in table (if required)>
114
115 <value of parameter indexing into the column of a table or vector - or value
116   itself for a VALUE coefficient>
117 <values of parameter indexing into row of a table if TABLE type> <Value of
118   coefficient at this row and column>
119
120 <... repeat above for each column of data in table ...>
121
122 As an example for the X-15, for the lift due to mach:
123 <PRE>
124
125 CLa0
126 Lift_at_zero_alpha
127 Table 8 3
128 16384
129 32768
130 16387
131
132 0.00
133 0.0 0.0
134 0.5 0.4
135 0.9 0.9
136 1.0 1.6
137 1.1 1.3
138 1.4 1.0
139 2.0 0.5
140 3.0 0.5
141
142 30000.00
143 0.0 0.0
144 0.5 0.5
145 0.9 1.0
146 1.0 1.7
147 1.1 1.4
148 1.4 1.1
149 2.0 0.6
150 3.0 0.6
151
152 70000.00
153 0.0 0.0
154 0.5 0.6
155 0.9 1.1
156 1.0 1.7
157 1.1 1.5
158 1.4 1.2
159 2.0 0.7
160 3.0 0.7
161 </PRE>
162
163 Note that the values in a row which index into the table must be the same value
164 for each column of data, so the first column of numbers for each altitude are
165 seen to be equal, and there are the same number of values for each altitude.
166
167 <PRE>
168 FG_QBAR         1
169 FG_WINGAREA     2
170 FG_WINGSPAN     4
171 FG_CBAR         8
172 FG_ALPHA       16
173 FG_ALPHADOT    32
174 FG_BETA        64
175 FG_BETADOT    128
176 FG_PITCHRATE  256
177 FG_ROLLRATE   512
178 FG_YAWRATE   1024
179 FG_ELEVATOR  2048
180 FG_AILERON   4096
181 FG_RUDDER    8192
182 FG_MACH     16384
183 FG_ALTITUDE 32768L
184 </PRE>
185 @author Jon S. Berndt
186 @memo This class models the stability derivative coefficient lookup tables or equations.
187 */
188 /*******************************************************************************
189 CLASS DECLARATION
190 *******************************************************************************/
191
192 class FGCoefficient
193 {
194 public:
195   // ***************************************************************************
196   /** @memo
197       @param
198       @return
199   */
200   FGCoefficient(FGFDMExec*, ifstream&);
201
202   // ***************************************************************************
203   /** @memo
204       @param
205       @return
206   */
207   ~FGCoefficient(void);
208
209   // ***************************************************************************
210   /** @memo
211       @param
212       @return
213   */
214   bool Allocate(int);
215
216   // ***************************************************************************
217   /** @memo
218       @param
219       @return
220   */
221   bool Allocate(int, int);
222
223   // ***************************************************************************
224   /** @memo
225       @param
226       @return
227   */
228   float Value(float, float);
229
230   // ***************************************************************************
231   /** @memo
232       @param
233       @return
234   */
235   float Value(float);
236
237   // ***************************************************************************
238   /** @memo
239       @param
240       @return
241   */
242   float Value(void);
243
244   // ***************************************************************************
245   /** @memo
246       @param
247       @return
248   */
249   float TotalValue(void);
250
251   // ***************************************************************************
252   /** @memo
253       @param
254       @return
255   */
256   enum Type {UNKNOWN, VALUE, VECTOR, TABLE, EQUATION};
257
258 protected:
259
260 private:
261   string filename;
262   string description;
263   string name;
264   string method;
265   float StaticValue;
266   float *Table2D;
267   float **Table3D;
268   float LookupR, LookupC;
269   long int mult_idx[10];
270   int rows, columns;
271   Type type;
272   int multipliers;
273   int mult_count;
274
275   float GetCoeffVal(int);
276
277   FGFDMExec*      FDMExec;
278   FGState*        State;
279   FGAtmosphere*   Atmosphere;
280   FGFCS*          FCS;
281   FGAircraft*     Aircraft;
282   FGTranslation*  Translation;
283   FGRotation*     Rotation;
284   FGPosition*     Position;
285   FGAuxiliary*    Auxiliary;
286   FGOutput*       Output;
287 };
288
289 /******************************************************************************/
290 #endif