2021-06-09 08:31:34 -03:00
|
|
|
#include "AP_Baro.h"
|
2011-10-13 11:22:03 -03:00
|
|
|
|
2015-08-11 03:28:42 -03:00
|
|
|
#include <AP_HAL/AP_HAL.h>
|
2022-10-26 07:41:33 -03:00
|
|
|
#include <AP_Math/definitions.h>
|
2014-01-05 01:36:12 -04:00
|
|
|
|
2012-10-11 14:53:21 -03:00
|
|
|
extern const AP_HAL::HAL& hal;
|
2011-10-13 11:22:03 -03:00
|
|
|
|
2013-07-20 10:00:41 -03:00
|
|
|
// ==========================================================================
|
|
|
|
// based on tables.cpp from http://www.pdas.com/atmosdownload.html
|
|
|
|
|
2018-05-07 16:23:37 -03:00
|
|
|
void AP_Baro::SimpleUnderWaterAtmosphere(
|
|
|
|
float alt, // depth, km.
|
|
|
|
float& rho, // density/sea-level
|
|
|
|
float& delta, // pressure/sea-level standard pressure
|
|
|
|
float& theta) // temperature/sea-level standard temperature
|
|
|
|
{
|
|
|
|
// Values and equations based on:
|
|
|
|
// https://en.wikipedia.org/wiki/Standard_sea_level
|
|
|
|
const float seaDensity = 1.024f; // g/cm3
|
|
|
|
const float maxSeaDensity = 1.028f; // g/cm3
|
|
|
|
const float pAC = maxSeaDensity - seaDensity; // pycnocline angular coefficient
|
|
|
|
|
|
|
|
// From: https://www.windows2universe.org/earth/Water/density.html
|
|
|
|
rho = seaDensity;
|
|
|
|
if (alt < 1.0f) {
|
|
|
|
// inside pycnocline
|
|
|
|
rho += pAC*alt;
|
|
|
|
} else {
|
|
|
|
rho += pAC;
|
|
|
|
}
|
|
|
|
rho = rho/seaDensity;
|
|
|
|
|
|
|
|
// From: https://www.grc.nasa.gov/www/k-12/WindTunnel/Activities/fluid_pressure.html
|
|
|
|
// \f$P = \rho (kg) \cdot gravity (m/s2) \cdot depth (m)\f$
|
|
|
|
// \f$P_{atmosphere} = 101.325 kPa\f$
|
|
|
|
// \f$P_{total} = P_{atmosphere} + P_{fluid}\f$
|
2018-05-10 23:27:48 -03:00
|
|
|
delta = (SSL_AIR_PRESSURE + (seaDensity * 1e3) * GRAVITY_MSS * (alt * 1e3)) / SSL_AIR_PRESSURE;
|
2018-05-07 16:23:37 -03:00
|
|
|
|
|
|
|
// From: http://residualanalysis.blogspot.com.br/2010/02/temperature-of-ocean-water-at-given.html
|
|
|
|
// \f$T(D)\f$ Temperature underwater at given temperature
|
|
|
|
// \f$S\f$ Surface temperature at the surface
|
|
|
|
// \f$T(D)\approx\frac{S}{1.8 \cdot 10^{-4} \cdot S \cdot T + 1}\f$
|
2022-01-12 08:03:24 -04:00
|
|
|
const float seaTempSurface = KELVIN_TO_C(SSL_AIR_TEMPERATURE); // Celsius
|
2018-05-07 16:23:37 -03:00
|
|
|
const float S = seaTempSurface * 0.338f;
|
2019-04-04 19:06:32 -03:00
|
|
|
theta = 1.0f / ((1.8e-4f) * S * (alt * 1e3f) + 1.0f);
|
2018-05-07 16:23:37 -03:00
|
|
|
}
|