JSBSim Flight Dynamics Model 1.2.4 (07 Feb 2026)
An Open Source Flight Dynamics and Control Software Library in C++
Loading...
Searching...
No Matches
FGAtmosphere Class Referenceabstract

Detailed Description

Models an empty, abstract base atmosphere class.

Properties

  • atmosphere/T-R The current modeled temperature in degrees Rankine.
  • atmosphere/rho-slugs_ft3
  • atmosphere/P-psf
  • atmosphere/a-fps
  • atmosphere/T-sl-R
  • atmosphere/rho-sl-slugs_ft3
  • atmosphere/P-sl-psf
  • atmosphere/a-sl-fps
  • atmosphere/theta
  • atmosphere/sigma
  • atmosphere/delta
  • atmosphere/a-ratio
Author
Jon Berndt

Definition at line 76 of file FGAtmosphere.h.

#include <FGAtmosphere.h>

+ Inheritance diagram for FGAtmosphere:
+ Collaboration diagram for FGAtmosphere:

Classes

struct  Inputs
 

Public Types

enum  ePressure {
  eNoPressUnit =0 , ePSF , eMillibars , ePascals ,
  eInchesHg
}
 Enums for specifying pressure units. More...
 
enum  eTemperature {
  eNoTempUnit =0 , eFahrenheit , eCelsius , eRankine ,
  eKelvin
}
 Enums for specifying temperature units. More...
 
- Public Types inherited from FGJSBBase
enum  { eL = 1 , eM , eN }
 Moments L, M, N. More...
 
enum  { eP = 1 , eQ , eR }
 Rates P, Q, R. More...
 
enum  { eU = 1 , eV , eW }
 Velocities U, V, W. More...
 
enum  { eX = 1 , eY , eZ }
 Positions X, Y, Z. More...
 
enum  { ePhi = 1 , eTht , ePsi }
 Euler angles Phi, Theta, Psi. More...
 
enum  { eDrag = 1 , eSide , eLift }
 Stability axis forces, Drag, Side force, Lift. More...
 
enum  { eRoll = 1 , ePitch , eYaw }
 Local frame orientation Roll, Pitch, Yaw. More...
 
enum  { eNorth = 1 , eEast , eDown }
 Local frame position North, East, Down. More...
 
enum  { eLat = 1 , eLong , eRad }
 Locations Radius, Latitude, Longitude. More...
 
enum  {
  inNone = 0 , inDegrees , inRadians , inMeters ,
  inFeet
}
 Conversion specifiers. More...
 

Public Member Functions

 FGAtmosphere (FGFDMExec *)
 Constructor.
 
virtual ~FGAtmosphere ()
 Destructor.
 
bool InitModel (void) override
 
bool Run (bool Holding) override
 Runs the atmosphere forces model; called by the Executive.
 
Temperature access functions.

There are several ways to get the temperature, and several modeled temperature values that can be retrieved.

virtual double GetTemperature () const
 Returns the actual, modeled temperature at the current altitude in degrees Rankine.
 
virtual double GetTemperature (double altitude) const =0
 Returns the actual modeled temperature in degrees Rankine at a specified altitude.
 
virtual double GetTemperatureSL () const
 Returns the actual, modeled sea level temperature in degrees Rankine.
 
virtual double GetTemperatureRatio () const
 Returns the ratio of the at-current-altitude temperature as modeled over the sea level value.
 
virtual double GetTemperatureRatio (double h) const
 Returns the ratio of the temperature as modeled at the supplied altitude over the sea level value.
 
virtual void SetTemperatureSL (double t, eTemperature unit=eFahrenheit)
 Sets the Sea Level temperature.
 
virtual void SetTemperature (double t, double h, eTemperature unit=eFahrenheit)=0
 Sets the temperature at the supplied altitude.
 
Pressure access functions.
virtual double GetPressure (void) const
 Returns the pressure in psf.
 
virtual double GetPressure (double altitude) const =0
 Returns the pressure at a specified altitude in psf.
 
virtual double GetPressureSL (ePressure to=ePSF) const
 
virtual double GetPressureRatio (void) const
 Returns the ratio of at-altitude pressure over the sea level value.
 
virtual void SetPressureSL (ePressure unit, double pressure)
 Sets the sea level pressure for modeling.
 
Density access functions.
virtual double GetDensity (void) const
 Returns the density in slugs/ft^3.
 
virtual double GetDensity (double altitude) const
 Returns the density in slugs/ft^3 at a given altitude in ft.
 
virtual double GetDensitySL (void) const
 Returns the sea level density in slugs/ft^3.
 
virtual double GetDensityRatio (void) const
 Returns the ratio of at-altitude density over the sea level value.
 
Speed of sound access functions.
virtual double GetSoundSpeed (void) const
 Returns the speed of sound in ft/sec.
 
virtual double GetSoundSpeed (double altitude) const
 Returns the speed of sound in ft/sec at a given altitude in ft.
 
virtual double GetSoundSpeedSL (void) const
 Returns the sea level speed of sound in ft/sec.
 
virtual double GetSoundSpeedRatio (void) const
 Returns the ratio of at-altitude sound speed over the sea level value.
 
