ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ShocPDF Class Reference

#include <ERF_ShocPDF.H>

Static Public Member Functions

static void diagnose_pdf (ShocColumnData &col, const ShocRuntimeOptions &opts, double dt)
 

Member Function Documentation

◆ diagnose_pdf()

void ShocPDF::diagnose_pdf ( ShocColumnData col,
const ShocRuntimeOptions opts,
double  dt 
)
static
284 {
285  // Interim native-SHOC contract: this PDF remains liquid-cloud
286  // macrophysics. It may carry pre-existing ice through the thermodynamic
287  // state, but it does not create or repartition cloud ice here.
288  FArrayBox w3_zt, thl_sec_zt, qw_sec_zt, wthl_zt, wqw_zt, qwthl_zt;
289  const auto layout = col.layout;
290  const Box cell_box(IntVect(0,0,0), IntVect(layout.ncell - 1, layout.nlev - 1, 0));
291  w3_zt.resize(cell_box, 1, The_Async_Arena());
292  thl_sec_zt.resize(cell_box, 1, The_Async_Arena());
293  qw_sec_zt.resize(cell_box, 1, The_Async_Arena());
294  wthl_zt.resize(cell_box, 1, The_Async_Arena());
295  wqw_zt.resize(cell_box, 1, The_Async_Arena());
296  qwthl_zt.resize(cell_box, 1, The_Async_Arena());
297 
298  {
299  BL_PROFILE("SHOC::advance::pdf::interpolate");
300  interpolate_iface_to_cc(col, col.w3, w3_zt, shoc_large_neg());
301  interpolate_iface_to_cc(col, col.thl_sec, thl_sec_zt, 0.0_rt);
302  interpolate_iface_to_cc(col, col.qw_sec, qw_sec_zt, 0.0_rt);
303  interpolate_iface_to_cc(col, col.wthl_sec, wthl_zt, shoc_large_neg());
304  interpolate_iface_to_cc(col, col.wqw_sec, wqw_zt, shoc_large_neg());
305  interpolate_iface_to_cc(col, col.qwthl_sec, qwthl_zt, shoc_large_neg());
306  }
307 
308  auto shoc_cldfrac = col.shoc_cldfrac.array();
309  auto shoc_ql = col.shoc_ql.array();
310  auto shoc_ql2 = col.shoc_ql2.array();
311  auto shoc_cond = col.shoc_cond.array();
312  auto shoc_evap = col.shoc_evap.array();
313  auto wqls_sec = col.wqls_sec.array();
314  auto wthv_sec = col.wthv_sec.array();
315 
316  const auto thetal = col.thetal.const_array();
317  const auto qw = col.qw.const_array();
318  const auto w_field = col.w.const_array();
319  const auto p_mid = col.p_mid.const_array();
320  const auto thl_sec = thl_sec_zt.const_array();
321  const auto qw_sec = qw_sec_zt.const_array();
322  const auto qwthl_sec = qwthl_zt.const_array();
323  const auto wthl_sec = wthl_zt.const_array();
324  const auto wqw_sec = wqw_zt.const_array();
325  const auto w_sec = col.w_sec.const_array();
326  const auto w3 = w3_zt.const_array();
327 
328  {
329  BL_PROFILE("SHOC::advance::pdf::main_kernel");
330  ParallelFor(cell_box, [=] AMREX_GPU_DEVICE (int ic, int k, int) noexcept
331  {
332  const Real thl_first = thetal(ic,k,0);
333  const Real qw_first = qw(ic,k,0);
334  const Real w_first = w_field(ic,k,0);
335  const Real w2sec = amrex::max(w_sec(ic,k,0), 0.0_rt);
336  const Real sqrtw2 = std::sqrt(w2sec);
337  const Real sqrtthl = amrex::max(shoc_thl_tol(), std::sqrt(amrex::max(thl_sec(ic,k,0), 0.0_rt)));
338  const Real sqrtqt = amrex::max(shoc_rt_tol(), std::sqrt(amrex::max(qw_sec(ic,k,0), 0.0_rt)));
339 
340  Real skew_w = 0.0, w1_1 = w_first, w1_2 = w_first, w2_1 = 0.0, w2_2 = 0.0, a = 0.5;
341  vv_parameters(w_first, w2sec, w3(ic,k,0), skew_w, w1_1, w1_2, w2_1, w2_2, a);
342 
343  Real thl1_1 = thl_first, thl1_2 = thl_first, thl2_1 = 0.0, thl2_2 = 0.0;
344  Real sqrtthl2_1 = 0.0, sqrtthl2_2 = 0.0;
345  thl_parameters(wthl_sec(ic,k,0), sqrtw2, sqrtthl, amrex::max(thl_sec(ic,k,0), 0.0_rt),
346  thl_first, w1_1, w1_2, skew_w, a,
347  thl1_1, thl1_2, thl2_1, thl2_2, sqrtthl2_1, sqrtthl2_2);
348 
349  Real qw1_1 = qw_first, qw1_2 = qw_first, qw2_1 = 0.0, qw2_2 = 0.0;
350  Real sqrtqw2_1 = 0.0, sqrtqw2_2 = 0.0;
351  qw_parameters(wqw_sec(ic,k,0), sqrtw2, skew_w, sqrtqt, amrex::max(qw_sec(ic,k,0), 0.0_rt),
352  w1_2, w1_1, qw_first, a,
353  qw1_1, qw1_2, qw2_1, qw2_2, sqrtqw2_1, sqrtqw2_2);
354 
355  w1_1 = w1_1 * sqrtw2 + w_first;
356  w1_2 = w1_2 * sqrtw2 + w_first;
357 
358  const Real r_qwthl_1 = inplume_correlation(sqrtqw2_1, sqrtthl2_1, a,
359  sqrtqw2_2, sqrtthl2_2,
360  qwthl_sec(ic,k,0), qw1_1, qw_first,
361  thl1_1, thl_first, qw1_2, thl1_2);
362 
363  Real Tl1_1 = amrex::max(shoc_tl_min(), compute_temperature(thl1_1, p_mid(ic,k,0)));
364  Real Tl1_2 = amrex::max(shoc_tl_min(), compute_temperature(thl1_2, p_mid(ic,k,0)));
365  Real qs1 = 0.0_rt, beta1 = 0.0_rt, qs2 = 0.0_rt, beta2 = 0.0_rt;
366  compute_qs_beta(Tl1_1, p_mid(ic,k,0), qs1, beta1);
367  compute_qs_beta(Tl1_2, p_mid(ic,k,0), qs2, beta2);
368 
369  Real s1 = 0.0_rt, std_s1 = 0.0_rt, qn1 = 0.0_rt, c1 = 0.0_rt;
370  Real s2 = 0.0_rt, std_s2 = 0.0_rt, qn2 = 0.0_rt, c2 = 0.0_rt;
371  compute_s_terms(qw1_1, qs1, beta1, p_mid(ic,k,0), thl2_1, qw2_1,
372  sqrtthl2_1, sqrtqw2_1, r_qwthl_1, s1, std_s1, qn1, c1);
373 
374  if (qw1_1 == qw1_2 && thl2_1 == thl2_2 && qs1 == qs2) {
375  s2 = s1;
376  std_s2 = std_s1;
377  qn2 = qn1;
378  c2 = c1;
379  } else {
380  compute_s_terms(qw1_2, qs2, beta2, p_mid(ic,k,0), thl2_2, qw2_2,
381  sqrtthl2_2, sqrtqw2_2, r_qwthl_1, s2, std_s2, qn2, c2);
382  }
383 
384  const Real ql1 = amrex::min(qn1, qw1_1);
385  const Real ql2 = amrex::min(qn2, qw1_2);
386  const Real old_ql = shoc_ql(ic,k,0);
387  const Real cldfrac = amrex::min(1.0_rt, a * c1 + (1.0_rt - a) * c2);
388  const Real ql = amrex::max(0.0_rt, a * ql1 + (1.0_rt - a) * ql2);
389  const Real ql2_var = amrex::max(0.0_rt, a * (s1 * ql1 + c1 * std_s1 * std_s1)
390  + (1.0_rt - a) * (s2 * ql2 + c2 * std_s2 * std_s2)
391  - ql * ql);
392  const Real wqls = a * ((w1_1 - w_first) * ql1) + (1.0_rt - a) * ((w1_2 - w_first) * ql2);
393 
394  shoc_cldfrac(ic,k,0) = clamp01(cldfrac);
395  shoc_ql(ic,k,0) = ql;
396  shoc_ql2(ic,k,0) = ql2_var;
397  wqls_sec(ic,k,0) = wqls;
398  wthv_sec(ic,k,0) = compute_buoyancy_flux(wthl_sec(ic,k,0), wqw_sec(ic,k,0),
399  p_mid(ic,k,0), wqls);
400 
401  if (opts.extra_shoc_diags) {
402  const Real dt = static_cast<Real>(dt_d);
403  const Real ql_change = ql - old_ql;
404  shoc_cond(ic,k,0) = amrex::max(0.0_rt, ql_change / amrex::max(dt, eps()));
405  shoc_evap(ic,k,0) = amrex::max(0.0_rt, -ql_change / amrex::max(dt, eps()));
406  } else {
407  shoc_cond(ic,k,0) = 0.0_rt;
408  shoc_evap(ic,k,0) = 0.0_rt;
409  }
410  });
411  }
412 }
ParallelFor(grown_box, [=] AMREX_GPU_DEVICE(int i, int j, int k) { qrcuten_arr(i, j, k)=Real(0);qscuten_arr(i, j, k)=Real(0);qicuten_arr(i, j, k)=Real(0);})
amrex::Real Real
Definition: ERF_ShocInterface.H:19
AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE Real compute_temperature(const Real p_b, const Real q_t, const Real eq_pot_temp, const bool use_empirical, const int which_zone, const Real scaled_height)
Definition: ERF_HSEUtils.H:478
@ qn2
Definition: ERF_AdvanceWSM6.cpp:103
real(c_double), parameter c2
Definition: ERF_module_model_constants.F90:35
real(c_double), private c1
Definition: ERF_module_mp_morr_two_moment.F90:212
amrex::FArrayBox shoc_cond
Definition: ERF_ShocTypes.H:246
amrex::FArrayBox w_sec
Definition: ERF_ShocTypes.H:258
amrex::FArrayBox w3
Definition: ERF_ShocTypes.H:257
amrex::FArrayBox shoc_evap
Definition: ERF_ShocTypes.H:247
amrex::FArrayBox wthv_sec
Definition: ERF_ShocTypes.H:241
amrex::FArrayBox wqw_sec
Definition: ERF_ShocTypes.H:253
amrex::FArrayBox shoc_ql
Definition: ERF_ShocTypes.H:243
amrex::FArrayBox w
Definition: ERF_ShocTypes.H:226
amrex::FArrayBox qw_sec
Definition: ERF_ShocTypes.H:250
ShocColumnLayout layout
Definition: ERF_ShocTypes.H:205
amrex::FArrayBox qw
Definition: ERF_ShocTypes.H:221
amrex::FArrayBox p_mid
Definition: ERF_ShocTypes.H:211
amrex::FArrayBox wqls_sec
Definition: ERF_ShocTypes.H:245
amrex::FArrayBox wthl_sec
Definition: ERF_ShocTypes.H:252
amrex::FArrayBox thl_sec
Definition: ERF_ShocTypes.H:249
amrex::FArrayBox shoc_ql2
Definition: ERF_ShocTypes.H:244
amrex::FArrayBox qwthl_sec
Definition: ERF_ShocTypes.H:251
amrex::FArrayBox shoc_cldfrac
Definition: ERF_ShocTypes.H:242
amrex::FArrayBox thetal
Definition: ERF_ShocTypes.H:217
bool extra_shoc_diags
Definition: ERF_ShocTypes.H:100

Referenced by ShocDiagnostics::diagnose_post_implicit().

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

The documentation for this class was generated from the following files: