Skip to content

Commit 7b59b31

Browse files
committed
fix: adjust krylov_dims
1 parent 1355ba9 commit 7b59b31

File tree

3 files changed

+27
-26
lines changed

3 files changed

+27
-26
lines changed

benchmarks/NonlinearProblem/bruss.jmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,13 +553,13 @@ solvers_all = [
553553
(; pkg = :wrapper, name = "TR [NLsolve.jl]", solver = Dict(:alg => NLsolveJL(; autodiff = :forward))),
554554

555555
(; pkg = :wrapper, name = "NR [Sundials]", solver = Dict(:alg => KINSOL(; linear_solver = :LapackDense, maxsetupcalls=1))),
556-
(; pkg = :wrapper, name = "Newton Krylov [Sundials]", solver = Dict(:alg => KINSOL(; linear_solver = :GMRES, maxsetupcalls=1))),
556+
(; pkg = :wrapper, name = "Newton Krylov [Sundials]", solver = Dict(:alg => KINSOL(; linear_solver = :GMRES, maxsetupcalls=1, krylov_dim = 1000))),
557557

558558
(; pkg = :wrapper, name = "Mod. Powell [MINPACK]", solver = Dict(:alg => CMINPACK())),
559559

560560
(; pkg = :wrapper, name = "NR [PETSc]", solver = Dict(:alg => PETScSNES(; snes_type = "newtonls", snes_linesearch_type = "basic", autodiff = missing))),
561561
(; pkg = :wrapper, name = "TR [PETSc]", solver = Dict(:alg => PETScSNES(; snes_type = "newtontr", autodiff = missing))),
562-
(; pkg = :wrapper, name = "Newton Krylov [PETSc]", solver = Dict(:alg => PETScSNES(; snes_type = "newtonls", snes_linesearch_type = "basic", ksp_type = "gmres", autodiff = missing, snes_mf = true))),
562+
(; pkg = :wrapper, name = "Newton Krylov [PETSc]", solver = Dict(:alg => PETScSNES(; snes_type = "newtonls", snes_linesearch_type = "basic", ksp_type = "gmres", autodiff = missing, snes_mf = true, ksp_gmres_restart = 1000))),
563563
];
564564
```
565565

benchmarks/NonlinearProblem/bruss_krylov.jmd

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -152,29 +152,30 @@ function algebraicmultigrid_jacobi(W, p = nothing)
152152
end
153153

154154
Ns = 2 .^ (2:7)
155+
krylov_dim = 1000
155156

156157
solvers_scaling_jacobian_free = [
157-
(; pkg = :nonlinearsolve, name = "Newton Krylov", alg = NewtonRaphson(; linsolve = KrylovJL_GMRES(; gmres_restart = 50))),
158-
(; pkg = :nonlinearsolve, name = "Newton Krylov (ILU)", alg = NewtonRaphson(; linsolve = KrylovJL_GMRES(; gmres_restart = 50, precs = incompletelu), concrete_jac = true)),
159-
(; pkg = :nonlinearsolve, name = "Newton Krylov (AMG)", alg = NewtonRaphson(; linsolve = KrylovJL_GMRES(; gmres_restart = 50, precs = algebraicmultigrid), concrete_jac = true)),
160-
(; pkg = :nonlinearsolve, name = "Newton Krylov (AMG Jacobi)", alg = NewtonRaphson(; linsolve = KrylovJL_GMRES(; gmres_restart = 50, precs = algebraicmultigrid_jacobi), concrete_jac = true)),
161-
162-
(; pkg = :nonlinearsolve, name = "TR Krylov", alg = TrustRegion(; linsolve = KrylovJL_GMRES(; gmres_restart = 50))),
163-
(; pkg = :nonlinearsolve, name = "TR Krylov (ILU)", alg = TrustRegion(; linsolve = KrylovJL_GMRES(; gmres_restart = 50, precs = incompletelu), concrete_jac = true)),
164-
(; pkg = :nonlinearsolve, name = "TR Krylov (AMG)", alg = TrustRegion(; linsolve = KrylovJL_GMRES(; gmres_restart = 50, precs = algebraicmultigrid), concrete_jac = true)),
165-
(; pkg = :nonlinearsolve, name = "TR Krylov (AMG Jacobi)", alg = TrustRegion(; linsolve = KrylovJL_GMRES(; gmres_restart = 50, precs = algebraicmultigrid_jacobi), concrete_jac = true)),
166-
167-
(; pkg = :wrapper, name = "Newton Krylov [Sundials]", alg = KINSOL(; linear_solver = :GMRES, maxsetupcalls=1, krylov_dim=50)),
168-
169-
(; pkg = :wrapper, name = "Newton Krylov [PETSc]", alg = PETScSNES(; snes_type = "newtonls", snes_linesearch_type = "basic", ksp_type = "gmres", snes_mf = true, ksp_gmres_restart = 50)),
170-
(; pkg = :wrapper, name = "Newton Krylov (ILU) [PETSc]", alg = PETScSNES(; snes_type = "newtonls", snes_linesearch_type = "basic", ksp_type = "gmres", pc_type = "ilu", ksp_gmres_restart = 50, pc_factor_levels = 0, pc_factor_drop_tolerance = 50.0)),
171-
(; pkg = :wrapper, name = "Newton Krylov (AMG) [PETSc]", alg = PETScSNES(; snes_type = "newtonls", snes_linesearch_type = "basic", ksp_type = "gmres", pc_type = "gamg", ksp_gmres_restart = 50)),
172-
(; pkg = :wrapper, name = "Newton Krylov (AMG Jacobi) [PETSc]", alg = PETScSNES(; snes_type = "newtonls", snes_linesearch_type = "basic", ksp_type = "gmres", pc_type = "gamg", mg_levels_ksp_type = "richardson", mg_levels_pc_type = "jacobi", ksp_gmres_restart = 50)),
173-
174-
(; pkg = :wrapper, name = "TR Krylov (Not Matrix Free) [PETSc]", alg = PETScSNES(; snes_type = "newtontr", ksp_type = "gmres", ksp_gmres_restart = 50)),
175-
(; pkg = :wrapper, name = "TR Krylov (ILU) [PETSc]", alg = PETScSNES(; snes_type = "newtontr", ksp_type = "gmres", pc_type = "ilu", ksp_gmres_restart = 50, pc_factor_levels = 0, pc_factor_drop_tolerance = 50.0)),
176-
(; pkg = :wrapper, name = "TR Krylov (AMG) [PETSc]", alg = PETScSNES(; snes_type = "newtontr", ksp_type = "gmres", pc_type = "gamg", ksp_gmres_restart = 50)),
177-
(; pkg = :wrapper, name = "TR Krylov (AMG Jacobi) [PETSc]", alg = PETScSNES(; snes_type = "newtontr", ksp_type = "gmres", pc_type = "gamg", mg_levels_ksp_type = "richardson", mg_levels_pc_type = "jacobi", ksp_gmres_restart = 50)),
158+
(; pkg = :nonlinearsolve, name = "Newton Krylov", alg = NewtonRaphson(; linsolve = KrylovJL_GMRES())),
159+
(; pkg = :nonlinearsolve, name = "Newton Krylov (ILU)", alg = NewtonRaphson(; linsolve = KrylovJL_GMRES(; precs = incompletelu), concrete_jac = true)),
160+
(; pkg = :nonlinearsolve, name = "Newton Krylov (AMG)", alg = NewtonRaphson(; linsolve = KrylovJL_GMRES(; precs = algebraicmultigrid), concrete_jac = true)),
161+
(; pkg = :nonlinearsolve, name = "Newton Krylov (AMG Jacobi)", alg = NewtonRaphson(; linsolve = KrylovJL_GMRES(; precs = algebraicmultigrid_jacobi), concrete_jac = true)),
162+
163+
(; pkg = :nonlinearsolve, name = "TR Krylov", alg = TrustRegion(; linsolve = KrylovJL_GMRES())),
164+
(; pkg = :nonlinearsolve, name = "TR Krylov (ILU)", alg = TrustRegion(; linsolve = KrylovJL_GMRES(; precs = incompletelu), concrete_jac = true)),
165+
(; pkg = :nonlinearsolve, name = "TR Krylov (AMG)", alg = TrustRegion(; linsolve = KrylovJL_GMRES(; precs = algebraicmultigrid), concrete_jac = true)),
166+
(; pkg = :nonlinearsolve, name = "TR Krylov (AMG Jacobi)", alg = TrustRegion(; linsolve = KrylovJL_GMRES(; precs = algebraicmultigrid_jacobi), concrete_jac = true)),
167+
168+
(; pkg = :wrapper, name = "Newton Krylov [Sundials]", alg = KINSOL(; linear_solver = :GMRES, maxsetupcalls=1, krylov_dim)),
169+
170+
(; pkg = :wrapper, name = "Newton Krylov [PETSc]", alg = PETScSNES(; snes_type = "newtonls", snes_linesearch_type = "basic", ksp_type = "gmres", snes_mf = true, ksp_gmres_restart = krylov_dim)),
171+
(; pkg = :wrapper, name = "Newton Krylov (ILU) [PETSc]", alg = PETScSNES(; snes_type = "newtonls", snes_linesearch_type = "basic", ksp_type = "gmres", pc_type = "ilu", ksp_gmres_restart = krylov_dim, pc_factor_levels = 0, pc_factor_drop_tolerance = 50.0)),
172+
(; pkg = :wrapper, name = "Newton Krylov (AMG) [PETSc]", alg = PETScSNES(; snes_type = "newtonls", snes_linesearch_type = "basic", ksp_type = "gmres", pc_type = "gamg", ksp_gmres_restart = krylov_dim)),
173+
(; pkg = :wrapper, name = "Newton Krylov (AMG Jacobi) [PETSc]", alg = PETScSNES(; snes_type = "newtonls", snes_linesearch_type = "basic", ksp_type = "gmres", pc_type = "gamg", mg_levels_ksp_type = "richardson", mg_levels_pc_type = "jacobi", ksp_gmres_restart = krylov_dim)),
174+
175+
(; pkg = :wrapper, name = "TR Krylov (Not Matrix Free) [PETSc]", alg = PETScSNES(; snes_type = "newtontr", ksp_type = "gmres", ksp_gmres_restart = krylov_dim)),
176+
(; pkg = :wrapper, name = "TR Krylov (ILU) [PETSc]", alg = PETScSNES(; snes_type = "newtontr", ksp_type = "gmres", pc_type = "ilu", ksp_gmres_restart = krylov_dim, pc_factor_levels = 0, pc_factor_drop_tolerance = 50.0)),
177+
(; pkg = :wrapper, name = "TR Krylov (AMG) [PETSc]", alg = PETScSNES(; snes_type = "newtontr", ksp_type = "gmres", pc_type = "gamg", ksp_gmres_restart = krylov_dim)),
178+
(; pkg = :wrapper, name = "TR Krylov (AMG Jacobi) [PETSc]", alg = PETScSNES(; snes_type = "newtontr", ksp_type = "gmres", pc_type = "gamg", mg_levels_ksp_type = "richardson", mg_levels_pc_type = "jacobi", ksp_gmres_restart = krylov_dim)),
178179
]
179180

180181
gc_disabled = false

benchmarks/NonlinearProblem/nonlinear_battery_problem.jmd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Doyle-Fuller-Newman (DFN) Battery Model Initialization
33
author: Marc D. Berliner & Avik Pal
4-
priority: 50000000
4+
priority: 50000
55
---
66

77
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:
@@ -59,7 +59,7 @@ solvers_all = [
5959
(; pkg = :nonlinearsolve, name = "Levenberg-Marquardt (No Geodesic Accln.) with Cholesky", solver = Dict(:alg => LevenbergMarquardt(; disable_geodesic = Val(true), linsolve = CholeskyFactorization(), autodiff = AutoEnzyme()))),
6060

6161
(; 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))),
62+
(; pkg = :wrapper, name = "Newton Krylov [Sundials]", solver = Dict(:alg => KINSOL(; linear_solver = :LapackDense, linear_solver = :GMRES, maxsetupcalls=1, krylov_dim = 1000)),
6363
(; pkg = :wrapper, name = "Newton Raphson with LineSearch [Sundials]", solver = Dict(:alg => KINSOL(; globalization_strategy = :LineSearch, maxsetupcalls=1))),
6464

6565
(; pkg = :wrapper, name = "Newton Raphson [NLsolve.jl]", solver = Dict(:alg => NLsolveJL(; method = :newton, autodiff = :forward))),
@@ -75,7 +75,7 @@ solvers_all = [
7575
(; pkg = :wrapper, name = "Newton Raphson with BackTracking [PETSc]", solver = Dict(:alg => PETScSNES(; snes_type = "newtonls"))),
7676
(; pkg = :wrapper, name = "Newton Raphson with BackTracking & QR [PETSc]", solver = Dict(:alg => PETScSNES(; snes_type = "newtonls", pc_type = "qr"))),
7777
(; pkg = :wrapper, name = "Trust Region [PETSc]", solver = Dict(:alg => PETScSNES(; snes_type = "newtontr"))),
78-
(; pkg = :wrapper, name = "Newton Krylov with GMRES [PETSc]", solver = Dict(:alg => PETScSNES(; snes_type = "newtonls", snes_linesearch_type = "basic", ksp_type = "gmres"))),
78+
(; pkg = :wrapper, name = "Newton Krylov with GMRES [PETSc]", solver = Dict(:alg => PETScSNES(; snes_type = "newtonls", snes_linesearch_type = "basic", ksp_type = "gmres", ksp_gmres_restart = 1000))),
7979
];
8080
```
8181

0 commit comments

Comments
 (0)