ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
similarity_funs Struct Reference

#include <ERF_MOSTUtils.H>

Collaboration diagram for similarity_funs:

Public Member Functions

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real calc_psi_m2 (amrex::Real zeta) const
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real calc_psi_h2 (amrex::Real zeta) const
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real calc_psi_m (amrex::Real zeta) const
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real calc_psi_h (amrex::Real zeta) const
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real calc_phi_m (amrex::Real zeta) const
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real calc_phi_h (amrex::Real zeta) const
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real calc_zeta_fold (amrex::Real C) const
 
AMREX_GPU_HOST_DEVICE void set_stable_functions (bool use_qnse, amrex::Real am, amrex::Real bm, amrex::Real ah, amrex::Real bh)
 
AMREX_GPU_HOST_DEVICE bool uses_qnse () const
 

Static Private Member Functions

AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real qnse_psi (amrex::Real zeta, amrex::Real a, amrex::Real b)
 
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real qnse_phi (amrex::Real zeta, amrex::Real a, amrex::Real b)
 

Private Attributes

amrex::Real beta_m {amrex::Real(5.0)}
 Constants from Dyer, BLM, 1974. More...
 
amrex::Real beta_h {amrex::Real(5.0)}
 https://doi.org/amrex::Real(10.1007)/BF00240838 More...
 
amrex::Real gamma_m {amrex::Real(16.0)}
 
amrex::Real gamma_h {amrex::Real(16.0)}
 
bool m_qnse {false}
 stable side QNSE instead of Businger-Dyer More...
 
amrex::Real m_qnse_am {amrex::Real(2.5)}
 QNSE a_m (Sukoriansky et al. 2005) More...
 
amrex::Real m_qnse_bm {amrex::Real(0.2)}
 QNSE b_m. More...
 
amrex::Real m_qnse_ah {amrex::Real(2.5)}
 QNSE a_h. More...
 
amrex::Real m_qnse_bh {amrex::Real(0.2)}
 QNSE b_h. More...
 

Detailed Description

Structure of similarity functions for Moeng formulation.

The unstable side is Businger-Dyer. The stable side is Businger-Dyer (the default, phi = 1 + beta zeta, psi = -beta zeta) or, after set_stable_functions, the QNSE form phi = (1 + a zeta)/(1 + b zeta), psi = -((a - b)/b) ln(1 + b zeta) of Sukoriansky, Galperin and Perov (2005), with its own coefficients for momentum and heat (most.stable_functions, read by read_most_similarity_funs). The Jimenez (2012) pair (calc_psi_m2, calc_psi_h2) is not affected by the choice.

Member Function Documentation

◆ calc_phi_h()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real similarity_funs::calc_phi_h ( amrex::Real  zeta) const
inline

Compute the heat gradient function (Businger-Dyer, or QNSE on the stable side), the exact companion of calc_psi_h: dtheta/dz = theta_* phi_h(zeta) / (kappa z).

See the note in calc_phi_m about the Jimenez pair.

Parameters
[in]zetastability coordinate z/L
220  {
221  if (zeta > 0) {
222  return m_qnse ? qnse_phi(zeta, m_qnse_ah, m_qnse_bh) : one + beta_h * zeta;
223  } else {
224  return one / std::sqrt(one - gamma_h * zeta);
225  }
226  }
constexpr amrex::Real one
Definition: ERF_NumericalConstants.H:37
amrex::Real beta_h
https://doi.org/amrex::Real(10.1007)/BF00240838
Definition: ERF_MOSTUtils.H:356
amrex::Real m_qnse_bh
QNSE b_h.
Definition: ERF_MOSTUtils.H:363
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real qnse_phi(amrex::Real zeta, amrex::Real a, amrex::Real b)
Definition: ERF_MOSTUtils.H:350
amrex::Real gamma_h
Definition: ERF_MOSTUtils.H:358
amrex::Real m_qnse_ah
QNSE a_h.
Definition: ERF_MOSTUtils.H:362
bool m_qnse
stable side QNSE instead of Businger-Dyer
Definition: ERF_MOSTUtils.H:359

Referenced by ApplySurfaceLayerGradientsPBL().

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

◆ calc_phi_m()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real similarity_funs::calc_phi_m ( amrex::Real  zeta) const
inline

Compute the momentum gradient function (Businger-Dyer, or QNSE on the stable side).

This is the exact companion of calc_psi_m: the two are tied by psi_m(zeta) = int_0^zeta (1 - phi_m(x))/x dx, so differentiating the MOST wind profile u(z) = (u_star/kappa)[ln(z/z0) - psi_m(z/L)] gives du/dz = u_* phi_m(zeta) / (kappa z).

NOTE: the surface_temp* flux calculators use the Jimenez psi pair (calc_psi_m2/calc_psi_h2) rather than this one; their companions are not implemented yet, so a prescribed-surface-temperature run gets the Businger-Dyer gradient here.

Parameters
[in]zetastability coordinate z/L
200  {
201  if (zeta > 0) {
202  return m_qnse ? qnse_phi(zeta, m_qnse_am, m_qnse_bm) : one + beta_m * zeta;
203  } else {
204  return one / std::sqrt(std::sqrt(one - gamma_m * zeta));
205  }
206  }
amrex::Real beta_m
Constants from Dyer, BLM, 1974.
Definition: ERF_MOSTUtils.H:355
amrex::Real m_qnse_bm
QNSE b_m.
Definition: ERF_MOSTUtils.H:361
amrex::Real m_qnse_am
QNSE a_m (Sukoriansky et al. 2005)
Definition: ERF_MOSTUtils.H:360
amrex::Real gamma_m
Definition: ERF_MOSTUtils.H:357

Referenced by ApplySurfaceLayerGradientsPBL(), and ComputeQKESourceTerms().

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

◆ calc_psi_h()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real similarity_funs::calc_psi_h ( amrex::Real  zeta) const
inline

Compute the heat stability correction (Businger-Dyer, or QNSE on the stable side).

Parameters
[in]zetastability coordinate z/L
169  {
170  if (zeta > 0) {
171  return m_qnse ? qnse_psi(zeta, m_qnse_ah, m_qnse_bh) : -beta_h * zeta;
172  } else {
173  amrex::Real x = std::sqrt(one - gamma_h * zeta);
174  return two * std::log(myhalf * (one + x));
175  }
176  }
constexpr amrex::Real two
Definition: ERF_NumericalConstants.H:38
constexpr amrex::Real myhalf
Definition: ERF_NumericalConstants.H:41
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real qnse_psi(amrex::Real zeta, amrex::Real a, amrex::Real b)
Definition: ERF_MOSTUtils.H:341

Referenced by compute_if_most_target_vel(), ImmersedForcingBuildings_Scalar(), ImmersedForcingTerrain_Scalar(), ImmersedForcingTerrain_Xmom(), ImmersedForcingTerrain_Ymom(), surface_flux_charnock::iterate_flux(), surface_flux_mod_charnock::iterate_flux(), surface_flux_donelan::iterate_flux(), surface_flux_wave_coupled::iterate_flux(), surface_flux::iterate_flux(), surface_flux_eb::iterate_flux(), and ib_wall::wall_state().

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

◆ calc_psi_h2()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real similarity_funs::calc_psi_h2 ( amrex::Real  zeta) const
inline

Compute the Jimenez heat stability correction.

Parameters
[in]zetastability coordinate z/L
122  {
123  if (zeta > 0) {
124  amrex::Real x = std::pow(one + std::pow(zeta, amrex::Real(1.1)), one/amrex::Real(1.1));
125  return ( -amrex::Real(5.3)*std::log(zeta + x) );
126  } else {
127  amrex::Real x = std::sqrt(one - amrex::Real(16.0)*zeta);
128  amrex::Real psi_k_h = two * std::log(myhalf * (one + x));
129  amrex::Real y = std::pow(one - amrex::Real(34.0)*zeta, one/three);
130  amrex::Real psi_c_h = (three/two)*std::log((y*y + y + one)/three)
131  - std::sqrt(three)*std::atan((two*y + one)/std::sqrt(three))
132  + PI/std::sqrt(three);
133  return ( (psi_k_h + zeta*zeta*psi_c_h) / (one + zeta*zeta) );
134  }
135  }
constexpr amrex::Real three
Definition: ERF_NumericalConstants.H:39
constexpr amrex::Real PI
Definition: ERF_NumericalConstants.H:46

Referenced by surface_temp_charnock::iterate_flux(), surface_temp_mod_charnock::iterate_flux(), surface_temp_donelan::iterate_flux(), surface_temp_wave_coupled::iterate_flux(), surface_temp::iterate_flux(), surface_temp_eb::iterate_flux(), most_rib_resid(), erf_cloud_chamber_wall_flux::most_stability_coordinate(), erf_cloud_chamber_wall_flux::most_wall_coefficients(), and erf_surface_moisture::surface_layer_aerodynamic_resistance().

Here is the caller graph for this function:

◆ calc_psi_m()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real similarity_funs::calc_psi_m ( amrex::Real  zeta) const
inline

Compute the momentum stability correction (Businger-Dyer, or QNSE on the stable side).

Parameters
[in]zetastability coordinate z/L
150  {
151  if (zeta > 0) {
152  return m_qnse ? qnse_psi(zeta, m_qnse_am, m_qnse_bm) : -beta_m * zeta;
153  } else {
154  amrex::Real x = std::sqrt(std::sqrt(one - gamma_m * zeta));
155  return two * std::log(myhalf * (one + x)) + std::log(myhalf * (one + x * x)) -
156  two * std::atan(x) + PIoTwo;
157  }
158  }
constexpr amrex::Real PIoTwo
Definition: ERF_NumericalConstants.H:47

Referenced by compute_if_most_target_vel(), ImmersedForcingBuildings_Scalar(), ImmersedForcingTerrain_Scalar(), ImmersedForcingTerrain_Xmom(), ImmersedForcingTerrain_Ymom(), surface_flux_charnock::iterate_flux(), surface_flux_mod_charnock::iterate_flux(), surface_flux_donelan::iterate_flux(), surface_flux_wave_coupled::iterate_flux(), surface_flux::iterate_flux(), surface_flux_eb::iterate_flux(), and ib_wall::wall_state().

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

◆ calc_psi_m2()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real similarity_funs::calc_psi_m2 ( amrex::Real  zeta) const
inline

Compute the Jimenez momentum stability correction.

Parameters
[in]zetastability coordinate z/L
97  {
98  if (zeta > 0) {
99  amrex::Real x = std::pow(one + std::pow(zeta, amrex::Real(2.5)), one/amrex::Real(2.5));
100  return ( -amrex::Real(6.1)*std::log(zeta + x) );
101  } else {
102  amrex::Real x = std::pow(one - amrex::Real(16.0)*zeta, fourth);
103  amrex::Real psi_k_m = two * std::log(myhalf * (one + x)) + std::log(myhalf * (one + x * x)) -
104  two * std::atan(x) + PIoTwo;
105  amrex::Real y = std::pow(one - amrex::Real(10.0)*zeta, one/three);
106  amrex::Real psi_c_m = (three/two)*std::log((y*y + y + one)/three)
107  - std::sqrt(three)*std::atan((two*y + one)/std::sqrt(three))
108  + PI/std::sqrt(three);
109  return ( (psi_k_m + zeta*zeta*psi_c_m) / (one + zeta*zeta) );
110  }
111  }
constexpr amrex::Real fourth
Definition: ERF_NumericalConstants.H:42

Referenced by Compute_roughness(), surface_temp_charnock::iterate_flux(), surface_temp_mod_charnock::iterate_flux(), surface_temp_donelan::iterate_flux(), surface_temp_wave_coupled::iterate_flux(), surface_temp::iterate_flux(), surface_temp_eb::iterate_flux(), most_rib_resid(), erf_cloud_chamber_wall_flux::most_stability_coordinate(), and erf_cloud_chamber_wall_flux::most_wall_coefficients().

Here is the caller graph for this function:

◆ calc_zeta_fold()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real similarity_funs::calc_zeta_fold ( amrex::Real  C) const
inline

Stable z/L at which the prescribed-flux problem folds.

With L fixed by u* and the flux, the wind a given u* supports is u* max(C - psi_m, b) / kappa, with b = most_bracket_floor(C). Below the smallest such wind the prescribed stable flux has no solution with z/L below most_zeta_lim (Basu et al., BLM 2008; with QNSE the supported wind rises again past its first minimum to a local maximum at the second zero of f below, at z/L of order 1e3 to 1e4, and only then tends to zero with u*; the kernels never reach that range). The physical (large u*) branch has z/L below this value, so bounding z/L by it leaves every point that has a solution unchanged. The result is positive for every C.

