Skip to content
Snippets Groups Projects
Commit ae784c35 authored by Brian Groenke's avatar Brian Groenke
Browse files

Use NLsolve solver for interpolant

parent 6092571e
No related branches found
No related tags found
No related merge requests found
......@@ -157,13 +157,12 @@ function CryoGrid.initialcondition!(soil::Soil{<:HomogeneousCharacteristicFracti
C(θw) = heatcapacity(soil, heat, θw, θtot-θw, θa, θm, θo),
Hmin = enthalpy(Tmin, C(f(Tmin)), L, f(Tmin)),
Hmax = enthalpy(Tmax, C(f(Tmax)), L, f(Tmax));
sfccsolver = SFCCNewtonSolver(abstol=sfcc.solver.errtol, reltol=sfcc.solver.errtol, maxiter=100)
# residual as a function of T and H
resid(T,H) = sfccresidual(soil, heat, sfcc.f, args, C, T, H)
function solve(H,T₀)
opt = sfccsolve(sfccsolver, soil, heat, sfcc.f, args, C, H, T₀)
@assert opt.T_converged "solver failed to converge after $(opt.itercount) iterations: H=$H, T₀=$T₀, T=$(opt.T), Tres=$(opt.Tres), θw=$(opt.θw)"
return opt
local T = nlsolve(T -> resid(T[1],H)[1], [T₀]).zero[1]
θw = f(T)
return (; T, θw)
end
function deriv(T) # implicit partial derivative w.r.t H as a function of T
θw, ∂θ∂T = (f, T)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment