]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/FGAtmosphere.cpp
Sync. with JSBSim CVS
[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 FGAtmosphere::FGAtmosphere(FGFDMExec* fdmex) : FGModel(fdmex)
68 {
69   Name = "FGAtmosphere";
70   lastIndex = 0;
71   h = 0.0;
72   psiw = 0.0;
73   htab[0]=0;
74   htab[1]=36089.239;
75   htab[2]=65616.798;
76   htab[3]=104986.878;
77   htab[4]=154199.475;
78   htab[5]=170603.675;
79   htab[6]=200131.234;
80   htab[7]=259186.352; //ft.
81
82   MagnitudedAccelDt = MagnitudeAccel = Magnitude = 0.0;
83   SetTurbType( ttCulp );
84   TurbGain = 0.0;
85   TurbRate = 1.7;
86   Rhythmicity = 0.1;
87   spike = target_time = strength = 0.0;
88   wind_from_clockwise = 0.0;
89
90   T_dev_sl = T_dev = delta_T = 0.0;
91   StandardTempOnly = false;
92   first_pass = true;
93   vGustNED.InitMatrix();
94   vTurbulenceNED.InitMatrix();
95
96   bind();
97   Debug(0);
98 }
99
100 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
101
102 FGAtmosphere::~FGAtmosphere()
103 {
104   Debug(1);
105 }
106
107 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
108
109 bool FGAtmosphere::InitModel(void)
110 {
111   if (!FGModel::InitModel()) return false;
112
113   UseInternal();  // this is the default
114
115   Calculate(h);
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;
124
125   return true;
126 }
127
128 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
129
130 bool FGAtmosphere::Run(void)
131 {
132   if (FGModel::Run()) return true;
133   if (FDMExec->Holding()) return false;
134
135   T_dev = 0.0;
136   h = Propagate->Geth();
137
138   if (!useExternal) {
139     Calculate(h);
140     CalculateDerived();
141   } else {
142     CalculateDerived();
143   }
144
145   Debug(2);
146   return false;
147 }
148
149 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
150 //
151 // See reference 1
152
153 void FGAtmosphere::Calculate(double altitude)
154 {
155   double slope, reftemp, refpress;
156   int i = lastIndex;
157
158   if (altitude < htab[lastIndex]) {
159     if (altitude <= 0) {
160       i = 0;
161       altitude=0;
162     } else {
163        i = lastIndex-1;
164        while (htab[i] > altitude) i--;
165     }
166   } else if (altitude > htab[lastIndex+1]) {
167     if (altitude >= htab[7]) {
168       i = 7;
169       altitude = htab[7];
170     } else {
171       i = lastIndex+1;
172       while (htab[i+1] < altitude) i++;
173     }
174   }
175
176   switch(i) {
177   case 1:     // 36089 ft.
178     slope     = 0;
179     reftemp   = 389.97;
180     refpress  = 472.452;
181     //refdens   = 0.000706032;
182     break;
183   case 2:     // 65616 ft.
184     slope     = 0.00054864;
185     reftemp   = 389.97;
186     refpress  = 114.636;
187     //refdens   = 0.000171306;
188     break;
189   case 3:     // 104986 ft.
190     slope     = 0.00153619;
191     reftemp   = 411.57;
192     refpress  = 8.36364;
193     //refdens   = 1.18422e-05;
194     break;
195   case 4:     // 154199 ft.
196     slope     = 0;
197     reftemp   = 487.17;
198     refpress  = 0.334882;
199     //refdens   = 4.00585e-7;
200     break;
201   case 5:     // 170603 ft.
202     slope     = -0.00109728;
203     reftemp   = 487.17;
204     refpress  = 0.683084;
205     //refdens   = 8.17102e-7;
206     break;
207   case 6:     // 200131 ft.
208     slope     = -0.00219456;
209     reftemp   = 454.17;
210     refpress  = 0.00684986;
211     //refdens   = 8.77702e-9;
212     break;
213   case 7:     // 259186 ft.
214     slope     = 0;
215     reftemp   = 325.17;
216     refpress  = 0.000122276;
217     //refdens   = 2.19541e-10;
218     break;
219   case 0:
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.
225     break;
226
227   }
228
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).
231
232   if(!StandardTempOnly) {
233     T_dev = 0.0;
234     if (delta_T != 0.0) {
235       T_dev = delta_T;
236     } else {
237       if ((altitude < 36089.239) && (T_dev_sl != 0.0)) {
238         T_dev = T_dev_sl * ( 1.0 - (altitude/36089.239));
239       }
240     }
241     reftemp+=T_dev;
242   }
243
244   if (slope == 0) {
245     intTemperature = reftemp;
246     intPressure = refpress*exp(-Inertial->SLgravity()/(reftemp*Reng)*(altitude-htab[i]));
247     intDensity = intPressure/(Reng*intTemperature);
248   } else {
249     intTemperature = reftemp+slope*(altitude-htab[i]);
250     intPressure = refpress*pow(intTemperature/reftemp,-Inertial->SLgravity()/(slope*Reng));
251     intDensity = intPressure/(Reng*intTemperature);
252   }
253
254   lastIndex=i;
255 }
256
257 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
258 // Calculate parameters derived from T, P and rho
259 // Sum gust and turbulence values in NED frame into the wind vector.
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) Turbulence();
267
268   vTotalWindNED = vWindNED + vGustNED + vTurbulenceNED;
269
270   if (vWindNED(eX) != 0.0) psiw = atan2( vWindNED(eY), vWindNED(eX) );
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::SetWindspeed(double speed)
331 {
332   if (vWindNED.Magnitude() == 0.0) {
333     psiw = 0.0;
334     vWindNED(eNorth) = speed;
335   } else {
336     vWindNED(eNorth) = speed * cos(psiw);
337     vWindNED(eEast) = speed * sin(psiw);
338     vWindNED(eDown) = 0.0;
339   }
340 }
341
342 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
343
344 double FGAtmosphere::GetWindspeed(void) const
345 {
346   return vWindNED.Magnitude();
347 }
348
349 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
350
351 void FGAtmosphere::SetWindPsi(double dir)
352 {
353   double mag = GetWindspeed();
354   psiw = dir;
355   SetWindspeed(mag);  
356 }
357
358 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
359
360 void FGAtmosphere::Turbulence(void)
361 {
362   switch (turbType) {
363   case ttStandard: {
364     TurbGain = TurbGain * TurbGain * 100.0;
365
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));
369
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);
378
379     vDirectiondAccelDt.Normalize();
380
381                                 // deemphasise non-vertical forces
382     vDirectiondAccelDt(eX) = square_signed(vDirectiondAccelDt(eX));
383     vDirectiondAccelDt(eY) = square_signed(vDirectiondAccelDt(eY));
384
385     vDirectionAccel += vDirectiondAccelDt*rate*TurbRate*State->Getdt();
386     vDirectionAccel.Normalize();
387     vDirection      += vDirectionAccel*rate*State->Getdt();
388
389     vDirection.Normalize();
390
391                                 // Diminish turbulence within three wingspans
392                                 // of the ground
393     vTurbulenceNED = TurbGain * Magnitude * vDirection;
394     double HOverBMAC = Auxiliary->GetHOverBMAC();
395     if (HOverBMAC < 3.0)
396         vTurbulenceNED *= (HOverBMAC / 3.0) * (HOverBMAC / 3.0);
397
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?
403
404     // Need to determine the turbulence change in body axes between two time points.
405
406     vTurbulenceGrad = TurbGain*MagnitudeAccel * vDirection;
407     vBodyTurbGrad = Propagate->GetTl2b()*vTurbulenceGrad;
408
409     if (Aircraft->GetWingSpan() > 0) {
410       vTurbPQR(eP) = vBodyTurbGrad(eY)/Aircraft->GetWingSpan();
411     } else {
412       vTurbPQR(eP) = vBodyTurbGrad(eY)/30.0;
413     }
414 //     if (Aircraft->GetHTailArm() != 0.0)
415 //       vTurbPQR(eQ) = vBodyTurbGrad(eZ)/Aircraft->GetHTailArm();
416 //     else
417 //       vTurbPQR(eQ) = vBodyTurbGrad(eZ)/10.0;
418
419     if (Aircraft->GetVTailArm() > 0)
420       vTurbPQR(eR) = vBodyTurbGrad(eX)/Aircraft->GetVTailArm();
421     else
422       vTurbPQR(eR) = vBodyTurbGrad(eX)/10.0;
423
424                                 // Clear the horizontal forces
425                                 // actually felt by the plane, now
426                                 // that we've used them to calculate
427                                 // moments.
428                                 // Why? (JSB)
429 //    vTurbulenceNED(eX) = 0.0;
430 //    vTurbulenceNED(eY) = 0.0;
431
432     break;
433   }
434   case ttBerndt: { // This is very experimental and incomplete at the moment.
435
436     TurbGain = TurbGain * TurbGain * 100.0;
437   
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));
441
442
443     MagnitudedAccelDt = 1 - 2.0*(double(rand())/double(RAND_MAX)) - Magnitude;
444     MagnitudeAccel    += MagnitudedAccelDt*rate*State->Getdt();
445     Magnitude         += MagnitudeAccel*rate*State->Getdt();
446
447     vDirectiondAccelDt.Normalize();
448     vDirectionAccel += vDirectiondAccelDt*rate*State->Getdt();
449     vDirectionAccel.Normalize();
450     vDirection      += vDirectionAccel*rate*State->Getdt();
451
452                                 // Diminish z-vector within two wingspans
453                                 // of the ground
454     double HOverBMAC = Auxiliary->GetHOverBMAC();
455     if (HOverBMAC < 2.0)
456         vDirection(eZ) *= HOverBMAC / 2.0;
457
458     vDirection.Normalize();
459
460     vTurbulenceNED = TurbGain*Magnitude * vDirection;
461     vTurbulenceGrad = TurbGain*MagnitudeAccel * vDirection;
462
463     vBodyTurbGrad = Propagate->GetTl2b()*vTurbulenceGrad;
464     vTurbPQR(eP) = vBodyTurbGrad(eY)/Aircraft->GetWingSpan();
465     if (Aircraft->GetHTailArm() > 0)
466       vTurbPQR(eQ) = vBodyTurbGrad(eZ)/Aircraft->GetHTailArm();
467     else
468       vTurbPQR(eQ) = vBodyTurbGrad(eZ)/10.0;
469
470     if (Aircraft->GetVTailArm() > 0)
471       vTurbPQR(eR) = vBodyTurbGrad(eX)/Aircraft->GetVTailArm();
472     else
473       vTurbPQR(eR) = vBodyTurbGrad(eX)/10.0;
474
475     break;
476   }
477   case ttCulp: { 
478
479     vTurbPQR(eP) = wind_from_clockwise;
480     if (TurbGain == 0.0) return;
481   
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;
489
490     // generate a sine wave corresponding to turbulence rate in hertz
491     double time = FDMExec->GetSimTime();
492     double sinewave = sin( time * TurbRate * 6.283185307 );
493
494     double random = 0.0;
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);
498     }
499     if (time > target_time) {
500       spike = 1.0;
501       target_time = 0.0;
502     }    
503
504     // max vertical wind speed in fps, corresponds to TurbGain = 1.0
505     double max_vs = 40;
506
507     vTurbulenceNED(1) = vTurbulenceNED(2) = vTurbulenceNED(3) = 0.0;
508     double delta = strength * max_vs * TurbGain * (1-Rhythmicity) * spike;
509
510     // Vertical component of turbulence.
511     vTurbulenceNED(3) = sinewave * max_vs * TurbGain * Rhythmicity;
512     vTurbulenceNED(3)+= delta;
513     double HOverBMAC = Auxiliary->GetHOverBMAC();
514     if (HOverBMAC < 3.0)
515         vTurbulenceNED(3) *= HOverBMAC * 0.3333;
516  
517     // Yaw component of turbulence.
518     vTurbulenceNED(1) = sin( delta * 3.0 );
519     vTurbulenceNED(2) = cos( delta * 3.0 );
520
521     // Roll component of turbulence. Clockwise vortex causes left roll.
522     vTurbPQR(eP) += delta * 0.04;
523
524     spike = spike * 0.9;
525     break;
526   }
527   default:
528     break;
529   }
530 }
531
532 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
533
534 void FGAtmosphere::UseExternal(void)
535 {
536   temperature=&exTemperature;
537   pressure=&exPressure;
538   density=&exDensity;
539   useExternal=true;
540 }
541
542 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
543
544 void FGAtmosphere::UseInternal(void)
545 {
546   temperature=&intTemperature;
547   pressure=&intPressure;
548   density=&intDensity;
549   useExternal=false;
550 }
551
552 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
553
554 void FGAtmosphere::bind(void)
555 {
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);
575
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);
589
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);
596
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);
604 }
605
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
613 //       whatsoever.
614 //    1: This value explicity requests the normal JSBSim
615 //       startup messages
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
624
625 void FGAtmosphere::Debug(int from)
626 {
627   if (debug_lvl <= 0) return;
628
629   if (debug_lvl & 1) { // Standard console startup message output
630     if (from == 0) { // Constructor
631     }
632   }
633   if (debug_lvl & 2 ) { // Instantiation/Destruction notification
634     if (from == 0) cout << "Instantiated: FGAtmosphere" << endl;
635     if (from == 1) cout << "Destroyed:    FGAtmosphere" << endl;
636   }
637   if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
638   }
639   if (debug_lvl & 8 ) { // Runtime state variables
640   }
641   if (debug_lvl & 16) { // Sanity checking
642   }
643   if (debug_lvl & 128) { // Turbulence
644     if (first_pass && from == 2) {
645       first_pass = false;
646       cout << "vTurbulenceNED(X), vTurbulenceNED(Y), vTurbulenceNED(Z), "
647            << "vTurbulenceGrad(X), vTurbulenceGrad(Y), vTurbulenceGrad(Z), "
648            << "vDirection(X), vDirection(Y), vDirection(Z), "
649            << "Magnitude, "
650            << "vTurbPQR(P), vTurbPQR(Q), vTurbPQR(R), " << endl;
651     } 
652     if (from == 2) {
653       cout << vTurbulenceNED << ", " << vTurbulenceGrad << ", " << vDirection << ", " << Magnitude << ", " << vTurbPQR << endl;
654     }
655   }
656   if (debug_lvl & 64) {
657     if (from == 0) { // Constructor
658       cout << IdSrc << endl;
659       cout << IdHdr << endl;
660     }
661   }
662 }
663
664 } // namespace JSBSim