Skip to content

Commit 72ca7c8

Browse files
authored
Merge pull request #3746 from CliMA/cc/add_updraft_u_3_jacobian_to_updraft_eqns
Add u_{3, j} Jacobians to updraft MSE, rho*a, and q_tot equations
2 parents 1ed6412 + 4e48b99 commit 72ca7c8

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
),
@@ -890,6 +897,8 @@ function update_implicit_equation_jacobian!(A, Y, p, dtγ, t)
890897
top = Operators.SetValue(zero(UpwindMatrixRowType{CT3{FT}})),
891898
bottom = Operators.SetValue(zero(UpwindMatrixRowType{CT3{FT}})),
892899
) # Need to wrap ᶠupwind_matrix in this for well-defined boundaries.
900+
901+
ᶠu³ʲ_data = ᶠu³ʲs.:(1).components.data.:1
893902
ᶜkappa_mʲ = p.ᶜtemp_scalar
894903
@. ᶜkappa_mʲ =
895904
TD.gas_constant_air(thermo_params, ᶜtsʲs.:(1)) /
@@ -904,6 +913,20 @@ function update_implicit_equation_jacobian!(A, Y, p, dtγ, t)
904913
ᶠset_upwind_matrix_bcs(ᶠupwind_matrix(ᶠu³ʲs.:(1)))
905914
) - (I,)
906915

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

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

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

0 commit comments

Comments
 (0)