-
Notifications
You must be signed in to change notification settings - Fork 20
/
mean_free_path.hpp
54 lines (50 loc) · 1.4 KB
/
mean_free_path.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#pragma once
#include "units.hpp"
#include "macros.hpp"
#include "moist_air.hpp"
namespace libcloudphxx
{
namespace common
{
namespace mean_free_path
{
// eq. 6.6 in Williams and Loyalka 1991
template <typename real_t>
BOOST_GPU_ENABLED
quantity<si::length, real_t> lambda_D(
quantity<si::temperature, real_t> T // temperature
)
{
using moist_air::R_v;
using moist_air::D_0; // TODO: perhaps D as a parameter to allow it to vary with T,p?
#if !defined(__NVCC__)
using std::sqrt;
#endif
return real_t(2) * (D_0<real_t>() / si::metres_per_second) / (
real_t(sqrt(
real_t(2) * real_t((R_v<real_t>() / si::joules * si::kilograms) * T)
))
);
}
// eq. 6.33 in Williams and Loyalka 1991
template <typename real_t>
BOOST_GPU_ENABLED
quantity<si::length, real_t> lambda_K(
const quantity<si::temperature, real_t> &T, // temperature
const quantity<si::pressure, real_t> &p // pressure
)
{
using moist_air::R_d;
using moist_air::K_0;
#if !defined(__NVCC__)
using std::sqrt;
#endif
return real_t(.8) * (K_0<real_t>() * T / p / si::metres_per_second) / (
real_t(sqrt(
real_t(2) * real_t((R_d<real_t>() / si::joules * si::kilograms) * T)
))
);
}
};
};
};