@@ -67,26 +67,14 @@ Arguments:
6767Modifies components of tendency vector `Yₜ.c` (e.g., `Yₜ.c.uₕ`, `Yₜ.c.ρe_tot`, `Yₜ.c.ρ`, and
6868various tracer fields such as `Yₜ.c.ρq_tot`).
6969"""
70-
7170vertical_diffusion_boundary_layer_tendency! (Yₜ, Y, p, t) =
72- vertical_diffusion_boundary_layer_tendency! (
73- Yₜ,
74- Y,
75- p,
76- t,
77- p. atmos. vertical_diffusion,
78- )
79-
80- vertical_diffusion_boundary_layer_tendency! (Yₜ, Y, p, t, :: Nothing ) = nothing
81-
82- function vertical_diffusion_boundary_layer_tendency! (
83- Yₜ,
84- Y,
85- p,
86- t,
71+ vertical_diffusion_boundary_layer_tendency! (Yₜ, Y, p, t, p. atmos. vertical_diffusion)
72+
73+ vertical_diffusion_boundary_layer_tendency! (_, _, _, _, :: Nothing ) = nothing
74+
75+ function vertical_diffusion_boundary_layer_tendency! (Yₜ, Y, p, _,
8776 :: Union{VerticalDiffusion, DecayWithHeightDiffusion} ,
8877)
89- FT = eltype (Y)
9078 (; vertical_diffusion) = p. atmos
9179 α_vert_diff_tracer = CAP. α_vert_diff_tracer (p. params)
9280 thermo_params = CAP. thermodynamics_params (p. params)
@@ -96,33 +84,20 @@ function vertical_diffusion_boundary_layer_tendency!(
9684 if vertical_diffusion isa DecayWithHeightDiffusion
9785 ᶜK_h .= ᶜcompute_eddy_diffusivity_coefficient (Y. c. ρ, vertical_diffusion)
9886 elseif vertical_diffusion isa VerticalDiffusion
99- ᶜK_h .= ᶜcompute_eddy_diffusivity_coefficient (
100- Y. c. uₕ,
101- ᶜp,
102- vertical_diffusion,
103- )
87+ ᶜK_h .= ᶜcompute_eddy_diffusivity_coefficient (Y. c. uₕ, ᶜp, vertical_diffusion)
10488 end
10589
10690 if ! disable_momentum_vertical_diffusion (p. atmos. vertical_diffusion)
10791 ᶠstrain_rate = compute_strain_rate_face_vertical (ᶜu)
108- @. Yₜ. c. uₕ -= C12 (
109- ᶜdivᵥ (- 2 * ᶠinterp (Y. c. ρ) * ᶠinterp (ᶜK_h) * ᶠstrain_rate) / Y. c. ρ,
110- ) # assumes ᶜK_u = ᶜK_h
92+ @. Yₜ. c. uₕ -= C12 (ᶜdivᵥ (- 2 * ᶠinterp (Y. c. ρ) * ᶠinterp (ᶜK_h) * ᶠstrain_rate) / Y. c. ρ) # assumes ᶜK_u = ᶜK_h
11193 end
11294
113- ᶜdivᵥ_ρe_tot = Operators. DivergenceF2C (
114- top = Operators. SetValue (C3 (0 )),
115- bottom = Operators. SetValue (C3 (0 )),
116- )
117- ᶜh_tot = @. lazy (
118- TD. total_specific_enthalpy (
119- thermo_params,
120- ᶜts,
121- specific (Y. c. ρe_tot, Y. c. ρ),
122- ),
123- )
124- @. Yₜ. c. ρe_tot -=
125- ᶜdivᵥ_ρe_tot (- (ᶠinterp (Y. c. ρ) * ᶠinterp (ᶜK_h) * ᶠgradᵥ (ᶜh_tot)))
95+ top = bottom = Operators. SetValue (C3 (0 ))
96+ ᶜdivᵥ_ρχ = Operators. DivergenceF2C (; top, bottom)
97+
98+ e_tot = @. lazy (specific (Y. c. ρe_tot, Y. c. ρ))
99+ ᶜh_tot = @. lazy (TD. total_specific_enthalpy (thermo_params, ᶜts, e_tot))
100+ @. Yₜ. c. ρe_tot -= ᶜdivᵥ_ρχ (- (ᶠinterp (Y. c. ρ) * ᶠinterp (ᶜK_h) * ᶠgradᵥ (ᶜh_tot)))
126101
127102 ᶜρχₜ_diffusion = p. scratch. ᶜtemp_scalar_2
128103 ᶜK_h_scaled = p. scratch. ᶜtemp_scalar_3
@@ -133,17 +108,8 @@ function vertical_diffusion_boundary_layer_tendency!(
133108 else
134109 @. ᶜK_h_scaled = ᶜK_h
135110 end
136- ᶜdivᵥ_ρχ = Operators. DivergenceF2C (
137- top = Operators. SetValue (C3 (0 )),
138- bottom = Operators. SetValue (C3 (0 )),
139- )
140- @. ᶜρχₜ_diffusion = ᶜdivᵥ_ρχ (
141- - (
142- ᶠinterp (Y. c. ρ) *
143- ᶠinterp (ᶜK_h_scaled) *
144- ᶠgradᵥ (specific (ᶜρχ, Y. c. ρ))
145- ),
146- )
111+ ᶜχ = @. lazy (specific (ᶜρχ, Y. c. ρ))
112+ @. ᶜρχₜ_diffusion = ᶜdivᵥ_ρχ (- (ᶠinterp (Y. c. ρ) * ᶠinterp (ᶜK_h_scaled) * ᶠgradᵥ (ᶜχ)))
147113 @. ᶜρχₜ -= ᶜρχₜ_diffusion
148114 # Only add contribution from total water diffusion to mass tendency
149115 # (exclude contributions from diffusion of condensate, precipitation)
0 commit comments