JSBSim Flight Dynamics Model 1.2.2 (22 Mar 2025)
An Open Source Flight Dynamics and Control Software Library in C++
Loading...
Searching...
No Matches
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
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
72/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73CLASS DECLARATION
74%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
75
76class JSBSIM_API FGAtmosphere : public FGModel {
77public:
78
80 enum eTemperature {eNoTempUnit=0, eFahrenheit, eCelsius, eRankine, eKelvin};
81
83 enum ePressure {eNoPressUnit=0, ePSF, eMillibars, ePascals, eInchesHg};
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 {
210 double altitudeASL;
211 double GeodLatitudeDeg;
212 double LongitudeDeg;
213 } in;
214
215 static constexpr double StdDaySLtemperature = 518.67;
216 static constexpr double StdDaySLpressure = 2116.228;
217 const double StdDaySLsoundspeed;
218 static constexpr double SHRatio = 1.4;
219
220protected:
221 // Sea level conditions
222 double SLtemperature = 1.8;
223 double SLdensity = 1.0;
224 double SLpressure = 1.0;
225 double SLsoundspeed = 1.0;
226 // Current actual conditions at altitude
227 double Temperature = 1.8;
228 double Density = 0.0;
229 double Pressure = 0.0;
230 double Soundspeed = 0.0;
231 double PressureAltitude = 0.0;
232 double DensityAltitude = 0.0;
233
234 static constexpr double SutherlandConstant = 198.72; // deg Rankine
235 static constexpr double Beta = 2.269690E-08; // slug/(sec ft R^0.5)
236 double Viscosity = 0.0;
237 double KinematicViscosity = 0.0;
238
240 virtual void Calculate(double altitude);
241
247 virtual double CalculateDensityAltitude(double density, double geometricAlt) { return geometricAlt; }
248
254 virtual double CalculatePressureAltitude(double pressure, double geometricAlt) { return geometricAlt; }
255
257 double ConvertToRankine(double t, eTemperature unit) const;
258
260 double ConvertFromRankine(double t, eTemperature unit) const;
261
263 double ConvertToPSF(double t, ePressure unit=ePSF) const;
264
266 double ConvertFromPSF(double t, ePressure unit=ePSF) const;
267
271 double ValidatePressure(double p, const std::string& msg, bool quiet=false) const;
272
276 double ValidateTemperature(double t, const std::string& msg, bool quiet=false) const;
277
279
280
281 static constexpr double Rstar = 8.31432 * kgtoslug / KelvinToRankine(fttom * fttom);
283 static constexpr double Mair = 28.9645 * kgtoslug / 1000.0;
289 static constexpr double g0 = 9.80665 / fttom;
291 static constexpr double Reng0 = Rstar / Mair;
293
294 double Reng = Reng0;
295
296 virtual void bind(void);
297 void Debug(int from) override;
298
299public:
300 static constexpr double StdDaySLdensity = StdDaySLpressure / (Reng0 * StdDaySLtemperature);
301};
302
303} // namespace JSBSim
304
305//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
306#endif
Models an empty, abstract base atmosphere class.
virtual double GetSoundSpeedRatio(void) const
Returns the ratio of at-altitude sound speed over the sea level value.
virtual double GetPressureRatio(void) const
Returns the ratio of at-altitude pressure 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.
virtual double CalculatePressureAltitude(double pressure, double geometricAlt)
Calculates the pressure altitude given any temperature or pressure bias.
virtual double GetPressure(double altitude) const =0
Returns the pressure at a specified altitude in psf.
virtual double GetPressure(void) const
Returns the pressure in psf.
virtual double GetSoundSpeedSL(void) const
Returns the sea level speed of sound in ft/sec.
eTemperature
Enums for specifying temperature units.
virtual double GetTemperature(double altitude) const =0
Returns the actual modeled temperature in degrees Rankine at a specified altitude.
virtual double GetKinematicViscosity(void) const
Returns the kinematic viscosity.
virtual double CalculateDensityAltitude(double density, double geometricAlt)
Calculates the density altitude given any temperature or pressure bias.
virtual double GetSoundSpeed(void) const
Returns the speed of sound in ft/sec.
virtual double GetDensitySL(void) const
Returns the sea level density in slugs/ft^3.
ePressure
Enums for specifying pressure units.
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 GetDensityRatio(void) const
Returns the ratio of at-altitude density over the sea level value.
virtual void SetTemperature(double t, double h, eTemperature unit=eFahrenheit)=0
Sets the temperature at the supplied altitude.
virtual double GetAbsoluteViscosity(void) const
Returns the absolute viscosity.
virtual double GetDensity(void) const
Returns the density in slugs/ft^3.
virtual double GetTemperature() const
Returns the actual, modeled temperature at the current altitude in degrees Rankine.
Encapsulates the JSBSim simulation executive.
Definition FGFDMExec.h:184
Base class for all scheduled JSBSim models.
Definition FGModel.h:70