- Public Member Functions inherited from FGModel
 FGModel (FGFDMExec *)
 Constructor.
 
 ~FGModel () override
 Destructor.
 
virtual SGPath FindFullPathName (const SGPath &path) const
 
FGFDMExecGetExec (void)
 
const std::string & GetName (void)
 
unsigned int GetRate (void)
 Get the output rate for the model in frames.
 
bool InitModel (void) override
 
virtual bool Load (Element *el)
 
void SetPropertyManager (std::shared_ptr< FGPropertyManager > fgpm)
 
void SetRate (unsigned int tt)
 Set the ouput rate for the model in frames.
 
- Public Member Functions inherited from FGModelFunctions
std::string GetFunctionStrings (const std::string &delimeter) const
 Gets the strings for the current set of functions.
 
std::string GetFunctionValues (const std::string &delimeter) const
 Gets the function values.
 
std::shared_ptr< FGFunctionGetPreFunction (const std::string &name)
 Get one of the "pre" function.
 
bool Load (Element *el, FGFDMExec *fdmex, std::string prefix="")
 
void PostLoad (Element *el, FGFDMExec *fdmex, std::string prefix="")
 
void PreLoad (Element *el, FGFDMExec *fdmex, std::string prefix="")
 
void RunPostFunctions (void)
 
void RunPreFunctions (void)
 
- Public Member Functions inherited from FGJSBBase
 FGJSBBase ()
 Constructor for FGJSBBase.
 
virtual ~FGJSBBase ()
 Destructor for FGJSBBase.
 
void disableHighLighting (void)
 Disables highlighting in the console output.
 

Viscosity access functions.

struct JSBSim::FGAtmosphere::Inputs in
 
const double StdDaySLsoundspeed
 
static constexpr double StdDaySLtemperature = 518.67
 
static constexpr double StdDaySLpressure = 2116.228
 
static constexpr double SHRatio = 1.4
 
double SLtemperature = 1.8
 
double SLdensity = 1.0
 
double SLpressure = 1.0
 
double SLsoundspeed = 1.0
 
double Temperature = 1.8
 
double Density = 0.0
 
double Pressure = 0.0
 
double Soundspeed = 0.0
 
double PressureAltitude = 0.0
 
double DensityAltitude = 0.0
 
double Viscosity = 0.0
 
double KinematicViscosity = 0.0
 
SGPropertyNode_ptr atmosphere_node
 
SGPropertyNode_ptr override_node
 
SGPropertyNode_ptr override_temperature_node
 
SGPropertyNode_ptr override_pressure_node
 
SGPropertyNode_ptr override_density_node
 
static constexpr double SutherlandConstant = 198.72
 
static constexpr double Beta = 2.269690E-08
 
virtual double GetAbsoluteViscosity (void) const
 Returns the absolute viscosity.
 
virtual double GetKinematicViscosity (void) const
 Returns the kinematic viscosity.
 
virtual double GetDensityAltitude () const
 
virtual double GetPressureAltitude () const
 
virtual void Calculate (double altitude)
 Calculate the atmosphere for the given altitude.
 
virtual double CalculateDensityAltitude (double density, double geometricAlt)
 Calculates the density altitude given any temperature or pressure bias.
 
virtual double CalculatePressureAltitude (double pressure, double geometricAlt)
 Calculates the pressure altitude given any temperature or pressure bias.
 
double ConvertToRankine (double t, eTemperature unit) const
 Converts to Rankine from one of several unit systems.
 
double ConvertFromRankine (double t, eTemperature unit) const
 Converts from Rankine to one of several unit systems.
 
double ConvertToPSF (double t, ePressure unit=ePSF) const
 Converts to PSF (pounds per square foot) from one of several unit systems.
 
double ConvertFromPSF (double t, ePressure unit=ePSF) const
 Converts from PSF (pounds per square foot) to one of several unit systems.
 
double ValidatePressure (double p, const std::string &msg, bool quiet=false) const
 Check that the pressure is within plausible boundaries.
 
double ValidateTemperature (double t, const std::string &msg, bool quiet=false) const
 Check that the temperature is within plausible boundaries.
 

ISA constants

static constexpr double StdDaySLdensity = StdDaySLpressure / (Reng0 * StdDaySLtemperature)
 
double Reng = Reng0
 
static constexpr double Rstar = 8.31432 * kgtoslug / KelvinToRankine(fttom * fttom)
 Universal gas constant - ft*lbf/R/mol.
 
static constexpr double Mair = 28.9645 * kgtoslug / 1000.0
 Mean molecular weight for air - slug/mol.
 
static constexpr double g0 = 9.80665 / fttom
 Sea-level acceleration of gravity - ft/s^2.
 
static constexpr double Reng0 = Rstar / Mair
 Specific gas constant for air - ft*lbf/slug/R.
 
virtual void bind (void)
 
void Debug (int from) override
 

Additional Inherited Members

- Static Public Member Functions inherited from FGJSBBase
static const std::string & GetVersion (void)
 Returns the version number of JSBSim.
 
static constexpr double KelvinToFahrenheit (double kelvin)
 Converts from degrees Kelvin to degrees Fahrenheit.
 
static constexpr double CelsiusToRankine (double celsius)
 Converts from degrees Celsius to degrees Rankine.
 
