Skip to content

Commit e3d8c1b

Browse files
authored
Merge pull request #2898 from CliMA/zs/edmf_scalar_bc
make edmf boundary condition dependent on surface area fraction
2 parents e9aba77 + e2c5939 commit e3d8c1b

File tree

8 files changed

+41
-11
lines changed

8 files changed

+41
-11
lines changed

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
2020
Dierckx = "39dd38d3-220a-591b-8e3c-4c3a8c710a94"
2121
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
2222
DiffEqCallbacks = "459566f4-90b8-5000-8ac3-15dfb0a30def"
23+
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
2324
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
2425
FastGaussQuadrature = "442a2c76-b920-505d-bb47-c5924d526838"
2526
Insolation = "e98cc03f-d57e-4e3c-b70c-8d51efe9e0d8"
@@ -61,6 +62,7 @@ Dates = "1"
6162
Dierckx = "0.5"
6263
DiffEqBase = "6"
6364
DiffEqCallbacks = "2"
65+
Distributions = "0.25"
6466
DocStringExtensions = "0.8, 0.9"
6567
FastGaussQuadrature = "0.4, 0.5, 1"
6668
Insolation = "0.9.2"

docs/Manifest.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ weakdeps = ["SparseArrays"]
319319
ChainRulesCoreSparseArraysExt = "SparseArrays"
320320

321321
[[deps.ClimaAtmos]]
322-
deps = ["Adapt", "ArgParse", "ArtifactWrappers", "Artifacts", "AtmosphericProfilesLibrary", "ClimaComms", "ClimaCore", "ClimaParams", "ClimaTimeSteppers", "ClimaUtilities", "CloudMicrophysics", "Colors", "Dates", "Dierckx", "DiffEqBase", "DiffEqCallbacks", "DocStringExtensions", "FastGaussQuadrature", "Insolation", "Interpolations", "IntervalSets", "Krylov", "LinearAlgebra", "Logging", "NCDatasets", "NVTX", "Pkg", "Printf", "RRTMGP", "Random", "RootSolvers", "SciMLBase", "StaticArrays", "Statistics", "StatsBase", "SurfaceFluxes", "Thermodynamics", "YAML"]
322+
deps = ["Adapt", "ArgParse", "ArtifactWrappers", "Artifacts", "AtmosphericProfilesLibrary", "ClimaComms", "ClimaCore", "ClimaParams", "ClimaTimeSteppers", "ClimaUtilities", "CloudMicrophysics", "Colors", "Dates", "Dierckx", "DiffEqBase", "DiffEqCallbacks", "Distributions", "DocStringExtensions", "FastGaussQuadrature", "Insolation", "Interpolations", "IntervalSets", "Krylov", "LinearAlgebra", "Logging", "NCDatasets", "NVTX", "Pkg", "Printf", "RRTMGP", "Random", "RootSolvers", "SciMLBase", "StaticArrays", "Statistics", "StatsBase", "SurfaceFluxes", "Thermodynamics", "YAML"]
323323
path = ".."
324324
uuid = "b2c96348-7fb7-4fe0-8da9-78d88439e717"
325325
version = "0.23.0"

examples/Manifest.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ weakdeps = ["CairoMakie"]
307307
CairoMakieExt = "CairoMakie"
308308

309309
[[deps.ClimaAtmos]]
310-
deps = ["Adapt", "ArgParse", "ArtifactWrappers", "Artifacts", "AtmosphericProfilesLibrary", "ClimaComms", "ClimaCore", "ClimaParams", "ClimaTimeSteppers", "ClimaUtilities", "CloudMicrophysics", "Colors", "Dates", "Dierckx", "DiffEqBase", "DiffEqCallbacks", "DocStringExtensions", "FastGaussQuadrature", "Insolation", "Interpolations", "IntervalSets", "Krylov", "LinearAlgebra", "Logging", "NCDatasets", "NVTX", "Pkg", "Printf", "RRTMGP", "Random", "RootSolvers", "SciMLBase", "StaticArrays", "Statistics", "StatsBase", "SurfaceFluxes", "Thermodynamics", "YAML"]
310+
deps = ["Adapt", "ArgParse", "ArtifactWrappers", "Artifacts", "AtmosphericProfilesLibrary", "ClimaComms", "ClimaCore", "ClimaParams", "ClimaTimeSteppers", "ClimaUtilities", "CloudMicrophysics", "Colors", "Dates", "Dierckx", "DiffEqBase", "DiffEqCallbacks", "Distributions", "DocStringExtensions", "FastGaussQuadrature", "Insolation", "Interpolations", "IntervalSets", "Krylov", "LinearAlgebra", "Logging", "NCDatasets", "NVTX", "Pkg", "Printf", "RRTMGP", "Random", "RootSolvers", "SciMLBase", "StaticArrays", "Statistics", "StatsBase", "SurfaceFluxes", "Thermodynamics", "YAML"]
311311
path = ".."
312312
uuid = "b2c96348-7fb7-4fe0-8da9-78d88439e717"
313313
version = "0.23.0"

perf/Manifest.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ version = "0.5.0"
322322
GeoMakie = "db073c08-6b98-4ee5-b6a4-5efafb3259c6"
323323

324324
[[deps.ClimaAtmos]]
325-
deps = ["Adapt", "ArgParse", "ArtifactWrappers", "Artifacts", "AtmosphericProfilesLibrary", "ClimaComms", "ClimaCore", "ClimaParams", "ClimaTimeSteppers", "ClimaUtilities", "CloudMicrophysics", "Colors", "Dates", "Dierckx", "DiffEqBase", "DiffEqCallbacks", "DocStringExtensions", "FastGaussQuadrature", "Insolation", "Interpolations", "IntervalSets", "Krylov", "LinearAlgebra", "Logging", "NCDatasets", "NVTX", "Pkg", "Printf", "RRTMGP", "Random", "RootSolvers", "SciMLBase", "StaticArrays", "Statistics", "StatsBase", "SurfaceFluxes", "Thermodynamics", "YAML"]
325+
deps = ["Adapt", "ArgParse", "ArtifactWrappers", "Artifacts", "AtmosphericProfilesLibrary", "ClimaComms", "ClimaCore", "ClimaParams", "ClimaTimeSteppers", "ClimaUtilities", "CloudMicrophysics", "Colors", "Dates", "Dierckx", "DiffEqBase", "DiffEqCallbacks", "Distributions", "DocStringExtensions", "FastGaussQuadrature", "Insolation", "Interpolations", "IntervalSets", "Krylov", "LinearAlgebra", "Logging", "NCDatasets", "NVTX", "Pkg", "Printf", "RRTMGP", "Random", "RootSolvers", "SciMLBase", "StaticArrays", "Statistics", "StatsBase", "SurfaceFluxes", "Thermodynamics", "YAML"]
326326
path = ".."
327327
uuid = "b2c96348-7fb7-4fe0-8da9-78d88439e717"
328328
version = "0.23.0"

regression_tests/ref_counter.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
158
1+
159
2+
3+
# 159:
4+
# - Changed the boundary condition of edmf updraft properties
5+
# to be dependent on the surface area
26

37
# 158:
48
# - Switched back the precipitation threshold defintion in the
5-
# 0-moment scheme to specific humidity
9+
# 0-moment scheme to specific humidity
10+
611
# 157:
712
# - For the grid mean precipitation tendency in the 0-moment scheme:
813
# - added limiting by q_tot/dt

src/cache/diagnostic_edmf_precomputed_quantities.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ NVTX.@annotate function set_diagnostic_edmf_precomputed_quantities_bottom_bc!(
155155
@. mseʲ_int_level = sgs_scalar_first_interior_bc(
156156
z_int_level - z_sfc_halflevel,
157157
ρ_int_level,
158+
turbconv_model.a_int,
158159
h_tot_int_level - K_int_level,
159160
buoyancy_flux_sfc_halflevel,
160161
ρ_flux_h_tot_sfc_halflevel,
@@ -165,6 +166,7 @@ NVTX.@annotate function set_diagnostic_edmf_precomputed_quantities_bottom_bc!(
165166
@. q_totʲ_int_level = sgs_scalar_first_interior_bc(
166167
z_int_level - z_sfc_halflevel,
167168
ρ_int_level,
169+
turbconv_model.a_int,
168170
q_tot_int_level,
169171
buoyancy_flux_sfc_halflevel,
170172
ρ_flux_q_tot_sfc_halflevel,

src/cache/prognostic_edmf_precomputed_quantities.jl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_draft_and_bc!
7070

7171
(; params) = p
7272
thermo_params = CAP.thermodynamics_params(params)
73+
turbconv_params = CAP.turbconv_params(params)
7374

7475
(; ᶜΦ,) = p.core
7576
(; ᶜspecific, ᶜp, ᶜh_tot, ᶜK) = p.precomputed
@@ -96,7 +97,7 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_draft_and_bc!
9697

9798
# We need field_values everywhere because we are mixing
9899
# information from surface and first interior inside the
99-
# sgs_h/q_tot_first_interior_bc call.
100+
# sgs_scalar_first_interior_bc call.
100101
ᶜz_int_val =
101102
Fields.field_values(Fields.level(Fields.coordinate_field(Y.c).z, 1))
102103
z_sfc_val = Fields.field_values(
@@ -116,13 +117,18 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_draft_and_bc!
116117
)
117118

118119
# Based on boundary conditions for updrafts we overwrite
119-
# the first interior point for EDMFX ᶜh_totʲ...
120+
# the first interior point for EDMFX ᶜmseʲ...
121+
ᶜaʲ_int_val = p.scratch.temp_data_level
122+
# TODO: replace this with the actual surface area fraction when
123+
# using prognostic surface area
124+
@. ᶜaʲ_int_val = FT(turbconv_params.surface_area)
120125
ᶜh_tot_int_val = Fields.field_values(Fields.level(ᶜh_tot, 1))
121126
ᶜK_int_val = Fields.field_values(Fields.level(ᶜK, 1))
122127
ᶜmseʲ_int_val = Fields.field_values(Fields.level(ᶜmseʲ, 1))
123128
@. ᶜmseʲ_int_val = sgs_scalar_first_interior_bc(
124129
ᶜz_int_val - z_sfc_val,
125130
ᶜρ_int_val,
131+
ᶜaʲ_int_val,
126132
ᶜh_tot_int_val - ᶜK_int_val,
127133
buoyancy_flux_val,
128134
ρ_flux_h_tot_val,
@@ -137,6 +143,7 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_draft_and_bc!
137143
@. ᶜq_totʲ_int_val = sgs_scalar_first_interior_bc(
138144
ᶜz_int_val - z_sfc_val,
139145
ᶜρ_int_val,
146+
ᶜaʲ_int_val,
140147
ᶜq_tot_int_val,
141148
buoyancy_flux_val,
142149
ρ_flux_q_tot_val,
@@ -158,7 +165,6 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_draft_and_bc!
158165
sgsʲs_ρa_int_val =
159166
Fields.field_values(Fields.level(Y.c.sgsʲs.:($j).ρa, 1))
160167

161-
turbconv_params = CAP.turbconv_params(params)
162168
@. sgsʲs_ρ_int_val = TD.air_density(thermo_params, ᶜtsʲ_int_val)
163169
@. sgsʲs_ρa_int_val =
164170
$(FT(turbconv_params.surface_area)) *

src/prognostic_equations/edmfx_boundary_condition.jl

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
##### EDMFX SGS boundary condition
33
#####
44

5+
import Distributions
6+
57
function sgs_scalar_first_interior_bc(
68
ᶜz_int::FT,
79
ᶜρ_int::FT,
10+
ᶜaʲ_int::FT,
811
ᶜscalar_int::FT,
912
sfc_buoyancy_flux,
1013
sfc_ρ_flux_scalar,
@@ -13,8 +16,6 @@ function sgs_scalar_first_interior_bc(
1316
sfc_local_geometry,
1417
) where {FT}
1518
sfc_buoyancy_flux > 0 || return ᶜscalar_int
16-
# a_total = edmf.surface_area
17-
# a_ = area_surface_bc(surface_conditions, edmf)
1819
scalar_var = get_first_interior_variance(
1920
sfc_ρ_flux_scalar / ᶜρ_int,
2021
ustar,
@@ -26,7 +27,8 @@ function sgs_scalar_first_interior_bc(
2627
# 1 - a_total + (i - 1) * a_,
2728
# 1 - a_total + i * a_,
2829
# )
29-
surface_scalar_coeff = FT(1.75)
30+
# TODO: This assumes that there is only one updraft
31+
surface_scalar_coeff = percentile_bounds_mean_norm(1 - ᶜaʲ_int, FT(1))
3032
return ᶜscalar_int + surface_scalar_coeff * sqrt(scalar_var)
3133
end
3234

@@ -46,3 +48,16 @@ function get_first_interior_variance(
4648
return 4 * Geometry._norm_sqr(c_star, local_geometry)
4749
end
4850
end
51+
52+
function percentile_bounds_mean_norm(
53+
low_percentile::FT,
54+
high_percentile::FT,
55+
) where {FT <: Real}
56+
gauss_int(x) = -exp(-x * x / 2) / sqrt(2 * pi)
57+
xp_low = Distributions.quantile(Distributions.Normal(), low_percentile)
58+
xp_high = Distributions.quantile(Distributions.Normal(), high_percentile)
59+
return (gauss_int(xp_high) - gauss_int(xp_low)) / (
60+
Distributions.cdf(Distributions.Normal(), xp_high) -
61+
Distributions.cdf(Distributions.Normal(), xp_low)
62+
)
63+
end

0 commit comments

Comments
 (0)