Skip to content

Commit 4a28a99

Browse files
authored
Merge pull request #4097 from CliMA/sa/fix_edmf_diffusion
Fix edmf diffusion;
2 parents 79028dd + f982cc0 commit 4a28a99

File tree

2 files changed

+16
-22
lines changed

2 files changed

+16
-22
lines changed

src/prognostic_equations/edmfx_sgs_flux.jl

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ function edmfx_sgs_diffusive_flux_tendency!(
390390
thermo_params = CAP.thermodynamics_params(params)
391391
turbconv_params = CAP.turbconv_params(params)
392392
c_d = CAP.tke_diss_coeff(turbconv_params)
393-
(; ᶜK, ᶜu⁰, ᶜK⁰, ᶜlinear_buoygrad, ᶜstrain_rate_norm, ᶜts) = p.precomputed
393+
(; ᶜK, ᶜu⁰, ᶜK⁰, ᶜlinear_buoygrad, ᶜstrain_rate_norm, ᶜρʲs, ᶜts, ᶜts⁰) = p.precomputed
394394
(; ρatke_flux) = p.precomputed
395395
ᶠgradᵥ = Operators.GradientC2F()
396396
ᶜρa⁰ = @. lazy(ρa⁰(Y.c.ρ, Y.c.sgsʲs, turbconv_model))
@@ -475,6 +475,8 @@ function edmfx_sgs_diffusive_flux_tendency!(
475475
top = Operators.SetValue(C3(FT(0))),
476476
bottom = Operators.SetValue(C3(FT(0))),
477477
)
478+
ᶜρʲ = ᶜρʲs.:(1)
479+
ᶜρ⁰ = @. lazy(TD.air_density(thermo_params, ᶜts⁰))
478480

479481
microphysics_tracers = (
480482
(@name(c.ρq_liq), @name(c.sgsʲs.:(1).q_liq), @name(q_liq), FT(1)),
@@ -495,15 +497,19 @@ function edmfx_sgs_diffusive_flux_tendency!(
495497
ᶜχ⁰ = ᶜspecific_env_value(χ_name, Y, p)
496498

497499
# add updraft diffusion
498-
@. ᶜρχₜ_diffusion = ᶜdivᵥ_ρq(
499-
-(ᶠinterp(Y.c.sgsʲs.:(1).ρa) * ᶠinterp(ᶜK_h) * α * ᶠgradᵥ(ᶜχʲ)),
500-
)
500+
@. ᶜρχₜ_diffusion =
501+
draft_area(Y.c.sgsʲs.:(1).ρa, ᶜρʲ) *
502+
ᶜdivᵥ_ρq(
503+
-(ᶠinterp(ᶜρʲ) * ᶠinterp(ᶜK_h) * α * ᶠgradᵥ(ᶜχʲ)),
504+
)
501505
@. ᶜρχₜ -= ᶜρχₜ_diffusion
502506

503507
# add environment diffusion
504-
@. ᶜρχₜ_diffusion = ᶜdivᵥ_ρq(
505-
-(ᶠinterp(ᶜρa⁰) * ᶠinterp(ᶜK_h) * α * ᶠgradᵥ(ᶜχ⁰)),
506-
)
508+
@. ᶜρχₜ_diffusion =
509+
draft_area(ᶜρa⁰, ᶜρ⁰) *
510+
ᶜdivᵥ_ρq(
511+
-(ᶠinterp(ᶜρ⁰) * ᶠinterp(ᶜK_h) * α * ᶠgradᵥ(ᶜχ⁰)),
512+
)
507513
@. ᶜρχₜ -= ᶜρχₜ_diffusion
508514
end
509515
end

src/prognostic_equations/mass_flux_closures.jl

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,8 @@ function edmfx_vertical_diffusion_tendency!(
129129
)
130130
if p.atmos.edmfx_model.vertical_diffusion isa Val{true}
131131
(; params) = p
132-
(; ᶜts, ᶜK, ᶜρʲs) = p.precomputed
132+
(; ᶜρʲs) = p.precomputed
133133
FT = eltype(p.params)
134-
thermo_params = CAP.thermodynamics_params(params)
135134
turbconv_params = CAP.turbconv_params(params)
136135
n = n_mass_flux_subdomains(turbconv_model)
137136
ᶜdivᵥ_mse = Operators.DivergenceF2C(
@@ -142,15 +141,6 @@ function edmfx_vertical_diffusion_tendency!(
142141
top = Operators.SetValue(C3(0)),
143142
bottom = Operators.SetValue(C3(0)),
144143
)
145-
ᶜinv_ρ̂ = (@. lazy(
146-
specific(
147-
FT(1),
148-
Y.c.sgsʲs.:(1).ρa,
149-
FT(0),
150-
ᶜρʲs.:(1),
151-
turbconv_model,
152-
),
153-
))
154144

155145
(; ᶜlinear_buoygrad, ᶜstrain_rate_norm) = p.precomputed
156146
ᶜtke⁰ = @. lazy(specific(Y.c.sgs⁰.ρatke, Y.c.ρ))
@@ -165,7 +155,6 @@ function edmfx_vertical_diffusion_tendency!(
165155

166156
for j in 1:n
167157
ᶜρʲ = ᶜρʲs.:($j)
168-
ᶜρaʲ = Y.c.sgsʲs.:($j).ρa
169158
ᶜmseʲ = Y.c.sgsʲs.:($j).mse
170159
ᶜq_totʲ = Y.c.sgsʲs.:($j).q_tot
171160
# Note: For this and other diffusive tendencies, we should use ρaʲ instead of ρʲ,
@@ -181,7 +170,7 @@ function edmfx_vertical_diffusion_tendency!(
181170
p.atmos.microphysics_model isa Microphysics2Moment
182171
)
183172
α_precip = CAP.α_vert_diff_tracer(params)
184-
ᶜρaʲ = Y.c.sgsʲs.:(1).ρa
173+
ᶜρʲ = ᶜρʲs.:(1)
185174
ᶜdivᵥ_q = Operators.DivergenceF2C(
186175
top = Operators.SetValue(C3(FT(0))),
187176
bottom = Operators.SetValue(C3(FT(0))),
@@ -205,8 +194,7 @@ function edmfx_vertical_diffusion_tendency!(
205194
ᶜχʲ = MatrixFields.get_field(Y, χʲ_name)
206195
ᶜχʲₜ = MatrixFields.get_field(Yₜ, χʲ_name)
207196

208-
@. ᶜχʲₜ -=
209-
ᶜinv_ρ̂ * ᶜdivᵥ_q(-(ᶠinterp(ᶜρaʲ) * ᶠinterp(ᶜK_h) * α * ᶠgradᵥ(ᶜχʲ)))
197+
@. ᶜχʲₜ -= ᶜdivᵥ_q(-(ᶠinterp(ᶜρʲ) * ᶠinterp(ᶜK_h) * α * ᶠgradᵥ(ᶜχʲ))) / ᶜρʲ
210198
end
211199
end
212200
end

0 commit comments

Comments
 (0)