ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_Wstar.H
Go to the documentation of this file.
1 #ifndef ERF_UTILS_WSTAR_H_
2 #define ERF_UTILS_WSTAR_H_
3 
4 #include <ERF_Constants.H>
5 
6 /*
7  * Whether a PBL height has actually been diagnosed. The SurfaceLayer's pblh holds
8  * bogus_large_value until a scheme writes one: on the first call to update_fluxes, on a
9  * level that was just made or regridded, and in any cell no scheme reaches. A w* built
10  * from that is ~1e50 and destroys the surface fluxes, so we take w* = 0 there instead.
11  */
12 AMREX_GPU_HOST_DEVICE
13 AMREX_FORCE_INLINE
14 bool
16 {
17  return pblh < amrex::Real(0.5) * bogus_large_value;
18 }
19 
20 /*
21  * Calculate the convective velocity scale
22  */
23 
24 AMREX_GPU_HOST_DEVICE
25 AMREX_FORCE_INLINE
27 calc_wstar (const amrex::Real& ust,
28  const amrex::Real& tst,
29  const amrex::Real& qst,
30  const amrex::Real& pblh,
31  const amrex::Real& th,
32  const amrex::Real& thv,
33  const amrex::Real& qv = amrex::Real(0))
34 {
35  amrex::Real hfx = -ust*tst; // <theta'w'>
36  if (hfx <= 0 || !pblh_is_diagnosed(pblh)) {
37  return amrex::Real(0);
38  }
39  if (qv > 0) {
40  // have moisture -- estimate buoyancy flux, <thetav'w'> (Stull 4.4.5d)
41  hfx = hfx*(one + epsv*qv) + epsv*th*(-ust*qst);
42  }
43  return std::cbrt(CONST_GRAV / thv * pblh * hfx);
44 }
45 
46 /**
47  * Calculate the convective velocity scale from buoyancy flux.
48  *
49  * @param[in] hfx Buoyancy flux.
50  * @param[in] pblh PBL height.
51  * @param[in] thv Virtual potential temperature.
52  * @return Convective velocity scale.
53  */
54 AMREX_GPU_HOST_DEVICE
55 AMREX_FORCE_INLINE
57 calc_wstar (const amrex::Real& hfx,
58  const amrex::Real& pblh,
59  const amrex::Real& thv)
60 {
61  if (hfx <= 0 || !pblh_is_diagnosed(pblh)) {
62  return amrex::Real(0);
63  } else {
64  return std::cbrt(CONST_GRAV / thv * pblh * hfx);
65  }
66 }
67 #endif
constexpr amrex::Real epsv
Definition: ERF_Constants.H:56
constexpr amrex::Real bogus_large_value
Definition: ERF_Constants.H:19
constexpr amrex::Real CONST_GRAV
Definition: ERF_Constants.H:72
constexpr amrex::Real one
Definition: ERF_NumericalConstants.H:37
amrex::Real Real
Definition: ERF_ShocInterface.H:19
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool pblh_is_diagnosed(const amrex::Real &pblh)
Definition: ERF_Wstar.H:15
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real calc_wstar(const amrex::Real &ust, const amrex::Real &tst, const amrex::Real &qst, const amrex::Real &pblh, const amrex::Real &th, const amrex::Real &thv, const amrex::Real &qv=amrex::Real(0))
Definition: ERF_Wstar.H:27
@ qv
Definition: ERF_Kessler.H:31