48 #include "FGFDMExec.h" 49 #include "FGAtmosphere.h" 53 IDENT(IdSrc,
"$Id: FGAtmosphere.cpp,v 1.62 2016/01/16 12:05:47 bcoconni Exp $");
54 IDENT(IdHdr,ID_ATMOSPHERE);
61 PressureAltitude(0.0),
63 SutherlandConstant(198.72),
66 Name =
"FGAtmosphere";
81 bool FGAtmosphere::InitModel(
void)
83 if (!FGModel::InitModel())
return false;
86 SLtemperature = Temperature = 518.67;
87 SLpressure = Pressure = 2116.22;
88 SLdensity = Density = Pressure/(Reng*Temperature);
89 SLsoundspeed = Soundspeed = sqrt(SHRatio*Reng*(Temperature));
91 rSLtemperature = 1/SLtemperature ;
92 rSLpressure = 1/SLpressure ;
93 rSLdensity = 1/SLdensity ;
94 rSLsoundspeed = 1/SLsoundspeed ;
104 if (Holding)
return false;
117 if (!PropertyManager->HasNode(
"atmosphere/override/temperature"))
120 Temperature = node->
GetDouble(
"atmosphere/override/temperature");
122 if (!PropertyManager->HasNode(
"atmosphere/override/pressure"))
125 Pressure = node->
GetDouble(
"atmosphere/override/pressure");
127 if (!PropertyManager->HasNode(
"atmosphere/override/density"))
128 Density = Pressure/(Reng*Temperature);
130 Density = node->
GetDouble(
"atmosphere/override/density");
132 Soundspeed = sqrt(SHRatio*Reng*(Temperature));
133 PressureAltitude = altitude;
134 DensityAltitude = altitude;
136 Viscosity = Beta * pow(Temperature, 1.5) / (SutherlandConstant + Temperature);
137 KinematicViscosity = Viscosity / Density;
144 double press = ConvertToPSF(pressure, unit);
171 SLtemperature = ConvertToRankine(t, unit);
176 double FGAtmosphere::ConvertToRankine(
double t,
eTemperature unit)
const 182 targetTemp = t + 459.67;
185 targetTemp = t*9.0/5.0 + 32.0 + 459.67;
191 targetTemp = t*9.0/5.0;
202 double FGAtmosphere::ConvertToPSF(
double p,
ePressure unit)
const 204 double targetPressure=0;
211 targetPressure = p*2.08854342;
214 targetPressure = p*0.0208854342;
217 targetPressure = p*70.7180803;
220 throw(
"Undefined pressure unit given");
223 return targetPressure;
226 double FGAtmosphere::ConvertFromPSF(
double p,
ePressure unit)
const 228 double targetPressure=0;
235 targetPressure = p/2.08854342;
238 targetPressure = p/0.0208854342;
241 targetPressure = p/70.7180803;
244 throw(
"Undefined pressure unit given");
247 return targetPressure;
252 void FGAtmosphere::bind(
void)
265 PropertyManager->
Tie(
"atmosphere/density-altitude",
this, &FGAtmosphere::GetDensityAltitude);
266 PropertyManager->
Tie(
"atmosphere/pressure-altitude",
this, &FGAtmosphere::GetPressureAltitude);
288 void FGAtmosphere::Debug(
int from)
290 if (debug_lvl <= 0)
return;
296 if (debug_lvl & 2 ) {
297 if (from == 0) std::cout <<
"Instantiated: FGAtmosphere" << std::endl;
298 if (from == 1) std::cout <<
"Destroyed: FGAtmosphere" << std::endl;
300 if (debug_lvl & 4 ) {
302 if (debug_lvl & 8 ) {
304 if (debug_lvl & 16) {
306 if (debug_lvl & 128) {
308 if (debug_lvl & 64) {
310 std::cout << IdSrc << std::endl;
311 std::cout << IdHdr << std::endl;
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.
void Calculate(double altitude)
Calculate the atmosphere for the given altitude.
virtual double GetSoundSpeedSL(void) const
Returns the sea level speed of sound in ft/sec.
Class wrapper for property handling.
ePressure
Enums for specifying pressure units.
virtual double GetPressure(void) const
Returns the pressure in psf.
virtual ~FGAtmosphere()
Destructor.
virtual double GetPressureRatio(void) const
Returns the ratio of at-altitude pressure over the sea level value.
virtual bool Run(bool Holding)
Runs the model; called by the Executive.
void Tie(const std::string &name, bool *pointer, bool useDefault=true)
Tie a property to an external bool variable.
virtual double GetDensitySL(void) const
Returns the sea level density in slugs/ft^3.
virtual double GetSoundSpeed(void) const
Returns the speed of sound in ft/sec.
Base class for all scheduled JSBSim models.
virtual double GetTemperatureSL() const
Returns the actual, modeled sea level temperature in degrees Rankine.
double GetDouble(const std::string &name, double defaultValue=0.0) const
Get a double value for a property.
bool Run(bool Holding)
Runs the atmosphere forces model; called by the Executive.
virtual double GetDensity(void) const
Returns the density in slugs/ft^3.
FGAtmosphere(FGFDMExec *)
Constructor.
eTemperature
Enums for specifying temperature units.
virtual double GetSoundSpeedRatio(void) const
Returns the ratio of at-altitude sound speed over the sea level value.
Encapsulates the JSBSim simulation executive.
virtual double GetDensityRatio(void) const
Returns the ratio of at-altitude density 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 GetTemperature() const
Returns the actual, modeled temperature at the current altitude in degrees Rankine.