]> git.mxchange.org Git - flightgear.git/blobdiff - src/WeatherCM/FGWeatherUtils.h
Erik Hofman:
[flightgear.git] / src / WeatherCM / FGWeatherUtils.h
index cf25b988dfb6a77af9250b8055ac3fdfd8988ca1..505fcdc58cc81103daa0d03449cdab997444a683 100644 (file)
@@ -39,6 +39,8 @@ HISTORY
                                and lots of wee code cleaning
 17.01.2000 Christian Mayer     Added conversion routines make it easier for
                                JSBsim to use the weather database.
                                and lots of wee code cleaning
 17.01.2000 Christian Mayer     Added conversion routines make it easier for
                                JSBsim to use the weather database.
+18.05.2000 Christian Mayer      Added function for geting the density when
+                                temperature and pressure are given
 *****************************************************************************/
 
 /****************************************************************************/
 *****************************************************************************/
 
 /****************************************************************************/
@@ -71,7 +73,7 @@ HISTORY
 /* dp:     dew point in °C                                                 */
 /* wb:     approximate wetbulp in °C                                       */
 /*                                                                         */
 /* dp:     dew point in °C                                                 */
 /* wb:     approximate wetbulp in °C                                       */
 /*                                                                         */
-/* NOTE: Pascal is the SI unit for preasure and is defined as Pa = N/m^2    */
+/* NOTE: Pascal is the SI unit for pressure and is defined as Pa = N/m^2    */
 /*       1 mbar = 1 hPa = 100 Pa                                           */
 /* NOTE: °C isn't a SI unit, so I should use °K instead. But as all        */
 /*       formulas are given in °C and the weather database only uses       */
 /*       1 mbar = 1 hPa = 100 Pa                                           */
 /* NOTE: °C isn't a SI unit, so I should use °K instead. But as all        */
 /*       formulas are given in °C and the weather database only uses       */
@@ -141,24 +143,32 @@ inline WeatherPrecision wb(const WeatherPrecision t, const WeatherPrecision p, c
 
 }
 
 
 }
 
+// Assume that we've got an ideal gas in normal altitudes
+inline WeatherPrecision Density(const WeatherPrecision AirPressure, const WeatherPrecision Temperature )
+{
+    const float rho0 = 1.293; /*density for air in normal altitudes at 0°C and 1013 mbar*/
+
+    return rho0 * 273.15 * AirPressure / (101300.0 * Temperature);
+}
+
 inline WeatherPrecision Celsius                    (const WeatherPrecision celsius)
 {
 inline WeatherPrecision Celsius                    (const WeatherPrecision celsius)
 {
-    return celsius + 273.16;                           //Kelvin
+    return celsius + 273.15;                           //Kelvin
 }
 
 inline WeatherPrecision Fahrenheit         (const WeatherPrecision fahrenheit)
 {
 }
 
 inline WeatherPrecision Fahrenheit         (const WeatherPrecision fahrenheit)
 {
-    return (fahrenheit * 9.0 / 5.0) + 32.0 + 273.16;   //Kelvin
+    return (fahrenheit * 9.0 / 5.0) + 32.0 + 273.15;   //Kelvin
 }
 
 inline WeatherPrecision Kelvin2Celsius     (const WeatherPrecision kelvin)
 {
 }
 
 inline WeatherPrecision Kelvin2Celsius     (const WeatherPrecision kelvin)
 {
-    return kelvin - 273.16;                            //Celsius
+    return kelvin - 273.15;                            //Celsius
 }
 
 inline WeatherPrecision Kelvin2Fahrenheit   (const WeatherPrecision kelvin)
 {
 }
 
 inline WeatherPrecision Kelvin2Fahrenheit   (const WeatherPrecision kelvin)
 {
-    return ((kelvin - 273.16) * 9.0 / 5.0) + 32.0;     //Fahrenheit
+    return ((kelvin - 273.15) * 9.0 / 5.0) + 32.0;     //Fahrenheit
 }
 
 inline WeatherPrecision Celsius2Fahrenheit  (const WeatherPrecision celsius)
 }
 
 inline WeatherPrecision Celsius2Fahrenheit  (const WeatherPrecision celsius)
@@ -188,7 +198,7 @@ inline WeatherPrecision JSBsim2SIdensity    (const WeatherPrecision JSBsim)
 
 inline WeatherPrecision psf2Pascal         (const WeatherPrecision psf)
 {
 
 inline WeatherPrecision psf2Pascal         (const WeatherPrecision psf)
 {
-    return psf / 0.0020885434;                         //lbs / square foot (used in JSBsim)
+    return psf / 0.020885434;                          //lbs / square foot (used in JSBsim)
 }
 
 inline WeatherPrecision Kelvin2Rankine     (const WeatherPrecision kelvin)
 }
 
 inline WeatherPrecision Kelvin2Rankine     (const WeatherPrecision kelvin)
@@ -203,7 +213,7 @@ inline WeatherPrecision SIdensity2JSBsim    (const WeatherPrecision SIdensity)
 
 inline WeatherPrecision Pascal2psf         (const WeatherPrecision Pascal)
 {
 
 inline WeatherPrecision Pascal2psf         (const WeatherPrecision Pascal)
 {
-    return 0.0020885434 * Pascal;                      //lbs / square feet (used in JSBsim)
+    return 0.020885434 * Pascal;                       //lbs / square feet (used in JSBsim)
 }
 
 /****************************************************************************/
 }
 
 /****************************************************************************/