Skip to content

Commit

Permalink
Add harmonics limiter for entr/detr, set GABLS config
Browse files Browse the repository at this point in the history
  • Loading branch information
trontrytel committed Sep 27, 2023
1 parent bac0b76 commit 3976c84
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 11 deletions.
1 change: 0 additions & 1 deletion .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,6 @@ steps:
julia --color=yes --project=examples examples/hybrid/driver.jl
--config_file $CONFIG_PATH/edmfx_gabls_box.yml
artifact_paths: "edmfx_gabls_box/*"
soft_fail: true
agents:
slurm_mem: 20GB

Expand Down
5 changes: 3 additions & 2 deletions config/model_configs/edmfx_gabls_box.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ x_elem: 2
y_elem: 2
z_elem: 8
z_stretch: false
dt: "10secs"
dt: "5secs"
t_end: "9hours"
dt_save_to_disk: "10mins"
perturb_initstate: false
FLOAT_TYPE: "Float64"
toml: [toml/edmfx_box_gabls.toml]
toml: [toml/edmfx_box.toml]
#toml: [toml/edmfx_box_gabls.toml]
6 changes: 3 additions & 3 deletions examples/hybrid/driver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ import OrderedCollections
using ClimaCoreTempestRemap
using ClimaCorePlots, Plots
using ClimaCoreMakie, CairoMakie
if config.comms_ctx isa ClimaComms.SingletonCommsContext
include(joinpath(pkgdir(CA), "perf", "jet_report_nfailures.jl"))
end
#if config.comms_ctx isa ClimaComms.SingletonCommsContext
# include(joinpath(pkgdir(CA), "perf", "jet_report_nfailures.jl"))
#end
include(joinpath(pkgdir(CA), "post_processing", "contours_and_profiles.jl"))
include(joinpath(pkgdir(CA), "post_processing", "post_processing_funcs.jl"))
include(
Expand Down
53 changes: 50 additions & 3 deletions src/prognostic_equations/edmfx_entr_detr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
##### EDMF entrainment detrainment
#####

# return a harmonic mean of (a, 1-a)
hm_limiter(a) = 2 * a * (1 - a)

"""
Return entrainment rate [1/s].
Expand Down Expand Up @@ -107,6 +110,28 @@ function entrainment(
return entr
end

function entrainment(
params,
ᶜz::FT,
z_sfc::FT,
ᶜp::FT,
ᶜρ::FT,
buoy_flux_surface::FT,
ᶜaʲ::FT,
ᶜwʲ::FT,
ᶜRHʲ::FT,
ᶜbuoyʲ::FT,
ᶜw⁰::FT,
ᶜRH⁰::FT,
ᶜbuoy⁰::FT,
dt::FT,
::ConstantCoefficientHarmonicsEntrainment,
) where {FT}
entr_coeff = CAP.entr_coeff(params)
entr = min(entr_coeff * abs(ᶜwʲ) / (ᶜz - z_sfc), 1 / dt)
return entr * FT(2) * hm_limiter(ᶜaʲ)
end

function entrainment(
params,
ᶜz::FT,
Expand Down Expand Up @@ -236,12 +261,34 @@ function detrainment(
return detr
end

function detrainment(
params,
ᶜz::FT,
z_sfc::FT,
ᶜp::FT,
ᶜρ::FT,
buoy_flux_surface::FT,
ᶜaʲ::FT,
ᶜwʲ::FT,
ᶜRHʲ::FT,
ᶜbuoyʲ::FT,
ᶜw⁰::FT,
ᶜRH⁰::FT,
ᶜbuoy⁰::FT,
dt::FT,
::ConstantCoefficientHarmonicsDetrainment,
) where {FT}
detr_coeff = CAP.detr_coeff(params)
detr = min(detr_coeff * abs(ᶜwʲ), 1 / dt)
return detr * FT(2) * hm_limiter(ᶜaʲ)
end

edmfx_entr_detr_tendency!(Yₜ, Y, p, t, colidx, turbconv_model) = nothing
function edmfx_entr_detr_tendency!(Yₜ, Y, p, t, colidx, turbconv_model::EDMFX)

n = n_mass_flux_subdomains(turbconv_model)
(; ᶜspecificʲs, ᶜh_totʲs, ᶜentrʲs, ᶜdetrʲs) = p
(; ᶜu⁰, ᶜspecific⁰, ᶜh_tot⁰) = p
(; ᶜspecific⁰, ᶜh_tot⁰, ᶠu₃⁰) = p

for j in 1:n

Expand All @@ -262,8 +309,8 @@ function edmfx_entr_detr_tendency!(Yₜ, Y, p, t, colidx, turbconv_model::EDMFX)
)

@. Yₜ.f.sgsʲs.:($$j).u₃[colidx] +=
ᶠinterp(ᶜentrʲs.:($$j)[colidx] * C3(ᶜu⁰[colidx])) -
ᶠinterp(ᶜentrʲs.:($$j)[colidx]) * Y.f.sgsʲs.:($$j).u₃[colidx]
ᶠinterp(ᶜentrʲs.:($$j)[colidx]) *
(ᶠu₃⁰[colidx] - Y.f.sgsʲs.:($$j).u₃[colidx])
end
return nothing
end
4 changes: 4 additions & 0 deletions src/solver/model_getters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,8 @@ function get_entrainment_model(parsed_args)
PiGroupsEntrainment()
elseif entr_model == "ConstantCoefficient"
ConstantCoefficientEntrainment()
elseif entr_model == "ConstantCoefficientHarmonics"
ConstantCoefficientHarmonicsEntrainment()
elseif entr_model == "ConstantTimescale"
ConstantTimescaleEntrainment()
else
Expand All @@ -387,6 +389,8 @@ function get_detrainment_model(parsed_args)
PiGroupsDetrainment()
elseif detr_model == "ConstantCoefficient"
ConstantCoefficientDetrainment()
elseif detr_model == "ConstantCoefficientHarmonics"
ConstantCoefficientHarmonicsDetrainment()
else
error("Invalid entr_model $(entr_model)")
end
Expand Down
2 changes: 2 additions & 0 deletions src/solver/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,15 @@ abstract type AbstractEntrainmentModel end
struct NoEntrainment <: AbstractEntrainmentModel end
struct PiGroupsEntrainment <: AbstractEntrainmentModel end
struct ConstantCoefficientEntrainment <: AbstractEntrainmentModel end
struct ConstantCoefficientHarmonicsEntrainment <: AbstractEntrainmentModel end
struct ConstantTimescaleEntrainment <: AbstractEntrainmentModel end

abstract type AbstractDetrainmentModel end

struct NoDetrainment <: AbstractDetrainmentModel end
struct PiGroupsDetrainment <: AbstractDetrainmentModel end
struct ConstantCoefficientDetrainment <: AbstractDetrainmentModel end
struct ConstantCoefficientHarmonicsDetrainment <: AbstractDetrainmentModel end

abstract type AbstractQuadratureType end
struct LogNormalQuad <: AbstractQuadratureType end
Expand Down
2 changes: 1 addition & 1 deletion toml/edmfx_box.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ type = "float"

[EDMF_min_area]
alias = "min_area"
value = 1.0e-2
value = 1.0e-3
type = "float"
description = "Minimum area fraction per updraft. Parameter not described in the literature."
20 changes: 19 additions & 1 deletion toml/edmfx_box_gabls.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,25 @@ alias = "C_E"
value = 0.044
type = "float"

[entr_coeff]
alias = "entr_coeff"
value = 1.0
type = "float"
description = "TODO: Remove this. Constant entrainment coefficient used for testing EDMF"

[detr_coeff]
alias = "detr_coeff"
value = 0.001
type = "float"
description = "TODO: Remove this. Constant entrainment coefficient used for testing EDMF"

[EDMF_surface_area]
alias = "surface_area"
value = 1e-4
value = 1e-1
type = "float"

[EDMF_min_area]
alias = "min_area"
value = 1.0e-3
type = "float"
description = "Minimum area fraction per updraft. Parameter not described in the literature."

0 comments on commit 3976c84

Please sign in to comment.