1 /*******************************************************************************
5 Implementation of 1959 Standard Atmosphere added by Tony Peden
8 ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
10 This program is free software; you can redistribute it and/or modify it under
11 the terms of the GNU General Public License as published by the Free Software
12 Foundation; either version 2 of the License, or (at your option) any later
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
20 You should have received a copy of the GNU General Public License along with
21 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22 Place - Suite 330, Boston, MA 02111-1307, USA.
24 Further information about the GNU General Public License can also be found on
25 the world wide web at http://www.gnu.org.
28 --------------------------------------------------------------------------------
30 07/23/99 TP Added implementation of 1959 Standard Atmosphere
31 Moved calculation of Mach number to FGTranslation
34 ********************************************************************************
36 *******************************************************************************/
38 #ifndef FGAtmosphere_H
39 #define FGAtmosphere_H
41 /*******************************************************************************
43 *******************************************************************************/
46 #include "FGMatrix33.h"
47 #include "FGColumnVector3.h"
48 #include "FGColumnVector4.h"
50 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
52 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
54 #define ID_ATMOSPHERE "$Id$"
56 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
58 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
60 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
61 COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
62 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
64 [1] Anderson, John D. "Introduction to Flight, Third Edition", McGraw-Hill,
65 1989, ISBN 0-07-001641-0
67 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
69 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
71 /** Models the standard atmosphere.
72 @author Tony Peden, Jon Berndt
76 /******************************************************************************
78 *******************************************************************************/
80 class FGAtmosphere : public FGModel {
84 FGAtmosphere(FGFDMExec*);
87 /** Runs the Atmosphere model; called by the Executive
88 @return false if no error */
93 /// Returns the temperature in degrees Rankine.
94 inline float GetTemperature(void) {return temperature;}
95 /** Returns the density in slugs/ft^3.
96 <i>This function may <b>only</b> be used if Run() is called first.</i> */
97 inline float GetDensity(void) {return density;}
98 /// Returns the pressure in psf.
99 inline float GetPressure(void) {return pressure;}
100 /// Returns the speed of sound in ft/sec.
101 inline float GetSoundSpeed(void) {return soundspeed;}
103 /// Returns the sea level temperature in degrees Rankine.
104 inline float GetTemperatureSL(void) { return SLtemperature; }
105 /// Returns the sea level density in slugs/ft^3
106 inline float GetDensitySL(void) { return SLdensity; }
107 /// Returns the sea level pressure in psf.
108 inline float GetPressureSL(void) { return SLpressure; }
109 /// Returns the sea level speed of sound in ft/sec.
110 inline float GetSoundSpeedSL(void) { return SLsoundspeed; }
112 /// Returns the ratio of at-altitude temperature over the sea level value.
113 inline float GetTemperatureRatio(void) { return temperature*rSLtemperature; }
114 /// Returns the ratio of at-altitude density over the sea level value.
115 inline float GetDensityRatio(void) { return density*rSLdensity; }
116 /// Returns the ratio of at-altitude pressure over the sea level value.
117 inline float GetPressureRatio(void) { return pressure*rSLpressure; }
118 /// Returns the ratio of at-altitude sound speed over the sea level value.
119 inline float GetSoundSpeedRatio(void) { return soundspeed*rSLsoundspeed; }
121 /// Tells the simulator to use an externally calculated atmosphere model.
122 inline void UseExternal(void) { useExternal=true; }
123 /// Tells the simulator to use the internal atmosphere model.
124 inline void UseInternal(void) { useExternal=false; } //this is the default
125 /// Gets the boolean that tells if the external atmosphere model is being used.
126 bool External(void) { return useExternal; }
128 /// Provides the external atmosphere model with an interface to set the temperature.
129 inline void SetExTemperature(float t) { exTemperature=t; }
130 /// Provides the external atmosphere model with an interface to set the density.
131 inline void SetExDensity(float d) { exDensity=d; }
132 /// Provides the external atmosphere model with an interface to set the pressure.
133 inline void SetExPressure(float p) { exPressure=p; }
135 /// Sets the wind components in NED frame.
136 inline void SetWindNED(float wN, float wE, float wD) { vWindNED(1)=wN; vWindNED(2)=wE; vWindNED(3)=wD;}
138 /// Retrieves the wind components in NED frame.
139 inline FGColumnVector3& GetWindNED(void) { return vWindNED; }
141 /** Retrieves the wind direction. The direction is defined as north=0 and
142 increases counterclockwise. The wind heading is returned in radians.*/
143 inline float GetWindPsi(void) { return psiw; }
151 double SLtemperature,SLdensity,SLpressure,SLsoundspeed;
152 double rSLtemperature,rSLdensity,rSLpressure,rSLsoundspeed; //reciprocals
153 double temperature,density,pressure,soundspeed;
155 double exTemperature,exDensity,exPressure;
157 FGColumnVector3 vWindNED;
160 void Calculate(float altitude);
164 /******************************************************************************/