JSBSim Flight Dynamics Model 1.3.0 (09 Apr 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
 
const std::string & GetName (void) const
 
unsigned int GetRate (void) const
 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 57 of file FGAtmosphere.cpp.

58 : FGModel(fdmex),
59 StdDaySLsoundspeed(sqrt(SHRatio*Reng0*StdDaySLtemperature))
60{
61 Name = "FGAtmosphere";
62
63 bind();
64 SGPropertyNode* root = PropertyManager->GetNode();
65 atmosphere_node = root->getNode("atmosphere");
66
67 assert(atmosphere_node);
68 Debug(0);
69}
static constexpr double Reng0
Specific gas constant for air - ft*lbf/slug/R.
FGModel(FGFDMExec *)
Constructor.
Definition FGModel.cpp:58
A node in a property tree.
Definition props.hxx:747
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 73 of file FGAtmosphere.cpp.

74{
75 Debug(1);
76}

Member Function Documentation

◆ bind()

void bind ( void  )
protectedvirtual

Definition at line 344 of file FGAtmosphere.cpp.

345{
346 PropertyManager->Tie("atmosphere/T-R", this, &FGAtmosphere::GetTemperature);
347 PropertyManager->Tie("atmosphere/rho-slugs_ft3", this, &FGAtmosphere::GetDensity);
348 PropertyManager->Tie("atmosphere/P-psf", this, &FGAtmosphere::GetPressure);
349 PropertyManager->Tie("atmosphere/a-fps", this, &FGAtmosphere::GetSoundSpeed);
350 PropertyManager->Tie("atmosphere/T-sl-R", this, &FGAtmosphere::GetTemperatureSL);
351 PropertyManager->Tie("atmosphere/rho-sl-slugs_ft3", this, &FGAtmosphere::GetDensitySL);
352 PropertyManager->Tie("atmosphere/a-sl-fps", this, &FGAtmosphere::GetSoundSpeedSL);
353 PropertyManager->Tie("atmosphere/theta", this, &FGAtmosphere::GetTemperatureRatio);
354 PropertyManager->Tie("atmosphere/sigma", this, &FGAtmosphere::GetDensityRatio);
355 PropertyManager->Tie("atmosphere/delta", this, &FGAtmosphere::GetPressureRatio);
356 PropertyManager->Tie("atmosphere/a-ratio", this, &FGAtmosphere::GetSoundSpeedRatio);
357 PropertyManager->Tie("atmosphere/density-altitude", this, &FGAtmosphere::GetDensityAltitude);
358 PropertyManager->Tie("atmosphere/pressure-altitude", this, &FGAtmosphere::GetPressureAltitude);
359}
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 146 of file FGAtmosphere.cpp.

147{
148 double t =0.0;
149 double p = 0.0;
150
151 if (!override_node) override_node = atmosphere_node->getNode("override");
152
153 // Temperature and pressure
154 if (override_node) {
155 if (!override_temperature_node)
156 override_temperature_node = override_node->getNode("temperature");
157
158 if (override_temperature_node)
159 t = override_temperature_node->getDoubleValue();
160 else
161 t = GetTemperature(altitude);
162
163 if (!override_pressure_node)
164 override_pressure_node = override_node->getNode("pressure");
165
166 if (override_pressure_node)
167 p = override_pressure_node->getDoubleValue();
168 else
169 p = GetPressure(altitude);
170 } else {
171 t = GetTemperature(altitude);
172 p = GetPressure(altitude);
173 }
174
175 Temperature = ValidateTemperature(t, "", true);
176 Pressure = ValidatePressure(p, "", true);
177
178 // Density
179 if (override_node) {
180 if (!override_density_node)
181 override_density_node = override_node->getNode("density");
182
183 if (override_density_node)
184 Density = override_density_node->getDoubleValue();
185 else
186 Density = Pressure/(Reng*Temperature);
187 }
188 else
189 Density = Pressure/(Reng*Temperature);
190
191 Soundspeed = sqrt(SHRatio*Reng*Temperature);
192 PressureAltitude = CalculatePressureAltitude(Pressure, altitude);
193 DensityAltitude = CalculateDensityAltitude(Density, altitude);
194
195 Viscosity = Beta * pow(Temperature, 1.5) / (SutherlandConstant + Temperature);
196 KinematicViscosity = Viscosity / Density;
197}
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 318 of file FGAtmosphere.cpp.

319{
320 double targetPressure=0; // Pressure
321
322 switch(unit) {
323 case ePSF:
324 targetPressure = p;
325 break;
326 case eMillibars:
327 targetPressure = p/2.08854342;
328 break;
329 case ePascals:
330 targetPressure = p/0.0208854342;
331 break;
332 case eInchesHg:
333 targetPressure = p/70.7180803;
334 break;
335 default:
336 throw BaseException("Undefined pressure unit given");
337 }
338
339 return targetPressure;
340}
+ 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 266 of file FGAtmosphere.cpp.

267{
268 double targetTemp=0;
269
270 switch(unit) {
271 case eFahrenheit:
272 targetTemp = t - 459.67;
273 break;
274 case eCelsius:
275 targetTemp = t/1.8 - 273.15;
276 break;
277 case eRankine:
278 targetTemp = t;
279 break;
280 case eKelvin:
281 targetTemp = t/1.8;
282 break;
283 default:
284 throw BaseException("Undefined temperature unit given");
285 }
286
287 return targetTemp;
288}
+ 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 292 of file FGAtmosphere.cpp.

293{
294 double targetPressure=0; // Pressure in PSF
295
296 switch(unit) {
297 case ePSF:
298 targetPressure = p;
299 break;
300 case eMillibars:
301 targetPressure = p*2.08854342;
302 break;
303 case ePascals:
304 targetPressure = p*0.0208854342;
305 break;
306 case eInchesHg:
307 targetPressure = p*70.7180803;
308 break;
309 default:
310 throw BaseException("Undefined pressure unit given");
311 }
312
313 return targetPressure;
314}
+ 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 240 of file FGAtmosphere.cpp.

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

◆ Debug()

void Debug ( int  from)
overrideprotectedvirtual

Reimplemented from FGModel.

Definition at line 380 of file FGAtmosphere.cpp.

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

◆ 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 212 of file FGAtmosphere.cpp.

213{
214 return GetPressure(altitude)/(Reng * GetTemperature(altitude));
215}
+ 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 219 of file FGAtmosphere.cpp.

220{
221 return sqrt(SHRatio * Reng * GetTemperature(altitude));
222}
+ 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 80 of file FGAtmosphere.cpp.

81{
82 if (!FGModel::InitModel()) return false;
83
84 SLtemperature = Temperature = StdDaySLtemperature;
85 SLpressure = Pressure = StdDaySLpressure;
86 SLdensity = Density = Pressure/(Reng*Temperature);
87 SLsoundspeed = Soundspeed = StdDaySLsoundspeed;
88 Calculate(0.0);
89
90 return true;
91}
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 95 of file FGAtmosphere.cpp.

96{
97 if (FGModel::Run(Holding)) return true;
98 if (Holding) return false;
99
100 Calculate(in.altitudeASL);
101
102 Debug(2);
103 return false;
104}
virtual bool Run(bool Holding)
Runs the model; called by the Executive.
Definition FGModel.cpp:90
+ 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 201 of file FGAtmosphere.cpp.

202{
203 double press = ConvertToPSF(pressure, unit);
204
205 SLpressure = ValidatePressure(press, "Sea Level pressure");
206 SLdensity = GetDensity(0.0);
207}
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 229 of file FGAtmosphere.cpp.

230{
231 double temp = ConvertToRankine(t, unit);
232
233 SLtemperature = ValidateTemperature(temp, "Sea Level temperature");
234 SLdensity = GetDensity(0.0);
235 SLsoundspeed = GetSoundSpeed(0.0);
236}
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 109 of file FGAtmosphere.cpp.

110{
111 const double MinPressure = ConvertToPSF(1E-15, ePascals);
112 if (p < MinPressure) {
113 if (!quiet) {
114 FGLogging log(LogLevel::WARN);
115 log << msg << " " << p << " is too low." << endl
116 << msg << " will be capped to " << MinPressure << endl;
117 }
118 return MinPressure;
119 }
120 return p;
121}
+ 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 128 of file FGAtmosphere.cpp.

129{
130 // Minimum known temperature in the universe currently
131 constexpr double minUniverseTemperature = KelvinToRankine(1.0);
132
133 if (t < minUniverseTemperature) {
134 if (!quiet) {
135 FGLogging log(LogLevel::WARN);
136 log << msg << " " << t << " is too low." << endl
137 << msg << " will be capped to " << minUniverseTemperature << endl;
138 }
139 return minUniverseTemperature;
140 }
141 return t;
142}
static constexpr double KelvinToRankine(double kelvin)
Converts from degrees Kelvin to degrees Rankine.
Definition FGJSBBase.h:207
+ 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: