FlightGear next
FGAtmosphere.h
Go to the documentation of this file.
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
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
26HISTORY
27--------------------------------------------------------------------------------
285/2011 JSB Created
29
30%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31SENTRY
32%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
33
34#ifndef FGATMOSPHERE_H
35#define FGATMOSPHERE_H
36
37/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38INCLUDES
39%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40
41#include "models/FGModel.h"
42
43/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
44FORWARD DECLARATIONS
45%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
46
47namespace JSBSim {
48
49/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
50CLASS DOCUMENTATION
51%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
52
71
72/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73CLASS DECLARATION
74%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
75
76class FGAtmosphere : public FGModel {
77public:
78
81
84
87
89 virtual ~FGAtmosphere();
90
98 bool Run(bool Holding) override;
99
100 bool InitModel(void) override;
101
102 // *************************************************************************
106 // @{
109 virtual double GetTemperature() const {return Temperature;}
110
114 virtual double GetTemperature(double altitude) const = 0;
115
118 virtual double GetTemperatureSL() const { return SLtemperature; }
119
122 virtual double GetTemperatureRatio() const { return GetTemperature()/SLtemperature; }
123
126 virtual double GetTemperatureRatio(double h) const { return GetTemperature(h)/SLtemperature; }
127
131 virtual void SetTemperatureSL(double t, eTemperature unit=eFahrenheit);
132
137 virtual void SetTemperature(double t, double h, eTemperature unit=eFahrenheit) = 0;
139
140 // *************************************************************************
142
143
144 virtual double GetPressure(void) const {return Pressure;}
145
147 virtual double GetPressure(double altitude) const = 0;
148
149 // Returns the sea level pressure in target units, default in psf.
150 virtual double GetPressureSL(ePressure to=ePSF) const { return ConvertFromPSF(SLpressure, to); }
151
153 virtual double GetPressureRatio(void) const { return Pressure/SLpressure; }
154
159 virtual void SetPressureSL(ePressure unit, double pressure);
161
162 // *************************************************************************
164
165
167 virtual double GetDensity(void) const {return Density;}
168
170 virtual double GetDensity(double altitude) const;
171
173 virtual double GetDensitySL(void) const { return SLdensity; }
174
176 virtual double GetDensityRatio(void) const { return Density/SLdensity; }
178
179 // *************************************************************************
181
182
183 virtual double GetSoundSpeed(void) const {return Soundspeed;}
184
186 virtual double GetSoundSpeed(double altitude) const;
187
189 virtual double GetSoundSpeedSL(void) const { return SLsoundspeed; }
190
192 virtual double GetSoundSpeedRatio(void) const { return Soundspeed/SLsoundspeed; }
194
195 // *************************************************************************
197
198
199 virtual double GetAbsoluteViscosity(void) const {return Viscosity;}
200
202 virtual double GetKinematicViscosity(void) const {return KinematicViscosity;}
204
205 virtual double GetDensityAltitude() const {return DensityAltitude;}
206
207 virtual double GetPressureAltitude() const {return PressureAltitude;}
208
209 struct Inputs {
211 } in;
212
213 static constexpr double StdDaySLtemperature = 518.67;
214 static constexpr double StdDaySLpressure = 2116.228;
215 static const double StdDaySLsoundspeed;
216
217protected:
218 double SLtemperature, SLdensity, SLpressure, SLsoundspeed; // Sea level conditions
219 double Temperature, Density, Pressure, Soundspeed; // Current actual conditions at altitude
220
223
224 static constexpr double SutherlandConstant = 198.72; // deg Rankine
225 static constexpr double Beta = 2.269690E-08; // slug/(sec ft R^0.5)
227
229 virtual void Calculate(double altitude);
230
236 virtual double CalculateDensityAltitude(double density, double geometricAlt) { return geometricAlt; }
237
243 virtual double CalculatePressureAltitude(double pressure, double geometricAlt) { return geometricAlt; }
244
246 double ConvertToRankine(double t, eTemperature unit) const;
247
249 double ConvertFromRankine(double t, eTemperature unit) const;
250
252 double ConvertToPSF(double t, ePressure unit=ePSF) const;
253
255 double ConvertFromPSF(double t, ePressure unit=ePSF) const;
256
258
259
260 static constexpr double Rstar = 8.31432 * kgtoslug / KelvinToRankine(fttom * fttom);
262 static constexpr double Mair = 28.9645 * kgtoslug / 1000.0;
268 static constexpr double g0 = 9.80665 / fttom;
270 static double Reng;
272
273 static constexpr double SHRatio = 1.4;
274
275 virtual void bind(void);
276 void Debug(int from) override;
277};
278
279} // namespace JSBSim
280
281//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
282#endif
double altitude
Definition ADA.cxx:46
static const double StdDaySLsoundspeed
bool Run(bool Holding) override
Runs the atmosphere forces model; called by the Executive.
struct JSBSim::FGAtmosphere::Inputs in
eTemperature
Enums for specifying temperature units.
static constexpr double Mair
Mean molecular weight for air - slug/mol.
double ConvertToPSF(double t, ePressure unit=ePSF) const
Converts to PSF (pounds per square foot) from one of several unit systems.
void Debug(int from) override
virtual double GetPressureSL(ePressure to=ePSF) const
virtual void SetTemperatureSL(double t, eTemperature unit=eFahrenheit)
Sets the Sea Level temperature.
virtual double GetSoundSpeed(void) const
Returns the speed of sound in ft/sec.
bool InitModel(void) override
virtual void SetTemperature(double t, double h, eTemperature unit=eFahrenheit)=0
Sets the temperature at the supplied altitude.
virtual double GetTemperature(double altitude) const =0
Returns the actual modeled temperature in degrees Rankine at a specified altitude.
virtual double CalculatePressureAltitude(double pressure, double geometricAlt)
Calculates the pressure altitude given any temperature or pressure bias.
virtual double GetDensityRatio(void) const
Returns the ratio of at-altitude density over the sea level value.
FGAtmosphere(FGFDMExec *)
Constructor.
virtual void SetPressureSL(ePressure unit, double pressure)
Sets the sea level pressure for modeling.
double ConvertFromRankine(double t, eTemperature unit) const
Converts from Rankine to one of several unit systems.
virtual ~FGAtmosphere()
Destructor.
virtual double GetDensityAltitude() const
virtual double GetDensitySL(void) const
Returns the sea level density in slugs/ft^3.
virtual double GetTemperatureSL() const
Returns the actual, modeled sea level temperature in degrees Rankine.
virtual double GetTemperatureRatio(double h) const
Returns the ratio of the temperature as modeled at the supplied altitude over the sea level value.
virtual double GetTemperatureRatio() const
Returns the ratio of the at-current-altitude temperature as modeled over the sea level value.
static double Reng
Specific gas constant for air - ft*lbf/slug/R.
static constexpr double SutherlandConstant
virtual void bind(void)
virtual double GetTemperature() const
Returns the actual, modeled temperature at the current altitude in degrees Rankine.
double ConvertToRankine(double t, eTemperature unit) const
Converts to Rankine from one of several unit systems.
virtual double GetDensity(void) const
Returns the density in slugs/ft^3.
virtual double GetPressureRatio(void) const
Returns the ratio of at-altitude pressure over the sea level value.
static constexpr double Rstar
Universal gas constant - ft*lbf/R/mol.
double ConvertFromPSF(double t, ePressure unit=ePSF) const
Converts from PSF (pounds per square foot) to one of several unit systems.
virtual double GetPressure(void) const
Returns the pressure in psf.
static constexpr double StdDaySLpressure
static constexpr double StdDaySLtemperature
virtual double GetSoundSpeedSL(void) const
Returns the sea level speed of sound in ft/sec.
virtual void Calculate(double altitude)
Calculate the atmosphere for the given altitude.
virtual double GetAbsoluteViscosity(void) const
Returns the absolute viscosity.
ePressure
Enums for specifying pressure units.
virtual double CalculateDensityAltitude(double density, double geometricAlt)
Calculates the density altitude given any temperature or pressure bias.
static constexpr double SHRatio
virtual double GetSoundSpeedRatio(void) const
Returns the ratio of at-altitude sound speed over the sea level value.
virtual double GetPressure(double altitude) const =0
Returns the pressure at a specified altitude in psf.
virtual double GetKinematicViscosity(void) const
Returns the kinematic viscosity.
static constexpr double Beta
virtual double GetPressureAltitude() const
static constexpr double g0
Sea-level acceleration of gravity - ft/s^2.
static constexpr double KelvinToRankine(double kelvin)
Converts from degrees Kelvin to degrees Rankine.
Definition FGJSBBase.h:216
static constexpr double kgtoslug
Definition FGJSBBase.h:369
static constexpr double fttom
Definition FGJSBBase.h:356
FGModel(FGFDMExec *)
Constructor.
Definition FGModel.cpp:57