Skip to content

Commit 9793487

Browse files
authored
Merge pull request #3928 from CliMA/zs/updraft_rayleigh_sponge
add rayleigh sponge for edmf variables
2 parents c2dadf1 + 743ca05 commit 9793487

File tree

10 files changed

+94
-15
lines changed

10 files changed

+94
-15
lines changed

Project.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ ClimaComms = "0.6.9"
4747
ClimaCore = "0.14.37"
4848
ClimaDiagnostics = "0.2.12"
4949
ClimaInterpolations = "0.1.0"
50-
ClimaParams = "0.10.35, 0.11"
50+
ClimaParams = "0.11.1"
5151
ClimaTimeSteppers = "0.8.2"
5252
ClimaUtilities = "0.1.23"
53-
CloudMicrophysics = "0.26.1"
53+
CloudMicrophysics = "0.26.2"
5454
Dates = "1"
55-
ForwardDiff = "0.10.38, 1"
56-
Insolation = "0.9.2"
55+
ForwardDiff = "1"
56+
Insolation = "0.9.5"
5757
Interpolations = "0.15.1, 0.16"
5858
LazyArtifacts = "1"
5959
LazyBroadcast = "1"
@@ -62,14 +62,14 @@ Logging = "1"
6262
NCDatasets = "0.14.2"
6363
NVTX = "0.3, 1"
6464
NullBroadcasts = "0.1"
65-
RRTMGP = "0.21.3"
65+
RRTMGP = "0.21.4"
6666
Random = "1"
67-
SciMLBase = "2.34"
67+
SciMLBase = "2.108"
6868
SparseMatrixColorings = "0.4.20"
6969
StaticArrays = "1.9"
7070
Statistics = "1"
71-
SurfaceFluxes = "0.11, 0.12"
72-
Thermodynamics = "0.12.14, 0.13"
71+
SurfaceFluxes = "0.12.1"
72+
Thermodynamics = "0.13.1"
7373
UnrolledUtilities = "0.1.9"
7474
YAML = "0.4"
7575
julia = "1.9"

config/model_configs/prognostic_edmfx_aquaplanet.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
z_max: 30000.0
33
z_elem: 10
44
dz_bottom: 500.0
5-
rayleigh_sponge: false
6-
viscous_sponge: false
75
dt: 20secs
86
surface_setup: DefaultMoninObukhov
97
rad: clearsky

reproducibility_tests/ref_counter.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
253
1+
254
22

33
# **README**
44
#
@@ -20,6 +20,12 @@
2020

2121

2222
#=
23+
254
24+
- Use rayleigh and viscous sponges in the prognostic_edmfx_aquaplanet
25+
26+
253
27+
- Update deps, specifically ClimaParams.jl and Thermodynamics.jl
28+
2329
252
2430
- Update deps, specifically RootSolvers.jl
2531

src/parameterized_tendencies/sponge/rayleigh_sponge.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,26 @@ import ClimaCore.Fields as Fields
1111
αₘ(s, z, s.α_uₕ) * ζ_rayleigh(s, z, zmax)
1212
β_rayleigh_w(s::RayleighSponge{FT}, z, zmax) where {FT} =
1313
αₘ(s, z, s.α_w) * ζ_rayleigh(s, z, zmax)
14+
β_rayleigh_sgs_tracer(s::RayleighSponge{FT}, z, zmax) where {FT} =
15+
αₘ(s, z, s.α_sgs_tracer) * ζ_rayleigh(s, z, zmax)
1416

1517
function rayleigh_sponge_tendency_uₕ(ᶜuₕ, s)
1618
s isa Nothing && return NullBroadcasted()
1719
(; ᶜz, ᶠz) = z_coordinate_fields(axes(ᶜuₕ))
1820
zmax = z_max(axes(ᶠz))
1921
return @. lazy(-β_rayleigh_uₕ(s, ᶜz, zmax) * ᶜuₕ)
2022
end
23+
24+
function rayleigh_sponge_tendency_sgs_tracer(ᶜχ, s)
25+
s isa Nothing && return NullBroadcasted()
26+
(; ᶜz, ᶠz) = z_coordinate_fields(axes(ᶜχ))
27+
zmax = z_max(axes(ᶠz))
28+
return @. lazy(-β_rayleigh_sgs_tracer(s, ᶜz, zmax) * ᶜχ)
29+
end
30+
31+
function rayleigh_sponge_tendency_sgs_tracer(ᶜχʲ, ᶜχ, s)
32+
s isa Nothing && return NullBroadcasted()
33+
(; ᶜz, ᶠz) = z_coordinate_fields(axes(ᶜχ))
34+
zmax = z_max(axes(ᶠz))
35+
return @. lazy(-β_rayleigh_sgs_tracer(s, ᶜz, zmax) * (ᶜχʲ - ᶜχ))
36+
end

src/parameters/Parameters.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ Base.@kwdef struct ClimaAtmosParameters{
104104
# Sponge
105105
alpha_rayleigh_w::FT
106106
alpha_rayleigh_uh::FT
107+
alpha_rayleigh_sgs_tracer::FT
107108
zd_viscous::FT
108109
zd_rayleigh::FT
109110
kappa_2_sponge::FT

src/parameters/create_parameters.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ atmos_name_map = (;
109109
:c_smag => :c_smag,
110110
:alpha_rayleigh_w => :alpha_rayleigh_w,
111111
:alpha_rayleigh_uh => :alpha_rayleigh_uh,
112+
:alpha_rayleigh_sgs_tracer => :alpha_rayleigh_sgs_tracer,
112113
:astronomical_unit => :astro_unit,
113114
:held_suarez_T_equator_dry => :T_equator_dry,
114115
:drag_layer_vertical_extent => :σ_b,

src/prognostic_equations/remaining_tendency.jl

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,13 @@ NVTX.@annotate function additional_tendency!(Yₜ, Y, p, t)
139139
ᶜuₕ = Y.c.uₕ
140140
ᶠu₃ = Y.f.u₃
141141
ᶜρ = Y.c.ρ
142-
(; radiation_mode, moisture_model, turbconv_model) = p.atmos
142+
(; radiation_mode, moisture_model, turbconv_model, microphysics_model) =
143+
p.atmos
143144
(; rayleigh_sponge, viscous_sponge) = p.atmos
144145
(; ls_adv, scm_coriolis) = p.atmos
145146
(; params) = p
146147
thermo_params = CAP.thermodynamics_params(params)
147-
(; ᶜp, sfc_conditions, ᶜts) = p.precomputed
148+
(; ᶜp, sfc_conditions, ᶜts, ᶜK) = p.precomputed
148149

149150
ᶜh_tot = @. lazy(
150151
TD.total_specific_enthalpy(
@@ -157,6 +158,55 @@ NVTX.@annotate function additional_tendency!(Yₜ, Y, p, t)
157158
vst_u₃ = viscous_sponge_tendency_u₃(ᶠu₃, viscous_sponge)
158159
vst_ρe_tot = viscous_sponge_tendency_ρe_tot(ᶜρ, ᶜh_tot, viscous_sponge)
159160
rst_uₕ = rayleigh_sponge_tendency_uₕ(ᶜuₕ, rayleigh_sponge)
161+
162+
if use_prognostic_tke(turbconv_model)
163+
rst_ρatke =
164+
rayleigh_sponge_tendency_sgs_tracer(Y.c.sgs⁰.ρatke, rayleigh_sponge)
165+
@. Yₜ.c.sgs⁰.ρatke += rst_ρatke
166+
end
167+
if turbconv_model isa PrognosticEDMFX
168+
ᶜmse = @. lazy(ᶜh_tot - ᶜK)
169+
ᶜq_tot = @. lazy(specific(Y.c.ρq_tot, Y.c.ρ))
170+
n = n_mass_flux_subdomains(p.atmos.turbconv_model)
171+
for j in 1:n
172+
rst_sgs_mse = rayleigh_sponge_tendency_sgs_tracer(
173+
Y.c.sgsʲs.:($j).mse,
174+
ᶜmse,
175+
rayleigh_sponge,
176+
)
177+
@. Yₜ.c.sgsʲs.:($$j).mse += rst_sgs_mse
178+
rst_sgs_q_tot = rayleigh_sponge_tendency_sgs_tracer(
179+
Y.c.sgsʲs.:($j).q_tot,
180+
ᶜq_tot,
181+
rayleigh_sponge,
182+
)
183+
@. Yₜ.c.sgsʲs.:($$j).q_tot += rst_sgs_q_tot
184+
end
185+
if moisture_model isa NonEquilMoistModel &&
186+
microphysics_model isa Microphysics1Moment
187+
# TODO: This doesn't work for multiple updrafts
188+
moisture_species = (
189+
(@name(c.sgsʲs.:(1).q_liq), @name(c.ρq_liq)),
190+
(@name(c.sgsʲs.:(1).q_ice), @name(c.ρq_ice)),
191+
(@name(c.sgsʲs.:(1).q_rai), @name(c.ρq_rai)),
192+
(@name(c.sgsʲs.:(1).q_sno), @name(c.ρq_sno)),
193+
)
194+
MatrixFields.unrolled_foreach(
195+
moisture_species,
196+
) do (sgs_q_name, ρq_name)
197+
ᶜρq = MatrixFields.get_field(Y, ρq_name)
198+
ᶜq = @. lazy(specific(ᶜρq, Y.c.ρ))
199+
ᶜsgs_q = MatrixFields.get_field(Y, sgs_q_name)
200+
ᶜsgs_qₜ = MatrixFields.get_field(Yₜ, sgs_q_name)
201+
rst_sgs_q = rayleigh_sponge_tendency_sgs_tracer(
202+
ᶜsgs_q,
203+
ᶜq,
204+
rayleigh_sponge,
205+
)
206+
@. ᶜsgs_qₜ += rst_sgs_q
207+
end
208+
end
209+
end
160210
# For HeldSuarezForcing, the radiation_mode is used as the forcing parameter
161211
forcing = radiation_mode isa HeldSuarezForcing ? radiation_mode : nothing
162212
hs_args = (ᶜuₕ, ᶜp, params, sfc_conditions.ts, moisture_model, forcing)

src/solver/model_getters.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ function get_rayleigh_sponge_model(parsed_args, params, ::Type{FT}) where {FT}
183183
zd = params.zd_rayleigh
184184
α_uₕ = params.alpha_rayleigh_uh
185185
α_w = params.alpha_rayleigh_w
186-
RayleighSponge{FT}(; zd, α_uₕ, α_w)
186+
α_sgs_tracer = params.alpha_rayleigh_sgs_tracer
187+
RayleighSponge{FT}(; zd, α_uₕ, α_w, α_sgs_tracer)
187188
else
188189
error("Uncaught rayleigh sponge model `$rs_name`.")
189190
end

src/solver/types.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ Base.@kwdef struct RayleighSponge{FT} <: AbstractSponge
238238
zd::FT
239239
α_uₕ::FT
240240
α_w::FT
241+
α_sgs_tracer::FT
241242
end
242243

243244
abstract type AbstractGravityWave end

test/parameterized_tendencies/sponge/rayleigh_sponge.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ using ClimaCore.CommonSpaces
3535
@. ᶜuₕ.components.data.:1 = 1
3636
@. ᶜuₕ.components.data.:2 = 1
3737
### Component test begins here
38-
rs = CA.RayleighSponge(; zd = FT(0), α_uₕ = FT(1), α_w = FT(1))
38+
rs = CA.RayleighSponge(;
39+
zd = FT(0),
40+
α_uₕ = FT(1),
41+
α_w = FT(1),
42+
α_sgs_tracer = FT(1),
43+
)
3944
expected = @. sin(FT(π) / 2 * ᶜz / zmax)^2
4045
computed = CA.rayleigh_sponge_tendency_uₕ(ᶜuₕ, rs)
4146
@test CA.β_rayleigh_uₕ.(rs, ᶜz, zmax) == expected

0 commit comments

Comments
 (0)