From 18be0b109d9906c59bfeb266b1bf2bb684560907 Mon Sep 17 00:00:00 2001 From: Zhaoyi Shen <11598433+szy21@users.noreply.github.com> Date: Fri, 21 Jun 2024 11:55:24 -0700 Subject: [PATCH] limit temperature for radiation --- docs/Manifest.toml | 4 ++-- examples/Manifest.toml | 4 ++-- perf/Manifest.toml | 4 ++-- src/callbacks/callbacks.jl | 6 +++++- src/parameters/Parameters.jl | 2 ++ src/parameters/create_parameters.jl | 2 ++ 6 files changed, 15 insertions(+), 7 deletions(-) diff --git a/docs/Manifest.toml b/docs/Manifest.toml index 32ec313d0b4..e63d4e324d8 100644 --- a/docs/Manifest.toml +++ b/docs/Manifest.toml @@ -332,9 +332,9 @@ version = "0.2.2" [[deps.ClimaParams]] deps = ["DocStringExtensions", "TOML", "Test"] -git-tree-sha1 = "8da1dc4aa297847cf74c51168cab1995e5631eeb" +git-tree-sha1 = "0b5afc75bd3aa7c30d76c2d33b8361f961e86237" uuid = "5c42b081-d73a-476f-9059-fd94b934656c" -version = "0.10.7" +version = "0.10.8" [[deps.ClimaTimeSteppers]] deps = ["ClimaComms", "Colors", "DataStructures", "DiffEqBase", "DiffEqCallbacks", "KernelAbstractions", "Krylov", "LinearAlgebra", "LinearOperators", "NVTX", "SciMLBase", "StaticArrays"] diff --git a/examples/Manifest.toml b/examples/Manifest.toml index 8648f0bd80d..4827fcb4123 100644 --- a/examples/Manifest.toml +++ b/examples/Manifest.toml @@ -384,9 +384,9 @@ version = "0.2.2" [[deps.ClimaParams]] deps = ["DocStringExtensions", "TOML", "Test"] -git-tree-sha1 = "8da1dc4aa297847cf74c51168cab1995e5631eeb" +git-tree-sha1 = "0b5afc75bd3aa7c30d76c2d33b8361f961e86237" uuid = "5c42b081-d73a-476f-9059-fd94b934656c" -version = "0.10.7" +version = "0.10.8" [[deps.ClimaTimeSteppers]] deps = ["ClimaComms", "Colors", "DataStructures", "DiffEqBase", "DiffEqCallbacks", "KernelAbstractions", "Krylov", "LinearAlgebra", "LinearOperators", "NVTX", "SciMLBase", "StaticArrays"] diff --git a/perf/Manifest.toml b/perf/Manifest.toml index 657dc647e71..774a4747cfc 100644 --- a/perf/Manifest.toml +++ b/perf/Manifest.toml @@ -395,9 +395,9 @@ version = "0.2.2" [[deps.ClimaParams]] deps = ["DocStringExtensions", "TOML", "Test"] -git-tree-sha1 = "8da1dc4aa297847cf74c51168cab1995e5631eeb" +git-tree-sha1 = "0b5afc75bd3aa7c30d76c2d33b8361f961e86237" uuid = "5c42b081-d73a-476f-9059-fd94b934656c" -version = "0.10.7" +version = "0.10.8" [[deps.ClimaTimeSteppers]] deps = ["ClimaComms", "Colors", "DataStructures", "DiffEqBase", "DiffEqCallbacks", "KernelAbstractions", "Krylov", "LinearAlgebra", "LinearOperators", "NVTX", "SciMLBase", "StaticArrays"] diff --git a/src/callbacks/callbacks.jl b/src/callbacks/callbacks.jl index ce6dc6ca16e..f5c581263da 100644 --- a/src/callbacks/callbacks.jl +++ b/src/callbacks/callbacks.jl @@ -70,6 +70,8 @@ NVTX.@annotate function rrtmgp_model_callback!(integrator) FT = Spaces.undertype(axes(Y.c)) thermo_params = CAP.thermodynamics_params(params) + T_min = CAP.optics_lookup_temperature_min(params) + T_max = CAP.optics_lookup_temperature_max(params) sfc_ts = sfc_conditions.ts sfc_T = @@ -79,7 +81,9 @@ NVTX.@annotate function rrtmgp_model_callback!(integrator) ᶜp = Fields.array2field(radiation_model.center_pressure, axes(Y.c)) ᶜT = Fields.array2field(radiation_model.center_temperature, axes(Y.c)) @. ᶜp = TD.air_pressure(thermo_params, ᶜts) - @. ᶜT = TD.air_temperature(thermo_params, ᶜts) + # TODO: add these to parameters + @. ᶜT = + min(max(TD.air_temperature(thermo_params, ᶜts), FT(T_min)), FT(T_max)) if !(radiation_model.radiation_mode isa RRTMGPI.GrayRadiation) ᶜvmr_h2o = Fields.array2field( diff --git a/src/parameters/Parameters.jl b/src/parameters/Parameters.jl index f32c8b858cf..ccf57fab175 100644 --- a/src/parameters/Parameters.jl +++ b/src/parameters/Parameters.jl @@ -87,6 +87,8 @@ Base.@kwdef struct ClimaAtmosParameters{ # Radiation idealized_ocean_albedo::FT water_refractive_index::FT + optics_lookup_temperature_min::FT + optics_lookup_temperature_max::FT end Base.eltype(::ClimaAtmosParameters{FT}) where {FT} = FT diff --git a/src/parameters/create_parameters.jl b/src/parameters/create_parameters.jl index b3bff9be974..2136717261d 100644 --- a/src/parameters/create_parameters.jl +++ b/src/parameters/create_parameters.jl @@ -124,6 +124,8 @@ function create_parameter_set(config::AtmosConfig) :held_suarez_minimum_temperature => :T_min_hs, :ocean_surface_albedo => :idealized_ocean_albedo, :water_refractive_index => :water_refractive_index, + :optics_lookup_temperature_min => :optics_lookup_temperature_min, + :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}(;