5 #ifndef ERF_Microphysics_Utils_H
6 #define ERF_Microphysics_Utils_H
10 #include <AMReX_REAL.H>
11 #include <AMReX_Array.H>
14 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
16 return std::exp(lgamma(
x));
23 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
25 amrex::Real
const a0 = 6.11147274;
26 amrex::Real
const a1 = 0.503160820;
27 amrex::Real
const a2 = 0.188439774e-1;
28 amrex::Real
const a3 = 0.420895665e-3;
29 amrex::Real
const a4 = 0.615021634e-5;
30 amrex::Real
const a5 = 0.602588177e-7;
31 amrex::Real
const a6 = 0.385852041e-9;
32 amrex::Real
const a7 = 0.146898966e-11;
33 amrex::Real
const a8 = 0.252751365e-14;
35 amrex::Real dtt = t-273.16;
36 AMREX_ALWAYS_ASSERT(dtt>-85);
42 esati = a0 + dtt*(a1+dtt*(a2+dtt*(a3+dtt*(a4+dtt*(a5+dtt*(a6+dtt*(a7+a8*dtt)))))));
48 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
50 constexpr amrex::Real svp1 = 0.6112;
51 constexpr amrex::Real svp2 = 17.67;
52 constexpr amrex::Real svp3 = 29.65;
53 constexpr amrex::Real svpt0 = 273.15;
55 amrex::Real esatw = 10.0 * svp1 * std::exp(svp2 * (t - svpt0) / (t - svp3));
63 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
65 amrex::Real
const a0 = 6.11239921;
66 amrex::Real
const a1 = 0.443987641;
67 amrex::Real
const a2 = 0.142986287e-1;
68 amrex::Real
const a3 = 0.264847430e-3;
69 amrex::Real
const a4 = 0.302950461e-5;
70 amrex::Real
const a5 = 0.206739458e-7;
71 amrex::Real
const a6 = 0.640689451e-10;
72 amrex::Real
const a7 = -0.952447341e-13;
73 amrex::Real
const a8 = -0.976195544e-15;
75 amrex::Real dtt = t-273.16;
77 if (dtt>-85 && dtt<70.0) {
78 esatw = a0 + dtt*(a1+dtt*(a2+dtt*(a3+dtt*(a4+dtt*(a5+dtt*(a6+dtt*(a7+a8*dtt)))))));
89 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
91 amrex::Real
const a0 = 0.503223089;
92 amrex::Real
const a1 = 0.377174432e-1;
93 amrex::Real
const a2 = 0.126710138e-2;
94 amrex::Real
const a3 = 0.249065913e-4;
95 amrex::Real
const a4 = 0.312668753e-6;
96 amrex::Real
const a5 = 0.255653718e-8;
97 amrex::Real
const a6 = 0.132073448e-10;
98 amrex::Real
const a7 = 0.390204672e-13;
99 amrex::Real
const a8 = 0.497275778e-16;
101 amrex::Real dtt = t-273.16;
102 AMREX_ALWAYS_ASSERT(dtt>-85);
107 dtesati = a0 + dtt*(a1+dtt*(a2+dtt*(a3+dtt*(a4+dtt*(a5+dtt*(a6+dtt*(a7+a8*dtt)))))));
113 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
115 constexpr amrex::Real svp1 = 0.6112;
116 constexpr amrex::Real svp2 = 17.67;
117 constexpr amrex::Real svp3 = 29.65;
118 constexpr amrex::Real svpt0 = 273.15;
119 amrex::Real dtesatw = 10.0 * svp1 * svp2 * std::exp(svp2 * (t - svpt0) / (t - svp3))
120 * (svpt0 - svp3) / ((t - svp3) * (t - svp3));
128 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
130 amrex::Real
const a0 = 0.443956472;
131 amrex::Real
const a1 = 0.285976452e-1;
132 amrex::Real
const a2 = 0.794747212e-3;
133 amrex::Real
const a3 = 0.121167162e-4;
134 amrex::Real
const a4 = 0.103167413e-6;
135 amrex::Real
const a5 = 0.385208005e-9;
136 amrex::Real
const a6 = -0.604119582e-12;
137 amrex::Real
const a7 = -0.792933209e-14;
138 amrex::Real
const a8 = -0.599634321e-17;
140 amrex::Real dtt = t-273.16;
142 if (dtt>-85.0 && dtt<70.) {
143 dtesatw = a0 + dtt*(a1+dtt*(a2+dtt*(a3+dtt*(a4+dtt*(a5+dtt*(a6+dtt*(a7+a8*dtt)))))));
150 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
151 void erf_qsati (amrex::Real t, amrex::Real p, amrex::Real &qsati) {
154 qsati =
Rd_on_Rv*esati/std::max(esati,p-esati);
157 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
158 void erf_qsatw (amrex::Real t, amrex::Real p, amrex::Real &qsatw) {
161 qsatw =
Rd_on_Rv*esatw/std::max(esatw,p-esatw);
164 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
165 void erf_dtqsati (amrex::Real t, amrex::Real p, amrex::Real &dtqsati) {
169 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
170 void erf_dtqsatw (amrex::Real t, amrex::Real p, amrex::Real &dtqsatw) {
174 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
175 void z0_est (amrex::Real z, amrex::Real bflx, amrex::Real wnd, amrex::Real ustar, amrex::Real &z0) {
176 amrex::Real vonk = 0.4;
177 amrex::Real eps = 1.0e-10;
178 amrex::Real am = 4.8;
179 amrex::Real bm = 19.3;
180 amrex::Real c1 = 3.14159/2.0 - 3.0*log(2.0);
181 amrex::Real rlmo = -bflx*vonk/(ustar*ustar*ustar+eps);
182 amrex::Real zeta = std::min(1.0,
z*rlmo);
189 x = std::sqrt(sqrt(1.0-bm*zeta));
190 psi1 = 2.0*std::log(1.0+
x) + std::log(1.0+
x*
x) -2.0*std::atan(
x) + c1;
192 amrex::Real lnz = std::max(0.0, vonk*wnd/(ustar+eps) +psi1);
193 z0 =
z*std::exp(-lnz);
196 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
204 amrex::Real term_vel = 0.0;
208 amrex::Real qrr = omp*qploc;
209 amrex::Real qss = (1.0-omp)*(1.0-omg)*qploc;
210 amrex::Real qgg = (1.0-omp)*(omg)*qploc;
211 term_vel = omp*vrain*std::pow(
rho*qrr,
crain)
212 + (1.0-omp)*( (1.0-omg)*vsnow*std::pow(
rho*qss,
csnow)
213 + omg *vgrau*std::pow(
rho*qgg,
cgrau) );
218 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
219 amrex::Real
pp (amrex::Real y) {
220 return std::max(0.0,
y);
223 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
224 amrex::Real
pn (amrex::Real y) {
225 return -std::min(0.0,
y);
constexpr amrex::Real csnow
Definition: ERF_Constants.H:82
constexpr amrex::Real a_gr
Definition: ERF_Constants.H:79
constexpr amrex::Real Rd_on_Rv
Definition: ERF_Constants.H:87
constexpr amrex::Real cgrau
Definition: ERF_Constants.H:83
constexpr amrex::Real tprmin
Definition: ERF_Constants.H:33
constexpr amrex::Real qp_threshold
Definition: ERF_Constants.H:60
constexpr amrex::Real crain
Definition: ERF_Constants.H:81
constexpr amrex::Real tgrmin
Definition: ERF_Constants.H:35
constexpr amrex::Real a_pr
Definition: ERF_Constants.H:78
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_esatw(amrex::Real t)
Definition: ERF_MicrophysicsUtils.H:64
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_dtesatw(amrex::Real t)
Definition: ERF_MicrophysicsUtils.H:129
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void erf_dtqsatw(amrex::Real t, amrex::Real p, amrex::Real &dtqsatw)
Definition: ERF_MicrophysicsUtils.H:170
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_dtesati(amrex::Real t)
Definition: ERF_MicrophysicsUtils.H:90
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_esati(amrex::Real t)
Definition: ERF_MicrophysicsUtils.H:24
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real pn(amrex::Real y)
Definition: ERF_MicrophysicsUtils.H:224
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void z0_est(amrex::Real z, amrex::Real bflx, amrex::Real wnd, amrex::Real ustar, amrex::Real &z0)
Definition: ERF_MicrophysicsUtils.H:175
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_dtesatw_cc(amrex::Real t)
Definition: ERF_MicrophysicsUtils.H:114
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void erf_dtqsati(amrex::Real t, amrex::Real p, amrex::Real &dtqsati)
Definition: ERF_MicrophysicsUtils.H:165
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real term_vel_qp(amrex::Real qploc, amrex::Real vrain, amrex::Real vsnow, amrex::Real vgrau, amrex::Real rho, amrex::Real tabs)
Definition: ERF_MicrophysicsUtils.H:197
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void erf_qsatw(amrex::Real t, amrex::Real p, amrex::Real &qsatw)
Definition: ERF_MicrophysicsUtils.H:158
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_gammafff(amrex::Real x)
Definition: ERF_MicrophysicsUtils.H:15
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void erf_qsati(amrex::Real t, amrex::Real p, amrex::Real &qsati)
Definition: ERF_MicrophysicsUtils.H:151
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real pp(amrex::Real y)
Definition: ERF_MicrophysicsUtils.H:219
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_esatw_cc(amrex::Real t)
Definition: ERF_MicrophysicsUtils.H:49
@ tabs
Definition: ERF_Kessler.H:32
@ rho
Definition: ERF_Kessler.H:30