Skip to content

Commit 3695e16

Browse files
committed
Fix presolver 1D not handling saturation parameter
1 parent a847efc commit 3695e16

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "FreezeCurves"
22
uuid = "71e4ad71-e4f2-45a3-aa0a-91ffaa9676be"
33
authors = ["Brian Groenke <[email protected]> and contributors"]
4-
version = "0.9.1"
4+
version = "0.9.2"
55

66
[deps]
77
Flatten = "4c728ea3-d9ee-5c9a-9642-b6f7d7dc04fa"

src/sfccsolvers/presolver.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@ Note that this presolver implementation is **only valid when all other freeze cu
3131
"""
3232
mutable struct SFCCPreSolverCache1D{TF} <: AbstractPreSolverCache
3333
f_H::TF # θw(H) interpolant
34+
ΔH_min::Float64
3435
initialized::Bool
35-
function SFCCPreSolverCache1D()
36+
function SFCCPreSolverCache1D(ΔH_min=1e-3)
3637
# initialize with dummy functions to get type information;
3738
# this is just to make sure that the compiler can still infer all of the types.
3839
x = -3e8:1e6:3e8
3940
dummy_f = _build_interpolant1D(x, zeros(length(x)))
40-
return new{typeof(dummy_f)}(dummy_f, false)
41+
return new{typeof(dummy_f)}(dummy_f, ΔH_min, false)
4142
end
4243
end
4344
function _build_interpolant1D(H, θw)
@@ -67,7 +68,7 @@ function initialize!(solver::SFCCPreSolver{<:SFCCPreSolverCache1D}, fc::SFCC, hc
6768
ρw = SoilWaterVolume(fc).ρw,
6869
L = ρw*Lsl,
6970
f_kwargs = (; θsat, fc_kwargs...),
70-
f(T) = fc(T; f_kwargs...),
71+
f(T) = fc(T, sat; f_kwargs...),
7172
Hmin = FreezeCurves.enthalpy(Tmin, hc(f(Tmin), sat*θsat, θsat), L, f(Tmin)),
7273
Hmax = FreezeCurves.enthalpy(Tmax, hc(f(Tmax), sat*θsat, θsat), L, f(Tmax));
7374
# residual as a function of T and H
@@ -107,6 +108,10 @@ function initialize!(solver::SFCCPreSolver{<:SFCCPreSolverCache1D}, fc::SFCC, hc
107108
ϵ = step(ΔH, H[end], θw[end], ∂θw∂H[end], T[end])
108109
# iteratively halve the step size until error tolerance is satisfied
109110
ΔH *= 0.5
111+
if ΔH < solver.cache.ΔH_min
112+
@warn "ΔH ($ΔH) < ΔH_min ($(solver.cache.ΔH_min))! SFCC approximation tolerance not guaranteed (ϵ = )"
113+
break
114+
end
110115
end
111116
Hnew = H[end] + ΔH
112117
@assert isfinite(Hnew) "isfinite(ΔH) failed; H=$(H[end]), T=$(T[end]), ΔH=$ΔH"

0 commit comments

Comments
 (0)