]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/FGAtmosphere.cpp
95afb809274b0fef8548ba8d241eee7f23960de2
[flightgear.git] / src / FDM / JSBSim / models / FGAtmosphere.cpp
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3  Module:       FGAtmosphere.cpp
4  Author:       Jon Berndt
5                Implementation of 1959 Standard Atmosphere added by Tony Peden
6  Date started: 11/24/98
7  Purpose:      Models the atmosphere
8  Called by:    FGSimExec
9
10  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
11
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
15  version.
16
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
20  details.
21
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.
25
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.
28
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.
33
34 HISTORY
35 --------------------------------------------------------------------------------
36 11/24/98   JSB   Created
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
45
46 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
47 INCLUDES
48 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
49
50 #include "FGAtmosphere.h"
51 #include <FGState.h>
52 #include <FGFDMExec.h>
53 #include "FGAircraft.h"
54 #include "FGPropagate.h"
55 #include "FGInertial.h"
56 #include <input_output/FGPropertyManager.h>
57
58 namespace JSBSim {
59
60 static const char *IdSrc = "$Id$";
61 static const char *IdHdr = ID_ATMOSPHERE;
62
63 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
64 CLASS IMPLEMENTATION
65 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
66
67
68 FGAtmosphere::FGAtmosphere(FGFDMExec* fdmex) : FGModel(fdmex)
69 {
70   Name = "FGAtmosphere";
71   lastIndex = 0;
72   h = 0.0;
73   psiw = 0.0;
74   htab[0]=0;
75   htab[1]=36089.239;
76   htab[2]=65616.798;
77   htab[3]=104986.878;
78   htab[4]=154199.475;
79   htab[5]=170603.675;
80   htab[6]=200131.234;
81   htab[7]=259186.352; //ft.
82
83   MagnitudedAccelDt = MagnitudeAccel = Magnitude = 0.0;
84   SetTurbType( ttCulp );
85   TurbGain = 0.0;
86   TurbRate = 1.7;
87   Rhythmicity = 0.1;
88   spike = target_time = strength = 0.0;
89   wind_from_clockwise = 0.0;
90
91   T_dev_sl = T_dev = delta_T = 0.0;
92   StandardTempOnly = false;
93   first_pass = true;
94   vGustNED(1) = vGustNED(2) = vGustNED(3) = 0.0; bgustSet = false;
95   vTurbulence(1) = vTurbulence(2) = vTurbulence(3) = 0.0;
96
97   bind();
98   Debug(0);
99 }
100
101 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
102
103 FGAtmosphere::~FGAtmosphere()
104 {
105   Debug(1);
106 }
107
108 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
109
110 bool FGAtmosphere::InitModel(void)
111 {
112   if (!FGModel::InitModel()) return false;
113
114   UseInternal();  // this is the default
115
116   Calculate(h);
117   StdSLtemperature = SLtemperature = 518.67;
118   StdSLpressure    = SLpressure = 2116.22;
119   StdSLdensity     = SLdensity = 0.00237767;
120   StdSLsoundspeed  = SLsoundspeed = sqrt(SHRatio*Reng*StdSLtemperature);
121   rSLtemperature = 1.0/StdSLtemperature;
122   rSLpressure    = 1.0/StdSLpressure;
123   rSLdensity     = 1.0/StdSLdensity;
124   rSLsoundspeed  = 1.0/StdSLsoundspeed;
125
126   return true;
127 }
128
129 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
130
131 bool FGAtmosphere::Run(void)
132 {
133   if (FGModel::Run()) return true;
134   if (FDMExec->Holding()) return false;
135
136   T_dev = 0.0;
137   h = Propagate->Geth();
138
139   if (!useExternal) {
140     Calculate(h);
141     CalculateDerived();
142   } else {
143     CalculateDerived();
144   }
145
146   Debug(2);
147   return false;
148 }
149
150 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
151 //
152 // See reference 1
153
154 void FGAtmosphere::Calculate(double altitude)
155 {
156   double slope, reftemp, refpress;
157   int i = lastIndex;
158
159   if (altitude < htab[lastIndex]) {
160     if (altitude <= 0) {
161       i = 0;
162       altitude=0;
163     } else {
164        i = lastIndex-1;
165        while (htab[i] > altitude) i--;
166     }
167   } else if (altitude > htab[lastIndex+1]) {
168     if (altitude >= htab[7]) {
169       i = 7;
170       altitude = htab[7];
171     } else {
172       i = lastIndex+1;
173       while (htab[i+1] < altitude) i++;
174     }
175   }
176
177   switch(i) {
178   case 1:     // 36089 ft.
179     slope     = 0;
180     reftemp   = 389.97;
181     refpress  = 472.452;
182     //refdens   = 0.000706032;
183     break;
184   case 2:     // 65616 ft.
185     slope     = 0.00054864;
186     reftemp   = 389.97;
187     refpress  = 114.636;
188     //refdens   = 0.000171306;
189     break;
190   case 3:     // 104986 ft.
191     slope     = 0.00153619;
192     reftemp   = 411.57;
193     refpress  = 8.36364;
194     //refdens   = 1.18422e-05;
195     break;
196   case 4:     // 154199 ft.
197     slope     = 0;
198     reftemp   = 487.17;
199     refpress  = 0.334882;
200     //refdens   = 4.00585e-7;
201     break;
202   case 5:     // 170603 ft.
203     slope     = -0.00109728;
204     reftemp   = 487.17;
205     refpress  = 0.683084;
206     //refdens   = 8.17102e-7;
207     break;
208   case 6:     // 200131 ft.
209     slope     = -0.00219456;
210     reftemp   = 454.17;
211     refpress  = 0.00684986;
212     //refdens   = 8.77702e-9;
213     break;
214   case 7:     // 259186 ft.
215     slope     = 0;
216     reftemp   = 325.17;
217     refpress  = 0.000122276;
218     //refdens   = 2.19541e-10;
219     break;
220   case 0:
221   default:     // sea level
222     slope     = -0.00356616; // R/ft.
223     reftemp   = 518.67;    // R
224     refpress  = 2116.22;    // psf
225     //refdens   = 0.00237767;  // slugs/cubic ft.
226     break;
227
228   }
229
230   // If delta_T is set, then that is our temperature deviation at any altitude.
231   // If not, then we'll estimate a deviation based on the sea level deviation (if set).
232
233   if(!StandardTempOnly) {
234     T_dev = 0.0;
235     if (delta_T != 0.0) {
236       T_dev = delta_T;
237     } else {
238       if ((altitude < 36089.239) && (T_dev_sl != 0.0)) {
239         T_dev = T_dev_sl * ( 1.0 - (altitude/36089.239));
240       }
241     }
242     reftemp+=T_dev;
243   }
244
245   if (slope == 0) {
246     intTemperature = reftemp;
247     intPressure = refpress*exp(-Inertial->SLgravity()/(reftemp*Reng)*(altitude-htab[i]));
248     intDensity = intPressure/(Reng*intTemperature);
249   } else {
250     intTemperature = reftemp+slope*(altitude-htab[i]);
251     intPressure = refpress*pow(intTemperature/reftemp,-Inertial->SLgravity()/(slope*Reng));
252     intDensity = intPressure/(Reng*intTemperature);
253   }
254
255   lastIndex=i;
256 }
257
258 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
259 // Calculate parameters derived from T, P and rho
260
261 void FGAtmosphere::CalculateDerived(void)
262 {
263   T_dev = (*temperature) - GetTemperature(h);
264   density_altitude = h + T_dev * 66.7;
265
266   if (turbType == ttStandard || ttCulp) {
267     Turbulence();
268     vWindNED += vGustNED + vTurbulence;
269   }
270   if (vWindNED(1) != 0.0) psiw = atan2( vWindNED(2), vWindNED(1) );
271   if (psiw < 0) psiw += 2*M_PI;
272
273   soundspeed = sqrt(SHRatio*Reng*(*temperature));
274 }
275
276
277 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
278 // Get the standard atmospheric properties at a specified altitude
279
280 void FGAtmosphere::GetStdAtmosphere(double altitude) {
281   StandardTempOnly = true;
282   Calculate(altitude);
283   StandardTempOnly = false;
284   atmosphere.Temperature = intTemperature;
285   atmosphere.Pressure = intPressure;
286   atmosphere.Density = intDensity;
287
288   // Reset the internal atmospheric state
289   Calculate(h);
290 }
291
292 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
293 // Get the standard pressure at a specified altitude
294
295 double FGAtmosphere::GetPressure(double altitude) {
296   GetStdAtmosphere(altitude);
297   return atmosphere.Pressure;
298 }
299
300 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
301 // Get the standard temperature at a specified altitude
302
303 double FGAtmosphere::GetTemperature(double altitude) {
304   GetStdAtmosphere(altitude);
305   return atmosphere.Temperature;
306 }
307
308 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
309 // Get the standard density at a specified altitude
310
311 double FGAtmosphere::GetDensity(double altitude) {
312   GetStdAtmosphere(altitude);
313   return atmosphere.Density;
314 }
315
316
317 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
318 // square a value, but preserve the original sign
319
320 static inline double square_signed (double value)
321 {
322     if (value < 0)
323         return value * value * -1;
324     else
325         return value * value;
326 }
327
328 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
329
330 void FGAtmosphere::Turbulence(void)
331 {
332   switch (turbType) {
333   case ttStandard: {
334     TurbGain = TurbGain * TurbGain * 100.0;
335
336     vDirectiondAccelDt(eX) = 1 - 2.0*(double(rand())/double(RAND_MAX));
337     vDirectiondAccelDt(eY) = 1 - 2.0*(double(rand())/double(RAND_MAX));
338     vDirectiondAccelDt(eZ) = 1 - 2.0*(double(rand())/double(RAND_MAX));
339
340     MagnitudedAccelDt = 1 - 2.0*(double(rand())/double(RAND_MAX)) - Magnitude;
341                                 // Scale the magnitude so that it moves
342                                 // away from the peaks
343     MagnitudedAccelDt = ((MagnitudedAccelDt - Magnitude) /
344                          (1 + fabs(Magnitude)));
345     MagnitudeAccel    += MagnitudedAccelDt*rate*TurbRate*State->Getdt();
346     Magnitude         += MagnitudeAccel*rate*State->Getdt();
347     Magnitude          = fabs(Magnitude);
348
349     vDirectiondAccelDt.Normalize();
350
351                                 // deemphasise non-vertical forces
352     vDirectiondAccelDt(eX) = square_signed(vDirectiondAccelDt(eX));
353     vDirectiondAccelDt(eY) = square_signed(vDirectiondAccelDt(eY));
354
355     vDirectionAccel += vDirectiondAccelDt*rate*TurbRate*State->Getdt();
356     vDirectionAccel.Normalize();
357     vDirection      += vDirectionAccel*rate*State->Getdt();
358
359     vDirection.Normalize();
360
361                                 // Diminish turbulence within three wingspans
362                                 // of the ground
363     vTurbulence = TurbGain * Magnitude * vDirection;
364     double HOverBMAC = Auxiliary->GetHOverBMAC();
365     if (HOverBMAC < 3.0)
366         vTurbulence *= (HOverBMAC / 3.0) * (HOverBMAC / 3.0);
367
368     // I don't believe these next two statements calculate the proper gradient over
369     // the aircraft body. One reason is because this has no relationship with the
370     // orientation or velocity of the aircraft, which it must have. What is vTurbulenceGrad
371     // supposed to represent? And the direction and magnitude of the turbulence can change,
372     // so both accelerations need to be accounted for, no?
373
374     // Need to determine the turbulence change in body axes between two time points.
375
376     vTurbulenceGrad = TurbGain*MagnitudeAccel * vDirection;
377     vBodyTurbGrad = Propagate->GetTl2b()*vTurbulenceGrad;
378
379     if (Aircraft->GetWingSpan() > 0) {
380       vTurbPQR(eP) = vBodyTurbGrad(eY)/Aircraft->GetWingSpan();
381     } else {
382       vTurbPQR(eP) = vBodyTurbGrad(eY)/30.0;
383     }
384 //     if (Aircraft->GetHTailArm() != 0.0)
385 //       vTurbPQR(eQ) = vBodyTurbGrad(eZ)/Aircraft->GetHTailArm();
386 //     else
387 //       vTurbPQR(eQ) = vBodyTurbGrad(eZ)/10.0;
388
389     if (Aircraft->GetVTailArm() > 0)
390       vTurbPQR(eR) = vBodyTurbGrad(eX)/Aircraft->GetVTailArm();
391     else
392       vTurbPQR(eR) = vBodyTurbGrad(eX)/10.0;
393
394                                 // Clear the horizontal forces
395                                 // actually felt by the plane, now
396                                 // that we've used them to calculate
397                                 // moments.
398                                 // Why? (JSB)
399 //    vTurbulence(eX) = 0.0;
400 //    vTurbulence(eY) = 0.0;
401
402     break;
403   }
404   case ttBerndt: { // This is very experimental and incomplete at the moment.
405
406     TurbGain = TurbGain * TurbGain * 100.0;
407   
408     vDirectiondAccelDt(eX) = 1 - 2.0*(double(rand())/double(RAND_MAX));
409     vDirectiondAccelDt(eY) = 1 - 2.0*(double(rand())/double(RAND_MAX));
410     vDirectiondAccelDt(eZ) = 1 - 2.0*(double(rand())/double(RAND_MAX));
411
412
413     MagnitudedAccelDt = 1 - 2.0*(double(rand())/double(RAND_MAX)) - Magnitude;
414     MagnitudeAccel    += MagnitudedAccelDt*rate*State->Getdt();
415     Magnitude         += MagnitudeAccel*rate*State->Getdt();
416
417     vDirectiondAccelDt.Normalize();
418     vDirectionAccel += vDirectiondAccelDt*rate*State->Getdt();
419     vDirectionAccel.Normalize();
420     vDirection      += vDirectionAccel*rate*State->Getdt();
421
422                                 // Diminish z-vector within two wingspans
423                                 // of the ground
424     double HOverBMAC = Auxiliary->GetHOverBMAC();
425     if (HOverBMAC < 2.0)
426         vDirection(eZ) *= HOverBMAC / 2.0;
427
428     vDirection.Normalize();
429
430     vTurbulence = TurbGain*Magnitude * vDirection;
431     vTurbulenceGrad = TurbGain*MagnitudeAccel * vDirection;
432
433     vBodyTurbGrad = Propagate->GetTl2b()*vTurbulenceGrad;
434     vTurbPQR(eP) = vBodyTurbGrad(eY)/Aircraft->GetWingSpan();
435     if (Aircraft->GetHTailArm() > 0)
436       vTurbPQR(eQ) = vBodyTurbGrad(eZ)/Aircraft->GetHTailArm();
437     else
438       vTurbPQR(eQ) = vBodyTurbGrad(eZ)/10.0;
439
440     if (Aircraft->GetVTailArm() > 0)
441       vTurbPQR(eR) = vBodyTurbGrad(eX)/Aircraft->GetVTailArm();
442     else
443       vTurbPQR(eR) = vBodyTurbGrad(eX)/10.0;
444
445     break;
446   }
447   case ttCulp: { 
448
449     vTurbPQR(eP) = wind_from_clockwise;
450     if (TurbGain == 0.0) return;
451   
452     // keep the inputs within allowable limts for this model
453     if (TurbGain < 0.0) TurbGain = 0.0;
454     if (TurbGain > 1.0) TurbGain = 1.0;
455     if (TurbRate < 0.0) TurbRate = 0.0;
456     if (TurbRate > 30.0) TurbRate = 30.0;
457     if (Rhythmicity < 0.0) Rhythmicity = 0.0;
458     if (Rhythmicity > 1.0) Rhythmicity = 1.0;
459
460     // generate a sine wave corresponding to turbulence rate in hertz
461     double time = FDMExec->GetSimTime();
462     double sinewave = sin( time * TurbRate * 6.283185307 );
463
464     double random = 0.0;
465     if (target_time == 0.0) {
466       strength = random = 1 - 2.0*(double(rand())/double(RAND_MAX));
467       target_time = time + 0.71 + (random * 0.5);
468     }
469     if (time > target_time) {
470       spike = 1.0;
471       target_time = 0.0;
472     }    
473
474     // max vertical wind speed in fps, corresponds to TurbGain = 1.0
475     double max_vs = 40;
476
477     vTurbulence(1) = vTurbulence(2) = vTurbulence(3) = 0.0;
478     double delta = strength * max_vs * TurbGain * (1-Rhythmicity) * spike;
479
480     // Vertical component of turbulence.
481     vTurbulence(3) = sinewave * max_vs * TurbGain * Rhythmicity;
482     vTurbulence(3)+= delta;
483     double HOverBMAC = Auxiliary->GetHOverBMAC();
484     if (HOverBMAC < 3.0)
485         vTurbulence(3) *= HOverBMAC * 0.3333;
486  
487     // Yaw component of turbulence.
488     vTurbulence(1) = sin( delta * 3.0 );
489     vTurbulence(2) = cos( delta * 3.0 );
490
491     // Roll component of turbulence. Clockwise vortex causes left roll.
492     vTurbPQR(eP) += delta * 0.04;
493
494     spike = spike * 0.9;
495     break;
496   }
497   default:
498     break;
499   }
500 }
501
502 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
503
504 void FGAtmosphere::UseExternal(void)
505 {
506   temperature=&exTemperature;
507   pressure=&exPressure;
508   density=&exDensity;
509   useExternal=true;
510 }
511
512 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
513
514 void FGAtmosphere::UseInternal(void)
515 {
516   temperature=&intTemperature;
517   pressure=&intPressure;
518   density=&intDensity;
519   useExternal=false;
520 }
521
522 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
523
524 void FGAtmosphere::bind(void)
525 {
526   typedef double (FGAtmosphere::*PMF)(int) const;
527   typedef double (FGAtmosphere::*PMFv)(void) const;
528   typedef void   (FGAtmosphere::*PMFd)(int,double);
529   PropertyManager->Tie("atmosphere/T-R", this, (PMFv)&FGAtmosphere::GetTemperature);
530   PropertyManager->Tie("atmosphere/rho-slugs_ft3", this, (PMFv)&FGAtmosphere::GetDensity);
531   PropertyManager->Tie("atmosphere/P-psf", this, (PMFv)&FGAtmosphere::GetPressure);
532   PropertyManager->Tie("atmosphere/a-fps", this, &FGAtmosphere::GetSoundSpeed);
533   PropertyManager->Tie("atmosphere/T-sl-R", this, &FGAtmosphere::GetTemperatureSL);
534   PropertyManager->Tie("atmosphere/rho-sl-slugs_ft3", this, &FGAtmosphere::GetDensitySL);
535   PropertyManager->Tie("atmosphere/P-sl-psf", this, &FGAtmosphere::GetPressureSL);
536   PropertyManager->Tie("atmosphere/a-sl-fps", this, &FGAtmosphere::GetSoundSpeedSL);
537   PropertyManager->Tie("atmosphere/theta", this, &FGAtmosphere::GetTemperatureRatio);
538   PropertyManager->Tie("atmosphere/sigma", this, &FGAtmosphere::GetDensityRatio);
539   PropertyManager->Tie("atmosphere/delta", this, &FGAtmosphere::GetPressureRatio);
540   PropertyManager->Tie("atmosphere/a-ratio", this, &FGAtmosphere::GetSoundSpeedRatio);
541   PropertyManager->Tie("atmosphere/psiw-rad", this, &FGAtmosphere::GetWindPsi);
542   PropertyManager->Tie("atmosphere/delta-T", this, &FGAtmosphere::GetDeltaT, &FGAtmosphere::SetDeltaT);
543   PropertyManager->Tie("atmosphere/T-sl-dev-F", this, &FGAtmosphere::GetSLTempDev, &FGAtmosphere::SetSLTempDev);
544   PropertyManager->Tie("atmosphere/density-altitude", this, &FGAtmosphere::GetDensityAltitude);
545   PropertyManager->Tie("atmosphere/p-turb-rad_sec", this,1, (PMF)&FGAtmosphere::GetTurbPQR);
546   PropertyManager->Tie("atmosphere/q-turb-rad_sec", this,2, (PMF)&FGAtmosphere::GetTurbPQR);
547   PropertyManager->Tie("atmosphere/r-turb-rad_sec", this,3, (PMF)&FGAtmosphere::GetTurbPQR);
548   PropertyManager->Tie("atmosphere/turb-rate", this, &FGAtmosphere::GetTurbRate, &FGAtmosphere::SetTurbRate);
549   PropertyManager->Tie("atmosphere/turb-gain", this, &FGAtmosphere::GetTurbGain, &FGAtmosphere::SetTurbGain);
550   PropertyManager->Tie("atmosphere/turb-rhythmicity", this, &FGAtmosphere::GetRhythmicity,
551                                                             &FGAtmosphere::SetRhythmicity);
552   PropertyManager->Tie("atmosphere/gust-north-fps", this,1, (PMF)&FGAtmosphere::GetGustNED,
553                                                           (PMFd)&FGAtmosphere::SetGustNED);
554   PropertyManager->Tie("atmosphere/gust-east-fps",  this,2, (PMF)&FGAtmosphere::GetGustNED,
555                                                           (PMFd)&FGAtmosphere::SetGustNED);
556   PropertyManager->Tie("atmosphere/gust-down-fps",  this,3, (PMF)&FGAtmosphere::GetGustNED,
557                                                           (PMFd)&FGAtmosphere::SetGustNED);
558   PropertyManager->Tie("atmosphere/wind-from-cw", this, &FGAtmosphere::GetWindFromClockwise,
559                                                         &FGAtmosphere::SetWindFromClockwise);
560 }
561
562 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
563 //    The bitmasked value choices are as follows:
564 //    unset: In this case (the default) JSBSim would only print
565 //       out the normally expected messages, essentially echoing
566 //       the config files as they are read. If the environment
567 //       variable is not set, debug_lvl is set to 1 internally
568 //    0: This requests JSBSim not to output any messages
569 //       whatsoever.
570 //    1: This value explicity requests the normal JSBSim
571 //       startup messages
572 //    2: This value asks for a message to be printed out when
573 //       a class is instantiated
574 //    4: When this value is set, a message is displayed when a
575 //       FGModel object executes its Run() method
576 //    8: When this value is set, various runtime state variables
577 //       are printed out periodically
578 //    16: When set various parameters are sanity checked and
579 //       a message is printed out when they go out of bounds
580
581 void FGAtmosphere::Debug(int from)
582 {
583   if (debug_lvl <= 0) return;
584
585   if (debug_lvl & 1) { // Standard console startup message output
586     if (from == 0) { // Constructor
587     }
588   }
589   if (debug_lvl & 2 ) { // Instantiation/Destruction notification
590     if (from == 0) cout << "Instantiated: FGAtmosphere" << endl;
591     if (from == 1) cout << "Destroyed:    FGAtmosphere" << endl;
592   }
593   if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
594   }
595   if (debug_lvl & 8 ) { // Runtime state variables
596   }
597   if (debug_lvl & 16) { // Sanity checking
598   }
599   if (debug_lvl & 128) { // Turbulence
600     if (first_pass && from == 2) {
601       first_pass = false;
602       cout << "vTurbulence(X), vTurbulence(Y), vTurbulence(Z), "
603            << "vTurbulenceGrad(X), vTurbulenceGrad(Y), vTurbulenceGrad(Z), "
604            << "vDirection(X), vDirection(Y), vDirection(Z), "
605            << "Magnitude, "
606            << "vTurbPQR(P), vTurbPQR(Q), vTurbPQR(R), " << endl;
607     } 
608     if (from == 2) {
609       cout << vTurbulence << ", " << vTurbulenceGrad << ", " << vDirection << ", " << Magnitude << ", " << vTurbPQR << endl;
610     }
611   }
612   if (debug_lvl & 64) {
613     if (from == 0) { // Constructor
614       cout << IdSrc << endl;
615       cout << IdHdr << endl;
616     }
617   }
618 }
619
620 } // namespace JSBSim