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}(2.4507377808459824e-15,3.051758525442467e-5,3.155745325704466e-15), Dual{Nothing}(3.0517585254595755e-5,7.68306482566931e-15,3.051758525519226e-5)], ForwardDiff.Dual{Nothing, Float64, 2}[Dual{Nothing}(6.099748459217069e-10,3.05175852755265e-5,9.140165266411821e-10), Dual{Nothing}(3.051758527744747e-5,8.324915176758221e-10,3.051758527693929e-5)])), [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ₐ= NaN
Note that all variables are initialized with NaN
s.
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+00
Note that the residuals are still NaN
s 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.