FlightGear next
FGStandardAtmosphere.h
Go to the documentation of this file.
1/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3 Header: FGStandardAtmosphere.h
4 Author: Jon Berndt
5 Date started: 5/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 FGSTANDARDATMOSPHERE_H
35#define FGSTANDARDATMOSPHERE_H
36
37/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38INCLUDES
39%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40
41#include <vector>
42
43#include "math/FGTable.h"
44#include "models/FGAtmosphere.h"
45
46/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
47FORWARD DECLARATIONS
48%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
49
50namespace JSBSim {
51
52/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53CLASS DOCUMENTATION
54%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
55
93
94/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
95CLASS DECLARATION
96%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
97
99public:
102
104 virtual ~FGStandardAtmosphere();
105
106 bool InitModel(void) override;
107
108 // *************************************************************************
118 // @{
123 double GetTemperature(double altitude) const override;
124
131 virtual double GetStdTemperature(double altitude) const;
132
135 virtual double GetStdTemperatureSL() const { return StdSLtemperature; }
136
139 virtual double GetStdTemperatureRatio(double h) const { return GetStdTemperature(h)/StdSLtemperature; }
140
142 virtual double GetTemperatureBias(eTemperature to) const
143 { if (to == eCelsius || to == eKelvin) return TemperatureBias/1.80; else return TemperatureBias; }
144
148 { if (to == eCelsius || to == eKelvin) return TemperatureDeltaGradient/1.80; else return TemperatureDeltaGradient; }
149
159 void SetTemperatureSL(double t, eTemperature unit=eFahrenheit) override;
160
172 void SetTemperature(double t, double h, eTemperature unit=eFahrenheit) override;
173
183 virtual void SetTemperatureBias(eTemperature unit, double t);
184
198 virtual void SetSLTemperatureGradedDelta(eTemperature unit, double t);
199
207 virtual void SetTemperatureGradedDelta(double t, double h, eTemperature unit=eFahrenheit);
208
213 virtual void ResetSLTemperature();
215
216 // *************************************************************************
218
219
220 double GetPressure(double altitude) const override;
221
223 virtual double GetStdPressure(double altitude) const;
224
231 void SetPressureSL(ePressure unit, double pressure) override;
232
235 virtual void ResetSLPressure();
237
238 // *************************************************************************
240
241
242 virtual double GetStdDensity(double altitude) const;
244
245 // *************************************************************************
247
248
252 void SetDewPoint(eTemperature unit, double dewpoint);
255 double GetDewPoint(eTemperature to) const;
260 void SetVaporPressure(ePressure unit, double Pv);
264 double GetVaporPressure(ePressure to) const;
268 double GetSaturatedVaporPressure(ePressure to) const;
271 void SetRelativeHumidity(double RH);
273 double GetRelativeHumidity(void) const;
276 void SetVaporMassFractionPPM(double frac);
278 double GetVaporMassFractionPPM(void) const;
280
282 virtual void PrintStandardAtmosphereTable();
283
284protected:
287
293
296 std::vector<double> LapseRates;
297 std::vector<double> PressureBreakpoints;
298 std::vector<double> StdPressureBreakpoints;
299 std::vector<double> StdDensityBreakpoints;
300 std::vector<double> StdLapseRates;
301
302 void Calculate(double altitude) override;
303
308 void CalculateLapseRates();
309
312 void CalculatePressureBreakpoints(double SLpress);
313
317
319 double GeopotentialAltitude(double geometalt) const { return (geometalt * EarthRadius) / (EarthRadius + geometalt); }
320
322 double GeometricAltitude(double geopotalt) const { return (geopotalt * EarthRadius) / (EarthRadius - geopotalt); }
323
333 double CalculateDensityAltitude(double density, double geometricAlt) override;
334
343 double CalculatePressureAltitude(double pressure, double geometricAlt) override;
344
346 double CalculateVaporPressure(double temperature);
347
349 void ValidateVaporMassFraction(double geometricAlt);
350
353
356
357 void bind(void) override;
358 void Debug(int from) override;
359
361 static constexpr double EarthRadius = 6356766.0 / fttom;
365 static constexpr double a = 611.2/psftopa; // psf
366 static constexpr double b = 17.62; // 1/degC
367 static constexpr double c = 243.12; // degC
369 static constexpr double Mwater = 18.016 * kgtoslug / 1000.0;
370 static constexpr double Rdry = Rstar / Mair;
371 static constexpr double Rwater = Rstar / Mwater;
372};
373
374} // namespace JSBSim
375
376//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
377#endif
double altitude
Definition ADA.cxx:46
eTemperature
Enums for specifying temperature units.
static constexpr double Mair
Mean molecular weight for air - slug/mol.
FGAtmosphere(FGFDMExec *)
Constructor.
static double Reng
Specific gas constant for air - ft*lbf/slug/R.
virtual double GetTemperature() const
Returns the actual, modeled temperature at the current altitude in degrees Rankine.
static constexpr double Rstar
Universal gas constant - ft*lbf/R/mol.
virtual double GetPressure(void) const
Returns the pressure in psf.
ePressure
Enums for specifying pressure units.
static constexpr double psftopa
Definition FGJSBBase.h:352
static constexpr double kgtoslug
Definition FGJSBBase.h:369
static constexpr double fttom
Definition FGJSBBase.h:356
virtual void SetSLTemperatureGradedDelta(eTemperature unit, double t)
Sets a Sea Level temperature delta that is ramped out by 86 km.
double CalculateDensityAltitude(double density, double geometricAlt) override
Calculates the density altitude given any temperature or pressure bias.
virtual double GetStdTemperature(double altitude) const
Returns the standard temperature in degrees Rankine at a specified altitude.
void SetDewPoint(eTemperature unit, double dewpoint)
Sets the dew point.
static constexpr double Mwater
Mean molecular weight for water - slug/mol.
double GetVaporPressure(ePressure to) const
Returns the partial pressure of water vapor.
virtual double GetTemperatureDeltaGradient(eTemperature to)
Returns the temperature gradient to be applied on top of the standard temperature gradient.
std::vector< double > StdDensityBreakpoints
virtual void PrintStandardAtmosphereTable()
Prints the U.S. Standard Atmosphere table.
void SetVaporPressure(ePressure unit, double Pv)
Sets the partial pressure of water vapor.
double CalculatePressureAltitude(double pressure, double geometricAlt) override
Calculates the pressure altitude given any temperature or pressure bias.
std::vector< double > PressureBreakpoints
void CalculateLapseRates()
Recalculate the lapse rate vectors when the temperature profile is altered in a way that would change...
void CalculatePressureBreakpoints(double SLpress)
Calculate (or recalculate) the atmospheric pressure breakpoints at the altitudes in the standard temp...
void SetTemperatureSL(double t, eTemperature unit=eFahrenheit) override
Sets the Sea Level temperature, if it is to be different than the standard.
virtual void ResetSLTemperature()
This function resets the model to apply no bias or delta gradient to the temperature.
static constexpr double a
Sonntag constants based on ref [2].
virtual void SetTemperatureBias(eTemperature unit, double t)
Sets the temperature bias to be added to the standard temperature at all altitudes.
void ValidateVaporMassFraction(double geometricAlt)
Validate the value of the vapor mass fraction.
FGStandardAtmosphere(FGFDMExec *)
Constructor.
void CalculateStdDensityBreakpoints()
Calculate the atmospheric density breakpoints at the altitudes in the standard temperature table.
static constexpr double EarthRadius
Earth radius in ft as defined for ISA 1976.
std::vector< double > StdLapseRates
virtual double GetTemperatureBias(eTemperature to) const
Returns the temperature bias over the sea level value in degrees Rankine.
virtual double GetStdTemperatureSL() const
Returns the standard sea level temperature in degrees Rankine.
std::vector< double > StdPressureBreakpoints
void Calculate(double altitude) override
Calculate the atmosphere for the given altitude.
virtual void SetTemperatureGradedDelta(double t, double h, eTemperature unit=eFahrenheit)
Sets the temperature delta value at the supplied altitude/elevation above sea level,...
virtual double GetStdPressure(double altitude) const
Returns the standard pressure at the specified altitude.
double GetSaturatedVaporPressure(ePressure to) const
Returns the saturated pressure of water vapor.
double GeometricAltitude(double geopotalt) const
Convert a geopotential altitude to a geometric altitude.
double GetRelativeHumidity(void) const
Returns the relative humidity in percent.
double GeopotentialAltitude(double geometalt) const
Convert a geometric altitude to a geopotential altitude.
virtual void ResetSLPressure()
Resets the sea level to the Standard sea level pressure, and recalculates dependent parameters so tha...
void SetPressureSL(ePressure unit, double pressure) override
Sets the sea level pressure for modeling an off-standard pressure profile.
virtual double GetStdTemperatureRatio(double h) const
Returns the ratio of the standard temperature at the supplied altitude over the standard sea level te...
void CalculateSLDensity(void)
Calculate the SL density.
void CalculateSLSoundSpeedAndDensity(void)
Calculate the SL density and sound speed.
void SetRelativeHumidity(double RH)
Sets the relative humidity.
double GetVaporMassFractionPPM(void) const
Returns the vapor mass per million of dry air mass units (ppm).
double StdSLtemperature
Standard sea level conditions.
void SetTemperature(double t, double h, eTemperature unit=eFahrenheit) override
Sets the temperature at the supplied altitude, if it is to be different than the standard temperature...
virtual double GetStdDensity(double altitude) const
Returns the standard density at a specified altitude.
double GetDewPoint(eTemperature to) const
Returns the dew point.
virtual ~FGStandardAtmosphere()
Destructor.
double CalculateVaporPressure(double temperature)
Calculate the pressure of water vapor with the Magnus formula.
void SetVaporMassFractionPPM(double frac)
Sets the vapor mass per million of dry air mass units.
Lookup table class.
Definition FGTable.h:234