Skip to content

Commit 8835be9

Browse files
authored
Merge pull request #3665 from CliMA/aj/explicit_tracer_vadv
Move vertical passive tracer advection to explicit tendency
2 parents b6c1c54 + 4666cbc commit 8835be9

File tree

3 files changed

+34
-28
lines changed

3 files changed

+34
-28
lines changed

reproducibility_tests/ref_counter.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
218
1+
219
22

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

2121

2222
#=
23+
219
24+
- Change the operations order in vertical advection upwinding
2325
2426
218
2527
- Change surface flux tendency to fully explicit
@@ -37,7 +39,7 @@
3739
214
3840
- Rename some config files
3941
40-
213
42+
213
4143
- Update to deep-atmos eqns by default, fix vorticity diagnostic
4244
4345
212

src/prognostic_equations/advection.jl

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -115,21 +115,27 @@ NVTX.@annotate function explicit_vertical_advection_tendency!(Yₜ, Y, p, t)
115115
# Without the CT12(), the right-hand side would be a CT1 or CT2 in 2D space.
116116

117117
ᶜρ = Y.c.ρ
118-
if :ρe_tot in propertynames(Yₜ.c)
118+
119+
# Full vertical advection of passive tracers (like liq, rai, etc) ...
120+
for (ᶜρχₜ, ᶜχ, χ_name) in matching_subfields(Yₜ.c, ᶜspecific)
121+
χ_name in (:e_tot, :q_tot) && continue
122+
vtt = vertical_transport(ᶜρ, ᶠu³, ᶜχ, float(dt), tracer_upwinding)
123+
@. ᶜρχₜ += vtt
124+
end
125+
# ... and upwinding correction of energy and total water.
126+
# (The central advection of energy and total water is done implicitly.)
127+
if energy_upwinding != Val(:none)
119128
(; ᶜh_tot) = p.precomputed
120-
for (coeff, upwinding) in ((1, energy_upwinding), (-1, Val(:none)))
121-
energy_upwinding isa Val{:none} && continue
122-
vtt = vertical_transport(ᶜρ, ᶠu³, ᶜh_tot, float(dt), upwinding)
123-
@. Yₜ.c.ρe_tot += coeff * vtt
124-
end
129+
vtt = vertical_transport(ᶜρ, ᶠu³, ᶜh_tot, float(dt), energy_upwinding)
130+
vtt_central = vertical_transport(ᶜρ, ᶠu³, ᶜh_tot, float(dt), Val(:none))
131+
@. Yₜ.c.ρe_tot += vtt - vtt_central
125132
end
126-
for (ᶜρχₜ, ᶜχ, χ_name) in matching_subfields(Yₜ.c, ᶜspecific)
127-
χ_name == :e_tot && continue
128-
for (coeff, upwinding) in ((1, tracer_upwinding), (-1, Val(:none)))
129-
tracer_upwinding isa Val{:none} && continue
130-
vtt = vertical_transport(ᶜρ, ᶠu³, ᶜχ, float(dt), upwinding)
131-
@. ᶜρχₜ += coeff * vtt
132-
end
133+
134+
if !(p.atmos.moisture_model isa DryModel) && tracer_upwinding != Val(:none)
135+
ᶜq_tot = ᶜspecific.q_tot
136+
vtt = vertical_transport(ᶜρ, ᶠu³, ᶜq_tot, float(dt), tracer_upwinding)
137+
vtt_central = vertical_transport(ᶜρ, ᶠu³, ᶜq_tot, float(dt), Val(:none))
138+
@. Yₜ.c.ρq_tot += vtt - vtt_central
133139
end
134140

135141
if isnothing(ᶠf¹²)

src/prognostic_equations/implicit/implicit_tendency.jl

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,18 @@ function implicit_vertical_advection_tendency!(Yₜ, Y, p, t)
126126

127127
@. Yₜ.c.ρ -= ᶜdivᵥ(ᶠinterp(Y.c.ρ * ᶜJ) / ᶠJ * ᶠu³)
128128

129-
# Central advection of active tracers (e_tot and all the q_...)
129+
# Central vertical advection of active tracers (e_tot and q_tot)
130130
vtt = vertical_transport(Y.c.ρ, ᶠu³, ᶜh_tot, dt, Val(:none))
131131
@. Yₜ.c.ρe_tot += vtt
132-
133-
for (ᶜρχₜ, ᶜχ, χ_name) in matching_subfields(Yₜ.c, ᶜspecific)
134-
χ_name == :e_tot && continue
135-
vtt = vertical_transport(Y.c.ρ, ᶠu³, ᶜχ, dt, Val(:none))
136-
@. ᶜρχₜ += vtt
132+
if !(moisture_model isa DryModel)
133+
vtt = vertical_transport(Y.c.ρ, ᶠu³, ᶜspecific.q_tot, dt, Val(:none))
134+
@. Yₜ.c.ρq_tot += vtt
137135
end
138136

139-
#vertical_advection_of_water_tendency!(Yₜ, Y, p, t)
140-
137+
# Vertical advection of passive tracers with the mean flow
138+
# is done in the explicit tendency.
139+
# Here we add the vertical advection with precipitation terminal velocity
140+
# using downward biasing and free outflow bottom boundary condition
141141
if moisture_model isa NonEquilMoistModel
142142
(; ᶜwₗ, ᶜwᵢ) = p.precomputed
143143
@. Yₜ.c.ρq_liq -= ᶜprecipdivᵥ(
@@ -149,12 +149,7 @@ function implicit_vertical_advection_tendency!(Yₜ, Y, p, t)
149149
ᶠright_bias(Geometry.WVector(-(ᶜwᵢ)) * ᶜspecific.q_ice),
150150
)
151151
end
152-
153152
if precip_model isa Microphysics1Moment
154-
# Advection of precipitation with the mean flow
155-
# is done with other passive tracers in the explicit tendency.
156-
# Here we add the advection with precipitation terminal velocity
157-
# using downward biasing and free outflow bottom boundary condition
158153
(; ᶜwᵣ, ᶜwₛ) = p.precomputed
159154
@. Yₜ.c.ρq_rai -= ᶜprecipdivᵥ(
160155
ᶠinterp(Y.c.ρ * ᶜJ) / ᶠJ *
@@ -166,6 +161,9 @@ function implicit_vertical_advection_tendency!(Yₜ, Y, p, t)
166161
)
167162
end
168163

164+
# TODO - decide if this needs to be explicit or implicit
165+
#vertical_advection_of_water_tendency!(Yₜ, Y, p, t)
166+
169167
@. Yₜ.f.u₃ -= ᶠgradᵥ(ᶜp) / ᶠinterp(Y.c.ρ) + ᶠgradᵥ_ᶜΦ
170168

171169
if rayleigh_sponge isa RayleighSponge

0 commit comments

Comments
 (0)