static constexpr double RankineToCelsius (double rankine)
 Converts from degrees Rankine to degrees Celsius.
 
static constexpr double KelvinToRankine (double kelvin)
 Converts from degrees Kelvin to degrees Rankine.
 
static constexpr double RankineToKelvin (double rankine)
 Converts from degrees Rankine to degrees Kelvin.
 
static constexpr double FahrenheitToCelsius (double fahrenheit)
 Converts from degrees Fahrenheit to degrees Celsius.
 
static constexpr double CelsiusToFahrenheit (double celsius)
 Converts from degrees Celsius to degrees Fahrenheit.
 
static constexpr double CelsiusToKelvin (double celsius)
 Converts from degrees Celsius to degrees Kelvin.
 
static constexpr double KelvinToCelsius (double kelvin)
 Converts from degrees Kelvin to degrees Celsius.
 
static constexpr double FeetToMeters (double measure)
 Converts from feet to meters.
 
static bool EqualToRoundoff (double a, double b)
 Finite precision comparison.
 
static bool EqualToRoundoff (float a, float b)
 Finite precision comparison.
 
static bool EqualToRoundoff (float a, double b)
 Finite precision comparison.
 
static bool EqualToRoundoff (double a, float b)
 Finite precision comparison.
 
static constexpr double Constrain (double min, double value, double max)
 Constrain a value between a minimum and a maximum value.
 
static constexpr double sign (double num)
 
- Static Public Attributes inherited from FGJSBBase
static char highint [5] = {27, '[', '1', 'm', '\0' }
 highlights text
 
static char halfint [5] = {27, '[', '2', 'm', '\0' }
 low intensity text
 
static char normint [6] = {27, '[', '2', '2', 'm', '\0' }
 normal intensity text
 
static char reset [5] = {27, '[', '0', 'm', '\0' }
 resets text properties
 
static char underon [5] = {27, '[', '4', 'm', '\0' }
 underlines text
 
static char underoff [6] = {27, '[', '2', '4', 'm', '\0' }
 underline off
 
static char fgblue [6] = {27, '[', '3', '4', 'm', '\0' }
 blue text
 
static char fgcyan [6] = {27, '[', '3', '6', 'm', '\0' }
 cyan text
 
static char fgred [6] = {27, '[', '3', '1', 'm', '\0' }
 red text
 
static char fggreen [6] = {27, '[', '3', '2', 'm', '\0' }
 green text
 
static char fgdef [6] = {27, '[', '3', '9', 'm', '\0' }
 default text
 
static short debug_lvl = 1
 
- Protected Member Functions inherited from FGModel
bool Upload (Element *el, bool preLoad)
 Uploads this model in memory.
 
- Static Protected Member Functions inherited from FGJSBBase
static std::string CreateIndexedPropertyName (const std::string &Property, int index)
 
- Protected Attributes inherited from FGModel
unsigned int exe_ctr
 
FGFDMExecFDMExec
 
std::string Name
 
std::shared_ptr< FGPropertyManager > PropertyManager
 
unsigned int rate
 
- Protected Attributes inherited from FGModelFunctions
FGPropertyReader LocalProperties
 
std::vector< std::shared_ptr< FGFunction > > PostFunctions
 
std::vector< std::shared_ptr< FGFunction > > PreFunctions
 
- Static Protected Attributes inherited from FGJSBBase
static constexpr double radtodeg = 180. / M_PI
 
static constexpr double degtorad = M_PI / 180.
 
static constexpr double hptoftlbssec = 550.0
 
static constexpr double psftoinhg = 0.014138
 
static constexpr double psftopa = 47.88
 
static constexpr double fttom = 0.3048
 
static constexpr double ktstofps = 1852./(3600*fttom)
 
static constexpr double fpstokts = 1.0 / ktstofps
 
static constexpr double inchtoft = 1.0/12.0
 
static constexpr double m3toft3 = 1.0/(fttom*fttom*fttom)
 
static constexpr double in3tom3 = inchtoft*inchtoft*inchtoft/m3toft3
 
static constexpr double inhgtopa = 3386.38
 
static constexpr double slugtolb = 32.174049
 Note that definition of lbtoslug by the inverse of slugtolb and not to a different constant you can also get from some tables will make lbtoslug*slugtolb == 1 up to the magnitude of roundoff.
 
static constexpr double lbtoslug = 1.0/slugtolb
 
static constexpr double kgtolb = 2.20462
 
static constexpr double kgtoslug = 0.06852168
 
static const std::string needed_cfg_version = "2.0"
 
static const std::string JSBSim_version = JSBSIM_VERSION " " __DATE__ " " __TIME__
 

Member Enumeration Documentation

◆ ePressure

enum ePressure

Enums for specifying pressure units.

Definition at line 83 of file FGAtmosphere.h.

83{eNoPressUnit=0, ePSF, eMillibars, ePascals, eInchesHg};

◆ eTemperature

Enums for specifying temperature units.

Definition at line 80 of file FGAtmosphere.h.

80{eNoTempUnit=0, eFahrenheit, eCelsius, eRankine, eKelvin};

Constructor & Destructor Documentation

◆ FGAtmosphere()

FGAtmosphere ( FGFDMExec fdmex)

