Skip to content

Commit 4e48b99

Browse files
committed
Add u_{3,m} (updraft) Jacobians to updraft MSE, rho*a, and q_tot prognostic equations. Move sgs ∂ᶠu₃ʲ derivatives to BlockLowerTriangularSolve.
1 parent f927ae3 commit 4e48b99

File tree

2 files changed

+59
-5
lines changed

2 files changed

+59
-5
lines changed

reproducibility_tests/ref_counter.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
229
1+
230
22

33
# **README**
44
#
@@ -21,6 +21,9 @@
2121

2222
#=
2323
24+
230
25+
- Add u_{3,m} (updraft) Jacobians to updraft MSE, rho*a, and q_tot prognostic equations. Move sgs ∂ᶠu₃ʲ derivatives to BlockLowerTriangularSolve.
26+
2427
229
2528
remove derivatives with respect to grid mean rho in edmf implicit solver
2629

src/prognostic_equations/implicit/implicit_solver.jl

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,12 @@ function ImplicitEquationJacobian(
293293
similar(Y.c, TridiagonalRow),
294294
(@name(c.sgsʲs.:(1).ρa), @name(c.sgsʲs.:(1).mse)) =>
295295
similar(Y.c, TridiagonalRow),
296+
(@name(c.sgsʲs.:(1).ρa), @name(f.sgsʲs.:(1).u₃)) =>
297+
similar(Y.c, BidiagonalRow_ACT3),
298+
(@name(c.sgsʲs.:(1).mse), @name(f.sgsʲs.:(1).u₃)) =>
299+
similar(Y.c, BidiagonalRow_ACT3),
300+
(@name(c.sgsʲs.:(1).q_tot), @name(f.sgsʲs.:(1).u₃)) =>
301+
similar(Y.c, BidiagonalRow_ACT3),
296302
(@name(f.sgsʲs.:(1).u₃), @name(c.sgsʲs.:(1).q_tot)) =>
297303
similar(Y.f, BidiagonalRow_C3),
298304
(@name(f.sgsʲs.:(1).u₃), @name(c.sgsʲs.:(1).mse)) =>
@@ -359,12 +365,14 @@ function ImplicitEquationJacobian(
359365
names₁ = (
360366
names₁_group₁...,
361367
available_sgs_scalar_names...,
362-
sgs_u³_names_if_available...,
363368
names₁_group₂...,
364369
names₁_group₃...,
365370
)
366371

367-
alg₂ = MatrixFields.BlockLowerTriangularSolve(@name(c.uₕ))
372+
alg₂ = MatrixFields.BlockLowerTriangularSolve(
373+
@name(c.uₕ),
374+
sgs_u³_names_if_available...,
375+
)
368376
alg =
369377
if use_derivative(diffusion_flag) ||
370378
use_derivative(sgs_advection_flag) ||
@@ -386,8 +394,7 @@ function ImplicitEquationJacobian(
386394
alg₂ = MatrixFields.BlockLowerTriangularSolve(
387395
@name(c.sgsʲs.:(1).mse);
388396
alg₂ = MatrixFields.BlockLowerTriangularSolve(
389-
@name(c.sgsʲs.:(1).ρa),
390-
@name(f.sgsʲs.:(1).u₃);
397+
@name(c.sgsʲs.:(1).ρa);
391398
diff_subalg...,
392399
),
393400
),
@@ -889,6 +896,8 @@ function update_implicit_equation_jacobian!(A, Y, p, dtγ, t)
889896
top = Operators.SetValue(zero(UpwindMatrixRowType{CT3{FT}})),
890897
bottom = Operators.SetValue(zero(UpwindMatrixRowType{CT3{FT}})),
891898
) # Need to wrap ᶠupwind_matrix in this for well-defined boundaries.
899+
900+
ᶠu³ʲ_data = ᶠu³ʲs.:(1).components.data.:1
892901
ᶜkappa_mʲ = p.ᶜtemp_scalar
893902
@. ᶜkappa_mʲ =
894903
TD.gas_constant_air(thermo_params, ᶜtsʲs.:(1)) /
@@ -903,6 +912,20 @@ function update_implicit_equation_jacobian!(A, Y, p, dtγ, t)
903912
ᶠset_upwind_matrix_bcs(ᶠupwind_matrix(ᶠu³ʲs.:(1)))
904913
) - (I,)
905914

915+
∂ᶜq_totʲ_err_∂ᶠu₃ʲ =
916+
matrix[@name(c.sgsʲs.:(1).q_tot), @name(f.sgsʲs.:(1).u₃)]
917+
918+
@. ∂ᶜq_totʲ_err_∂ᶠu₃ʲ =
919+
dtγ * (
920+
-(ᶜadvdivᵥ_matrix()) DiagonalMatrixRow(
921+
ᶠset_upwind_bcs(
922+
ᶠupwind(CT3(sign(ᶠu³ʲ_data)), Y.c.sgsʲs.:(1).q_tot),
923+
) * adjoint(C3(sign(ᶠu³ʲ_data))),
924+
) +
925+
DiagonalMatrixRow(Y.c.sgsʲs.:(1).q_tot) ᶜadvdivᵥ_matrix()
926+
) DiagonalMatrixRow(g³³(ᶠgⁱʲ))
927+
928+
906929
∂ᶜmseʲ_err_∂ᶜq_totʲ =
907930
matrix[@name(c.sgsʲs.:(1).mse), @name(c.sgsʲs.:(1).q_tot)]
908931
@. ∂ᶜmseʲ_err_∂ᶜq_totʲ =
@@ -915,6 +938,18 @@ function update_implicit_equation_jacobian!(A, Y, p, dtγ, t)
915938
)
916939
)
917940

