Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Const diss rate for micro #162

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ target_link_libraries(uwlcm
clphxx::cloudphxx_lgrngn
)

# enabling c++14, but not gnu++14
# enabling c++17, but not gnu++17
set_target_properties(uwlcm PROPERTIES CXX_EXTENSIONS OFF)
target_compile_features(uwlcm PRIVATE cxx_std_14)
target_compile_features(uwlcm PRIVATE cxx_std_17)

# search for Boost
find_package(Boost COMPONENTS thread iostreams system timer program_options filesystem REQUIRED)
Expand Down
13 changes: 13 additions & 0 deletions src/opts/opts_lgrngn.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ void setopts_micro(
("turb_cond", po::value<bool>()->default_value(rt_params.cloudph_opts.turb_cond), "turbulence effects in SD condensation (1=on, 0=off)")
("turb_adve", po::value<bool>()->default_value(rt_params.cloudph_opts.turb_adve), "turbulence effects in SD motion (1=on, 0=off)")
("turb_coal", po::value<bool>()->default_value(rt_params.cloudph_opts.turb_coal) , "turbulence effects in SD coalescence (1=on, 0=off)")
("turb_diss_rate", po::value<setup::real_t>()->default_value(-1), "TKE dissipation rate (constant) [cm^2/s^3] used in SGS turbulence models in SDM microphysics in ILES. In LES with Smagroinsky, dissipation rate is diagnosed from the flow.")
("ReL", po::value<setup::real_t>()->default_value(100) , "taylor-microscale reynolds number (onishi kernel)")
("out_dry_spec", po::value<bool>()->default_value(false), "enable output for plotting dry spectrum")
("out_wet_spec", po::value<bool>()->default_value(false), "enable output for plotting wet spectrum")
Expand Down Expand Up @@ -425,6 +426,18 @@ void setopts_micro(

rt_params.cloudph_opts_init.turb_adve_switch = vm["turb_adve"].as<bool>();
rt_params.cloudph_opts.turb_adve = vm["turb_adve"].as<bool>();

rt_params.turb_diss_rate = vm["turb_diss_rate"].as<thrust_real_t>();

if constexpr(solver_t::ct_params_t_::sgs_scheme != libmpdataxx::solvers::iles) // SGS
{
if(rt_params.turb_diss_rate >= 0) throw std::runtime_error("turb_diss_rate cannot be set in a simulation with the Smagorinsky model (--sgs=1). It is diagnosed from the flow.");
}
else // ILES
{
if( (rt_params.cloudph_opts.turb_cond || rt_params.cloudph_opts.turb_adve || rt_params.cloudph_opts.turb_coal) && rt_params.turb_diss_rate < 0)
throw std::runtime_error("turb_cond/adve/coal in ILES require turb_diss_rate >= 0");
}

// subsidence of SDs
rt_params.cloudph_opts_init.subs_switch = rt_params.subsidence;
Expand Down
2 changes: 1 addition & 1 deletion src/solvers/blk_2m/update_rhs_blk_2m_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void slvr_blk_2m_common<ct_params_t>::update_rhs(
dot_rc = where(dot_rc * dt <= -rc, -rc / dt, dot_rc);
dot_rr = where(dot_rr * dt <= -rr, -rr / dt, dot_rr);
dot_nc = where(dot_nc * dt <= -nc, -nc / dt, dot_nc);
dot_nr = where(dot_nr * dt <= -rr, -rr / dt, dot_nr);
dot_nr = where(dot_nr * dt <= -nr, -nr / dt, dot_nr);


this->mem->barrier();
Expand Down
1 change: 1 addition & 0 deletions src/solvers/lgrngn/hook_ante_loop_lgrngn.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ void slvr_lgrngn<ct_params_t>::hook_ante_loop(int nt)
this->record_aux_const("turb_adve", "lgrngn", params.cloudph_opts.turb_adve);
this->record_aux_const("turb_cond", "lgrngn", params.cloudph_opts.turb_cond);
this->record_aux_const("turb_coal", "lgrngn", params.cloudph_opts.turb_coal);
this->record_aux_const("turb_diss_rate", "lgrngn", params.turb_diss_rate);
this->record_aux_const("chem_switch", "lgrngn", params.cloudph_opts_init.chem_switch);
this->record_aux_const("coal_switch", "lgrngn", params.cloudph_opts_init.coal_switch);
this->record_aux_const("sedi_switch", "lgrngn", params.cloudph_opts_init.sedi_switch);
Expand Down
6 changes: 3 additions & 3 deletions src/solvers/lgrngn/hook_mixed_rhs_ante_step_lgrngn.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ void slvr_lgrngn<ct_params_t>::hook_mixed_rhs_ante_step()
make_arrinfo(Cx),
this->n_dims == 2 ? libcloudphxx::lgrngn::arrinfo_t<real_t>() : make_arrinfo(Cy),
make_arrinfo(Cz),
(ct_params_t::sgs_scheme == libmpdataxx::solvers::iles) || (!params.cloudph_opts.turb_cond && !params.cloudph_opts.turb_adve && !params.cloudph_opts.turb_coal) ?
libcloudphxx::lgrngn::arrinfo_t<real_t>() :
make_arrinfo(this->diss_rate(this->domain).reindex(this->zero))
(!params.cloudph_opts.turb_cond && !params.cloudph_opts.turb_adve && !params.cloudph_opts.turb_coal) ?
libcloudphxx::lgrngn::arrinfo_t<real_t>() :
make_arrinfo(this->diss_rate(this->domain).reindex(this->zero))
);

// start sync/async run of step_cond
Expand Down
5 changes: 5 additions & 0 deletions src/solvers/slvr_lgrngn.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ class slvr_lgrngn : public std::conditional_t<ct_params_t::sgs_scheme == libmpda
outmom_t<real_t> out_dry, out_wet;
bool flag_coal; // do we want coal after spinup
real_t gccn; // multiplicity of gccn
real_t turb_diss_rate;
};

private:
Expand All @@ -202,6 +203,10 @@ class slvr_lgrngn : public std::conditional_t<ct_params_t::sgs_scheme == libmpda
{
r_c = 0.;
// TODO: equip rank() in libmpdata with an assert() checking if not in serial block

// set the TKE dissipation rate for SGS models in SDM
if constexpr(ct_params_t::sgs_scheme == libmpdataxx::solvers::iles)
this->diss_rate = p.turb_diss_rate * 1e-4; // constant TKE dissipation rate for SGS models in microphysics; change from [cm2/s3] to [m2/s3]
}

static void alloc(typename parent_t::mem_t *mem, const int &n_iters)
Expand Down