17 #ifndef ERF_WATER_VAPOR_SATURATION_H_
18 #define ERF_WATER_VAPOR_SATURATION_H_
32 static constexpr amrex::Real
tmin = 127.16;
33 static constexpr amrex::Real
tmax = 375.16;
39 static constexpr
int npcf = 5;
40 static constexpr
const amrex::Real
pcf[
npcf] = {5.04469588506e-01,
47 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
48 static amrex::Real
svp_water (
const amrex::Real& t) {
53 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
54 static amrex::Real
svp_ice (
const amrex::Real& t) {
59 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
60 static amrex::Real
svp_trans (
const amrex::Real& t) {
66 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
69 const amrex::Real& hltalt) {
70 return Cp_d * t + hltalt * q;
75 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
77 amrex::Real& hltalt) {
81 if (t >=
tmelt) hltalt = hltalt - 2369.0*(t-
tmelt);
89 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
92 amrex::Real* tterm =
nullptr) {
93 amrex::Real tc, weight;
108 for(
auto i =
npcf-1; i > 0; --i) *tterm =
pcf[i] + tc*(*tterm);
116 hltalt = hltalt + weight*
lat_ice;
121 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
123 const amrex::Real& p,
124 const amrex::Real& es,
125 const amrex::Real& qs,
126 const amrex::Real& hltalt,
127 const amrex::Real& tterm,
129 amrex::Real& dqsdt) {
133 amrex::Real dqsdt_loc;
139 desdt = hltalt*es/(
R_v*t*t) + tterm;
140 dqsdt_loc = qs*p*desdt/(es*(p-
omeps*es));
144 gam = dqsdt_loc * (hltalt/
Cp_d);
151 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
152 static void qsat (
const amrex::Real& t,
153 const amrex::Real& p,
156 amrex::Real* gam =
nullptr,
157 amrex::Real* dqsdt =
nullptr,
158 amrex::Real* enthalpy =
nullptr) {
161 amrex::Real tterm = 0.0;
168 es = std::min(es, p);
190 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
192 const amrex::Real& p,
195 amrex::Real* gam =
nullptr,
196 amrex::Real* dqsdt =
nullptr,
197 amrex::Real* enthalpy =
nullptr) {
224 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
226 const amrex::Real& p,
231 amrex::Real& enthalpy) {
261 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
262 static void findsp (
const amrex::Real& q,
263 const amrex::Real& t,
264 const amrex::Real& p,
283 amrex::Real t1, q1, dt, dq;
285 amrex::Real r1b, c1, c2, c3;
286 constexpr amrex::Real dttol = 1.e-4;
287 constexpr amrex::Real dqtol = 1.e-4;
288 amrex::Real enin, enout;
290 c3 = 287.04*(7.5*log(10.))/
Cp_d;
301 if (p <= 5.*es || qs <= 0. || qs >= 0.5 || t < tmin || t >
tmax) {
324 c2 = std::pow(t + 36., 2);
325 r1b = c2/(c2 + c1*qs);
326 qvd = r1b * (q - qs);
327 tsp = t + ((hltalt/
Cp_d)*qvd);
331 qsat(tsp, p, es, qsp, &gam, &enout);
336 for(
auto l = 1; l < iter; ++l) {
339 dgdt = -
Cp_d * (1 + gam);
343 dt = abs(t1 - tsp)/t1;
356 qsp = (enin -
Cp_d*tsp)/hltalt;
364 qsat(tsp, p, es, q1, &gam, &enout);
368 dq = abs(q1 - qsp)/std::max(q1,1.e-12);
372 if (dt < dttol && dq < dqtol) {
378 if (abs((enin-enout)/(enin+enout)) > 1.e-4) status = 8;
constexpr amrex::Real R_v
Definition: ERF_Constants.H:11
constexpr amrex::Real lat_vap
Definition: ERF_Constants.H:85
constexpr amrex::Real Cp_d
Definition: ERF_Constants.H:12
constexpr amrex::Real tmelt
Definition: ERF_Constants.H:88
constexpr amrex::Real ttrice
Definition: ERF_Constants.H:91
constexpr amrex::Real lat_ice
Definition: ERF_Constants.H:86
constexpr amrex::Real omeps
Definition: ERF_Constants.H:93
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real wv_sat_svp_water(const amrex::Real &t, const int idx=1)
Definition: ERF_Sat_methods.H:97
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real wv_sat_svp_to_qsat(const amrex::Real &es, const amrex::Real &p)
Definition: ERF_Sat_methods.H:42
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE void wv_sat_qsat_water(const amrex::Real &t, const amrex::Real &p, amrex::Real &es, amrex::Real &qs, const int idx=1)
Definition: ERF_Sat_methods.H:51
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE void wv_sat_qsat_ice(const amrex::Real &t, const amrex::Real &p, amrex::Real &es, amrex::Real &qs, const int idx=1)
Definition: ERF_Sat_methods.H:66
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real wv_sat_svp_trans(const amrex::Real &t, const int idx=1)
Definition: ERF_Sat_methods.H:131
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real wv_sat_svp_ice(const amrex::Real &t, const int idx=1)
Definition: ERF_Sat_methods.H:114
Definition: ERF_Water_vapor_saturation.H:28
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real svp_ice(const amrex::Real &t)
Definition: ERF_Water_vapor_saturation.H:54
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE void findsp(const amrex::Real &q, const amrex::Real &t, const amrex::Real &p, const bool &use_ice, amrex::Real &tsp, amrex::Real &qsp, int &status)
Definition: ERF_Water_vapor_saturation.H:262
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real svp_water(const amrex::Real &t)
Definition: ERF_Water_vapor_saturation.H:48
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE void qsat_ice(const amrex::Real &t, const amrex::Real &p, amrex::Real &es, amrex::Real &qs, amrex::Real &gam, amrex::Real &dqsdt, amrex::Real &enthalpy)
Definition: ERF_Water_vapor_saturation.H:225
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real svp_trans(const amrex::Real &t)
Definition: ERF_Water_vapor_saturation.H:60
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE void calc_hltalt(const amrex::Real &t, amrex::Real &hltalt, amrex::Real *tterm=nullptr)
Definition: ERF_Water_vapor_saturation.H:90
static constexpr amrex::Real tmax
Definition: ERF_Water_vapor_saturation.H:33
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE void qsat(const amrex::Real &t, const amrex::Real &p, amrex::Real &es, amrex::Real &qs, amrex::Real *gam=nullptr, amrex::Real *dqsdt=nullptr, amrex::Real *enthalpy=nullptr)
Definition: ERF_Water_vapor_saturation.H:152
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE void deriv_outputs(const amrex::Real &t, const amrex::Real &p, const amrex::Real &es, const amrex::Real &qs, const amrex::Real &hltalt, const amrex::Real &tterm, amrex::Real &gam, amrex::Real &dqsdt)
Definition: ERF_Water_vapor_saturation.H:122
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE void no_ip_hltalt(const amrex::Real &t, amrex::Real &hltalt)
Definition: ERF_Water_vapor_saturation.H:76
static constexpr int npcf
Definition: ERF_Water_vapor_saturation.H:39
static constexpr amrex::Real tmin
Definition: ERF_Water_vapor_saturation.H:32
static constexpr const amrex::Real pcf[npcf]
Definition: ERF_Water_vapor_saturation.H:40
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE void qsat_water(const amrex::Real &t, const amrex::Real &p, amrex::Real &es, amrex::Real &qs, amrex::Real *gam=nullptr, amrex::Real *dqsdt=nullptr, amrex::Real *enthalpy=nullptr)
Definition: ERF_Water_vapor_saturation.H:191
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real tq_enthalpy(const amrex::Real &t, const amrex::Real &q, const amrex::Real &hltalt)
Definition: ERF_Water_vapor_saturation.H:67