Skip to content

Commit 9405d3c

Browse files
committed
rft: clean up diagnostics
1 parent f7b702b commit 9405d3c

File tree

3 files changed

+349
-1134
lines changed

3 files changed

+349
-1134
lines changed
Lines changed: 61 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,70 @@
1-
function ᶜcompute_eddy_diffusivity_coefficient(
2-
ᶜρ,
3-
vert_diff::DecayWithHeightDiffusion,
4-
)
1+
2+
"""
3+
ᶜcompute_eddy_diffusivity_coefficient(ᶜρ, (; D₀, H)::DecayWithHeightDiffusion)
4+
5+
Return lazy representation of the vertical profile of eddy diffusivity
6+
for the `DecayWithHeightDiffusion` model.
7+
8+
The profile is given by:
9+
```
10+
K(z) = D₀ ⋅ exp(-(z - z_sfc) / H)
11+
```
12+
13+
# Arguments
14+
- `ᶜρ`: Cell-centered field whose axes provide vertical coordinates.
15+
- Instance of `DecayWithHeightDiffusion` model, with fields:
16+
- `D₀`: Surface eddy diffusivity magnitude.
17+
- `H`: E-folding height for the exponential decay.
18+
19+
# See also
20+
- [`DecayWithHeightDiffusion`] for the model specification
21+
- [`vertical_diffusion_boundary_layer_tendency!`] where this coefficient is applied
22+
"""
23+
function ᶜcompute_eddy_diffusivity_coefficient(ᶜρ, (; D₀, H)::DecayWithHeightDiffusion)
524
(; ᶜz, ᶠz) = z_coordinate_fields(axes(ᶜρ))
625
ᶠz_sfc = Fields.level(ᶠz, Fields.half)
7-
return @. lazy(
8-
eddy_diffusivity_coefficient_H(vert_diff.D₀, vert_diff.H, ᶠz_sfc, ᶜz),
9-
)
26+
return @. lazy(eddy_diffusivity_coefficient_H(D₀, H, ᶠz_sfc, ᶜz))
1027
end
28+
eddy_diffusivity_coefficient_H(D₀, H, z_sfc, z) = D₀ * exp(-(z - z_sfc) / H)
1129

12-
function ᶜcompute_eddy_diffusivity_coefficient(
13-
ᶜuₕ,
14-
ᶜp,
15-
vert_diff::VerticalDiffusion,
16-
)
30+
"""
31+
ᶜcompute_eddy_diffusivity_coefficient(ᶜuₕ, ᶜp, (; C_E)::VerticalDiffusion)
32+
33+
Return lazy representation of the vertical profile of eddy diffusivity
34+
for the `VerticalDiffusion` model.
35+
36+
The profile is given by:
37+
```
38+
K(z) = K_E , if p > p_pbl
39+
= K_E * exp(-((p_pbl - p) / p_strato)^2), otherwise
40+
```
41+
where `K_E` is given by:
42+
```
43+
K_E = C_E ⋅ norm(ᶜuₕ(z_bot)) ⋅ Δz_bot / 2
44+
```
45+
where `z_bot` is the first interior center level of the model,
46+
and `Δz_bot` is the thickness of the surface layer.
47+
48+
# Arguments
49+
- `ᶜuₕ`: Cell-centered horizontal velocity field; its first interior level is used.
50+
- `ᶜp`: Cell-centered thermodynamic pressure field (or proxy) used by the closure.
51+
- Instance of `VerticalDiffusion` model, with field `C_E`:
52+
- `C_E`: Dimensionless eddy-coefficient factor.
53+
54+
# See also
55+
- [`VerticalDiffusion`] for the model specification
56+
"""
57+
function ᶜcompute_eddy_diffusivity_coefficient(ᶜuₕ, ᶜp, (; C_E)::VerticalDiffusion)
1758
interior_uₕ = Fields.level(ᶜuₕ, 1)
1859
ᶜΔz_surface = Fields.Δz_field(interior_uₕ)
1960
return @. lazy(
20-
eddy_diffusivity_coefficient(
21-
vert_diff.C_E,
22-
norm(interior_uₕ),
23-
ᶜΔz_surface / 2,
24-
ᶜp,
25-
),
61+
eddy_diffusivity_coefficient(C_E, norm(interior_uₕ), ᶜΔz_surface / 2, ᶜp),
2662
)
2763
end
64+
65+
function eddy_diffusivity_coefficient(C_E, norm_uₕ_bottom, Δz_bottom, p)
66+
p_pbl = 85000
67+
p_strato = 10000
68+
K_E = C_E * norm_uₕ_bottom * Δz_bottom
69+
return p > p_pbl ? K_E : K_E * exp(-((p_pbl - p) / p_strato)^2)
70+
end

src/cache/precomputed_quantities.jl

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -431,16 +431,6 @@ ts_gs(thermo_params, moisture_model, microphysics_model, ᶜY, K, Φ, ρ) =
431431
ρ,
432432
)
433433

434-
function eddy_diffusivity_coefficient_H(D₀, H, z_sfc, z)
435-
return D₀ * exp(-(z - z_sfc) / H)
436-
end
437-
function eddy_diffusivity_coefficient(C_E, norm_v_a, z_a, p)
438-
p_pbl = 85000
439-
p_strato = 10000
440-
K_E = C_E * norm_v_a * z_a
441-
return p > p_pbl ? K_E : K_E * exp(-((p_pbl - p) / p_strato)^2)
442-
end
443-
444434
"""
445435
set_implicit_precomputed_quantities!(Y, p, t)
446436
set_implicit_precomputed_quantities_part1!(Y, p, t)

0 commit comments

Comments
 (0)