@@ -57,9 +57,10 @@ solvers_all = [
5757 (; pkg = :nonlinearsolve, name = "Levenberg-Marquardt with Cholesky", solver = Dict(:alg => LevenbergMarquardt(; linsolve = CholeskyFactorization()))),
5858 (; pkg = :nonlinearsolve, name = "Levenberg-Marquardt (No Geodesic Accln.)", solver = Dict(:alg => LevenbergMarquardt(; disable_geodesic = Val(true)))),
5959 (; pkg = :nonlinearsolve, name = "Levenberg-Marquardt (No Geodesic Accln.) with Cholesky", solver = Dict(:alg => LevenbergMarquardt(; disable_geodesic = Val(true), linsolve = CholeskyFactorization()))),
60+ (; pkg = :wrapper, name = "Newton Raphson [PETSc]", solver = Dict(:alg => PETScSNES(; snes_type = "newtonls", snes_linesearch_type = "basic"))),
6061 (; pkg = :wrapper, name = "Newton Raphson with BackTracking [PETSc]", solver = Dict(:alg => PETScSNES(; snes_type = "newtonls"))),
6162 (; pkg = :wrapper, name = "Trust Region [PETSc]", solver = Dict(:alg => PETScSNES(; snes_type = "newtontr"))),
62- (; pkg = :wrapper, name = "Nonlinear GMRES [PETSc]", solver = Dict(:alg => PETScSNES(; snes_type = "ngmres "))),
63+ (; pkg = :wrapper, name = "Newton Krylov with GMRES [PETSc]", solver = Dict(:alg => PETScSNES(; snes_type = "newtonls", snes_linesearch_type = "basic", ksp_type = "gmres "))),
6364 (; pkg = :wrapper, name = "Modified Powell [MINPACK]", solver = Dict(:alg => CMINPACK(; method = :hybr))),
6465 (; pkg = :wrapper, name = "Levenberg-Marquardt [MINPACK]", solver = Dict(:alg => CMINPACK(; method = :lm))),
6566 (; pkg = :wrapper, name = "Newton Raphson [NLsolve.jl]", solver = Dict(:alg => NLsolveJL(; method = :newton, autodiff = :forward))),
@@ -205,28 +206,42 @@ reltols = 1.0 ./ 10.0 .^ (3:0.5:6);
205206Prepares various helper functions for benchmarking a specific problem.
206207
207208```julia
209+ function log_msg(msg; kwargs...)
210+ if startswith(msg, "[Info]")
211+ @info msg
212+ elseif startswith(msg, "[Warn]")
213+ @warn msg
214+ elseif startswith(msg, "[Error]")
215+ @error msg
216+ else
217+ @info msg
218+ end
219+ Base.printstyled(msg; kwargs...)
220+ return
221+ end
222+
208223function check_solver(prob, solver)
209224 try
210225 sol = solve(prob.prob, solver.solver[:alg]; abstol = 1e-4, reltol = 1e-4,
211226 maxiters = 10000)
212227 err = norm(sol.resid, Inf)
213228 if !SciMLBase.successful_retcode(sol.retcode)
214- Base.printstyled ("[Warn] Solver $(solver.name) returned retcode $(sol.retcode) with an residual norm = $(norm(sol.resid)).\n";
229+ log_msg ("[Warn] Solver $(solver.name) returned retcode $(sol.retcode) with an residual norm = $(norm(sol.resid)).\n";
215230 color = :red)
216231 return false
217232 elseif err > 1e3
218- Base.printstyled ("[Warn] Solver $(solver.name) had a very large residual (norm = $(norm(sol.resid))).\n";
233+ log_msg ("[Warn] Solver $(solver.name) had a very large residual (norm = $(norm(sol.resid))).\n";
219234 color = :red)
220235 return false
221236 elseif isinf(err) || isnan(err)
222- Base.printstyled ("[Warn] Solver $(solver.name) had a residual of $(err).\n";
237+ log_msg ("[Warn] Solver $(solver.name) had a residual of $(err).\n";
223238 color = :red)
224239 return false
225240 end
226- Base.printstyled ("[Info] Solver $(solver.name) successfully solved the problem (norm = $(norm(sol.resid))).\n";
241+ log_msg ("[Info] Solver $(solver.name) successfully solved the problem (norm = $(norm(sol.resid))).\n";
227242 color = :green)
228243 catch e
229- Base.printstyled ("[Warn] Solver $(solver.name) threw an error: $e.\n"; color = :red)
244+ log_msg ("[Warn] Solver $(solver.name) threw an error: $e.\n"; color = :red)
230245 return false
231246 end
232247 return true
0 commit comments