5 #ifndef ERF_Microphysics_Utils_H
6 #define ERF_Microphysics_Utils_H
12 #include <AMReX_REAL.H>
13 #include <AMReX_Array.H>
35 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
37 const amrex::Real
rho,
38 const amrex::Real rho_theta,
40 const amrex::Real
rdOcp,
41 const bool use_anelastic_reference_pressure,
42 const amrex::Real
p0) noexcept
44 if (use_anelastic_reference_pressure) {
45 const amrex::Real
theta = rho_theta /
rho;
55 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
58 return std::exp(std::lgamma(
x));
67 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
69 amrex::Real
const a0 = amrex::Real(6.11147274);
70 amrex::Real
const a1 = amrex::Real(0.503160820);
71 amrex::Real
const a2 = amrex::Real(0.188439774e-1);
72 amrex::Real
const a3 = amrex::Real(0.420895665e-3);
73 amrex::Real
const a4 = amrex::Real(0.615021634e-5);
74 amrex::Real
const a5 = amrex::Real(0.602588177e-7);
75 amrex::Real
const a6 = amrex::Real(0.385852041e-9);
76 amrex::Real
const a7 = amrex::Real(0.146898966e-11);
77 amrex::Real
const a8 = amrex::Real(0.252751365e-14);
79 amrex::Real dtt =
t-amrex::Real(273.16);
84 if (dtt > amrex::Real(0)) {
85 esati = amrex::Real(0);
87 esati = a0 + dtt*(a1+dtt*(
a2+dtt*(
a3+dtt*(
a4+dtt*(a5+dtt*(a6+dtt*(a7+a8*dtt)))))));
98 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
100 constexpr amrex::Real
svp1 = amrex::Real(0.6112);
101 constexpr amrex::Real
svp2 = amrex::Real(17.67);
102 constexpr amrex::Real
svp3 = amrex::Real(29.65);
103 constexpr amrex::Real
svpt0 = amrex::Real(273.15);
108 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
111 amrex::Real
const a0 = amrex::Real(6.11239921);
112 amrex::Real
const a1 = amrex::Real(0.443987641);
113 amrex::Real
const a2 = amrex::Real(0.142986287e-1);
114 amrex::Real
const a3 = amrex::Real(0.264847430e-3);
115 amrex::Real
const a4 = amrex::Real(0.302950461e-5);
116 amrex::Real
const a5 = amrex::Real(0.206739458e-7);
117 amrex::Real
const a6 = amrex::Real(0.640689451e-10);
118 amrex::Real
const a7 = -amrex::Real(0.952447341e-13);
119 amrex::Real
const a8 = -amrex::Real(0.976195544e-15);
121 return a0 + dtt*(a1+dtt*(
a2+dtt*(
a3+dtt*(
a4+dtt*(a5+dtt*(a6+dtt*(a7+a8*dtt)))))));
124 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
127 amrex::Real
const a0 = amrex::Real(0.443956472);
128 amrex::Real
const a1 = amrex::Real(0.285976452e-1);
129 amrex::Real
const a2 = amrex::Real(0.794747212e-3);
130 amrex::Real
const a3 = amrex::Real(0.121167162e-4);
131 amrex::Real
const a4 = amrex::Real(0.103167413e-6);
132 amrex::Real
const a5 = amrex::Real(0.385208005e-9);
133 amrex::Real
const a6 = -amrex::Real(0.604119582e-12);
134 amrex::Real
const a7 = -amrex::Real(0.792933209e-14);
135 amrex::Real
const a8 = -amrex::Real(0.599634321e-17);
137 return a0 + dtt*(a1+dtt*(
a2+dtt*(
a3+dtt*(
a4+dtt*(a5+dtt*(a6+dtt*(a7+a8*dtt)))))));
140 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
143 amrex::Real
const dtt =
t - amrex::Real(273.16);
144 amrex::Real
const poly_min_dtt = -amrex::Real(70.0);
145 return dtt > poly_min_dtt && dtt < amrex::Real(70.0) &&
159 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
163 return amrex::Real(0.01) *
164 std::exp(amrex::Real(34.494) - amrex::Real(4924.99)/(
t - amrex::Real(273.15) + amrex::Real(237.1))) /
165 std::pow(
t - amrex::Real(273.15) + amrex::Real(105.0), amrex::Real(1.57));
179 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
181 amrex::Real
const a0 = amrex::Real(0.503223089);
182 amrex::Real
const a1 = amrex::Real(0.377174432e-1);
183 amrex::Real
const a2 = amrex::Real(0.126710138e-2);
184 amrex::Real
const a3 = amrex::Real(0.249065913e-4);
185 amrex::Real
const a4 = amrex::Real(0.312668753e-6);
186 amrex::Real
const a5 = amrex::Real(0.255653718e-8);
187 amrex::Real
const a6 = amrex::Real(0.132073448e-10);
188 amrex::Real
const a7 = amrex::Real(0.390204672e-13);
189 amrex::Real
const a8 = amrex::Real(0.497275778e-16);
191 amrex::Real dtt =
t-amrex::Real(273.16);
195 if (dtt > amrex::Real(0)) {
196 dtesati = amrex::Real(0);
198 dtesati = a0 + dtt*(a1+dtt*(
a2+dtt*(
a3+dtt*(
a4+dtt*(a5+dtt*(a6+dtt*(a7+a8*dtt)))))));
206 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
208 constexpr amrex::Real
svp1 = amrex::Real(0.6112);
209 constexpr amrex::Real
svp2 = amrex::Real(17.67);
210 constexpr amrex::Real
svp3 = amrex::Real(29.65);
211 constexpr amrex::Real
svpt0 = amrex::Real(273.15);
222 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
233 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
236 return RdoRv * esat / std::max(esat,
p - esat);
241 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
244 if ((
p - esat) >= esat) {
245 amrex::Real
const denom =
p - esat;
246 return RdoRv * dtesat *
p / (denom * denom);
249 return amrex::Real(0);
254 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
264 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
271 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
280 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
constexpr amrex::Real RdoRv
Definition: ERF_Constants.H:60
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getTgivenRandRTh(const amrex::Real rho, const amrex::Real rhotheta, const amrex::Real qv=amrex::Real(0))
Definition: ERF_EOS.H:46
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getPgivenRTh(const amrex::Real rhotheta, const amrex::Real qv=amrex::Real(0))
Definition: ERF_EOS.H:81
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getTgivenPandTh(const amrex::Real P, const amrex::Real th, const amrex::Real rdOcp)
Definition: ERF_EOS.H:32
const Real rdOcp
Definition: ERF_InitCustomPert_ABL.H:128
AMREX_ALWAYS_ASSERT(bx.length()[2]==khi+1)
bool use_empirical
Definition: ERF_InitCustomPert_MultiSpeciesBubble.H:29
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool erf_use_positive_esatw_poly(amrex::Real t)
Definition: ERF_MicrophysicsUtils.H:141
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_dtesatw(amrex::Real t)
Definition: ERF_MicrophysicsUtils.H:223
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void erf_dtqsatw(amrex::Real t, amrex::Real p, amrex::Real &dtqsatw)
Definition: ERF_MicrophysicsUtils.H:281
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_dtesati(amrex::Real t)
Definition: ERF_MicrophysicsUtils.H:180
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_esatw_flatau_poly(amrex::Real dtt)
Definition: ERF_MicrophysicsUtils.H:109
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_dtesatw_flatau_poly(amrex::Real dtt)
Definition: ERF_MicrophysicsUtils.H:125
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_esati(amrex::Real t)
Definition: ERF_MicrophysicsUtils.H:68
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE MicrophysicsThermoState diagnose_microphysics_thermo_state(const amrex::Real rho, const amrex::Real rho_theta, const amrex::Real qv, const amrex::Real rdOcp, const bool use_anelastic_reference_pressure, const amrex::Real p0) noexcept
Definition: ERF_MicrophysicsUtils.H:36
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_dtesatw_cc(amrex::Real t)
Definition: ERF_MicrophysicsUtils.H:207
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_qsat_from_esat(amrex::Real esat, amrex::Real p)
Definition: ERF_MicrophysicsUtils.H:234
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void erf_dtqsati(amrex::Real t, amrex::Real p, amrex::Real &dtqsati)
Definition: ERF_MicrophysicsUtils.H:272
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void erf_qsatw(amrex::Real t, amrex::Real p, amrex::Real &qsatw)
Definition: ERF_MicrophysicsUtils.H:265
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_gammafff(amrex::Real x)
Definition: ERF_MicrophysicsUtils.H:56
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_dtqsat_from_esat(amrex::Real esat, amrex::Real dtesat, amrex::Real p)
Definition: ERF_MicrophysicsUtils.H:242
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void erf_qsati(amrex::Real t, amrex::Real p, amrex::Real &qsati)
Definition: ERF_MicrophysicsUtils.H:255
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_esatw(amrex::Real t, bool use_empirical=false)
Definition: ERF_MicrophysicsUtils.H:160
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_esatw_cc(amrex::Real t)
Definition: ERF_MicrophysicsUtils.H:99
@ rho
Definition: ERF_Kessler.H:25
@ theta
Definition: ERF_Kessler.H:26
@ qv
Definition: ERF_Kessler.H:31
@ qsatw
Definition: ERF_WSM6.H:363
@ qsati
Definition: ERF_WSM6.H:363
@ t
Definition: ERF_WSM6.H:295
@ p
Definition: ERF_WSM6.H:303
real(c_double), parameter svp1
Definition: ERF_module_model_constants.F90:78
real(c_double), parameter p0
Definition: ERF_module_model_constants.F90:40
real(c_double), parameter epsilon
Definition: ERF_module_model_constants.F90:12
real(c_double), parameter a2
Definition: ERF_module_model_constants.F90:95
real(c_double), parameter a3
Definition: ERF_module_model_constants.F90:96
real(c_double), parameter svp3
Definition: ERF_module_model_constants.F90:80
real(c_double), parameter svp2
Definition: ERF_module_model_constants.F90:79
real(c_double), parameter a4
Definition: ERF_module_model_constants.F90:97
real(c_double), parameter svpt0
Definition: ERF_module_model_constants.F90:81
Definition: ERF_MicrophysicsUtils.H:22
amrex::Real pressure_pa
Definition: ERF_MicrophysicsUtils.H:23
amrex::Real temperature
Definition: ERF_MicrophysicsUtils.H:24