]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGCoefficient.h
Latest JSBSim changes, mostly to support yaw and roll trim.
[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
41 #ifdef FGFS
42 #  include <simgear/compiler.h>
43 #endif
44
45 #include <vector>
46 #include <string>
47 #include "FGConfigFile.h"
48 #include "FGTable.h"
49 #include "FGJSBBase.h"
50
51 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
52 DEFINITIONS
53 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
54
55 #define ID_COEFFICIENT "$Id$"
56
57 using std::vector;
58
59 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
60 FORWARD DECLARATIONS
61 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
62
63 class FGFDMExec;
64 class FGState;
65 class FGAtmosphere;
66 class FGFCS;
67 class FGAircraft;
68 class FGTranslation;
69 class FGRotation;
70 class FGPosition;
71 class FGAuxiliary;
72 class FGOutput;
73
74 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
75 COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
76 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
77
78 Note that the coefficients need not be calculated each delta-t. This is
79 something that may be fixed someday.
80
81 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
82 CLASS DOCUMENTATION
83 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
84
85 /** This class models the stability derivative coefficient lookup tables.
86     Each coefficient for an axis is stored in that axes' vector of coefficients.
87     Each FDM execution frame the Run() method of the [currently] FGAircraft model
88     is called and the coefficient value is calculated.
89     @author Jon S. Berndt
90     @version $Id$
91     @see -
92 */
93
94 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
95 CLASS DECLARATION
96 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
97
98 class FGCoefficient : public FGJSBBase
99 {
100 public:
101   FGCoefficient(FGFDMExec*);
102   virtual ~FGCoefficient();
103   
104   virtual bool Load(FGConfigFile* AC_cfg);
105   
106   typedef vector <eParam> MultVec;
107   virtual double TotalValue(void);
108   virtual inline string Getname(void) {return name;}
109   virtual inline double GetSD(void) { return SD;}
110   inline MultVec Getmultipliers(void) {return multipliers;}
111   void DumpSD(void);  
112   
113   /** Outputs coefficient information.
114       Non-dimensionalizing parameter descriptions are output
115       for each aero coefficient defined.
116       @param multipliers the list of multipliers for this coefficient.*/
117   virtual void DisplayCoeffFactors(void);
118   virtual inline string GetCoefficientStrings(void) { return name; }
119   virtual string GetCoefficientValues(void);
120   
121   inline void setBias(double b) { bias=b; }
122   inline void setGain(double g) { gain=g; };
123   inline double getBias(void) { return bias; }
124   inline double getGain(void) { return gain; }
125
126 private:
127   enum Type {UNKNOWN, VALUE, VECTOR, TABLE, EQUATION};
128
129   int numInstances;
130   string filename;
131   string description;
132   string name;
133   string method;
134   string multparms;
135   string multparmsRow;
136   string multparmsCol;
137   double Value(double, double);
138   double Value(double);
139   double Value(void);
140   double StaticValue;
141   double bias,gain;
142   eParam LookupR, LookupC;
143   MultVec multipliers;
144   int rows, columns;
145   Type type;
146   double SD; // Actual stability derivative (or other coefficient) value
147   FGTable *Table;
148
149   FGFDMExec*      FDMExec;
150   FGState*        State;
151   FGAtmosphere*   Atmosphere;
152   FGFCS*          FCS;
153   FGAircraft*     Aircraft;
154   FGTranslation*  Translation;
155   FGRotation*     Rotation;
156   FGPosition*     Position;
157   FGAuxiliary*    Auxiliary;
158   FGOutput*       Output;
159
160   virtual void Debug(int from);
161 };
162
163 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
164 #endif
165