Skip to content

Commit

Permalink
Calculate dthetav/dz for MYNN
Browse files Browse the repository at this point in the history
Verified no solution change for dry
  • Loading branch information
ewquon committed Aug 14, 2024
1 parent 1eb6435 commit f0c7650
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 27 deletions.
64 changes: 39 additions & 25 deletions Source/Diffusion/PBLModels.H
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
#ifndef _PBLMODELS_H_
#define _PBLMODELS_H_

AMREX_GPU_DEVICE
AMREX_FORCE_INLINE
amrex::Real
Thetav (int i, int j, int k,
const amrex::Array4<const amrex::Real>& cell_data,
const bool use_moisture)
{
amrex::Real thetav = cell_data(i,j,k,RhoTheta_comp) / cell_data(i,j,k,Rho_comp);
if (use_moisture) {
thetav *= (1.0 + 0.61 * cell_data(i,j,k,RhoQ1_comp) / cell_data(i,j,k,Rho_comp));
}
return thetav;
}

/**
* Function for computing vertical derivatives for use in PBL model
*
Expand All @@ -11,35 +25,35 @@
AMREX_GPU_DEVICE
AMREX_FORCE_INLINE
void
ComputeVerticalDerivativesPBL(int i, int j, int k,
const amrex::Array4<const amrex::Real>& uvel,
const amrex::Array4<const amrex::Real>& vvel,
const amrex::Array4<const amrex::Real>& cell_data,
const int izmin,
const int izmax,
const amrex::Real& dz_inv,
const bool c_ext_dir_on_zlo,
const bool c_ext_dir_on_zhi,
const bool u_ext_dir_on_zlo,
const bool u_ext_dir_on_zhi,
const bool v_ext_dir_on_zlo,
const bool v_ext_dir_on_zhi,
amrex::Real& dthetadz,
amrex::Real& dudz,
amrex::Real& dvdz)
ComputeVerticalDerivativesPBL (int i, int j, int k,
const amrex::Array4<const amrex::Real>& uvel,
const amrex::Array4<const amrex::Real>& vvel,
const amrex::Array4<const amrex::Real>& cell_data,
const int izmin,
const int izmax,
const amrex::Real& dz_inv,
const bool c_ext_dir_on_zlo,
const bool c_ext_dir_on_zhi,
const bool u_ext_dir_on_zlo,
const bool u_ext_dir_on_zhi,
const bool v_ext_dir_on_zlo,
const bool v_ext_dir_on_zhi,
amrex::Real& dthetadz,
amrex::Real& dudz,
amrex::Real& dvdz,
const bool use_moisture = false)
{
// TODO: account for moisture
if ( k==izmax && c_ext_dir_on_zhi ) {
dthetadz = (1.0/3.0)*(-cell_data(i,j,k-1,RhoTheta_comp)/cell_data(i,j,k-1,Rho_comp)
- 3.0 * cell_data(i,j,k ,RhoTheta_comp)/cell_data(i,j,k ,Rho_comp)
+ 4.0 * cell_data(i,j,k+1,RhoTheta_comp)/cell_data(i,j,k+1,Rho_comp) )*dz_inv;
dthetadz = (1.0/3.0)*( -Thetav(i,j,k-1,cell_data,use_moisture)
- 3.0 * Thetav(i,j,k ,cell_data,use_moisture)
+ 4.0 * Thetav(i,j,k+1,cell_data,use_moisture) )*dz_inv;
} else if ( k==izmin && c_ext_dir_on_zlo ) {
dthetadz = (1.0/3.0)*( cell_data(i,j,k+1,RhoTheta_comp)/cell_data(i,j,k+1,Rho_comp)
+ 3.0 * cell_data(i,j,k ,RhoTheta_comp)/cell_data(i,j,k ,Rho_comp)
- 4.0 * cell_data(i,j,k-1,RhoTheta_comp)/cell_data(i,j,k-1,Rho_comp) )*dz_inv;
dthetadz = (1.0/3.0)*( Thetav(i,j,k+1,cell_data,use_moisture)
+ 3.0 * Thetav(i,j,k ,cell_data,use_moisture)
- 4.0 * Thetav(i,j,k-1,cell_data,use_moisture) )*dz_inv;
} else {
dthetadz = 0.5*( cell_data(i,j,k+1,RhoTheta_comp)/cell_data(i,j,k+1,Rho_comp)
- cell_data(i,j,k-1,RhoTheta_comp)/cell_data(i,j,k-1,Rho_comp) )*dz_inv;
dthetadz = 0.5*( Thetav(i,j,k+1,cell_data,use_moisture)
- Thetav(i,j,k-1,cell_data,use_moisture) )*dz_inv;
}

if ( k==izmax && u_ext_dir_on_zhi ) {
Expand Down
5 changes: 3 additions & 2 deletions Source/Diffusion/PBLModels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ ComputeTurbulentViscosityPBL (const MultiFab& xvel,
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);

// Spatially varying MOST
Real theta0 = tm_arr(i,j,0);
Expand Down Expand Up @@ -230,7 +231,7 @@ ComputeTurbulentViscosityPBL (const MultiFab& xvel,

// Calculate nondimensional production terms
Real shearProd = dudz*dudz + dvdz*dvdz;
Real buoyProd = -(CONST_GRAV/theta0) * dthetadz; // TODO: account for moisture
Real buoyProd = -(CONST_GRAV/theta0) * dthetadz;
Real L2_over_q2 = Lturb*Lturb/(qvel(i,j,k)*qvel(i,j,k));
Real GM = L2_over_q2 * shearProd;
Real GH = L2_over_q2 * buoyProd;
Expand Down

0 comments on commit f0c7650

Please sign in to comment.