Skip to content

Commit 496a86a

Browse files
committed
Add constant horizontal diffusion option for testing
1 parent 79e7695 commit 496a86a

File tree

12 files changed

+85
-5
lines changed

12 files changed

+85
-5
lines changed

.buildkite/Manifest-v1.11.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -445,9 +445,9 @@ weakdeps = ["CUDA"]
445445

446446
[[deps.ClimaParams]]
447447
deps = ["Dates", "TOML"]
448-
git-tree-sha1 = "995991392b8bf4c8400b38ba5bcb7d3a0e7d9cce"
448+
git-tree-sha1 = "5ade630eb2f88bd670f316b7fb9f8001adc772c2"
449449
uuid = "5c42b081-d73a-476f-9059-fd94b934656c"
450-
version = "1.0.3"
450+
version = "1.0.7"
451451

452452
[[deps.ClimaReproducibilityTests]]
453453
deps = ["OrderedCollections", "PrettyTables"]
@@ -1864,7 +1864,7 @@ version = "2.5.5+0"
18641864
[[deps.OpenLibm_jll]]
18651865
deps = ["Artifacts", "Libdl"]
18661866
uuid = "05823500-19ac-5b8b-9628-191a04bc5112"
1867-
version = "0.8.1+4"
1867+
version = "0.8.5+0"
18681868

18691869
[[deps.OpenMPI_jll]]
18701870
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Hwloc_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "MPIPreferences", "TOML", "Zlib_jll"]

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ ClimaComms = "0.6.9"
4747
ClimaCore = "0.14.43"
4848
ClimaDiagnostics = "0.2.13"
4949
ClimaInterpolations = "0.1.0"
50-
ClimaParams = "1.0.2"
50+
ClimaParams = "1.0.7"
5151
ClimaTimeSteppers = "0.8.2"
5252
ClimaUtilities = "0.1.27"
5353
CloudMicrophysics = "0.28, 0.29"

config/default_configs/default_config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ amd_les:
169169
c_amd:
170170
help: "Model coefficient for AMD-LES closure (TODO: Move to parameters.toml)"
171171
value: 0.29
172+
constant_horizontal_diffusion:
173+
help: "Constant horizontal diffusion closure [`true`, `false` (default)]"
174+
value: false
172175
smagorinsky_lilly:
173176
help: "Smagorinsky-Lilly diffusive closure [`nothing` (default), `UVW`, `UV`, `W`, `UV_W_decoupled`]"
174177
value: ~

config/model_configs/aquaplanet_nonequil_allsky_gw_res.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
constant_horizontal_diffusion: true
12
viscous_sponge: false
23
dt: "360secs"
34
t_end: "1days"

src/ClimaAtmos.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,13 @@ include(
138138
"anisotropic_minimum_dissipation.jl",
139139
),
140140
)
141+
include(
142+
joinpath(
143+
"parameterized_tendencies",
144+
"les_sgs_models",
145+
"constant_horizontal_diffusion.jl",
146+
),
147+
)
141148
include(joinpath("prognostic_equations", "advection.jl"))
142149

143150
include(joinpath("cache", "temporary_quantities.jl"))
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#####
2+
##### Constant Horizontal Diffusion
3+
#####
4+
5+
horizontal_constant_diffusion_tendency!(Yₜ, Y, p, t, ::Nothing) = nothing
6+
7+
"""
8+
horizontal_constant_diffusion_tendency!(Yₜ,Y, p, t, ::ConstantHorizontalDiffusion)
9+
10+
"""
11+
function horizontal_constant_diffusion_tendency!(
12+
Yₜ,
13+
Y,
14+
p,
15+
t,
16+
chd::ConstantHorizontalDiffusion,
17+
)
18+
FT = eltype(Y)
19+
thermo_params = CAP.thermodynamics_params(p.params)
20+
(; ᶜtemp_scalar) = p.scratch
21+
(; ᶜts) = p.precomputed
22+
23+
ᶜD = @. ᶜtemp_scalar = FT(chd.D)
24+
25+
# Total energy diffusion
26+
ᶜh_tot = @. lazy(
27+
TD.total_specific_enthalpy(
28+
thermo_params,
29+
ᶜts,
30+
specific(Y.c.ρe_tot, Y.c.ρ),
31+
),
32+
)
33+
@. Yₜ.c.ρe_tot += wdivₕ(Y.c.ρ * ᶜD * gradₕ(ᶜh_tot))
34+
35+
# Tracer diffusion
36+
foreach_gs_tracer(Yₜ, Y) do ᶜρχₜ, ᶜρχ, ρχ_name
37+
ᶜχ = @. lazy(specific(ᶜρχ, Y.c.ρ))
38+
ᶜρχₜ_diffusion = @. lazy(wdivₕ(Y.c.ρ * ᶜD * gradₕ(ᶜχ)))
39+
@. ᶜρχₜ += ᶜρχₜ_diffusion
40+
if ρχ_name == @name(ρq_tot)
41+
@. Yₜ.c.ρ += ᶜρχₜ_diffusion
42+
end
43+
end
44+
end

src/parameters/Parameters.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ Base.@kwdef struct ClimaAtmosParameters{
120120
α_hyperdiff_tracer::FT
121121
# Vertical diffusion
122122
α_vert_diff_tracer::FT
123+
# Constant horizontal diffusion
124+
constant_horizontal_diffusion_D::FT
123125
end
124126

125127
Base.eltype(::ClimaAtmosParameters{FT}) where {FT} = FT

src/parameters/create_parameters.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ atmos_name_map = (;
136136
:optics_lookup_temperature_max => :optics_lookup_temperature_max,
137137
:tracer_hyperdiffusion_factor => :α_hyperdiff_tracer,
138138
:tracer_vertical_diffusion_factor => :α_vert_diff_tracer,
139+
:D_horizontal_diffusion => :constant_horizontal_diffusion_D,
139140
)
140141

141142
cloud_parameters(::Type{FT}) where {FT <: AbstractFloat} =

src/prognostic_equations/remaining_tendency.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,9 @@ NVTX.@annotate function additional_tendency!(Yₜ, Y, p, t)
357357
horizontal_amd_tendency!(Yₜ, Y, p, t, amd)
358358
vertical_amd_tendency!(Yₜ, Y, p, t, amd)
359359

360+
chd = p.atmos.constant_horizontal_diffusion
361+
horizontal_constant_diffusion_tendency!(Yₜ, Y, p, t, chd)
362+
360363
# Optional tendency to bring negative small tracers back from negative
361364
# at the cost of water vapor.
362365
moisture_fixer_tendency!(Yₜ, Y, p, t, moisture_model, microphysics_model)

src/solver/model_getters.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,14 @@ function get_amd_les_model(parsed_args, ::Type{FT}) where {FT}
192192
nothing
193193
end
194194

195+
function get_constant_horizontal_diffusion_model(parsed_args, params, ::Type{FT}) where {FT}
196+
is_model_active = parsed_args["constant_horizontal_diffusion"]
197+
@assert is_model_active in (true, false)
198+
return is_model_active ?
199+
ConstantHorizontalDiffusion{FT}(CAP.constant_horizontal_diffusion_D(params)) :
200+
nothing
201+
end
202+
195203
function get_rayleigh_sponge_model(parsed_args, params, ::Type{FT}) where {FT}
196204
rs_name = parsed_args["rayleigh_sponge"]
197205
return if rs_name in ("false", false)

0 commit comments

Comments
 (0)