Businger-Dyer (psi_m = -beta_m z/L): for C > 0 the minimum is at z/L = C / (2 beta_m); for small or negative C (z0 near or above zref) the floor binds first and the minimum is at the kink z/L = (b - C) / beta_m.

QNSE (psi_m = -c ln(1 + b_m z/L), c = (a_m - b_m)/b_m): with u* proportional to (z/L)^(-1/3), the supported wind falls with z/L while f(z/L) = C + c ln(1 + b_m z/L) - 3 c b_m (z/L) / (1 + b_m z/L) is positive, and f falls from C at z/L = 0 to its minimum at z/L = 2 / b_m and rises without bound after it. The fold is the first zero of f beyond the kink where the floor stops binding (C - psi_m = b), found by Newton's method on the bracket [kink, 2 / b_m] where f is convex and decreasing (f' = c b_m (b_m z/L - 2) / (1 + b_m z/L)^2 < 0, f'' > 0 for b_m z/L < 5): after the first step the iterates approach the root from the left, a step that would leave the bracket is replaced by its midpoint, and the iteration stops at a relative change of 1e-10 (a handful of steps against the 60 passes of a bisection to the same precision; the roughness kernels call this once per u* iteration). It is the kink itself when f is already negative there, and most_zeta_lim when f has no zero (C > c (2 - ln 3), 10.4 with the default coefficients): the wind then falls monotonically with z/L up to the bound, where the kernels hold z/L and reduce the flux as at a fold. Every return value is at most most_zeta_lim.

Parameters
[in]Cln(zref/z0)
266  {
267  if (!m_qnse) {
268  return amrex::max(C / (two * beta_m), (most_bracket_floor(C) - C) / beta_m);
269  }
270  // A non-finite C (bad zref or z0) is returned as it is, as most_rib_zeta_bracketed does,
271  // so that it shows up in the kernel's results instead of a bisection artifact
272  if (!amrex::Math::isfinite(C)) { return C; }
273  const amrex::Real b = m_qnse_bm;
274  const amrex::Real c = (m_qnse_am - m_qnse_bm) / m_qnse_bm;
275  if (c <= zero) { return most_zeta_lim; } // a_m <= b_m is refused by the reader; psi_m = 0 would have no fold
276  const amrex::Real bf = most_bracket_floor(C);
277  amrex::Real lo = (C < bf) ? (std::exp((bf - C) / c) - one) / b : zero;
278  auto f = [&] (amrex::Real z) {
279  const amrex::Real s = one + b * z;
280  return C + c * std::log(s) - three * c * b * z / s;
281  };
282  auto df = [&] (amrex::Real z) {
283  const amrex::Real s = one + b * z;
284  return c * b * (b * z - two) / (s * s);
285  };
286  const amrex::Real zlim = most_zeta_lim; // by value: a namespace constant must not bind to min's reference in device code
287  if (f(lo) <= zero) { return amrex::min(lo, zlim); }
288  amrex::Real hi = two / b;
289  if (lo >= hi || f(hi) >= zero) { return zlim; }
290  // Safeguarded Newton on [lo, hi]: f(lo) > 0 > f(hi), f convex and decreasing, so from
291  // the second step on the iterates rise monotonically to the root; a step outside the
292  // bracket (the first one can be, from the midpoint) falls back to the midpoint
293  amrex::Real z = myhalf * (lo + hi);
294  constexpr amrex::Real rtol = amrex::Real(1.0e-10);
295  for (int n = 0; n < 30; ++n) {
296  const amrex::Real fz = f(z);
297  if (fz > zero) { lo = z; } else if (fz < zero) { hi = z; } else { break; }
298  const amrex::Real d = df(z);
299  amrex::Real zn = (d < zero) ? z - fz / d : myhalf * (lo + hi);
300  if (!(zn > lo && zn < hi)) { zn = myhalf * (lo + hi); }
301  const bool done = std::abs(zn - z) <= rtol * zn;
302  z = zn;
303  if (done) { break; }
304  }
305  return amrex::min(z, zlim);
306  }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real most_bracket_floor(amrex::Real C)
Definition: ERF_MOSTUtils.H:61
constexpr amrex::Real most_zeta_lim
Definition: ERF_MOSTUtils.H:71
constexpr amrex::Real zero
Definition: ERF_NumericalConstants.H:36

