@@ -620,7 +620,7 @@ function update_jacobian!(alg::ManualSparseJacobian, cache, Y, p, dtγ, t)
620620 (; vertical_diffusion, smagorinsky_lilly) = p. atmos
621621 (; ᶜp) = p. precomputed
622622 ᶜK_u = p. scratch. ᶜtemp_scalar_4
623- ᶜK_h = p. scratch. ᶜtemp_scalar_5
623+ ᶜK_h = p. scratch. ᶜtemp_scalar_6
624624 if vertical_diffusion isa DecayWithHeightDiffusion
625625 ᶜK_h .= ᶜcompute_eddy_diffusivity_coefficient (Y. c. ρ, vertical_diffusion)
626626 ᶜK_u = ᶜK_h
@@ -644,17 +644,18 @@ function update_jacobian!(alg::ManualSparseJacobian, cache, Y, p, dtγ, t)
644644 @. ᶜK_h = eddy_diffusivity (ᶜK_u, ᶜprandtl_nvec)
645645 end
646646
647- @. ᶜadvection_matrix =
648- ᶜadvdivᵥ_matrix () ⋅ DiagonalMatrixRow (ᶠinterp (ᶜρ) * ᶠinterp (ᶜK_h))
649- @. ᶜdiffusion_h_matrix = ᶜadvection_matrix ⋅ ᶠgradᵥ_matrix ()
647+ ∂ᶠρχ_dif_flux_∂ᶜχ = ᶠp_grad_matrix
648+ @. ∂ᶠρχ_dif_flux_∂ᶜχ =
649+ DiagonalMatrixRow (ᶠinterp (ᶜρ) * ᶠinterp (ᶜK_h)) ⋅ ᶠgradᵥ_matrix ()
650+ @. ᶜdiffusion_h_matrix = ᶜadvdivᵥ_matrix () ⋅ ∂ᶠρχ_dif_flux_∂ᶜχ
650651 if (
651652 MatrixFields. has_field (Y, @name (c. sgs⁰. ρatke)) ||
652653 ! isnothing (p. atmos. turbconv_model) ||
653654 ! disable_momentum_vertical_diffusion (p. atmos. vertical_diffusion)
654655 )
655- @. ᶜadvection_matrix =
656- ᶜadvdivᵥ_matrix () ⋅ DiagonalMatrixRow (ᶠinterp (ᶜρ) * ᶠinterp (ᶜK_u))
657- @. ᶜdiffusion_u_matrix = ᶜadvection_matrix ⋅ ᶠgradᵥ_matrix ()
656+ @. ∂ᶠρχ_dif_flux_∂ᶜχ =
657+ DiagonalMatrixRow (ᶠinterp (ᶜρ) * ᶠinterp (ᶜK_u)) ⋅ ᶠgradᵥ_matrix ( )
658+ @. ᶜdiffusion_u_matrix = ᶜadvdivᵥ_matrix () ⋅ ∂ᶠρχ_dif_flux_∂ᶜχ
658659 end
659660
660661 ∂ᶜρe_tot_err_∂ᶜρ = matrix[@name (c. ρe_tot), @name (c. ρ)]
0 commit comments