Constructor.

Definition at line 56 of file FGAtmosphere.cpp.

57 : FGModel(fdmex),
58 StdDaySLsoundspeed(sqrt(SHRatio*Reng0*StdDaySLtemperature))
59{
60 Name = "FGAtmosphere";
61
62 bind();
63 SGPropertyNode* root = PropertyManager->GetNode();
64 atmosphere_node = root->getNode("atmosphere");
65
66 assert(atmosphere_node);
67 Debug(0);
68}
static constexpr double Reng0
Specific gas constant for air - ft*lbf/slug/R.
FGModel(FGFDMExec *)
Constructor.
Definition FGModel.cpp:57
A node in a property tree.
Definition props.hxx:754
SGPropertyNode * getNode(const char *relative_path, bool create=false)
Get a pointer to another node by relative path.
+ Here is the call graph for this function:

◆ ~FGAtmosphere()

~FGAtmosphere ( )
virtual

Destructor.

Definition at line 72 of file FGAtmosphere.cpp.

73{
74 Debug(1);
75}

Member Function Documentation

◆ bind()

void bind ( void  )
protectedvirtual

Definition at line 341 of file FGAtmosphere.cpp.

342{
343 PropertyManager->Tie("atmosphere/T-R", this, &FGAtmosphere::GetTemperature);
344 PropertyManager->Tie("atmosphere/rho-slugs_ft3", this, &FGAtmosphere::GetDensity);
345 PropertyManager->Tie("atmosphere/P-psf", this, &FGAtmosphere::GetPressure);
346 PropertyManager->Tie("atmosphere/a-fps", this, &FGAtmosphere::GetSoundSpeed);
347 PropertyManager->Tie("atmosphere/T-sl-R", this, &FGAtmosphere::GetTemperatureSL);
348 PropertyManager->Tie("atmosphere/rho-sl-slugs_ft3", this, &FGAtmosphere::GetDensitySL);
349 PropertyManager->Tie("atmosphere/a-sl-fps", this, &FGAtmosphere::GetSoundSpeedSL);
350 PropertyManager->Tie("atmosphere/theta", this, &FGAtmosphere::GetTemperatureRatio);
351 PropertyManager->Tie("atmosphere/sigma", this, &FGAtmosphere::GetDensityRatio);
352 PropertyManager->Tie("atmosphere/delta", this, &FGAtmosphere::GetPressureRatio);
353 PropertyManager->Tie("atmosphere/a-ratio", this, &FGAtmosphere::GetSoundSpeedRatio);
354 PropertyManager->Tie("atmosphere/density-altitude", this, &FGAtmosphere::GetDensityAltitude);
355 PropertyManager->Tie("atmosphere/pressure-altitude", this, &FGAtmosphere::GetPressureAltitude);
356}
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 GetPressure(void) const
Returns the pressure in psf.
virtual double GetSoundSpeedSL(void) const
Returns the sea level speed of sound in ft/sec.
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.
virtual double GetTemperatureSL() const
Returns the actual, modeled sea level temperature in degrees Rankine.
virtual double GetDensityRatio(void) const
Returns the ratio of at-altitude density over the sea level value.
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.

◆ Calculate()

void Calculate ( double  altitude)
protectedvirtual

Calculate the atmosphere for the given altitude.

Reimplemented in FGMSIS, and FGStandardAtmosphere.

Definition at line 143 of file FGAtmosphere.cpp.

144{
145 double t =0.0;
146 double p = 0.0;
147
148 if (!override_node) override_node = atmosphere_node->getNode("override");
149
150 // Temperature and pressure
151 if (override_node) {
152 if (!override_temperature_node)
153 override_temperature_node = override_node->getNode("temperature");
154
155 if (override_temperature_node)
156 t = override_temperature_node->getDoubleValue();
157 else
158 t = GetTemperature(altitude);
159
160 if (!override_pressure_node)
161 override_pressure_node = override_node->getNode("pressure");
162
163 if (override_pressure_node)
164 p = override_pressure_node->getDoubleValue();
165 else
166 p = GetPressure(altitude);
167 } else {
168 t = GetTemperature(altitude);
169 p = GetPressure(altitude);
170 }
171
172 Temperature = ValidateTemperature(t, "", true);
173 Pressure = ValidatePressure(p, "", true);
174
175 // Density
176 if (override_node) {
177 if (!override_density_node)
178 override_density_node = override_node->getNode("density");
179
180 if (override_density_node)
181 Density = override_density_node->getDoubleValue();
182 else
183 Density = Pressure/(Reng*Temperature);
184 }
185 else
186 Density = Pressure/(Reng*Temperature);
187
188 Soundspeed = sqrt(SHRatio*Reng*Temperature);
189 PressureAltitude = CalculatePressureAltitude(Pressure, altitude);
190 DensityAltitude = CalculateDensityAltitude(Density, altitude);
191
192 Viscosity = Beta * pow(Temperature, 1.5) / (SutherlandConstant + Temperature);
193 KinematicViscosity = Viscosity / Density;
194}
virtual double CalculatePressureAltitude(double pressure, double geometricAlt)
Calculates the pressure altitude given any temperature or pressure bias.
double ValidatePressure(double p, const std::string &msg, bool quiet=false) const
Check that the pressure is within plausible boundaries.
double ValidateTemperature(double t, const std::string &msg, bool quiet=false) const
Check that the temperature is within plausible boundaries.
virtual double CalculateDensityAltitude(double density, double geometricAlt)
Calculates the density altitude given any temperature or pressure bias.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CalculateDensityAltitude()

