]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGAuxiliary.h
Fix stall widths for the "auxilliary" (reverse flow) stalls so they
[flightgear.git] / src / FDM / JSBSim / FGAuxiliary.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3  Header:       FGAuxiliary.h
4  Author:       Jon Berndt
5  Date started: 01/26/99
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 11/22/98   JSB   Created
29   1/1/00   TP    Added calcs and getters for VTAS, VCAS, VEAS, Vground, in knots
30
31 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
32 SENTRY
33 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
34
35 #ifndef FGAUXILIARY_H
36 #define FGAUXILIARY_H
37
38 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39 INCLUDES
40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
41
42 #include "FGModel.h"
43 #include "FGColumnVector3.h"
44 #include "FGLocation.h"
45 #include "FGPropagate.h"
46
47 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
48 DEFINITIONS
49 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
50
51 #define ID_AUXILIARY "$Id$"
52
53 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
54 FORWARD DECLARATIONS
55 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
56
57 namespace JSBSim {
58
59 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
60 CLASS DOCUMENTATION
61 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
62
63 /** Encapsulates various uncategorized scheduled functions.
64     Pilot sensed accelerations are calculated here. This is used
65     for the coordinated turn ball instrument. Motion base platforms sometimes
66     use the derivative of pilot sensed accelerations as the driving parameter,
67     rather than straight accelerations.
68
69     The theory behind pilot-sensed calculations is presented:
70
71     For purposes of discussion and calculation, assume for a minute that the
72     pilot is in space and motionless in inertial space. She will feel
73     no accelerations. If the aircraft begins to accelerate along any axis or
74     axes (without rotating), the pilot will sense those accelerations. If
75     any rotational moment is applied, the pilot will sense an acceleration
76     due to that motion in the amount:
77
78     [wdot X R]  +  [w X (w X R)]
79     Term I          Term II
80
81     where:
82
83     wdot = omegadot, the rotational acceleration rate vector
84     w    = omega, the rotational rate vector
85     R    = the vector from the aircraft CG to the pilot eyepoint
86
87     The sum total of these two terms plus the acceleration of the aircraft
88     body axis gives the acceleration the pilot senses in inertial space.
89     In the presence of a large body such as a planet, a gravity field also
90     provides an accelerating attraction. This acceleration can be transformed
91     from the reference frame of the planet so as to be expressed in the frame
92     of reference of the aircraft. This gravity field accelerating attraction
93     is felt by the pilot as a force on her tushie as she sits in her aircraft
94     on the runway awaiting takeoff clearance.
95
96     In JSBSim the acceleration of the body frame in inertial space is given
97     by the F = ma relation. If the vForces vector is divided by the aircraft
98     mass, the acceleration vector is calculated. The term wdot is equivalent
99     to the JSBSim vPQRdot vector, and the w parameter is equivalent to vPQR.
100     The radius R is calculated below in the vector vToEyePt.
101
102     @author Tony Peden, Jon Berndt
103     @version $Id$
104 */
105
106 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
107 CLASS DECLARATION
108 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
109
110 class FGAuxiliary : public FGModel {
111 public:
112   /** Constructor
113       @param Executive a pointer to the parent executive object */
114   FGAuxiliary(FGFDMExec* Executive);
115
116   /// Destructor
117   ~FGAuxiliary();
118
119   /** Runs the Auxiliary routines; called by the Executive
120       @return false if no error */
121   bool Run(void);
122
123 // GET functions
124
125   // Atmospheric parameters GET functions
126   double GetVcalibratedFPS(void) const { return vcas; }
127   double GetVcalibratedKTS(void) const { return vcas*fpstokts; }
128   double GetVequivalentFPS(void) const { return veas; }
129   double GetVequivalentKTS(void) const { return veas*fpstokts; }
130
131   // total pressure above is freestream total pressure for subsonic only
132   // for supersonic it is the 1D total pressure behind a normal shock
133   double GetTotalPressure(void) const { return pt; }
134   double GetTotalTemperature(void) const { return tat; }
135   double GetTAT_C(void) const { return tatc; }
136
137   double GetPilotAccel(int idx)  const { return vPilotAccel(idx);  }
138   double GetNpilot(int idx)      const { return vPilotAccelN(idx); }
139   double GetAeroPQR(int axis)    const { return vAeroPQR(axis);    }
140   double GetEulerRates(int axis) const { return vEulerRates(axis); }
141
142   const FGColumnVector3& GetPilotAccel (void) const { return vPilotAccel;  }
143   const FGColumnVector3& GetNpilot     (void) const { return vPilotAccelN; }
144   const FGColumnVector3& GetAeroPQR    (void) const { return vAeroPQR;     }
145   const FGColumnVector3& GetEulerRates (void) const { return vEulerRates;  }
146   const FGColumnVector3& GetAeroUVW    (void) const { return vAeroUVW;     }
147   const FGLocation&      GetLocationVRP(void) const { return vLocationVRP; }
148
149   double GethVRP(void) const { return vLocationVRP.GetRadius() - Propagate->GetSeaLevelRadius(); }
150   double GetAeroUVW (int idx) const { return vAeroUVW(idx); }
151   double Getalpha   (void) const { return alpha;      }
152   double Getbeta    (void) const { return beta;       }
153   double Getadot    (void) const { return adot;       }
154   double Getbdot    (void) const { return bdot;       }
155   double GetMagBeta (void) const { return fabs(beta); }
156
157   double Getalpha   (int unit) const { if (unit == inDegrees) return alpha*radtodeg;
158                                        else cerr << "Bad units" << endl; return 0.0;}
159   double Getbeta    (int unit) const { if (unit == inDegrees) return beta*radtodeg;
160                                        else cerr << "Bad units" << endl; return 0.0;}
161   double Getadot    (int unit) const { if (unit == inDegrees) return adot*radtodeg;
162                                        else cerr << "Bad units" << endl; return 0.0;}
163   double Getbdot    (int unit) const { if (unit == inDegrees) return bdot*radtodeg;
164                                        else cerr << "Bad units" << endl; return 0.0;}
165   double GetMagBeta (int unit) const { if (unit == inDegrees) return fabs(beta)*radtodeg;
166                                        else cerr << "Bad units" << endl; return 0.0;}
167
168   double Getqbar    (void) const { return qbar;       }
169   double GetqbarUW  (void) const { return qbarUW;     }
170   double GetqbarUV  (void) const { return qbarUV;     }
171   double GetVt      (void) const { return Vt;         }
172   double GetVground (void) const { return Vground;    }
173   double GetMach    (void) const { return Mach;       }
174   double GetMachU   (void) const { return MachU;      }
175
176   double GetHOverBCG(void) const { return hoverbcg; }
177   double GetHOverBMAC(void) const { return hoverbmac; }
178
179   double GetGamma(void)              const { return gamma;         }
180   double GetGroundTrack(void)        const { return psigt;         }
181   double GetEarthPositionAngle(void) const { return earthPosAngle; }
182
183   double GetHeadWind(void);
184   double GetCrossWind(void);
185
186 // SET functions
187
188   void SetAeroUVW(FGColumnVector3 tt) { vAeroUVW = tt; }
189
190   void Setalpha  (double tt) { alpha = tt;  }
191   void Setbeta   (double tt) { beta  = tt;  }
192   void Setqbar   (double tt) { qbar = tt;   }
193   void SetqbarUW (double tt) { qbarUW = tt; }
194   void SetqbarUV (double tt) { qbarUV = tt; }
195   void SetVt     (double tt) { Vt = tt;     }
196   void SetMach   (double tt) { Mach=tt;     }
197   void Setadot   (double tt) { adot = tt;   }
198   void Setbdot   (double tt) { bdot = tt;   }
199
200   void SetAB    (double t1, double t2) { alpha=t1; beta=t2; }
201   void SetGamma (double tt)            { gamma = tt;        }
202
203 // Time routines, SET and GET functions
204
205   void SetDayOfYear    (int doy)    { day_of_year = doy;    }
206   void SetSecondsInDay (double sid) { seconds_in_day = sid; }
207
208   int    GetDayOfYear    (void) const { return day_of_year;    }
209   double GetSecondsInDay (void) const { return seconds_in_day; }
210
211   void bind(void);
212   void unbind(void);
213
214 private:
215   double vcas, veas;
216   double rhosl, rho, p, psl, pt, tat, sat, tatc; // Don't add a getter for pt!
217
218   FGColumnVector3 vPilotAccel;
219   FGColumnVector3 vPilotAccelN;
220   FGColumnVector3 vToEyePt;
221   FGColumnVector3 vAeroPQR;
222   FGColumnVector3 vAeroUVW;
223   FGColumnVector3 vEuler;
224   FGColumnVector3 vEulerRates;
225   FGColumnVector3 vMachUVW;
226   FGLocation vLocationVRP;
227
228   double Vt, Vground, Mach, MachU;
229   double qbar, qbarUW, qbarUV;
230   double alpha, beta;
231   double adot,bdot;
232   double psigt, gamma;
233   double seconds_in_day;  // seconds since current GMT day began
234   int    day_of_year;     // GMT day, 1 .. 366
235
236   double earthPosAngle;
237   double hoverbcg, hoverbmac;
238
239   void Debug(int from);
240 };
241
242 } // namespace JSBSim
243
244 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
245 #endif