Skip to content

Commit 76c8be1

Browse files
authored
Merge pull request #2940 from CliMA/zs/mixing_length
add different mixing lengths to cache and diagnostics
2 parents 45519fb + 2d19bd6 commit 76c8be1

File tree

7 files changed

+109
-5
lines changed

7 files changed

+109
-5
lines changed

config/model_configs/prognostic_edmfx_bomex_column.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ diagnostics:
3333
period: 10mins
3434
- short_name: [arup, waup, taup, thetaaup, haup, husup, hurup, clwup, cliup, waen, taen, thetaaen, haen, husen, huren, clwen, clien, tke]
3535
period: 10mins
36-
- short_name: [entr, detr, lmix, bgrad, strain, edt, evu]
36+
- short_name: [entr, detr, lmix, lmixw, lmixtke, lmixb, bgrad, strain, edt, evu]
3737
period: 10mins

src/cache/diagnostic_edmf_precomputed_quantities.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,12 @@ NVTX.@annotate function set_diagnostic_edmf_precomputed_quantities_env_closures!
766766
(; ustar, obukhov_length) = p.precomputed.sfc_conditions
767767
(; ᶜρaʲs, ᶠu³ʲs, ᶜdetrʲs) = p.precomputed
768768
(; ᶜtke⁰, ᶠu³⁰, ᶜu⁰) = p.precomputed
769-
(; ᶜlinear_buoygrad, ᶜstrain_rate_norm, ᶜmixing_length) = p.precomputed
769+
(;
770+
ᶜlinear_buoygrad,
771+
ᶜstrain_rate_norm,
772+
ᶜmixing_length_tuple,
773+
ᶜmixing_length,
774+
) = p.precomputed
770775
(; ᶜK_h, ᶜK_u, ρatke_flux) = p.precomputed
771776
thermo_params = CAP.thermodynamics_params(params)
772777
ᶜlg = Fields.local_geometry_field(Y.c)
@@ -816,7 +821,7 @@ NVTX.@annotate function set_diagnostic_edmf_precomputed_quantities_env_closures!
816821

