1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 Module: FGAtmosphere.cpp
5 Implementation of 1959 Standard Atmosphere added by Tony Peden
7 Purpose: Models the atmosphere
10 ------------- Copyright (C) 1999 Jon S. Berndt (jon@jsbsim.org) -------------
12 This program is free software; you can redistribute it and/or modify it under
13 the terms of the GNU Lesser General Public License as published by the Free Software
14 Foundation; either version 2 of the License, or (at your option) any later
17 This program is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
22 You should have received a copy of the GNU Lesser General Public License along with
23 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
24 Place - Suite 330, Boston, MA 02111-1307, USA.
26 Further information about the GNU Lesser General Public License can also be found on
27 the world wide web at http://www.gnu.org.
29 FUNCTIONAL DESCRIPTION
30 --------------------------------------------------------------------------------
31 Models the atmosphere. The equation used below was determined by a third order
32 curve fit using Excel. The data is from the ICAO atmosphere model.
35 --------------------------------------------------------------------------------
37 07/23/99 TP Added implementation of 1959 Standard Atmosphere
38 Moved calculation of Mach number to FGPropagate
39 Later updated to '76 model
40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
41 COMMENTS, REFERENCES, and NOTES
42 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43 [1] Anderson, John D. "Introduction to Flight, Third Edition", McGraw-Hill,
44 1989, ISBN 0-07-001641-0
46 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
48 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
50 #include "FGAtmosphere.h"
52 #include <FGFDMExec.h>
53 #include "FGAircraft.h"
54 #include "FGPropagate.h"
55 #include "FGInertial.h"
56 #include <input_output/FGPropertyManager.h>
60 static const char *IdSrc = "$Id$";
61 static const char *IdHdr = ID_ATMOSPHERE;
63 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
65 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
67 FGAtmosphere::FGAtmosphere(FGFDMExec* fdmex) : FGModel(fdmex)
69 Name = "FGAtmosphere";
80 htab[7]=278385.0; //ft.
82 MagnitudedAccelDt = MagnitudeAccel = Magnitude = 0.0;
83 // SetTurbType( ttCulp );
84 SetTurbType( ttNone );
88 spike = target_time = strength = 0.0;
89 wind_from_clockwise = 0.0;
90 SutherlandConstant = 198.72; // deg Rankine
91 Beta = 2.269690E-08; // slug/(sec ft R^0.5)
93 T_dev_sl = T_dev = delta_T = 0.0;
94 StandardTempOnly = false;
96 vGustNED.InitMatrix();
97 vTurbulenceNED.InitMatrix();
103 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
105 FGAtmosphere::~FGAtmosphere()
110 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
112 bool FGAtmosphere::InitModel(void)
114 if (!FGModel::InitModel()) return false;
116 UseInternal(); // this is the default
119 StdSLtemperature = SLtemperature = 518.67;
120 StdSLpressure = SLpressure = 2116.22;
121 StdSLdensity = SLdensity = 0.00237767;
122 StdSLsoundspeed = SLsoundspeed = sqrt(SHRatio*Reng*StdSLtemperature);
123 rSLtemperature = 1.0/StdSLtemperature;
124 rSLpressure = 1.0/StdSLpressure;
125 rSLdensity = 1.0/StdSLdensity;
126 rSLsoundspeed = 1.0/StdSLsoundspeed;
131 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
133 bool FGAtmosphere::Run(void)
135 if (FGModel::Run()) return true;
136 if (FDMExec->Holding()) return false;
139 h = Propagate->GetAltitudeASL();
152 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
156 void FGAtmosphere::Calculate(double altitude)
158 double slope, reftemp, refpress;
161 if (altitude < htab[lastIndex]) {
167 while (htab[i] > altitude) i--;
169 } else if (altitude > htab[lastIndex+1]) {
170 if (altitude >= htab[7]) {
175 while (htab[i+1] < altitude) i++;
181 slope = -0.00356616; // R/ft.
182 reftemp = 518.67; // in degrees Rankine, 288.15 Kelvin
183 refpress = 2116.22; // psf
184 //refdens = 0.00237767; // slugs/cubic ft.
186 case 1: // 36089 ft. or 11 km
188 reftemp = 389.97; // in degrees Rankine, 216.65 Kelvin
190 //refdens = 0.000706032;
192 case 2: // 65616 ft. or 20 km
194 reftemp = 389.97; // in degrees Rankine, 216.65 Kelvin
196 //refdens = 0.000171306;
198 case 3: // 104986 ft. or 32 km
200 reftemp = 411.57; // in degrees Rankine, 228.65 Kelvin
202 //refdens = 1.18422e-05;
204 case 4: // 154199 ft. 47 km
206 reftemp = 487.17; // in degrees Rankine, 270.65 Kelvin
208 //refdens = 4.00585e-7;
210 case 5: // 167322 ft. or 51 km
211 slope = -0.001536192;
212 reftemp = 487.17; // in degrees Rankine, 270.65 Kelvin
214 //refdens = 8.17102e-7;
216 case 6: // 232940 ft. or 71 km
218 reftemp = 386.368; // in degrees Rankine, 214.649 Kelvin
220 //refdens = 8.77702e-9;
222 case 7: // 278385 ft. or 84.8520 km
224 reftemp = 336.5; // in degrees Rankine, 186.94 Kelvin
226 //refdens = 2.19541e-10;
228 default: // sea level
229 slope = -0.00356616; // R/ft.
230 reftemp = 518.67; // in degrees Rankine, 288.15 Kelvin
231 refpress = 2116.22; // psf
232 //refdens = 0.00237767; // slugs/cubic ft.
237 // If delta_T is set, then that is our temperature deviation at any altitude.
238 // If not, then we'll estimate a deviation based on the sea level deviation (if set).
240 if(!StandardTempOnly) {
242 if (delta_T != 0.0) {
245 if ((altitude < 36089.239) && (T_dev_sl != 0.0)) {
246 T_dev = T_dev_sl * ( 1.0 - (altitude/36089.239));
253 intTemperature = reftemp;
254 intPressure = refpress*exp(-Inertial->SLgravity()/(reftemp*Reng)*(altitude-htab[i]));
255 intDensity = intPressure/(Reng*intTemperature);
257 intTemperature = reftemp+slope*(altitude-htab[i]);
258 intPressure = refpress*pow(intTemperature/reftemp,-Inertial->SLgravity()/(slope*Reng));
259 intDensity = intPressure/(Reng*intTemperature);
265 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
266 // Calculate parameters derived from T, P and rho
267 // Sum gust and turbulence values in NED frame into the wind vector.
269 void FGAtmosphere::CalculateDerived(void)
271 T_dev = (*temperature) - GetTemperature(h);
272 density_altitude = h + T_dev * 66.7;
274 if (turbType != ttNone) Turbulence();
276 vTotalWindNED = vWindNED + vGustNED + vTurbulenceNED;
278 // psiw (Wind heading) is the direction the wind is blowing towards
279 if (vWindNED(eX) != 0.0) psiw = atan2( vWindNED(eY), vWindNED(eX) );
280 if (psiw < 0) psiw += 2*M_PI;
282 soundspeed = sqrt(SHRatio*Reng*(*temperature));
284 intViscosity = Beta * pow(intTemperature, 1.5) / (SutherlandConstant + intTemperature);
285 intKinematicViscosity = intViscosity / intDensity;
289 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
290 // Get the standard atmospheric properties at a specified altitude
292 void FGAtmosphere::GetStdAtmosphere(double altitude) {
293 StandardTempOnly = true;
295 StandardTempOnly = false;
296 atmosphere.Temperature = intTemperature;
297 atmosphere.Pressure = intPressure;
298 atmosphere.Density = intDensity;
300 // Reset the internal atmospheric state
304 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
305 // Get the standard pressure at a specified altitude
307 double FGAtmosphere::GetPressure(double altitude) {
308 GetStdAtmosphere(altitude);
309 return atmosphere.Pressure;
312 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
313 // Get the standard temperature at a specified altitude
315 double FGAtmosphere::GetTemperature(double altitude) {
316 GetStdAtmosphere(altitude);
317 return atmosphere.Temperature;
320 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
321 // Get the standard density at a specified altitude
323 double FGAtmosphere::GetDensity(double altitude) {
324 GetStdAtmosphere(altitude);
325 return atmosphere.Density;
329 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
330 // square a value, but preserve the original sign
332 static inline double square_signed (double value)
335 return value * value * -1;
337 return value * value;
340 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
342 // psi is the angle that the wind is blowing *towards*
344 void FGAtmosphere::SetWindspeed(double speed)
346 if (vWindNED.Magnitude() == 0.0) {
348 vWindNED(eNorth) = speed;
350 vWindNED(eNorth) = speed * cos(psiw);
351 vWindNED(eEast) = speed * sin(psiw);
352 vWindNED(eDown) = 0.0;
356 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
358 double FGAtmosphere::GetWindspeed(void) const
360 return vWindNED.Magnitude();
363 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
365 // psi is the angle that the wind is blowing *towards*
367 void FGAtmosphere::SetWindPsi(double dir)
369 double mag = GetWindspeed();
374 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
376 void FGAtmosphere::Turbulence(void)
380 TurbGain = TurbGain * TurbGain * 100.0;
382 vDirectiondAccelDt(eX) = 1 - 2.0*(double(rand())/double(RAND_MAX));
383 vDirectiondAccelDt(eY) = 1 - 2.0*(double(rand())/double(RAND_MAX));
384 vDirectiondAccelDt(eZ) = 1 - 2.0*(double(rand())/double(RAND_MAX));
386 MagnitudedAccelDt = 1 - 2.0*(double(rand())/double(RAND_MAX)) - Magnitude;
387 // Scale the magnitude so that it moves
388 // away from the peaks
389 MagnitudedAccelDt = ((MagnitudedAccelDt - Magnitude) /
390 (1 + fabs(Magnitude)));
391 MagnitudeAccel += MagnitudedAccelDt*rate*TurbRate*State->Getdt();
392 Magnitude += MagnitudeAccel*rate*State->Getdt();
393 Magnitude = fabs(Magnitude);
395 vDirectiondAccelDt.Normalize();
397 // deemphasise non-vertical forces
398 vDirectiondAccelDt(eX) = square_signed(vDirectiondAccelDt(eX));
399 vDirectiondAccelDt(eY) = square_signed(vDirectiondAccelDt(eY));
401 vDirectionAccel += vDirectiondAccelDt*rate*TurbRate*State->Getdt();
402 vDirectionAccel.Normalize();
403 vDirection += vDirectionAccel*rate*State->Getdt();
405 vDirection.Normalize();
407 // Diminish turbulence within three wingspans
409 vTurbulenceNED = TurbGain * Magnitude * vDirection;
410 double HOverBMAC = Auxiliary->GetHOverBMAC();
412 vTurbulenceNED *= (HOverBMAC / 3.0) * (HOverBMAC / 3.0);
414 // I don't believe these next two statements calculate the proper gradient over
415 // the aircraft body. One reason is because this has no relationship with the
416 // orientation or velocity of the aircraft, which it must have. What is vTurbulenceGrad
417 // supposed to represent? And the direction and magnitude of the turbulence can change,
418 // so both accelerations need to be accounted for, no?
420 // Need to determine the turbulence change in body axes between two time points.
422 vTurbulenceGrad = TurbGain*MagnitudeAccel * vDirection;
423 vBodyTurbGrad = Propagate->GetTl2b()*vTurbulenceGrad;
425 if (Aircraft->GetWingSpan() > 0) {
426 vTurbPQR(eP) = vBodyTurbGrad(eY)/Aircraft->GetWingSpan();
428 vTurbPQR(eP) = vBodyTurbGrad(eY)/30.0;
430 // if (Aircraft->GetHTailArm() != 0.0)
431 // vTurbPQR(eQ) = vBodyTurbGrad(eZ)/Aircraft->GetHTailArm();
433 // vTurbPQR(eQ) = vBodyTurbGrad(eZ)/10.0;
435 if (Aircraft->GetVTailArm() > 0)
436 vTurbPQR(eR) = vBodyTurbGrad(eX)/Aircraft->GetVTailArm();
438 vTurbPQR(eR) = vBodyTurbGrad(eX)/10.0;
440 // Clear the horizontal forces
441 // actually felt by the plane, now
442 // that we've used them to calculate
445 // vTurbulenceNED(eX) = 0.0;
446 // vTurbulenceNED(eY) = 0.0;
450 case ttBerndt: { // This is very experimental and incomplete at the moment.
452 TurbGain = TurbGain * TurbGain * 100.0;
454 vDirectiondAccelDt(eX) = 1 - 2.0*(double(rand())/double(RAND_MAX));
455 vDirectiondAccelDt(eY) = 1 - 2.0*(double(rand())/double(RAND_MAX));
456 vDirectiondAccelDt(eZ) = 1 - 2.0*(double(rand())/double(RAND_MAX));
459 MagnitudedAccelDt = 1 - 2.0*(double(rand())/double(RAND_MAX)) - Magnitude;
460 MagnitudeAccel += MagnitudedAccelDt*rate*State->Getdt();
461 Magnitude += MagnitudeAccel*rate*State->Getdt();
463 vDirectiondAccelDt.Normalize();
464 vDirectionAccel += vDirectiondAccelDt*rate*State->Getdt();
465 vDirectionAccel.Normalize();
466 vDirection += vDirectionAccel*rate*State->Getdt();
468 // Diminish z-vector within two wingspans
470 double HOverBMAC = Auxiliary->GetHOverBMAC();
472 vDirection(eZ) *= HOverBMAC / 2.0;
474 vDirection.Normalize();
476 vTurbulenceNED = TurbGain*Magnitude * vDirection;
477 vTurbulenceGrad = TurbGain*MagnitudeAccel * vDirection;
479 vBodyTurbGrad = Propagate->GetTl2b()*vTurbulenceGrad;
480 vTurbPQR(eP) = vBodyTurbGrad(eY)/Aircraft->GetWingSpan();
481 if (Aircraft->GetHTailArm() > 0)
482 vTurbPQR(eQ) = vBodyTurbGrad(eZ)/Aircraft->GetHTailArm();
484 vTurbPQR(eQ) = vBodyTurbGrad(eZ)/10.0;
486 if (Aircraft->GetVTailArm() > 0)
487 vTurbPQR(eR) = vBodyTurbGrad(eX)/Aircraft->GetVTailArm();
489 vTurbPQR(eR) = vBodyTurbGrad(eX)/10.0;
495 vTurbPQR(eP) = wind_from_clockwise;
496 if (TurbGain == 0.0) return;
498 // keep the inputs within allowable limts for this model
499 if (TurbGain < 0.0) TurbGain = 0.0;
500 if (TurbGain > 1.0) TurbGain = 1.0;
501 if (TurbRate < 0.0) TurbRate = 0.0;
502 if (TurbRate > 30.0) TurbRate = 30.0;
503 if (Rhythmicity < 0.0) Rhythmicity = 0.0;
504 if (Rhythmicity > 1.0) Rhythmicity = 1.0;
506 // generate a sine wave corresponding to turbulence rate in hertz
507 double time = FDMExec->GetSimTime();
508 double sinewave = sin( time * TurbRate * 6.283185307 );
511 if (target_time == 0.0) {
512 strength = random = 1 - 2.0*(double(rand())/double(RAND_MAX));
513 target_time = time + 0.71 + (random * 0.5);
515 if (time > target_time) {
520 // max vertical wind speed in fps, corresponds to TurbGain = 1.0
523 vTurbulenceNED(1) = vTurbulenceNED(2) = vTurbulenceNED(3) = 0.0;
524 double delta = strength * max_vs * TurbGain * (1-Rhythmicity) * spike;
526 // Vertical component of turbulence.
527 vTurbulenceNED(3) = sinewave * max_vs * TurbGain * Rhythmicity;
528 vTurbulenceNED(3)+= delta;
529 double HOverBMAC = Auxiliary->GetHOverBMAC();
531 vTurbulenceNED(3) *= HOverBMAC * 0.3333;
533 // Yaw component of turbulence.
534 vTurbulenceNED(1) = sin( delta * 3.0 );
535 vTurbulenceNED(2) = cos( delta * 3.0 );
537 // Roll component of turbulence. Clockwise vortex causes left roll.
538 vTurbPQR(eP) += delta * 0.04;
548 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
550 void FGAtmosphere::UseExternal(void)
552 temperature=&exTemperature;
553 pressure=&exPressure;
558 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
560 void FGAtmosphere::UseInternal(void)
562 temperature=&intTemperature;
563 pressure=&intPressure;
568 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
570 void FGAtmosphere::bind(void)
572 typedef double (FGAtmosphere::*PMF)(int) const;
573 typedef double (FGAtmosphere::*PMFv)(void) const;
574 typedef void (FGAtmosphere::*PMFd)(int,double);
575 PropertyManager->Tie("atmosphere/T-R", this, (PMFv)&FGAtmosphere::GetTemperature);
576 PropertyManager->Tie("atmosphere/rho-slugs_ft3", this, (PMFv)&FGAtmosphere::GetDensity);
577 PropertyManager->Tie("atmosphere/P-psf", this, (PMFv)&FGAtmosphere::GetPressure);
578 PropertyManager->Tie("atmosphere/a-fps", this, &FGAtmosphere::GetSoundSpeed);
579 PropertyManager->Tie("atmosphere/T-sl-R", this, &FGAtmosphere::GetTemperatureSL);
580 PropertyManager->Tie("atmosphere/rho-sl-slugs_ft3", this, &FGAtmosphere::GetDensitySL);
581 PropertyManager->Tie("atmosphere/P-sl-psf", this, &FGAtmosphere::GetPressureSL);
582 PropertyManager->Tie("atmosphere/a-sl-fps", this, &FGAtmosphere::GetSoundSpeedSL);
583 PropertyManager->Tie("atmosphere/theta", this, &FGAtmosphere::GetTemperatureRatio);
584 PropertyManager->Tie("atmosphere/sigma", this, &FGAtmosphere::GetDensityRatio);
585 PropertyManager->Tie("atmosphere/delta", this, &FGAtmosphere::GetPressureRatio);
586 PropertyManager->Tie("atmosphere/a-ratio", this, &FGAtmosphere::GetSoundSpeedRatio);
587 PropertyManager->Tie("atmosphere/psiw-rad", this, &FGAtmosphere::GetWindPsi, &FGAtmosphere::SetWindPsi);
588 PropertyManager->Tie("atmosphere/delta-T", this, &FGAtmosphere::GetDeltaT, &FGAtmosphere::SetDeltaT);
589 PropertyManager->Tie("atmosphere/T-sl-dev-F", this, &FGAtmosphere::GetSLTempDev, &FGAtmosphere::SetSLTempDev);
590 PropertyManager->Tie("atmosphere/density-altitude", this, &FGAtmosphere::GetDensityAltitude);
592 PropertyManager->Tie("atmosphere/wind-north-fps", this, eNorth, (PMF)&FGAtmosphere::GetWindNED,
593 (PMFd)&FGAtmosphere::SetWindNED);
594 PropertyManager->Tie("atmosphere/wind-east-fps", this, eEast, (PMF)&FGAtmosphere::GetWindNED,
595 (PMFd)&FGAtmosphere::SetWindNED);
596 PropertyManager->Tie("atmosphere/wind-down-fps", this, eDown, (PMF)&FGAtmosphere::GetWindNED,
597 (PMFd)&FGAtmosphere::SetWindNED);
598 PropertyManager->Tie("atmosphere/wind-mag-fps", this, &FGAtmosphere::GetWindspeed,
599 &FGAtmosphere::SetWindspeed);
600 PropertyManager->Tie("atmosphere/total-wind-north-fps", this, eNorth, (PMF)&FGAtmosphere::GetTotalWindNED);
601 PropertyManager->Tie("atmosphere/total-wind-east-fps", this, eEast, (PMF)&FGAtmosphere::GetTotalWindNED);
602 PropertyManager->Tie("atmosphere/total-wind-down-fps", this, eDown, (PMF)&FGAtmosphere::GetTotalWindNED);
604 PropertyManager->Tie("atmosphere/gust-north-fps", this, eNorth, (PMF)&FGAtmosphere::GetGustNED,
605 (PMFd)&FGAtmosphere::SetGustNED);
606 PropertyManager->Tie("atmosphere/gust-east-fps", this, eEast, (PMF)&FGAtmosphere::GetGustNED,
607 (PMFd)&FGAtmosphere::SetGustNED);
608 PropertyManager->Tie("atmosphere/gust-down-fps", this, eDown, (PMF)&FGAtmosphere::GetGustNED,
609 (PMFd)&FGAtmosphere::SetGustNED);
611 PropertyManager->Tie("atmosphere/p-turb-rad_sec", this,1, (PMF)&FGAtmosphere::GetTurbPQR);
612 PropertyManager->Tie("atmosphere/q-turb-rad_sec", this,2, (PMF)&FGAtmosphere::GetTurbPQR);
613 PropertyManager->Tie("atmosphere/r-turb-rad_sec", this,3, (PMF)&FGAtmosphere::GetTurbPQR);
614 PropertyManager->Tie("atmosphere/turb-rate", this, &FGAtmosphere::GetTurbRate, &FGAtmosphere::SetTurbRate);
615 PropertyManager->Tie("atmosphere/turb-gain", this, &FGAtmosphere::GetTurbGain, &FGAtmosphere::SetTurbGain);
616 PropertyManager->Tie("atmosphere/turb-rhythmicity", this, &FGAtmosphere::GetRhythmicity,
617 &FGAtmosphere::SetRhythmicity);
620 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
621 // The bitmasked value choices are as follows:
622 // unset: In this case (the default) JSBSim would only print
623 // out the normally expected messages, essentially echoing
624 // the config files as they are read. If the environment
625 // variable is not set, debug_lvl is set to 1 internally
626 // 0: This requests JSBSim not to output any messages
628 // 1: This value explicity requests the normal JSBSim
630 // 2: This value asks for a message to be printed out when
631 // a class is instantiated
632 // 4: When this value is set, a message is displayed when a
633 // FGModel object executes its Run() method
634 // 8: When this value is set, various runtime state variables
635 // are printed out periodically
636 // 16: When set various parameters are sanity checked and
637 // a message is printed out when they go out of bounds
639 void FGAtmosphere::Debug(int from)
641 if (debug_lvl <= 0) return;
643 if (debug_lvl & 1) { // Standard console startup message output
644 if (from == 0) { // Constructor
647 if (debug_lvl & 2 ) { // Instantiation/Destruction notification
648 if (from == 0) cout << "Instantiated: FGAtmosphere" << endl;
649 if (from == 1) cout << "Destroyed: FGAtmosphere" << endl;
651 if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
653 if (debug_lvl & 8 ) { // Runtime state variables
655 if (debug_lvl & 16) { // Sanity checking
657 if (debug_lvl & 128) { // Turbulence
658 if (first_pass && from == 2) {
660 cout << "vTurbulenceNED(X), vTurbulenceNED(Y), vTurbulenceNED(Z), "
661 << "vTurbulenceGrad(X), vTurbulenceGrad(Y), vTurbulenceGrad(Z), "
662 << "vDirection(X), vDirection(Y), vDirection(Z), "
664 << "vTurbPQR(P), vTurbPQR(Q), vTurbPQR(R), " << endl;
667 cout << vTurbulenceNED << ", " << vTurbulenceGrad << ", " << vDirection << ", " << Magnitude << ", " << vTurbPQR << endl;
670 if (debug_lvl & 64) {
671 if (from == 0) { // Constructor
672 cout << IdSrc << endl;
673 cout << IdHdr << endl;
678 } // namespace JSBSim