ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_TurbStruct.H
Go to the documentation of this file.
1 #ifndef ERF_TURB_STRUCT_H_
2 #define ERF_TURB_STRUCT_H_
3 
4 #include <AMReX_ParallelDescriptor.H>
5 #include <ERF_MYNNStruct.H>
6 #include <ERF_RANSClosure.H>
7 
8 #include <iomanip>
9 #include <sstream>
10 
11 /**
12  * @brief Large-eddy simulation closure type.
13  */
14 AMREX_ENUM(LESType, None, Smagorinsky, Smagorinsky2D, Deardorff);
15 
16 /**
17  * @brief Reynolds-averaged turbulence closure type.
18  */
19 AMREX_ENUM(RANSType, None, kEqn);
20 
21 // Vertical shear in the strain invariant of the k-eqn RANS closure (erf.rans_shear_stencil):
22 // central (average of the face strains) or log_law (exact for a logarithmic profile)
23 AMREX_ENUM(RANSShearStencil,
24  central, log_law
25 );
26 
27 /**
28  * @brief Planetary boundary-layer closure type.
29  *
30  * YSUNew, SHOC and EAMXX_SHOC are input names only: TurbChoice::init_params maps YSUNew to
31  * YSU and SHOC to NATIVE_SHOC, and stops for EAMXX_SHOC, which is no longer available, so no
32  * other code sees them.
33  */
34 AMREX_ENUM(PBLType, None, MYJ, MYNN25, MYNNEDMF, YSU, YSUNew, MRF, SHOC, EAMXX_SHOC, NATIVE_SHOC);
35 
36 /**
37  * @brief Thermodynamic variable used for stability stratification.
38  */
39 AMREX_ENUM(StratType, theta, thetav, thetal);
40 
41 /**
42  * @brief Query a scalar or per-level input value.
43  * @tparam T Value type accepted by ParmParse::query.
44  * @param pp ParmParse object to query.
45  * @param query_string Input key to query.
46  * @param query_var Destination value for the requested level.
47  * @param lev AMR level index.
48  * @param maxlev Maximum AMR level configured for the run.
49  * @return ParmParse query result, or zero if the key is absent.
50  */
51 template <typename T>
52 int
54  const amrex::ParmParse& pp,
55  const char* query_string,
56  T& query_var,
57  const int lev,
58  const int maxlev)
59 {
60  int count = pp.countval(query_string);
61  if (count == 0) {
62  return 0; // nothing to do
63  } else if (count == 1) {
64  // In this case, we assume the same value is used at every level
65  return pp.query(query_string, query_var);
66  } else if (count >= maxlev + 1) {
67  // In this case, there may be more values than levels so we
68  // will just read the number of values we need and ignore the
69  // extra levels
70  return pp.query(query_string, query_var, lev);
71  } else {
72  // In this case, there is more than one value AND there
73  // are more levels than values; as an example, if max_level = 2
74  // but count = 2 so we have three levels but only two values --
75  // it is not clear how to interpret this so we abort
76  amrex::Error(
77  "For parmparse variable " + pp.prefixedName(query_string) +
78  ": if specified, specify once total or at least once for each level");
79  return 0; // avoid compiler warning
80  }
81 }
82 
83 /**
84  * @brief Query a scalar or per-level enum input value using case-insensitive matching.
85  * @tparam T Enum type accepted by ParmParse::query_enum_case_insensitive.
86  * @param pp ParmParse object to query.
87  * @param query_string Input key to query.
88  * @param query_var Destination enum value for the requested level.
89  * @param lev AMR level index.
90  * @param maxlev Maximum AMR level configured for the run.
91  * @return ParmParse query result, or zero if the key is absent.
92  */
93 template <typename T>
94 int
96  const amrex::ParmParse& pp,
97  const char* query_string,
98  T& query_var,
99  const int lev,
100  const int maxlev)
101 {
102  int count = pp.countval(query_string);
103  if (count == 0) {
104  return 0; // nothing to do
105  } else if (count == 1) {
106  // In this case, we assume the same value is used at every level
107  return pp.query_enum_case_insensitive(query_string, query_var);
108  } else if (count >= maxlev + 1) {
109  // In this case, there may be more values than levels so we
110  // will just read the number of values we need and ignore the
111  // extra levels
112  return pp.query_enum_case_insensitive(query_string, query_var, lev);
113  } else {
114  // In this case, there is more than one value AND there
115  // are more levels than values; as an example, if max_level = 2
116  // but count = 2 so we have three levels but only two values --
117  // it is not clear how to interpret this so we abort
118  amrex::Error(
119  "For parmparse variable " + pp.prefixedName(query_string) +
120  ": if specified, specify once total or at least once for each level");
121  return 0; // avoid compiler warning
122  }
123 }
124 
125 /**
126  * Container holding quantities related to turbulence parametrizations
127  */
129 {
130 public:
131  /**
132  * @brief Read turbulence options for one AMR level from the input parameter database.
133  * @param lev AMR level index.
134  * @param max_level Maximum AMR level configured for the run.
135  * @param pp_prefix ParmParse prefix for the ERF input namespace.
136  */
137  void init_params (int lev, int max_level, std::string pp_prefix)
138  {
139  amrex::ParmParse pp(pp_prefix);
140 
141  // Which LES closure?
142  query_one_or_per_level(pp, "les_type", les_type, lev, max_level);
143  // Immersed-boundary awareness of the MRF and YSU schemes (off by default):
144  // the surface of a column with immersed solid cells is the first fluid cell
145  // above them, heights and the boundary-layer depth are measured from it,
146  // the eddy diffusivities are zero inside the solid, and the surface
147  // scales over such a column come from a neutral log law at its top with
148  // the roughness pbl_ib_z0. Only MRF and YSU honor it.
149  query_one_or_per_level(pp, "pbl_ib_aware", pbl_ib_aware, lev, max_level);
150  query_one_or_per_level(pp, "pbl_ib_z0", pbl_ib_z0, lev, max_level);
151 
152  // Handle 2-D Smag
153  if (les_type == LESType::Smagorinsky2D) {
154  les_type = LESType::Smagorinsky;
155  smag2d = true;
156  }
157 
158  // Which RANS closure?
159  query_one_or_per_level(pp, "rans_type", rans_type, lev, max_level);
160 
161  if ((rans_type != RANSType::None) && (les_type != LESType::None)) {
162  amrex::Error("Hybrid RANS-LES not implemented");
163  }
164 
165  // Which PBL Closure
166  query_one_or_per_level_enum_case_insensitive(pp, "pbl_type", pbl_type, lev, max_level);
167  // SHOC used to select the EAMxx SHOC, which has been removed; it now selects native SHOC
168  if (pbl_type == PBLType::SHOC) {
169  static bool warned_legacy_shoc = false;
170  if (!warned_legacy_shoc && amrex::ParallelDescriptor::IOProcessor()) {
171  amrex::Warning("erf.pbl_type = SHOC now selects the native SHOC (erf.pbl_type = NATIVE_SHOC); "
172  "it used to select the EAMxx SHOC, which has been removed");
173  }
174  warned_legacy_shoc = true;
175  pbl_type = PBLType::NATIVE_SHOC;
176  }
177  if (pbl_type == PBLType::EAMXX_SHOC) {
178  amrex::Abort("erf.pbl_type = EAMXX_SHOC is no longer available: the EAMxx SHOC has been "
179  "removed; use erf.pbl_type = NATIVE_SHOC");
180  }
181  // The former YSUNew is now the only YSU; the name is still accepted
182  if (pbl_type == PBLType::YSUNew) {
183  static bool warned_ysunew = false;
184  if (!warned_ysunew && amrex::ParallelDescriptor::IOProcessor()) {
185  amrex::Warning("erf.pbl_type = YSUNew is deprecated; it is now erf.pbl_type = YSU");
186  }
187  warned_ysunew = true;
188  pbl_type = PBLType::YSU;
189  }
190 
191  // Do some more stuff for PBL Modeling
192  if (pbl_type != PBLType::None) {
193  // Check for compatibility between PBL, LES, Molec Transport
194  if (les_type != LESType::None) {
195  amrex::Print() << "Selected a PBL model and an LES model: "
196  << "Using PBL for vertical transport, LES for horizontal"
197  << std::endl;
198  }
199  if (les_type == LESType::Smagorinsky) {
200  if (!smag2d)
201  amrex::Error("If using Smagorinsky with a PBL model, the 2-D "
202  "formulation should be used");
203  } else if (les_type == LESType::Deardorff) {
204  amrex::Error(
205  "It is not recommended to use Deardorff LES and a PBL model");
206  }
207  // Both the k-eqn RANS closure and these PBL schemes transport RhoKE
208  if ((rans_type == RANSType::kEqn) &&
209  ((pbl_type == PBLType::MYJ) || (pbl_type == PBLType::MYNN25) ||
210  (pbl_type == PBLType::MYNNEDMF) || uses_shoc_family())) {
211  amrex::Error("erf.rans_type = kEqn cannot be combined with erf.pbl_type = " +
212  std::string(amrex::getEnumNameString(pbl_type)) +
213  ": both transport the turbulent kinetic energy");
214  }
215 
216  if (pbl_type == PBLType::MYNN25 || pbl_type == PBLType::MYNNEDMF) {
217  // NN09 (the default) uses Lt_alpha = 0.23 and a 1/l sum for the master
218  // length scale; Chen2021 uses Lt_alpha = 0.10 and a 1/l^2 sum.
220  pp, "pbl_mynn_config", pbl_mynn.config, lev, max_level);
221  // l_T = Lt_alpha*<zq>/<q> follows the config unless set explicitly.
222  pbl_mynn.Lt_alpha = (pbl_mynn.config == MYNNConfigType::Chen2021)
223  ? amrex::Real(0.1) : amrex::Real(0.23);
225  pp, "pbl_mynn_Lt_alpha", pbl_mynn.Lt_alpha, lev, max_level);
226  query_one_or_per_level(pp, "pbl_mynn_A1", pbl_mynn.A1, lev, max_level);
227  query_one_or_per_level(pp, "pbl_mynn_A2", pbl_mynn.A2, lev, max_level);
228  query_one_or_per_level(pp, "pbl_mynn_B1", pbl_mynn.B1, lev, max_level);
229  query_one_or_per_level(pp, "pbl_mynn_B2", pbl_mynn.B2, lev, max_level);
230  query_one_or_per_level(pp, "pbl_mynn_C1", pbl_mynn.C1, lev, max_level);
231  query_one_or_per_level(pp, "pbl_mynn_C2", pbl_mynn.C2, lev, max_level);
232  query_one_or_per_level(pp, "pbl_mynn_C3", pbl_mynn.C3, lev, max_level);
233  query_one_or_per_level(pp, "pbl_mynn_C4", pbl_mynn.C4, lev, max_level);
234  query_one_or_per_level(pp, "pbl_mynn_C5", pbl_mynn.C5, lev, max_level);
238  // Moisture is now always diffused by MYNN, as it is by every other
239  // PBL scheme; catch the retired flag rather than ignoring it silently.
240  if (pp.contains("pbl_mynn_diffuse_moistvars")) {
241  amrex::Abort("erf.pbl_mynn_diffuse_moistvars has been removed. "
242  "MYNN always diffuses the moisture variables now, as "
243  "MYJ, YSU, MRF and SHOC always have; there is no "
244  "longer a way to turn it off.");
245  }
247  pp, "pbl_mynn_SMmin", pbl_mynn.SMmin, lev, max_level);
249  pp, "pbl_mynn_SMmax", pbl_mynn.SMmax, lev, max_level);
251  pp, "pbl_mynn_SHmin", pbl_mynn.SHmin, lev, max_level);
253  pp, "pbl_mynn_SHmax", pbl_mynn.SHmax, lev, max_level);
255  pp, "pbl_mynn_SQfactor", pbl_mynn.SQfac, lev, max_level);
256 
257  // SQ = SQfac*SM, so its bound is tied to SHmax and SQfac; the default member
258  // initializer was evaluated before either could be overridden here.
260 
261  // Surface-layer length scale alone in the first cell (see MYNNLevel25::surface_lm).
263  pp, "pbl_mynn_surface_lm", pbl_mynn.surface_lm, lev, max_level);
264  if (pbl_mynn.surface_lm && pbl_type != PBLType::MYNN25) {
265  amrex::Abort("erf.pbl_mynn_surface_lm is only implemented for erf.pbl_type = MYNN25");
266  }
267 
268  } else if (pbl_type == PBLType::YSU) {
270  pp, "pbl_ysu_coriolis_freq", pbl_ysu_coriolis_freq, lev, max_level);
272  pp, "pbl_ysu_use_consistent_coriolis",
273  pbl_ysu_use_consistent_coriolis, lev, max_level);
275  pp, "pbl_ysu_land_Ribcr", pbl_ysu_land_Ribcr, lev, max_level);
276  // Only the YSU that the former YSUNew replaced read these; catch them rather
277  // than ignoring them silently.
278  for (const char* removed : {"pbl_ysu_force_over_water", "pbl_ysu_unst_Ribcr"}) {
279  if (pp.contains(removed)) {
280  amrex::Abort(std::string("erf.") + removed + " has been removed along with "
281  "the original YSU scheme; erf.pbl_type = YSU (formerly YSUNew) "
282  "does not use it.");
283  }
284  }
285  // YSU now uses theta_v at WRF's thvx sites and theta_l at its thlix
286  // sites; catch the retired switch between them rather than ignoring it.
287  if (pp.contains("enable_ysu_liquid_theta")) {
288  amrex::Abort("erf.enable_ysu_liquid_theta has been removed. YSU uses "
289  "theta_v (all condensate loading) for the bulk Richardson "
290  "number and clear-sky entrainment, and theta_l (cloud "
291  "liquid and ice) for the cloud-top extension scan and "
292  "cloudy entrainment, as WRF does with thvx and thlix.");
293  }
295  pp, "enable_ysu_countergradient", enable_ysu_countergradient, lev, max_level);
296  // The floor of the YSU PBL height is the top face of the first cell on
297  // every mesh type. This switch selected it on terrain-fitted and
298  // stretched meshes (its default); constant-dz meshes, where the floor was
299  // the first cell center, now use it too (erf-model/ERF#5252). Catch the
300  // retired switch rather than ignoring it.
301  if (pp.contains("enable_ysu_terrain_pblh_floor")) {
302  amrex::Abort("erf.enable_ysu_terrain_pblh_floor has been removed. The floor "
303  "of the YSU PBL height is the top face of the first cell (at "
304  "least 10 m) on every mesh type (erf-model/ERF#5252).");
305  }
307  pp, "enable_ysu_sat_limiter", enable_ysu_sat_limiter, lev, max_level);
309  pp, "enable_ysu_topdown", enable_ysu_topdown, lev, max_level);
311  pp, "enable_ysu_entrainment", enable_ysu_entrainment, lev, max_level);
313  pp, "enable_ysu_cloud_pblh", enable_ysu_cloud_pblh, lev, max_level);
315  pp, "enable_mrf_unbounded_vpert", enable_mrf_unbounded_vpert, lev, max_level);
317  pp, "ysu_qcloud_threshold", ysu_qcloud_threshold, lev, max_level);
318  // A negative threshold would count every cell as cloudy, clear air included
320  "erf.ysu_qcloud_threshold must not be negative");
322  pp, "ysu_moistvars", ysu_moistvars, lev, max_level);
324  pp, "pbl_ysunew_highres_bounds", pbl_ysunew_highres_bounds, lev, max_level);
325  // Radiative tendency limiter (YSU only)
327  pp, "enable_ysu_rad_tend_limiter", enable_ysu_rad_tend_limiter, lev, max_level);
329  pp, "ysu_rad_tend_limiter_magnitude", ysu_rad_tend_limiter_magnitude, lev, max_level);
330  if (!(ysu_rad_tend_limiter_magnitude > 0.0)) {
331  if (amrex::ParallelDescriptor::IOProcessor()) {
332  amrex::Print() << "WARNING: erf.ysu_rad_tend_limiter_magnitude = "
334  << " is not positive; using the default of 1.0 K/s\n";
335  }
336  ysu_rad_tend_limiter_magnitude = amrex::Real(1.0);
337  }
338  // Vogelezang & Holtslag (1996) shear correction
340  pp, "enable_vh96_shear_correction", enable_vh96_shear_correction, lev, max_level);
342  pp, "vh96_shear_const_b", vh96_shear_const_b, lev, max_level);
343  // PBLH spatial smoothing
345  pp, "enable_pblh_smoothing", enable_pblh_smoothing, lev, max_level);
347  pp, "pblh_smoothing_passes", pblh_smoothing_passes, lev, max_level);
349  pp, "pblh_smoothing_weight", pblh_smoothing_weight, lev, max_level);
350  // Validate pblh_smoothing_weight is in [0,1]
351  if (enable_pblh_smoothing && (pblh_smoothing_weight < 0 || pblh_smoothing_weight > 1)) {
352  amrex::Error("pblh_smoothing_weight must be in [0, 1]");
353  }
354  // QNSE stable stability functions (Sukoriansky et al. 2005)
356  pp, "enable_qnse_stable_functions", enable_qnse_stable_functions, lev, max_level);
358  pp, "qnse_am", qnse_am, lev, max_level);
360  pp, "qnse_bm", qnse_bm, lev, max_level);
362  pp, "qnse_ah", qnse_ah, lev, max_level);
364  pp, "qnse_bh", qnse_bh, lev, max_level);
365  } else if (pbl_type == PBLType::MRF) {
367  pp, "pbl_mrf_coriolis_freq", pbl_mrf_coriolis_freq, lev, max_level);
369  pp, "pbl_mrf_Ribcr", pbl_mrf_Ribcr, lev, max_level);
371  pp, "pbl_mrf_const_b", pbl_mrf_const_b, lev, max_level);
372  query_one_or_per_level(pp, "pbl_mrf_sf", pbl_mrf_sf, lev, max_level);
374  pp, "enable_mrf_countergradient", enable_mrf_countergradient, lev, max_level);
376  pp, "enable_mrf_cloud_adjustment", enable_mrf_cloud_adjustment, lev, max_level);
378  pp, "pbl_mrf_highres_bounds", pbl_mrf_highres_bounds, lev, max_level);
379  query_one_or_per_level(pp, "pbl_mrf_Sc_t", pbl_mrf_Sc_t, lev, max_level);
380  if (pbl_mrf_Sc_t < amrex::Real(0)) {
381  amrex::Abort("erf.pbl_mrf_Sc_t must be >= 0 (0: the passive scalars mix as heat does)");
382  }
384  pp, "enable_mrf_unbounded_vpert", enable_mrf_unbounded_vpert, lev, max_level);
386  pp, "pbl_mrf_use_zero_ri_extent", pbl_mrf_use_zero_ri_extent, lev, max_level);
388  pp, "pbl_mrf_fire_thermal_excess", mrf_fire_thermal_excess, lev, max_level);
390  pp, "mrf_fire_q_threshold", mrf_fire_q_threshold, lev, max_level);
391  if (mrf_fire_q_threshold < amrex::Real(0)) {
392  amrex::Abort("erf.mrf_fire_q_threshold must be >= 0");
393  }
394 #ifndef ERF_USE_FIRE
396  amrex::Abort("erf.pbl_mrf_fire_thermal_excess = true needs the fire coupling"
397  "; rebuild with it (CMake ERF_ENABLE_FIRE=ON, GNU make USE_FIRE=TRUE)");
398  }
399 #endif
400  // QNSE stable stability functions (Sukoriansky et al. 2005)
402  pp, "enable_qnse_stable_functions", enable_qnse_stable_functions, lev, max_level);
404  pp, "qnse_am", qnse_am, lev, max_level);
406  pp, "qnse_bm", qnse_bm, lev, max_level);
408  pp, "qnse_ah", qnse_ah, lev, max_level);
410  pp, "qnse_bh", qnse_bh, lev, max_level);
411  // Scale-aware PBL-LES blending parameters.
413  pp, "pbl_blend_length", pbl_blend_length, lev, max_level);
415  pp, "pbl_blend_cs", pbl_blend_cs, lev, max_level);
417  pp, "pbl_blend_c_max", pbl_blend_c_max, lev, max_level);
419  pp, "pbl_blend_use_smag", pbl_blend_use_smag, lev, max_level);
420  // Vogelezang & Holtslag (1996) shear correction
422  pp, "enable_vh96_shear_correction", enable_vh96_shear_correction, lev, max_level);
424  pp, "vh96_shear_const_b", vh96_shear_const_b, lev, max_level);
425  // PBLH spatial smoothing
427  pp, "enable_pblh_smoothing", enable_pblh_smoothing, lev, max_level);
429  pp, "pblh_smoothing_passes", pblh_smoothing_passes, lev, max_level);
431  pp, "pblh_smoothing_weight", pblh_smoothing_weight, lev, max_level);
432  // Validate pblh_smoothing_weight is in [0,1]
433  if (enable_pblh_smoothing && (pblh_smoothing_weight < 0 || pblh_smoothing_weight > 1)) {
434  amrex::Error("pblh_smoothing_weight must be in [0, 1]");
435  }
436  }
438  std::string zlo_bc = "none";
439  amrex::ParmParse pp_bc("zlo");
440  pp_bc.get("type",zlo_bc);
441  if (amrex::toLower(zlo_bc) != "surface_layer") {
442  amrex::Abort("You must use the surface_layer BC at zlo with the selected PBL.");
443  }
444  }
445  }
446 
447  // Flags for QKE/TKE equation
448  if (pbl_type == PBLType::MYJ || pbl_type == PBLType::MYNN25 || pbl_type == PBLType::MYNNEDMF) {
449  // Add sources/sinks to QKE/TKE? (MYJ does this inline)
450  if (pbl_type == PBLType::MYNN25 || pbl_type == PBLType::MYNNEDMF) {
451  use_pbl_tke = true;
452  }
453  // Advect QKE/TKE?
454  query_one_or_per_level(pp, "advect_tke" , advect_tke , lev, max_level);
455  // Apply numerical diffusion to QKE/TKE? (no effect while the 6th-order numerical
456  // diffusion is deactivated, see erf.num_diff_coeff)
457  if (query_one_or_per_level(pp, "diffuse_tke_3D", diffuse_tke_3D, lev, max_level) && lev == 0) {
458  amrex::Warning("erf.diffuse_tke_3D is ignored: the 6th-order numerical diffusion is currently deactivated");
459  }
460  }
461 
462  // There is a default value of 1e-6 but the user can override the value here,
463  // and in addition can add perturbational values. and in addition can add perturbational values.
464  pp.queryAdd("tke_min",tke_min);
465 
466  // LES constants...
467  query_one_or_per_level(pp, "Cs", Cs, lev, max_level);
468 
469  query_one_or_per_level(pp, "Pr_t", Pr_t, lev, max_level);
470  query_one_or_per_level(pp, "Sc_t", Sc_t, lev, max_level);
471 
472  // Compute relevant forms of diffusion parameters
473  Pr_t_inv = one / Pr_t;
474  Sc_t_inv = one / Sc_t;
475 
476  if (les_type == LESType::Deardorff) {
477  query_one_or_per_level(pp, "Ck", Ck, lev, max_level);
478  query_one_or_per_level(pp, "Ce", Ce, lev, max_level);
479  query_one_or_per_level(pp, "Ce_wall", Ce_wall, lev, max_level);
480  }
481 
482  // To quantify atmospheric stability for subgrid modeling
483  const bool strat_type_set = (pp.countval("thermal_stratification") > 0);
484  query_one_or_per_level(pp, "thermal_stratification", strat_type, lev, max_level);
485  // The PBL schemes have always used theta_v for their buoyancy gradient,
486  // which is the physically right choice there. Honor an explicit
487  // erf.thermal_stratification everywhere, but when the user has not set it
488  // keep the historical split: theta for the LES closures, theta_v for the
489  // PBL ones. That way the knob reaches the PBL schemes without silently
490  // changing any existing moist answer.
491  pbl_strat_type = strat_type_set ? strat_type : StratType::thetav;
492  amrex::Print() << "PBL thermal stratification variable: "
493  << amrex::getEnumNameString(pbl_strat_type) << std::endl;
494  if (strat_type == StratType::theta) {
495  amrex::Print() << "Thermal stratification based on gradient of potential temperature" << std::endl;
496  } else if (strat_type == StratType::thetav) {
497  amrex::Print() << "Thermal stratification based on gradient of virtual potential temperature" << std::endl;
498  } else if (strat_type == StratType::thetal) {
499  amrex::Print() << "Thermal stratification based on gradient of linearized liquid-water potential temperature" << std::endl;
500  }
501 
502  // k-eqn constants
503  query_one_or_per_level(pp, "Cmu0", Cmu0, lev, max_level);
504  query_one_or_per_level(pp, "Cb", Cb, lev, max_level);
505  query_one_or_per_level(pp, "Rt_crit", Rt_crit, lev, max_level);
506  query_one_or_per_level(pp, "Rt_min", Rt_min, lev, max_level);
507  query_one_or_per_level(pp, "max_geom_lscale", l_g_max, lev, max_level);
508  query_one_or_per_level(pp, "dirichlet_k", dirichlet_k, lev, max_level);
509  query_one_or_per_level(pp, "tke_floor", tke_floor, lev, max_level);
510  query_one_or_per_level(pp, "implicit_tke_dissipation", implicit_tke_dissipation, lev, max_level);
511  query_one_or_per_level(pp, "rans_consistent_diffusivities", rans_consistent_diffusivities, lev, max_level);
512  query_one_or_per_level(pp, "rans_lscale_from_pblh", rans_lscale_from_pblh, lev, max_level);
513  query_one_or_per_level(pp, "rans_lscale_min", rans_lscale_min, lev, max_level);
514  query_one_or_per_level(pp, "rans_realizability", rans_realizability, lev, max_level);
515  if (rans_realizability != zero) {
516  if (!(rans_realizability >= amrex::Real(0.01) && rans_realizability <= amrex::Real(10))) {
517  amrex::Error("erf.rans_realizability must be 0 (off) or in [0.01, 10]; Cmu0^2 = 0.309 is the neutral equilibrium value");
518  }
519  if (rans_type != RANSType::kEqn) {
520  // One value for the whole hierarchy (a single entry, or a list whose entries are all
521  // equal) is meant for the levels that run the k-eqn closure and is reset here; a list
522  // with different entries names this level on purpose and must not switch the cap on
523  // where there is no closure.
524  amrex::Vector<amrex::Real> all_levels;
525  pp.getarr("rans_realizability", all_levels);
526  bool uniform = true;
527  for (auto v : all_levels) { uniform = uniform && (v == all_levels[0]); }
528  if (uniform) {
529  amrex::Print() << "erf.rans_realizability reset to 0 on level " << lev
530  << " (no k-eqn closure there)" << std::endl;
532  } else {
533  amrex::Error("erf.rans_realizability needs erf.rans_type = kEqn (it caps the k-eqn eddy viscosity; level "
534  + std::to_string(lev) + ")");
535  }
536  }
537  }
538  // After the reset above, so a hierarchy with a PBL scheme on an LES level and the cap on
539  // its k-eqn level is accepted
540  if ((rans_realizability != zero) && (pbl_type != PBLType::None)) {
541  amrex::Error("erf.rans_realizability needs erf.pbl_type = None: a PBL scheme overwrites the vertical "
542  "diffusivities the cap acts on (level " + std::to_string(lev) + ")");
543  }
544  if (rans_lscale_from_pblh && !(rans_lscale_min > 0)) {
545  amrex::Error("erf.rans_lscale_min must be > 0 with erf.rans_lscale_from_pblh");
546  }
547  // Moist TKE buoyancy of the k-eqn closure (the Deardorff LES, which shares the TKE source,
548  // keeps the dry form). One value for the hierarchy is meant for its k-eqn levels and is
549  // reset on the others, as erf.rans_realizability is; a per-level list must not name a level
550  // without the closure.
551  query_one_or_per_level(pp, "rans_moist_buoyancy", rans_moist_buoyancy, lev, max_level);
552  if (rans_moist_buoyancy && rans_type != RANSType::kEqn) {
553  if (pp.countval("rans_moist_buoyancy") == 1) {
554  amrex::Print() << "erf.rans_moist_buoyancy reset to false on level " << lev
555  << " (no k-eqn closure there)" << std::endl;
556  rans_moist_buoyancy = false;
557  } else {
558  amrex::Error("erf.rans_moist_buoyancy needs erf.rans_type = kEqn (it is the k-eqn TKE buoyancy; level "
559  + std::to_string(lev) + ")");
560  }
561  }
562 
563  // Log-consistent vertical shear of the k-eqn closure (ERF_LogShear.H). One value for the
564  // hierarchy is meant for its k-eqn levels and is reset on the others, as
565  // erf.rans_moist_buoyancy is; a per-level list must not name a level without the closure.
566  // An unknown name stops the run in the query.
567  query_one_or_per_level_enum_case_insensitive(pp, "rans_shear_stencil", rans_shear_stencil, lev, max_level);
568  if (rans_shear_stencil != RANSShearStencil::central && rans_type != RANSType::kEqn) {
569  if (pp.countval("rans_shear_stencil") == 1) {
570  amrex::Print() << "erf.rans_shear_stencil reset to central on level " << lev
571  << " (no k-eqn closure there)" << std::endl;
572  rans_shear_stencil = RANSShearStencil::central;
573  } else {
574  amrex::Error("erf.rans_shear_stencil = log_law needs erf.rans_type = kEqn (it is the shear of the k-eqn "
575  "production; level " + std::to_string(lev) + ")");
576  }
577  }
578 
579  if (rans_type == RANSType::kEqn) {
580  // The stability functions (AL01 Eqs. 31, 32) have poles at Rt = -3.59869
581  // (cmu) and -3.61011 (cmu'); the Burchard & Petersen smoothing maps
582  // Rt < Rt_crit onto (Rt_min, Rt_crit) and needs Rt_min < Rt_crit <= 0,
583  // with Rt_min above the pole of cmu (AL01::Rt_min_lower_bound) and above
584  // the zero of its numerator (AL01::cmu_numerator_root), so cmu > 0.
585  if (!(Cmu0 > 0)) { amrex::Error("erf.Cmu0 must be > 0 for the k-eqn RANS"); }
586  if (!(Cb > 0)) { amrex::Error("erf.Cb must be > 0 for the k-eqn RANS"); }
587  if (!(l_g_max > 0)) { amrex::Error("erf.max_geom_lscale must be > 0 for the k-eqn RANS"); }
588  if (!(Rt_crit <= 0)) { amrex::Error("erf.Rt_crit must be <= 0 for the k-eqn RANS"); }
589  if (!(Rt_min < Rt_crit)) { amrex::Error("erf.Rt_min must be < erf.Rt_crit for the k-eqn RANS"); }
590  if (!(Rt_min > AL01::Rt_min_lower_bound)) {
591  std::ostringstream msg;
592  msg << std::setprecision(8) << "erf.Rt_min must be > " << AL01::Rt_min_lower_bound
593  << " for the k-eqn RANS: the momentum stability function cmu has a pole at Rt = -3.5986889850,"
594  << " and just below it cmu and the eddy viscosity are negative (level " << lev << ")";
595  amrex::Error(msg.str());
596  }
598  std::ostringstream msg;
599  msg << std::setprecision(8) << "erf.Rt_min must be > -erf.Cmu0/0.108 = " << AL01::cmu_numerator_root(Cmu0)
600  << " for the k-eqn RANS: below it the numerator Cmu0 + 0.108 Rt of cmu is negative;"
601  << " raise erf.Cmu0 or erf.Rt_min (level " << lev << ")";
602  amrex::Error(msg.str());
603  }
604  }
605  if (tke_floor < 0) { amrex::Error("erf.tke_floor must be >= 0"); }
606 
607  // Common inputs (LES or RANS)
608  if (!query_one_or_per_level(pp, "sigma_k", sigma_k, lev, max_level) && rans_type == RANSType::kEqn) {
609  amrex::Print() << "Overriding default sigma_k for k-eqn RANS" << std::endl;
610  sigma_k = one;
611  };
612  query_one_or_per_level(pp, "theta_ref", theta_ref, lev, max_level);
613 
614  query_one_or_per_level(pp, "mix_isotropic", mix_isotropic, lev, max_level);
615  query_one_or_per_level(pp, "use_Ri_correction", use_Ri_correction, lev, max_level);
616  query_one_or_per_level(pp, "Ri_crit", Ri_crit, lev, max_level);
617 
618  // Set common flags
619  use_kturb =
621  (pbl_type != PBLType::None));
622  use_keqn =
623  ((les_type == LESType::Deardorff) || (rans_type == RANSType::kEqn));
624  use_tke =
625  ((les_type == LESType::Deardorff) || (rans_type == RANSType::kEqn) ||
626  (pbl_type == PBLType::MYJ) || (pbl_type == PBLType::MYNN25) ||
627  (pbl_type == PBLType::MYNNEDMF) || uses_shoc_family());
628 
629  if (use_tke) {
630  query_one_or_per_level(pp, "init_tke_from_ustar", init_tke_from_ustar, lev, max_level);
631  }
632 
633  // Validate inputs
634  if (les_type == LESType::Smagorinsky) {
635  if (Cs == 0) {
636  amrex::Error("Need to specify Cs for Smagorsinky LES");
637  }
638  if (smag2d && mix_isotropic) {
639  amrex::Print() << "Turning off mix_isotropic for 2-D Smagorinsky" << std::endl;
640  mix_isotropic = false;
641  }
642  }
643 
644  // Opt-in limits of WRF's Smagorinsky-2D closure (dyn_em/module_diffusion_em.F, smag2d_km):
645  // the slope limiter, which divides K_h by alpha or alpha^2 on terrain-fitted meshes, and the
646  // cap K_h <= smag2d_kh_cap * Delta_h (WRF: 10 m/s). Both are off by default. The mesh check
647  // for the slope limiter is in SolverChoice::init_params, where the terrain type is known.
648  query_one_or_per_level(pp, "smag2d_slope_limiter", smag2d_slope_limiter, lev, max_level);
649  query_one_or_per_level(pp, "smag2d_kh_cap", smag2d_kh_cap, lev, max_level);
650  if (!(smag2d_kh_cap >= zero)) {
651  amrex::Error("erf.smag2d_kh_cap must be >= 0 (0 = no cap; WRF uses 10 m/s)");
652  }
654  if (!smag2d) {
655  // A single value applies to every level; it is meant for the levels that run
656  // Smagorinsky2D (SolverChoice aborts if none does). A per-level list must not
657  // switch the limits on at a level that does not.
658  if (pp.countval("smag2d_slope_limiter") == 1) { smag2d_slope_limiter = false; }
659  if (pp.countval("smag2d_kh_cap") == 1) { smag2d_kh_cap = zero; }
661  amrex::Error("erf.smag2d_slope_limiter and erf.smag2d_kh_cap apply only to "
662  "erf.les_type = Smagorinsky2D (level " + std::to_string(lev) + ")");
663  }
664  }
665  }
666 
667  /**
668  * @brief Validate turbulence options against physical boundary conditions.
669  * @param phys_bc_type Physical boundary-condition types.
670  */
671  void check_params (amrex::GpuArray<ERF_BC, AMREX_SPACEDIM*2>& phys_bc_type)
672  {
673  // BC compatibility
675  phys_bc_type[amrex::Orientation(amrex::Direction::z,amrex::Orientation::low)] != ERF_BC::surface_layer ) {
676  amrex::Abort("The selected PBL model requires MOST at lower boundary");
677  }
678  if ( (les_type == LESType::Deardorff) && (Ce_wall > 0) &&
679  (phys_bc_type[amrex::Orientation(amrex::Direction::z,amrex::Orientation::low)] != ERF_BC::surface_layer) &&
680  (phys_bc_type[amrex::Orientation(amrex::Direction::z,amrex::Orientation::low)] != ERF_BC::slip_wall) &&
681  (phys_bc_type[amrex::Orientation(amrex::Direction::z,amrex::Orientation::low)] != ERF_BC::no_slip_wall) )
682  {
683  amrex::Warning("Deardorff LES assumes wall at zlo when applying Ce_wall");
684  }
685  }
686 
687  /**
688  * @brief Print turbulence settings for one AMR level.
689  * @param lev AMR level index.
690  */
691  void display (int lev)
692  {
693  amrex::Print() << "Turbulence Settings at level " << lev << std::endl;
694 
695  if (
697  pbl_type == PBLType::None) {
698  amrex::Print() << " Using DNS model at level " << lev << std::endl;
699  } else if (les_type == LESType::Smagorinsky) {
700  if (smag2d) {
701  amrex::Print() << " Using 2D Smagorinsky LES model at level " << lev << std::endl;
702  } else {
703  amrex::Print() << " Using Smagorinsky LES model at level " << lev << std::endl;
704  }
705  if (use_Ri_correction) {
706  amrex::Print() << " Smagorinsky uses Richardson number correction with Ri_crit = "
707  << Ri_crit << std::endl;
708  }
709  if (smag2d) {
710  amrex::Print() << " WRF slope limiter : " << smag2d_slope_limiter << std::endl;
711  if (smag2d_kh_cap > zero) {
712  amrex::Print() << " K_h cap : " << smag2d_kh_cap << " * Delta_h" << std::endl;
713  } else {
714  amrex::Print() << " K_h cap : none" << std::endl;
715  }
716  }
717  } else if (les_type == LESType::Deardorff) {
718  amrex::Print() << " Using Deardorff LES model at level " << lev << std::endl;
719  } else if (rans_type == RANSType::kEqn) {
720  amrex::Print()
721  << " Using Axell & Liungman one-equation RANS k model at level " << lev
722  << std::endl;
723  } else if (pbl_type == PBLType::MYJ) {
724  amrex::Print() << " Using MYJ PBL model at level " << lev << std::endl;
725  } else if (pbl_type == PBLType::MYNN25) {
726  amrex::Print() << " Using MYNN2.5 PBL model at level " << lev << std::endl;
727  } else if (pbl_type == PBLType::MYNNEDMF) {
728  amrex::Print() << " Using MYNNEDMF PBL model at level " << lev << std::endl;
729  } else if (pbl_type == PBLType::YSU) {
730  amrex::Print() << " Using YSU PBL model at level " << lev << std::endl;
731  } else if (pbl_type == PBLType::MRF) {
732  amrex::Print() << " Using MRF PBL model at level " << lev << std::endl;
733  } else if (pbl_type == PBLType::NATIVE_SHOC) {
734  amrex::Print() << " Using native SHOC PBL model at level " << lev << std::endl;
735  } else {
736  amrex::Error("Unknown turbulence model");
737  }
738 
739  if (les_type != LESType::None) {
740  if (les_type == LESType::Smagorinsky) {
741  amrex::Print() << " Cs : " << Cs << std::endl;
742  }
743  if (les_type == LESType::Deardorff) {
744  amrex::Print() << " Ce : " << Ce << std::endl;
745  amrex::Print() << " Ce at wall : " << Ce_wall << std::endl;
746  amrex::Print() << " Ck : " << Ck << std::endl;
747  amrex::Print() << " sigma_k : " << sigma_k << std::endl;
748 
749  // Sullivan et al 1994, Eqn 14
750  amrex::Real Cs_equiv = std::sqrt(Ck * std::sqrt(Ck / Ce));
751  amrex::Print() << " equivalent Cs : " << Cs_equiv
752  << std::endl;
753  }
754  amrex::Print() << " isotropic mixing : " << mix_isotropic
755  << std::endl;
756  }
757 
758  if (rans_type != RANSType::None) {
759  if (rans_type == RANSType::kEqn) {
760  amrex::Print() << "Cmu0 : " << Cmu0 << std::endl;
761  amrex::Print() << "sigma_k : " << sigma_k << std::endl;
762  amrex::Print() << "Cb : " << Cb << std::endl;
763  amrex::Print() << "Rt_crit : " << Rt_crit << std::endl;
764  amrex::Print() << "Rt_min : " << Rt_min << std::endl;
765  amrex::Print() << "max_geom_lscale : " << l_g_max << std::endl;
766  amrex::Print() << "rans_realizability : " << rans_realizability << std::endl;
767  amrex::Print() << "rans_shear_stencil : " << amrex::getEnumNameString(rans_shear_stencil) << std::endl;
768  amrex::Print() << "rans_moist_buoyancy : " << rans_moist_buoyancy << std::endl;
769  amrex::Print() << "dirichlet_k : " << dirichlet_k << std::endl;
770  amrex::Print() << "tke_floor : " << tke_floor << std::endl;
771  amrex::Print() << "implicit_tke_dissipation : " << implicit_tke_dissipation << std::endl;
772  amrex::Print() << "consistent diffusivities : " << rans_consistent_diffusivities << std::endl;
773  amrex::Print() << "lscale cap from PBL height : " << rans_lscale_from_pblh
774  << " (floor " << rans_lscale_min << " m)" << std::endl;
775  }
776  }
777 
778  if ((les_type == LESType::Deardorff) ||
779  (rans_type == RANSType::kEqn)) {
780  if (theta_ref > 0) {
781  amrex::Print() << " reference theta : " << theta_ref << std::endl;
782  } else {
783  amrex::Print() << " reference theta : n/a" << std::endl;
784  }
785  }
786 
787  if ((les_type != LESType::None) || (rans_type != RANSType::None)) {
788  amrex::Print() << " Pr_t : " << Pr_t << std::endl;
789  amrex::Print() << " Sc_t : " << Sc_t << std::endl;
790  }
791 
792  if (pbl_type == PBLType::MYNN25 || pbl_type == PBLType::MYNNEDMF) {
793  amrex::Print() << " pbl_mynn_config : "
794  << amrex::getEnumNameString(pbl_mynn.config) << std::endl;
795  amrex::Print() << " pbl_mynn_Lt_alpha : " << pbl_mynn.Lt_alpha << std::endl;
796  amrex::Print() << " pbl_mynn_A1 : " << pbl_mynn.A1 << std::endl;
797  amrex::Print() << " pbl_mynn_A2 : " << pbl_mynn.A2 << std::endl;
798  amrex::Print() << " pbl_mynn_B1 : " << pbl_mynn.B1 << std::endl;
799  amrex::Print() << " pbl_mynn_B2 : " << pbl_mynn.B2 << std::endl;
800  amrex::Print() << " pbl_mynn_C1 : " << pbl_mynn.C1 << std::endl;
801  amrex::Print() << " pbl_mynn_C2 : " << pbl_mynn.C2 << std::endl;
802  amrex::Print() << " pbl_mynn_C3 : " << pbl_mynn.C3 << std::endl;
803  amrex::Print() << " pbl_mynn_C4 : " << pbl_mynn.C4 << std::endl;
804  amrex::Print() << " pbl_mynn_C5 : " << pbl_mynn.C5 << std::endl;
805  amrex::Print() << " pbl_mynn_surface_lm : " << pbl_mynn.surface_lm << std::endl;
806  } else if (pbl_type == PBLType::YSU) {
807  amrex::Print() << " pbl_ysu_coriolis_freq : "
808  << pbl_ysu_coriolis_freq << std::endl;
809  amrex::Print() << " pbl_ysu_use_consistent_coriolis : "
810  << pbl_ysu_use_consistent_coriolis << std::endl;
811  amrex::Print() << " pbl_ysu_land_Ribcr : "
812  << pbl_ysu_land_Ribcr << std::endl;
813  amrex::Print() << " enable_ysu_countergradient : "
814  << enable_ysu_countergradient << std::endl;
815  amrex::Print() << " enable_ysu_sat_limiter : "
816  << enable_ysu_sat_limiter << std::endl;
817  amrex::Print() << " enable_ysu_topdown : "
818  << enable_ysu_topdown << std::endl;
819  amrex::Print() << " enable_ysu_entrainment : "
820  << enable_ysu_entrainment << std::endl;
821  amrex::Print() << " enable_ysu_cloud_pblh : "
822  << enable_ysu_cloud_pblh << std::endl;
823  amrex::Print() << " ysu_qcloud_threshold : "
824  << ysu_qcloud_threshold << std::endl;
825  amrex::Print() << " ysu_moistvars : "
826  << ysu_moistvars << std::endl;
827  amrex::Print() << " pbl_ysunew_highres_bounds : "
828  << pbl_ysunew_highres_bounds << std::endl;
829  // Radiative tendency limiter/smoothing (YSU only)
830  amrex::Print() << " enable_ysu_rad_tend_limiter : "
831  << enable_ysu_rad_tend_limiter << std::endl;
832  amrex::Print() << " ysu_rad_tend_limiter_magnitude : "
833  << ysu_rad_tend_limiter_magnitude << std::endl;
834  amrex::Print() << " enable_vh96_shear_correction : "
835  << enable_vh96_shear_correction << std::endl;
836  amrex::Print() << " vh96_shear_const_b : "
837  << vh96_shear_const_b << std::endl;
838  amrex::Print() << " enable_pblh_smoothing : "
839  << enable_pblh_smoothing << std::endl;
840  amrex::Print() << " pblh_smoothing_passes : "
841  << pblh_smoothing_passes << std::endl;
842  amrex::Print() << " pblh_smoothing_weight : "
843  << pblh_smoothing_weight << std::endl;
844  amrex::Print() << " enable_mrf_unbounded_vpert : "
845  << enable_mrf_unbounded_vpert << std::endl;
846  amrex::Print() << " enable_qnse_stable_functions : "
847  << enable_qnse_stable_functions << std::endl;
849  amrex::Print() << " qnse_am (momentum coeff) : " << qnse_am << std::endl;
850  amrex::Print() << " qnse_bm (momentum coeff) : " << qnse_bm << std::endl;
851  amrex::Print() << " qnse_ah (heat coeff) : " << qnse_ah << std::endl;
852  amrex::Print() << " qnse_bh (heat coeff) : " << qnse_bh << std::endl;
853  }
854  } else if (pbl_type == PBLType::MRF) {
855  amrex::Print() << " pbl_mrf_coriolis_freq : " << pbl_mrf_coriolis_freq
856  << std::endl;
857  amrex::Print() << " pbl_mrf_Ribcr : " << pbl_mrf_Ribcr
858  << std::endl;
859  amrex::Print() << " pbl_mrf_const_b : " << pbl_mrf_const_b
860  << std::endl;
861  amrex::Print() << " pbl_mrf_sf : " << pbl_mrf_sf
862  << std::endl;
863  amrex::Print() << " enable_mrf_countergradient : " << enable_mrf_countergradient
864  << std::endl;
865  amrex::Print() << " enable_mrf_cloud_adjustment : " << enable_mrf_cloud_adjustment
866  << std::endl;
867  amrex::Print() << " pbl_mrf_highres_bounds : " << pbl_mrf_highres_bounds
868  << std::endl;
869  amrex::Print() << " pbl_mrf_Sc_t : " << pbl_mrf_Sc_t
870  << std::endl;
871  amrex::Print() << " enable_mrf_unbounded_vpert : " << enable_mrf_unbounded_vpert
872  << std::endl;
873  amrex::Print() << " pbl_mrf_use_zero_ri_extent : " << pbl_mrf_use_zero_ri_extent
874  << std::endl;
875  amrex::Print() << " pbl_mrf_fire_thermal_excess : " << mrf_fire_thermal_excess
876  << std::endl;
877  amrex::Print() << " mrf_fire_q_threshold : " << mrf_fire_q_threshold
878  << std::endl;
879  amrex::Print() << " pbl_blend_length : " << pbl_blend_length
880  << std::endl;
881  amrex::Print() << " pbl_blend_cs : " << pbl_blend_cs
882  << std::endl;
883  amrex::Print() << " pbl_blend_c_max : " << pbl_blend_c_max
884  << std::endl;
885  amrex::Print() << " pbl_blend_use_smag : " << pbl_blend_use_smag
886  << std::endl;
887  amrex::Print() << " enable_vh96_shear_correction : " << enable_vh96_shear_correction
888  << std::endl;
889  amrex::Print() << " vh96_shear_const_b : " << vh96_shear_const_b
890  << std::endl;
891  amrex::Print() << " enable_pblh_smoothing : " << enable_pblh_smoothing
892  << std::endl;
893  amrex::Print() << " pblh_smoothing_passes : " << pblh_smoothing_passes
894  << std::endl;
895  amrex::Print() << " pblh_smoothing_weight : " << pblh_smoothing_weight
896  << std::endl;
897  amrex::Print() << " enable_qnse_stable_functions : "
898  << enable_qnse_stable_functions << std::endl;
900  amrex::Print() << " qnse_am (momentum coeff) : " << qnse_am << std::endl;
901  amrex::Print() << " qnse_bm (momentum coeff) : " << qnse_bm << std::endl;
902  amrex::Print() << " qnse_ah (heat coeff) : " << qnse_ah << std::endl;
903  amrex::Print() << " qnse_bh (heat coeff) : " << qnse_bh << std::endl;
904  }
905  }
906  }
907 
908  // LES model
910 
911  // Turbulent Prandtl number
912  amrex::Real Pr_t = one / three;
913  amrex::Real Pr_t_inv = three;
914 
915  // Turbulent Schmidt number
916  amrex::Real Sc_t = one;
917  amrex::Real Sc_t_inv = one;
918 
919  // Smagorinsky
920  amrex::Real Cs = zero;
921  bool smag2d = false;
922  // WRF smag2d_km limits (opt-in): slope limiter K_h /= alpha or alpha^2 on terrain-fitted
923  // meshes, and the cap K_h <= smag2d_kh_cap * Delta_h (m/s; 0 = no cap)
924  bool smag2d_slope_limiter = false;
925  amrex::Real smag2d_kh_cap = zero;
926  // whether either limit was given as on for this level, before a single value is
927  // dropped at a level without Smagorinsky2D
929 
930  // Deardorff
931  amrex::Real Ce = amrex::Real(0.93);
932  amrex::Real Ce_wall = zero; // if > 0, then set Ce to this at k=0
933  amrex::Real Ck = amrex::Real(0.1);
934 
935  // k-eqn RANS coefficients (Axell & Liungman 2001)
936  amrex::Real Cmu0 = amrex::Real(0.5562);
937  amrex::Real Cb = amrex::Real(0.35);
938  amrex::Real Rt_crit = -one;
939  amrex::Real Rt_min = -three;
940  amrex::Real l_g_max = amrex::Real(30.0); // ~ kappa * (amrex::Real(0.1) * zi)
941 
942  // Deardorff or k-eqn RANS
943  // - diffusivity of tke is 1/sigma_k times the eddy viscosity
944  amrex::Real sigma_k = amrex::Real(0.5);
945  // - reference potential temperature used to quantify the stratification in
946  // a stable region
947  amrex::Real theta_ref = zero;
948  // - how to quantify stratification effects
950  // Stratification variable used by the PBL schemes; see init_params.
951  StratType pbl_strat_type = StratType::thetav;
952 
953  // Anisotropic length scales
954  bool mix_isotropic = true;
955 
956  bool use_Ri_correction = true;
957  amrex::Real Ri_crit = fourth;
958 
959  // RANS type
961 
962  bool dirichlet_k = false;
963 
964  // Runtime floor on the turbulent kinetic energy [m2/s2] in the k-equation
965  // update and the RANS closure; 0 means machine epsilon on rho*k (the
966  // historical floor). Distinct from tke_min, the initial TKE value.
967  amrex::Real tke_floor = zero;
968 
969  // Treat the TKE dissipation implicitly: eps = (Cmu0^3 sqrt(k_old)/L) * k_new
970  // folded into the update (Deardorff and k-eqn RANS)
972 
973  // k-eqn RANS: horizontal heat, scalar and moisture diffusivities follow the
974  // AL01 scalar stability function (cmu') like the vertical heat diffusivity,
975  // instead of Pr_t and Sc_t times the eddy viscosity
977 
978  // k-eqn RANS: cap the geometric length at kappa * 0.1 * PBL height (from
979  // erf.most.pblh_calc), clamped to [rans_lscale_min, max_geom_lscale],
980  // instead of the fixed max_geom_lscale
981  bool rans_lscale_from_pblh = false;
982  amrex::Real rans_lscale_min = one;
983 
984  // k-eqn RANS: realizability cap nu_t <= C_r k / S on the eddy viscosity
985  // (and every eddy diffusivity through the same ratio), 0 = off. C_r = Cmu0^2
986  // leaves a neutral equilibrium surface layer untouched and limits the
987  // viscosity in the shear layer that leaves a crest (AL01 Eqs. 11 and 19;
988  // the SST limiter form).
989  amrex::Real rans_realizability = zero;
990 
991  // k-eqn RANS: vertical gradients of u and v in S_mn S_mn (shear production of k and the S of
992  // the realizability cap): central keeps the average of the face strains, log_law uses the
993  // difference that is exact for a logarithmic profile over the ground (ERF_LogShear.H)
994  RANSShearStencil rans_shear_stencil = RANSShearStencil::central;
995 
996  // k-eqn RANS: moist TKE buoyancy production (erf.rans_moist_buoyancy),
997  // B = g / theta_v0 [(1 + epsv qv) <w'theta'> + epsv theta <w'qv'>],
998  // water vapor only (no cloud-water flux, no saturated form); false keeps the
999  // dry production g / theta_0 <w'theta'>
1000  bool rans_moist_buoyancy = false;
1001 
1002  // PBL model
1004 
1005  /**
1006  * @brief Query whether this level uses the native SHOC PBL scheme.
1007  * @return True if PBLType::NATIVE_SHOC is selected.
1008  */
1009  bool uses_native_shoc () const noexcept
1010  {
1011  return pbl_type == PBLType::NATIVE_SHOC;
1012  }
1013 
1014  /**
1015  * @brief Query whether this level uses any SHOC-family PBL scheme.
1016  * @return True if native SHOC is selected (the only SHOC since the EAMxx one was removed).
1017  */
1018  bool uses_shoc_family () const noexcept
1019  {
1020  return uses_native_shoc();
1021  }
1022 
1023  /**
1024  * @brief Query whether the horizontal and vertical eddy viscosities can differ on this level.
1025  * @return True for Smagorinsky-2D, anisotropic Smagorinsky or Deardorff, and any PBL scheme
1026  * (which sets the vertical diffusivities on its own).
1027  */
1028  bool kh_kv_can_differ () const noexcept
1029  {
1030  return ( (les_type == LESType::Smagorinsky && (smag2d || !mix_isotropic)) ||
1031  (les_type == LESType::Deardorff && !mix_isotropic) ||
1032  (pbl_type != PBLType::None) );
1033  }
1034 
1035  /**
1036  * @brief Query whether the selected PBL scheme requires surface-layer boundary conditions.
1037  * @return True if the PBL scheme requires a lower surface-layer boundary.
1038  */
1039  bool pbl_requires_surface_layer () const noexcept
1040  {
1041  return (pbl_type == PBLType::MYNN25) ||
1042  (pbl_type == PBLType::MYNNEDMF) ||
1043  (pbl_type == PBLType::YSU) ||
1044  (pbl_type == PBLType::MRF) ||
1045  uses_shoc_family();
1046  }
1047 
1048  /**
1049  * @brief Query whether the selected PBL scheme suppresses microphysics condensation.
1050  * @return True when the PBL scheme owns condensation handling.
1051  */
1053  {
1054  return uses_shoc_family();
1055  }
1056 
1058  MYNNLevel2 pbl_mynn_level2; // limiting in the decaying turbulence regime
1059 
1060  // Common Flags
1061  bool use_kturb = false; // Any turbulence modeling?
1062  bool use_keqn =
1063  false; // Any microscale turbulence modeling (LES, RANS) with TKE closure?
1064  // Then need to populate SmnSmn_lev for production term.
1066  false; // Any mesoscale turbulence modeling (PBL) with TKE closure?
1067  bool use_tke = false; // Any TKE closure (meso or microscale)?
1068 
1069  // Initialize TKE/QKE with linear profiles whose surface values are a
1070  // function of the friction velocity calculated by the surface layer scheme
1071  // (e.g., as done in MYNN-EDMF)
1072  bool init_tke_from_ustar = false;
1073 
1074  // This is the value of tke_min in WRF 4.5
1075  amrex::Real tke_min = amrex::Real(1.e-6);
1076 
1077  // Model coefficients - YSU
1078  // TODO: Add parmparse for all of these above
1080  amrex::Real(1.0e-4); // 1e-4 is hardcoded in WRF, we let the user specify or take the
1081  // value from ERF coriolis forcing
1083  false; // ignore input pbl_ysu_coriolis_freq, take value from ERF coriolis
1084  // forcing instead
1085  amrex::Real pbl_ysu_land_Ribcr =
1086  fourth; // Critical Bulk Richardson number of Land for stable conditions
1088  true; // if true, apply YSU-style HGAMT/HGAMQ/HGAMU/HGAMV countergradient correction
1090  false; // if true, apply saturation limiter to moisture countergradient
1092  true; // if true, enable top-down mixing for cloud-topped boundary layers
1094  true; // if true, enable entrainment layer parameterization
1096  true; // if true, raise the PBL-top cell index by one where that cell is cloudy;
1097  // independent of enable_ysu_entrainment
1098  amrex::Real ysu_qcloud_threshold =
1099  amrex::Real(1.0e-4); // Cloud water plus cloud ice threshold for YSU (kg/kg)
1100  bool ysu_moistvars = false; // if true, adds turbulence to moisture
1101  bool pbl_ysunew_highres_bounds = false; // if true, apply high-resolution grid-dependent diffusivity bounds
1102  // Radiative tendency limiter (YSU only)
1103  bool enable_ysu_rad_tend_limiter = false; // if true, guard and bound the qheating_rates top-down forcing
1104  amrex::Real ysu_rad_tend_limiter_magnitude = amrex::Real(1.0); // Bound on the limited radiative tendency (K/s)
1105  // Vogelezang & Holtslag (1996) shear correction and PBLH smoothing for YSU
1106  bool enable_vh96_shear_correction = false; // if true, use VH96 shear correction term instead of ad-hoc floor
1107  amrex::Real vh96_shear_const_b = amrex::Real(100.0); // VH96 shear correction constant b
1108  bool enable_pblh_smoothing = false; // if true, apply spatial smoothing to diagnosed PBLH
1109  int pblh_smoothing_passes = 1; // number of smoothing iterations
1110  amrex::Real pblh_smoothing_weight = amrex::Real(0.5); // center-cell weight in smoothing stencil
1111  // Model coefficients - MRF
1112  amrex::Real pbl_mrf_coriolis_freq = amrex::Real(1.0e-4);
1113  amrex::Real pbl_mrf_Ribcr = amrex::Real(0.5); // Critical Bulk Richardson number for MRF PBL model
1114  amrex::Real pbl_mrf_const_b = amrex::Real(7.8); // Constant b in MRF PBL model, used to compute the PBL height
1115  amrex::Real pbl_mrf_sf = amrex::Real(0.1); // MRF surface flux, used to compute the PBL height
1116  // Scale-aware PBL-LES blending parameters.
1117  // Boutle et al. (2014): https://doi.org/10.1175/MWR-D-13-00229.1
1118  // Set pbl_blend_length = 0 to disable (default). Recovers original behavior.
1119  amrex::Real pbl_blend_length = amrex::Real(0.0); ///< Boutle blending length L [m]. 0 = off.
1120  amrex::Real pbl_blend_cs = amrex::Real(0.17); ///< Smagorinsky coeff for K_h ceiling.
1121  amrex::Real pbl_blend_c_max = amrex::Real(0.1); ///< Power-law ceiling coeff [m^(2/3)/s].
1122  bool pbl_blend_use_smag = true; ///< Use Smagorinsky ceiling (else power-law).
1123  bool enable_mrf_countergradient = false; // if true, apply WRF-style HGAMT/HGAMQ correction to PBL height
1124  bool pbl_ib_aware = false; // MRF / YSU: measure heights from the top of immersed solid columns
1125  amrex::Real pbl_ib_z0 = amrex::Real(0.01); // roughness [m] of the neutral log law at the top of an immersed column
1126  bool enable_mrf_cloud_adjustment = false; // if true, apply cloud-aware stability function adjustments in MRF scheme
1127  bool pbl_mrf_highres_bounds = false; // if true, apply high-resolution grid-dependent diffusivity bounds instead of global forecast bounds
1128  amrex::Real pbl_mrf_Sc_t = amrex::Real(0); // MRF: the passive scalars' Schmidt number; Scalar_v = Theta_v * Pr_t / Sc_t, and 0 gives Scalar_v = Theta_v
1129  bool enable_mrf_unbounded_vpert = false; // if true, does not limit VPERT to GAMCRT
1130  bool pbl_mrf_use_zero_ri_extent = false; // if true, use Ri=0 (pbli_zero_arr) for K-profile extent; default false uses Ri=0.5 corrector (pbli_arr) for WRF compatibility
1131  bool mrf_fire_thermal_excess = false; // MRF with fire: raise w* in columns where the lagged fire heat flux exceeds mrf_fire_q_threshold
1132  amrex::Real mrf_fire_q_threshold = amrex::Real(50.0); // fire heat flux [W/m2] above which a column counts as burning
1133  // QNSE (Quasi-Normal Scale Elimination) spectral stable stability functions
1134  // Sukoriansky, S., B. Galperin, and V. Perov, 2005: Application of a New Spectral
1135  // Theory of Stably Stratified Turbulence to the Atmospheric Boundary Layer over
1136  // Sea Ice. Boundary-Layer Meteorology, 117, 231–257.
1137  // https://doi.org/10.1007/s10546-004-6848-4
1138  bool enable_qnse_stable_functions = false; // if true, use QNSE spectral stability functions
1139  // instead of linear Businger-Dyer form for stable conditions
1140  amrex::Real qnse_am = amrex::Real(2.5); // QNSE momentum stability function coefficient (dimensionless)
1141  amrex::Real qnse_bm = amrex::Real(0.2); // QNSE momentum stability function coefficient (dimensionless)
1142  amrex::Real qnse_ah = amrex::Real(2.5); // QNSE heat stability function coefficient (dimensionless)
1143  amrex::Real qnse_bh = amrex::Real(0.2); // QNSE heat stability function coefficient (dimensionless)
1144  // MYNN2.5 PBL model
1145  // TKE/QKE stuff
1146  bool advect_tke = true; // if MYNN2.5 PBL is used default is turb transport in
1147  // Z-direction only
1148  bool diffuse_tke_3D = true; // if numerical diffusion is turned on
1149 };
1150 
1151 /**
1152  * @var TurbChoice::les_type
1153  * @brief Selected LES closure.
1154  * @var TurbChoice::Pr_t
1155  * @brief Turbulent Prandtl number.
1156  * @var TurbChoice::Pr_t_inv
1157  * @brief Inverse turbulent Prandtl number.
1158  * @var TurbChoice::Sc_t
1159  * @brief Turbulent Schmidt number.
1160  * @var TurbChoice::Sc_t_inv
1161  * @brief Inverse turbulent Schmidt number.
1162  * @var TurbChoice::Cs
1163  * @brief Smagorinsky model coefficient.
1164  * @var TurbChoice::smag2d
1165  * @brief Whether the 2-D Smagorinsky formulation is used.
1166  * @var TurbChoice::smag2d_slope_limiter
1167  * @brief Apply WRF's Smagorinsky-2D slope limiter (K_h / alpha or / alpha^2) on terrain-fitted meshes.
1168  * @var TurbChoice::smag2d_kh_cap
1169  * @brief Cap K_h <= smag2d_kh_cap * Delta_h for Smagorinsky-2D (m/s); 0 means no cap.
1170  * @var TurbChoice::smag2d_limits_requested
1171  * @brief Whether either Smagorinsky-2D limit was given as on for this level.
1172  * @var TurbChoice::Ce
1173  * @brief Deardorff dissipation coefficient.
1174  * @var TurbChoice::Ce_wall
1175  * @brief Wall value for the Deardorff dissipation coefficient.
1176  * @var TurbChoice::Ck
1177  * @brief Deardorff eddy-viscosity coefficient.
1178  * @var TurbChoice::Cmu0
1179  * @brief One-equation RANS Cmu0 coefficient.
1180  * @var TurbChoice::Cb
1181  * @brief One-equation RANS buoyancy coefficient.
1182  * @var TurbChoice::Rt_crit
1183  * @brief Critical turbulent Reynolds number.
1184  * @var TurbChoice::Rt_min
1185  * @brief Minimum turbulent Reynolds number.
1186  * @var TurbChoice::l_g_max
1187  * @brief Maximum geometric length scale.
1188  * @var TurbChoice::sigma_k
1189  * @brief TKE diffusivity coefficient denominator.
1190  * @var TurbChoice::theta_ref
1191  * @brief Reference potential temperature for stable stratification.
1192  * @var TurbChoice::strat_type
1193  * @brief Thermodynamic variable used for stability stratification.
1194  * @var TurbChoice::mix_isotropic
1195  * @brief Whether subgrid mixing uses isotropic length scales.
1196  * @var TurbChoice::use_Ri_correction
1197  * @brief Whether Richardson-number correction is applied.
1198  * @var TurbChoice::Ri_crit
1199  * @brief Critical Richardson number for stability correction.
1200  * @var TurbChoice::rans_type
1201  * @brief Selected RANS closure.
1202  * @var TurbChoice::dirichlet_k
1203  * @brief Whether TKE uses Dirichlet boundary treatment.
1204  * @var TurbChoice::pbl_type
1205  * @brief Selected PBL closure.
1206  * @var TurbChoice::pbl_mynn
1207  * @brief MYNN level-2.5 closure coefficients.
1208  * @var TurbChoice::pbl_mynn_level2
1209  * @brief MYNN level-2 closure coefficients for limiting.
1210  * @var TurbChoice::use_kturb
1211  * @brief Whether any turbulence model is active.
1212  * @var TurbChoice::use_keqn
1213  * @brief Whether a microscale TKE closure is active.
1214  * @var TurbChoice::use_pbl_tke
1215  * @brief Whether a mesoscale PBL TKE closure is active.
1216  * @var TurbChoice::use_tke
1217  * @brief Whether any TKE or QKE closure is active.
1218  * @var TurbChoice::init_tke_from_ustar
1219  * @brief Whether initial TKE/QKE profiles are based on surface friction velocity.
1220  * @var TurbChoice::tke_min
1221  * @brief Minimum TKE/QKE value.
1222  * @var TurbChoice::pbl_ysu_coriolis_freq
1223  * @brief Coriolis frequency used by YSU-family PBL schemes.
1224  * @var TurbChoice::pbl_ysu_use_consistent_coriolis
1225  * @brief Whether YSU uses the ERF Coriolis frequency.
1226  * @var TurbChoice::pbl_ysu_land_Ribcr
1227  * @brief Critical bulk Richardson number over land for stable YSU conditions.
1228  * @var TurbChoice::enable_ysu_countergradient
1229  * @brief Whether YSU countergradient corrections are enabled.
1230  * @var TurbChoice::enable_ysu_sat_limiter
1231  * @brief Whether YSU applies a saturation limiter to moisture countergradient terms.
1232  * @var TurbChoice::enable_ysu_topdown
1233  * @brief Whether YSU top-down mixing is enabled.
1234  * @var TurbChoice::enable_ysu_entrainment
1235  * @brief Whether YSU entrainment-layer parameterization is enabled.
1236  * @var TurbChoice::enable_ysu_cloud_pblh
1237  * @brief Whether the YSU PBL-top cell index is raised by one where that cell is cloudy.
1238  * @var TurbChoice::ysu_qcloud_threshold
1239  * @brief Cloud water plus cloud ice threshold for YSU [kg/kg].
1240  * @var TurbChoice::ysu_moistvars
1241  * @brief Whether YSU applies turbulence to moisture variables.
1242  * @var TurbChoice::pbl_ysunew_highres_bounds
1243  * @brief Whether YSU applies high-resolution grid-dependent diffusivity bounds.
1244  * @var TurbChoice::enable_vh96_shear_correction
1245  * @brief Whether Vogelezang & Holtslag (1996) shear-correction term is enabled.
1246  * @var TurbChoice::vh96_shear_const_b
1247  * @brief Vogelezang & Holtslag (1996) shear-correction constant b.
1248  * @var TurbChoice::enable_pblh_smoothing
1249  * @brief Whether spatial smoothing of diagnosed PBLH is enabled.
1250  * @var TurbChoice::pblh_smoothing_passes
1251  * @brief Number of PBLH smoothing iterations to apply.
1252  * @var TurbChoice::pblh_smoothing_weight
1253  * @brief Center-cell weight in PBLH smoothing stencil (must be in [0,1]).
1254  * @var TurbChoice::pbl_mrf_coriolis_freq
1255  * @brief Coriolis frequency used by the MRF PBL scheme.
1256  * @var TurbChoice::pbl_mrf_Ribcr
1257  * @brief Critical bulk Richardson number for the MRF PBL scheme.
1258  * @var TurbChoice::pbl_mrf_const_b
1259  * @brief MRF constant used to compute PBL height.
1260  * @var TurbChoice::pbl_mrf_sf
1261  * @brief MRF surface flux value used to compute PBL height.
1262  * @var TurbChoice::enable_mrf_countergradient
1263  * @brief Whether MRF countergradient corrections are enabled.
1264  * @var TurbChoice::pbl_ib_aware
1265  * When true, the MRF and YSU schemes treat the first fluid cell above the
1266  * immersed solid of a column (buildings or terrain by immersed forcing) as
1267  * that column's surface: the bulk Richardson heights, the boundary-layer
1268  * depth and the K profile are measured from it, the diffusivities vanish
1269  * inside the solid, and the surface scales of such a column are a neutral
1270  * log law at its top (u* from the wind there and pbl_ib_z0, theta* = 0). The
1271  * boundary-layer height both schemes store (pblh, Lturb) stays the absolute
1272  * height above the domain bottom; with enable_pblh_smoothing the stencil runs
1273  * on that absolute height, and the smoothed value is kept at or above each
1274  * column's own floor (YSU: the top face of its first fluid cell, at least 10 m). Off by
1275  * default; without immersed cells the results are identical. Not supported
1276  * with terrain-fitted coordinates.
1277  * @var TurbChoice::pbl_ib_z0
1278  * Roughness length [m] of that log law.
1279  * @var TurbChoice::enable_mrf_cloud_adjustment
1280  * @brief Whether MRF cloud-aware stability adjustments are enabled.
1281  * @var TurbChoice::pbl_mrf_highres_bounds
1282  * @brief Whether MRF applies high-resolution grid-dependent diffusivity bounds.
1283  * @var TurbChoice::pbl_mrf_Sc_t
1284  * @brief MRF turbulent Schmidt number of the passive scalars (erf.pbl_mrf_Sc_t): their
1285  * vertical diffusivity is the heat one times erf.Pr_t / Sc_t; 0 (the default)
1286  * leaves it equal to the heat one.
1287  * @var TurbChoice::enable_mrf_unbounded_vpert
1288  * @brief Whether MRF leaves VPERT unlimited by GAMCRT.
1289  * @var TurbChoice::pbl_mrf_use_zero_ri_extent
1290  * @brief Whether MRF uses the Ri=0 K-profile extent.
1291  * @var TurbChoice::advect_tke
1292  * @brief Whether TKE/QKE is advected.
1293  * @var TurbChoice::diffuse_tke_3D
1294  * @brief Whether three-dimensional numerical diffusion is applied to TKE/QKE.
1295  */
1296 #endif
int count
Definition: ERF_ActuatorSpreading.cpp:264
@ no_slip_wall
@ surface_layer
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(axis >=0 &&axis< AMREX_SPACEDIM, "prob.axis must be 0, 1 or 2")
ParmParse pp("prob")
constexpr amrex::Real three
Definition: ERF_NumericalConstants.H:39
constexpr amrex::Real one
Definition: ERF_NumericalConstants.H:37
constexpr amrex::Real fourth
Definition: ERF_NumericalConstants.H:42
constexpr amrex::Real zero
Definition: ERF_NumericalConstants.H:36
AMREX_ENUM(LESType, None, Smagorinsky, Smagorinsky2D, Deardorff)
Large-eddy simulation closure type.
int query_one_or_per_level_enum_case_insensitive(const amrex::ParmParse &pp, const char *query_string, T &query_var, const int lev, const int maxlev)
Query a scalar or per-level enum input value using case-insensitive matching.
Definition: ERF_TurbStruct.H:95
int query_one_or_per_level(const amrex::ParmParse &pp, const char *query_string, T &query_var, const int lev, const int maxlev)
Query a scalar or per-level input value.
Definition: ERF_TurbStruct.H:53
constexpr amrex::Real Rt_min_lower_bound
Definition: ERF_RANSClosure.H:142
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real cmu_numerator_root(amrex::Real Cmu0)
Definition: ERF_RANSClosure.H:148
@ None
Definition: ERF_LSM_Types.H:6
@ theta
Definition: ERF_Kessler.H:26
@ T
Definition: ERF_IndexDefines.H:180
Coefficients and stability functions for the Level 2.5 MYNN closure.
Definition: ERF_MYNNStruct.H:18
amrex::Real SMmax
Definition: ERF_MYNNStruct.H:65
amrex::Real SHmax
Definition: ERF_MYNNStruct.H:67
amrex::Real Lt_alpha
Definition: ERF_MYNNStruct.H:77
amrex::Real SQfac
Definition: ERF_MYNNStruct.H:61
amrex::Real C4
Definition: ERF_MYNNStruct.H:57
amrex::Real C1
Definition: ERF_MYNNStruct.H:54
MYNNConfigType config
Definition: ERF_MYNNStruct.H:71
amrex::Real C3
Definition: ERF_MYNNStruct.H:56
amrex::Real C2
Definition: ERF_MYNNStruct.H:55
amrex::Real A2
Definition: ERF_MYNNStruct.H:51
amrex::Real SHmin
Definition: ERF_MYNNStruct.H:66
amrex::Real B1
Definition: ERF_MYNNStruct.H:52
amrex::Real B2
Definition: ERF_MYNNStruct.H:53
amrex::Real C5
Definition: ERF_MYNNStruct.H:58
amrex::Real SMmin
Definition: ERF_MYNNStruct.H:64
bool surface_lm
Definition: ERF_MYNNStruct.H:82
amrex::Real A1
Definition: ERF_MYNNStruct.H:50
amrex::Real SQmax
Definition: ERF_MYNNStruct.H:69
Coefficients and stability functions for the Level 2 MYNN closure.
Definition: ERF_MYNNStruct.H:88
void init_coeffs(amrex::Real A1_lvl25, amrex::Real A2_lvl25, amrex::Real B1, amrex::Real B2, amrex::Real C1, amrex::Real C2, amrex::Real C3, amrex::Real, amrex::Real C5)
Initialize Level 2 closure coefficients from Level 2.5 coefficients.
Definition: ERF_MYNNStruct.H:100
Definition: ERF_TurbStruct.H:129
bool advect_tke
Whether TKE/QKE is advected.
Definition: ERF_TurbStruct.H:1146
bool implicit_tke_dissipation
Definition: ERF_TurbStruct.H:971
StratType strat_type
Thermodynamic variable used for stability stratification.
Definition: ERF_TurbStruct.H:949
bool rans_consistent_diffusivities
Definition: ERF_TurbStruct.H:976
amrex::Real Ce
Deardorff dissipation coefficient.
Definition: ERF_TurbStruct.H:931
amrex::Real pbl_mrf_Sc_t
MRF turbulent Schmidt number of the passive scalars (erf.pbl_mrf_Sc_t): their vertical diffusivity is...
Definition: ERF_TurbStruct.H:1128
bool enable_mrf_unbounded_vpert
Whether MRF leaves VPERT unlimited by GAMCRT.
Definition: ERF_TurbStruct.H:1129
amrex::Real Sc_t
Turbulent Schmidt number.
Definition: ERF_TurbStruct.H:916
MYNNLevel2 pbl_mynn_level2
MYNN level-2 closure coefficients for limiting.
Definition: ERF_TurbStruct.H:1058
bool diffuse_tke_3D
Whether three-dimensional numerical diffusion is applied to TKE/QKE.
Definition: ERF_TurbStruct.H:1148
bool use_tke
Whether any TKE or QKE closure is active.
Definition: ERF_TurbStruct.H:1067
amrex::Real sigma_k
TKE diffusivity coefficient denominator.
Definition: ERF_TurbStruct.H:944
bool use_Ri_correction
Whether Richardson-number correction is applied.
Definition: ERF_TurbStruct.H:956
bool pbl_ysu_use_consistent_coriolis
Whether YSU uses the ERF Coriolis frequency.
Definition: ERF_TurbStruct.H:1082
amrex::Real pbl_blend_length
Boutle blending length L [m]. 0 = off.
Definition: ERF_TurbStruct.H:1119
amrex::Real Ck
Deardorff eddy-viscosity coefficient.
Definition: ERF_TurbStruct.H:933
bool pbl_mrf_use_zero_ri_extent
Whether MRF uses the Ri=0 K-profile extent.
Definition: ERF_TurbStruct.H:1130
amrex::Real Ce_wall
Wall value for the Deardorff dissipation coefficient.
Definition: ERF_TurbStruct.H:932
amrex::Real qnse_ah
Definition: ERF_TurbStruct.H:1142
amrex::Real mrf_fire_q_threshold
Definition: ERF_TurbStruct.H:1132
RANSType rans_type
Selected RANS closure.
Definition: ERF_TurbStruct.H:960
StratType pbl_strat_type
Definition: ERF_TurbStruct.H:951
RANSShearStencil rans_shear_stencil
Definition: ERF_TurbStruct.H:994
void check_params(amrex::GpuArray< ERF_BC, AMREX_SPACEDIM *2 > &phys_bc_type)
Validate turbulence options against physical boundary conditions.
Definition: ERF_TurbStruct.H:671
bool enable_vh96_shear_correction
Whether Vogelezang & Holtslag (1996) shear-correction term is enabled.
Definition: ERF_TurbStruct.H:1106
amrex::Real theta_ref
Reference potential temperature for stable stratification.
Definition: ERF_TurbStruct.H:947
amrex::Real Sc_t_inv
Inverse turbulent Schmidt number.
Definition: ERF_TurbStruct.H:917
amrex::Real l_g_max
Maximum geometric length scale.
Definition: ERF_TurbStruct.H:940
bool enable_mrf_cloud_adjustment
Whether MRF cloud-aware stability adjustments are enabled.
Definition: ERF_TurbStruct.H:1126
bool use_keqn
Whether a microscale TKE closure is active.
Definition: ERF_TurbStruct.H:1062
bool enable_ysu_entrainment
Whether YSU entrainment-layer parameterization is enabled.
Definition: ERF_TurbStruct.H:1093
bool enable_ysu_sat_limiter
Whether YSU applies a saturation limiter to moisture countergradient terms.
Definition: ERF_TurbStruct.H:1089
bool enable_ysu_cloud_pblh
Whether the YSU PBL-top cell index is raised by one where that cell is cloudy.
Definition: ERF_TurbStruct.H:1095
amrex::Real pbl_mrf_const_b
MRF constant used to compute PBL height.
Definition: ERF_TurbStruct.H:1114
amrex::Real pblh_smoothing_weight
Center-cell weight in PBLH smoothing stencil (must be in [0,1]).
Definition: ERF_TurbStruct.H:1110
amrex::Real pbl_blend_cs
Smagorinsky coeff for K_h ceiling.
Definition: ERF_TurbStruct.H:1120
amrex::Real tke_floor
Definition: ERF_TurbStruct.H:967
bool uses_shoc_family() const noexcept
Query whether this level uses any SHOC-family PBL scheme.
Definition: ERF_TurbStruct.H:1018
amrex::Real ysu_qcloud_threshold
Cloud water plus cloud ice threshold for YSU [kg/kg].
Definition: ERF_TurbStruct.H:1098
amrex::Real qnse_bm
Definition: ERF_TurbStruct.H:1141
amrex::Real pbl_blend_c_max
Power-law ceiling coeff [m^(2/3)/s].
Definition: ERF_TurbStruct.H:1121
bool init_tke_from_ustar
Whether initial TKE/QKE profiles are based on surface friction velocity.
Definition: ERF_TurbStruct.H:1072
amrex::Real qnse_bh
Definition: ERF_TurbStruct.H:1143
bool enable_qnse_stable_functions
Definition: ERF_TurbStruct.H:1138
bool enable_mrf_countergradient
Whether MRF countergradient corrections are enabled.
Definition: ERF_TurbStruct.H:1123
bool enable_ysu_countergradient
Whether YSU countergradient corrections are enabled.
Definition: ERF_TurbStruct.H:1087
bool mix_isotropic
Whether subgrid mixing uses isotropic length scales.
Definition: ERF_TurbStruct.H:954
bool enable_pblh_smoothing
Whether spatial smoothing of diagnosed PBLH is enabled.
Definition: ERF_TurbStruct.H:1108
bool uses_native_shoc() const noexcept
Query whether this level uses the native SHOC PBL scheme.
Definition: ERF_TurbStruct.H:1009
amrex::Real smag2d_kh_cap
Cap K_h <= smag2d_kh_cap * Delta_h for Smagorinsky-2D (m/s); 0 means no cap.
Definition: ERF_TurbStruct.H:925
bool rans_moist_buoyancy
Definition: ERF_TurbStruct.H:1000
bool kh_kv_can_differ() const noexcept
Query whether the horizontal and vertical eddy viscosities can differ on this level.
Definition: ERF_TurbStruct.H:1028
bool dirichlet_k
Whether TKE uses Dirichlet boundary treatment.
Definition: ERF_TurbStruct.H:962
int pblh_smoothing_passes
Number of PBLH smoothing iterations to apply.
Definition: ERF_TurbStruct.H:1109
LESType les_type
Selected LES closure.
Definition: ERF_TurbStruct.H:909
amrex::Real rans_realizability
Definition: ERF_TurbStruct.H:989
void init_params(int lev, int max_level, std::string pp_prefix)
Read turbulence options for one AMR level from the input parameter database.
Definition: ERF_TurbStruct.H:137
amrex::Real pbl_ib_z0
Definition: ERF_TurbStruct.H:1125
bool enable_ysu_topdown
Whether YSU top-down mixing is enabled.
Definition: ERF_TurbStruct.H:1091
bool rans_lscale_from_pblh
Definition: ERF_TurbStruct.H:981
bool pbl_ib_aware
Definition: ERF_TurbStruct.H:1124
amrex::Real ysu_rad_tend_limiter_magnitude
Definition: ERF_TurbStruct.H:1104
amrex::Real rans_lscale_min
Definition: ERF_TurbStruct.H:982
bool pbl_mrf_highres_bounds
Whether MRF applies high-resolution grid-dependent diffusivity bounds.
Definition: ERF_TurbStruct.H:1127
bool mrf_fire_thermal_excess
Definition: ERF_TurbStruct.H:1131
amrex::Real Rt_min
Minimum turbulent Reynolds number.
Definition: ERF_TurbStruct.H:939
bool pbl_blend_use_smag
Use Smagorinsky ceiling (else power-law).
Definition: ERF_TurbStruct.H:1122
MYNNLevel25 pbl_mynn
MYNN level-2.5 closure coefficients.
Definition: ERF_TurbStruct.H:1057
amrex::Real pbl_ysu_land_Ribcr
Critical bulk Richardson number over land for stable YSU conditions.
Definition: ERF_TurbStruct.H:1085
amrex::Real Cb
One-equation RANS buoyancy coefficient.
Definition: ERF_TurbStruct.H:937
amrex::Real Ri_crit
Critical Richardson number for stability correction.
Definition: ERF_TurbStruct.H:957
amrex::Real Rt_crit
Critical turbulent Reynolds number.
Definition: ERF_TurbStruct.H:938
amrex::Real vh96_shear_const_b
Vogelezang & Holtslag (1996) shear-correction constant b.
Definition: ERF_TurbStruct.H:1107
bool smag2d_limits_requested
Whether either Smagorinsky-2D limit was given as on for this level.
Definition: ERF_TurbStruct.H:928
bool pbl_suppresses_microphysics_condensation() const noexcept
Query whether the selected PBL scheme suppresses microphysics condensation.
Definition: ERF_TurbStruct.H:1052
amrex::Real pbl_mrf_Ribcr
Critical bulk Richardson number for the MRF PBL scheme.
Definition: ERF_TurbStruct.H:1113
amrex::Real qnse_am
Definition: ERF_TurbStruct.H:1140
amrex::Real pbl_mrf_sf
MRF surface flux value used to compute PBL height.
Definition: ERF_TurbStruct.H:1115
amrex::Real Cmu0
One-equation RANS Cmu0 coefficient.
Definition: ERF_TurbStruct.H:936
amrex::Real Cs
Smagorinsky model coefficient.
Definition: ERF_TurbStruct.H:920
amrex::Real Pr_t
Turbulent Prandtl number.
Definition: ERF_TurbStruct.H:912
bool smag2d_slope_limiter
Apply WRF's Smagorinsky-2D slope limiter (K_h / alpha or / alpha^2) on terrain-fitted meshes.
Definition: ERF_TurbStruct.H:924
amrex::Real pbl_mrf_coriolis_freq
Coriolis frequency used by the MRF PBL scheme.
Definition: ERF_TurbStruct.H:1112
bool pbl_ysunew_highres_bounds
Whether YSU applies high-resolution grid-dependent diffusivity bounds.
Definition: ERF_TurbStruct.H:1101
amrex::Real tke_min
Minimum TKE/QKE value.
Definition: ERF_TurbStruct.H:1075
amrex::Real pbl_ysu_coriolis_freq
Coriolis frequency used by YSU-family PBL schemes.
Definition: ERF_TurbStruct.H:1079
void display(int lev)
Print turbulence settings for one AMR level.
Definition: ERF_TurbStruct.H:691
bool use_kturb
Whether any turbulence model is active.
Definition: ERF_TurbStruct.H:1061
bool ysu_moistvars
Whether YSU applies turbulence to moisture variables.
Definition: ERF_TurbStruct.H:1100
PBLType pbl_type
Selected PBL closure.
Definition: ERF_TurbStruct.H:1003
amrex::Real Pr_t_inv
Inverse turbulent Prandtl number.
Definition: ERF_TurbStruct.H:913
bool smag2d
Whether the 2-D Smagorinsky formulation is used.
Definition: ERF_TurbStruct.H:921
bool enable_ysu_rad_tend_limiter
Definition: ERF_TurbStruct.H:1103
bool pbl_requires_surface_layer() const noexcept
Query whether the selected PBL scheme requires surface-layer boundary conditions.
Definition: ERF_TurbStruct.H:1039
bool use_pbl_tke
Whether a mesoscale PBL TKE closure is active.
Definition: ERF_TurbStruct.H:1065