Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
charleskawczynski committed Sep 15, 2022
1 parent 32bd292 commit 6f8ec27
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
6 changes: 5 additions & 1 deletion src/relations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1455,7 +1455,11 @@ function saturation_adjustment(
_T_min::FT = TP.T_min(param_set)
cv_d::FT = TP.cv_d(param_set)
# Convert temperature tolerance to a convergence criterion on internal energy residuals
tol = RS.ResidualTolerance(temperature_tol * cv_d)
# LH_v0 = TP.LH_v0(param_set)
# tol = RS.ResidualTolerance(temperature_tol * cv_d + LH_v0 * q_tot)
# LH_v0 = TP.LH_v0(param_set)
# tol = RS.ResidualTolerance(temperature_tol * cv_d + LH_v0 * q_tot/(1000))
tol = RS.SolutionTolerance(temperature_tol)

T_1 = max(_T_min, air_temperature(param_set, e_int, PhasePartition(q_tot))) # Assume all vapor
q_v_sat = q_vap_saturation(param_set, T_1, ρ, phase_type)
Expand Down
21 changes: 12 additions & 9 deletions test/relations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1632,34 +1632,37 @@ end
8,
FT(1e-1),
RS.NewtonsMethod,
T .+ (FT(0.5) .- rand(FT, length(T))),
T .+ (FT(0.2) .* randn(FT, length(T))),
)
end

Thermodynamics.error_on_non_convergence() = false
Thermodynamics.print_warning() = false
# Thermodynamics.error_on_non_convergence() = false
# Thermodynamics.print_warning() = false
Random.seed!(1234)
@testset "Thermodynamics - desired settings" begin
ArrayType = Array{Float64}
FT = eltype(ArrayType)
param_set = parameter_set(FT)
profiles = TestedProfiles.PhaseEquilProfiles(param_set, ArrayType)
@unpack ρ, e_int, q_tot, T, phase_type = profiles
# provide an initial guess +/- std of 0.3 K from true solution
T_guess = T .+ (FT(0.3) .* randn(FT, length(T)))
@show maximum(abs.(T .- T_guess))
ts =
PhaseEquil_ρeq.(
param_set,
ρ,
e_int,
q_tot,
2,
FT(1e-1),
8,
FT(0.05),
RS.NewtonsMethod,
T .+ (FT(0.5) .- rand(FT, length(T))), # provide an initial guess +/- 0.5 K from true solution
# T_guess,
)
# max error: 0.39158966143736507
@show maximum(abs.(T .- TD.air_temperature.(param_set, ts)))
end
Thermodynamics.error_on_non_convergence() = true
Thermodynamics.print_warning() = true
# Thermodynamics.error_on_non_convergence() = true
# Thermodynamics.print_warning() = true

rm(joinpath(@__DIR__, "logfilepath_Float32.toml"); force = true)
rm(joinpath(@__DIR__, "logfilepath_Float64.toml"); force = true)

0 comments on commit 6f8ec27

Please sign in to comment.