@@ -31,13 +31,14 @@ Note that this presolver implementation is **only valid when all other freeze cu
3131"""
3232mutable 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
4243end
4344function _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