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 (jsb@hal-pc.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 );
87 spike = target_time = strength = 0.0;
88 wind_from_clockwise = 0.0;
89 SutherlandConstant = 198.72; // deg Rankine
90 Beta = 2.269690E-08; // slug/(sec ft R^0.5)
92 T_dev_sl = T_dev = delta_T = 0.0;
93 StandardTempOnly = false;
95 vGustNED.InitMatrix();
96 vTurbulenceNED.InitMatrix();
102 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
104 FGAtmosphere::~FGAtmosphere()
109 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
111 bool FGAtmosphere::InitModel(void)
113 if (!FGModel::InitModel()) return false;
115 UseInternal(); // this is the default
118 StdSLtemperature = SLtemperature = 518.67;
119 StdSLpressure = SLpressure = 2116.22;
120 StdSLdensity = SLdensity = 0.00237767;
121 StdSLsoundspeed = SLsoundspeed = sqrt(SHRatio*Reng*StdSLtemperature);
122 rSLtemperature = 1.0/StdSLtemperature;
123 rSLpressure = 1.0/StdSLpressure;
124 rSLdensity = 1.0/StdSLdensity;
125 rSLsoundspeed = 1.0/StdSLsoundspeed;
130 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
132 bool FGAtmosphere::Run(void)
134 if (FGModel::Run()) return true;
135 if (FDMExec->Holding()) return false;
138 h = Propagate->Geth();
151 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
155 void FGAtmosphere::Calculate(double altitude)
157 double slope, reftemp, refpress;
160 if (altitude < htab[lastIndex]) {
166 while (htab[i] > altitude) i--;
168 } else if (altitude > htab[lastIndex+1]) {
169 if (altitude >= htab[7]) {
174 while (htab[i+1] < altitude) i++;
180 slope = -0.00356616; // R/ft.
181 reftemp = 518.67; // in degrees Rankine, 288.15 Kelvin
182 refpress = 2116.22; // psf
183 //refdens = 0.00237767; // slugs/cubic ft.
185 case 1: // 36089 ft. or 11 km
187 reftemp = 389.97; // in degrees Rankine, 216.65 Kelvin
189 //refdens = 0.000706032;
191 case 2: // 65616 ft. or 20 km
193 reftemp = 389.97; // in degrees Rankine, 216.65 Kelvin
195 //refdens = 0.000171306;
197 case 3: // 104986 ft. or 32 km
199 reftemp = 411.57; // in degrees Rankine, 228.65 Kelvin
201 //refdens = 1.18422e-05;
203 case 4: // 154199 ft. 47 km
205 reftemp = 487.17; // in degrees Rankine, 270.65 Kelvin
207 //refdens = 4.00585e-7;
209 case 5: // 167322 ft. or 51 km
210 slope = -0.001536192;
211 reftemp = 487.17; // in degrees Rankine, 270.65 Kelvin
213 //refdens = 8.17102e-7;
215 case 6: // 232940 ft. or 71 km
217 reftemp = 386.368; // in degrees Rankine, 214.649 Kelvin
219 //refdens = 8.77702e-9;
221 case 7: // 278385 ft. or 84.8520 km
223 reftemp = 336.5; // in degrees Rankine, 186.94 Kelvin
225 //refdens = 2.19541e-10;
227 default: // sea level
228 slope = -0.00356616; // R/ft.
229 reftemp = 518.67; // in degrees Rankine, 288.15 Kelvin
230 refpress = 2116.22; // psf
231 //refdens = 0.00237767; // slugs/cubic ft.
236 // If delta_T is set, then that is our temperature deviation at any altitude.
237 // If not, then we'll estimate a deviation based on the sea level deviation (if set).
239 if(!StandardTempOnly) {
241 if (delta_T != 0.0) {
244 if ((altitude < 36089.239) && (T_dev_sl != 0.0)) {
245 T_dev = T_dev_sl * ( 1.0 - (altitude/36089.239));
252 intTemperature = reftemp;
253 intPressure = refpress*exp(-Inertial->SLgravity()/(reftemp*Reng)*(altitude-htab[i]));
254 intDensity = intPressure/(Reng*intTemperature);
256 intTemperature = reftemp+slope*(altitude-htab[i]);
257 intPressure = refpress*pow(intTemperature/reftemp,-Inertial->SLgravity()/(slope*Reng));
258 intDensity = intPressure/(Reng*intTemperature);
264 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
265 // Calculate parameters derived from T, P and rho
266 // Sum gust and turbulence values in NED frame into the wind vector.
268 void FGAtmosphere::CalculateDerived(void)
270 T_dev = (*temperature) - GetTemperature(h);
271 density_altitude = h + T_dev * 66.7;
273 if (turbType != ttNone) Turbulence();
275 vTotalWindNED = vWindNED + vGustNED + vTurbulenceNED;
277 if (vWindNED(eX) != 0.0) psiw = atan2( vWindNED(eY), vWindNED(eX) );
278 if (psiw < 0) psiw += 2*M_PI;
280 soundspeed = sqrt(SHRatio*Reng*(*temperature));
282 intViscosity = Beta * pow(intTemperature, 1.5) / (SutherlandConstant + intTemperature);
283 intKinematicViscosity = intViscosity / intDensity;
287 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
288 // Get the standard atmospheric properties at a specified altitude
290 void FGAtmosphere::GetStdAtmosphere(double altitude) {
291 StandardTempOnly = true;
293 StandardTempOnly = false;
294 atmosphere.Temperature = intTemperature;
295 atmosphere.Pressure = intPressure;
296 atmosphere.Density = intDensity;
298 // Reset the internal atmospheric state
302 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
303 // Get the standard pressure at a specified altitude
305 double FGAtmosphere::GetPressure(double altitude) {
306 GetStdAtmosphere(altitude);
307 return atmosphere.Pressure;
310 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
311 // Get the standard temperature at a specified altitude
313 double FGAtmosphere::GetTemperature(double altitude) {
314 GetStdAtmosphere(altitude);
315 return atmosphere.Temperature;
318 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
319 // Get the standard density at a specified altitude
321 double FGAtmosphere::GetDensity(double altitude) {
322 GetStdAtmosphere(altitude);
323 return atmosphere.Density;
327 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
328 // square a value, but preserve the original sign
330 static inline double square_signed (double value)
333 return value * value * -1;
335 return value * value;
338 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
340 void FGAtmosphere::SetWindspeed(double speed)
342 if (vWindNED.Magnitude() == 0.0) {
344 vWindNED(eNorth) = speed;
346 vWindNED(eNorth) = speed * cos(psiw);
347 vWindNED(eEast) = speed * sin(psiw);
348 vWindNED(eDown) = 0.0;
352 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
354 double FGAtmosphere::GetWindspeed(void) const
356 return vWindNED.Magnitude();
359 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
361 void FGAtmosphere::SetWindPsi(double dir)
363 double mag = GetWindspeed();
368 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
370 void FGAtmosphere::Turbulence(void)
374 TurbGain = TurbGain * TurbGain * 100.0;
376 vDirectiondAccelDt(eX) = 1 - 2.0*(double(rand())/double(RAND_MAX));
377 vDirectiondAccelDt(eY) = 1 - 2.0*(double(rand())/double(RAND_MAX));
378 vDirectiondAccelDt(eZ) = 1 - 2.0*(double(rand())/double(RAND_MAX));
380 MagnitudedAccelDt = 1 - 2.0*(double(rand())/double(RAND_MAX)) - Magnitude;
381 // Scale the magnitude so that it moves
382 // away from the peaks
383 MagnitudedAccelDt = ((MagnitudedAccelDt - Magnitude) /
384 (1 + fabs(Magnitude)));
385 MagnitudeAccel += MagnitudedAccelDt*rate*TurbRate*State->Getdt();
386 Magnitude += MagnitudeAccel*rate*State->Getdt();
387 Magnitude = fabs(Magnitude);
389 vDirectiondAccelDt.Normalize();
391 // deemphasise non-vertical forces
392 vDirectiondAccelDt(eX) = square_signed(vDirectiondAccelDt(eX));
393 vDirectiondAccelDt(eY) = square_signed(vDirectiondAccelDt(eY));
395 vDirectionAccel += vDirectiondAccelDt*rate*TurbRate*State->Getdt();
396 vDirectionAccel.Normalize();
397 vDirection += vDirectionAccel*rate*State->Getdt();
399 vDirection.Normalize();
401 // Diminish turbulence within three wingspans
403 vTurbulenceNED = TurbGain * Magnitude * vDirection;
404 double HOverBMAC = Auxiliary->GetHOverBMAC();
406 vTurbulenceNED *= (HOverBMAC / 3.0) * (HOverBMAC / 3.0);
408 // I don't believe these next two statements calculate the proper gradient over
409 // the aircraft body. One reason is because this has no relationship with the
410 // orientation or velocity of the aircraft, which it must have. What is vTurbulenceGrad
411 // supposed to represent? And the direction and magnitude of the turbulence can change,
412 // so both accelerations need to be accounted for, no?
414 // Need to determine the turbulence change in body axes between two time points.
416 vTurbulenceGrad = TurbGain*MagnitudeAccel * vDirection;
417 vBodyTurbGrad = Propagate->GetTl2b()*vTurbulenceGrad;
419 if (Aircraft->GetWingSpan() > 0) {
420 vTurbPQR(eP) = vBodyTurbGrad(eY)/Aircraft->GetWingSpan();
422 vTurbPQR(eP) = vBodyTurbGrad(eY)/30.0;
424 // if (Aircraft->GetHTailArm() != 0.0)
425 // vTurbPQR(eQ) = vBodyTurbGrad(eZ)/Aircraft->GetHTailArm();
427 // vTurbPQR(eQ) = vBodyTurbGrad(eZ)/10.0;
429 if (Aircraft->GetVTailArm() > 0)
430 vTurbPQR(eR) = vBodyTurbGrad(eX)/Aircraft->GetVTailArm();
432 vTurbPQR(eR) = vBodyTurbGrad(eX)/10.0;
434 // Clear the horizontal forces
435 // actually felt by the plane, now
436 // that we've used them to calculate
439 // vTurbulenceNED(eX) = 0.0;
440 // vTurbulenceNED(eY) = 0.0;
444 case ttBerndt: { // This is very experimental and incomplete at the moment.
446 TurbGain = TurbGain * TurbGain * 100.0;
448 vDirectiondAccelDt(eX) = 1 - 2.0*(double(rand())/double(RAND_MAX));
449 vDirectiondAccelDt(eY) = 1 - 2.0*(double(rand())/double(RAND_MAX));
450 vDirectiondAccelDt(eZ) = 1 - 2.0*(double(rand())/double(RAND_MAX));
453 MagnitudedAccelDt = 1 - 2.0*(double(rand())/double(RAND_MAX)) - Magnitude;
454 MagnitudeAccel += MagnitudedAccelDt*rate*State->Getdt();
455 Magnitude += MagnitudeAccel*rate*State->Getdt();
457 vDirectiondAccelDt.Normalize();
458 vDirectionAccel += vDirectiondAccelDt*rate*State->Getdt();
459 vDirectionAccel.Normalize();
460 vDirection += vDirectionAccel*rate*State->Getdt();
462 // Diminish z-vector within two wingspans
464 double HOverBMAC = Auxiliary->GetHOverBMAC();
466 vDirection(eZ) *= HOverBMAC / 2.0;
468 vDirection.Normalize();
470 vTurbulenceNED = TurbGain*Magnitude * vDirection;
471 vTurbulenceGrad = TurbGain*MagnitudeAccel * vDirection;
473 vBodyTurbGrad = Propagate->GetTl2b()*vTurbulenceGrad;
474 vTurbPQR(eP) = vBodyTurbGrad(eY)/Aircraft->GetWingSpan();
475 if (Aircraft->GetHTailArm() > 0)
476 vTurbPQR(eQ) = vBodyTurbGrad(eZ)/Aircraft->GetHTailArm();
478 vTurbPQR(eQ) = vBodyTurbGrad(eZ)/10.0;
480 if (Aircraft->GetVTailArm() > 0)
481 vTurbPQR(eR) = vBodyTurbGrad(eX)/Aircraft->GetVTailArm();
483 vTurbPQR(eR) = vBodyTurbGrad(eX)/10.0;
489 vTurbPQR(eP) = wind_from_clockwise;
490 if (TurbGain == 0.0) return;
492 // keep the inputs within allowable limts for this model
493 if (TurbGain < 0.0) TurbGain = 0.0;
494 if (TurbGain > 1.0) TurbGain = 1.0;
495 if (TurbRate < 0.0) TurbRate = 0.0;
496 if (TurbRate > 30.0) TurbRate = 30.0;
497 if (Rhythmicity < 0.0) Rhythmicity = 0.0;
498 if (Rhythmicity > 1.0) Rhythmicity = 1.0;
500 // generate a sine wave corresponding to turbulence rate in hertz
501 double time = FDMExec->GetSimTime();
502 double sinewave = sin( time * TurbRate * 6.283185307 );
505 if (target_time == 0.0) {
506 strength = random = 1 - 2.0*(double(rand())/double(RAND_MAX));
507 target_time = time + 0.71 + (random * 0.5);
509 if (time > target_time) {
514 // max vertical wind speed in fps, corresponds to TurbGain = 1.0
517 vTurbulenceNED(1) = vTurbulenceNED(2) = vTurbulenceNED(3) = 0.0;
518 double delta = strength * max_vs * TurbGain * (1-Rhythmicity) * spike;
520 // Vertical component of turbulence.
521 vTurbulenceNED(3) = sinewave * max_vs * TurbGain * Rhythmicity;
522 vTurbulenceNED(3)+= delta;
523 double HOverBMAC = Auxiliary->GetHOverBMAC();
525 vTurbulenceNED(3) *= HOverBMAC * 0.3333;
527 // Yaw component of turbulence.
528 vTurbulenceNED(1) = sin( delta * 3.0 );
529 vTurbulenceNED(2) = cos( delta * 3.0 );
531 // Roll component of turbulence. Clockwise vortex causes left roll.
532 vTurbPQR(eP) += delta * 0.04;
542 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
544 void FGAtmosphere::UseExternal(void)
546 temperature=&exTemperature;
547 pressure=&exPressure;
552 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
554 void FGAtmosphere::UseInternal(void)
556 temperature=&intTemperature;
557 pressure=&intPressure;
562 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
564 void FGAtmosphere::bind(void)
566 typedef double (FGAtmosphere::*PMF)(int) const;
567 typedef double (FGAtmosphere::*PMFv)(void) const;
568 typedef void (FGAtmosphere::*PMFd)(int,double);
569 PropertyManager->Tie("atmosphere/T-R", this, (PMFv)&FGAtmosphere::GetTemperature);
570 PropertyManager->Tie("atmosphere/rho-slugs_ft3", this, (PMFv)&FGAtmosphere::GetDensity);
571 PropertyManager->Tie("atmosphere/P-psf", this, (PMFv)&FGAtmosphere::GetPressure);
572 PropertyManager->Tie("atmosphere/a-fps", this, &FGAtmosphere::GetSoundSpeed);
573 PropertyManager->Tie("atmosphere/T-sl-R", this, &FGAtmosphere::GetTemperatureSL);
574 PropertyManager->Tie("atmosphere/rho-sl-slugs_ft3", this, &FGAtmosphere::GetDensitySL);
575 PropertyManager->Tie("atmosphere/P-sl-psf", this, &FGAtmosphere::GetPressureSL);
576 PropertyManager->Tie("atmosphere/a-sl-fps", this, &FGAtmosphere::GetSoundSpeedSL);
577 PropertyManager->Tie("atmosphere/theta", this, &FGAtmosphere::GetTemperatureRatio);
578 PropertyManager->Tie("atmosphere/sigma", this, &FGAtmosphere::GetDensityRatio);
579 PropertyManager->Tie("atmosphere/delta", this, &FGAtmosphere::GetPressureRatio);
580 PropertyManager->Tie("atmosphere/a-ratio", this, &FGAtmosphere::GetSoundSpeedRatio);
581 PropertyManager->Tie("atmosphere/psiw-rad", this, &FGAtmosphere::GetWindPsi);
582 PropertyManager->Tie("atmosphere/delta-T", this, &FGAtmosphere::GetDeltaT, &FGAtmosphere::SetDeltaT);
583 PropertyManager->Tie("atmosphere/T-sl-dev-F", this, &FGAtmosphere::GetSLTempDev, &FGAtmosphere::SetSLTempDev);
584 PropertyManager->Tie("atmosphere/density-altitude", this, &FGAtmosphere::GetDensityAltitude);
586 PropertyManager->Tie("atmosphere/wind-north-fps", this, eNorth, (PMF)&FGAtmosphere::GetWindNED,
587 (PMFd)&FGAtmosphere::SetWindNED);
588 PropertyManager->Tie("atmosphere/wind-east-fps", this, eEast, (PMF)&FGAtmosphere::GetWindNED,
589 (PMFd)&FGAtmosphere::SetWindNED);
590 PropertyManager->Tie("atmosphere/wind-down-fps", this, eDown, (PMF)&FGAtmosphere::GetWindNED,
591 (PMFd)&FGAtmosphere::SetWindNED);
592 PropertyManager->Tie("atmosphere/wind-from-cw", this, &FGAtmosphere::GetWindFromClockwise,
593 &FGAtmosphere::SetWindFromClockwise);
594 PropertyManager->Tie("atmosphere/wind-mag-fps", this, &FGAtmosphere::GetWindspeed,
595 &FGAtmosphere::SetWindspeed);
596 PropertyManager->Tie("atmosphere/total-wind-north-fps", this, eNorth, (PMF)&FGAtmosphere::GetTotalWindNED);
597 PropertyManager->Tie("atmosphere/total-wind-east-fps", this, eEast, (PMF)&FGAtmosphere::GetTotalWindNED);
598 PropertyManager->Tie("atmosphere/total-wind-down-fps", this, eDown, (PMF)&FGAtmosphere::GetTotalWindNED);
600 PropertyManager->Tie("atmosphere/gust-north-fps", this, eNorth, (PMF)&FGAtmosphere::GetGustNED,
601 (PMFd)&FGAtmosphere::SetGustNED);
602 PropertyManager->Tie("atmosphere/gust-east-fps", this, eEast, (PMF)&FGAtmosphere::GetGustNED,
603 (PMFd)&FGAtmosphere::SetGustNED);
604 PropertyManager->Tie("atmosphere/gust-down-fps", this, eDown, (PMF)&FGAtmosphere::GetGustNED,
605 (PMFd)&FGAtmosphere::SetGustNED);
607 PropertyManager->Tie("atmosphere/p-turb-rad_sec", this,1, (PMF)&FGAtmosphere::GetTurbPQR);
608 PropertyManager->Tie("atmosphere/q-turb-rad_sec", this,2, (PMF)&FGAtmosphere::GetTurbPQR);
609 PropertyManager->Tie("atmosphere/r-turb-rad_sec", this,3, (PMF)&FGAtmosphere::GetTurbPQR);
610 PropertyManager->Tie("atmosphere/turb-rate", this, &FGAtmosphere::GetTurbRate, &FGAtmosphere::SetTurbRate);
611 PropertyManager->Tie("atmosphere/turb-gain", this, &FGAtmosphere::GetTurbGain, &FGAtmosphere::SetTurbGain);
612 PropertyManager->Tie("atmosphere/turb-rhythmicity", this, &FGAtmosphere::GetRhythmicity,
613 &FGAtmosphere::SetRhythmicity);
616 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
617 // The bitmasked value choices are as follows:
618 // unset: In this case (the default) JSBSim would only print
619 // out the normally expected messages, essentially echoing
620 // the config files as they are read. If the environment
621 // variable is not set, debug_lvl is set to 1 internally
622 // 0: This requests JSBSim not to output any messages
624 // 1: This value explicity requests the normal JSBSim
626 // 2: This value asks for a message to be printed out when
627 // a class is instantiated
628 // 4: When this value is set, a message is displayed when a
629 // FGModel object executes its Run() method
630 // 8: When this value is set, various runtime state variables
631 // are printed out periodically
632 // 16: When set various parameters are sanity checked and
633 // a message is printed out when they go out of bounds
635 void FGAtmosphere::Debug(int from)
637 if (debug_lvl <= 0) return;
639 if (debug_lvl & 1) { // Standard console startup message output
640 if (from == 0) { // Constructor
643 if (debug_lvl & 2 ) { // Instantiation/Destruction notification
644 if (from == 0) cout << "Instantiated: FGAtmosphere" << endl;
645 if (from == 1) cout << "Destroyed: FGAtmosphere" << endl;
647 if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
649 if (debug_lvl & 8 ) { // Runtime state variables
651 if (debug_lvl & 16) { // Sanity checking
653 if (debug_lvl & 128) { // Turbulence
654 if (first_pass && from == 2) {
656 cout << "vTurbulenceNED(X), vTurbulenceNED(Y), vTurbulenceNED(Z), "
657 << "vTurbulenceGrad(X), vTurbulenceGrad(Y), vTurbulenceGrad(Z), "
658 << "vDirection(X), vDirection(Y), vDirection(Z), "
660 << "vTurbPQR(P), vTurbPQR(Q), vTurbPQR(R), " << endl;
663 cout << vTurbulenceNED << ", " << vTurbulenceGrad << ", " << vDirection << ", " << Magnitude << ", " << vTurbPQR << endl;
666 if (debug_lvl & 64) {
667 if (from == 0) { // Constructor
668 cout << IdSrc << endl;
669 cout << IdHdr << endl;
674 } // namespace JSBSim