Skip to content

Commit dbdca3d

Browse files
committed
add diffusivity diagnostics
1 parent 44f015a commit dbdca3d

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

src/cache/precomputed_quantities.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,12 @@ function precomputed_quantities(Y, atmos)
248248
smagorinsky_quantities =
249249
if atmos.smagorinsky_horizontal isa SmagorinskyLilly ||
250250
atmos.smagorinsky_vertical isa SmagorinskyLilly
251-
uvw_vec = UVW(FT(0), FT(0), FT(0))
251+
uvw_vec = UVW(FT(0), FT(0), FT(0))
252252
(;
253253
ᶜS = similar(Y.c, typeof(uvw_vec * uvw_vec')),
254254
ᶠS = similar(Y.f, typeof(uvw_vec * uvw_vec')),
255255
ᶜL_h = similar(Y.c, FT), ᶜL_v = similar(Y.c, FT),
256+
ᶜD_h = similar(Y.c, FT), ᶠD_v = similar(Y.f, FT),
256257
)
257258
else
258259
(;)

src/diagnostics/core_diagnostics.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,26 @@ add_diagnostic_variable!(
343343
end,
344344
)
345345

346+
###
347+
# Smagorinski Lilly diffusivity
348+
###
349+
add_diagnostic_variable!(
350+
short_name = "D_smag_h",
351+
long_name = "Horizontal smagorinski diffusivity",
352+
units = "m^2 s^-1",
353+
compute! = (out, _, cache, _) -> begin
354+
isnothing(out) ? copy(cache.precomputed.ᶜD_h) : (out .= cache.precomputed.ᶜD_h)
355+
end,
356+
)
357+
add_diagnostic_variable!(
358+
short_name = "D_smag_v",
359+
long_name = "Horizontal smagorinski diffusivity",
360+
units = "m^2 s^-1",
361+
compute! = (out, _, cache, _) -> begin
362+
isnothing(out) ? copy(cache.precomputed.ᶠD_v) : (out .= cache.precomputed.ᶠD_v)
363+
end,
364+
)
365+
346366
###
347367
# Relative humidity (3d)
348368
###

src/parameterized_tendencies/les_sgs_models/smagorinsky_lilly.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ function horizontal_smagorinsky_lilly_tendency!(Yₜ, Y, p, t, ::SmagorinskyLill
7777

7878
# Turbulent diffusivity
7979
ᶜD_smag = @. ᶜtemp_scalar = ᶜνₜ_h / Pr_t
80+
@. p.precomputed.ᶜD_h = ᶜD_smag # save to diagnostics
8081

8182
# Subgrid-scale momentum flux tensor, `τ = -2 νₜ ∘ S`
8283
ᶜτ_smag = @. ᶜtemp_UVWxUVW = -2 * ᶜνₜ_h * ᶜS # TODO: Lazify once we can mix lazy horizontal & vertical operations
@@ -140,6 +141,7 @@ function vertical_smagorinsky_lilly_tendency!(Yₜ, Y, p, t, ::SmagorinskyLilly)
140141

141142
# Turbulent diffusivity
142143
ᶠD_smag = @. ᶠtemp_scalar_2 = ᶠνₜ_v / Pr_t
144+
@. p.precomputed.ᶠD_v = ᶠD_smag # save to diagnostics
143145

144146
# Apply to tendencies
145147
## Horizontal momentum tendency

0 commit comments

Comments
 (0)