Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change temperature tolerance of all PhaseEquil constructor to 1e-4 #222

Merged
merged 1 commit into from
Jul 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Thermodynamics.jl Release Notes
========================

main
-------
- ![][badge-🤖precisionΔ] Change the tolerance of PhaseEquil constructor to 1e-4

v0.12.7
-------
- ![][badge-🔥behavioralΔ] Change the upper limit of saturation specific humidity

v0.12.4
-------
- Upgraded to use ClimaParams.jl
Expand Down
2 changes: 1 addition & 1 deletion src/relations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1925,7 +1925,7 @@ See also [`saturation_adjustment`](@ref).
q_tot::FT,
::Type{phase_type},
maxiter::Int,
relative_temperature_tol::Real = sqrt(eps(FT)),
relative_temperature_tol::Real,
T_guess::Union{FT, Nothing} = nothing,
) where {FT <: Real, sat_adjust_method, phase_type <: PhaseEquil}
tol = RS.RelativeSolutionTolerance(relative_temperature_tol)
Expand Down
20 changes: 10 additions & 10 deletions src/states.jl
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,6 @@ end
Base.convert(::Type{PhaseEquil{FT}}, ts::PhaseEquil) where {FT} =
PhaseEquil{FT}(ts.ρ, ts.p, ts.e_int, ts.q_tot, ts.T)

@inline ifnothing(x, y) = x
@inline ifnothing(x::Nothing, y) = y

"""
PhaseEquil_ρeq(param_set, ρ, e_int, q_tot[, maxiter, relative_temperature_tol, sat_adjust_method, T_guess])

Expand All @@ -333,8 +330,9 @@ and, optionally
::Type{sat_adjust_method} = RS.NewtonsMethod,
T_guess::Union{FT, Nothing} = nothing,
) where {FT <: Real, sat_adjust_method, IT <: ITERTYPE, TT <: TOLTYPE}
maxiter = ifnothing(maxiter, 8)
relative_temperature_tol = ifnothing(relative_temperature_tol, FT(1e-4))
maxiter === nothing && (maxiter = 8)
relative_temperature_tol === nothing &&
(relative_temperature_tol = FT(1e-4))
phase_type = PhaseEquil{FT}
q_tot_safe = clamp(q_tot, FT(0), FT(1))
T = saturation_adjustment(
Expand Down Expand Up @@ -403,7 +401,7 @@ Constructs a [`PhaseEquil`](@ref) thermodynamic state from:
) where {FT <: Real, IT <: ITERTYPE, TT <: TOLTYPE}
maxiter === nothing && (maxiter = 36)
relative_temperature_tol === nothing &&
(relative_temperature_tol = FT(1e-5))
(relative_temperature_tol = FT(1e-4))
phase_type = PhaseEquil{FT}
tol = RS.RelativeSolutionTolerance(relative_temperature_tol)
T = saturation_adjustment_given_ρθq(
Expand Down Expand Up @@ -590,12 +588,14 @@ TODO: change input argument order: perform_sat_adjust is
p::FT,
q_tot::FT,
perform_sat_adjust = false,
maxiter::Int = 5,
relative_temperature_tol::Real = FT(sqrt(eps(FT))),
maxiter::IT = nothing,
relative_temperature_tol::TT = nothing,
::Type{sat_adjust_method} = RS.NewtonsMethodAD,
T_guess::Union{FT, Nothing} = nothing,
) where {FT <: Real, sat_adjust_method}

) where {FT <: Real, sat_adjust_method, IT <: ITERTYPE, TT <: TOLTYPE}
maxiter === nothing && (maxiter = 5)
relative_temperature_tol === nothing &&
(relative_temperature_tol = FT(1e-4))
phase_type = PhaseEquil{FT}
if perform_sat_adjust
T = saturation_adjustment_ρpq(
Expand Down
Loading