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]=259186.352; //ft.
82 MagnitudedAccelDt = MagnitudeAccel = Magnitude = 0.0;
83 SetTurbType( ttCulp );
87 spike = target_time = strength = 0.0;
88 wind_from_clockwise = 0.0;
90 T_dev_sl = T_dev = delta_T = 0.0;
91 StandardTempOnly = false;
93 vGustNED.InitMatrix();
94 vTurbulenceNED.InitMatrix();
100 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
102 FGAtmosphere::~FGAtmosphere()
107 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
109 bool FGAtmosphere::InitModel(void)
111 if (!FGModel::InitModel()) return false;
113 UseInternal(); // this is the default
116 StdSLtemperature = SLtemperature = 518.67;
117 StdSLpressure = SLpressure = 2116.22;
118 StdSLdensity = SLdensity = 0.00237767;
119 StdSLsoundspeed = SLsoundspeed = sqrt(SHRatio*Reng*StdSLtemperature);
120 rSLtemperature = 1.0/StdSLtemperature;
121 rSLpressure = 1.0/StdSLpressure;
122 rSLdensity = 1.0/StdSLdensity;
123 rSLsoundspeed = 1.0/StdSLsoundspeed;
128 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
130 bool FGAtmosphere::Run(void)
132 if (FGModel::Run()) return true;
133 if (FDMExec->Holding()) return false;
136 h = Propagate->Geth();
149 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
153 void FGAtmosphere::Calculate(double altitude)
155 double slope, reftemp, refpress;
158 if (altitude < htab[lastIndex]) {
164 while (htab[i] > altitude) i--;
166 } else if (altitude > htab[lastIndex+1]) {
167 if (altitude >= htab[7]) {
172 while (htab[i+1] < altitude) i++;
181 //refdens = 0.000706032;
187 //refdens = 0.000171306;
189 case 3: // 104986 ft.
193 //refdens = 1.18422e-05;
195 case 4: // 154199 ft.
199 //refdens = 4.00585e-7;
201 case 5: // 170603 ft.
205 //refdens = 8.17102e-7;
207 case 6: // 200131 ft.
210 refpress = 0.00684986;
211 //refdens = 8.77702e-9;
213 case 7: // 259186 ft.
216 refpress = 0.000122276;
217 //refdens = 2.19541e-10;
220 default: // sea level
221 slope = -0.00356616; // R/ft.
222 reftemp = 518.67; // R
223 refpress = 2116.22; // psf
224 //refdens = 0.00237767; // slugs/cubic ft.
229 // If delta_T is set, then that is our temperature deviation at any altitude.
230 // If not, then we'll estimate a deviation based on the sea level deviation (if set).
232 if(!StandardTempOnly) {
234 if (delta_T != 0.0) {
237 if ((altitude < 36089.239) && (T_dev_sl != 0.0)) {
238 T_dev = T_dev_sl * ( 1.0 - (altitude/36089.239));
245 intTemperature = reftemp;
246 intPressure = refpress*exp(-Inertial->SLgravity()/(reftemp*Reng)*(altitude-htab[i]));
247 intDensity = intPressure/(Reng*intTemperature);
249 intTemperature = reftemp+slope*(altitude-htab[i]);
250 intPressure = refpress*pow(intTemperature/reftemp,-Inertial->SLgravity()/(slope*Reng));
251 intDensity = intPressure/(Reng*intTemperature);
257 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
258 // Calculate parameters derived from T, P and rho
259 // Sum gust and turbulence values in NED frame into the wind vector.
261 void FGAtmosphere::CalculateDerived(void)
263 T_dev = (*temperature) - GetTemperature(h);
264 density_altitude = h + T_dev * 66.7;
266 if (turbType == ttStandard || ttCulp) Turbulence();
268 vTotalWindNED = vWindNED + vGustNED + vTurbulenceNED;
270 if (vWindNED(eX) != 0.0) psiw = atan2( vWindNED(eY), vWindNED(eX) );
271 if (psiw < 0) psiw += 2*M_PI;
273 soundspeed = sqrt(SHRatio*Reng*(*temperature));
277 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
278 // Get the standard atmospheric properties at a specified altitude
280 void FGAtmosphere::GetStdAtmosphere(double altitude) {
281 StandardTempOnly = true;
283 StandardTempOnly = false;
284 atmosphere.Temperature = intTemperature;
285 atmosphere.Pressure = intPressure;
286 atmosphere.Density = intDensity;
288 // Reset the internal atmospheric state
292 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
293 // Get the standard pressure at a specified altitude
295 double FGAtmosphere::GetPressure(double altitude) {
296 GetStdAtmosphere(altitude);
297 return atmosphere.Pressure;
300 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
301 // Get the standard temperature at a specified altitude
303 double FGAtmosphere::GetTemperature(double altitude) {
304 GetStdAtmosphere(altitude);
305 return atmosphere.Temperature;
308 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
309 // Get the standard density at a specified altitude
311 double FGAtmosphere::GetDensity(double altitude) {
312 GetStdAtmosphere(altitude);
313 return atmosphere.Density;
317 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
318 // square a value, but preserve the original sign
320 static inline double square_signed (double value)
323 return value * value * -1;
325 return value * value;
328 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
330 void FGAtmosphere::SetWindspeed(double speed)
332 if (vWindNED.Magnitude() == 0.0) {
334 vWindNED(eNorth) = speed;
336 vWindNED(eNorth) = speed * cos(psiw);
337 vWindNED(eEast) = speed * sin(psiw);
338 vWindNED(eDown) = 0.0;
342 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
344 double FGAtmosphere::GetWindspeed(void) const
346 return vWindNED.Magnitude();
349 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
351 void FGAtmosphere::SetWindPsi(double dir)
353 double mag = GetWindspeed();
358 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
360 void FGAtmosphere::Turbulence(void)
364 TurbGain = TurbGain * TurbGain * 100.0;
366 vDirectiondAccelDt(eX) = 1 - 2.0*(double(rand())/double(RAND_MAX));
367 vDirectiondAccelDt(eY) = 1 - 2.0*(double(rand())/double(RAND_MAX));
368 vDirectiondAccelDt(eZ) = 1 - 2.0*(double(rand())/double(RAND_MAX));
370 MagnitudedAccelDt = 1 - 2.0*(double(rand())/double(RAND_MAX)) - Magnitude;
371 // Scale the magnitude so that it moves
372 // away from the peaks
373 MagnitudedAccelDt = ((MagnitudedAccelDt - Magnitude) /
374 (1 + fabs(Magnitude)));
375 MagnitudeAccel += MagnitudedAccelDt*rate*TurbRate*State->Getdt();
376 Magnitude += MagnitudeAccel*rate*State->Getdt();
377 Magnitude = fabs(Magnitude);
379 vDirectiondAccelDt.Normalize();
381 // deemphasise non-vertical forces
382 vDirectiondAccelDt(eX) = square_signed(vDirectiondAccelDt(eX));
383 vDirectiondAccelDt(eY) = square_signed(vDirectiondAccelDt(eY));
385 vDirectionAccel += vDirectiondAccelDt*rate*TurbRate*State->Getdt();
386 vDirectionAccel.Normalize();
387 vDirection += vDirectionAccel*rate*State->Getdt();
389 vDirection.Normalize();
391 // Diminish turbulence within three wingspans
393 vTurbulenceNED = TurbGain * Magnitude * vDirection;
394 double HOverBMAC = Auxiliary->GetHOverBMAC();
396 vTurbulenceNED *= (HOverBMAC / 3.0) * (HOverBMAC / 3.0);
398 // I don't believe these next two statements calculate the proper gradient over
399 // the aircraft body. One reason is because this has no relationship with the
400 // orientation or velocity of the aircraft, which it must have. What is vTurbulenceGrad
401 // supposed to represent? And the direction and magnitude of the turbulence can change,
402 // so both accelerations need to be accounted for, no?
404 // Need to determine the turbulence change in body axes between two time points.
406 vTurbulenceGrad = TurbGain*MagnitudeAccel * vDirection;
407 vBodyTurbGrad = Propagate->GetTl2b()*vTurbulenceGrad;
409 if (Aircraft->GetWingSpan() > 0) {
410 vTurbPQR(eP) = vBodyTurbGrad(eY)/Aircraft->GetWingSpan();
412 vTurbPQR(eP) = vBodyTurbGrad(eY)/30.0;
414 // if (Aircraft->GetHTailArm() != 0.0)
415 // vTurbPQR(eQ) = vBodyTurbGrad(eZ)/Aircraft->GetHTailArm();
417 // vTurbPQR(eQ) = vBodyTurbGrad(eZ)/10.0;
419 if (Aircraft->GetVTailArm() > 0)
420 vTurbPQR(eR) = vBodyTurbGrad(eX)/Aircraft->GetVTailArm();
422 vTurbPQR(eR) = vBodyTurbGrad(eX)/10.0;
424 // Clear the horizontal forces
425 // actually felt by the plane, now
426 // that we've used them to calculate
429 // vTurbulenceNED(eX) = 0.0;
430 // vTurbulenceNED(eY) = 0.0;
434 case ttBerndt: { // This is very experimental and incomplete at the moment.
436 TurbGain = TurbGain * TurbGain * 100.0;
438 vDirectiondAccelDt(eX) = 1 - 2.0*(double(rand())/double(RAND_MAX));
439 vDirectiondAccelDt(eY) = 1 - 2.0*(double(rand())/double(RAND_MAX));
440 vDirectiondAccelDt(eZ) = 1 - 2.0*(double(rand())/double(RAND_MAX));
443 MagnitudedAccelDt = 1 - 2.0*(double(rand())/double(RAND_MAX)) - Magnitude;
444 MagnitudeAccel += MagnitudedAccelDt*rate*State->Getdt();
445 Magnitude += MagnitudeAccel*rate*State->Getdt();
447 vDirectiondAccelDt.Normalize();
448 vDirectionAccel += vDirectiondAccelDt*rate*State->Getdt();
449 vDirectionAccel.Normalize();
450 vDirection += vDirectionAccel*rate*State->Getdt();
452 // Diminish z-vector within two wingspans
454 double HOverBMAC = Auxiliary->GetHOverBMAC();
456 vDirection(eZ) *= HOverBMAC / 2.0;
458 vDirection.Normalize();
460 vTurbulenceNED = TurbGain*Magnitude * vDirection;
461 vTurbulenceGrad = TurbGain*MagnitudeAccel * vDirection;
463 vBodyTurbGrad = Propagate->GetTl2b()*vTurbulenceGrad;
464 vTurbPQR(eP) = vBodyTurbGrad(eY)/Aircraft->GetWingSpan();
465 if (Aircraft->GetHTailArm() > 0)
466 vTurbPQR(eQ) = vBodyTurbGrad(eZ)/Aircraft->GetHTailArm();
468 vTurbPQR(eQ) = vBodyTurbGrad(eZ)/10.0;
470 if (Aircraft->GetVTailArm() > 0)
471 vTurbPQR(eR) = vBodyTurbGrad(eX)/Aircraft->GetVTailArm();
473 vTurbPQR(eR) = vBodyTurbGrad(eX)/10.0;
479 vTurbPQR(eP) = wind_from_clockwise;
480 if (TurbGain == 0.0) return;
482 // keep the inputs within allowable limts for this model
483 if (TurbGain < 0.0) TurbGain = 0.0;
484 if (TurbGain > 1.0) TurbGain = 1.0;
485 if (TurbRate < 0.0) TurbRate = 0.0;
486 if (TurbRate > 30.0) TurbRate = 30.0;
487 if (Rhythmicity < 0.0) Rhythmicity = 0.0;
488 if (Rhythmicity > 1.0) Rhythmicity = 1.0;
490 // generate a sine wave corresponding to turbulence rate in hertz
491 double time = FDMExec->GetSimTime();
492 double sinewave = sin( time * TurbRate * 6.283185307 );
495 if (target_time == 0.0) {
496 strength = random = 1 - 2.0*(double(rand())/double(RAND_MAX));
497 target_time = time + 0.71 + (random * 0.5);
499 if (time > target_time) {
504 // max vertical wind speed in fps, corresponds to TurbGain = 1.0
507 vTurbulenceNED(1) = vTurbulenceNED(2) = vTurbulenceNED(3) = 0.0;
508 double delta = strength * max_vs * TurbGain * (1-Rhythmicity) * spike;
510 // Vertical component of turbulence.
511 vTurbulenceNED(3) = sinewave * max_vs * TurbGain * Rhythmicity;
512 vTurbulenceNED(3)+= delta;
513 double HOverBMAC = Auxiliary->GetHOverBMAC();
515 vTurbulenceNED(3) *= HOverBMAC * 0.3333;
517 // Yaw component of turbulence.
518 vTurbulenceNED(1) = sin( delta * 3.0 );
519 vTurbulenceNED(2) = cos( delta * 3.0 );
521 // Roll component of turbulence. Clockwise vortex causes left roll.
522 vTurbPQR(eP) += delta * 0.04;
532 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
534 void FGAtmosphere::UseExternal(void)
536 temperature=&exTemperature;
537 pressure=&exPressure;
542 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
544 void FGAtmosphere::UseInternal(void)
546 temperature=&intTemperature;
547 pressure=&intPressure;
552 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
554 void FGAtmosphere::bind(void)
556 typedef double (FGAtmosphere::*PMF)(int) const;
557 typedef double (FGAtmosphere::*PMFv)(void) const;
558 typedef void (FGAtmosphere::*PMFd)(int,double);
559 PropertyManager->Tie("atmosphere/T-R", this, (PMFv)&FGAtmosphere::GetTemperature);
560 PropertyManager->Tie("atmosphere/rho-slugs_ft3", this, (PMFv)&FGAtmosphere::GetDensity);
561 PropertyManager->Tie("atmosphere/P-psf", this, (PMFv)&FGAtmosphere::GetPressure);
562 PropertyManager->Tie("atmosphere/a-fps", this, &FGAtmosphere::GetSoundSpeed);
563 PropertyManager->Tie("atmosphere/T-sl-R", this, &FGAtmosphere::GetTemperatureSL);
564 PropertyManager->Tie("atmosphere/rho-sl-slugs_ft3", this, &FGAtmosphere::GetDensitySL);
565 PropertyManager->Tie("atmosphere/P-sl-psf", this, &FGAtmosphere::GetPressureSL);
566 PropertyManager->Tie("atmosphere/a-sl-fps", this, &FGAtmosphere::GetSoundSpeedSL);
567 PropertyManager->Tie("atmosphere/theta", this, &FGAtmosphere::GetTemperatureRatio);
568 PropertyManager->Tie("atmosphere/sigma", this, &FGAtmosphere::GetDensityRatio);
569 PropertyManager->Tie("atmosphere/delta", this, &FGAtmosphere::GetPressureRatio);
570 PropertyManager->Tie("atmosphere/a-ratio", this, &FGAtmosphere::GetSoundSpeedRatio);
571 PropertyManager->Tie("atmosphere/psiw-rad", this, &FGAtmosphere::GetWindPsi);
572 PropertyManager->Tie("atmosphere/delta-T", this, &FGAtmosphere::GetDeltaT, &FGAtmosphere::SetDeltaT);
573 PropertyManager->Tie("atmosphere/T-sl-dev-F", this, &FGAtmosphere::GetSLTempDev, &FGAtmosphere::SetSLTempDev);
574 PropertyManager->Tie("atmosphere/density-altitude", this, &FGAtmosphere::GetDensityAltitude);
576 PropertyManager->Tie("atmosphere/wind-north-fps", this, eNorth, (PMF)&FGAtmosphere::GetWindNED,
577 (PMFd)&FGAtmosphere::SetWindNED);
578 PropertyManager->Tie("atmosphere/wind-east-fps", this, eEast, (PMF)&FGAtmosphere::GetWindNED,
579 (PMFd)&FGAtmosphere::SetWindNED);
580 PropertyManager->Tie("atmosphere/wind-down-fps", this, eDown, (PMF)&FGAtmosphere::GetWindNED,
581 (PMFd)&FGAtmosphere::SetWindNED);
582 PropertyManager->Tie("atmosphere/wind-from-cw", this, &FGAtmosphere::GetWindFromClockwise,
583 &FGAtmosphere::SetWindFromClockwise);
584 PropertyManager->Tie("atmosphere/wind-mag-fps", this, &FGAtmosphere::GetWindspeed,
585 &FGAtmosphere::SetWindspeed);
586 PropertyManager->Tie("atmosphere/total-wind-north-fps", this, eNorth, (PMF)&FGAtmosphere::GetTotalWindNED);
587 PropertyManager->Tie("atmosphere/total-wind-east-fps", this, eEast, (PMF)&FGAtmosphere::GetTotalWindNED);
588 PropertyManager->Tie("atmosphere/total-wind-down-fps", this, eDown, (PMF)&FGAtmosphere::GetTotalWindNED);
590 PropertyManager->Tie("atmosphere/gust-north-fps", this, eNorth, (PMF)&FGAtmosphere::GetGustNED,
591 (PMFd)&FGAtmosphere::SetGustNED);
592 PropertyManager->Tie("atmosphere/gust-east-fps", this, eEast, (PMF)&FGAtmosphere::GetGustNED,
593 (PMFd)&FGAtmosphere::SetGustNED);
594 PropertyManager->Tie("atmosphere/gust-down-fps", this, eDown, (PMF)&FGAtmosphere::GetGustNED,
595 (PMFd)&FGAtmosphere::SetGustNED);
597 PropertyManager->Tie("atmosphere/p-turb-rad_sec", this,1, (PMF)&FGAtmosphere::GetTurbPQR);
598 PropertyManager->Tie("atmosphere/q-turb-rad_sec", this,2, (PMF)&FGAtmosphere::GetTurbPQR);
599 PropertyManager->Tie("atmosphere/r-turb-rad_sec", this,3, (PMF)&FGAtmosphere::GetTurbPQR);
600 PropertyManager->Tie("atmosphere/turb-rate", this, &FGAtmosphere::GetTurbRate, &FGAtmosphere::SetTurbRate);
601 PropertyManager->Tie("atmosphere/turb-gain", this, &FGAtmosphere::GetTurbGain, &FGAtmosphere::SetTurbGain);
602 PropertyManager->Tie("atmosphere/turb-rhythmicity", this, &FGAtmosphere::GetRhythmicity,
603 &FGAtmosphere::SetRhythmicity);
606 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
607 // The bitmasked value choices are as follows:
608 // unset: In this case (the default) JSBSim would only print
609 // out the normally expected messages, essentially echoing
610 // the config files as they are read. If the environment
611 // variable is not set, debug_lvl is set to 1 internally
612 // 0: This requests JSBSim not to output any messages
614 // 1: This value explicity requests the normal JSBSim
616 // 2: This value asks for a message to be printed out when
617 // a class is instantiated
618 // 4: When this value is set, a message is displayed when a
619 // FGModel object executes its Run() method
620 // 8: When this value is set, various runtime state variables
621 // are printed out periodically
622 // 16: When set various parameters are sanity checked and
623 // a message is printed out when they go out of bounds
625 void FGAtmosphere::Debug(int from)
627 if (debug_lvl <= 0) return;
629 if (debug_lvl & 1) { // Standard console startup message output
630 if (from == 0) { // Constructor
633 if (debug_lvl & 2 ) { // Instantiation/Destruction notification
634 if (from == 0) cout << "Instantiated: FGAtmosphere" << endl;
635 if (from == 1) cout << "Destroyed: FGAtmosphere" << endl;
637 if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
639 if (debug_lvl & 8 ) { // Runtime state variables
641 if (debug_lvl & 16) { // Sanity checking
643 if (debug_lvl & 128) { // Turbulence
644 if (first_pass && from == 2) {
646 cout << "vTurbulenceNED(X), vTurbulenceNED(Y), vTurbulenceNED(Z), "
647 << "vTurbulenceGrad(X), vTurbulenceGrad(Y), vTurbulenceGrad(Z), "
648 << "vDirection(X), vDirection(Y), vDirection(Z), "
650 << "vTurbPQR(P), vTurbPQR(Q), vTurbPQR(R), " << endl;
653 cout << vTurbulenceNED << ", " << vTurbulenceGrad << ", " << vDirection << ", " << Magnitude << ", " << vTurbPQR << endl;
656 if (debug_lvl & 64) {
657 if (from == 0) { // Constructor
658 cout << IdSrc << endl;
659 cout << IdHdr << endl;
664 } // namespace JSBSim