941+
∂ᶜmseʲ_err_∂ᶠu₃ʲ =
942+
matrix[@name(c.sgsʲs.:(1).mse), @name(f.sgsʲs.:(1).u₃)]
943+
@. ∂ᶜmseʲ_err_∂ᶠu₃ʲ =
944+
dtγ * (
945+
-(ᶜadvdivᵥ_matrix()) DiagonalMatrixRow(
946+
ᶠset_upwind_bcs(
947+
ᶠupwind(CT3(sign(ᶠu³ʲ_data)), Y.c.sgsʲs.:(1).mse),
948+
) * adjoint(C3(sign(ᶠu³ʲ_data))),
949+
) +
950+
DiagonalMatrixRow(Y.c.sgsʲs.:(1).mse) ᶜadvdivᵥ_matrix()
951+
) DiagonalMatrixRow(g³³(ᶠgⁱʲ))
952+
918953
∂ᶜmseʲ_err_∂ᶜmseʲ =
919954
matrix[@name(c.sgsʲs.:(1).mse), @name(c.sgsʲs.:(1).mse)]
920955
@. ∂ᶜmseʲ_err_∂ᶜmseʲ =
@@ -987,6 +1022,22 @@ function update_implicit_equation_jacobian!(A, Y, p, dtγ, t)
9871022
ᶠset_upwind_matrix_bcs(ᶠupwind_matrix(ᶠu³ʲs.:(1)))
9881023
DiagonalMatrixRow(1 / ᶜρʲs.:(1)) - (I,)
9891024

1025+
1026+
∂ᶜρaʲ_err_∂ᶠu₃ʲ =
1027+
matrix[@name(c.sgsʲs.:(1).ρa), @name(f.sgsʲs.:(1).u₃)]
1028+
@. ∂ᶜρaʲ_err_∂ᶠu₃ʲ =
1029+
dtγ * -(ᶜadvdivᵥ_matrix()) DiagonalMatrixRow(
1030+
ᶠinterp(ᶜρʲs.:(1) * ᶜJ) / ᶠJ *
1031+
ᶠset_upwind_bcs(
1032+
ᶠupwind(
1033+
CT3(sign(ᶠu³ʲ_data)),
1034+
draft_area(Y.c.sgsʲs.:(1).ρa, ᶜρʲs.:(1)),
1035+
),
1036+
) *
1037+
adjoint(C3(sign(ᶠu³ʲ_data))) *
1038+
g³³(ᶠgⁱʲ),
1039+
)
1040+
9901041
∂ᶠu₃ʲ_err_∂ᶜq_totʲ =
9911042
matrix[@name(f.sgsʲs.:(1).u₃), @name(c.sgsʲs.:(1).q_tot)]
9921043
@. ∂ᶠu₃ʲ_err_∂ᶜq_totʲ =

0 commit comments

Comments
 (0)