Skip to content

Commit 4bfcd52

Browse files
committed
fix(diffusion): use the shared sedimenting-tracer list in vertical diffusion
Select the tracers that receive the α_vert_diff_tracer eddy-diffusivity scaling in vertical_diffusion_boundary_layer_tendency! from the shared gs_sedimenting_tracer_candidates list instead of a stale hardcoded tuple of species. The tracer diffusivity scaling is now consistent with the EDMFX SGS flux, the EDMFX updraft vertical diffusion, and the implicit Jacobian, which already use that list.
1 parent 0ec0ffb commit 4bfcd52

4 files changed

Lines changed: 80 additions & 4 deletions

File tree

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ ClimaAtmos.jl Release Notes
33

44
main
55
----
6+
- [#4699](https://github.com/CliMA/ClimaAtmos.jl/pull/4699) ![][badge-🔥behavioralΔ] Select the tracers that receive the `α_vert_diff_tracer` eddy-diffusivity scaling in the boundary-layer vertical diffusion from the shared `gs_sedimenting_tracer_candidates` list instead of a hardcoded tuple of species. The tracer diffusivity scaling is now consistent across the boundary-layer diffusion, the EDMFX SGS flux, the EDMFX updraft vertical diffusion, and the implicit Jacobian.
67

78
0.42.0
89
-------

src/prognostic_equations/vertical_diffusion_boundary_layer.jl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,7 @@ function vertical_diffusion_boundary_layer_tendency!(
134134
ᶜK_h_scaled = p.scratch.ᶜtemp_scalar_3
135135

136136
foreach_gs_tracer(Yₜ, Y) do ᶜρχₜ, ᶜρχ, ρχ_name
137-
if ρχ_name in (
138-
@name(ρq_lcl), @name(ρq_icl), @name(ρq_rai),
139-
@name(ρq_sno), @name(ρn_lcl), @name(ρn_rai)
140-
)
137+
if ρχ_name in gs_sedimenting_tracer_candidates
141138
@. ᶜK_h_scaled = α_vert_diff_microphysics * ᶜK_h
142139
else
143140
@. ᶜK_h_scaled = ᶜK_h
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Sedimenting tracers in `gs_sedimenting_tracer_candidates` (including P3
2+
# `ρn_ice`/`ρq_rim`/`ρb_rim`) receive the `α_vert_diff_tracer`-scaled diffusivity;
3+
# passive tracers keep the unscaled diffusivity.
4+
using Test
5+
import ClimaComms
6+
ClimaComms.@import_required_backends
7+
import ClimaAtmos as CA
8+
import ClimaAtmos.Parameters as CAP
9+
import ClimaParams as CP
10+
import ClimaCore: Fields, Geometry
11+
12+
include("../test_helpers.jl")
13+
14+
@testset "Vertical diffusion tracer diffusivity scaling" begin
15+
FT = Float64
16+
α = FT(0.4)
17+
override_file = Dict(
18+
"tracer_vertical_diffusion_factor" => Dict("value" => α, "type" => "float"),
19+
)
20+
params = CA.ClimaAtmosParameters(CP.create_toml_dict(FT; override_file))
21+
@test CAP.α_vert_diff_tracer(params) == α
22+
23+
(; cent_space) = get_cartesian_spaces(; FT)
24+
coords = Fields.coordinate_field(cent_space)
25+
ᶜz = coords.z
26+
27+
tracer_names = (:ρq_tot, :ρq_rai, :ρn_ice, :ρq_rim, :ρb_rim, :ρq_gas_A)
28+
NT = NamedTuple{
29+
(, :ρe_tot, tracer_names...),
30+
NTuple{2 + length(tracer_names), FT},
31+
}
32+
Yc = similar(coords, NT)
33+
@. Yc.ρ = FT(1.2)
34+
@. Yc.ρe_tot = Yc.ρ * FT(2.5e5)
35+
@. Yc.ρq_tot = Yc.ρ * FT(1e-2)
36+
ᶜρχ = @. Yc.ρ * cos(ᶜz)
37+
@. Yc.ρq_rai = ᶜρχ
38+
@. Yc.ρn_ice = ᶜρχ
39+
@. Yc.ρq_rim = ᶜρχ
40+
@. Yc.ρb_rim = ᶜρχ
41+
@. Yc.ρq_gas_A = ᶜρχ
42+
Y = Fields.FieldVector(; c = Yc)
43+
44+
ᶜu = @. Geometry.UVWVector(zero(ᶜz), zero(ᶜz), zero(ᶜz))
45+
ᶜp = @. FT(1e5) - FT(1e3) * ᶜz
46+
ᶜT = @. FT(280) - FT(20) * (ᶜz / FT(π))
47+
ᶜq_liq = @. FT(1e-4) + zero(ᶜz)
48+
ᶜq_ice = @. FT(1e-5) + zero(ᶜz)
49+
ᶜq_tot_nonneg = @. FT(1e-2) + zero(ᶜz)
50+
p = (;
51+
atmos = (;
52+
vertical_diffusion = CA.DecayWithHeightDiffusion{FT}(;
53+
disable_momentum_vertical_diffusion = true,
54+
H = FT(1),
55+
D₀ = FT(1),
56+
),
57+
),
58+
params,
59+
precomputed = (; ᶜu, ᶜp, ᶜT, ᶜq_liq, ᶜq_ice, ᶜq_tot_nonneg),
60+
core = (; ᶜΦ = (@. CAP.grav(params) * ᶜz)),
61+
scratch = (;
62+
ᶜtemp_scalar = similar(ᶜz),
63+
ᶜtemp_scalar_2 = similar(ᶜz),
64+
ᶜtemp_scalar_3 = similar(ᶜz),
65+
),
66+
)
67+
68+
Yₜ = Fields.FieldVector(; c = zero(Yc))
69+
CA.vertical_diffusion_boundary_layer_tendency!(Yₜ, Y, p, FT(0))
70+
71+
@test maximum(abs, parent(Yₜ.c.ρq_rai)) > 0
72+
@test parent(Yₜ.c.ρn_ice) == parent(Yₜ.c.ρq_rai)
73+
@test parent(Yₜ.c.ρq_rim) == parent(Yₜ.c.ρq_rai)
74+
@test parent(Yₜ.c.ρb_rim) == parent(Yₜ.c.ρq_rai)
75+
@test parent(Yₜ.c.ρn_ice) α .* parent(Yₜ.c.ρq_gas_A)
76+
@test parent(Yₜ.c.ρq_gas_A) != parent(Yₜ.c.ρn_ice)
77+
end

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ if TEST_GROUP in ("dynamics", "all")
6363
@safetestset "Tendency computations" begin @time include("prognostic_equations/tendency_tests.jl") end
6464
@safetestset "Tracer/mass transport consistency" begin @time include("prognostic_equations/tracer_mass_consistency_tests.jl") end
6565
@safetestset "Post-Newton implicit-advection correction" begin @time include("prognostic_equations/correct_implicit_advection_tests.jl") end
66+
@safetestset "Vertical diffusion tracer scaling" begin @time include("prognostic_equations/vertical_diffusion_tests.jl") end
6667
@safetestset "Vertical water borrowing limiter" begin @time include("prognostic_equations/vertical_water_borrowing_tests.jl") end
6768
@safetestset "Enforce physical constraints" begin @time include("prognostic_equations/enforce_physical_constraints_tests.jl") end
6869
@safetestset "Eddy diffusion closures" begin @time include("prognostic_equations/eddy_diffusion_closures_tests.jl") end

0 commit comments

Comments
 (0)