Skip to content

Commit f1f1a90

Browse files
authored
Merge pull request #3988 from CliMA/zs/diagedmf_massflux
add mass flux to microphysic tracers in diagnostic EDMF
2 parents c668894 + 60c88f9 commit f1f1a90

File tree

2 files changed

+55
-2
lines changed

2 files changed

+55
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ NVTX = "0.3, 1"
6464
NullBroadcasts = "0.1"
6565
RRTMGP = "0.21.5"
6666
Random = "1"
67-
SciMLBase = "2.108"
67+
SciMLBase = "~2.108, ~2.109, ~2.110, ~2.111, ~2.112"
6868
SparseMatrixColorings = "0.4.20"
6969
StaticArrays = "1.9"
7070
Statistics = "1"

src/prognostic_equations/edmfx_sgs_flux.jl

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,60 @@ function edmfx_sgs_mass_flux_tendency!(
269269
)
270270
@. Yₜ.c.ρq_tot += vtt
271271
end
272-
# TODO: add environment flux?
272+
end
273+
274+
# Microphysics tracers fluxes
275+
if p.atmos.moisture_model isa NonEquilMoistModel && (
276+
p.atmos.microphysics_model isa Microphysics1Moment ||
277+
p.atmos.microphysics_model isa Microphysics2Moment
278+
)
279+
microphysics_tracers = (
280+
(@name(c.ρq_liq), @name(ᶜq_liqʲs.:(1))),
281+
(@name(c.ρq_ice), @name(ᶜq_iceʲs.:(1))),
282+
(@name(c.ρq_rai), @name(ᶜq_raiʲs.:(1))),
283+
(@name(c.ρq_sno), @name(ᶜq_snoʲs.:(1))),
284+
(@name(c.ρn_liq), @name(ᶜn_liqʲs.:(1))),
285+
(@name(c.ρn_rai), @name(ᶜn_raiʲs.:(1))),
286+
)
287+
for j in 1:n
288+
# TODO using unrolled_foreach here allocates! (breaks the flame tests
289+
# even though they use 0M microphysics)
290+
# MatrixFields.unrolled_foreach(
291+
# microphysics_tracers,
292+
# ) do (ρχ_name, χʲ_name)
293+
for (ρχ_name, χʲ_name) in microphysics_tracers
294+
MatrixFields.has_field(Y, ρχ_name) || continue
295+
296+
ᶜχʲ = MatrixFields.get_field(p.precomputed, χʲ_name)
297+
ᶜρχ = MatrixFields.get_field(Y, ρχ_name)
298+
ᶜχ = (@. lazy(specific(ᶜρχ, Y.c.ρ)))
299+
300+
@. ᶠu³_diff = ᶠu³ʲs.:($$j) - ᶠu³
301+
# @. ᶜa_scalar =
302+
# (ᶜχʲ - ᶜχ) *
303+
# draft_area(ᶜρaʲs.:($$j), ᶜρʲs.:($$j))
304+
# TODO: remove this filter when mass flux is treated implicitly
305+
@. ᶜa_scalar =
306+
(ᶜχʲ - ᶜχ) * min(
307+
min(draft_area(ᶜρaʲs.:($$j), ᶜρʲs.:($$j)), a_max),
308+
FT(0.02) / max(
309+
Geometry.WVector(
310+
ᶜinterp(ᶠu³_diff),
311+
).components.data.:1,
312+
eps(FT),
313+
),
314+
)
315+
vtt = vertical_transport_precip_massflux(
316+
ᶜρʲs.:($j),
317+
ᶠu³_diff,
318+
ᶜa_scalar,
319+
dt,
320+
edmfx_sgsflux_upwinding,
321+
)
322+
ᶜρχₜ = MatrixFields.get_field(Yₜ, ρχ_name)
323+
@. ᶜρχₜ += vtt
324+
end
325+
end
273326
end
274327
# TODO: the following adds the environment flux to the tendency
275328
# Make active and test later

0 commit comments

Comments
 (0)