Referenced by surface_flux_charnock::iterate_flux(), surface_flux_mod_charnock::iterate_flux(), surface_flux_donelan::iterate_flux(), surface_flux_wave_coupled::iterate_flux(), surface_flux::iterate_flux(), and surface_flux_eb::iterate_flux().

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

◆ qnse_phi()

AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real similarity_funs::qnse_phi ( amrex::Real  zeta,
amrex::Real  a,
amrex::Real  b 
)
inlinestaticprivate

QNSE gradient function, phi = (1 + a zeta)/(1 + b zeta), zeta > 0.

351  {
352  return (one + a * zeta) / (one + b * zeta);
353  }

Referenced by calc_phi_h(), and calc_phi_m().

Here is the caller graph for this function:

◆ qnse_psi()

AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real similarity_funs::qnse_psi ( amrex::Real  zeta,
amrex::Real  a,
amrex::Real  b 
)
inlinestaticprivate

QNSE integrated function, psi = -((a - b)/b) ln(1 + b zeta), zeta > 0.

342  {
343  return -((a - b) / b) * std::log(one + b * zeta);
344  }

Referenced by calc_psi_h(), and calc_psi_m().

Here is the caller graph for this function:

◆ set_stable_functions()

AMREX_GPU_HOST_DEVICE void similarity_funs::set_stable_functions ( bool  use_qnse,
amrex::Real  am,
amrex::Real  bm,
amrex::Real  ah,
amrex::Real  bh 
)
inline

Select the QNSE stable-side functions phi = (1 + a zeta)/(1 + b zeta) for momentum (a_m, b_m) and heat (a_h, b_h), or return to Businger-Dyer (use_qnse false, the coefficients then unused). read_most_similarity_funs checks the inputs: b_m, b_h > 0 and a_m > b_m, a_h > b_h.

Parameters
[in]use_qnsewhether the stable side is QNSE
[in]ama_m
[in]bmb_m
[in]aha_h
[in]bhb_h
324  {
325  m_qnse = use_qnse;
326  m_qnse_am = am;
327  m_qnse_bm = bm;
328  m_qnse_ah = ah;
329  m_qnse_bh = bh;
330  }

Referenced by read_most_similarity_funs().

Here is the caller graph for this function:

◆ uses_qnse()

AMREX_GPU_HOST_DEVICE bool similarity_funs::uses_qnse ( ) const
inline

Whether the stable side is QNSE.

334 { return m_qnse; }

Referenced by SurfaceLayer::check_similarity_funs_use().

Here is the caller graph for this function:

Member Data Documentation

◆ beta_h

amrex::Real similarity_funs::beta_h {amrex::Real(5.0)}
private

◆ beta_m

amrex::Real similarity_funs::beta_m {amrex::Real(5.0)}
private

Constants from Dyer, BLM, 1974.

Referenced by calc_phi_m(), calc_psi_m(), and calc_zeta_fold().

◆ gamma_h

amrex::Real similarity_funs::gamma_h {amrex::Real(16.0)}
private

Referenced by calc_phi_h(), and calc_psi_h().

◆ gamma_m

amrex::Real similarity_funs::gamma_m {amrex::Real(16.0)}
private

Referenced by calc_phi_m(), and calc_psi_m().

◆ m_qnse

bool similarity_funs::m_qnse {false}
private

stable side QNSE instead of Businger-Dyer

Referenced by calc_phi_h(), calc_phi_m(), calc_psi_h(), calc_psi_m(), calc_zeta_fold(), set_stable_functions(), and uses_qnse().

◆ m_qnse_ah

amrex::Real similarity_funs::m_qnse_ah {amrex::Real(2.5)}
private

QNSE a_h.

Referenced by calc_phi_h(), calc_psi_h(), and set_stable_functions().

◆ m_qnse_am

amrex::Real similarity_funs::m_qnse_am {amrex::Real(2.5)}
private

QNSE a_m (Sukoriansky et al. 2005)

Referenced by calc_phi_m(), calc_psi_m(), calc_zeta_fold(), and set_stable_functions().

◆ m_qnse_bh

amrex::Real similarity_funs::m_qnse_bh {amrex::Real(0.2)}
private

QNSE b_h.

Referenced by calc_phi_h(), calc_psi_h(), and set_stable_functions().

◆ m_qnse_bm

amrex::Real similarity_funs::m_qnse_bm {amrex::Real(0.2)}
private

The documentation for this struct was generated from the following file: