ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_AddTKESources.H
Go to the documentation of this file.
1  // Using Deardorff (see Sullivan et al 1994)
2  // or k-eqn RANS (see Axell & Liungman 2001)
3  //
4  // Note: At this point, the thermal diffusivity ("Khv" field in ERF), the
5  // subgrid heat flux ("hfx_z" here), and the subgrid dissipation
6  // ("diss" here) have been updated by ComputeTurbulentViscosityLES --
7  // at the beginning of each timestep.
8  // The strain rate magnitude is updated at the beginning of the first
9  // RK stage only, therefore the shear production term also does not
10  // change between RK stages.
11  // The surface heat flux hfx_z(i,j,-1) is updated in MOSTStress at
12  // each RK stage, but that does not change the buoyancy production term here.
13  if (l_use_keqn && (start_comp <= RhoKE_comp) && (end_comp >= RhoKE_comp)) {
14  int qty_index = RhoKE_comp;
15  ParallelFor(bx,[=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
16  {
17  // Add Buoyancy Source
18  // where the SGS buoyancy flux tau_{theta,i} = -KH * dtheta/dx_i,
19  // such that for dtheta/dz < 0, there is a positive (upward) heat
20  // flux; the TKE buoyancy production is then
21  // B = g/theta_0 * tau_{theta,w}
22  // for a dry atmosphere.
23  // TODO: To account for moisture, the Brunt-Vaisala frequency,
24  // N^2 = g[1/theta * dtheta/dz + ...]
25  // **should** be a function of the water vapor and total water
26  // mixing ratios, depending on whether conditions are saturated or
27  // not (see the WRF model description, Skamarock et al 2019).
28  cell_rhs(i,j,k,qty_index) += l_abs_g * l_inv_theta0 * hfx_z(i,j,k);
29  if (!use_ref_theta) {
30  // l_inv_theta0 == 1, divide by actual theta
31  cell_rhs(i,j,k,qty_index) /= cell_prim(i,j,k,PrimTheta_comp);
32  }
33 
34  // TKE shear production
35  // P = -tau_ij * S_ij = 2 * mu_turb * S_ij * S_ij
36  // Note: This assumes that the horizontal and vertical diffusivities
37  // of momentum are equal
38  cell_rhs(i,j,k,qty_index) += two*mu_turb(i,j,k,EddyDiff::Mom_v) * SmnSmn_a(i,j,k);
39 
40  // TKE dissipation
41  cell_rhs(i,j,k,qty_index) -= diss(i,j,k);
42  });
43  }
constexpr amrex::Real two
Definition: ERF_Constants.H:8
#define PrimTheta_comp
Definition: ERF_IndexDefines.H:50
#define RhoKE_comp
Definition: ERF_IndexDefines.H:38
ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept { const Real *dx=geomdata.CellSize();const Real x=(i+0.5) *dx[0];const Real y=(j+0.5) *dx[1];const Real Omg=erf_vortex_Gaussian(x, y, xc, yc, R, beta, sigma);const Real deltaT=-(gamma - 1.0)/(2.0 *sigma *sigma) *Omg *Omg;const Real rho_norm=std::pow(1.0+deltaT, inv_gm1);const Real T=(1.0+deltaT) *T_inf;const Real p=std::pow(rho_norm, Gamma)/Gamma *rho_0 *a_inf *a_inf;const Real rho_theta=rho_0 *rho_norm *(T *std::pow(p_0/p, rdOcp));state_pert(i, j, k, RhoTheta_comp)=rho_theta - getRhoThetagivenP(p_hse(i, j, k));const Real r2d_xy=std::sqrt((x-xc) *(x-xc)+(y-yc) *(y-yc));state_pert(i, j, k, RhoScalar_comp)=0.25 *(1.0+std::cos(PI *std::min(r2d_xy, R)/R));})
const int end_comp
Definition: ERF_SetupDiff.H:11
bool l_use_keqn
Definition: ERF_SetupDiff.H:12
const bool use_ref_theta
Definition: ERF_SetupDiff.H:16
const Real l_inv_theta0
Definition: ERF_SetupDiff.H:17
@ Mom_v
Definition: ERF_IndexDefines.H:193