Line data Source code
1 : #include "AP_Baro.h" 2 : 3 : #include <AP_HAL/AP_HAL.h> 4 : #include <AP_Math/definitions.h> 5 : 6 : extern const AP_HAL::HAL& hal; 7 : 8 : // ========================================================================== 9 : // based on tables.cpp from http://www.pdas.com/atmosdownload.html 10 : 11 1117401 : void AP_Baro::SimpleUnderWaterAtmosphere( 12 : float alt, // depth, km. 13 : float& rho, // density/sea-level 14 : float& delta, // pressure/sea-level standard pressure 15 : float& theta) // temperature/sea-level standard temperature 16 : { 17 : // Values and equations based on: 18 : // https://en.wikipedia.org/wiki/Standard_sea_level 19 1117401 : const float seaDensity = 1.024f; // g/cm3 20 1117401 : const float maxSeaDensity = 1.028f; // g/cm3 21 1117401 : const float pAC = maxSeaDensity - seaDensity; // pycnocline angular coefficient 22 : 23 : // From: https://www.windows2universe.org/earth/Water/density.html 24 1117401 : rho = seaDensity; 25 1117401 : if (alt < 1.0f) { 26 : // inside pycnocline 27 1117401 : rho += pAC*alt; 28 : } else { 29 0 : rho += pAC; 30 : } 31 1117401 : rho = rho/seaDensity; 32 : 33 : // From: https://www.grc.nasa.gov/www/k-12/WindTunnel/Activities/fluid_pressure.html 34 : // \f$P = \rho (kg) \cdot gravity (m/s2) \cdot depth (m)\f$ 35 : // \f$P_{atmosphere} = 101.325 kPa\f$ 36 : // \f$P_{total} = P_{atmosphere} + P_{fluid}\f$ 37 1117401 : delta = (SSL_AIR_PRESSURE + (seaDensity * 1e3) * GRAVITY_MSS * (alt * 1e3)) / SSL_AIR_PRESSURE; 38 : 39 : // From: http://residualanalysis.blogspot.com.br/2010/02/temperature-of-ocean-water-at-given.html 40 : // \f$T(D)\f$ Temperature underwater at given temperature 41 : // \f$S\f$ Surface temperature at the surface 42 : // \f$T(D)\approx\frac{S}{1.8 \cdot 10^{-4} \cdot S \cdot T + 1}\f$ 43 1117401 : const float seaTempSurface = KELVIN_TO_C(SSL_AIR_TEMPERATURE); // Celsius 44 1117401 : const float S = seaTempSurface * 0.338f; 45 1117401 : theta = 1.0f / ((1.8e-4f) * S * (alt * 1e3f) + 1.0f); 46 1117401 : }