From 6f8ec27fcc05332bea870da700185d105c052897 Mon Sep 17 00:00:00 2001 From: Charles Kawczynski Date: Thu, 15 Sep 2022 16:17:18 -0700 Subject: [PATCH] WIP --- src/relations.jl | 6 +++++- test/relations.jl | 21 ++++++++++++--------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/relations.jl b/src/relations.jl index 695a2567..15c98424 100644 --- a/src/relations.jl +++ b/src/relations.jl @@ -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) diff --git a/test/relations.jl b/test/relations.jl index 8f2844d9..025a90f2 100644 --- a/test/relations.jl +++ b/test/relations.jl @@ -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)