Skip to content

Commit d0e94d1

Browse files
committed
feat: add PETSc to battery
1 parent aca9f6d commit d0e94d1

File tree

5 files changed

+22
-7
lines changed

5 files changed

+22
-7
lines changed

benchmarks/NonlinearProblem/bruss.jmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: Ill-Conditioned Nonlinear System Work-Precision Diagrams
33
author: Avik Pal
4+
priority: 10
45
---
56

67
# Setup

benchmarks/NonlinearProblem/nonlinear_battery_problem.jmd

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: Doyle-Fuller-Newman (DFN) Battery Model Initialization
33
author: Marc D. Berliner & Avik Pal
4+
priority: 10000
45
---
56

67
These 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 +24,7 @@ Fetch required packages.
2324
using NonlinearSolve, LinearSolve, StaticArrays, Sundials, SpeedMapping,
2425
BenchmarkTools, LinearAlgebra, DiffEqDevTools, PolyesterForwardDiff, CairoMakie,
2526
RecursiveFactorization
26-
import MINPACK, NLsolve
27+
import MINPACK, NLsolve, PETSc
2728
import LineSearches
2829

2930
const RUS = RadiusUpdateSchemes;
@@ -35,7 +36,8 @@ Declare the benchmarked solvers (and their names and plotting options).
3536
HagerZhang() = LineSearchesJL(; method = LineSearches.HagerZhang())
3637
MoreThuente() = LineSearchesJL(; method = LineSearches.MoreThuente())
3738

38-
# XXX: Add PETSc
39+
GC.enable(false) # for PETSc
40+
3941
solvers_all = [
4042
(; pkg = :nonlinearsolve, name = "Default PolyAlgorithm", solver = Dict(:alg => FastShortcutNonlinearPolyalg())),
4143
(; pkg = :nonlinearsolve, name = "Newton Raphson", solver = Dict(:alg => NewtonRaphson())),
@@ -55,14 +57,17 @@ solvers_all = [
5557
(; pkg = :nonlinearsolve, name = "Levenberg-Marquardt with Cholesky", solver = Dict(:alg => LevenbergMarquardt(; linsolve = CholeskyFactorization()))),
5658
(; pkg = :nonlinearsolve, name = "Levenberg-Marquardt (No Geodesic Accln.)", solver = Dict(:alg => LevenbergMarquardt(; disable_geodesic = Val(true)))),
5759
(; 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 with BackTracking [PETSc]", solver = Dict(:alg => PETScSNES(; snes_type = "newtonls"))),
61+
(; 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"))),
5863
(; pkg = :wrapper, name = "Modified Powell [MINPACK]", solver = Dict(:alg => CMINPACK(; method = :hybr))),
5964
(; pkg = :wrapper, name = "Levenberg-Marquardt [MINPACK]", solver = Dict(:alg => CMINPACK(; method = :lm))),
6065
(; pkg = :wrapper, name = "Newton Raphson [NLsolve.jl]", solver = Dict(:alg => NLsolveJL(; method = :newton, autodiff = :forward))),
6166
(; pkg = :wrapper, name = "Trust Region [NLsolve.jl]", solver = Dict(:alg => NLsolveJL(; autodiff = :forward))),
6267
(; pkg = :wrapper, name = "Mod. Newton Raphson [Sundials]", solver = Dict(:alg => KINSOL())),
6368
(; pkg = :wrapper, name = "Newton Krylov [Sundials]", solver = Dict(:alg => KINSOL(; linear_solver = :GMRES))),
6469
(; pkg = :wrapper, name = "Newton Raphson with LineSearch [Sundials]", solver = Dict(:alg => KINSOL(; globalization_strategy = :LineSearch))),
65-
(; pkg = :wrapper, name = "Speed Mapping [SpeedMapping.jl]", solver = Dict(:alg => SpeedMappingJL()))
70+
(; pkg = :wrapper, name = "Speed Mapping [SpeedMapping.jl]", solver = Dict(:alg => SpeedMappingJL())),
6671
];
6772
```
6873

@@ -265,7 +270,7 @@ fig = begin
265270

266271
idxs = sortperm(median.(getfield.(wp_set.wps, :times)))
267272

268-
with_theme(plot_theme) do
273+
with_theme(plot_theme) do
269274
fig = Figure(; size = (WIDTH, HEIGHT))
270275
# `textbf` doesn't work
271276
ax = Axis(fig[1, 1], ylabel = L"Time $\mathbf{(s)}$",

benchmarks/NonlinearProblem/nonlinear_solver_23_tests.jmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: Nonlinear Solver 23 Test Problems
33
author: Torkel Loman & Avik Pal
4+
priority: 1000
45
---
56

67
These benchmarks compares the runtime and error for a range of nonlinear solvers. The problems are a standard set of problems as described [here](https://people.sc.fsu.edu/~jburkardt/m_src/test_nonlin/test_nonlin.html). 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. For each problem we test the following solvers:

benchmarks/NonlinearProblem/quadratic_nonlinear.jmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: Quadratic Nonlinear Rootfinding Benchmark
33
author: Avik Pal
4+
priority: 1
45
---
56

67
This is a test of a simple small nonlinear rootfinding problem.

src/SciMLBenchmarks.jl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,19 @@ function weave_all(build_list=(:script,:github))
6868
end
6969

7070
function weave_folder(folder, build_list=(:script,:github))
71+
weave_files = String[]
72+
priorities = Int[]
7173
for file in readdir(folder)
7274
# Skip non-`.jmd` files
73-
if !endswith(file, ".jmd")
74-
continue
75-
end
75+
endswith(file, ".jmd") || continue
76+
push!(weave_files, file)
77+
weave_doc = Weave.WeaveDoc(joinpath(folder, file))
78+
push!(priorities, get(weave_doc.header, "priority", 0))
79+
end
80+
81+
weave_files = weave_files[sortperm(priorities; rev=true)]
7682

83+
for file in weave_files
7784
try
7885
@eval @subprocess begin
7986
using SciMLBenchmarks

0 commit comments

Comments
 (0)