@@ -6,6 +6,25 @@ import ClimaCore.Fields as Fields
66import ClimaCore. Operators as Operators
77import ClimaCore: Geometry
88
9+ function smagorinsky_mixing_length (Y, p)
10+ c_s = CAP. c_smag (p. params)
11+ # For equal spacings, L = c_s Δ
12+ # For unequal spacings, Deardorff employed an equivalent length scale Δ_eq = (Δx Δy Δz)^(1/3)
13+ # For highly anisotropic grids, we follow Scotti 1993, which suggests
14+ # L = c_s Δ_eq * f(a_1, a_2), where a_1 = Δ_1 / Δ_max, a_2 = Δ_2 / Δ_max, and
15+ h_space = Spaces. horizontal_space (axes (Y. c))
16+ Δx = Δy = Spaces. node_horizontal_length_scale (h_space) # scalar value TODO : Get Δx and Δy separately?
17+ Δ_max = max (Δx, Δy)
18+ ᶜΔz = Fields. Δz_field (Y. c)
19+ a₁ = @. lazy (ᶜΔz / Δ_max)
20+ a₂ = min (Δx, Δy) / Δ_max # isotropic in horizontal
21+ f = @. lazy (cosh (√ (4 // 27 * (log (a₁)^ 2 - log (a₁) * log (a₂) + log (a₂)^ 2 )))) # Scotti 1993, Eq 19
22+
23+ Δ_eq = @. lazy (∛ (Δx * Δy * ᶜΔz))
24+ L = @. lazy (c_s * Δ_eq * f) # Smagorinsky mixing length
25+ return L
26+ end
27+
928"""
1029 set_smagorinsky_lilly_precomputed_quantities!(Y, p)
1130
@@ -27,8 +46,8 @@ These quantities are computed for both cell centers and faces, with prefixes `
2746"""
2847function set_smagorinsky_lilly_precomputed_quantities! (Y, p)
2948
30- (; atmos, precomputed, scratch, params) = p
31- c_smag = CAP. c_smag (params)
49+ (; precomputed, scratch, params) = p
50+ # c_smag = CAP.c_smag(params)
3251 Pr_t = CAP. Prandtl_number_0 (CAP. turbconv_params (params))
3352 (; ᶜu, ᶠu³, ᶜts, ᶜτ_smag, ᶠτ_smag, ᶜD_smag, ᶠD_smag) = precomputed
3453 FT = eltype (Y)
@@ -69,16 +88,17 @@ function set_smagorinsky_lilly_precomputed_quantities!(Y, p)
6988 ᶜS_norm = @. ᶜtemp_scalar_2 = √ (2 * CA. norm_sqr (ᶜS))
7089
7190 ᶜRi = @. ᶜtemp_scalar = ᶜN² / (ᶜS_norm^ 2 + eps (FT)) # Ri = N² / |S|²
72- ᶜfb = @. ᶜtemp_scalar = ifelse (ᶜRi ≤ 0 , 1 , max (0 , 1 - ᶜRi / Pr_t)^ (1 / 4 ))
91+ # ᶜfb = @. ᶜtemp_scalar = ifelse(ᶜRi ≤ 0, 1, max(0, 1 - ᶜRi / Pr_t)^(1 / 4))
7392
7493 # filter scale
75- h_space = Spaces. horizontal_space (axes (Y. c))
76- Δ_xy = Spaces. node_horizontal_length_scale (h_space)^ 2 # Δ_x * Δ_y
77- ᶜΔ_z = Fields. Δz_field (Y. c)
78- ᶜΔ = @. ᶜtemp_scalar = ∛ (Δ_xy * ᶜΔ_z) * ᶜfb
94+ # h_space = Spaces.horizontal_space(axes(Y.c))
95+ # Δ_xy = Spaces.node_horizontal_length_scale(h_space)^2 # Δ_x * Δ_y
96+ # ᶜΔ_z = Fields.Δz_field(Y.c)
97+ # ᶜΔ = @. ᶜtemp_scalar = ∛(Δ_xy * ᶜΔ_z) * ᶜfb
7998
8099 # Smagorinsky-Lilly eddy viscosity
81- ᶜνₜ = @. ᶜtemp_scalar = c_smag^ 2 * ᶜΔ^ 2 * ᶜS_norm
100+ L = smagorinsky_mixing_length (Y, p)
101+ ᶜνₜ = @. ᶜtemp_scalar = L^ 2 * ᶜS_norm
82102 ᶠνₜ = @. ᶠtemp_scalar = ᶠinterp (ᶜνₜ)
83103
84104 # Subgrid-scale momentum flux tensor, `τ = -2 νₜ ∘ S`
0 commit comments