Skip to content

Commit

Permalink
Merge pull request #2712 from CliMA/zs/progedmf_vertical_ke
Browse files Browse the repository at this point in the history
separate vertical kinetic energy in edmf momentum equation
  • Loading branch information
szy21 authored Feb 23, 2024
2 parents 3ecdff1 + 6ede77e commit 7974a4f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/cache/precomputed_quantities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ function precomputed_quantities(Y, atmos)
ᶜuʲs = similar(Y.c, NTuple{n, C123{FT}}),
ᶠu³ʲs = similar(Y.f, NTuple{n, CT3{FT}}),
ᶜKʲs = similar(Y.c, NTuple{n, FT}),
ᶜKᵥʲs = similar(Y.c, NTuple{n, FT}),
ᶜtsʲs = similar(Y.c, NTuple{n, TST}),
ᶜρʲs = similar(Y.c, NTuple{n, FT}),
ᶜentrʲs = similar(Y.c, NTuple{n, FT}),
Expand Down
4 changes: 3 additions & 1 deletion src/cache/prognostic_edmf_precomputed_quantities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,22 @@ function set_prognostic_edmf_precomputed_quantities_draft_and_bc!(Y, p, ᶠuₕ

(; ᶜΦ,) = p.core
(; ᶜspecific, ᶜp, ᶜh_tot, ᶜK) = p.precomputed
(; ᶜuʲs, ᶠu³ʲs, ᶜKʲs, ᶜtsʲs, ᶜρʲs) = p.precomputed
(; ᶜuʲs, ᶠu³ʲs, ᶜKʲs, ᶜKᵥʲs, ᶜtsʲs, ᶜρʲs) = p.precomputed
(; ustar, obukhov_length, buoyancy_flux) = p.precomputed.sfc_conditions

for j in 1:n
ᶜuʲ = ᶜuʲs.:($j)
ᶠu³ʲ = ᶠu³ʲs.:($j)
ᶜKʲ = ᶜKʲs.:($j)
ᶜKᵥʲ = ᶜKᵥʲs.:($j)
ᶠu₃ʲ = Y.f.sgsʲs.:($j).u₃
ᶜtsʲ = ᶜtsʲs.:($j)
ᶜρʲ = ᶜρʲs.:($j)
ᶜmseʲ = Y.c.sgsʲs.:($j).mse
ᶜq_totʲ = Y.c.sgsʲs.:($j).q_tot

set_velocity_quantities!(ᶜuʲ, ᶠu³ʲ, ᶜKʲ, ᶠu₃ʲ, Y.c.uₕ, ᶠuₕ³)
@. ᶜKᵥʲ = ᶜinterp(adjoint(CT3(ᶠu₃ʲ)) * ᶠu₃ʲ) / 2
@. ᶜtsʲ = TD.PhaseEquil_phq(thermo_params, ᶜp, ᶜmseʲ - ᶜΦ, ᶜq_totʲ)
@. ᶜρʲ = TD.air_density(thermo_params, ᶜtsʲ)

Expand Down
8 changes: 4 additions & 4 deletions src/prognostic_equations/advection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ NVTX.@annotate function explicit_vertical_advection_tendency!(Yₜ, Y, p, t)
(; ᶜf³, ᶠf¹², ᶜΦ) = p.core
(; ᶜu, ᶠu³, ᶜK) = p.precomputed
(; edmfx_upwinding) = n > 0 || advect_tke ? p.atmos.numerics : all_nothing
(; ᶜuʲs, ᶜKʲs) = n > 0 ? p.precomputed : all_nothing
(; ᶜuʲs, ᶜKʲs, ᶜKᵥʲs) = n > 0 ? p.precomputed : all_nothing
(; ᶠu³⁰) = advect_tke ? p.precomputed : all_nothing
(; energy_upwinding, tracer_upwinding) = p.atmos.numerics
(; ᶜspecific) = p.precomputed
Expand Down Expand Up @@ -169,7 +169,7 @@ NVTX.@annotate function explicit_vertical_advection_tendency!(Yₜ, Y, p, t)
for j in 1:n
@. Yₜ.f.sgsʲs.:($$j).u₃[colidx] -=
ᶠω¹²ʲs.:($$j)[colidx] × ᶠinterp(CT12(ᶜuʲs.:($$j)[colidx])) +
ᶠgradᵥ(ᶜKʲs.:($$j)[colidx])
ᶠgradᵥ(ᶜKʲs.:($$j)[colidx] - ᶜKᵥʲs.:($$j)[colidx])
end

if use_prognostic_tke(turbconv_model) # advect_tke triggers allocations
Expand Down Expand Up @@ -204,7 +204,7 @@ function edmfx_sgs_vertical_advection_tendency!(
(; dt) = p
ᶜJ = Fields.local_geometry_field(Y.c).J
(; edmfx_upwinding) = p.atmos.numerics
(; ᶠu³ʲs, ᶜρʲs) = p.precomputed
(; ᶠu³ʲs, ᶜKᵥʲs, ᶜρʲs) = p.precomputed
(; ᶠgradᵥ_ᶜΦ) = p.core

ᶠz = Fields.coordinate_field(Y.f).z
Expand All @@ -214,7 +214,7 @@ function edmfx_sgs_vertical_advection_tendency!(
# and calcuate the buoyancy term relative to the grid-mean density.
@. Yₜ.f.sgsʲs.:($$j).u₃[colidx] -=
(ᶠinterp(ᶜρʲs.:($$j)[colidx] - Y.c.ρ[colidx]) * ᶠgradᵥ_ᶜΦ[colidx]) /
ᶠinterp(ᶜρʲs.:($$j)[colidx])
ᶠinterp(ᶜρʲs.:($$j)[colidx]) + ᶠgradᵥ(ᶜKᵥʲs.:($$j)[colidx])

# buoyancy term in mse equation
@. Yₜ.c.sgsʲs.:($$j).mse[colidx] +=
Expand Down

0 comments on commit 7974a4f

Please sign in to comment.