11---
22title: Doyle-Fuller-Newman (DFN) Battery Model Initialization
33author: Marc D. Berliner & Avik Pal
4- priority: 10000
4+ priority: 50000000
55---
66
77These benchmarks compares the runtime and error for a range of nonlinear solvers. The solvers are implemented in [NonlinearProblemLibrary.jl](https://github.com/SciML/DiffEqProblemLibrary.jl/blob/master/lib/NonlinearProblemLibrary/src/NonlinearProblemLibrary.jl), where you can find the problem function declarations. We test the following solvers:
@@ -23,7 +23,7 @@ Fetch required packages.
2323```julia
2424using NonlinearSolve, LinearSolve, StaticArrays, Sundials, SpeedMapping,
2525 BenchmarkTools, LinearAlgebra, DiffEqDevTools, PolyesterForwardDiff, CairoMakie,
26- RecursiveFactorization
26+ RecursiveFactorization, Enzyme
2727import MINPACK, NLsolve, PETSc
2828import LineSearches
2929
@@ -39,38 +39,43 @@ MoreThuente() = LineSearchesJL(; method = LineSearches.MoreThuente())
3939GC.enable(false) # for PETSc
4040
4141solvers_all = [
42- (; pkg = :nonlinearsolve, name = "Default PolyAlgorithm", solver = Dict(:alg => FastShortcutNonlinearPolyalg())),
43- (; pkg = :nonlinearsolve, name = "Newton Raphson", solver = Dict(:alg => NewtonRaphson())),
44- (; pkg = :nonlinearsolve, name = "Newton Raphson (HagerZhang LineSearch)", solver = Dict(:alg => NewtonRaphson(; linesearch = HagerZhang()))),
45- (; pkg = :nonlinearsolve, name = "Newton Raphson (MoreThuente LineSearch)", solver = Dict(:alg => NewtonRaphson(; linesearch = MoreThuente()))),
46- (; pkg = :nonlinearsolve, name = "Newton Raphson (BackTracking LineSearch)", solver = Dict(:alg => NewtonRaphson(; linesearch = BackTracking()))),
47- (; pkg = :nonlinearsolve, name = "Newton Krylov with GMRES", solver = Dict(:alg => NewtonRaphson(; linsolve = KrylovJL_GMRES()))),
42+ (; pkg = :nonlinearsolve, name = "Default PolyAlgorithm", solver = Dict(:alg => FastShortcutNonlinearPolyalg(; autodiff = AutoEnzyme() ))),
43+ (; pkg = :nonlinearsolve, name = "Newton Raphson", solver = Dict(:alg => NewtonRaphson(; autodiff = AutoEnzyme() ))),
44+ (; pkg = :nonlinearsolve, name = "Newton Raphson (HagerZhang LineSearch)", solver = Dict(:alg => NewtonRaphson(; linesearch = HagerZhang(), autodiff = AutoEnzyme() ))),
45+ (; pkg = :nonlinearsolve, name = "Newton Raphson (MoreThuente LineSearch)", solver = Dict(:alg => NewtonRaphson(; linesearch = MoreThuente(), autodiff = AutoEnzyme() ))),
46+ (; pkg = :nonlinearsolve, name = "Newton Raphson (BackTracking LineSearch)", solver = Dict(:alg => NewtonRaphson(; linesearch = BackTracking(), autodiff = AutoEnzyme() ))),
47+ (; pkg = :nonlinearsolve, name = "Newton Krylov with GMRES", solver = Dict(:alg => NewtonRaphson(; linsolve = KrylovJL_GMRES(), autodiff = AutoEnzyme() ))),
4848 (; pkg = :nonlinearsolve, name = "DFSane", solver = Dict(:alg => DFSane())),
49- (; pkg = :nonlinearsolve, name = "Trust Region", solver = Dict(:alg => TrustRegion())),
50- (; pkg = :nonlinearsolve, name = "Trust Region (NLsolve Update)", solver = Dict(:alg => TrustRegion(; radius_update_scheme = RUS.NLsolve))),
51- (; pkg = :nonlinearsolve, name = "Trust Region (Nocedal Wright)", solver = Dict(:alg => TrustRegion(; radius_update_scheme = RUS.NocedalWright))),
52- (; pkg = :nonlinearsolve, name = "Trust Region (Hei)", solver = Dict(:alg => TrustRegion(; radius_update_scheme = RUS.Hei))),
53- (; pkg = :nonlinearsolve, name = "Trust Region (Yuan)", solver = Dict(:alg => TrustRegion(; radius_update_scheme = RUS.Yuan))),
54- (; pkg = :nonlinearsolve, name = "Trust Region (Bastin)", solver = Dict(:alg => TrustRegion(; radius_update_scheme = RUS.Bastin))),
55- (; pkg = :nonlinearsolve, name = "Trust Region (Fan)", solver = Dict(:alg => TrustRegion(; radius_update_scheme = RUS.Fan))),
56- (; pkg = :nonlinearsolve, name = "Levenberg-Marquardt", solver = Dict(:alg => LevenbergMarquardt())),
57- (; pkg = :nonlinearsolve, name = "Levenberg-Marquardt with Cholesky", solver = Dict(:alg => LevenbergMarquardt(; linsolve = CholeskyFactorization()))),
58- (; pkg = :nonlinearsolve, name = "Levenberg-Marquardt (No Geodesic Accln.)", solver = Dict(:alg => LevenbergMarquardt(; disable_geodesic = Val(true)))),
59- (; pkg = :nonlinearsolve, name = "Levenberg-Marquardt (No Geodesic Accln.) with Cholesky", solver = Dict(:alg => LevenbergMarquardt(; disable_geodesic = Val(true), linsolve = CholeskyFactorization()))),
49+ (; pkg = :nonlinearsolve, name = "Trust Region", solver = Dict(:alg => TrustRegion(; autodiff = AutoEnzyme()))),
50+ (; pkg = :nonlinearsolve, name = "Trust Region (NLsolve Update)", solver = Dict(:alg => TrustRegion(; radius_update_scheme = RUS.NLsolve, autodiff = AutoEnzyme()))),
51+ (; pkg = :nonlinearsolve, name = "Trust Region (Nocedal Wright)", solver = Dict(:alg => TrustRegion(; radius_update_scheme = RUS.NocedalWright, autodiff = AutoEnzyme()))),
52+ (; pkg = :nonlinearsolve, name = "Trust Region (Hei)", solver = Dict(:alg => TrustRegion(; radius_update_scheme = RUS.Hei, autodiff = AutoEnzyme()))),
53+ (; pkg = :nonlinearsolve, name = "Trust Region (Yuan)", solver = Dict(:alg => TrustRegion(; radius_update_scheme = RUS.Yuan, autodiff = AutoEnzyme()))),
54+ (; pkg = :nonlinearsolve, name = "Trust Region (Bastin)", solver = Dict(:alg => TrustRegion(; radius_update_scheme = RUS.Bastin, autodiff = AutoEnzyme()))),
55+ (; pkg = :nonlinearsolve, name = "Trust Region (Fan)", solver = Dict(:alg => TrustRegion(; radius_update_scheme = RUS.Fan, autodiff = AutoEnzyme()))),
56+ (; pkg = :nonlinearsolve, name = "Levenberg-Marquardt", solver = Dict(:alg => LevenbergMarquardt(; autodiff = AutoEnzyme()))),
57+ (; pkg = :nonlinearsolve, name = "Levenberg-Marquardt with Cholesky", solver = Dict(:alg => LevenbergMarquardt(; linsolve = CholeskyFactorization(), autodiff = AutoEnzyme()))),
58+ (; pkg = :nonlinearsolve, name = "Levenberg-Marquardt (No Geodesic Accln.)", solver = Dict(:alg => LevenbergMarquardt(; disable_geodesic = Val(true), autodiff = AutoEnzyme()))),
59+ (; pkg = :nonlinearsolve, name = "Levenberg-Marquardt (No Geodesic Accln.) with Cholesky", solver = Dict(:alg => LevenbergMarquardt(; disable_geodesic = Val(true), linsolve = CholeskyFactorization(), autodiff = AutoEnzyme()))),
60+
61+ (; pkg = :wrapper, name = "Newton Raphson [Sundials]", solver = Dict(:alg => KINSOL(; linear_solver = :LapackDense, maxsetupcalls=1))),
62+ (; pkg = :wrapper, name = "Newton Krylov [Sundials]", solver = Dict(:alg => KINSOL(; linear_solver = :GMRES, maxsetupcalls=1))),
63+ (; pkg = :wrapper, name = "Newton Raphson with LineSearch [Sundials]", solver = Dict(:alg => KINSOL(; globalization_strategy = :LineSearch, maxsetupcalls=1))),
64+
65+ (; pkg = :wrapper, name = "Newton Raphson [NLsolve.jl]", solver = Dict(:alg => NLsolveJL(; method = :newton, autodiff = :forward))),
66+ (; pkg = :wrapper, name = "Trust Region [NLsolve.jl]", solver = Dict(:alg => NLsolveJL(; autodiff = :forward))),
67+
68+ (; pkg = :wrapper, name = "Modified Powell [MINPACK]", solver = Dict(:alg => CMINPACK(; method = :hybr))),
69+ (; pkg = :wrapper, name = "Levenberg-Marquardt [MINPACK]", solver = Dict(:alg => CMINPACK(; method = :lm))),
70+
71+ (; pkg = :wrapper, name = "Speed Mapping [SpeedMapping.jl]", solver = Dict(:alg => SpeedMappingJL())),
72+
6073 (; pkg = :wrapper, name = "Newton Raphson [PETSc]", solver = Dict(:alg => PETScSNES(; snes_type = "newtonls", snes_linesearch_type = "basic"))),
6174 (; pkg = :wrapper, name = "Newton Raphson with QR [PETSc]", solver = Dict(:alg => PETScSNES(; snes_type = "newtonls", snes_linesearch_type = "basic", pc_type = "qr"))),
6275 (; pkg = :wrapper, name = "Newton Raphson with BackTracking [PETSc]", solver = Dict(:alg => PETScSNES(; snes_type = "newtonls"))),
6376 (; pkg = :wrapper, name = "Newton Raphson with BackTracking & QR [PETSc]", solver = Dict(:alg => PETScSNES(; snes_type = "newtonls", pc_type = "qr"))),
6477 (; pkg = :wrapper, name = "Trust Region [PETSc]", solver = Dict(:alg => PETScSNES(; snes_type = "newtontr"))),
6578 (; pkg = :wrapper, name = "Newton Krylov with GMRES [PETSc]", solver = Dict(:alg => PETScSNES(; snes_type = "newtonls", snes_linesearch_type = "basic", ksp_type = "gmres"))),
66- (; pkg = :wrapper, name = "Modified Powell [MINPACK]", solver = Dict(:alg => CMINPACK(; method = :hybr))),
67- (; pkg = :wrapper, name = "Levenberg-Marquardt [MINPACK]", solver = Dict(:alg => CMINPACK(; method = :lm))),
68- (; pkg = :wrapper, name = "Newton Raphson [NLsolve.jl]", solver = Dict(:alg => NLsolveJL(; method = :newton, autodiff = :forward))),
69- (; pkg = :wrapper, name = "Trust Region [NLsolve.jl]", solver = Dict(:alg => NLsolveJL(; autodiff = :forward))),
70- (; pkg = :wrapper, name = "Newton Raphson [Sundials]", solver = Dict(:alg => KINSOL(; linear_solver = :LapackDense, maxsetupcalls=1))),
71- (; pkg = :wrapper, name = "Newton Krylov [Sundials]", solver = Dict(:alg => KINSOL(; linear_solver = :GMRES, maxsetupcalls=1))),
72- (; pkg = :wrapper, name = "Newton Raphson with LineSearch [Sundials]", solver = Dict(:alg => KINSOL(; globalization_strategy = :LineSearch, maxsetupcalls=1))),
73- (; pkg = :wrapper, name = "Speed Mapping [SpeedMapping.jl]", solver = Dict(:alg => SpeedMappingJL())),
7479];
7580```
7681
0 commit comments