817822
sfc_tke = Fields.level(ᶜtke⁰, 1)
818823
z_sfc = Fields.level(Fields.coordinate_field(Y.f).z, half)
819-
@. ᶜmixing_length = mixing_length(
824+
@. ᶜmixing_length_tuple = mixing_length(
820825
params,
821826
ustar,
822827
ᶜz,
@@ -830,6 +835,7 @@ NVTX.@annotate function set_diagnostic_edmf_precomputed_quantities_env_closures!
830835
ᶜprandtl_nvec,
831836
ᶜtke_exch,
832837
)
838+
@. ᶜmixing_length = ᶜmixing_length_tuple.master
833839

834840
turbconv_params = CAP.turbconv_params(params)
835841
c_m = CAP.tke_ed_coeff(turbconv_params)

src/cache/precomputed_quantities.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ function precomputed_quantities(Y, atmos)
8585
ᶜq_tot⁰ = similar(Y.c, FT),
8686
ᶜts⁰ = similar(Y.c, TST),
8787
ᶜρ⁰ = similar(Y.c, FT),
88+
ᶜmixing_length_tuple = similar(Y.c, MixingLength{FT}),
8889
ᶜK_u = similar(Y.c, FT),
8990
ᶜK_h = similar(Y.c, FT),
9091
ρatke_flux = similar(Fields.level(Y.f, half), C3{FT}),
@@ -126,6 +127,7 @@ function precomputed_quantities(Y, atmos)
126127
ᶜu⁰ = similar(Y.c, C123{FT}),
127128
ᶜK⁰ = similar(Y.c, FT),
128129
ᶜtke⁰ = similar(Y.c, FT),
130+
ᶜmixing_length_tuple = similar(Y.c, MixingLength{FT}),
129131
ᶜK_u = similar(Y.c, FT),
130132
ᶜK_h = similar(Y.c, FT),
131133
ρatke_flux = similar(Fields.level(Y.f, half), C3{FT}),

src/cache/prognostic_edmf_precomputed_quantities.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_closures!(
196196

197197
(; ᶜtke⁰, ᶜu, ᶜp, ᶜρa⁰, ᶠu³⁰, ᶜts⁰, ᶜq_tot⁰) = p.precomputed
198198
(;
199+
ᶜmixing_length_tuple,
199200
ᶜmixing_length,
200201
ᶜlinear_buoygrad,
201202
ᶜstrain_rate_norm,
@@ -307,7 +308,7 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_closures!(
307308
end
308309

309310
sfc_tke = Fields.level(ᶜtke⁰, 1)
310-
@. ᶜmixing_length = mixing_length(
311+
@. ᶜmixing_length_tuple = mixing_length(
311312
p.params,
312313
ustar,
313314
ᶜz,
@@ -322,6 +323,8 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_closures!(
322323
ᶜtke_exch,
323324
)
324325

326+
@. ᶜmixing_length = ᶜmixing_length_tuple.master
327+
325328
turbconv_params = CAP.turbconv_params(params)
326329
c_m = CAP.tke_ed_coeff(turbconv_params)
327330
@. ᶜK_u = c_m * ᶜmixing_length * sqrt(max(ᶜtke⁰, 0))

src/diagnostics/edmfx_diagnostics.jl

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,93 @@ add_diagnostic_variable!(
882882
compute! = compute_tke!,
883883
)
884884

885+
###
886+
# Environment Wall Constrained Mixing Length (3d)
887+
###
888+
compute_lmixw!(out, state, cache, time) =
889+
compute_lmixw!(out, state, cache, time, cache.atmos.turbconv_model)
890+
compute_lmixw!(_, _, _, _, turbconv_model::T) where {T} =
891+
error_diagnostic_variable("lmixw", turbconv_model)
892+
893+
function compute_lmixw!(
894+
out,
895+
state,
896+
cache,
897+
time,
898+
turbconv_model::Union{PrognosticEDMFX, DiagnosticEDMFX},
899+
)
900+
if isnothing(out)
901+
return copy(cache.precomputed.ᶜmixing_length_tuple.wall)
902+
else
903+
out .= cache.precomputed.ᶜmixing_length_tuple.wall
904+
end
905+
end
906+
907+
add_diagnostic_variable!(
908+
short_name = "lmixw",
909+
long_name = "Environment Wall Constrained Mixing Length",
910+
units = "m",
911+
compute! = compute_lmixw!,
912+
)
913+
914+
###
915+
# Environment TKE Balanced Mixing Length (3d)
916+
###
917+
compute_lmixtke!(out, state, cache, time) =
918+
compute_lmixtke!(out, state, cache, time, cache.atmos.turbconv_model)
919+
compute_lmixtke!(_, _, _, _, turbconv_model::T) where {T} =
920+
error_diagnostic_variable("lmixtke", turbconv_model)
921+
922+
function compute_lmixtke!(
923+
out,
924+
state,
925+
cache,
926+
time,
927+
turbconv_model::Union{PrognosticEDMFX, DiagnosticEDMFX},
928+
)
929+
if isnothing(out)
930+
return copy(cache.precomputed.ᶜmixing_length_tuple.tke)
931+
else
932+
out .= cache.precomputed.ᶜmixing_length_tuple.tke
933+
end
934+
end
935+
936+
add_diagnostic_variable!(
937+
short_name = "lmixtke",
938+
long_name = "Environment TKE Balanced Mixing Length",
939+
units = "m",
940+
compute! = compute_lmixtke!,
941+
)
942+
943+
###
944+
# Environment Stability Mixing Length (3d)
945+
###
946+
compute_lmixb!(out, state, cache, time) =
947+
compute_lmixb!(out, state, cache, time, cache.atmos.turbconv_model)
948+
compute_lmixb!(_, _, _, _, turbconv_model::T) where {T} =
949+
error_diagnostic_variable("lmixb", turbconv_model)
950+
951+
function compute_lmixb!(
952+
out,
953+
state,
954+
cache,
955+
time,
956+
turbconv_model::Union{PrognosticEDMFX, DiagnosticEDMFX},
957+
)
958+
if isnothing(out)
959+
return copy(cache.precomputed.ᶜmixing_length_tuple.buoy)
960+
else
961+
out .= cache.precomputed.ᶜmixing_length_tuple.buoy
962+
end
963+
end
964+
965+
add_diagnostic_variable!(
966+
short_name = "lmixb",
967+
long_name = "Environment Static Stability Mixing Length",
968+
units = "m",
969+
compute! = compute_lmixb!,
970+
)
971+
885972
###
886973
# Diffusivity of heat (3d)
887974
###

src/prognostic_equations/edmfx_closures.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ function mixing_length(
251251
l_smin = lamb_smooth_minimum(l, smin_ub, smin_rm)
252252
l_limited = max(l_smag, min(l_smin, l_z))
253253

254-
return l_limited
254+
return MixingLength{FT}(l_limited, l_W, l_TKE, l_N)
255255
end
256256

257257
"""

src/solver/types.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ end
153153
Base.eltype(::EnvBuoyGradVars{FT}) where {FT} = FT
154154
Base.broadcastable(x::EnvBuoyGradVars) = tuple(x)
155155

156+
struct MixingLength{FT}
157+
master::FT
158+
wall::FT
159+
tke::FT
160+
buoy::FT
161+
end
156162

157163
abstract type AbstractEDMF end
158164

0 commit comments

Comments
 (0)