Solver Status
In SimpleSolvers we can use the SimpleSolvers.NonlinearSolverStatus to provide a diagnostic tool for a NonlinearSolver. We first make an instance of NonlinearSystem:
x = [3., 1.3]
f = x -> tanh.(x)
F!(y, x, params) = y .= f(x)
nls = NonlinearSystem(F!, x, f(x))NonlinearSystem{Float64, false, typeof(Main.F!), JacobianAutodiff{Float64, typeof(Main.F!), ForwardDiff.JacobianConfig{Nothing, Float64, 2, Tuple{Vector{ForwardDiff.Dual{Nothing, Float64, 2}}, Vector{ForwardDiff.Dual{Nothing, Float64, 2}}}}, Vector{Float64}}, Vector{Float64}, Vector{Float64}, Matrix{Float64}}(Main.F!, JacobianAutodiff{Float64, typeof(Main.F!), ForwardDiff.JacobianConfig{Nothing, Float64, 2, Tuple{Vector{ForwardDiff.Dual{Nothing, Float64, 2}}, Vector{ForwardDiff.Dual{Nothing, Float64, 2}}}}, Vector{Float64}}(Main.F!, ForwardDiff.JacobianConfig{Nothing, Float64, 2, Tuple{Vector{ForwardDiff.Dual{Nothing, Float64, 2}}, Vector{ForwardDiff.Dual{Nothing, Float64, 2}}}}((Partials(1.0, 0.0), Partials(0.0, 1.0)), (ForwardDiff.Dual{Nothing, Float64, 2}[Dual{Nothing}(3.0e-323,6.92130056830806e-310,6.92130056830964e-310), Dual{Nothing}(6.9213005683128e-310,6.92130056831596e-310,6.9213005675871e-310)], ForwardDiff.Dual{Nothing, Float64, 2}[Dual{Nothing}(5.0e-324,5.0e-324,0.0), Dual{Nothing}(0.0,6.9213585885048e-310,6.921362325732e-310)])), [0.0, 0.0]), [NaN, NaN], [NaN NaN; NaN NaN], [NaN, NaN], [NaN, NaN], 0, 0)We now create an instance of NewtonSolver which also allocates a SimpleSolvers.NonlinearSolverStatus:
solver = NewtonSolver(x, f(x); F = F!)i= 0,
x= NaN,
f= NaN,
rxₐ= NaN,
rfₐ= NaNNote that all variables are initialized with NaNs.
For the first step we therefore have to call update![1]:
params = nothing
update!(solver, x, params)i= 0,
x=3.000000e+00,
f=9.950548e-01,
rxₐ= NaN,
rfₐ=1.316321e+00Note that the residuals are still NaNs however as we need to perform at least two updates in order to compute them. As a next step we write:
x = [2., 1.2]
update!(solver, x, params)i= 0,
x=2.000000e+00,
f=9.640276e-01,
rxₐ=1.004988e+00,
rfₐ=1.274492e+00- 1Also see the page on the
update!function.