Skip to content

Commit

Permalink
MYNN Update (erf-model#1738)
Browse files Browse the repository at this point in the history
* Cleanup, add clarifying comments

* Remove factor of rho from equilibrium (level 2) q

* Update notation to match NN09

* Calculate level 2 coeffs

* Create separate MYNNLevel2 struct

* Use level 2 stability function to calculate level2 qke for the limiter

* Create, update, and handoff Qr_prim to MOSTAverage

* Calculate virtual potential temp in MOSTAverage

* Update MOSTAverage field indices

* Add TODOs to calc buoyancy flux for Obukhov len if qstar is available

<w'Tv'> = <w'T'>(1 + 0.61<qv>) + 0.61<T><w'qv'>, Stull 4.4.5d

* Tv==T in MOSTAverage if no moisture vars

* Implement ABLMost::get_q_star and buoyancy flux calculation in MYNN

Verified dry solution does not change

* Calculate dthetav/dz for MYNN

Verified no solution change for dry

* Update GABLS inputs, gold data, and SCM best practice

* Oops

* Add option to specify eddy diffusivities for moist vars from MYNN

* Make the QKE source term update moisture-aware
  • Loading branch information
ewquon authored Aug 15, 2024
1 parent f5e7060 commit 4f4a729
Show file tree
Hide file tree
Showing 30 changed files with 667 additions and 294 deletions.
9 changes: 6 additions & 3 deletions Docs/sphinx_doc/BestPractices.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,12 @@ Single-Column Model

.. code-block:: python
geometry.prob_extent = 25 25 400
amr.n_cell = 4 4 64
geometry.is_periodic = 1 1 0
geometry.prob_extent = 400 400 400
amr.n_cell = 2 2 64
geometry.is_periodic = 1 1 0
When set up this way, the solution is not sensitive to horizontal problem
extent.

* An SCM was successfully run with third-order advection in the horizontal and
vertical.
99 changes: 52 additions & 47 deletions Docs/sphinx_doc/Inputs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -846,53 +846,58 @@ PBL Scheme
List of Parameters
------------------

+----------------------------------+--------------------+---------------------+-------------+
| Parameter | Definition | Acceptable | Default |
| | | Values | |
+==================================+====================+=====================+=============+
| **erf.pbl_type** | Name of PBL Scheme | "None", "MYNN2.5", | "None" |
| | to be used | "YSU" | |
+----------------------------------+--------------------+---------------------+-------------+
| **erf.pbl_mynn_A1** | MYNN Constant A1 | Real | 1.18 |
+----------------------------------+--------------------+---------------------+-------------+
| **erf.pbl_mynn_A2** | MYNN Constant A2 | Real | 0.665 |
+----------------------------------+--------------------+---------------------+-------------+
| **erf.pbl_mynn_B1** | MYNN Constant B1 | Real | 24.0 |
+----------------------------------+--------------------+---------------------+-------------+
| **erf.pbl_mynn_B2** | MYNN Constant B2 | Real | 15.0 |
+----------------------------------+--------------------+---------------------+-------------+
| **erf.pbl_mynn_C1** | MYNN Constant C1 | Real | 0.137 |
+----------------------------------+--------------------+---------------------+-------------+
| **erf.pbl_mynn_C2** | MYNN Constant C1 | Real | 0.75 |
+----------------------------------+--------------------+---------------------+-------------+
| **erf.pbl_mynn_C3** | MYNN Constant C3 | Real | 0.352 |
+----------------------------------+--------------------+---------------------+-------------+
| **erf.pbl_mynn_C4** | MYNN Constant C4 | Real | 0.0 |
+----------------------------------+--------------------+---------------------+-------------+
| **erf.pbl_mynn_C5** | MYNN Constant C5 | Real | 0.2 |
+----------------------------------+--------------------+---------------------+-------------+
| **erf.advect_QKE** | Include advection | bool | 1 |
| | terms in QKE eqn | | |
+----------------------------------+--------------------+---------------------+-------------+
| **erf.diffuse_QKE_3D** | Include horizontal | bool | 0 |
| | turb. diffusion | | |
| | terms in QKE eqn. | | |
+----------------------------------+--------------------+---------------------+-------------+
| **erf.pbl_ysu_over_land** | Treat whole domain | bool | 1 |
| | as being over land | | |
| | for YSU PBL scheme | | |
+----------------------------------+--------------------+---------------------+-------------+
| **erf.pbl_ysu_land_Ribcr** | Over land critical | Real | 0.25 |
| | Richardson number | | |
| | for YSU PBL Scheme | | |
+----------------------------------+--------------------+---------------------+-------------+
| **erf.pbl_ysu_unst_Ribcr** | Unstable critical | Real | 0.0 |
| | Richardson number | | |
| | for YSU PBL Scheme | | |
+----------------------------------+--------------------+---------------------+-------------+
| **erf.pbl_ysu_coriolis_freq** | Coriolis frq. used | Real | 1.0e-4 |
| | for YSU PBL Scheme | | |
+----------------------------------+--------------------+---------------------+-------------+
+------------------------------------+--------------------+---------------------+-------------+
| Parameter | Definition | Acceptable | Default |
| | | Values | |
+====================================+====================+=====================+=============+
| **erf.pbl_type** | Name of PBL Scheme | "None", "MYNN2.5", | "None" |
| | to be used | "YSU" | |
+------------------------------------+--------------------+---------------------+-------------+
| **erf.pbl_mynn_A1** | MYNN Constant A1 | Real | 1.18 |
+------------------------------------+--------------------+---------------------+-------------+
| **erf.pbl_mynn_A2** | MYNN Constant A2 | Real | 0.665 |
+------------------------------------+--------------------+---------------------+-------------+
| **erf.pbl_mynn_B1** | MYNN Constant B1 | Real | 24.0 |
+------------------------------------+--------------------+---------------------+-------------+
| **erf.pbl_mynn_B2** | MYNN Constant B2 | Real | 15.0 |
+------------------------------------+--------------------+---------------------+-------------+
| **erf.pbl_mynn_C1** | MYNN Constant C1 | Real | 0.137 |
+------------------------------------+--------------------+---------------------+-------------+
| **erf.pbl_mynn_C2** | MYNN Constant C1 | Real | 0.75 |
+------------------------------------+--------------------+---------------------+-------------+
| **erf.pbl_mynn_C3** | MYNN Constant C3 | Real | 0.352 |
+------------------------------------+--------------------+---------------------+-------------+
| **erf.pbl_mynn_C4** | MYNN Constant C4 | Real | 0.0 |
+------------------------------------+--------------------+---------------------+-------------+
| **erf.pbl_mynn_C5** | MYNN Constant C5 | Real | 0.2 |
+------------------------------------+--------------------+---------------------+-------------+
| **erf.pbl_mynn_diffuse_moistvars** | Diffuse moisture | bool | 0 |
| | variables using | | |
| | modeled eddy | | |
| | diffusivity | | |
+------------------------------------+--------------------+---------------------+-------------+
| **erf.advect_QKE** | Include advection | bool | 1 |
| | terms in QKE eqn | | |
+------------------------------------+--------------------+---------------------+-------------+
| **erf.diffuse_QKE_3D** | Include horizontal | bool | 0 |
| | turb. diffusion | | |
| | terms in QKE eqn. | | |
+------------------------------------+--------------------+---------------------+-------------+
| **erf.pbl_ysu_over_land** | Treat whole domain | bool | 1 |
| | as being over land | | |
| | for YSU PBL scheme | | |
+------------------------------------+--------------------+---------------------+-------------+
| **erf.pbl_ysu_land_Ribcr** | Over land critical | Real | 0.25 |
| | Richardson number | | |
| | for YSU PBL Scheme | | |
+------------------------------------+--------------------+---------------------+-------------+
| **erf.pbl_ysu_unst_Ribcr** | Unstable critical | Real | 0.0 |
| | Richardson number | | |
| | for YSU PBL Scheme | | |
+------------------------------------+--------------------+---------------------+-------------+
| **erf.pbl_ysu_coriolis_freq** | Coriolis frq. used | Real | 1.0e-4 |
| | for YSU PBL Scheme | | |
+------------------------------------+--------------------+---------------------+-------------+

Note that both PBL schemes must be used in conjunction with a MOST boundary condition
at the surface (Zlo) boundary. The YSU scheme is work in progress currently.
Expand Down
4 changes: 2 additions & 2 deletions Exec/ABL/inputs_GABLS1_mynn25
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ amrex.fpe_trap_invalid = 0
fabarray.mfiter_tile_size = 1024 1024 1024

# PROBLEM SIZE & GEOMETRY (Cuxart et al. 2006)
geometry.prob_extent = 25 25 400
amr.n_cell = 4 4 64
geometry.prob_extent = 400 400 400
amr.n_cell = 2 2 64

geometry.is_periodic = 1 1 0

Expand Down
11 changes: 8 additions & 3 deletions Source/BoundaryConditions/ABLMost.H
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public:
amrex::Vector<amrex::Vector<amrex::MultiFab>>& vars_old,
amrex::Vector<std::unique_ptr<amrex::MultiFab>>& Theta_prim,
amrex::Vector<std::unique_ptr<amrex::MultiFab>>& Qv_prim,
amrex::Vector<std::unique_ptr<amrex::MultiFab>>& Qr_prim,
amrex::Vector<std::unique_ptr<amrex::MultiFab>>& z_phys_nd,
amrex::Vector<amrex::Vector<std::unique_ptr<amrex::MultiFab>>>& sst_lev,
amrex::Vector<amrex::Vector<std::unique_ptr<amrex::iMultiFab>>>& lmask_lev,
Expand All @@ -50,7 +51,7 @@ public:
m_start_bdy_time(start_bdy_time),
m_bdy_time_interval(bdy_time_interval),
m_geom(geom),
m_ma(geom,vars_old,Theta_prim,Qv_prim,z_phys_nd)
m_ma(geom,vars_old,Theta_prim,Qv_prim,Qr_prim,z_phys_nd)
{
// We have a moisture model if Qv_prim is a valid pointer
use_moisture = (Qv_prim[0].get());
Expand Down Expand Up @@ -304,15 +305,19 @@ public:
update_mac_ptrs (const int& lev,
amrex::Vector<amrex::Vector<amrex::MultiFab>>& vars_old,
amrex::Vector<std::unique_ptr<amrex::MultiFab>>& Theta_prim,
amrex::Vector<std::unique_ptr<amrex::MultiFab>>& Qv_prim)
{ m_ma.update_field_ptrs(lev,vars_old,Theta_prim,Qv_prim); }
amrex::Vector<std::unique_ptr<amrex::MultiFab>>& Qv_prim,
amrex::Vector<std::unique_ptr<amrex::MultiFab>>& Qr_prim)
{ m_ma.update_field_ptrs(lev,vars_old,Theta_prim,Qv_prim,Qr_prim); }

const amrex::MultiFab*
get_u_star (const int& lev) { return u_star[lev].get(); }

const amrex::MultiFab*
get_t_star (const int& lev) { return t_star[lev].get(); }

const amrex::MultiFab*
get_q_star (const int& lev) { return q_star[lev].get(); }

const amrex::MultiFab*
get_olen (const int& lev) { return olen[lev].get(); }

Expand Down
4 changes: 2 additions & 2 deletions Source/BoundaryConditions/ABLMost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ ABLMost::compute_fluxes (const int& lev,
{
// Pointers to the computed averages
const auto *const tm_ptr = m_ma.get_average(lev,2);
const auto *const umm_ptr = m_ma.get_average(lev,4);
const auto *const umm_ptr = m_ma.get_average(lev,5);

for (MFIter mfi(*u_star[lev]); mfi.isValid(); ++mfi)
{
Expand Down Expand Up @@ -307,7 +307,7 @@ ABLMost::compute_most_bcs (const int& lev,
const auto *const v_mean = m_ma.get_average(lev,1);
const auto *const t_mean = m_ma.get_average(lev,2);
const auto *const q_mean = m_ma.get_average(lev,3);
const auto *const u_mag_mean = m_ma.get_average(lev,4);
const auto *const u_mag_mean = m_ma.get_average(lev,5);

const auto um_arr = u_mean->array(mfi);
const auto vm_arr = v_mean->array(mfi);
Expand Down
8 changes: 5 additions & 3 deletions Source/BoundaryConditions/MOSTAverage.H
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public:
amrex::Vector<amrex::Vector<amrex::MultiFab>>& vars_old,
amrex::Vector<std::unique_ptr<amrex::MultiFab>>& Theta_prim,
amrex::Vector<std::unique_ptr<amrex::MultiFab>>& Qv_prim,
amrex::Vector<std::unique_ptr<amrex::MultiFab>>& Qr_prim,
amrex::Vector<std::unique_ptr<amrex::MultiFab>>& z_phys_nd);

// MOSTAverage() = default;
Expand All @@ -38,7 +39,8 @@ public:
void update_field_ptrs (int lev,
amrex::Vector<amrex::Vector<amrex::MultiFab>>& vars_old,
amrex::Vector<std::unique_ptr<amrex::MultiFab>>& Theta_prim,
amrex::Vector<std::unique_ptr<amrex::MultiFab>>& Qv_prim);
amrex::Vector<std::unique_ptr<amrex::MultiFab>>& Qv_prim,
amrex::Vector<std::unique_ptr<amrex::MultiFab>>& Qr_prim);

// Update the rotated fields
void set_rotated_fields (int lev);
Expand Down Expand Up @@ -170,8 +172,8 @@ protected:

// General vars for multiple or all policies
//--------------------------------------------
int m_nvar{5}; // 5 fields for U/V/T/Qv/W
int m_navg{5}; // 5 averages for U/V/T/Qv/Umag
int m_nvar{6}; // 6 fields for U/V/T/Qv/Qr/W
int m_navg{6}; // 6 averages for U/V/T/Qv/Tv/Umag
int m_maxlev{0}; // Total number of levels
int m_policy{0}; // Policy for type of averaging
bool m_rotate{false}; // Do vector rotations for terrain?
Expand Down
Loading

0 comments on commit 4f4a729

Please sign in to comment.