Skip to content

Commit

Permalink
add entrainment and detrainment limiter to diagnostic edmf
Browse files Browse the repository at this point in the history
  • Loading branch information
szy21 committed Dec 9, 2023
1 parent b26b78b commit 94f181d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/cache/diagnostic_edmf_precomputed_quantities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ function set_diagnostic_edmf_precomputed_quantities_do_integral!(Y, p, t)
FT = eltype(Y)
n = n_mass_flux_subdomains(turbconv_model)
ᶜz = Fields.coordinate_field(Y.c).z
ᶜdz = Fields.Δz_field(axes(Y.c))
(; params) = p
(; dt) = p
(; ᶜΦ, ᶜρ_ref) = p.core
Expand Down Expand Up @@ -295,6 +296,7 @@ function set_diagnostic_edmf_precomputed_quantities_do_integral!(Y, p, t)
ts_prev_level = Fields.field_values(Fields.level(ᶜts, i - 1))
p_prev_level = Fields.field_values(Fields.level(ᶜp, i - 1))
z_prev_level = Fields.field_values(Fields.level(ᶜz, i - 1))
dz_prev_level = Fields.field_values(Fields.level(ᶜdz, i - 1))

local_geometry_prev_level = Fields.field_values(
Fields.level(Fields.local_geometry_field(Y.c), i - 1),
Expand Down Expand Up @@ -368,6 +370,18 @@ function set_diagnostic_edmf_precomputed_quantities_do_integral!(Y, p, t)
p.atmos.edmfx_entr_model,
)

if i > 2
@. entrʲ_prev_level = limit_entrainment(
entrʲ_prev_level,
draft_area(ρaʲ_prev_level, ρʲ_prev_level),
get_physical_w(
u³ʲ_prev_halflevel,
local_geometry_prev_halflevel,
),
dz_prev_level,
)
end

# TODO: use updraft top instead of scale height
@. nh_pressure³ʲ_prev_halflevel = ᶠupdraft_nh_pressure(
params,
Expand Down Expand Up @@ -497,6 +511,18 @@ function set_diagnostic_edmf_precomputed_quantities_do_integral!(Y, p, t)
p.atmos.edmfx_detr_model,
)

if i > 2
@. detrʲ_prev_level = limit_entrainment(
detrʲ_prev_level,
draft_area(ρaʲ_prev_level, ρʲ_prev_level),
get_physical_w(
u³ʲ_prev_halflevel,
local_geometry_prev_halflevel,
),
dz_prev_level,
)
end

ρaʲu³ʲ_data = p.scratch.temp_data_level_2
ρaʲu³ʲ_datah_tot = ρaʲu³ʲ_dataq_tot = p.scratch.temp_data_level_3

Expand Down
6 changes: 6 additions & 0 deletions src/prognostic_equations/edmfx_entr_detr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -403,3 +403,9 @@ function edmfx_entr_detr_tendency!(
end
return nothing
end

limit_entrainment(entr::FT, a, dt) where {FT} =
max(min(entr, (1 - a) / max(a, eps(FT)) / dt), 0)
limit_entrainment(entr, a, w, dz) = max(min(entr, w / dz), 0)
limit_detrainment(detr, a, dt) = max(min(detr, 1 / dt), 0)
limit_detrainment(detr, a, w, dz) = max(min(detr, w / dz), 0)

0 comments on commit 94f181d

Please sign in to comment.