virtual double CalculateDensityAltitude ( double  density,
double  geometricAlt 
)
inlineprotectedvirtual

Calculates the density altitude given any temperature or pressure bias.

Calculated density for the specified geometric altitude given any temperature or pressure biases is passed in.

Parameters
density
geometricAlt

Reimplemented in FGStandardAtmosphere.

Definition at line 254 of file FGAtmosphere.h.

254{ return geometricAlt; }

◆ CalculatePressureAltitude()

virtual double CalculatePressureAltitude ( double  pressure,
double  geometricAlt 
)
inlineprotectedvirtual

Calculates the pressure altitude given any temperature or pressure bias.

Calculated pressure for the specified geometric altitude given any temperature or pressure biases is passed in.

Parameters
pressure
geometricAlt

Reimplemented in FGStandardAtmosphere.

Definition at line 261 of file FGAtmosphere.h.

261{ return geometricAlt; }

◆ ConvertFromPSF()

double ConvertFromPSF ( double  t,
ePressure  unit = ePSF 
) const
protected

Converts from PSF (pounds per square foot) to one of several unit systems.

Definition at line 315 of file FGAtmosphere.cpp.

316{
317 double targetPressure=0; // Pressure
318
319 switch(unit) {
320 case ePSF:
321 targetPressure = p;
322 break;
323 case eMillibars:
324 targetPressure = p/2.08854342;
325 break;
326 case ePascals:
327 targetPressure = p/0.0208854342;
328 break;
329 case eInchesHg:
330 targetPressure = p/70.7180803;
331 break;
332 default:
333 throw BaseException("Undefined pressure unit given");
334 }
335
336 return targetPressure;
337}
+ Here is the caller graph for this function:

◆ ConvertFromRankine()

double ConvertFromRankine ( double  t,
eTemperature  unit 
) const
protected

Converts from Rankine to one of several unit systems.

Definition at line 263 of file FGAtmosphere.cpp.

264{
265 double targetTemp=0;
266
267 switch(unit) {
268 case eFahrenheit:
269 targetTemp = t - 459.67;
270 break;
271 case eCelsius:
272 targetTemp = t/1.8 - 273.15;
273 break;
274 case eRankine:
275 targetTemp = t;
276 break;
277 case eKelvin:
278 targetTemp = t/1.8;
279 break;
280 default:
281 throw BaseException("Undefined temperature unit given");
282 }
283
284 return targetTemp;
285}
+ Here is the caller graph for this function:

◆ ConvertToPSF()

double ConvertToPSF ( double  t,
ePressure  unit = ePSF 
) const
protected

Converts to PSF (pounds per square foot) from one of several unit systems.

Definition at line 289 of file FGAtmosphere.cpp.

290{
291 double targetPressure=0; // Pressure in PSF
292
293 switch(unit) {
294 case ePSF:
295 targetPressure = p;
296 break;
297 case eMillibars:
298 targetPressure = p*2.08854342;
299 break;
300 case ePascals:
301 targetPressure = p*0.0208854342;
302 break;
303 case eInchesHg:
304 targetPressure = p*70.7180803;
305 break;
306 default:
307 throw BaseException("Undefined pressure unit given");
308 }
309
310 return targetPressure;
311}
+ Here is the caller graph for this function:

◆ ConvertToRankine()

double ConvertToRankine ( double  t,
eTemperature  unit 
) const
protected

Converts to Rankine from one of several unit systems.

Definition at line 237 of file FGAtmosphere.cpp.

238{
239 double targetTemp=0; // in degrees Rankine
240
241 switch(unit) {
242 case eFahrenheit:
243 targetTemp = t + 459.67;
244 break;
245 case eCelsius:
246 targetTemp = (t + 273.15) * 1.8;
247 break;
248 case eRankine:
249 targetTemp = t;
250 break;
251 case eKelvin:
252 targetTemp = t*1.8;
253 break;
254 default:
255 throw BaseException("Undefined temperature unit given");
256 }
257
258 return targetTemp;
259}
+ Here is the caller graph for this function:

◆ Debug()

void Debug ( int  from)
overrideprotectedvirtual

Reimplemented from FGModel.

Definition at line 377 of file FGAtmosphere.cpp.

378{
379 if (debug_lvl <= 0) return;
380
381 if (debug_lvl & 1) { // Standard console startup message output
382 if (from == 0) { // Constructor
383 }
384 }
385 if (debug_lvl & 2 ) { // Instantiation/Destruction notification
386 if (from == 0) std::cout << "Instantiated: FGAtmosphere" << std::endl;
387 if (from == 1) std::cout << "Destroyed: FGAtmosphere" << std::endl;
388 }
389 if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
390 }
391 if (debug_lvl & 8 ) { // Runtime state variables
392 }
393 if (debug_lvl & 16) { // Sanity checking
394 }
395 if (debug_lvl & 128) { //
396 }
397 if (debug_lvl & 64) {
398 if (from == 0) { // Constructor
399 }
400 }
401}

