46#include "FGAtmosphere.h"
47#include "input_output/FGLog.h"
59 StdDaySLsoundspeed(sqrt(SHRatio*Reng0*StdDaySLtemperature))
61 Name =
"FGAtmosphere";
65 atmosphere_node = root->
getNode(
"atmosphere");
67 assert(atmosphere_node);
80bool FGAtmosphere::InitModel(
void)
82 if (!FGModel::InitModel())
return false;
84 SLtemperature = Temperature = StdDaySLtemperature;
85 SLpressure = Pressure = StdDaySLpressure;
86 SLdensity = Density = Pressure/(Reng*Temperature);
87 SLsoundspeed = Soundspeed = StdDaySLsoundspeed;
98 if (Holding)
return false;
111 const double MinPressure =
ConvertToPSF(1E-15, ePascals);
112 if (p < MinPressure) {
115 log << msg <<
" " << p <<
" is too low." << endl
116 << msg <<
" will be capped to " << MinPressure << endl;
133 if (t < minUniverseTemperature) {
136 log << msg <<
" " << t <<
" is too low." << endl
137 << msg <<
" will be capped to " << minUniverseTemperature << endl;
139 return minUniverseTemperature;
151 if (!override_node) override_node = atmosphere_node->getNode(
"override");
155 if (!override_temperature_node)
156 override_temperature_node = override_node->getNode(
"temperature");
158 if (override_temperature_node)
159 t = override_temperature_node->getDoubleValue();
163 if (!override_pressure_node)
164 override_pressure_node = override_node->getNode(
"pressure");
166 if (override_pressure_node)
167 p = override_pressure_node->getDoubleValue();
180 if (!override_density_node)
181 override_density_node = override_node->getNode(
"density");
183 if (override_density_node)
184 Density = override_density_node->getDoubleValue();
186 Density = Pressure/(Reng*Temperature);
189 Density = Pressure/(Reng*Temperature);
191 Soundspeed = sqrt(SHRatio*Reng*Temperature);
195 Viscosity = Beta * pow(Temperature, 1.5) / (SutherlandConstant + Temperature);
196 KinematicViscosity = Viscosity / Density;
246 targetTemp = t + 459.67;
249 targetTemp = (t + 273.15) * 1.8;
272 targetTemp = t - 459.67;
275 targetTemp = t/1.8 - 273.15;
294 double targetPressure=0;
301 targetPressure = p*2.08854342;
304 targetPressure = p*0.0208854342;
307 targetPressure = p*70.7180803;
313 return targetPressure;
320 double targetPressure=0;
327 targetPressure = p/2.08854342;
330 targetPressure = p/0.0208854342;
333 targetPressure = p/70.7180803;
339 return targetPressure;
344void FGAtmosphere::bind(
void)
357 PropertyManager->Tie(
"atmosphere/density-altitude",
this, &FGAtmosphere::GetDensityAltitude);
358 PropertyManager->Tie(
"atmosphere/pressure-altitude",
this, &FGAtmosphere::GetPressureAltitude);
380void FGAtmosphere::Debug(
int from)
382 if (debug_lvl <= 0)
return;
388 if (debug_lvl & 2 ) {
389 FGLogging log(LogLevel::DEBUG);
390 if (from == 0) log <<
"Instantiated: FGAtmosphere" << std::endl;
391 if (from == 1) log <<
"Destroyed: FGAtmosphere" << std::endl;
393 if (debug_lvl & 4 ) {
395 if (debug_lvl & 8 ) {
397 if (debug_lvl & 16) {
399 if (debug_lvl & 128) {
401 if (debug_lvl & 64) {
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.
double ConvertToRankine(double t, eTemperature unit) const
Converts to Rankine from one of several unit systems.
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 void Calculate(double altitude)
Calculate the atmosphere for the given altitude.
double ConvertFromPSF(double t, ePressure unit=ePSF) const
Converts from PSF (pounds per square foot) to one of several unit systems.
virtual double GetPressure(void) const
Returns the pressure in psf.
virtual double GetSoundSpeedSL(void) const
Returns the sea level speed of sound in ft/sec.
eTemperature
Enums for specifying temperature units.
double ConvertFromRankine(double t, eTemperature unit) const
Converts from Rankine 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.
bool Run(bool Holding) override
Runs the atmosphere forces model; called by the Executive.
double ValidateTemperature(double t, const std::string &msg, bool quiet=false) const
Check that the temperature is within plausible boundaries.
double ConvertToPSF(double t, ePressure unit=ePSF) const
Converts to PSF (pounds per square foot) from one of several unit systems.
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 ~FGAtmosphere()
Destructor.
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 void SetPressureSL(ePressure unit, double pressure)
Sets the sea level pressure for modeling.
virtual void SetTemperatureSL(double t, eTemperature unit=eFahrenheit)
Sets the Sea Level temperature.
virtual double GetDensityRatio(void) const
Returns the ratio of at-altitude density over the sea level value.
FGAtmosphere(FGFDMExec *)
Constructor.
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.
static constexpr double KelvinToRankine(double kelvin)
Converts from degrees Kelvin to degrees Rankine.
Base class for all scheduled JSBSim models.
virtual bool Run(bool Holding)
Runs the model; called by the Executive.
A node in a property tree.
SGPropertyNode * getNode(const char *relative_path, bool create=false)
Get a pointer to another node by relative path.
Main namespace for the JSBSim Flight Dynamics Model.