ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_MicrophysicsUtils.H File Reference
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <AMReX_REAL.H>
#include <AMReX_Array.H>
#include <ERF_Constants.H>
Include dependency graph for ERF_MicrophysicsUtils.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_gammafff (amrex::Real x)
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_esati (amrex::Real t)
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_esatw_cc (amrex::Real t)
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_esatw_flatau_poly (amrex::Real dtt)
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_dtesatw_flatau_poly (amrex::Real dtt)
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool erf_use_positive_esatw_poly (amrex::Real t)
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_esatw (amrex::Real t, bool use_empirical=false)
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_dtesati (amrex::Real t)
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_dtesatw_cc (amrex::Real t)
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_dtesatw (amrex::Real t)
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_qsat_from_esat (amrex::Real esat, amrex::Real p)
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_dtqsat_from_esat (amrex::Real esat, amrex::Real dtesat, amrex::Real p)
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void erf_qsati (amrex::Real t, amrex::Real p, amrex::Real &qsati)
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void erf_qsatw (amrex::Real t, amrex::Real p, amrex::Real &qsatw)
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void erf_dtqsati (amrex::Real t, amrex::Real p, amrex::Real &dtqsati)
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void erf_dtqsatw (amrex::Real t, amrex::Real p, amrex::Real &dtqsatw)
 

Function Documentation

◆ erf_dtesati()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_dtesati ( amrex::Real  t)
143  {
144  amrex::Real const a0 = amrex::Real(0.503223089);
145  amrex::Real const a1 = amrex::Real(0.377174432e-1);
146  amrex::Real const a2 = amrex::Real(0.126710138e-2);
147  amrex::Real const a3 = amrex::Real(0.249065913e-4);
148  amrex::Real const a4 = amrex::Real(0.312668753e-6);
149  amrex::Real const a5 = amrex::Real(0.255653718e-8);
150  amrex::Real const a6 = amrex::Real(0.132073448e-10);
151  amrex::Real const a7 = amrex::Real(0.390204672e-13);
152  amrex::Real const a8 = amrex::Real(0.497275778e-16);
153 
154  amrex::Real dtt = t-amrex::Real(273.16);
156  AMREX_ALWAYS_ASSERT(dtt >= -amrex::Real(85.0) - tol);
157  amrex::Real dtesati;
158  if (dtt > amrex::Real(0)) {
159  dtesati = amrex::Real(0);
160  } else {
161  dtesati = a0 + dtt*(a1+dtt*(a2+dtt*(a3+dtt*(a4+dtt*(a5+dtt*(a6+dtt*(a7+a8*dtt)))))));
162  }
163  return dtesati;
164 }
AMREX_ALWAYS_ASSERT(bx.length()[2]==khi+1)
Real * t
Definition: ERF_InitCustomPert_SquallLine.H:60
amrex::Real Real
Definition: ERF_ShocInterface.H:19
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 a4
Definition: ERF_module_model_constants.F90:97

Referenced by erf_dtqsati().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ erf_dtesatw()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_dtesatw ( amrex::Real  t)
186  {
188  return erf_dtesatw_flatau_poly(t - amrex::Real(273.16));
189  }
190 
191  return erf_dtesatw_cc(t);
192 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool erf_use_positive_esatw_poly(amrex::Real t)
Definition: ERF_MicrophysicsUtils.H:104
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_dtesatw_flatau_poly(amrex::Real dtt)
Definition: ERF_MicrophysicsUtils.H:88
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_dtesatw_cc(amrex::Real t)
Definition: ERF_MicrophysicsUtils.H:170

Referenced by erf_dtqsatw().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ erf_dtesatw_cc()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_dtesatw_cc ( amrex::Real  t)
170  {
171  constexpr amrex::Real svp1 = amrex::Real(0.6112);
172  constexpr amrex::Real svp2 = amrex::Real(17.67);
173  constexpr amrex::Real svp3 = amrex::Real(29.65);
174  constexpr amrex::Real svpt0 = amrex::Real(273.15);
175  amrex::Real dtesatw = amrex::Real(10.0) * svp1 * svp2 * std::exp(svp2 * (t - svpt0) / (t - svp3))
176  * (svpt0 - svp3) / ((t - svp3) * (t - svp3));
177  return dtesatw;
178 }
real(c_double), parameter svp1
Definition: ERF_module_model_constants.F90:78
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 svpt0
Definition: ERF_module_model_constants.F90:81

Referenced by erf_dtesatw().

Here is the caller graph for this function:

◆ erf_dtesatw_flatau_poly()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_dtesatw_flatau_poly ( amrex::Real  dtt)
89 {
90  amrex::Real const a0 = amrex::Real(0.443956472);
91  amrex::Real const a1 = amrex::Real(0.285976452e-1);
92  amrex::Real const a2 = amrex::Real(0.794747212e-3);
93  amrex::Real const a3 = amrex::Real(0.121167162e-4);
94  amrex::Real const a4 = amrex::Real(0.103167413e-6);
95  amrex::Real const a5 = amrex::Real(0.385208005e-9);
96  amrex::Real const a6 = -amrex::Real(0.604119582e-12);
97  amrex::Real const a7 = -amrex::Real(0.792933209e-14);
98  amrex::Real const a8 = -amrex::Real(0.599634321e-17);
99 
100  return a0 + dtt*(a1+dtt*(a2+dtt*(a3+dtt*(a4+dtt*(a5+dtt*(a6+dtt*(a7+a8*dtt)))))));
101 }

Referenced by erf_dtesatw().

Here is the caller graph for this function:

◆ erf_dtqsat_from_esat()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_dtqsat_from_esat ( amrex::Real  esat,
amrex::Real  dtesat,
amrex::Real  p 
)
206 {
207  if ((p - esat) >= esat) {
208  amrex::Real const denom = p - esat;
209  return Rd_on_Rv * dtesat * p / (denom * denom);
210  }
211 
212  return amrex::Real(0);
213 }
constexpr amrex::Real Rd_on_Rv
Definition: ERF_Constants.H:98
Real * p
Definition: ERF_InitCustomPert_SquallLine.H:61

Referenced by erf_dtqsati(), and erf_dtqsatw().

Here is the caller graph for this function:

◆ erf_dtqsati()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void erf_dtqsati ( amrex::Real  t,
amrex::Real  p,
amrex::Real dtqsati 
)
235  {
236  amrex::Real esati = erf_esati(t);
237  amrex::Real dtesati = erf_dtesati(t);
238  dtqsati = erf_dtqsat_from_esat(esati, dtesati, p);
239 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_dtesati(amrex::Real t)
Definition: ERF_MicrophysicsUtils.H:143
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_esati(amrex::Real t)
Definition: ERF_MicrophysicsUtils.H:31
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:205

Referenced by Morrison::NewtonIterSat(), and SAM::NewtonIterSat().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ erf_dtqsatw()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void erf_dtqsatw ( amrex::Real  t,
amrex::Real  p,
amrex::Real dtqsatw 
)
244  {
245  amrex::Real esatw = erf_esatw(t);
246  amrex::Real dtesatw = erf_dtesatw(t);
247  dtqsatw = erf_dtqsat_from_esat(esatw, dtesatw, p);
248 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_dtesatw(amrex::Real t)
Definition: ERF_MicrophysicsUtils.H:186
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_esatw(amrex::Real t, bool use_empirical=false)
Definition: ERF_MicrophysicsUtils.H:123

Referenced by Kessler::AdvanceKessler(), Morrison::NewtonIterSat(), SAM::NewtonIterSat(), and SatAdj::NewtonSolveSatTemperature().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ erf_esati()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_esati ( amrex::Real  t)
31  {
32  amrex::Real const a0 = amrex::Real(6.11147274);
33  amrex::Real const a1 = amrex::Real(0.503160820);
34  amrex::Real const a2 = amrex::Real(0.188439774e-1);
35  amrex::Real const a3 = amrex::Real(0.420895665e-3);
36  amrex::Real const a4 = amrex::Real(0.615021634e-5);
37  amrex::Real const a5 = amrex::Real(0.602588177e-7);
38  amrex::Real const a6 = amrex::Real(0.385852041e-9);
39  amrex::Real const a7 = amrex::Real(0.146898966e-11);
40  amrex::Real const a8 = amrex::Real(0.252751365e-14);
41 
42  amrex::Real dtt = t-amrex::Real(273.16);
44  AMREX_ALWAYS_ASSERT(dtt >= -amrex::Real(90.0) - tol);
45 
46  amrex::Real esati;
47  if (dtt > amrex::Real(0)) {
48  esati = amrex::Real(0);
49  } else {
50  esati = a0 + dtt*(a1+dtt*(a2+dtt*(a3+dtt*(a4+dtt*(a5+dtt*(a6+dtt*(a7+a8*dtt)))))));
51  }
52  return esati;
53 }

Referenced by Morrison::Compute_Coefficients(), SAM::Compute_Coefficients(), erf_dtqsati(), and erf_qsati().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ erf_esatw()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_esatw ( amrex::Real  t,
bool  use_empirical = false 
)
124 {
125  if (use_empirical) {
126  return amrex::Real(0.01) *
127  std::exp(amrex::Real(34.494) - amrex::Real(4924.99)/(t - amrex::Real(273.15) + amrex::Real(237.1))) /
128  std::pow(t - amrex::Real(273.15) + amrex::Real(105.0), amrex::Real(1.57));
129  }
130 
132  return erf_esatw_flatau_poly(t - amrex::Real(273.16));
133  }
134 
135  return erf_esatw_cc(t);
136 }
bool use_empirical
Definition: ERF_InitCustomPert_MultiSpeciesBubble.H:25
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_esatw_flatau_poly(amrex::Real dtt)
Definition: ERF_MicrophysicsUtils.H:72
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_esatw_cc(amrex::Real t)
Definition: ERF_MicrophysicsUtils.H:62

Referenced by Morrison::Compute_Coefficients(), SAM::Compute_Coefficients(), HSEutils::compute_saturation_pressure(), saturation_funcs::compute_saturation_pressure_H2O(), erf_dtqsatw(), erf_qsatw(), and ERF::Write3DPlotFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ erf_esatw_cc()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_esatw_cc ( amrex::Real  t)
62  {
63  constexpr amrex::Real svp1 = amrex::Real(0.6112);
64  constexpr amrex::Real svp2 = amrex::Real(17.67);
65  constexpr amrex::Real svp3 = amrex::Real(29.65);
66  constexpr amrex::Real svpt0 = amrex::Real(273.15);
67  amrex::Real esatw = amrex::Real(10.0) * svp1 * std::exp(svp2 * (t - svpt0) / (t - svp3));
68  return esatw;
69 }

Referenced by erf_esatw(), and ERF::Write3DPlotFile().

Here is the caller graph for this function:

◆ erf_esatw_flatau_poly()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_esatw_flatau_poly ( amrex::Real  dtt)
73 {
74  amrex::Real const a0 = amrex::Real(6.11239921);
75  amrex::Real const a1 = amrex::Real(0.443987641);
76  amrex::Real const a2 = amrex::Real(0.142986287e-1);
77  amrex::Real const a3 = amrex::Real(0.264847430e-3);
78  amrex::Real const a4 = amrex::Real(0.302950461e-5);
79  amrex::Real const a5 = amrex::Real(0.206739458e-7);
80  amrex::Real const a6 = amrex::Real(0.640689451e-10);
81  amrex::Real const a7 = -amrex::Real(0.952447341e-13);
82  amrex::Real const a8 = -amrex::Real(0.976195544e-15);
83 
84  return a0 + dtt*(a1+dtt*(a2+dtt*(a3+dtt*(a4+dtt*(a5+dtt*(a6+dtt*(a7+a8*dtt)))))));
85 }

Referenced by erf_esatw(), and erf_use_positive_esatw_poly().

Here is the caller graph for this function:

◆ erf_gammafff()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_gammafff ( amrex::Real  x)
19  {
21  return std::exp(std::lgamma(x));
22 }

Referenced by Morrison::Compute_Coefficients(), SAM::Compute_Coefficients(), and SAM::PrecipFall().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ erf_qsat_from_esat()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_qsat_from_esat ( amrex::Real  esat,
amrex::Real  p 
)
198 {
199  return Rd_on_Rv * esat / std::max(esat, p - esat);
200 }

Referenced by erf_qsati(), and erf_qsatw().

Here is the caller graph for this function:

◆ erf_qsati()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void erf_qsati ( amrex::Real  t,
amrex::Real  p,
amrex::Real qsati 
)
218  {
219  qsati = erf_qsat_from_esat(erf_esati(t), p);
220 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_qsat_from_esat(amrex::Real esat, amrex::Real p)
Definition: ERF_MicrophysicsUtils.H:197

Referenced by SAM::Cloud(), ComputeMoistStratification(), Morrison::NewtonIterSat(), SAM::NewtonIterSat(), and SAM::Precip().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ erf_qsatw()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void erf_qsatw ( amrex::Real  t,
amrex::Real  p,
amrex::Real qsatw 
)

◆ erf_use_positive_esatw_poly()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool erf_use_positive_esatw_poly ( amrex::Real  t)
105 {
106  amrex::Real const dtt = t - amrex::Real(273.16);
107  amrex::Real const poly_min_dtt = -amrex::Real(70.0);
108  return dtt > poly_min_dtt && dtt < amrex::Real(70.0) &&
110 }

Referenced by erf_dtesatw(), and erf_esatw().

Here is the call graph for this function:
Here is the caller graph for this function: