From 14b644b98b16022b636a65d92f7d85829fecd8f3 Mon Sep 17 00:00:00 2001 From: Anna Jaruga Date: Wed, 4 Dec 2024 10:27:29 -0800 Subject: [PATCH] Add exponentially decaying with height diffusion --- NEWS.md | 8 ++++ Project.toml | 2 +- .../experiments/gcm_driven_scm/Manifest.toml | 4 +- .../Manifest.toml | 4 +- config/default_configs/default_config.yml | 2 +- .../gpu_aquaplanet_dyamond_diag_1process.yml | 2 +- .../gpu_configs/gpu_aquaplanet_dyamond_ss.yml | 2 +- .../gpu_aquaplanet_dyamond_ws_1process.yml | 2 +- .../gpu_aquaplanet_dyamond_ws_2process.yml | 2 +- .../gpu_aquaplanet_dyamond_ws_4process.yml | 2 +- .../longrun_aquaplanet_allsky_0M.yml | 2 +- .../longrun_aquaplanet_allsky_0M_earth.yml | 2 +- .../longrun_aquaplanet_allsky_1M.yml | 2 +- .../longrun_aquaplanet_allsky_1M_noneq.yml | 2 +- ...aquaplanet_allsky_tvinsol_0M_slabocean.yml | 2 +- .../longrun_aquaplanet_dyamond.yml | 10 ++--- ...oe_equil_clearsky_tvinsol_0M_slabocean.yml | 2 +- ...uil_clearsky_tvinsol_0M_slabocean_ft64.yml | 2 +- .../model_configs/gpu_aquaplanet_dyamond.yml | 2 +- ...e_aquaplanet_rhoe_nonequilmoist_allsky.yml | 2 +- ...re_aquaplanet_rhoe_equilmoist_clearsky.yml | 2 +- docs/Manifest.toml | 4 +- examples/Manifest.toml | 4 +- perf/Manifest.toml | 4 +- src/cache/precomputed_quantities.jl | 32 ++++++++++----- src/diagnostics/Diagnostics.jl | 1 + src/diagnostics/edmfx_diagnostics.jl | 12 +++++- src/parameters/Parameters.jl | 3 +- src/parameters/create_parameters.jl | 41 ++++++++++++++++++- .../vertical_diffusion_boundary_layer.jl | 2 +- src/solver/model_getters.jl | 7 +++- src/solver/types.jl | 5 +++ 32 files changed, 125 insertions(+), 50 deletions(-) diff --git a/NEWS.md b/NEWS.md index 72179ea869..4eecc84b1d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -14,6 +14,14 @@ the atmosphere. PR [3476](https://github.com/CliMA/ClimaAtmos.jl/pull/3476) v0.27.9 ------- +### Features + +### New option for vertical diffusion + +When `vert_diff` is set to `DecayWithHeightDiffusion`, diffusion decays +exponentially with height. +PR [3475](https://github.com/CliMA/ClimaAtmos.jl/pull/3475) + v0.27.8 ------- diff --git a/Project.toml b/Project.toml index 15ecbe00d6..fbdd709b1b 100644 --- a/Project.toml +++ b/Project.toml @@ -43,7 +43,7 @@ AtmosphericProfilesLibrary = "0.1.7" ClimaComms = "0.6.4" ClimaCore = "0.14.12" ClimaDiagnostics = "0.2.4" -ClimaParams = "0.10.12" +ClimaParams = "0.10.17" ClimaTimeSteppers = "0.7.33" ClimaUtilities = "0.1.14" CloudMicrophysics = "0.22.3" diff --git a/calibration/experiments/gcm_driven_scm/Manifest.toml b/calibration/experiments/gcm_driven_scm/Manifest.toml index 24642f1f97..b5f1ab6ad2 100644 --- a/calibration/experiments/gcm_driven_scm/Manifest.toml +++ b/calibration/experiments/gcm_driven_scm/Manifest.toml @@ -371,9 +371,9 @@ version = "0.2.8" [[deps.ClimaParams]] deps = ["TOML"] -git-tree-sha1 = "b43ca371c435056129295445122ea87fd843b505" +git-tree-sha1 = "df21e7c6101f38cfd61f82a9e965332eb3136854" uuid = "5c42b081-d73a-476f-9059-fd94b934656c" -version = "0.10.14" +version = "0.10.17" [[deps.ClimaTimeSteppers]] deps = ["ClimaComms", "Colors", "DataStructures", "DiffEqBase", "KernelAbstractions", "Krylov", "LinearAlgebra", "LinearOperators", "NVTX", "SciMLBase", "StaticArrays"] diff --git a/calibration/experiments/sphere_held_suarez_rhoe_equilmoist/Manifest.toml b/calibration/experiments/sphere_held_suarez_rhoe_equilmoist/Manifest.toml index 7c03b1fe0b..9d46fcb28f 100644 --- a/calibration/experiments/sphere_held_suarez_rhoe_equilmoist/Manifest.toml +++ b/calibration/experiments/sphere_held_suarez_rhoe_equilmoist/Manifest.toml @@ -386,9 +386,9 @@ version = "0.1.7" [[deps.ClimaParams]] deps = ["DocStringExtensions", "TOML", "Test"] -git-tree-sha1 = "0b5afc75bd3aa7c30d76c2d33b8361f961e86237" +git-tree-sha1 = "df21e7c6101f38cfd61f82a9e965332eb3136854" uuid = "5c42b081-d73a-476f-9059-fd94b934656c" -version = "0.10.8" +version = "0.10.17" [[deps.ClimaTimeSteppers]] deps = ["ClimaComms", "Colors", "DataStructures", "DiffEqBase", "DiffEqCallbacks", "KernelAbstractions", "Krylov", "LinearAlgebra", "LinearOperators", "NVTX", "SciMLBase", "StaticArrays"] diff --git a/config/default_configs/default_config.yml b/config/default_configs/default_config.yml index 8a59cda1fb..ed3c0af1be 100644 --- a/config/default_configs/default_config.yml +++ b/config/default_configs/default_config.yml @@ -140,7 +140,7 @@ reference_job_id: Identifier of job to use as the "reference" solution in the quicklook plot; the current job's results get compared to the results of the quicklook job on the main branch value: ~ vert_diff: - help: "Vertical diffusion [`false` (default), `VerticalDiffusion`, `true` (defaults to `VerticalDiffusion`), `FriersonDiffusion`]" + help: "Vertical diffusion [`false` (default), `VerticalDiffusion`, `true` (defaults to `VerticalDiffusion`), `FriersonDiffusion`, `DecayWithHeightDiffusion`]" value: false hyperdiff: help: "Hyperdiffusion [`ClimaHyperdiffusion` (or `true`; default), `none` (or `false`)]" diff --git a/config/gpu_configs/gpu_aquaplanet_dyamond_diag_1process.yml b/config/gpu_configs/gpu_aquaplanet_dyamond_diag_1process.yml index 0a18858834..2d4e802435 100644 --- a/config/gpu_configs/gpu_aquaplanet_dyamond_diag_1process.yml +++ b/config/gpu_configs/gpu_aquaplanet_dyamond_diag_1process.yml @@ -11,7 +11,7 @@ precip_model: 1M rad: allskywithclear idealized_insolation: false dt_rad: 1hours -vert_diff: FriersonDiffusion +vert_diff: "DecayWithHeightDiffusion" implicit_diffusion: true approximate_linear_solve_iters: 2 dt_cloud_fraction: 1hours diff --git a/config/gpu_configs/gpu_aquaplanet_dyamond_ss.yml b/config/gpu_configs/gpu_aquaplanet_dyamond_ss.yml index 289d2ec215..edb16c5939 100644 --- a/config/gpu_configs/gpu_aquaplanet_dyamond_ss.yml +++ b/config/gpu_configs/gpu_aquaplanet_dyamond_ss.yml @@ -13,7 +13,7 @@ rad: "allskywithclear" insolation: "timevarying" dt_rad: "1hours" dt_cloud_fraction: "1hours" -vert_diff: "FriersonDiffusion" +vert_diff: "DecayWithHeightDiffusion" implicit_diffusion: true approximate_linear_solve_iters: 2 surface_setup: "DefaultMoninObukhov" diff --git a/config/gpu_configs/gpu_aquaplanet_dyamond_ws_1process.yml b/config/gpu_configs/gpu_aquaplanet_dyamond_ws_1process.yml index 19563ce88d..95161f866f 100644 --- a/config/gpu_configs/gpu_aquaplanet_dyamond_ws_1process.yml +++ b/config/gpu_configs/gpu_aquaplanet_dyamond_ws_1process.yml @@ -13,7 +13,7 @@ rad: "allskywithclear" insolation: "timevarying" dt_rad: "1hours" dt_cloud_fraction: "1hours" -vert_diff: "FriersonDiffusion" +vert_diff: "DecayWithHeightDiffusion" implicit_diffusion: true approximate_linear_solve_iters: 2 surface_setup: "DefaultMoninObukhov" diff --git a/config/gpu_configs/gpu_aquaplanet_dyamond_ws_2process.yml b/config/gpu_configs/gpu_aquaplanet_dyamond_ws_2process.yml index 5b3f502702..3cc7a18271 100644 --- a/config/gpu_configs/gpu_aquaplanet_dyamond_ws_2process.yml +++ b/config/gpu_configs/gpu_aquaplanet_dyamond_ws_2process.yml @@ -13,7 +13,7 @@ rad: "allskywithclear" insolation: "timevarying" dt_rad: "1hours" dt_cloud_fraction: "1hours" -vert_diff: "FriersonDiffusion" +vert_diff: "DecayWithHeightDiffusion" implicit_diffusion: true approximate_linear_solve_iters: 2 surface_setup: "DefaultMoninObukhov" diff --git a/config/gpu_configs/gpu_aquaplanet_dyamond_ws_4process.yml b/config/gpu_configs/gpu_aquaplanet_dyamond_ws_4process.yml index a8c4e0880d..cc492f89c3 100644 --- a/config/gpu_configs/gpu_aquaplanet_dyamond_ws_4process.yml +++ b/config/gpu_configs/gpu_aquaplanet_dyamond_ws_4process.yml @@ -13,7 +13,7 @@ rad: "allskywithclear" insolation: "timevarying" dt_rad: "1hours" dt_cloud_fraction: "1hours" -vert_diff: "FriersonDiffusion" +vert_diff: "DecayWithHeightDiffusion" implicit_diffusion: true approximate_linear_solve_iters: 2 surface_setup: "DefaultMoninObukhov" diff --git a/config/longrun_configs/longrun_aquaplanet_allsky_0M.yml b/config/longrun_configs/longrun_aquaplanet_allsky_0M.yml index 654f774f3d..e1befbc8e3 100644 --- a/config/longrun_configs/longrun_aquaplanet_allsky_0M.yml +++ b/config/longrun_configs/longrun_aquaplanet_allsky_0M.yml @@ -14,6 +14,6 @@ rad: "allskywithclear" dt_rad: "1hours" dt_cloud_fraction: "1hours" surface_setup: "DefaultMoninObukhov" -vert_diff: "FriersonDiffusion" +vert_diff: "DecayWithHeightDiffusion" precip_model: "0M" toml: [toml/longrun_aquaplanet.toml] diff --git a/config/longrun_configs/longrun_aquaplanet_allsky_0M_earth.yml b/config/longrun_configs/longrun_aquaplanet_allsky_0M_earth.yml index 997ab6d676..2e2b06e350 100644 --- a/config/longrun_configs/longrun_aquaplanet_allsky_0M_earth.yml +++ b/config/longrun_configs/longrun_aquaplanet_allsky_0M_earth.yml @@ -16,6 +16,6 @@ rad: "allskywithclear" dt_rad: "1hours" dt_cloud_fraction: "1hours" surface_setup: "DefaultMoninObukhov" -vert_diff: "FriersonDiffusion" +vert_diff: "DecayWithHeightDiffusion" precip_model: "0M" toml: [toml/longrun_aquaplanet.toml] diff --git a/config/longrun_configs/longrun_aquaplanet_allsky_1M.yml b/config/longrun_configs/longrun_aquaplanet_allsky_1M.yml index e5719e12c2..c312a131b1 100644 --- a/config/longrun_configs/longrun_aquaplanet_allsky_1M.yml +++ b/config/longrun_configs/longrun_aquaplanet_allsky_1M.yml @@ -14,6 +14,6 @@ rad: "allskywithclear" dt_rad: "1hours" dt_cloud_fraction: "1hours" surface_setup: "DefaultMoninObukhov" -vert_diff: "FriersonDiffusion" +vert_diff: "DecayWithHeightDiffusion" precip_model: "1M" toml: [toml/longrun_aquaplanet.toml] diff --git a/config/longrun_configs/longrun_aquaplanet_allsky_1M_noneq.yml b/config/longrun_configs/longrun_aquaplanet_allsky_1M_noneq.yml index fc6c23f03a..6f869a8e81 100644 --- a/config/longrun_configs/longrun_aquaplanet_allsky_1M_noneq.yml +++ b/config/longrun_configs/longrun_aquaplanet_allsky_1M_noneq.yml @@ -16,5 +16,5 @@ rad: "allskywithclear" dt_rad: "1hours" dt_cloud_fraction: "1hours" surface_setup: "DefaultMoninObukhov" -vert_diff: "FriersonDiffusion" +vert_diff: "DecayWithHeightDiffusion" toml: [toml/longrun_aquaplanet.toml] diff --git a/config/longrun_configs/longrun_aquaplanet_allsky_tvinsol_0M_slabocean.yml b/config/longrun_configs/longrun_aquaplanet_allsky_tvinsol_0M_slabocean.yml index f11102031a..edf98589f3 100644 --- a/config/longrun_configs/longrun_aquaplanet_allsky_tvinsol_0M_slabocean.yml +++ b/config/longrun_configs/longrun_aquaplanet_allsky_tvinsol_0M_slabocean.yml @@ -14,7 +14,7 @@ moist: "equil" prognostic_surface: "PrognosticSurfaceTemperature" albedo_model: "RegressionFunctionAlbedo" surface_setup: "DefaultMoninObukhov" -vert_diff: "FriersonDiffusion" +vert_diff: "DecayWithHeightDiffusion" rad: "allskywithclear" insolation: "timevarying" dt_rad: "1hours" diff --git a/config/longrun_configs/longrun_aquaplanet_dyamond.yml b/config/longrun_configs/longrun_aquaplanet_dyamond.yml index a971cf3783..0dd97ae034 100644 --- a/config/longrun_configs/longrun_aquaplanet_dyamond.yml +++ b/config/longrun_configs/longrun_aquaplanet_dyamond.yml @@ -6,16 +6,16 @@ rayleigh_sponge: true viscous_sponge: true implicit_diffusion: true approximate_linear_solve_iters: 2 -moist: "equil" +moist: "equil" cloud_model: "grid_scale" -dt: "60secs" +dt: "60secs" t_end: "30days" dt_save_state_to_disk: "10days" rad: "allskywithclear" insolation: "timevarying" dt_rad: "1hours" dt_cloud_fraction: "1hours" -surface_setup: "DefaultMoninObukhov" -vert_diff: "FriersonDiffusion" -precip_model: "0M" +surface_setup: "DefaultMoninObukhov" +vert_diff: "DecayWithHeightDiffusion" +precip_model: "0M" toml: [toml/longrun_aquaplanet.toml] diff --git a/config/model_configs/aquaplanet_rhoe_equil_clearsky_tvinsol_0M_slabocean.yml b/config/model_configs/aquaplanet_rhoe_equil_clearsky_tvinsol_0M_slabocean.yml index f0b6406cfc..ba6e564c3a 100644 --- a/config/model_configs/aquaplanet_rhoe_equil_clearsky_tvinsol_0M_slabocean.yml +++ b/config/model_configs/aquaplanet_rhoe_equil_clearsky_tvinsol_0M_slabocean.yml @@ -4,7 +4,7 @@ t_end: "5days" moist: "equil" precip_model: "0M" surface_setup: "DefaultMoninObukhov" -vert_diff: "FriersonDiffusion" +vert_diff: "DecayWithHeightDiffusion" implicit_diffusion: true approximate_linear_solve_iters: 2 rad: "clearsky" diff --git a/config/model_configs/aquaplanet_rhoe_equil_clearsky_tvinsol_0M_slabocean_ft64.yml b/config/model_configs/aquaplanet_rhoe_equil_clearsky_tvinsol_0M_slabocean_ft64.yml index ebda4e29eb..7df58c39e1 100644 --- a/config/model_configs/aquaplanet_rhoe_equil_clearsky_tvinsol_0M_slabocean_ft64.yml +++ b/config/model_configs/aquaplanet_rhoe_equil_clearsky_tvinsol_0M_slabocean_ft64.yml @@ -4,7 +4,7 @@ t_end: "5days" moist: "equil" precip_model: "0M" surface_setup: "DefaultMoninObukhov" -vert_diff: "FriersonDiffusion" +vert_diff: "DecayWithHeightDiffusion" implicit_diffusion: true approximate_linear_solve_iters: 2 rad: "clearsky" diff --git a/config/model_configs/gpu_aquaplanet_dyamond.yml b/config/model_configs/gpu_aquaplanet_dyamond.yml index 836c1c412a..7cc0e9ecf4 100644 --- a/config/model_configs/gpu_aquaplanet_dyamond.yml +++ b/config/model_configs/gpu_aquaplanet_dyamond.yml @@ -10,7 +10,7 @@ rad: "allskywithclear" insolation: "timevarying" dt_rad: "1hours" dt_cloud_fraction: "1hours" -vert_diff: "FriersonDiffusion" +vert_diff: "DecayWithHeightDiffusion" implicit_diffusion: true approximate_linear_solve_iters: 2 surface_setup: "DefaultMoninObukhov" diff --git a/config/model_configs/sphere_aquaplanet_rhoe_nonequilmoist_allsky.yml b/config/model_configs/sphere_aquaplanet_rhoe_nonequilmoist_allsky.yml index 05e922540c..26a58f0a51 100644 --- a/config/model_configs/sphere_aquaplanet_rhoe_nonequilmoist_allsky.yml +++ b/config/model_configs/sphere_aquaplanet_rhoe_nonequilmoist_allsky.yml @@ -4,7 +4,7 @@ dz_bottom: 50.0 dt: "400secs" t_end: "18hours" dt_save_state_to_disk: "18hours" -vert_diff: "FriersonDiffusion" +vert_diff: "DecayWithHeightDiffusion" implicit_diffusion: true approximate_linear_solve_iters: 2 cloud_model: "grid_scale" diff --git a/config/mpi_configs/mpi_sphere_aquaplanet_rhoe_equilmoist_clearsky.yml b/config/mpi_configs/mpi_sphere_aquaplanet_rhoe_equilmoist_clearsky.yml index 9e66b148ef..f3f1004cf6 100644 --- a/config/mpi_configs/mpi_sphere_aquaplanet_rhoe_equilmoist_clearsky.yml +++ b/config/mpi_configs/mpi_sphere_aquaplanet_rhoe_equilmoist_clearsky.yml @@ -1,4 +1,4 @@ -vert_diff: true +vert_diff: "DecayWithHeightDiffusion" surface_setup: "DefaultExchangeCoefficients" moist: "equil" rad: "clearsky" diff --git a/docs/Manifest.toml b/docs/Manifest.toml index fbee9a7b77..238578375c 100644 --- a/docs/Manifest.toml +++ b/docs/Manifest.toml @@ -349,9 +349,9 @@ version = "0.2.11" [[deps.ClimaParams]] deps = ["TOML"] -git-tree-sha1 = "489c5655993c62fb34293908a6b0877e32f183ee" +git-tree-sha1 = "df21e7c6101f38cfd61f82a9e965332eb3136854" uuid = "5c42b081-d73a-476f-9059-fd94b934656c" -version = "0.10.16" +version = "0.10.17" [[deps.ClimaTimeSteppers]] deps = ["ClimaComms", "Colors", "DataStructures", "DiffEqBase", "KernelAbstractions", "Krylov", "LinearAlgebra", "LinearOperators", "NVTX", "SciMLBase", "StaticArrays"] diff --git a/examples/Manifest.toml b/examples/Manifest.toml index 0c3f499cf7..af88d9d421 100644 --- a/examples/Manifest.toml +++ b/examples/Manifest.toml @@ -400,9 +400,9 @@ version = "0.2.11" [[deps.ClimaParams]] deps = ["TOML"] -git-tree-sha1 = "489c5655993c62fb34293908a6b0877e32f183ee" +git-tree-sha1 = "df21e7c6101f38cfd61f82a9e965332eb3136854" uuid = "5c42b081-d73a-476f-9059-fd94b934656c" -version = "0.10.16" +version = "0.10.17" [[deps.ClimaReproducibilityTests]] deps = ["OrderedCollections", "PrettyTables"] diff --git a/perf/Manifest.toml b/perf/Manifest.toml index 9ebf0babe1..c22db51468 100644 --- a/perf/Manifest.toml +++ b/perf/Manifest.toml @@ -411,9 +411,9 @@ version = "0.2.11" [[deps.ClimaParams]] deps = ["TOML"] -git-tree-sha1 = "489c5655993c62fb34293908a6b0877e32f183ee" +git-tree-sha1 = "df21e7c6101f38cfd61f82a9e965332eb3136854" uuid = "5c42b081-d73a-476f-9059-fd94b934656c" -version = "0.10.16" +version = "0.10.17" [[deps.ClimaTimeSteppers]] deps = ["ClimaComms", "Colors", "DataStructures", "DiffEqBase", "KernelAbstractions", "Krylov", "LinearAlgebra", "LinearOperators", "NVTX", "SciMLBase", "StaticArrays"] diff --git a/src/cache/precomputed_quantities.jl b/src/cache/precomputed_quantities.jl index 6acf4fa2ad..f7fa5668e0 100644 --- a/src/cache/precomputed_quantities.jl +++ b/src/cache/precomputed_quantities.jl @@ -139,15 +139,14 @@ function precomputed_quantities(Y, atmos) ρatke_flux = similar(Fields.level(Y.f, half), C3{FT}), precipitation_sgs_quantities..., ) : (;) - vert_diff_quantities = if atmos.vert_diff isa VerticalDiffusion - ᶜK_h = similar(Y.c, FT) - (; ᶜK_u = ᶜK_h, ᶜK_h) # ᶜK_u aliases ᶜK_h because they are always equal. - elseif atmos.vert_diff isa FriersonDiffusion - ᶜK_h = similar(Y.c, FT) - (; ᶜK_u = ᶜK_h, ᶜK_h) # ᶜK_u aliases ᶜK_h because they are always equal. - else - (;) - end + vert_diff_quantities = + if atmos.vert_diff isa + Union{VerticalDiffusion, DecayWithHeightDiffusion, FriersonDiffusion} + ᶜK_h = similar(Y.c, FT) + (; ᶜK_u = ᶜK_h, ᶜK_h) # ᶜK_u aliases ᶜK_h because they are always equal. + else + (;) + end precipitation_quantities = atmos.precip_model isa Microphysics1Moment ? (; @@ -333,6 +332,9 @@ ts_sgs(thermo_params, moisture_model, specific, K, Φ, p) = thermo_state( p, ) +function eddy_diffusivity_coefficient_H(D₀, H, z_sfc, z) + return D₀ * exp(-(z - z_sfc) / H) +end function eddy_diffusivity_coefficient(C_E, norm_v_a, z_a, p) p_pbl = 85000 p_strato = 10000 @@ -544,7 +546,17 @@ NVTX.@annotate function set_precomputed_quantities!(Y, p, t) ) end - if vert_diff isa VerticalDiffusion + if vert_diff isa DecayWithHeightDiffusion + (; ᶜK_h) = p.precomputed + ᶜz = Fields.coordinate_field(Y.c).z + ᶠz_sfc = Fields.level(Fields.coordinate_field(Y.f).z, Fields.half) + @. ᶜK_h = eddy_diffusivity_coefficient_H( + p.atmos.vert_diff.D₀, + p.atmos.vert_diff.H, + ᶠz_sfc, + ᶜz, + ) + elseif vert_diff isa VerticalDiffusion (; ᶜK_h) = p.precomputed interior_uₕ = Fields.level(Y.c.uₕ, 1) ᶜΔz_surface = Fields.Δz_field(interior_uₕ) diff --git a/src/diagnostics/Diagnostics.jl b/src/diagnostics/Diagnostics.jl index e8f655623c..cec21cb153 100644 --- a/src/diagnostics/Diagnostics.jl +++ b/src/diagnostics/Diagnostics.jl @@ -35,6 +35,7 @@ import ClimaAtmos.RRTMGPInterface as RRTMGPI # vert_diff import ..VerticalDiffusion import ..FriersonDiffusion +import ..DecayWithHeightDiffusion # turbconv_model import ..PrognosticEDMFX diff --git a/src/diagnostics/edmfx_diagnostics.jl b/src/diagnostics/edmfx_diagnostics.jl index 245405f577..fd01358f9b 100644 --- a/src/diagnostics/edmfx_diagnostics.jl +++ b/src/diagnostics/edmfx_diagnostics.jl @@ -1017,7 +1017,11 @@ function compute_edt!( state, cache, time, - vert_diff::Union{VerticalDiffusion, FriersonDiffusion}, + vert_diff::Union{ + VerticalDiffusion, + FriersonDiffusion, + DecayWithHeightDiffusion, + }, turbconv_model::Nothing, ) if isnothing(out) @@ -1072,7 +1076,11 @@ function compute_evu!( state, cache, time, - vert_diff::Union{VerticalDiffusion, FriersonDiffusion}, + vert_diff::Union{ + VerticalDiffusion, + FriersonDiffusion, + DecayWithHeightDiffusion, + }, turbconv_model::Nothing, ) if isnothing(out) diff --git a/src/parameters/Parameters.jl b/src/parameters/Parameters.jl index 24348aab78..2eebc7254f 100644 --- a/src/parameters/Parameters.jl +++ b/src/parameters/Parameters.jl @@ -69,6 +69,7 @@ Base.@kwdef struct ClimaAtmosParameters{ SFP, TCP, STP, + VDP, } <: ACAP thermodynamics_params::TP rrtmgp_params::RP @@ -79,12 +80,12 @@ Base.@kwdef struct ClimaAtmosParameters{ surface_fluxes_params::SFP turbconv_params::TCP surface_temp_params::STP + vert_diff_params::VDP Omega::FT f_plane_coriolis_frequency::FT planet_radius::FT astro_unit::FT c_smag::FT - C_E::FT C_H::FT # Held Suarez ΔT_y_dry::FT diff --git a/src/parameters/create_parameters.jl b/src/parameters/create_parameters.jl index 0fcf74f8f7..8c1ad6b9ed 100644 --- a/src/parameters/create_parameters.jl +++ b/src/parameters/create_parameters.jl @@ -135,6 +135,31 @@ function create_parameter_set(config::AtmosConfig) end MPP = typeof(microphysics_precipitation_params) + vert_diff_model = parsed_args["vert_diff"] + name_map_vert_diff = + if vert_diff_model in + ("true", true, "VerticalDiffusion", "FriersonDiffusion") + (; :C_E => :C_E,) + elseif vert_diff_model in ("DecayWithHeightDiffusion",) + (; :H_diffusion => :H, :D_0_diffusion => :D₀) + else + nothing + end + vert_diff_params = if vert_diff_model in ("false", false, "none") + nothing + elseif vert_diff_model in ( + "true", + true, + "VerticalDiffusion", + "FriersonDiffusion", + "DecayWithHeightDiffusion", + ) + CP.get_parameter_values(toml_dict, name_map_vert_diff, "ClimaAtmos") + else + error("Invalid diffusion model `$vert_diff_model`.") + end + VDP = typeof(vert_diff_params) + name_map = (; :f_plane_coriolis_frequency => :f_plane_coriolis_frequency, :equator_pole_temperature_gradient_wet => :ΔT_y_wet, @@ -145,7 +170,6 @@ function create_parameter_set(config::AtmosConfig) :zd_viscous => :zd_viscous, :planet_radius => :planet_radius, :potential_temp_vertical_gradient => :Δθ_z, - :C_E => :C_E, :C_H => :C_H, :c_smag => :c_smag, :alpha_rayleigh_w => :alpha_rayleigh_w, @@ -161,7 +185,19 @@ function create_parameter_set(config::AtmosConfig) :optics_lookup_temperature_max => :optics_lookup_temperature_max, ) parameters = CP.get_parameter_values(toml_dict, name_map, "ClimaAtmos") - return CAP.ClimaAtmosParameters{FT, TP, RP, IP, MPC, MPP, WP, SFP, TCP, STP}(; + return CAP.ClimaAtmosParameters{ + FT, + TP, + RP, + IP, + MPC, + MPP, + WP, + SFP, + TCP, + STP, + VDP, + }(; parameters..., thermodynamics_params, rrtmgp_params, @@ -172,5 +208,6 @@ function create_parameter_set(config::AtmosConfig) surface_fluxes_params, turbconv_params, surface_temp_params, + vert_diff_params, ) end diff --git a/src/prognostic_equations/vertical_diffusion_boundary_layer.jl b/src/prognostic_equations/vertical_diffusion_boundary_layer.jl index c9bdf3a581..7c906a4fb5 100644 --- a/src/prognostic_equations/vertical_diffusion_boundary_layer.jl +++ b/src/prognostic_equations/vertical_diffusion_boundary_layer.jl @@ -23,7 +23,7 @@ function vertical_diffusion_boundary_layer_tendency!( Y, p, t, - ::Union{VerticalDiffusion, FriersonDiffusion}, + ::Union{VerticalDiffusion, FriersonDiffusion, DecayWithHeightDiffusion}, ) FT = eltype(Y) (; ᶜu, ᶜh_tot, ᶜspecific, ᶜK_u, ᶜK_h, sfc_conditions) = p.precomputed diff --git a/src/solver/model_getters.jl b/src/solver/model_getters.jl index 29ef6a1160..8fe0eafb17 100644 --- a/src/solver/model_getters.jl +++ b/src/solver/model_getters.jl @@ -106,12 +106,15 @@ function get_vertical_diffusion_model( ::Type{FT}, ) where {FT} vert_diff_name = parsed_args["vert_diff"] + vdp = CAP.vert_diff_params(params) return if vert_diff_name in ("false", false, "none") nothing elseif vert_diff_name in ("true", true, "VerticalDiffusion") - VerticalDiffusion{diffuse_momentum, FT}(; C_E = params.C_E) + VerticalDiffusion{diffuse_momentum, FT}(; C_E = vdp.C_E) elseif vert_diff_name in ("FriersonDiffusion",) - FriersonDiffusion{diffuse_momentum, FT}(; C_E = params.C_E) + FriersonDiffusion{diffuse_momentum, FT}(; C_E = vdp.C_E) + elseif vert_diff_name in ("DecayWithHeightDiffusion",) + DecayWithHeightDiffusion{diffuse_momentum, FT}(; H = vdp.H, D₀ = vdp.D₀) else error("Uncaught diffusion model `$vert_diff_name`.") end diff --git a/src/solver/types.jl b/src/solver/types.jl index 6394389223..4a468c06b7 100644 --- a/src/solver/types.jl +++ b/src/solver/types.jl @@ -117,6 +117,11 @@ Base.@kwdef struct VerticalDiffusion{DM, FT} <: AbstractVerticalDiffusion C_E::FT end diffuse_momentum(::VerticalDiffusion{DM}) where {DM} = DM +Base.@kwdef struct DecayWithHeightDiffusion{DM, FT} <: AbstractVerticalDiffusion + H::FT + D₀::FT +end +diffuse_momentum(::DecayWithHeightDiffusion{DM}) where {DM} = DM Base.@kwdef struct FriersonDiffusion{DM, FT} <: AbstractVerticalDiffusion C_E::FT end