@@ -38,14 +38,16 @@ NVTX.@annotate function horizontal_dynamics_tendency!(Yₜ, Y, p, t)
3838 (; ᶜΦ) = p. core
3939 (; ᶜu, ᶜK, ᶜp, ᶜts) = p. precomputed
4040 (; params) = p
41+ FT = eltype(params)
4142 thermo_params = CAP. thermodynamics_params(params)
4243 cp_d = thermo_params. cp_d
4344
4445 if p. atmos. turbconv_model isa PrognosticEDMFX
4546 (; ᶜuʲs) = p. precomputed
4647 end
4748
48- @. Yₜ. c. ρ -= wdivₕ(Y. c. ρ * ᶜu)
49+ @. Yₜ. c. ρ -= split_divₕ(Y. c. ρ * ᶜu, FT(1 )) # This one
50+
4951 if p. atmos. turbconv_model isa PrognosticEDMFX
5052 for j in 1 : n
5153 @. Yₜ. c. sgsʲs.:($$ j). ρa -= wdivₕ(Y. c. sgsʲs.:($$ j). ρa * ᶜuʲs.:($$ j))
@@ -54,7 +56,7 @@ NVTX.@annotate function horizontal_dynamics_tendency!(Yₜ, Y, p, t)
5456
5557 ᶜe_tot = @. lazy(specific(Y. c. ρe_tot, Y. c. ρ))
5658 ᶜh_tot = @. lazy(TD. total_specific_enthalpy(thermo_params, ᶜts, ᶜe_tot))
57- @. Yₜ. c. ρe_tot -= wdivₕ (Y. c. ρ * ᶜh_tot * ᶜu)
59+ @. Yₜ. c. ρe_tot -= split_divₕ (Y. c. ρ * ᶜu, ᶜh_tot) # this one
5860
5961 if p. atmos. turbconv_model isa PrognosticEDMFX
6062 for j in 1 : n
@@ -73,8 +75,16 @@ NVTX.@annotate function horizontal_dynamics_tendency!(Yₜ, Y, p, t)
7375 ᶜθ_v = @. lazy(theta_v(thermo_params, ᶜts))
7476 ᶜθ_vr = @. lazy(theta_vr(thermo_params, ᶜts))
7577 ᶜΠ = @. lazy(dry_exner_function(thermo_params, ᶜts))
76- @. Yₜ. c. uₕ -= C12(gradₕ(ᶜK + ᶜΦ - ᶜΦ_r) + cp_d * (ᶜθ_v - ᶜθ_vr) * gradₕ(ᶜΠ))
77- # Without the C12(), the right-hand side would be a C1 or C2 in 2D space.
78+ ᶜθ_v_diff = @. lazy(ᶜθ_v - ᶜθ_vr)
79+ # PG = 0.5 * cp_d * [θv ∇Π + ∇(θv Π) - Π∇θv]
80+ @. Yₜ. c. uₕ -= C12(
81+ gradₕ(ᶜK + ᶜΦ - ᶜΦ_r) +
82+ FT(0.5 ) * cp_d * (
83+ ᶜθ_v_diff * gradₕ(ᶜΠ) + # θv ∇Π
84+ gradₕ(ᶜθ_v_diff * ᶜΠ) - # ∇(θv Π)
85+ ᶜΠ * gradₕ(ᶜθ_v_diff) # Π∇θv
86+ ),
87+ ) # Without the C12(), the right-hand side would be a C1 or C2 in 2D space.
7888 return nothing
7989end
8090
@@ -109,8 +119,9 @@ NVTX.@annotate function horizontal_tracer_advection_tendency!(Yₜ, Y, p, t)
109119 (; ᶜuʲs) = p. precomputed
110120 end
111121
112- for ρχ_name in filter(is_tracer_var, propertynames(Y. c))
113- @. Yₜ. c.:($$ ρχ_name) -= wdivₕ(Y. c.:($$ ρχ_name) * ᶜu)
122+ for ρχ_name in filter(is_tracer_var, propertynames(Y. c)) # this one
123+ ᶜχ = @. lazy(specific(Y. c.:($$ ρχ_name), Y. c. ρ))
124+ @. Yₜ. c.:($$ ρχ_name) -= split_divₕ(Y. c. ρ * ᶜu, ᶜχ)
114125 end
115126
116127 if p. atmos. turbconv_model isa PrognosticEDMFX
0 commit comments