@@ -328,6 +328,14 @@ function ImplicitEquationJacobian(
328
328
similar (Y. c, TridiagonalRow),
329
329
(@name (c. ρq_tot), @name (c. sgsʲs.:(1 ). q_tot)) =>
330
330
similar (Y. c, TridiagonalRow),
331
+ (@name (c. ρe_tot), @name (f. sgsʲs.:(1 ). u₃)) =>
332
+ similar (Y. c, BidiagonalRow_ACT3),
333
+ (@name (c. ρq_tot), @name (f. sgsʲs.:(1 ). u₃)) =>
334
+ similar (Y. c, BidiagonalRow_ACT3),
335
+ (@name (c. ρe_tot), @name (c. sgsʲs.:(1 ). ρa)) =>
336
+ similar (Y. c, TridiagonalRow),
337
+ (@name (c. ρq_tot), @name (c. sgsʲs.:(1 ). ρa)) =>
338
+ similar (Y. c, TridiagonalRow),
331
339
)
332
340
else
333
341
()
@@ -525,6 +533,11 @@ NVTX.@annotate function Wfact!(A, Y, p, dtγ, t)
525
533
p. atmos. turbconv_model isa PrognosticEDMFX ?
526
534
(; p. precomputed. ᶠu₃⁰,) : (;)
527
535
). .. ,
536
+ (
537
+ use_derivative (A. sgs_mass_flux_flag) &&
538
+ p. atmos. turbconv_model isa PrognosticEDMFX ?
539
+ (; p. precomputed. ᶜKʲs) : (;)
540
+ ). .. ,
528
541
p. core. ᶜΦ,
529
542
p. core. ᶠgradᵥ_ᶜΦ,
530
543
p. scratch. ᶜtemp_scalar,
@@ -864,6 +877,7 @@ function update_implicit_equation_jacobian!(A, Y, p, dtγ, t)
864
877
end
865
878
866
879
if p. atmos. turbconv_model isa PrognosticEDMFX
880
+
867
881
if use_derivative (sgs_advection_flag)
868
882
(; ᶜgradᵥ_ᶠΦ, ᶜρʲs, ᶠu³ʲs, ᶜtsʲs) = p
869
883
(; bdmr_l, bdmr_r, bdmr) = p
@@ -1068,7 +1082,7 @@ function update_implicit_equation_jacobian!(A, Y, p, dtγ, t)
1068
1082
# add updraft mass flux contributions to grid-mean
1069
1083
if use_derivative (sgs_mass_flux_flag)
1070
1084
1071
- (; ᶜgradᵥ_ᶠΦ, ᶜρʲs, ᶠu³ʲs, ᶜtsʲs, ᶠu³) = p
1085
+ (; ᶜgradᵥ_ᶠΦ, ᶜρʲs, ᶠu³ʲs, ᶜtsʲs, ᶠu³, ᶜKʲs ) = p
1072
1086
(; bdmr_l, bdmr_r, bdmr) = p
1073
1087
is_third_order = edmfx_upwinding == Val (:third_order )
1074
1088
ᶠupwind = is_third_order ? ᶠupwind3 : ᶠupwind1
@@ -1088,8 +1102,8 @@ function update_implicit_equation_jacobian!(A, Y, p, dtγ, t)
1088
1102
1089
1103
# Jacobian contributions of updraft massflux to grid-mean
1090
1104
1091
- ∂ᶜupdraft_mass_flux_∂ᶜh_tot = ᶠbidiagonal_matrix_ct3
1092
- @. ∂ᶜupdraft_mass_flux_∂ᶜh_tot =
1105
+ ∂ᶜupdraft_mass_flux_∂ᶜscalar = ᶠbidiagonal_matrix_ct3
1106
+ @. ∂ᶜupdraft_mass_flux_∂ᶜscalar =
1093
1107
DiagonalMatrixRow (
1094
1108
(ᶠinterp (ᶜρ * ᶜJ) / ᶠJ) * (ᶠu³ʲs.:(1 ) - ᶠu³),
1095
1109
) ⋅ ᶠinterp_matrix () ⋅
@@ -1098,7 +1112,7 @@ function update_implicit_equation_jacobian!(A, Y, p, dtγ, t)
1098
1112
# Derivative of total energy tendency with respect to updraft MSE
1099
1113
# # grid-mean ρe_tot
1100
1114
@. ∂ᶜρe_tot_err_∂ᶜρ +=
1101
- dtγ * ᶜadvdivᵥ_matrix () ⋅ ∂ᶜupdraft_mass_flux_∂ᶜh_tot ⋅
1115
+ dtγ * ᶜadvdivᵥ_matrix () ⋅ ∂ᶜupdraft_mass_flux_∂ᶜscalar ⋅
1102
1116
DiagonalMatrixRow (
1103
1117
(
1104
1118
- (1 + ᶜkappa_m) * ᶜspecific. e_tot -
@@ -1107,34 +1121,76 @@ function update_implicit_equation_jacobian!(A, Y, p, dtγ, t)
1107
1121
)
1108
1122
1109
1123
@. ∂ᶜρe_tot_err_∂ᶜρq_tot +=
1110
- dtγ * ᶜadvdivᵥ_matrix () ⋅ ∂ᶜupdraft_mass_flux_∂ᶜh_tot ⋅
1124
+ dtγ * ᶜadvdivᵥ_matrix () ⋅ ∂ᶜupdraft_mass_flux_∂ᶜscalar ⋅
1111
1125
DiagonalMatrixRow (ᶜkappa_m * ∂e_int_∂q_tot / ᶜρ)
1112
1126
1113
1127
@. ∂ᶜρe_tot_err_∂ᶜρe_tot +=
1114
- dtγ * ᶜadvdivᵥ_matrix () ⋅ ∂ᶜupdraft_mass_flux_∂ᶜh_tot ⋅
1128
+ dtγ * ᶜadvdivᵥ_matrix () ⋅ ∂ᶜupdraft_mass_flux_∂ᶜscalar ⋅
1115
1129
DiagonalMatrixRow ((1 + ᶜkappa_m) / ᶜρ)
1116
1130
1117
1131
∂ᶜρe_tot_err_∂ᶜmseʲ =
1118
1132
matrix[@name (c. ρe_tot), @name (c. sgsʲs.:(1 ). mse)]
1119
1133
@. ∂ᶜρe_tot_err_∂ᶜmseʲ =
1120
- - (dtγ * ᶜadvdivᵥ_matrix () ⋅ ∂ᶜupdraft_mass_flux_∂ᶜh_tot )
1134
+ - (dtγ * ᶜadvdivᵥ_matrix () ⋅ ∂ᶜupdraft_mass_flux_∂ᶜscalar )
1121
1135
1122
1136
# # grid-mean ρq_tot
1123
- ∂ᶜupdraft_mass_flux_∂ᶜqtot = ∂ᶜupdraft_mass_flux_∂ᶜh_tot
1124
1137
∂ᶜρq_tot_err_∂ᶜρ = matrix[@name (c. ρq_tot), @name (c. ρ)]
1125
1138
@. ∂ᶜρq_tot_err_∂ᶜρ +=
1126
- dtγ * ᶜadvdivᵥ_matrix () ⋅ ∂ᶜupdraft_mass_flux_∂ᶜqtot ⋅
1139
+ dtγ * ᶜadvdivᵥ_matrix () ⋅ ∂ᶜupdraft_mass_flux_∂ᶜscalar ⋅
1127
1140
DiagonalMatrixRow (- (ᶜspecific. q_tot) / ᶜρ)
1128
1141
1129
1142
∂ᶜρq_tot_err_∂ᶜρq_tot = matrix[@name (c. ρq_tot), @name (c. ρq_tot)]
1130
1143
@. ∂ᶜρq_tot_err_∂ᶜρq_tot +=
1131
- dtγ * ᶜadvdivᵥ_matrix () ⋅ ∂ᶜupdraft_mass_flux_∂ᶜqtot ⋅
1144
+ dtγ * ᶜadvdivᵥ_matrix () ⋅ ∂ᶜupdraft_mass_flux_∂ᶜscalar ⋅
1132
1145
DiagonalMatrixRow (1 / ᶜρ)
1133
1146
1134
1147
∂ᶜρq_tot_err_∂ᶜq_totʲ =
1135
1148
matrix[@name (c. ρq_tot), @name (c. sgsʲs.:(1 ). q_tot)]
1136
1149
@. ∂ᶜρq_tot_err_∂ᶜq_totʲ =
1137
- - (dtγ * ᶜadvdivᵥ_matrix () ⋅ ∂ᶜupdraft_mass_flux_∂ᶜqtot)
1150
+ - (dtγ * ᶜadvdivᵥ_matrix () ⋅ ∂ᶜupdraft_mass_flux_∂ᶜscalar)
1151
+
1152
+ # grid-mean ∂/∂(u₃ʲ)
1153
+ ∂ᶜρe_tot_err_∂ᶠu₃ʲ =
1154
+ matrix[@name (c. ρe_tot), @name (f. sgsʲs.:(1 ). u₃)]
1155
+ @. ∂ᶜρe_tot_err_∂ᶠu₃ʲ =
1156
+ dtγ * - (ᶜadvdivᵥ_matrix ()) ⋅ DiagonalMatrixRow (
1157
+ ᶠinterp (
1158
+ (Y. c. sgsʲs.:(1 ). mse + ᶜKʲs.:(1 ) - ᶜh_tot) *
1159
+ ᶜρʲs.:(1 ) *
1160
+ ᶜJ *
1161
+ draft_area (Y. c. sgsʲs.:(1 ). ρa, ᶜρʲs.:(1 )),
1162
+ ) / ᶠJ * (g³³ (ᶠgⁱʲ)),
1163
+ )
1164
+
1165
+
1166
+ ∂ᶜρq_tot_err_∂ᶠu₃ʲ =
1167
+ matrix[@name (c. ρq_tot), @name (f. sgsʲs.:(1 ). u₃)]
1168
+ @. ∂ᶜρq_tot_err_∂ᶠu₃ʲ =
1169
+ dtγ * - (ᶜadvdivᵥ_matrix ()) ⋅ DiagonalMatrixRow (
1170
+ ᶠinterp (
1171
+ (Y. c. sgsʲs.:(1 ). q_tot - ᶜspecific. q_tot) *
1172
+ ᶜρʲs.:(1 ) *
1173
+ ᶜJ *
1174
+ draft_area (Y. c. sgsʲs.:(1 ). ρa, ᶜρʲs.:(1 )),
1175
+ ) / ᶠJ * (g³³ (ᶠgⁱʲ)),
1176
+ )
1177
+
1178
+ # grid-mean ∂/∂(rho*a)
1179
+ ∂ᶜρe_tot_err_∂ᶜρa =
1180
+ matrix[@name (c. ρe_tot), @name (c. sgsʲs.:(1 ). ρa)]
1181
+ @. ∂ᶜρe_tot_err_∂ᶜρa =
1182
+ dtγ * - (ᶜadvdivᵥ_matrix ()) ⋅ DiagonalMatrixRow (
1183
+ (ᶠu³ʲs.:(1 ) - ᶠu³) *
1184
+ ᶠinterp ((Y. c. sgsʲs.:(1 ). mse + ᶜKʲs.:(1 ) - ᶜh_tot)) / ᶠJ,
1185
+ ) ⋅ ᶠinterp_matrix () ⋅ DiagonalMatrixRow (ᶜJ)
1186
+
1187
+ ∂ᶜρq_tot_err_∂ᶜρa =
1188
+ matrix[@name (c. ρq_tot), @name (c. sgsʲs.:(1 ). ρa)]
1189
+ @. ∂ᶜρq_tot_err_∂ᶜρa =
1190
+ dtγ * - (ᶜadvdivᵥ_matrix ()) ⋅ DiagonalMatrixRow (
1191
+ (ᶠu³ʲs.:(1 ) - ᶠu³) *
1192
+ ᶠinterp ((Y. c. sgsʲs.:(1 ). q_tot - ᶜspecific. q_tot)) / ᶠJ,
1193
+ ) ⋅ ᶠinterp_matrix () ⋅ DiagonalMatrixRow (ᶜJ)
1138
1194
1139
1195
end
1140
1196
0 commit comments