◆ GetAbsoluteViscosity()

virtual double GetAbsoluteViscosity ( void  ) const
inlinevirtual

Returns the absolute viscosity.

Definition at line 199 of file FGAtmosphere.h.

199{return Viscosity;}

◆ GetDensity() [1/2]

double GetDensity ( double  altitude) const
virtual

Returns the density in slugs/ft^3 at a given altitude in ft.

Reimplemented in FGMSIS, and FGMSIS.

Definition at line 209 of file FGAtmosphere.cpp.

210{
211 return GetPressure(altitude)/(Reng * GetTemperature(altitude));
212}
+ Here is the call graph for this function:

◆ GetDensity() [2/2]

virtual double GetDensity ( void  ) const
inlinevirtual

Returns the density in slugs/ft^3.

This function may only be used if Run() is called first.

Reimplemented in FGMSIS.

Definition at line 167 of file FGAtmosphere.h.

167{return Density;}
+ Here is the caller graph for this function:

◆ GetDensityAltitude()

virtual double GetDensityAltitude ( ) const
inlinevirtual

Definition at line 205 of file FGAtmosphere.h.

205{return DensityAltitude;}

◆ GetDensityRatio()

virtual double GetDensityRatio ( void  ) const
inlinevirtual

Returns the ratio of at-altitude density over the sea level value.

Definition at line 176 of file FGAtmosphere.h.

176{ return Density/SLdensity; }

◆ GetDensitySL()

virtual double GetDensitySL ( void  ) const
inlinevirtual

Returns the sea level density in slugs/ft^3.

Definition at line 173 of file FGAtmosphere.h.

173{ return SLdensity; }

◆ GetKinematicViscosity()

virtual double GetKinematicViscosity ( void  ) const
inlinevirtual

Returns the kinematic viscosity.

Definition at line 202 of file FGAtmosphere.h.

202{return KinematicViscosity;}

◆ GetPressure() [1/2]

virtual double GetPressure ( double  altitude) const
pure virtual

Returns the pressure at a specified altitude in psf.

Implemented in FGMSIS, FGStandardAtmosphere, and FGMSIS.

◆ GetPressure() [2/2]

virtual double GetPressure ( void  ) const
inlinevirtual

Returns the pressure in psf.

Reimplemented in FGMSIS.

Definition at line 144 of file FGAtmosphere.h.

144{return Pressure;}
+ Here is the caller graph for this function:

◆ GetPressureAltitude()

virtual double GetPressureAltitude ( ) const
inlinevirtual

Definition at line 207 of file FGAtmosphere.h.

207{return PressureAltitude;}

◆ GetPressureRatio()

virtual double GetPressureRatio ( void  ) const
inlinevirtual

Returns the ratio of at-altitude pressure over the sea level value.

Definition at line 153 of file FGAtmosphere.h.

153{ return Pressure/SLpressure; }

◆ GetPressureSL()

virtual double GetPressureSL ( ePressure  to = ePSF) const
inlinevirtual

Definition at line 150 of file FGAtmosphere.h.

150{ return ConvertFromPSF(SLpressure, to); }
double ConvertFromPSF(double t, ePressure unit=ePSF) const
Converts from PSF (pounds per square foot) to one of several unit systems.

◆ GetSoundSpeed() [1/2]

double GetSoundSpeed ( double  altitude) const
virtual

Returns the speed of sound in ft/sec at a given altitude in ft.

Reimplemented in FGMSIS, and FGMSIS.

Definition at line 216 of file FGAtmosphere.cpp.

217{
218 return sqrt(SHRatio * Reng * GetTemperature(altitude));
219}
+ Here is the call graph for this function:

◆ GetSoundSpeed() [2/2]

virtual double GetSoundSpeed ( void  ) const
inlinevirtual

Returns the speed of sound in ft/sec.

Reimplemented in FGMSIS.

Definition at line 183 of file FGAtmosphere.h.

183{return Soundspeed;}
+ Here is the caller graph for this function:

◆ GetSoundSpeedRatio()

virtual double GetSoundSpeedRatio ( void  ) const
inlinevirtual

Returns the ratio of at-altitude sound speed over the sea level value.

Definition at line 192 of file FGAtmosphere.h.

192{ return Soundspeed/SLsoundspeed; }

◆ GetSoundSpeedSL()

virtual double GetSoundSpeedSL ( void  ) const
inlinevirtual

Returns the sea level speed of sound in ft/sec.

Definition at line 189 of file FGAtmosphere.h.

189{ return SLsoundspeed; }

◆ GetTemperature() [1/2]

virtual double GetTemperature ( ) const
inlinevirtual

Returns the actual, modeled temperature at the current altitude in degrees Rankine.

Returns
Modeled temperature in degrees Rankine.

Reimplemented in FGMSIS.

Definition at line 109 of file FGAtmosphere.h.

109{return Temperature;}
+ Here is the caller graph for this function:

◆ GetTemperature() [2/2]

virtual double GetTemperature ( double  altitude) const
pure virtual

Returns the actual modeled temperature in degrees Rankine at a specified altitude.

