JSBSim Flight Dynamics Model  1.0 (02 March 2017)
An Open Source Flight Dynamics and Control Software Library in C++
FGAtmosphere.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 
3  Header: FGAtmosphere.h
4  Author: Jon Berndt
5  Date started: 6/2011
6 
7  ------------- Copyright (C) 2011 Jon S. Berndt (jon@jsbsim.org) -------------
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 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 Lesser General Public License for more
17  details.
18 
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.
22 
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.
25 
26 HISTORY
27 --------------------------------------------------------------------------------
28 5/2011 JSB Created
29 
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31 SENTRY
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
33 
34 #ifndef FGATMOSPHERE_H
35 #define FGATMOSPHERE_H
36 
37 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38 INCLUDES
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40 
41 #include <vector>
42 #include "models/FGModel.h"
43 
44 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
45 DEFINITIONS
46 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
47 
48 #define ID_ATMOSPHERE "$Id: FGAtmosphere.h,v 1.32 2016/01/10 15:56:30 bcoconni Exp $"
49 
50 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
51 FORWARD DECLARATIONS
52 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
53 
54 namespace JSBSim {
55 
56 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57 CLASS DOCUMENTATION
58 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
59 
80 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
81 CLASS DECLARATION
82 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
83 
84 class FGAtmosphere : public FGModel {
85 public:
86 
88  enum eTemperature {eNoTempUnit=0, eFahrenheit, eCelsius, eRankine, eKelvin};
89 
91  enum ePressure {eNoPressUnit=0, ePSF, eMillibars, ePascals, eInchesHg};
92 
95 
97  virtual ~FGAtmosphere();
98 
106  bool Run(bool Holding);
107 
108  bool InitModel(void);
109 
110  // *************************************************************************
114  // @{
117  virtual double GetTemperature() const {return Temperature;}
118 
122  virtual double GetTemperature(double altitude) const = 0;
123 
126  virtual double GetTemperatureSL() const { return GetTemperature(0.0); }
127 
130  virtual double GetTemperatureRatio() const { return GetTemperature()*rSLtemperature; }
131 
134  virtual double GetTemperatureRatio(double h) const { return GetTemperature(h)*rSLtemperature; }
135 
139  virtual void SetTemperatureSL(double t, eTemperature unit=eFahrenheit);
140 
145  virtual void SetTemperature(double t, double h, eTemperature unit=eFahrenheit) = 0;
147 
148  // *************************************************************************
150 
151  virtual double GetPressure(void) const {return Pressure;}
153 
155  virtual double GetPressure(double altitude) const = 0;
156 
157  // Returns the sea level pressure in target units, default in psf.
158  virtual double GetPressureSL(ePressure to=ePSF) const { return ConvertFromPSF(SLpressure, to); }
159 
161  virtual double GetPressureRatio(void) const { return Pressure*rSLpressure; }
162 
167  virtual void SetPressureSL(ePressure unit, double pressure);
169 
170  // *************************************************************************
172 
173 
175  virtual double GetDensity(void) const {return Density;}
176 
178  virtual double GetDensity(double altitude) const;
179 
181  virtual double GetDensitySL(void) const { return SLdensity; }
182 
184  virtual double GetDensityRatio(void) const { return Density*rSLdensity; }
186 
187  // *************************************************************************
189 
190  virtual double GetSoundSpeed(void) const {return Soundspeed;}
192 
194  virtual double GetSoundSpeed(double altitude) const;
195 
197  virtual double GetSoundSpeedSL(void) const { return SLsoundspeed; }
198 
200  virtual double GetSoundSpeedRatio(void) const { return Soundspeed*rSLsoundspeed; }
202 
203  // *************************************************************************
205 
206  virtual double GetAbsoluteViscosity(void) const {return Viscosity;}
208 
210  virtual double GetKinematicViscosity(void) const {return KinematicViscosity;}
212 
213  virtual double GetDensityAltitude() const {return DensityAltitude;}
214 
215  virtual double GetPressureAltitude() const {return PressureAltitude;}
216 
217  struct Inputs {
218  double altitudeASL;
219  } in;
220 
221 protected:
222  double SLtemperature, SLdensity, SLpressure, SLsoundspeed; // Sea level conditions
223  double Temperature, Density, Pressure, Soundspeed; // Current actual conditions at altitude
224  double rSLtemperature, rSLdensity, rSLpressure, rSLsoundspeed; // Reciprocal of sea level conditions
225 
226  double PressureAltitude;
227  double DensityAltitude;
228 
229  const double SutherlandConstant, Beta;
230  double Viscosity, KinematicViscosity;
231 
233  void Calculate(double altitude);
234 
235  // Converts to Rankine from one of several unit systems.
236  virtual double ConvertToRankine(double t, eTemperature unit) const;
237 
238  // Converts to PSF (pounds per square foot) from one of several unit systems.
239  virtual double ConvertToPSF(double t, ePressure unit=ePSF) const;
240 
241  // Converts from PSF (pounds per square foot) to one of several unit systems.
242  virtual double ConvertFromPSF(double t, ePressure unit=ePSF) const;
243 
244  virtual void bind(void);
245  void Debug(int from);
246 };
247 
248 } // namespace JSBSim
249 
250 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
251 #endif
252 
virtual void SetPressureSL(ePressure unit, double pressure)
Sets the sea level pressure for modeling.
virtual void SetTemperatureSL(double t, eTemperature unit=eFahrenheit)
Sets the Sea Level temperature.
void Calculate(double altitude)
Calculate the atmosphere for the given altitude.
virtual double GetSoundSpeedSL(void) const
Returns the sea level speed of sound in ft/sec.
Definition: FGAtmosphere.h:197
ePressure
Enums for specifying pressure units.
Definition: FGAtmosphere.h:91
virtual double GetPressure(void) const
Returns the pressure in psf.
Definition: FGAtmosphere.h:152
virtual double GetAbsoluteViscosity(void) const
Returns the absolute viscosity.
Definition: FGAtmosphere.h:207
virtual ~FGAtmosphere()
Destructor.
virtual double GetPressureRatio(void) const
Returns the ratio of at-altitude pressure over the sea level value.
Definition: FGAtmosphere.h:161
virtual double GetDensitySL(void) const
Returns the sea level density in slugs/ft^3.
Definition: FGAtmosphere.h:181
virtual double GetSoundSpeed(void) const
Returns the speed of sound in ft/sec.
Definition: FGAtmosphere.h:191
virtual double GetTemperatureRatio(double h) const
Returns the ratio of the temperature as modeled at the supplied altitude over the sea level value...
Definition: FGAtmosphere.h:134
Base class for all scheduled JSBSim models.
Definition: FGModel.h:74
virtual double GetTemperatureSL() const
Returns the actual, modeled sea level temperature in degrees Rankine.
Definition: FGAtmosphere.h:126
bool Run(bool Holding)
Runs the atmosphere forces model; called by the Executive.
Models an empty, abstract base atmosphere class.
Definition: FGAtmosphere.h:84
virtual double GetDensity(void) const
Returns the density in slugs/ft^3.
Definition: FGAtmosphere.h:175
FGAtmosphere(FGFDMExec *)
Constructor.
eTemperature
Enums for specifying temperature units.
Definition: FGAtmosphere.h:88
virtual double GetSoundSpeedRatio(void) const
Returns the ratio of at-altitude sound speed over the sea level value.
Definition: FGAtmosphere.h:200
virtual void SetTemperature(double t, double h, eTemperature unit=eFahrenheit)=0
Sets the temperature at the supplied altitude.
Encapsulates the JSBSim simulation executive.
Definition: FGFDMExec.h:189
virtual double GetDensityRatio(void) const
Returns the ratio of at-altitude density over the sea level value.
Definition: FGAtmosphere.h:184
virtual double GetTemperatureRatio() const
Returns the ratio of the at-current-altitude temperature as modeled over the sea level value...
Definition: FGAtmosphere.h:130
virtual double GetTemperature() const
Returns the actual, modeled temperature at the current altitude in degrees Rankine.
Definition: FGAtmosphere.h:117
virtual double GetKinematicViscosity(void) const
Returns the kinematic viscosity.
Definition: FGAtmosphere.h:210