]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGAtmosphere.h
First steps in a weather reorganization. Note especially that
[flightgear.git] / src / FDM / JSBSim / FGAtmosphere.h
index 964c0a5ddf27b4b52fe09300dbb995b3e15f2847..f88031280a756218e9a828e598e1dd373776d5fd 100644 (file)
@@ -43,76 +43,142 @@ INCLUDES
 *******************************************************************************/
 
 #include "FGModel.h"
-#include "FGMatrix.h"
+#include "FGMatrix33.h"
+#include "FGColumnVector3.h"
+#include "FGColumnVector4.h"
 
-#define ID_ATMOSPHERE "$Header$"
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+DEFINITIONS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-/*******************************************************************************
-COMMENTS, REFERENCES,  and NOTES
-********************************************************************************
-[1]    Anderson, John D. "Introduction to Flight, Third Edition", McGraw-Hill,
+#define ID_ATMOSPHERE "$Id$"
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+FORWARD DECLARATIONS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+[1]   Anderson, John D. "Introduction to Flight, Third Edition", McGraw-Hill,
       1989, ISBN 0-07-001641-0
-*******************************************************************************
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+CLASS DOCUMENTATION
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+/** Models the standard atmosphere.
+    @author Tony Peden, Jon Berndt
+    @version $Id$
+*/
+
+/******************************************************************************
 CLASS DECLARATION
 *******************************************************************************/
 
 class FGAtmosphere : public FGModel {
 public:
 
+  /// Constructor
   FGAtmosphere(FGFDMExec*);
-  ~FGAtmosphere(void);
+  /// Destructor
+  ~FGAtmosphere();
+  /** Runs the Atmosphere model; called by the Executive
+      @return false if no error */
   bool Run(void);
 
-  inline float GetTemperature(void) {return temperature;}
-  inline float GetDensity(void)    {return density;}     // use only after Run() has been called
-  inline float GetPressure(void)   {return pressure;}
-  inline float GetSoundSpeed(void) {return soundspeed;}
-
-  inline float GetTemperatureSL(void) { return SLtemperature; }  //Rankine, altitude in feet
-  inline float GetDensitySL(void)     { return SLdensity; }      //slugs/ft^3
-  inline float GetPressureSL(void)    { return SLpressure; }     //lbs/ft^2
-  inline float GetSoundSpeedSL(void)  { return SLsoundspeed; }   //ft/s
-
-  inline float GetTemperatureRatio(void)  { return temperature/SLtemperature; }
-  inline float GetDensityRatio(void)     { return density/SLdensity; }
-  inline float GetPressureRatio(void)     { return pressure/SLpressure; }
-  inline float GetSoundSpeedRatio(void)   { return soundspeed/SLsoundspeed; }
-
+  bool InitModel(void);
+
+  /// Returns the temperature in degrees Rankine.
+  inline double GetTemperature(void) {return temperature;}
+  /** Returns the density in slugs/ft^3.
+      <i>This function may <b>only</b> be used if Run() is called first.</i> */
+  inline double GetDensity(void)    {return density;}
+  /// Returns the pressure in psf.
+  inline double GetPressure(void)   {return pressure;}
+  /// Returns the speed of sound in ft/sec.
+  inline double GetSoundSpeed(void) {return soundspeed;}
+
+  /// Returns the sea level temperature in degrees Rankine.
+  inline double GetTemperatureSL(void) { return SLtemperature; }
+  /// Returns the sea level density in slugs/ft^3
+  inline double GetDensitySL(void)     { return SLdensity; }
+  /// Returns the sea level pressure in psf.
+  inline double GetPressureSL(void)    { return SLpressure; }
+  /// Returns the sea level speed of sound in ft/sec.
+  inline double GetSoundSpeedSL(void)  { return SLsoundspeed; }
+
+  /// Returns the ratio of at-altitude temperature over the sea level value.
+  inline double GetTemperatureRatio(void)  { return temperature*rSLtemperature; }
+  /// Returns the ratio of at-altitude density over the sea level value.
+  inline double GetDensityRatio(void)    { return density*rSLdensity; }
+  /// Returns the ratio of at-altitude pressure over the sea level value.
+  inline double GetPressureRatio(void)     { return pressure*rSLpressure; }
+  /// Returns the ratio of at-altitude sound speed over the sea level value.
+  inline double GetSoundSpeedRatio(void)   { return soundspeed*rSLsoundspeed; }
+
+  /// Tells the simulator to use an externally calculated atmosphere model.
   inline void UseExternal(void)          { useExternal=true;  }
+  /// Tells the simulator to use the internal atmosphere model.
   inline void UseInternal(void)          { useExternal=false; } //this is the default
+  /// Gets the boolean that tells if the external atmosphere model is being used.
   bool External(void) { return useExternal; }
 
-  inline void SetExTemperature(float t)  { exTemperature=t; }
-  inline void SetExDensity(float d)      { exDensity=d; }
-  inline void SetExPressure(float p)     { exPressure=p; }
-
-  inline void SetWindNED(float wN, float wE, float wD) { vWindNED(1)=wN; vWindNED(2)=wE; vWindNED(3)=wD;}
-
-  inline float GetWindN(void) { return vWindNED(1); }
-  inline float GetWindE(void) { return vWindNED(2); }
-  inline float GetWindD(void) { return vWindNED(3); }
-
-  inline FGColumnVector GetWindUVW(void) { return vWindUVW; }
-
-protected:
-
+  /// Provides the external atmosphere model with an interface to set the temperature.
+  inline void SetExTemperature(double t)  { exTemperature=t; }
+  /// Provides the external atmosphere model with an interface to set the density.
+  inline void SetExDensity(double d)      { exDensity=d; }
+  /// Provides the external atmosphere model with an interface to set the pressure.
+  inline void SetExPressure(double p)     { exPressure=p; }
+
+  /// Sets the wind components in NED frame.
+  inline void SetWindNED(double wN, double wE, double wD) { vWindNED(1)=wN; vWindNED(2)=wE; vWindNED(3)=wD;}
+
+  /// Retrieves the wind components in NED frame.
+  inline FGColumnVector3& GetWindNED(void) { return vWindNED; }
+  
+  /** Retrieves the wind direction. The direction is defined as north=0 and
+      increases counterclockwise. The wind heading is returned in radians.*/
+  inline double GetWindPsi(void) { return psiw; }
+  
+  inline void SetTurbGain(double tt) {TurbGain = tt;}
+  
+  inline double GetTurbPQR(int idx) {return vTurbPQR(idx);}
+  inline FGColumnVector3& GetTurbPQR(void) {return vTurbPQR;}
+  
 private:
-  float rho;
+  double rho;
 
-  float h;
-  float SLtemperature,SLdensity,SLpressure,SLsoundspeed;
-  float temperature,density,pressure,soundspeed;
-  bool useExternal;
-  float exTemperature,exDensity,exPressure;
-  FGColumnVector vWindNED,vWindUVW;
-
-  void Calculate(float altitude);
+  enum tType {ttBerndt, ttNone} turbType;
 
+  int lastIndex;
+  double h;
+  double htab[8];
+  double SLtemperature,SLdensity,SLpressure,SLsoundspeed;
+  double rSLtemperature,rSLdensity,rSLpressure,rSLsoundspeed; //reciprocals
+  double temperature,density,pressure,soundspeed;
+  bool useExternal;
+  double exTemperature,exDensity,exPressure;
+  
+  double MagnitudedAccelDt, MagnitudeAccel, Magnitude;
+  double TurbGain;
+  FGColumnVector3 vDirectiondAccelDt;
+  FGColumnVector3 vDirectionAccel;
+  FGColumnVector3 vDirection;
+  FGColumnVector3 vTurbulence;
+  FGColumnVector3 vTurbulenceGrad;
+  FGColumnVector3 vBodyTurbGrad;
+  FGColumnVector3 vTurbPQR;
+
+  FGColumnVector3 vWindNED;
+  double psiw;
+
+  void Calculate(double altitude);
+  void Turbulence(void);
+  void Debug(int from);
 };
 
-
-
 /******************************************************************************/
 #endif
+