Skip to content

Commit

Permalink
test: precs need concrete jacobian
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Oct 31, 2024
1 parent 8762dcc commit 71e9806
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 17 deletions.
2 changes: 1 addition & 1 deletion docs/src/tutorials/large_systems.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ which is more automatic. The setup is very similar to before:
using AlgebraicMultigrid
function algebraicmultigrid(W, p = nothing)
return aspreconditioner(ruge_stuben(convert(AbstractMatrix, W))), LinearAlgebra.I
return aspreconditioner(ruge_stuben(convert(AbstractMatrix, W))), LinearAlgebra.I
end
@btime solve(prob_brusselator_2d_sparse,
Expand Down
42 changes: 26 additions & 16 deletions lib/NonlinearSolveFirstOrder/test/rootfind_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,22 @@ end
@testset "[IIP] u0: $(typeof(u0))" for u0 in ([1.0, 1.0],)
ad isa AutoZygote && continue

@testset for linsolve in (
nothing,
KrylovJL_GMRES(; precs = nothing),
KrylovJL_GMRES(;
precs = (A, p = nothing) -> (
Diagonal(randn!(similar(A, size(A, 1)))), LinearAlgebra.I
@testset for (concrete_jac, linsolve) in (
(Val(false), nothing),
(Val(false), KrylovJL_GMRES(; precs = nothing)),
(
Val(true),
KrylovJL_GMRES(;
precs = (A, p = nothing) -> (
Diagonal(randn!(similar(A, size(A, 1)))), LinearAlgebra.I
)
)
),
\
(Val(false), \)
)
solver = NewtonRaphson(; linsolve, linesearch, autodiff = ad)
solver = NewtonRaphson(;
linsolve, linesearch, autodiff = ad, concrete_jac
)

sol = solve_iip(quadratic_f!, u0; solver)
@test SciMLBase.successful_retcode(sol)
Expand Down Expand Up @@ -114,17 +119,22 @@ end
@testset "[IIP] u0: $(typeof(u0))" for u0 in ([1.0, 1.0],)
ad isa AutoZygote && continue

@testset for linsolve in (
nothing,
KrylovJL_GMRES(; precs = nothing),
KrylovJL_GMRES(;
precs = (A, p = nothing) -> (
Diagonal(randn!(similar(A, size(A, 1)))), LinearAlgebra.I
@testset for (concrete_jac, linsolve) in (
(Val(false), nothing),
(Val(false), KrylovJL_GMRES(; precs = nothing)),
(
Val(true),
KrylovJL_GMRES(;
precs = (A, p = nothing) -> (
Diagonal(randn!(similar(A, size(A, 1)))), LinearAlgebra.I
)
)
),
\
(Val(false), \)
)
solver = PseudoTransient(; alpha_initial = 10.0, linsolve, autodiff = ad)
solver = PseudoTransient(;
alpha_initial = 10.0, linsolve, autodiff = ad, concrete_jac
)
sol = solve_iip(quadratic_f!, u0; solver)
@test SciMLBase.successful_retcode(sol)
err = maximum(abs, quadratic_f(sol.u, 2.0))
Expand Down

0 comments on commit 71e9806

Please sign in to comment.