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)
90  {
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;
100 
101  amrex::Real dtt = t-273.16;
102  AMREX_ALWAYS_ASSERT(dtt>-85);
103  amrex::Real dtesati;
104  if (dtt > 0.0) {
105  dtesati = 0.0;
106  } else {
107  dtesati = a0 + dtt*(a1+dtt*(a2+dtt*(a3+dtt*(a4+dtt*(a5+dtt*(a6+dtt*(a7+a8*dtt)))))));
108  }
109  return dtesati;
110 }

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)
129  {
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;
139 
140  amrex::Real dtt = t-273.16;
141  amrex::Real dtesatw;
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)))))));
144  } else {
145  dtesatw = erf_dtesatw_cc(t);
146  }
147  return dtesatw;
148 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_dtesatw_cc(amrex::Real t)
Definition: ERF_MicrophysicsUtils.H:114

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)
114  {
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));
121  return dtesatw;
122 }

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 
)
165  {
166  dtqsati = Rd_on_Rv*erf_dtesati(t)/p;
167 }
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:90

Referenced by 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 
)
170  {
171  dtqsatw = Rd_on_Rv*erf_dtesatw(t)/p;
172 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_dtesatw(amrex::Real t)
Definition: ERF_MicrophysicsUtils.H:129

Referenced by Kessler::AdvanceKessler(), SatAdj::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)
24  {
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;
34 
35  amrex::Real dtt = t-273.16;
36  AMREX_ALWAYS_ASSERT(dtt>-85);
37 
38  amrex::Real esati;
39  if (dtt > 0.0) {
40  esati = 0.0;
41  } else {
42  esati = a0 + dtt*(a1+dtt*(a2+dtt*(a3+dtt*(a4+dtt*(a5+dtt*(a6+dtt*(a7+a8*dtt)))))));
43  }
44  return esati;
45 }

Referenced by SAM::Compute_Coefficients(), 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)
64  {
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;
74 
75  amrex::Real dtt = t-273.16;
76  amrex::Real esatw;
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)))))));
79  } else {
80  esatw = erf_esatw_cc(t);
81  }
82  return esatw;
83 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_esatw_cc(amrex::Real t)
Definition: ERF_MicrophysicsUtils.H:49

Referenced by SAM::Compute_Coefficients(), erf_qsatw(), and ERF::WritePlotFile().

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)
49  {
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;
54  // NOTE: units of
55  amrex::Real esatw = 10.0 * svp1 * std::exp(svp2 * (t - svpt0) / (t - svp3));
56  return esatw;
57 }

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 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 
)
151  {
152  amrex::Real esati;
153  esati = erf_esati(t);
154  qsati = Rd_on_Rv*esati/std::max(esati,p-esati);
155 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_esati(amrex::Real t)
Definition: ERF_MicrophysicsUtils.H:24

Referenced by SAM::Cloud(), 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 
)
158  {
159  amrex::Real esatw;
160  esatw = erf_esatw(t);
161  qsatw = Rd_on_Rv*esatw/std::max(esatw,p-esatw);
162 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_esatw(amrex::Real t)
Definition: ERF_MicrophysicsUtils.H:64

Referenced by Kessler::AdvanceKessler(), SatAdj::AdvanceSatAdj(), SAM::Cloud(), SatAdj::NewtonIterSat(), SAM::NewtonIterSat(), SAM::Precip(), and ERF::WritePlotFile().

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)
224  {
225  return -std::min(0.0,y);
226 }

◆ pp()

◆ 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 
)
203 {
204  amrex::Real term_vel = 0.0;
205  if(qploc > qp_threshold) {
206  amrex::Real omp = std::max(0.0,std::min(1.0,(tabs-tprmin)*a_pr));
207  amrex::Real omg = std::max(0.0,std::min(1.0,(tabs-tgrmin)*a_gr));
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) );
214  }
215  return term_vel;
216 }
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:32
@ rho
Definition: ERF_Kessler.H:30

◆ 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 
)
175  {
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);
183  amrex::Real x;
184  amrex::Real psi1;
185  if(zeta >= 0.0) {
186  psi1 = -am*zeta;
187  }
188  else {
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;
191  }
192  amrex::Real lnz = std::max(0.0, vonk*wnd/(ustar+eps) +psi1);
193  z0 = z*std::exp(-lnz);
194 }