Parameters
altitudeThe altitude above sea level (ASL) in feet.
Returns
Modeled temperature in degrees Rankine at the specified altitude.

Implemented in FGMSIS, FGStandardAtmosphere, and FGMSIS.

◆ GetTemperatureRatio() [1/2]

virtual double GetTemperatureRatio ( ) const
inlinevirtual

Returns the ratio of the at-current-altitude temperature as modeled over the sea level value.

Definition at line 122 of file FGAtmosphere.h.

122{ return GetTemperature()/SLtemperature; }

◆ GetTemperatureRatio() [2/2]

virtual double GetTemperatureRatio ( double  h) const
inlinevirtual

Returns the ratio of the temperature as modeled at the supplied altitude over the sea level value.

Definition at line 126 of file FGAtmosphere.h.

126{ return GetTemperature(h)/SLtemperature; }

◆ GetTemperatureSL()

virtual double GetTemperatureSL ( ) const
inlinevirtual

Returns the actual, modeled sea level temperature in degrees Rankine.

Returns
The modeled temperature in degrees Rankine at sea level.

Definition at line 118 of file FGAtmosphere.h.

118{ return SLtemperature; }

◆ InitModel()

bool InitModel ( void  )
overridevirtual

Reimplemented from FGModelFunctions.

Reimplemented in FGMSIS.

Definition at line 79 of file FGAtmosphere.cpp.

80{
81 if (!FGModel::InitModel()) return false;
82
83 SLtemperature = Temperature = StdDaySLtemperature;
84 SLpressure = Pressure = StdDaySLpressure;
85 SLdensity = Density = Pressure/(Reng*Temperature);
86 SLsoundspeed = Soundspeed = StdDaySLsoundspeed;
87 Calculate(0.0);
88
89 return true;
90}
virtual void Calculate(double altitude)
Calculate the atmosphere for the given altitude.

◆ Run()

bool Run ( bool  Holding)
overridevirtual

Runs the atmosphere forces model; called by the Executive.

Can pass in a value indicating if the executive is directing the simulation to Hold.

Parameters
Holdingif true, the executive has been directed to hold the sim from advancing time. Some models may ignore this flag, such as the Input model, which may need to be active to listen on a socket for the "Resume" command to be given.
Returns
false if no error

Reimplemented from FGModel.

Definition at line 94 of file FGAtmosphere.cpp.

95{
96 if (FGModel::Run(Holding)) return true;
97 if (Holding) return false;
98
99 Calculate(in.altitudeASL);
100
101 Debug(2);
102 return false;
103}
virtual bool Run(bool Holding)
Runs the model; called by the Executive.
Definition FGModel.cpp:89
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetPressureSL()

void SetPressureSL ( ePressure  unit,
double  pressure 
)
virtual

Sets the sea level pressure for modeling.

Parameters
pressureThe pressure in the units specified.
unitthe unit of measure that the specified pressure is supplied in.

Reimplemented in FGStandardAtmosphere.

Definition at line 198 of file FGAtmosphere.cpp.

199{
200 double press = ConvertToPSF(pressure, unit);
201
202 SLpressure = ValidatePressure(press, "Sea Level pressure");
203 SLdensity = GetDensity(0.0);
204}
double ConvertToPSF(double t, ePressure unit=ePSF) const
Converts to PSF (pounds per square foot) from one of several unit systems.
+ Here is the call graph for this function:

◆ SetTemperature()

virtual void SetTemperature ( double  t,
double  h,
eTemperature  unit = eFahrenheit 
)
pure virtual

Sets the temperature at the supplied altitude.

Parameters
tThe temperature value in the unit provided.
hThe altitude in feet above sea level.
unitThe unit of the temperature.

Implemented in FGStandardAtmosphere.

◆ SetTemperatureSL()

void SetTemperatureSL ( double  t,
eTemperature  unit = eFahrenheit 
)
virtual

Sets the Sea Level temperature.

Parameters
tthe temperature value in the unit provided.
unitthe unit of the temperature.

Reimplemented in FGStandardAtmosphere.

Definition at line 226 of file FGAtmosphere.cpp.

227{
228 double temp = ConvertToRankine(t, unit);
229
230 SLtemperature = ValidateTemperature(temp, "Sea Level temperature");
231 SLdensity = GetDensity(0.0);
232 SLsoundspeed = GetSoundSpeed(0.0);
233}
double ConvertToRankine(double t, eTemperature unit) const
Converts to Rankine from one of several unit systems.
+ Here is the call graph for this function:

◆ ValidatePressure()

double ValidatePressure ( double  p,
const std::string &  msg,
bool  quiet = false 
) const
protected

Check that the pressure is within plausible boundaries.

Parameters
msgMessage to display if the pressure is out of boundaries
quietDon't display the message if set to true

Definition at line 108 of file FGAtmosphere.cpp.

109{
110 const double MinPressure = ConvertToPSF(1E-15, ePascals);
111 if (p < MinPressure) {
112 if (!quiet) {
113 cerr << msg << " " << p << " is too low." << endl
114 << msg << " is capped to " << MinPressure << endl;
115 }
116 return MinPressure;
117 }
118 return p;
119}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ValidateTemperature()

double ValidateTemperature ( double  t,
const std::string &  msg,
bool  quiet = false 
) const
protected

