ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
Microphysics_Utils.H File Reference
#include <cmath>
#include <vector>
#include <AMReX_REAL.H>
#include <AMReX_Array.H>
#include <ERF_Constants.H>
Include dependency graph for Microphysics_Utils.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 (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 (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)
68  {
69  amrex::Real const a0 = 0.503223089;
70  amrex::Real const a1 = 0.377174432e-1;
71  amrex::Real const a2 = 0.126710138e-2;
72  amrex::Real const a3 = 0.249065913e-4;
73  amrex::Real const a4 = 0.312668753e-6;
74  amrex::Real const a5 = 0.255653718e-8;
75  amrex::Real const a6 = 0.132073448e-10;
76  amrex::Real const a7 = 0.390204672e-13;
77  amrex::Real const a8 = 0.497275778e-16;
78 
79  amrex::Real dtt = t-273.16;
80  amrex::Real dtesati;
81  if(dtt > -80.0) {
82  dtesati = a0 + dtt*(a1+dtt*(a2+dtt*(a3+dtt*(a4+dtt*(a5+dtt*(a6+dtt*(a7+a8*dtt)))))));
83  }
84  else {
85  dtesati= erf_esati(t+1.0)-erf_esati(t);
86  }
87 
88  return dtesati;
89 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_esati(amrex::Real t)
Definition: Microphysics_Utils.H:21

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)
92  {
93  amrex::Real const a0 = 0.443956472;
94  amrex::Real const a1 = 0.285976452e-1;
95  amrex::Real const a2 = 0.794747212e-3;
96  amrex::Real const a3 = 0.121167162e-4;
97  amrex::Real const a4 = 0.103167413e-6;
98  amrex::Real const a5 = 0.385208005e-9;
99  amrex::Real const a6 = -0.604119582e-12;
100  amrex::Real const a7 = -0.792933209e-14;
101  amrex::Real const a8 = -0.599634321e-17;
102 
103  amrex::Real dtt = t-273.16;
104  amrex::Real dtesatw;
105  if(dtt > -80.0) {
106  dtesatw = a0 + dtt*(a1+dtt*(a2+dtt*(a3+dtt*(a4+dtt*(a5+dtt*(a6+dtt*(a7+a8*dtt)))))));
107  }
108  else {
109  dtesatw = erf_esatw(t+1.0)-erf_esatw(t);
110  }
111  return dtesatw;
112 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_esatw(amrex::Real t)
Definition: Microphysics_Utils.H:44

Referenced by erf_dtqsatw().

Here is the call graph for this function:
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 
)
129  {
130  dtqsati = Rd_on_Rv*erf_dtesati(t)/p;
131 }
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: Microphysics_Utils.H:68

Referenced by SAM::Cloud().

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 
)
134  {
135  dtqsatw = Rd_on_Rv*erf_dtesatw(t)/p;
136 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_dtesatw(amrex::Real t)
Definition: Microphysics_Utils.H:92

Referenced by SAM::Cloud().

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)
21  {
22  amrex::Real const a0 = 6.11147274;
23  amrex::Real const a1 = 0.503160820;
24  amrex::Real const a2 = 0.188439774e-1;
25  amrex::Real const a3 = 0.420895665e-3;
26  amrex::Real const a4 = 0.615021634e-5;
27  amrex::Real const a5 = 0.602588177e-7;
28  amrex::Real const a6 = 0.385852041e-9;
29  amrex::Real const a7 = 0.146898966e-11;
30  amrex::Real const a8 = 0.252751365e-14;
31 
32  amrex::Real dtt = t-273.16;
33  amrex::Real esati;
34  if(dtt > -80.0) {
35  esati = a0 + dtt*(a1+dtt*(a2+dtt*(a3+dtt*(a4+dtt*(a5+dtt*(a6+dtt*(a7+a8*dtt)))))));
36  }
37  else {
38  esati = 0.01*std::exp(9.550426 - 5723.265/t + 3.53068*std::log(t) - 0.00728332*t);
39  }
40  return esati;
41 }

Referenced by SAM::Compute_Coefficients(), erf_dtesati(), 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)
44  {
45  amrex::Real const a0 = 6.105851;
46  amrex::Real const a1 = 0.4440316;
47  amrex::Real const a2 = 0.1430341e-1;
48  amrex::Real const a3 = 0.2641412e-3;
49  amrex::Real const a4 = 0.2995057e-5;
50  amrex::Real const a5 = 0.2031998e-7;
51  amrex::Real const a6 = 0.6936113e-10;
52  amrex::Real const a7 = 0.2564861e-13;
53  amrex::Real const a8 = -0.3704404e-15;
54 
55  amrex::Real dtt = t-273.16;
56 
57  amrex::Real esatw;
58  if(dtt > -80.0) {
59  esatw = a0 + dtt*(a1+dtt*(a2+dtt*(a3+dtt*(a4+dtt*(a5+dtt*(a6+dtt*(a7+a8*dtt)))))));
60  }
61  else {
62  esatw = 2.0*0.01*std::exp(9.550426 - 5723.265/t + 3.53068*std::log(t) - 0.00728332*t);
63  }
64  return esatw;
65 }

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

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 
)
115  {
116  amrex::Real esati;
117  esati = erf_esati(t);
118  qsati = Rd_on_Rv*esati/std::max(esati,p-esati);
119 }

Referenced by SAM::Cloud(), 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 
)
122  {
123  amrex::Real esatw;
124  esatw = erf_esatw(t);
125  qsatw = Rd_on_Rv*esatw/std::max(esatw,p-esatw);
126 }

Referenced by Kessler::AdvanceKessler(), SAM::Cloud(), and SAM::Precip().

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)
188  {
189  return -std::min(0.0,y);
190 }

◆ 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 
)
167 {
168  amrex::Real term_vel = 0.0;
169  if(qploc > qp_threshold) {
170  amrex::Real omp = std::max(0.0,std::min(1.0,(tabs-tprmin)*a_pr));
171  amrex::Real omg = std::max(0.0,std::min(1.0,(tabs-tgrmin)*a_gr));
172  amrex::Real qrr = omp*qploc;
173  amrex::Real qss = (1.0-omp)*(1.0-omg)*qploc;
174  amrex::Real qgg = (1.0-omp)*(omg)*qploc;
175  term_vel = omp*vrain*std::pow(rho*qrr,crain)
176  + (1.0-omp)*( (1.0-omg)*vsnow*std::pow(rho*qss,csnow)
177  + omg *vgrau*std::pow(rho*qgg,cgrau) );
178  }
179  return term_vel;
180 }
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: Kessler.H:32
@ rho
Definition: 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 
)
139  {
140  amrex::Real vonk = 0.4;
141  amrex::Real eps = 1.0e-10;
142  amrex::Real am = 4.8;
143  amrex::Real bm = 19.3;
144  amrex::Real c1 = 3.14159/2.0 - 3.0*log(2.0);
145  amrex::Real rlmo = -bflx*vonk/(ustar*ustar*ustar+eps);
146  amrex::Real zeta = std::min(1.0,z*rlmo);
147  amrex::Real x;
148  amrex::Real psi1;
149  if(zeta >= 0.0) {
150  psi1 = -am*zeta;
151  }
152  else {
153  x = std::sqrt(sqrt(1.0-bm*zeta));
154  psi1 = 2.0*std::log(1.0+x) + std::log(1.0+x*x) -2.0*std::atan(x) + c1;
155  }
156  amrex::Real lnz = std::max(0.0, vonk*wnd/(ustar+eps) +psi1);
157  z0 = z*std::exp(-lnz);
158 }