 |
JSBSim Flight Dynamics Model
1.1.11 (13 Feb 2022)
An Open Source Flight Dynamics and Control Software Library in C++
|
45 #include "FGFDMExec.h"
46 #include "FGAtmosphere.h"
58 const double FGAtmosphere::StdDaySLsoundspeed = sqrt(SHRatio*Reng*StdDaySLtemperature);
61 PressureAltitude(0.0),
64 Name =
"FGAtmosphere";
79 bool FGAtmosphere::InitModel(
void)
81 if (!FGModel::InitModel())
return false;
84 SLtemperature = Temperature = StdDaySLtemperature;
85 SLpressure = Pressure = StdDaySLpressure;
86 SLdensity = Density = Pressure/(
Reng*Temperature);
87 SLsoundspeed = Soundspeed = StdDaySLsoundspeed;
97 if (Holding)
return false;
110 if (!PropertyManager->HasNode(
"atmosphere/override/temperature"))
113 Temperature = node->
GetDouble(
"atmosphere/override/temperature");
115 if (!PropertyManager->HasNode(
"atmosphere/override/pressure"))
118 Pressure = node->
GetDouble(
"atmosphere/override/pressure");
120 if (!PropertyManager->HasNode(
"atmosphere/override/density"))
123 Density = node->
GetDouble(
"atmosphere/override/density");
125 Soundspeed = sqrt(SHRatio*
Reng*Temperature);
129 Viscosity = Beta * pow(Temperature, 1.5) / (SutherlandConstant + Temperature);
130 KinematicViscosity = Viscosity / Density;
175 targetTemp = t + 459.67;
178 targetTemp = (t + 273.15) * 1.8;
201 targetTemp = t - 459.67;
204 targetTemp = t/1.8 - 273.15;
223 double targetPressure=0;
230 targetPressure = p*2.08854342;
233 targetPressure = p*0.0208854342;
236 targetPressure = p*70.7180803;
239 throw(
"Undefined pressure unit given");
242 return targetPressure;
247 double targetPressure=0;
254 targetPressure = p/2.08854342;
257 targetPressure = p/0.0208854342;
260 targetPressure = p/70.7180803;
263 throw(
"Undefined pressure unit given");
266 return targetPressure;
271 void FGAtmosphere::bind(
void)
284 PropertyManager->
Tie(
"atmosphere/density-altitude",
this, &FGAtmosphere::GetDensityAltitude);
285 PropertyManager->
Tie(
"atmosphere/pressure-altitude",
this, &FGAtmosphere::GetPressureAltitude);
307 void FGAtmosphere::Debug(
int from)
309 if (debug_lvl <= 0)
return;
315 if (debug_lvl & 2 ) {
316 if (from == 0) std::cout <<
"Instantiated: FGAtmosphere" << std::endl;
317 if (from == 1) std::cout <<
"Destroyed: FGAtmosphere" << std::endl;
319 if (debug_lvl & 4 ) {
321 if (debug_lvl & 8 ) {
323 if (debug_lvl & 16) {
325 if (debug_lvl & 128) {
327 if (debug_lvl & 64) {
Encapsulates the JSBSim simulation executive.
eTemperature
Enums for specifying temperature units.
double ConvertToRankine(double t, eTemperature unit) const
Converts to Rankine from one of several unit systems.
virtual double GetDensityRatio(void) const
Returns the ratio of at-altitude density over the sea level value.
virtual double GetPressure(void) const
Returns the pressure in psf.
Base class for all scheduled JSBSim models.
virtual double GetSoundSpeedSL(void) const
Returns the sea level speed of sound in ft/sec.
ePressure
Enums for specifying pressure units.
virtual void SetPressureSL(ePressure unit, double pressure)
Sets the sea level pressure for modeling.
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.
Class wrapper for property handling.
static double Reng
Specific gas constant for air - ft*lbf/slug/R.
virtual double GetDensitySL(void) const
Returns the sea level density in slugs/ft^3.
double GetDouble(const std::string &name, double defaultValue=0.0) const
Get a double value for a property.
virtual double GetTemperatureSL() const
Returns the actual, modeled sea level temperature in degrees Rankine.
virtual double GetSoundSpeed(void) const
Returns the speed of sound in ft/sec.
virtual void Calculate(double altitude)
Calculate the atmosphere for the given altitude.
virtual void SetTemperatureSL(double t, eTemperature unit=eFahrenheit)
Sets the Sea Level temperature.
virtual bool Run(bool Holding)
Runs the model; called by the Executive.
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 ConvertFromRankine(double t, eTemperature unit) const
Converts from Rankine to one of several unit systems.
virtual double GetTemperature() const
Returns the actual, modeled temperature at the current altitude in degrees Rankine.
virtual double CalculatePressureAltitude(double pressure, double geometricAlt)
Calculates the pressure altitude given any temperature or pressure bias.
virtual double GetTemperatureRatio() const
Returns the ratio of the at-current-altitude temperature as modeled over the sea level value.
FGAtmosphere(FGFDMExec *)
Constructor.
virtual ~FGAtmosphere()
Destructor.
bool Run(bool Holding) override
Runs the atmosphere forces model; called by the Executive.
virtual double GetDensity(void) const
Returns the density in slugs/ft^3.
virtual double CalculateDensityAltitude(double density, double geometricAlt)
Calculates the density altitude given any temperature or pressure bias.
void Tie(const std::string &name, T *pointer)
Tie a property to an external variable.