@@ -225,7 +225,6 @@ function edmfx_sgs_diffusive_flux_tendency!(
225225 (; dt, params) = p
226226 turbconv_params = CAP. turbconv_params (params)
227227 (; ᶜu) = p. precomputed
228- ᶠgradᵥ = Operators. GradientC2F ()
229228 n = n_mass_flux_subdomains (turbconv_model)
230229 # The SGS-updraft branches below apply the same specific tendency the grid
231230 # mean receives to each subdomain scalar (uniform vertical diffusion across
@@ -270,10 +269,6 @@ function edmfx_sgs_diffusive_flux_tendency!(
270269 # consistency with the unscaled ρq_tot diffusion equation, preserves
271270 # total water invariance under moist-adiabatic processes, and aligns
272271 # with the implicit solver's Jacobian formulation.
273- ᶜdivᵥ_ρe_tot = Operators. DivergenceF2C (
274- top = Operators. SetValue (C3 (FT (0 ))),
275- bottom = Operators. SetValue (C3 (FT (0 ))),
276- )
277272 thermo_params = CAP. thermodynamics_params (params)
278273 (; ᶜΦ) = p. core
279274 (; ᶜT, ᶜq_tot_nonneg, ᶜq_liq, ᶜq_ice) = p. precomputed
@@ -286,19 +281,10 @@ function edmfx_sgs_diffusive_flux_tendency!(
286281 # Uniform vertical diffusion in the grid box: every subdomain feels
287282 # the grid-mean specific tendency.
288283 ᶜρe_totₜ_diffusion = p. scratch. ᶜtemp_scalar_2
289- @. ᶜρe_totₜ_diffusion = ᶜdivᵥ_ρe_tot (
290- - (
291- ᶠρaK_h * (
292- ᶠgradᵥ (TD. dry_static_energy (thermo_params, ᶜT, ᶜΦ)) +
293- ᶠinterp (TD. enthalpy_vapor (thermo_params, ᶜT) + ᶜΦ) *
294- ᶠgradᵥ (ᶜq_vap) +
295- ᶠinterp (TD. enthalpy_liquid (thermo_params, ᶜT) + ᶜΦ) *
296- ᶠgradᵥ (ᶜq_liq) +
297- ᶠinterp (TD. enthalpy_ice (thermo_params, ᶜT) + ᶜΦ) *
298- ᶠgradᵥ (ᶜq_ice)
299- )
300- ),
284+ ᶠgrad_h = ᶠtotal_enthalpy_gradientᵥ (
285+ thermo_params, ᶜT, ᶜΦ, ᶜq_vap, ᶜq_liq, ᶜq_ice,
301286 )
287+ @. ᶜρe_totₜ_diffusion = ᶜdiffdivᵥ (- (ᶠρaK_h * ᶠgrad_h))
302288 @. Yₜ. c. ρe_tot -= ᶜρe_totₜ_diffusion
303289 if apply_sgs_updraft
304290 for j in 1 : n
@@ -332,12 +318,9 @@ function edmfx_sgs_diffusive_flux_tendency!(
332318 if ! (p. atmos. microphysics_model isa DryModel)
333319 # Specific humidity diffusion
334320 ᶜρχₜ_diffusion = p. scratch. ᶜtemp_scalar
335- ᶜdivᵥ_ρq_tot = Operators. DivergenceF2C (
336- top = Operators. SetValue (C3 (FT (0 ))),
337- bottom = Operators. SetValue (C3 (FT (0 ))),
338- )
339- @. ᶜρχₜ_diffusion =
340- ᶜdivᵥ_ρq_tot (- (ᶠρaK_h * ᶠgradᵥ (specific (Y. c. ρq_tot, Y. c. ρ))))
321+ ᶜq_tot = @. lazy (specific (Y. c. ρq_tot, Y. c. ρ))
322+ ᶜ∇ᵥρK∇q_tot = ᶜdiffusive_flux_divergenceᵥ (ᶠρaK_h, ᶜq_tot)
323+ @. ᶜρχₜ_diffusion = ᶜ∇ᵥρK∇q_tot
341324 @. Yₜ. c. ρq_tot -= ᶜρχₜ_diffusion
342325 @. Yₜ. c. ρ -= ᶜρχₜ_diffusion # Effect of moisture diffusion on (moist) air mass
343326 if apply_sgs_updraft
@@ -350,10 +333,6 @@ function edmfx_sgs_diffusive_flux_tendency!(
350333
351334 α_vert_diff_microphysics = CAP. α_vert_diff_tracer (params)
352335 ᶜρχₜ_diffusion = p. scratch. ᶜtemp_scalar
353- ᶜdivᵥ_ρq = Operators. DivergenceF2C (
354- top = Operators. SetValue (C3 (FT (0 ))),
355- bottom = Operators. SetValue (C3 (FT (0 ))),
356- )
357336 # Auto-discovered grid-scale tracers: sedimenting microphysics species
358337 # are diffused with α_vert_diff_tracer * K_h, all other tracers (e.g.
359338 # passive chemistry) with the unscaled K_h, matching
@@ -373,14 +352,9 @@ function edmfx_sgs_diffusive_flux_tendency!(
373352 # same velocity for every scalar, so its full weight is restored:
374353 # α ρ (K_h + K_e) + (1 - α) ρ K_e = ρ (α K_h + K_e).
375354 # For passive tracers α = 1, giving the full ρ (K_h + K_e).
376- @. ᶜρχₜ_diffusion = ᶜdivᵥ_ρq (
377- - (
378- (
379- α * ᶠρaK_h +
380- (1 - α) * ᶠinterp (Y. c. ρ) * ᶠK_entr
381- ) * ᶠgradᵥ (ᶜχ)
382- ),
383- )
355+ ᶠρK = @. lazy (α * ᶠρaK_h + (1 - α) * ᶠinterp (Y. c. ρ) * ᶠK_entr)
356+ ᶜ∇ᵥρK∇χ = ᶜdiffusive_flux_divergenceᵥ (ᶠρK, ᶜχ)
357+ @. ᶜρχₜ_diffusion = ᶜ∇ᵥρK∇χ
384358 @. ᶜρχₜ -= ᶜρχₜ_diffusion
385359 # Uniform vertical diffusion: apply the same specific tendency to
386360 # the matching subdomain field (e.g. ρq_lcl → q_lcl in updrafts).
0 commit comments