Skip to content

Commit

Permalink
Make the QKE source term update moisture-aware
Browse files Browse the repository at this point in the history
  • Loading branch information
ewquon committed Aug 15, 2024
1 parent 6543199 commit ace1d2a
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 11 deletions.
6 changes: 4 additions & 2 deletions Source/Diffusion/Diffusion.H
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ void DiffusionSrcForState_N (const amrex::Box& bx, const amrex::Box& domain,
const amrex::Array4<const amrex::Real>& tm_arr,
const amrex::GpuArray<amrex::Real,AMREX_SPACEDIM> grav_gpu,
const amrex::BCRec* bc_ptr,
const bool use_most);
const bool use_most,
const bool use_moisture);

void DiffusionSrcForState_T (const amrex::Box& bx, const amrex::Box& domain,
int start_comp, int num_comp,
Expand Down Expand Up @@ -99,7 +100,8 @@ void DiffusionSrcForState_T (const amrex::Box& bx, const amrex::Box& domain,
const amrex::Array4<const amrex::Real>& tm_arr,
const amrex::GpuArray<amrex::Real,AMREX_SPACEDIM> grav_gpu,
const amrex::BCRec* bc_ptr,
const bool use_most);
const bool use_most,
const bool use_moisture);



Expand Down
5 changes: 4 additions & 1 deletion Source/Diffusion/DiffusionSrcForState_N.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ using namespace amrex;
* @param[in] grav_gpu gravity vector
* @param[in] bc_ptr container with boundary conditions
* @param[in] use_most whether we have turned on MOST BCs
* @param[in] use_moisture whether we account for moisture in the QKE update
*/
void
DiffusionSrcForState_N (const Box& bx, const Box& domain,
Expand Down Expand Up @@ -63,7 +64,8 @@ DiffusionSrcForState_N (const Box& bx, const Box& domain,
const Array4<const Real>& tm_arr,
const GpuArray<Real,AMREX_SPACEDIM> grav_gpu,
const BCRec* bc_ptr,
const bool use_most)
const bool use_most,
const bool use_moisture)
{
BL_PROFILE_VAR("DiffusionSrcForState_N()",DiffusionSrcForState_N);

Expand Down Expand Up @@ -535,6 +537,7 @@ DiffusionSrcForState_N (const Box& bx, const Box& domain,
cell_rhs(i, j, k, qty_index) += ComputeQKESourceTerms(i,j,k,u,v,cell_data,cell_prim,
mu_turb,cellSizeInv,domain,
pbl_mynn_B1_l,tm_arr(i,j,0),
use_moisture,
c_ext_dir_on_zlo, c_ext_dir_on_zhi,
u_ext_dir_on_zlo, u_ext_dir_on_zhi,
v_ext_dir_on_zlo, v_ext_dir_on_zhi);
Expand Down
8 changes: 6 additions & 2 deletions Source/Diffusion/DiffusionSrcForState_T.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ using namespace amrex;
* @param[in] grav_gpu gravity vector
* @param[in] bc_ptr container with boundary conditions
* @param[in] use_most whether we have turned on MOST BCs
* @param[in] use_moisture whether we account for moisture in the QKE update
*/
void
DiffusionSrcForState_T (const Box& bx, const Box& domain,
Expand Down Expand Up @@ -71,7 +72,8 @@ DiffusionSrcForState_T (const Box& bx, const Box& domain,
const Array4<const Real>& tm_arr,
const GpuArray<Real,AMREX_SPACEDIM> grav_gpu,
const BCRec* bc_ptr,
const bool use_most)
const bool use_most,
const bool use_moisture)
{
BL_PROFILE_VAR("DiffusionSrcForState_T()",DiffusionSrcForState_T);

Expand Down Expand Up @@ -656,7 +658,9 @@ DiffusionSrcForState_T (const Box& bx, const Box& domain,
{
const Real met_h_zeta = detJ(i,j,k);
cell_rhs(i, j, k, qty_index) += ComputeQKESourceTerms(i,j,k,u,v,cell_data,cell_prim,
mu_turb,cellSizeInv,domain,pbl_mynn_B1_l,tm_arr(i,j,0),
mu_turb,cellSizeInv,domain,
pbl_mynn_B1_l,tm_arr(i,j,0),
use_moisture,
c_ext_dir_on_zlo, c_ext_dir_on_zhi,
u_ext_dir_on_zlo, u_ext_dir_on_zhi,
v_ext_dir_on_zlo, v_ext_dir_on_zhi,
Expand Down
6 changes: 4 additions & 2 deletions Source/Diffusion/PBLModels.H
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ ComputeQKESourceTerms (int i, int j, int k,
const amrex::Box& domain,
amrex::Real pbl_mynn_B1_l,
const amrex::Real theta_mean,
bool use_moisture,
bool c_ext_dir_on_zlo,
bool c_ext_dir_on_zhi,
bool u_ext_dir_on_zlo,
Expand All @@ -124,15 +125,16 @@ ComputeQKESourceTerms (int i, int j, int k,
c_ext_dir_on_zlo, c_ext_dir_on_zhi,
u_ext_dir_on_zlo, u_ext_dir_on_zhi,
v_ext_dir_on_zlo, v_ext_dir_on_zhi,
dthetadz, dudz, dvdz);
dthetadz, dudz, dvdz,
use_moisture);

// Note: Transport terms due to turbulence and pressure are included when
// DiffusionSrcForState_* is called.

// Shear Production (Note: We store mu_turb, which is 0.5*K_turb)
source_term += 4.0*K_turb(i,j,k,EddyDiff::Mom_v) * (dudz*dudz + dvdz*dvdz);

// Buoyancy (TODO: implement partial-condensation scheme)
// Buoyancy Production
source_term -= 2.0*(CONST_GRAV/theta_mean)*K_turb(i,j,k,EddyDiff::Theta_v)*dthetadz;

// Dissipation
Expand Down
5 changes: 5 additions & 0 deletions Source/Diffusion/PBLModels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,11 @@ ComputeTurbulentViscosityPBL (const MultiFab& xvel,
K_turb(i,j,k,EddyDiff::Theta_v) = rho * Lturb * qvel(i,j,k) * SH;
K_turb(i,j,k,EddyDiff::QKE_v) = rho * Lturb * qvel(i,j,k) * SQ;

// TODO: implement partial-condensation scheme?
// Currently, implementation matches NN09 without rain (i.e.,
// the liquid water potential temperature is equal to the
// potential temperature.

// NN09 gives the total water content flux; this assumes that
// all the species have the same eddy diffusivity
if (update_moist_eddydiff) {
Expand Down
6 changes: 4 additions & 2 deletions Source/TimeIntegration/ERF_slow_rhs_post.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,14 +394,16 @@ void erf_slow_rhs_post (int level, int finest_level,
z_nd, ax_arr, ay_arr, az_arr, detJ_arr,
dxInv, SmnSmn_a, mf_m, mf_u, mf_v,
hfx_z, q1fx_z, q2fx_z, diss,
mu_turb, dc, tc, tm_arr, grav_gpu, bc_ptr_d, use_most);
mu_turb, dc, tc,
tm_arr, grav_gpu, bc_ptr_d, use_most, l_use_moisture);
} else {
DiffusionSrcForState_N(tbx, domain, start_comp, num_comp, exp_most, u, v,
new_cons, cur_prim, cell_rhs,
diffflux_x, diffflux_y, diffflux_z,
dxInv, SmnSmn_a, mf_m, mf_u, mf_v,
hfx_z, q1fx_z, q2fx_z, diss,
mu_turb, dc, tc, tm_arr, grav_gpu, bc_ptr_d, use_most);
mu_turb, dc, tc,
tm_arr, grav_gpu, bc_ptr_d, use_most, l_use_moisture);
}
} // use_diff
} // valid slow var
Expand Down
4 changes: 2 additions & 2 deletions Source/TimeIntegration/ERF_slow_rhs_pre.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,15 +481,15 @@ if (cell_data(i,j,k,RhoTheta_comp) < 0.) printf("BAD THETA AT %d %d %d %e %e \n"
z_nd, ax_arr, ay_arr, az_arr, detJ_arr,
dxInv, SmnSmn_a, mf_m, mf_u, mf_v,
hfx_z, q1fx_z, q2fx_z, diss, mu_turb, dc, tc,
tm_arr, grav_gpu, bc_ptr_d, l_use_most);
tm_arr, grav_gpu, bc_ptr_d, l_use_most, l_use_moisture);
} else {
DiffusionSrcForState_N(bx, domain, n_start, n_comp, l_exp_most, u, v,
cell_data, cell_prim, cell_rhs,
diffflux_x, diffflux_y, diffflux_z,
dxInv, SmnSmn_a, mf_m, mf_u, mf_v,
hfx_z, q1fx_z, q2fx_z, diss,
mu_turb, dc, tc,
tm_arr, grav_gpu, bc_ptr_d, l_use_most);
tm_arr, grav_gpu, bc_ptr_d, l_use_most, l_use_moisture);
}
}

Expand Down

0 comments on commit ace1d2a

Please sign in to comment.