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 33db259
Showing 1 changed file with 26 additions and 16 deletions.
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 33db259

Please sign in to comment.