Commit 662b0b2e authored by Lefebvre, Jordan's avatar Lefebvre, Jordan
Browse files

Merge branch 'us-standard-atmosphere' into 'master'

US Standard Atmosphere Temperature

See merge request !107
parents 582e91f5 ac679cea
Pipeline #144969 passed with stages
in 17 minutes and 29 seconds
......@@ -13,9 +13,6 @@ mac_gcc_testing:
- git --version
- module load cmake gcc/4.8.5 qt/5.9.1 vtk/8.1.0
- which cmake
- which python
- python --version
- python TriBITS/tribits/ci_support/clone_extra_repos.py
- mkdir build
- cd build
- cmake -DTasmanian_DIR=/opt/tasmanian/6.0 ^
......@@ -39,9 +36,6 @@ mac_llvm_testing:
- which git
- git --version
- module load cmake qt/5.9.1 vtk/8.1.0
- which python
- python --version
- python TriBITS/tribits/ci_support/clone_extra_repos.py
- mkdir build
- cd build
- which cmake
......@@ -66,9 +60,6 @@ linux_gcc_testing:
script:
- which git
- git --version
- which python
- python --version
- python TriBITS/tribits/ci_support/clone_extra_repos.py
- mkdir build
- cd build
- module load cmake qt/5.9.0 vtk/8.1.0
......@@ -94,9 +85,6 @@ linux_analysis:
script:
- which git
- git --version
- which python
- python --version
- python TriBITS/tribits/ci_support/clone_extra_repos.py
- mkdir build
- cd build
- module load cmake valgrind
......@@ -126,9 +114,6 @@ linux_openmpi_testing:
script:
- which git
- git --version
- which python
- python --version
- python TriBITS/tribits/ci_support/clone_extra_repos.py
- mkdir build_mpi
- cd build_mpi
- module load cmake openmpi/1.8.1
......
......@@ -737,20 +737,20 @@ TEST(radix, relativeHumidityDewPoint)
30.0, 35.0, 40.0, 45.0, 50.0};
testDewPoints = {0.0, 5.0, 10.0, 15.0, 20.0, 25.0,
30.0, 35.0, 40.0, 45.0, 50.0};
for (size_t i = 0; i < testDewPoints.size(); ++ i)
for (size_t i = 0; i < testDewPoints.size(); ++i)
{
EXPECT_NEAR(testDewPoints[i],
relativeHumidityToDewPoint(testHumidity, testTemperatures[i]),
toleranceDewPt);
EXPECT_NEAR(
EXPECT_NEAR(
testHumidity,
dewPointToRelativeHumidity(testDewPoints[i], testTemperatures[i]),
toleranceRH);
}
// 75% humidity
testHumidity = 75.0;
testDewPoints = {-3.9, 0.94, 5.77, 10.6, 15.43, 20.26,
testHumidity = 75.0;
testDewPoints = {-3.9, 0.94, 5.77, 10.6, 15.43, 20.26,
25.08, 29.9, 34.72, 39.53, 44.34};
for (size_t i = 0; i < testDewPoints.size(); ++i)
{
......@@ -765,7 +765,7 @@ TEST(radix, relativeHumidityDewPoint)
// 50% humidity
testHumidity = 50.0;
testDewPoints = {-9.2, -4.58, 0.04, 4.65, 9.26, 13.85,
testDewPoints = {-9.2, -4.58, 0.04, 4.65, 9.26, 13.85,
18.44, 23.02, 27.60, 32.17, 36.73};
for (size_t i = 0; i < testDewPoints.size(); ++i)
{
......@@ -778,7 +778,7 @@ TEST(radix, relativeHumidityDewPoint)
toleranceRH);
}
// 25% humidity
// 25% humidity
testHumidity = 25.0;
testDewPoints = {-17.73, -13.44, -9.16, -4.9, -0.65, 3.59,
7.82, 12.04, 16.24, 20.43, 24.6};
......@@ -793,7 +793,7 @@ TEST(radix, relativeHumidityDewPoint)
toleranceRH);
}
// 1% humidity
// 1% humidity
testHumidity = 1.0;
testDewPoints = {-50.38, -47.25, -44.14, -41.07, -38.02, -34.99,
-31.99, -29.01, -26.06, -23.14, -20.23};
......@@ -808,3 +808,32 @@ TEST(radix, relativeHumidityDewPoint)
toleranceRH);
}
}
TEST(Radix, MolecularScaleTemperature)
{
// Lmb for b=0m H=0km
//
EXPECT_NEAR(287.825f, molecularScaleTemperature(50.f), 1e-3);
EXPECT_NEAR(287.500f, molecularScaleTemperature(100.f), 1e-3);
// Lmb for b=1, H=11km
//
EXPECT_NEAR(216.650, molecularScaleTemperature(11020.f), 1e-3);
// Lmb for b=2, H=20km
//
EXPECT_NEAR(216.650f, molecularScaleTemperature(20063.f), 1e-3);
// Lmb for b=3, H=32km
//
EXPECT_NEAR(228.650f, molecularScaleTemperature(32160.f), 2e-3);
// Lmb for b=4, H=47km
//
EXPECT_NEAR(270.650f, molecularScaleTemperature(47350.f), 1e-3);
// Lmb for b=5, H=51km
//
EXPECT_NEAR(270.650f, molecularScaleTemperature(51411.f), 1e-2);
// Lmb for b=6, H=71km
//
EXPECT_NEAR(214.650f, molecularScaleTemperature(71791.5f), 3e-2);
// Lmb for b=7, H=84.5km
//
EXPECT_NEAR(187.650f, molecularScaleTemperature(85636.f), 1e-2);
}
......@@ -10,6 +10,8 @@
#include "radixcore/visibility.hh"
#include <algorithm>
#include <array>
#include <vector>
namespace radix
......@@ -80,22 +82,62 @@ hypsometricProfile(const std::vector<type> &pressure,
template <typename type>
type gravity(type z)
{
return GRAVITATIONAL_ACCELERATION *
std::pow(type(1.) + z / wgs84_minor, type(-2));
return type(GRAVITATIONAL_ACCELERATION * std::pow(1. + z / wgs84_minor, -2.));
}
template <typename type>
type geopotentialHeight(type z)
{
size_t zi = std::ceil(z);
int zi = int(std::ceil(z));
type gravity_integral = type(0);
for (size_t i = 0; i < zi; ++i)
for (int i = 0; i < zi; ++i)
{
gravity_integral += gravity(type(i));
}
return gravity_integral / type(GRAVITATIONAL_ACCELERATION);
}
/**
* @brief Calculates the molecularScaleTemperature
* @param z geometric height in meters above sea level
* @return temperature in kelvin
*/
template <typename type>
type molecularScaleTemperature(type Z)
{
// geopotential z in meters
type H = geopotentialHeight(Z);
radix_tagged_line("Z(" << Z << "), H(" << H << ")");
// 0 - 86km Lm,b (Molesculare-scale temperature gradient)
static const std::array<float, 7> Lmb{-6.5f, 0.0f, 1.0f, 2.8f,
0.f, -2.8f, -2.f};
// 0 - 86km geopotential bounds (km) for Lmb
static const std::array<float, 8> geoHeight{0.f, 11.f, 20.f, 32.f,
47.f, 51.f, 71.f, 84.852f};
float T0 = 288.15f; // sea-level temperature
// molecular scale temperature at Lmb
std::array<float, 7> Tmb{T0, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f};
size_t index = 0;
type Hkm = H / type(1000.);
for (size_t i = 1; i < geoHeight.size(); ++i)
{
if (geoHeight[i - 1] <= Hkm && Hkm < geoHeight[i])
{
index = i - 1;
break;
}
// must calculate Tmb as we accend in altitude
Tmb[i] = Tmb[i - 1] + Lmb[i - 1] * (geoHeight[i] - geoHeight[i - 1]);
radix_tagged_line("Tmb[" << i << "]=" << Tmb[i] << ", Lmb[" << i
<< "]=" << Lmb[i] << ", H=" << geoHeight[i]);
}
radix_tagged_line("Found height (" << geoHeight[index] << ") Lmb ("
<< Lmb[index] << ") ");
return Tmb[index] + Lmb[index] * (Hkm - geoHeight[index]);
}
/**
* @brief absoluteTemperature Get the temperature of an air parcel given its
* potential temperature and pressure
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment