Skip to content

Commit 530c4c5

Browse files
committed
rft: split horizontal and vertical smagorinsky
- add diffusivity diagnostics - implicit vertical smagorinsky - les ci_plots edits - use vertical strain for lilly correction - full strain rate method
1 parent 0db5c3e commit 530c4c5

File tree

11 files changed

+265
-135
lines changed

11 files changed

+265
-135
lines changed

config/default_configs/default_config.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,14 @@ amd_les:
169169
c_amd:
170170
help: "Model coefficient for AMD-LES closure (TODO: Move to parameters.toml)"
171171
value: 0.29
172-
smagorinsky_lilly:
173-
help: "Smagorinsky-Lilly diffusive closure [`false` (default), `true`]"
172+
smagorinsky:
173+
help: "Smagorinsky diffusive closure in the horizontal and vertical [`false` (default), `true`]"
174+
value: false
175+
smagorinsky_horizontal:
176+
help: "Smagorinsky diffusive closure in the horizontal [`false` (default), `true`]"
177+
value: false
178+
smagorinsky_vertical:
179+
help: "Smagorinsky diffusive closure in the vertical [`false` (default), `true`]"
174180
value: false
175181
bubble:
176182
help: "Enable bubble correction for more accurate surface areas"

post_processing/ci_plots.jl

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,17 +1310,10 @@ function make_plots(
13101310

13111311
reduction = "inst"
13121312
short_names = [
1313-
"wa",
1314-
"ua",
1315-
"va",
1316-
"ta",
1317-
"thetaa",
1318-
"ha",
1319-
"hus",
1320-
"hur",
1321-
"cl",
1322-
"clw",
1323-
"cli",
1313+
"wa", "ua", "va", "ta", "thetaa", "ha", "hus", "hur", "cl", "clw", "cli", "ke",
1314+
"Dh_smag", "dtmaxh_smag", "strainrateh_smag", # smag horizontal
1315+
"Dv_smag", "dtmaxv_smag", "strainratev_smag", # smag vertical
1316+
"edt" # DecayWithHeight vertical diffusivity
13241317
]
13251318
short_names = short_names collect(keys(simdirs[1].vars))
13261319

@@ -1333,10 +1326,7 @@ function make_plots(
13331326
window_end = last(var.dims["time"])
13341327
window_start = window_end - 2hours
13351328
var_window = ClimaAnalysis.window(
1336-
var,
1337-
"time";
1338-
left = window_start,
1339-
right = window_end,
1329+
var, "time"; left = window_start, right = window_end,
13401330
)
13411331
var_reduced = horizontal_average(average_time(var_window))
13421332
return var_reduced

src/cache/precomputed_quantities.jl

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -245,14 +245,17 @@ function precomputed_quantities(Y, atmos)
245245
precipitation_sgs_quantities...,
246246
diagnostic_precipitation_sgs_quantities...,
247247
) : (;)
248-
smagorinsky_lilly_quantities =
249-
if atmos.smagorinsky_lilly isa SmagorinskyLilly
248+
smagorinsky_quantities =
249+
if atmos.smagorinsky_horizontal isa SmagorinskyLilly ||
250+
atmos.smagorinsky_vertical isa SmagorinskyLilly
250251
uvw_vec = UVW(FT(0), FT(0), FT(0))
251252
(;
252-
ᶜτ_smag = similar(Y.c, typeof(uvw_vec * uvw_vec')),
253-
ᶠτ_smag = similar(Y.f, typeof(uvw_vec * uvw_vec')),
254-
ᶜD_smag = similar(Y.c, FT),
255-
ᶠD_smag = similar(Y.f, FT),
253+
ᶜS = similar(Y.c, typeof(uvw_vec * uvw_vec')),
254+
ᶠS = similar(Y.f, typeof(uvw_vec * uvw_vec')),
255+
ᶜL_h = similar(Y.c, FT), ᶜL_v = similar(Y.c, FT),
256+
ᶜD_h = similar(Y.c, FT), ᶜD_v = similar(Y.c, FT),
257+
ᶜstrain_rate_norm_h = similar(Y.c, FT),
258+
ᶜstrain_rate_norm_v = similar(Y.c, FT),
256259
)
257260
else
258261
(;)
@@ -281,8 +284,9 @@ function precomputed_quantities(Y, atmos)
281284
precipitation_quantities...,
282285
surface_precip_fluxes...,
283286
cloud_diagnostics_tuple,
284-
smagorinsky_lilly_quantities...,
285-
amd_les_quantities...)
287+
smagorinsky_quantities...,
288+
amd_les_quantities...,
289+
)
286290
end
287291

288292
# Interpolates the third contravariant component of Y.c.uₕ to cell faces.
@@ -608,7 +612,8 @@ NVTX.@annotate function set_explicit_precomputed_quantities_part2!(Y, p, t)
608612
set_cloud_fraction!(Y, p, moisture_model, cloud_model)
609613
end
610614

611-
if p.atmos.smagorinsky_lilly isa SmagorinskyLilly
615+
if p.atmos.smagorinsky_horizontal isa SmagorinskyLilly ||
616+
p.atmos.smagorinsky_vertical isa SmagorinskyLilly
612617
set_smagorinsky_lilly_precomputed_quantities!(Y, p)
613618
end
614619

src/diagnostics/core_diagnostics.jl

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

346+
###
347+
# Smagorinski Lilly diffusivity
348+
###
349+
add_diagnostic_variable!(
350+
short_name = "Dh_smag",
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 = "Dv_smag",
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+
add_diagnostic_variable!(
366+
short_name = "dtmaxh_smag",
367+
long_name = "Max horizontal diffusion dt",
368+
units = "s",
369+
compute! = (out, state, cache, _) -> begin
370+
Δh = Spaces.node_horizontal_length_scale(Spaces.horizontal_space(axes(state.f)))
371+
dtmax = @. lazy(Δh^2 / cache.precomputed.ᶜD_h)
372+
isnothing(out) ? copy(dtmax) : (out .= dtmax)
373+
end,
374+
)
375+
add_diagnostic_variable!(
376+
short_name = "dtmaxv_smag",
377+
long_name = "Max diffusion dt",
378+
units = "s",
379+
compute! = (out, state, cache, _) -> begin
380+
ᶜΔ_z = Fields.Δz_field(state.c)
381+
dtmax = @. lazy(ᶜΔ_z^2 / cache.precomputed.ᶜD_v)
382+
isnothing(out) ? copy(dtmax) : (out .= dtmax)
383+
end,
384+
)
385+
import ..projected_strain_rate_norm
386+
add_diagnostic_variable!(
387+
short_name = "strainrateh_smag",
388+
long_name = "Strain rate horizontal",
389+
units = "s",
390+
compute! = (out, state, cache, _) -> begin
391+
ᶜS_norm_h = projected_strain_rate_norm(cache.precomputed.ᶜS, Geometry.UVAxis())
392+
isnothing(out) ? copy(ᶜS_norm_h) : (out .= ᶜS_norm_h)
393+
end,
394+
)
395+
add_diagnostic_variable!(
396+
short_name = "strainratev_smag",
397+
long_name = "Strain rate vertical",
398+
units = "s",
399+
compute! = (out, state, cache, _) -> begin
400+
ᶜS_norm_v = projected_strain_rate_norm(cache.precomputed.ᶜS, Geometry.WAxis())
401+
isnothing(out) ? copy(ᶜS_norm_v) : (out .= ᶜS_norm_v)
402+
end,
403+
)
404+
346405
###
347406
# Relative humidity (3d)
348407
###

0 commit comments

Comments
 (0)