Check that the temperature is within plausible boundaries.

Parameters
msgMessage to display if the pressure is out of boundaries
quietDon't display the message if set to true

Definition at line 126 of file FGAtmosphere.cpp.

127{
128 // Minimum known temperature in the universe currently
129 constexpr double minUniverseTemperature = KelvinToRankine(1.0);
130
131 if (t < minUniverseTemperature) {
132 if (!quiet) {
133 cerr << msg << " " << t << " is too low." << endl
134 << msg << " is capped to " << minUniverseTemperature << endl;
135 }
136 return minUniverseTemperature;
137 }
138 return t;
139}
static constexpr double KelvinToRankine(double kelvin)
Converts from degrees Kelvin to degrees Rankine.
Definition FGJSBBase.h:206
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ atmosphere_node

SGPropertyNode_ptr atmosphere_node
protected

Definition at line 240 of file FGAtmosphere.h.

◆ Beta

constexpr double Beta = 2.269690E-08
staticconstexprprotected

Definition at line 235 of file FGAtmosphere.h.

◆ Density

double Density = 0.0
protected

Definition at line 228 of file FGAtmosphere.h.

◆ DensityAltitude

double DensityAltitude = 0.0
protected

Definition at line 232 of file FGAtmosphere.h.

◆ g0

constexpr double g0 = 9.80665 / fttom
staticconstexprprotected

Sea-level acceleration of gravity - ft/s^2.

This constant is defined to compute the International Standard Atmosphere. It is by definition the sea level gravity at a latitude of 45deg. This value is fixed whichever gravity model is used by FGInertial.

Definition at line 296 of file FGAtmosphere.h.

◆ KinematicViscosity

double KinematicViscosity = 0.0
protected

Definition at line 237 of file FGAtmosphere.h.

◆ Mair

constexpr double Mair = 28.9645 * kgtoslug / 1000.0
staticconstexprprotected

Mean molecular weight for air - slug/mol.

Definition at line 290 of file FGAtmosphere.h.

◆ override_density_node

SGPropertyNode_ptr override_density_node
protected

Definition at line 244 of file FGAtmosphere.h.

◆ override_node

SGPropertyNode_ptr override_node
protected

Definition at line 241 of file FGAtmosphere.h.

◆ override_pressure_node

SGPropertyNode_ptr override_pressure_node
protected

Definition at line 243 of file FGAtmosphere.h.

◆ override_temperature_node

SGPropertyNode_ptr override_temperature_node
protected

Definition at line 242 of file FGAtmosphere.h.

◆ Pressure

double Pressure = 0.0
protected

Definition at line 229 of file FGAtmosphere.h.

◆ PressureAltitude

double PressureAltitude = 0.0
protected

Definition at line 231 of file FGAtmosphere.h.

◆ Reng

double Reng = Reng0
protected

Definition at line 301 of file FGAtmosphere.h.

◆ Reng0

constexpr double Reng0 = Rstar / Mair
staticconstexprprotected

Specific gas constant for air - ft*lbf/slug/R.

Definition at line 298 of file FGAtmosphere.h.

◆ Rstar

constexpr double Rstar = 8.31432 * kgtoslug / KelvinToRankine(fttom * fttom)
staticconstexprprotected

Universal gas constant - ft*lbf/R/mol.

Definition at line 288 of file FGAtmosphere.h.

◆ SHRatio

constexpr double SHRatio = 1.4
staticconstexpr

Definition at line 218 of file FGAtmosphere.h.

◆ SLdensity

double SLdensity = 1.0
protected

Definition at line 223 of file FGAtmosphere.h.

◆ SLpressure

double SLpressure = 1.0
protected

Definition at line 224 of file FGAtmosphere.h.

◆ SLsoundspeed

double SLsoundspeed = 1.0
protected

Definition at line 225 of file FGAtmosphere.h.

◆ SLtemperature

double SLtemperature = 1.8
protected

Definition at line 222 of file FGAtmosphere.h.

◆ Soundspeed

double Soundspeed = 0.0
protected

Definition at line 230 of file FGAtmosphere.h.

◆ StdDaySLdensity

constexpr double StdDaySLdensity = StdDaySLpressure / (Reng0 * StdDaySLtemperature)
staticconstexpr

Definition at line 307 of file FGAtmosphere.h.

◆ StdDaySLpressure

constexpr double StdDaySLpressure = 2116.228
staticconstexpr

Definition at line 216 of file FGAtmosphere.h.

◆ StdDaySLsoundspeed

const double StdDaySLsoundspeed

Definition at line 217 of file FGAtmosphere.h.

◆ StdDaySLtemperature

constexpr double StdDaySLtemperature = 518.67
staticconstexpr

Definition at line 215 of file FGAtmosphere.h.

◆ SutherlandConstant

constexpr double SutherlandConstant = 198.72
staticconstexprprotected

Definition at line 234 of file FGAtmosphere.h.

◆ Temperature

double Temperature = 1.8
protected

Definition at line 227 of file FGAtmosphere.h.

◆ Viscosity

double Viscosity = 0.0
protected

Definition at line 236 of file FGAtmosphere.h.


The documentation for this class was generated from the following files: