ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_MicrophysicsUtils.H File Reference
#include <cmath>
#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 (amrex::Real t)
 
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 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)
 
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)
 
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)
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real pp (amrex::Real y)
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real pn (amrex::Real y)
 

Function Documentation

◆ erf_dtesati()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_dtesati ( amrex::Real  t)
94  {
95  amrex::Real const a0 = 0.503223089;
96  amrex::Real const a1 = 0.377174432e-1;
97  amrex::Real const a2 = 0.126710138e-2;
98  amrex::Real const a3 = 0.249065913e-4;
99  amrex::Real const a4 = 0.312668753e-6;
100  amrex::Real const a5 = 0.255653718e-8;
101  amrex::Real const a6 = 0.132073448e-10;
102  amrex::Real const a7 = 0.390204672e-13;
103  amrex::Real const a8 = 0.497275778e-16;
104 
105  amrex::Real dtt = t-273.16;
106  AMREX_ALWAYS_ASSERT(dtt>-85);
107  amrex::Real dtesati;
108  if (dtt > 0.0) {
109  dtesati = 0.0;
110  } else {
111  dtesati = a0 + dtt*(a1+dtt*(a2+dtt*(a3+dtt*(a4+dtt*(a5+dtt*(a6+dtt*(a7+a8*dtt)))))));
112  }
113  return dtesati;
114 }
amrex::Real Real
Definition: ERF_ShocInterface.H:19
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 caller graph for this function:

◆ erf_dtesatw()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_dtesatw ( amrex::Real  t)
133  {
134  amrex::Real const a0 = 0.443956472;
135  amrex::Real const a1 = 0.285976452e-1;
136  amrex::Real const a2 = 0.794747212e-3;
137  amrex::Real const a3 = 0.121167162e-4;
138  amrex::Real const a4 = 0.103167413e-6;
139  amrex::Real const a5 = 0.385208005e-9;
140  amrex::Real const a6 = -0.604119582e-12;
141  amrex::Real const a7 = -0.792933209e-14;
142  amrex::Real const a8 = -0.599634321e-17;
143 
144  amrex::Real dtt = t-273.16; // Goff-Gratch
145  amrex::Real dtesatw;
146  if (dtt>-85.0 && dtt<70.) {
147  dtesatw = a0 + dtt*(a1+dtt*(a2+dtt*(a3+dtt*(a4+dtt*(a5+dtt*(a6+dtt*(a7+a8*dtt)))))));
148  } else {
149  dtesatw = erf_dtesatw_cc(t);
150  }
151  return dtesatw;
152 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_dtesatw_cc(amrex::Real t)
Definition: ERF_MicrophysicsUtils.H:118

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)
118  {
119  constexpr amrex::Real svp1 = 0.6112;
120  constexpr amrex::Real svp2 = 17.67;
121  constexpr amrex::Real svp3 = 29.65;
122  constexpr amrex::Real svpt0 = 273.15;
123  amrex::Real dtesatw = 10.0 * svp1 * svp2 * std::exp(svp2 * (t - svpt0) / (t - svp3))
124  * (svpt0 - svp3) / ((t - svp3) * (t - svp3));
125  return dtesatw;
126 }
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_dtqsati()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void erf_dtqsati ( amrex::Real  t,
amrex::Real  p,
amrex::Real dtqsati 
)
173  {
174  amrex::Real esati = erf_esati(t);
175  amrex::Real dtesati = erf_dtesati(t);
176  amrex::Real denom = p - esati;
177  dtqsati = Rd_on_Rv * dtesati * p / (denom * denom);
178 }
constexpr amrex::Real Rd_on_Rv
Definition: ERF_Constants.H:87
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_dtesati(amrex::Real t)
Definition: ERF_MicrophysicsUtils.H:94
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_esati(amrex::Real t)
Definition: ERF_MicrophysicsUtils.H:26

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 
)
181  {
182  amrex::Real esatw = erf_esatw(t);
183  amrex::Real dtesatw = erf_dtesatw(t);
184  amrex::Real denom = p - esatw;
185  dtqsatw = Rd_on_Rv * dtesatw * p / (denom * denom);
186 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_esatw(amrex::Real t)
Definition: ERF_MicrophysicsUtils.H:68
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_dtesatw(amrex::Real t)
Definition: ERF_MicrophysicsUtils.H:133

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

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)
26  {
27  amrex::Real const a0 = 6.11147274;
28  amrex::Real const a1 = 0.503160820;
29  amrex::Real const a2 = 0.188439774e-1;
30  amrex::Real const a3 = 0.420895665e-3;
31  amrex::Real const a4 = 0.615021634e-5;
32  amrex::Real const a5 = 0.602588177e-7;
33  amrex::Real const a6 = 0.385852041e-9;
34  amrex::Real const a7 = 0.146898966e-11;
35  amrex::Real const a8 = 0.252751365e-14;
36 
37  amrex::Real dtt = t-273.16;
38  AMREX_ALWAYS_ASSERT(dtt>-90);
39 
40  amrex::Real esati;
41  if (dtt > 0.0) {
42  esati = 0.0;
43  } else {
44  esati = a0 + dtt*(a1+dtt*(a2+dtt*(a3+dtt*(a4+dtt*(a5+dtt*(a6+dtt*(a7+a8*dtt)))))));
45  }
46  return esati;
47 }

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

