X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FFDM%2FJSBSim%2Fmodels%2FFGAtmosphere.h;h=57c6f87f8a43ef016b0597a3bce6f1fc495956e1;hb=1575fad886a0b18825363d41d53a287e8d36b9c8;hp=12e7af38fa3421c4fa88911c98765594361704a8;hpb=4dbedefb326b4c04614d904922936c074125b8f4;p=flightgear.git diff --git a/src/FDM/JSBSim/models/FGAtmosphere.h b/src/FDM/JSBSim/models/FGAtmosphere.h index 12e7af38f..57c6f87f8 100644 --- a/src/FDM/JSBSim/models/FGAtmosphere.h +++ b/src/FDM/JSBSim/models/FGAtmosphere.h @@ -2,10 +2,9 @@ Header: FGAtmosphere.h Author: Jon Berndt - Implementation of 1959 Standard Atmosphere added by Tony Peden - Date started: 11/24/98 + Date started: 6/2011 - ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) ------------- + ------------- Copyright (C) 2011 Jon S. Berndt (jon@jsbsim.org) ------------- This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software @@ -26,30 +25,27 @@ HISTORY -------------------------------------------------------------------------------- -11/24/98 JSB Created -07/23/99 TP Added implementation of 1959 Standard Atmosphere - Moved calculation of Mach number to FGPropagate - Updated to '76 model +5/2011 JSB Created %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SENTRY %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -#ifndef FGAtmosphere_H -#define FGAtmosphere_H +#ifndef FGATMOSPHERE_H +#define FGATMOSPHERE_H /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% INCLUDES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -#include "FGModel.h" -#include +#include +#include "models/FGModel.h" /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -#define ID_ATMOSPHERE "$Id$" +#define ID_ATMOSPHERE "$Id: FGAtmosphere.h,v 1.30 2012/04/13 13:18:28 jberndt Exp $" /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FORWARD DECLARATIONS @@ -61,11 +57,24 @@ namespace JSBSim { CLASS DOCUMENTATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -/** Models the standard atmosphere. - @author Tony Peden, Jon Berndt - @version $Id$ - @see Anderson, John D. "Introduction to Flight, Third Edition", McGraw-Hill, - 1989, ISBN 0-07-001641-0 +/** Models an empty, abstract base atmosphere class. + +

Properties

+ @property atmosphere/T-R The current modeled temperature in degrees Rankine. + @property atmosphere/rho-slugs_ft3 + @property atmosphere/P-psf + @property atmosphere/a-fps + @property atmosphere/T-sl-R + @property atmosphere/rho-sl-slugs_ft3 + @property atmosphere/P-sl-psf + @property atmosphere/a-sl-fps + @property atmosphere/theta + @property atmosphere/sigma + @property atmosphere/delta + @property atmosphere/a-ratio + + @author Jon Berndt + @version $Id: FGAtmosphere.h,v 1.30 2012/04/13 13:18:28 jberndt Exp $ */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -75,139 +84,158 @@ CLASS DECLARATION class FGAtmosphere : public FGModel { public: + /// Enums for specifying temperature units. + enum eTemperature {eNoTempUnit=0, eFahrenheit, eCelsius, eRankine, eKelvin}; + + /// Enums for specifying pressure units. + enum ePressure {eNoPressUnit=0, ePSF, eMillibars, ePascals, eInchesHg}; + /// Constructor FGAtmosphere(FGFDMExec*); + /// Destructor - ~FGAtmosphere(); - /** Runs the Atmosphere model; called by the Executive + virtual ~FGAtmosphere(); + + /** Runs the atmosphere forces model; called by the Executive. + Can pass in a value indicating if the executive is directing the simulation to Hold. + @param Holding if true, the executive has been directed to hold the sim from + advancing time. Some models may ignore this flag, such as the Input + model, which may need to be active to listen on a socket for the + "Resume" command to be given. @return false if no error */ - bool Run(void); + bool Run(bool Holding); + bool InitModel(void); - /// Returns the temperature in degrees Rankine. - inline double GetTemperature(void) const {return *temperature;} - /** Returns the density in slugs/ft^3. - This function may only be used if Run() is called first. */ - inline double GetDensity(void) const {return *density;} + // ************************************************************************* + /// @name Temperature access functions. + /// There are several ways to get the temperature, and several modeled temperature + /// values that can be retrieved. + // @{ + /// Returns the actual, modeled temperature at the current altitude in degrees Rankine. + /// @return Modeled temperature in degrees Rankine. + virtual double GetTemperature() const {return Temperature;} + + /// Returns the actual modeled temperature in degrees Rankine at a specified altitude. + /// @param altitude The altitude above sea level (ASL) in feet. + /// @return Modeled temperature in degrees Rankine at the specified altitude. + virtual double GetTemperature(double altitude) const = 0; + + /// Returns the actual, modeled sea level temperature in degrees Rankine. + /// @return The modeled temperature in degrees Rankine at sea level. + virtual double GetTemperatureSL() const { return GetTemperature(0.0); } + + /// Returns the ratio of the at-current-altitude temperature as modeled + /// over the sea level value. + virtual double GetTemperatureRatio() const { return GetTemperature()*rSLtemperature; } + + /// Returns the ratio of the temperature as modeled at the supplied altitude + /// over the sea level value. + virtual double GetTemperatureRatio(double h) const { return GetTemperature(h)*rSLtemperature; } + + /// Sets the Sea Level temperature. + /// @param t the temperature value in the unit provided. + /// @param unit the unit of the temperature. + virtual void SetTemperatureSL(double t, eTemperature unit=eFahrenheit); + + /// Sets the temperature at the supplied altitude. + /// @param t The temperature value in the unit provided. + /// @param h The altitude in feet above sea level. + /// @param unit The unit of the temperature. + virtual void SetTemperature(double t, double h, eTemperature unit=eFahrenheit) = 0; + //@} + + // ************************************************************************* + /// @name Pressure access functions. + //@{ /// Returns the pressure in psf. - double GetPressure(void) const {return *pressure;} - /// Returns the standard pressure at a specified altitude - double GetPressure(double altitude); - /// Returns the standard temperature at a specified altitude - inline double GetTemperature(double altitude); - /// Returns the standard density at a specified altitude - inline double GetDensity(double altitude); - /// Returns the speed of sound in ft/sec. - inline double GetSoundSpeed(void) const {return soundspeed;} + virtual double GetPressure(void) const {return Pressure;} + + /// Returns the pressure at a specified altitude in psf. + virtual double GetPressure(double altitude) const = 0; - /// Returns the sea level temperature in degrees Rankine. - inline double GetTemperatureSL(void) const { return SLtemperature; } - /// Returns the sea level density in slugs/ft^3 - inline double GetDensitySL(void) const { return SLdensity; } /// Returns the sea level pressure in psf. - inline double GetPressureSL(void) const { return SLpressure; } - /// Returns the sea level speed of sound in ft/sec. - inline double GetSoundSpeedSL(void) const { return SLsoundspeed; } + virtual double GetPressureSL(void) const { return SLpressure; } - /// Returns the ratio of at-altitude temperature over the sea level value. - inline double GetTemperatureRatio(void) const { return (*temperature)*rSLtemperature; } - /// Returns the ratio of at-altitude density over the sea level value. - inline double GetDensityRatio(void) const { return (*density)*rSLdensity; } /// Returns the ratio of at-altitude pressure over the sea level value. - inline double GetPressureRatio(void) const { return (*pressure)*rSLpressure; } + virtual double GetPressureRatio(void) const { return Pressure*rSLpressure; } + + /** Sets the sea level pressure for modeling. + @param pressure The pressure in the units specified. + @param unit the unit of measure that the specified pressure is + supplied in.*/ + virtual void SetPressureSL(ePressure unit, double pressure); + //@} + + // ************************************************************************* + /// @name Density access functions. + //@{ + /** Returns the density in slugs/ft^3. + This function may only be used if Run() is called first. */ + virtual double GetDensity(void) const {return Density;} + + /** Returns the density in slugs/ft^3 at a given altitude in ft. */ + virtual double GetDensity(double altitude) const; + + /// Returns the sea level density in slugs/ft^3 + virtual double GetDensitySL(void) const { return SLdensity; } + + /// Returns the ratio of at-altitude density over the sea level value. + virtual double GetDensityRatio(void) const { return Density*rSLdensity; } + //@} + + // ************************************************************************* + /// @name Speed of sound access functions. + //@{ + /// Returns the speed of sound in ft/sec. + virtual double GetSoundSpeed(void) const {return Soundspeed;} + + /// Returns the sea level speed of sound in ft/sec. + virtual double GetSoundSpeedSL(void) const { return SLsoundspeed; } + /// Returns the ratio of at-altitude sound speed over the sea level value. - inline double GetSoundSpeedRatio(void) const { return soundspeed*rSLsoundspeed; } - - /// Tells the simulator to use an externally calculated atmosphere model. - void UseExternal(void); - /// Tells the simulator to use the internal atmosphere model. - void UseInternal(void); //this is the default - /// Gets the boolean that tells if the external atmosphere model is being used. - bool External(void) { return useExternal; } - - /// 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 temperature deviation at sea-level in degrees Fahrenheit - inline void SetSLTempDev(double d) { T_dev_sl = d; } - /// Gets the temperature deviation at sea-level in degrees Fahrenheit - inline double GetSLTempDev(void) const { return T_dev_sl; } - /// Sets the current delta-T in degrees Fahrenheit - inline void SetDeltaT(double d) { delta_T = d; } - /// Gets the current delta-T in degrees Fahrenheit - inline double GetDeltaT(void) const { return delta_T; } - /// Gets the at-altitude temperature deviation in degrees Fahrenheit - inline double GetTempDev(void) const { return T_dev; } - /// Gets the density altitude in feet - inline double GetDensityAltitude(void) const { return density_altitude; } - - /// 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) const { return psiw; } - - inline void SetTurbGain(double tt) {TurbGain = tt;} - inline void SetTurbRate(double tt) {TurbRate = tt;} - - inline double GetTurbPQR(int idx) const {return vTurbPQR(idx);} - inline FGColumnVector3& GetTurbPQR(void) {return vTurbPQR;} - - void bind(void); - void unbind(void); + virtual double GetSoundSpeedRatio(void) const { return Soundspeed*rSLsoundspeed; } + //@} + + // ************************************************************************* + /// @name Viscosity access functions. + //@{ + /// Returns the absolute viscosity. + virtual double GetAbsoluteViscosity(void) const {return Viscosity;} + + /// Returns the kinematic viscosity. + virtual double GetKinematicViscosity(void) const {return KinematicViscosity;} + //@} + virtual double GetDensityAltitude() const {return DensityAltitude;} + + virtual double GetPressureAltitude() const {return PressureAltitude;} + + struct Inputs { + double altitudeASL; + } in; protected: - double rho; - - enum tType {ttStandard, ttBerndt, ttNone} turbType; - struct atmType {double Temperature; double Pressure; double Density;}; - - int lastIndex; - double h; - double htab[8]; - double StdSLtemperature,StdSLdensity,StdSLpressure,StdSLsoundspeed; - double rSLtemperature,rSLdensity,rSLpressure,rSLsoundspeed; //reciprocals - double SLtemperature,SLdensity,SLpressure,SLsoundspeed; - double *temperature, *density, *pressure; - double soundspeed; - bool useExternal; - double exTemperature,exDensity,exPressure; - double intTemperature, intDensity, intPressure; - double T_dev_sl, T_dev, delta_T, density_altitude; - atmType atmosphere; - bool StandardTempOnly; - bool first_pass; - - double MagnitudedAccelDt, MagnitudeAccel, Magnitude; - double TurbGain; - double TurbRate; - FGColumnVector3 vDirectiondAccelDt; - FGColumnVector3 vDirectionAccel; - FGColumnVector3 vDirection; - FGColumnVector3 vTurbulence; - FGColumnVector3 vTurbulenceGrad; - FGColumnVector3 vBodyTurbGrad; - FGColumnVector3 vTurbPQR; - - FGColumnVector3 vWindNED; - double psiw; - - /// Calculate the atmosphere for the given altitude, including effects of temperature deviation. + double SLtemperature, SLdensity, SLpressure, SLsoundspeed; // Sea level conditions + double Temperature, Density, Pressure, Soundspeed; // Current actual conditions at altitude + double rSLtemperature, rSLdensity, rSLpressure, rSLsoundspeed; // Reciprocal of sea level conditions + + double PressureAltitude; + double DensityAltitude; + + const double SutherlandConstant, Beta; + double Viscosity, KinematicViscosity; + + /// Calculate the atmosphere for the given altitude. void Calculate(double altitude); - /// Calculate atmospheric properties other than the basic T, P and rho. - void CalculateDerived(void); - /// Get T, P and rho for a standard atmosphere at the given altitude. - void GetStdAtmosphere(double altitude); - void Turbulence(void); + + // Converts to Rankine from one of several unit systems. + virtual double ConvertToRankine(double t, eTemperature unit) const; + + // Converts to PSF (pounds per square foot) from one of several unit systems. + virtual double ConvertToPSF(double t, ePressure unit=ePSF) const; + + virtual void bind(void); void Debug(int from); };