From 0eeda447485f4da993396954bfe2e5ae2315712c Mon Sep 17 00:00:00 2001 From: Charles Kawczynski Date: Tue, 13 Feb 2024 16:57:57 -0500 Subject: [PATCH 1/2] Use new ClimaParameter Bump minor version --- Project.toml | 2 +- ext/CreateParametersExt.jl | 1 + gpuenv/Project.toml | 2 +- perf/Project.toml | 2 +- src/Parameters.jl | 1 + src/config_numerical_method.jl | 57 ++++++++++++++++++++-------------- src/relations.jl | 11 ++++--- test/Project.toml | 2 +- 8 files changed, 45 insertions(+), 33 deletions(-) diff --git a/Project.toml b/Project.toml index b41bfcf9..54b6e3a5 100644 --- a/Project.toml +++ b/Project.toml @@ -23,4 +23,4 @@ KernelAbstractions = "0.9" Random = "1" RootSolvers = "0.4" julia = "1.6" -CLIMAParameters = "0.8" +CLIMAParameters = "0.9" diff --git a/ext/CreateParametersExt.jl b/ext/CreateParametersExt.jl index 38b05024..d1405531 100644 --- a/ext/CreateParametersExt.jl +++ b/ext/CreateParametersExt.jl @@ -29,6 +29,7 @@ function ThermodynamicsParameters(toml_dict::CP.AbstractTOMLDict) :isobaric_specific_heat_liquid => :cp_l, :latent_heat_vaporization_at_reference => :LH_v0, :temperature_saturation_adjustment_min => :T_min, + :temperature_saturation_adjustment_init_min => :T_init_min, :gas_constant => :gas_constant, :temperature_mean_at_reference => :T_surf_ref, :gravitational_acceleration => :grav, diff --git a/gpuenv/Project.toml b/gpuenv/Project.toml index 9523d868..6ba34545 100644 --- a/gpuenv/Project.toml +++ b/gpuenv/Project.toml @@ -10,7 +10,7 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" Thermodynamics = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c" [compat] -CLIMAParameters = "0.8" +CLIMAParameters = "0.9" CUDA = "3.5, 4, 5" KernelAbstractions = "0.9" RootSolvers = "0.4" diff --git a/perf/Project.toml b/perf/Project.toml index f873269e..dbec6373 100644 --- a/perf/Project.toml +++ b/perf/Project.toml @@ -15,7 +15,7 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" Thermodynamics = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c" [compat] -CLIMAParameters = "0.8" +CLIMAParameters = "0.9" KernelAbstractions = "0.9" RootSolvers = "0.4" julia = "1.7" diff --git a/src/Parameters.jl b/src/Parameters.jl index 19b871bf..86c053d7 100644 --- a/src/Parameters.jl +++ b/src/Parameters.jl @@ -35,6 +35,7 @@ Base.@kwdef struct ThermodynamicsParameters{FT} T_freeze::FT T_min::FT T_max::FT + T_init_min::FT entropy_reference_temperature::FT entropy_dry_air::FT entropy_water_vapor::FT diff --git a/src/config_numerical_method.jl b/src/config_numerical_method.jl index 370ffce2..91479378 100644 --- a/src/config_numerical_method.jl +++ b/src/config_numerical_method.jl @@ -55,9 +55,9 @@ end ::Type{phase_type}, T_guess::Union{FT, Nothing}, ) where {FT, NM <: RS.NewtonsMethod, phase_type <: PhaseEquil} - T_min = TP.T_min(param_set) + T_init_min = TP.T_init_min(param_set) T_init = if T_guess isa Nothing - max(T_min, air_temperature(param_set, e_int, PhasePartition(q_tot))) # Assume all vapor + max(T_init_min, air_temperature(param_set, e_int, PhasePartition(q_tot))) # Assume all vapor else T_guess end @@ -73,9 +73,9 @@ end ::Type{phase_type}, T_guess::FT, ) where {FT, NM <: RS.NewtonsMethodAD, phase_type <: PhaseEquil} - T_min = TP.T_min(param_set) + T_init_min = TP.T_init_min(param_set) T_init = if T_guess isa Nothing - max(T_min, air_temperature(param_set, e_int, PhasePartition(q_tot))) # Assume all vapor + max(T_init_min, air_temperature(param_set, e_int, PhasePartition(q_tot))) # Assume all vapor else T_guess end @@ -91,10 +91,13 @@ end ::Type{phase_type}, T_guess::Union{FT, Nothing}, ) where {FT, NM <: RS.SecantMethod, phase_type <: PhaseEquil} - T_min = TP.T_min(param_set) + T_init_min = TP.T_init_min(param_set) q_pt = PhasePartition(q_tot, FT(0), q_tot) # Assume all ice T_2 = air_temperature(param_set, e_int, q_pt) - T_1 = max(T_min, air_temperature(param_set, e_int, PhasePartition(q_tot))) # Assume all vapor + T_1 = max( + T_init_min, + air_temperature(param_set, e_int, PhasePartition(q_tot)), + ) # Assume all vapor T_2 = bound_upper_temperature(T_1, T_2) return RS.SecantMethod(T_1, T_2) end @@ -108,10 +111,13 @@ end ::Type{phase_type}, T_guess::Union{FT, Nothing}, ) where {FT, NM <: RS.RegulaFalsiMethod, phase_type <: PhaseEquil} - T_min = TP.T_min(param_set) + T_init_min = TP.T_init_min(param_set) q_pt = PhasePartition(q_tot, FT(0), q_tot) # Assume all ice T_2 = air_temperature(param_set, e_int, q_pt) - T_1 = max(T_min, air_temperature(param_set, e_int, PhasePartition(q_tot))) # Assume all vapor + T_1 = max( + T_init_min, + air_temperature(param_set, e_int, PhasePartition(q_tot)), + ) # Assume all vapor T_2 = bound_upper_temperature(T_1, T_2) return RS.RegulaFalsiMethod(T_1, T_2) end @@ -166,9 +172,9 @@ end ::Type{phase_type}, T_guess::Union{FT, Nothing}, ) where {FT, NM <: RS.NewtonsMethodAD, phase_type <: PhaseEquil} - T_min = TP.T_min(param_set) + T_init_min = TP.T_init_min(param_set) T_init = if T_guess isa Nothing - max(T_min, air_temperature(param_set, e_int, PhasePartition(q_tot))) # Assume all vapor + max(T_init_min, air_temperature(param_set, e_int, PhasePartition(q_tot))) # Assume all vapor else T_guess end @@ -184,10 +190,13 @@ end ::Type{phase_type}, T_guess::Union{FT, Nothing}, ) where {FT, NM <: RS.SecantMethod, phase_type <: PhaseEquil} - T_min = TP.T_min(param_set) + T_init_min = TP.T_init_min(param_set) q_pt = PhasePartition(q_tot, FT(0), q_tot) # Assume all ice T_2 = air_temperature(param_set, e_int, q_pt) - T_1 = max(T_min, air_temperature(param_set, e_int, PhasePartition(q_tot))) # Assume all vapor + T_1 = max( + T_init_min, + air_temperature(param_set, e_int, PhasePartition(q_tot)), + ) # Assume all vapor T_2 = bound_upper_temperature(T_1, T_2) return RS.SecantMethod(T_1, T_2) end @@ -205,10 +214,10 @@ end ::Type{phase_type}, T_guess::Union{FT, Nothing}, ) where {FT, NM <: RS.NewtonsMethodAD, phase_type <: PhaseEquil} - T_min = TP.T_min(param_set) + T_init_min = TP.T_init_min(param_set) T_init = if T_guess isa Nothing # Assume all vapor max( - T_min, + T_init_min, air_temperature_from_enthalpy(param_set, h, PhasePartition(q_tot)), ) else @@ -226,11 +235,11 @@ end ::Type{phase_type}, T_guess::Union{FT, Nothing}, ) where {FT, NM <: RS.SecantMethod, phase_type <: PhaseEquil} - T_min = TP.T_min(param_set) + T_init_min = TP.T_init_min(param_set) q_pt = PhasePartition(q_tot, FT(0), q_tot) # Assume all ice T_2 = air_temperature_from_enthalpy(param_set, h, q_pt) T_1 = max( - T_min, + T_init_min, air_temperature_from_enthalpy(param_set, h, PhasePartition(q_tot)), ) # Assume all vapor T_2 = bound_upper_temperature(T_1, T_2) @@ -246,11 +255,11 @@ end ::Type{phase_type}, T_guess::Union{FT, Nothing}, ) where {FT, NM <: RS.RegulaFalsiMethod, phase_type <: PhaseEquil} - T_min = TP.T_min(param_set) + T_init_min = TP.T_init_min(param_set) q_pt = PhasePartition(q_tot, FT(0), q_tot) # Assume all ice T_2 = air_temperature_from_enthalpy(param_set, h, q_pt) T_1 = max( - T_min, + T_init_min, air_temperature_from_enthalpy(param_set, h, PhasePartition(q_tot)), ) # Assume all vapor T_2 = bound_upper_temperature(T_1, T_2) @@ -270,10 +279,10 @@ end ::Type{phase_type}, T_guess::Union{FT, Nothing}, ) where {FT, NM <: RS.RegulaFalsiMethod, phase_type <: PhaseEquil} - _T_min = TP.T_min(param_set) + _T_init_min = TP.T_init_min(param_set) _T_max = TP.T_max(param_set) @inline air_temp(q) = air_temperature_given_pθq(param_set, p, θ_liq_ice, q) - T_1 = max(_T_min, air_temp(PhasePartition(q_tot))) # Assume all vapor + T_1 = max(_T_init_min, air_temp(PhasePartition(q_tot))) # Assume all vapor T_2 = T_1 + 10 T_1 = T_1 - 10 return RS.RegulaFalsiMethod(T_1, T_2) @@ -288,9 +297,9 @@ end ::Type{phase_type}, T_guess::Union{FT, Nothing}, ) where {FT, NM <: RS.SecantMethod, phase_type <: PhaseEquil} - _T_min = TP.T_min(param_set) + _T_init_min = TP.T_init_min(param_set) @inline air_temp(q) = air_temperature_given_pθq(param_set, p, θ_liq_ice, q) - T_1 = max(_T_min, air_temp(PhasePartition(q_tot))) # Assume all vapor + T_1 = max(_T_init_min, air_temp(PhasePartition(q_tot))) # Assume all vapor T_2 = air_temp(PhasePartition(q_tot, FT(0), q_tot)) # Assume all ice T_2 = bound_upper_temperature(T_1, T_2) return RS.SecantMethod(T_1, T_2) @@ -305,10 +314,10 @@ end ::Type{phase_type}, T_guess::Union{FT, Nothing}, ) where {FT, NM <: RS.NewtonsMethodAD, phase_type <: PhaseEquil} - T_min = TP.T_min(param_set) + T_init_min = TP.T_init_min(param_set) @inline air_temp(q) = air_temperature_given_pθq(param_set, p, θ_liq_ice, q) T_init = if T_guess isa Nothing - max(T_min, air_temp(PhasePartition(q_tot))) # Assume all vapor + max(T_init_min, air_temp(PhasePartition(q_tot))) # Assume all vapor else T_guess end diff --git a/src/relations.jl b/src/relations.jl index 11d078ed..067d3a98 100644 --- a/src/relations.jl +++ b/src/relations.jl @@ -2044,6 +2044,7 @@ See also [`saturation_adjustment`](@ref). T_guess::Union{FT, Nothing} = nothing, ) where {FT <: Real, phase_type <: PhaseEquil} _T_min = TP.T_min(param_set) + T_init_min = TP.T_init_min(param_set) @inline air_temp(q) = air_temperature_given_ρθq(param_set, ρ, θ_liq_ice, q) T_1 = max(_T_min, air_temp(PhasePartition(q_tot))) # Assume all vapor q_v_sat = q_vap_saturation(param_set, T_1, ρ, phase_type) @@ -2058,7 +2059,7 @@ See also [`saturation_adjustment`](@ref). θ_liq_ice sol = RS.find_zero( roots, - RS.SecantMethod(T_1, T_2), + RS.SecantMethod(T_init_min, T_2), RS.CompactSolution(), tol, maxiter, @@ -2368,13 +2369,13 @@ The air temperature and `q_tot` where tol::RS.AbstractTolerance = RS.ResidualTolerance{FT}(sqrt(eps(FT))), ) where {FT <: Real, phase_type <: ThermodynamicState} - _T_min = TP.T_min(param_set) + T_init_min = TP.T_init_min(param_set) _T_max = T_virt @inline roots(T) = T_virt - virt_temp_from_RH(param_set, heavisided(T), ρ, RH, phase_type) sol = RS.find_zero( roots, - RS.SecantMethod(_T_min, _T_max), + RS.SecantMethod(T_init_min, _T_max), RS.CompactSolution(), tol, maxiter, @@ -2464,7 +2465,7 @@ by finding the root of tol::RS.AbstractTolerance, q::PhasePartition{FT} = q_pt_0(FT), ) where {FT <: Real} - _T_min = TP.T_min(param_set) + T_init_min = TP.T_init_min(param_set) _T_max = TP.T_max(param_set) @inline roots(T) = T - air_temperature_given_pθq( @@ -2475,7 +2476,7 @@ by finding the root of ) sol = RS.find_zero( roots, - RS.SecantMethod(_T_min, _T_max), + RS.SecantMethod(T_init_min, _T_max), RS.CompactSolution(), tol, maxiter, diff --git a/test/Project.toml b/test/Project.toml index d889c0f3..cb6dbcdd 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -18,7 +18,7 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" Thermodynamics = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c" [compat] -CLIMAParameters = "0.8" +CLIMAParameters = "0.9" KernelAbstractions = "0.9" RootSolvers = "0.4" julia = "1.7" From 3fa7fd6754c7e48f28baf89138f9623e1c847c6d Mon Sep 17 00:00:00 2001 From: Charles Kawczynski Date: Tue, 13 Feb 2024 17:11:04 -0500 Subject: [PATCH 2/2] Bump patch version --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 54b6e3a5..69f11db7 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Thermodynamics" uuid = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c" authors = ["Climate Modeling Alliance"] -version = "0.11.7" +version = "0.12.0" [deps] DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"