Here is the caller graph for this function:

◆ erf_esatw()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_esatw ( amrex::Real  t)
68  {
69  amrex::Real const a0 = 6.11239921;
70  amrex::Real const a1 = 0.443987641;
71  amrex::Real const a2 = 0.142986287e-1;
72  amrex::Real const a3 = 0.264847430e-3;
73  amrex::Real const a4 = 0.302950461e-5;
74  amrex::Real const a5 = 0.206739458e-7;
75  amrex::Real const a6 = 0.640689451e-10;
76  amrex::Real const a7 = -0.952447341e-13;
77  amrex::Real const a8 = -0.976195544e-15;
78 
79  amrex::Real dtt = t-273.16;
80  amrex::Real esatw;
81  if (dtt>-85 && dtt<70.0) {
82  esatw = a0 + dtt*(a1+dtt*(a2+dtt*(a3+dtt*(a4+dtt*(a5+dtt*(a6+dtt*(a7+a8*dtt)))))));
83  } else {
84  esatw = erf_esatw_cc(t);
85  }
86  return esatw;
87 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_esatw_cc(amrex::Real t)
Definition: ERF_MicrophysicsUtils.H:51

Referenced by Morrison::Compute_Coefficients(), SAM::Compute_Coefficients(), 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)
51  {
52  constexpr amrex::Real svp1 = 0.6112;
53  constexpr amrex::Real svp2 = 17.67;
54  constexpr amrex::Real svp3 = 29.65;
55  constexpr amrex::Real svpt0 = 273.15;
56  // NOTE: units of
57  amrex::Real esatw = 10.0 * svp1 * std::exp(svp2 * (t - svpt0) / (t - svp3));
58  return esatw;
59 }

Referenced by erf_esatw().

Here is the caller graph for this function:

◆ erf_gammafff()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_gammafff ( amrex::Real  x)
15  {
16  return std::exp(lgamma(x));
17 }

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

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 
)
155  {
156  amrex::Real esati;
157  esati = erf_esati(t);
158  qsati = Rd_on_Rv*esati/std::max(esati,p-esati);
159 }

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 
)
166  {
167  amrex::Real esatw;
168  esatw = erf_esatw(t);
169  qsatw = Rd_on_Rv*esatw/std::max(esatw,p-esatw);
170 }

Referenced by Kessler::AdvanceKessler(), SatAdj::AdvanceSatAdj(), SAM::Cloud(), ComputeMoistStratification(), SurfaceLayer::fill_qsurf_with_qsat(), SatAdj::NewtonIterSat(), Morrison::NewtonIterSat(), SAM::NewtonIterSat(), SAM::Precip(), and ERF::Write3DPlotFile().

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

◆ pn()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real pn ( amrex::Real  y)
238  {
239  return -std::min(0.0,y);
240 }

◆ pp()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real pp ( amrex::Real  y)

◆ term_vel_qp()

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 
)
217 {
218  amrex::Real term_vel = 0.0;
219  if(qploc > qp_threshold) {
220  amrex::Real omp = std::max(0.0,std::min(1.0,(tabs-tprmin)*a_pr));
221  amrex::Real omg = std::max(0.0,std::min(1.0,(tabs-tgrmin)*a_gr));
222  amrex::Real qrr = omp*qploc;
223  amrex::Real qss = (1.0-omp)*(1.0-omg)*qploc;
224  amrex::Real qgg = (1.0-omp)*(omg)*qploc;
225  term_vel = omp*vrain*std::pow(rho*qrr,crain)
226  + (1.0-omp)*( (1.0-omg)*vsnow*std::pow(rho*qss,csnow)
227  + omg *vgrau*std::pow(rho*qgg,cgrau) );
228  }
229  return term_vel;
230 }
constexpr amrex::Real csnow
Definition: ERF_Constants.H:82
constexpr amrex::Real a_gr
Definition: ERF_Constants.H:79
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
@ tabs
Definition: ERF_Kessler.H:24
@ rho
Definition: ERF_Kessler.H:22

◆ z0_est()

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 
)
189  {
190  amrex::Real vonk = 0.4;
191  amrex::Real eps = 1.0e-10;
192  amrex::Real am = 4.8;
193  amrex::Real bm = 19.3;
194  amrex::Real c1 = 3.14159/2.0 - 3.0*log(2.0);
195  amrex::Real rlmo = -bflx*vonk/(ustar*ustar*ustar+eps);
196  amrex::Real zeta = std::min(1.0,z*rlmo);
197  amrex::Real x;
198  amrex::Real psi1;
199  if(zeta >= 0.0) {
200  psi1 = -am*zeta;
201  }
202  else {
203  x = std::sqrt(sqrt(1.0-bm*zeta));
204  psi1 = 2.0*std::log(1.0+x) + std::log(1.0+x*x) -2.0*std::atan(x) + c1;
205  }
206  amrex::Real lnz = std::max(0.0, vonk*wnd/(ustar+eps) +psi1);
207  z0 = z*std::exp(-lnz);
208 }
real(c_double), private c1
Definition: ERF_module_mp_morr_two_moment.F90:211