Skip to content

Commit

Permalink
clean up temperature tolerance
Browse files Browse the repository at this point in the history
  • Loading branch information
szy21 committed Jul 19, 2024
1 parent 245f5d8 commit 77d116f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
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

0 comments on commit 77d116f

Please sign in to comment.