Skip to content

Commit 0628793

Browse files
authored
Merge pull request #3772 from CliMA/zs/edmf_nh_buoy
move virtual mass term to prognostic edmf momentum equation
2 parents b40a5b4 + 0e9730c commit 0628793

File tree

7 files changed

+39
-37
lines changed

7 files changed

+39
-37
lines changed

config/default_configs/default_config.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,9 @@ implicit_sgs_entr_detr:
325325
help: "Whether to treat the subgrid-scale entrainment and detrainment tendency implicitly [`false` (default), `true`]. Setting it to true only works if implicit_sgs_advection is set to true."
326326
value: false
327327
implicit_sgs_nh_pressure:
328-
help: "Whether to treat the subgrid-scale nonhydrostatic pressure closure implicitly [`false` (default), `true`]. Setting it to true only works if implicit_sgs_advection is set to true.
329-
This flag only controls whether the drag term in the pressure closure is treated implicitly. The buoyancy term is always treated explicitly."
328+
help: "Whether to treat the subgrid-scale nonhydrostatic pressure closure implicitly. Setting it to true only works if
329+
`implicit_sgs_advection` is set to true. This flag only controls whether the drag term in the pressure closure is treated implicitly.
330+
The buoyancy term is always treated implicitly. [`false` (default), `true`]"
330331
value: false
331332
implicit_sgs_mass_flux:
332333
help: "Whether to treat the subgrid-scale mass flux tendency implicitly or explicitly in grid-mean equations. Currently updraft only with Jacobian terms 0. [`false` (default), `true`]. Setting it to true only works if both implicit_sgs_advection and implicit_diffusion are set to true."
@@ -338,7 +339,8 @@ edmfx_filter:
338339
help: "If set to true, it switches on the relaxation of negative velocity in EDMFX. [`true`, `false` (default)]"
339340
value: false
340341
edmfx_nh_pressure:
341-
help: "If set to true, it switches on EDMFX pressure drag closure. [`true`, `false` (default)]"
342+
help: "If set to true, it switches on EDMFX pressure drag closure. For prognostic EDMF, this only controls the drag term
343+
in the pressure closure. The buoyancy term is always applied. [`true`, `false` (default)]"
342344
value: false
343345
edmfx_entr_model:
344346
help: "EDMFX entrainment closure. [`nothing` (default), `PiGroups`, `Generalized`, `GeneralizedHarmonics`]"

reproducibility_tests/ref_counter.jl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
233
1+
234
22

33
# **README**
44
#
@@ -21,34 +21,46 @@
2121

2222
#=
2323
24+
234
25+
- Move the virtual mass term in pressure closure to prognostic edmf momentum equation
26+
(This only affects prognostic edmf)
27+
2428
233
2529
- modify the derivative of p and \rho with respect to qt
2630
2731
232
2832
- Use lazy broadcasting instead of temp scalar in implicit solver for kappa_m vars,
2933
which fixes a bug that the temp scalar is updated before it is reused.
34+
(This only affects prognostic edmf)
3035
3136
231
3237
- Add mass flux derivatives with respect to grid-mean u_3
38+
(This only affects prognostic edmf)
3339
3440
230
3541
- Add u_{3,m} (updraft) Jacobians to updraft MSE, rho*a, and q_tot prognostic equations. Move sgs ∂ᶠu₃ʲ derivatives to BlockLowerTriangularSolve.
42+
(This only affects prognostic edmf)
3643
3744
229
3845
- Remove derivatives with respect to grid mean rho in edmf implicit solver
46+
(This only affects prognostic edmf)
3947
4048
228
4149
- Only treat the drag term in edmf pressure closure implicitly
50+
(This only affects prognostic edmf)
4251
4352
227
4453
- Move nonhydrostatic pressure drag calculation to implicit precomputed quantities
54+
(This only affects prognostic edmf)
4555
4656
226
4757
- Add updraft rho*a and u_{3,m} jacobian terms
58+
(This only affects prognostic edmf)
4859
4960
225
5061
- Move nonhydrostatic pressure drag calculation to precomputed quantities and
5162
remove one reproducibility job
63+
(This only affects prognostic edmf)
5264
5365
224
5466
- Machine precision differences due to https://github.com/CliMA/ClimaCore.jl/pull/2232

src/cache/prognostic_edmf_precomputed_quantities.jl

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,9 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_draft!(
110110

111111
n = n_mass_flux_subdomains(turbconv_model)
112112
thermo_params = CAP.thermodynamics_params(p.params)
113-
turbconv_params = CAP.turbconv_params(p.params)
114113

115114
(; ᶜΦ,) = p.core
116-
(; ᶜspecific, ᶜp, ᶜh_tot, ᶜK) = p.precomputed
117-
(; ᶜuʲs, ᶠu³ʲs, ᶜKʲs, ᶠKᵥʲs, ᶜtsʲs, ᶜρʲs) = p.precomputed
118-
(; ustar, obukhov_length, buoyancy_flux) = p.precomputed.sfc_conditions
115+
(; ᶜp, ᶜuʲs, ᶠu³ʲs, ᶜKʲs, ᶠKᵥʲs, ᶜtsʲs, ᶜρʲs) = p.precomputed
119116

120117
for j in 1:n
121118
ᶜuʲ = ᶜuʲs.:($j)
@@ -468,15 +465,14 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_explicit_clos
468465
dt,
469466
)
470467

471-
# nonhydrostatic pressure closure buoyancy term
472-
if p.atmos.edmfx_model.nh_pressure isa Val{true}
473-
@. ᶠnh_pressure₃_buoyʲs.:($$j) = ᶠupdraft_nh_pressure_buoyancy(
474-
params,
475-
ᶠbuoyancy(ᶠinterp(Y.c.ρ), ᶠinterp(ᶜρʲs.:($$j)), ᶠgradᵥ_ᶜΦ),
476-
)
477-
else
478-
@. ᶠnh_pressure₃_buoyʲs.:($$j) = C3(0)
479-
end
468+
# The buoyancy term in the nonhydrostatic pressure closure is always applied
469+
# for prognostic edmf. The tendency is combined with the buoyancy term in the
470+
# updraft momentum equation in `edmfx_sgs_vertical_advection_tendency!`. This
471+
# term is still calculated here as it is used explicitly in the TKE equation.
472+
@. ᶠnh_pressure₃_buoyʲs.:($$j) = ᶠupdraft_nh_pressure_buoyancy(
473+
params,
474+
ᶠbuoyancy(ᶠinterp(Y.c.ρ), ᶠinterp(ᶜρʲs.:($$j)), ᶠgradᵥ_ᶜΦ),
475+
)
480476
end
481477

482478
(; ᶜgradᵥ_θ_virt⁰, ᶜgradᵥ_q_tot⁰, ᶜgradᵥ_θ_liq_ice⁰) = p.precomputed

src/prognostic_equations/advection.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ function edmfx_sgs_vertical_advection_tendency!(
201201
(; ᶠu³ʲs, ᶠKᵥʲs, ᶜρʲs) = p.precomputed
202202
(; ᶠgradᵥ_ᶜΦ) = p.core
203203

204+
turbconv_params = CAP.turbconv_params(params)
205+
α_b = CAP.pressure_normalmode_buoy_coeff1(turbconv_params)
204206
ᶠz = Fields.coordinate_field(Y.f).z
205207
ᶜa_scalar = p.scratch.ᶜtemp_scalar
206208
ᶜu₃ʲ = p.scratch.ᶜtemp_C3
@@ -215,9 +217,10 @@ function edmfx_sgs_vertical_advection_tendency!(
215217
)
216218
# For the updraft u_3 equation, we assume the grid-mean to be hydrostatic
217219
# and calcuate the buoyancy term relative to the grid-mean density.
220+
# We also include the buoyancy term in the nonhydrostatic pressure closure here.
218221
@. Yₜ.f.sgsʲs.:($$j).u₃ -=
219-
(ᶠinterp(ᶜρʲs.:($$j) - Y.c.ρ) * ᶠgradᵥ_ᶜΦ) / ᶠinterp(ᶜρʲs.:($$j)) +
220-
ᶠgradᵥ(ᶜKᵥʲ)
222+
(1 - α_b) * (ᶠinterp(ᶜρʲs.:($$j) - Y.c.ρ) * ᶠgradᵥ_ᶜΦ) /
223+
ᶠinterp(ᶜρʲs.:($$j)) + ᶠgradᵥ(ᶜKᵥʲ)
221224

222225
# buoyancy term in mse equation
223226
@. Yₜ.c.sgsʲs.:($$j).mse +=

src/prognostic_equations/edmfx_closures.jl

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -88,21 +88,6 @@ function ᶠupdraft_nh_pressure_drag(params, ᶠlg, ᶠu3ʲ, ᶠu3⁰, scale_hei
8888
max(scale_height, H_up_min)
8989
end
9090

91-
edmfx_nh_pressure_buoyancy_tendency!(Yₜ, Y, p, t, turbconv_model) = nothing
92-
function edmfx_nh_pressure_buoyancy_tendency!(
93-
Yₜ,
94-
Y,
95-
p,
96-
t,
97-
turbconv_model::PrognosticEDMFX,
98-
)
99-
(; ᶠnh_pressure₃_buoyʲs) = p.precomputed
100-
n = n_mass_flux_subdomains(turbconv_model)
101-
for j in 1:n
102-
@. Yₜ.f.sgsʲs.:($$j).u₃ -= ᶠnh_pressure₃_buoyʲs.:($$j)
103-
end
104-
end
105-
10691
edmfx_nh_pressure_drag_tendency!(Yₜ, Y, p, t, turbconv_model) = nothing
10792
function edmfx_nh_pressure_drag_tendency!(
10893
Yₜ,

src/prognostic_equations/implicit/implicit_solver.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,9 @@ function update_implicit_equation_jacobian!(A, Y, p, dtγ, t)
935935
Δcp_v * TD.gas_constant_air(thermo_params, ᶜtsʲs.:(1))
936936
) / abs2(TD.cp_m(thermo_params, ᶜtsʲs.:(1)))
937937

938+
turbconv_params = CAP.turbconv_params(params)
939+
α_b = CAP.pressure_normalmode_buoy_coeff1(turbconv_params)
940+
938941
∂ᶜq_totʲ_err_∂ᶜq_totʲ =
939942
matrix[@name(c.sgsʲs.:(1).q_tot), @name(c.sgsʲs.:(1).q_tot)]
940943
@. ∂ᶜq_totʲ_err_∂ᶜq_totʲ =
@@ -1085,7 +1088,8 @@ function update_implicit_equation_jacobian!(A, Y, p, dtγ, t)
10851088
matrix[@name(f.sgsʲs.:(1).u₃), @name(c.sgsʲs.:(1).q_tot)]
10861089
@. ∂ᶠu₃ʲ_err_∂ᶜq_totʲ =
10871090
dtγ * DiagonalMatrixRow(
1088-
ᶠgradᵥ_ᶜΦ * ᶠinterp(Y.c.ρ) / (ᶠinterp(ᶜρʲs.:(1)))^2,
1091+
(1 - α_b) * ᶠgradᵥ_ᶜΦ * ᶠinterp(Y.c.ρ) /
1092+
(ᶠinterp(ᶜρʲs.:(1)))^2,
10891093
) ᶠinterp_matrix() DiagonalMatrixRow(
10901094
(ᶜρʲs.:(1))^2 / ᶜp * (
10911095
ᶜkappa_mʲ / (ᶜkappa_mʲ + 1) * ∂e_int_∂q_tot +
@@ -1100,7 +1104,8 @@ function update_implicit_equation_jacobian!(A, Y, p, dtγ, t)
11001104
matrix[@name(f.sgsʲs.:(1).u₃), @name(c.sgsʲs.:(1).mse)]
11011105
@. ∂ᶠu₃ʲ_err_∂ᶜmseʲ =
11021106
dtγ * DiagonalMatrixRow(
1103-
ᶠgradᵥ_ᶜΦ * ᶠinterp(Y.c.ρ) / (ᶠinterp(ᶜρʲs.:(1)))^2,
1107+
(1 - α_b) * ᶠgradᵥ_ᶜΦ * ᶠinterp(Y.c.ρ) /
1108+
(ᶠinterp(ᶜρʲs.:(1)))^2,
11041109
) ᶠinterp_matrix() DiagonalMatrixRow(
11051110
ᶜkappa_mʲ * (ᶜρʲs.:(1))^2 / ((ᶜkappa_mʲ + 1) * ᶜp),
11061111
)

src/prognostic_equations/remaining_tendency.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ NVTX.@annotate function additional_tendency!(Yₜ, Y, p, t)
118118
if p.atmos.sgs_mf_mode == Explicit()
119119
edmfx_sgs_mass_flux_tendency!(Yₜ, Y, p, t, p.atmos.turbconv_model)
120120
end
121-
edmfx_nh_pressure_buoyancy_tendency!(Yₜ, Y, p, t, p.atmos.turbconv_model)
122121
if p.atmos.sgs_nh_pressure_mode == Explicit()
123122
edmfx_nh_pressure_drag_tendency!(Yₜ, Y, p, t, p.atmos.turbconv_model)
124123
end

0 commit comments

Comments
 (0)