From a3ff4c1c0c1606a1632fc1dab7662c0b70913f22 Mon Sep 17 00:00:00 2001 From: Oscar Smith Date: Sun, 1 Sep 2024 02:54:05 -0400 Subject: [PATCH] cleanup test --- test/interface/linear_nonlinear_tests.jl | 86 +++++++----------------- 1 file changed, 24 insertions(+), 62 deletions(-) diff --git a/test/interface/linear_nonlinear_tests.jl b/test/interface/linear_nonlinear_tests.jl index e799ca2616..537365a4e2 100644 --- a/test/interface/linear_nonlinear_tests.jl +++ b/test/interface/linear_nonlinear_tests.jl @@ -1,28 +1,44 @@ using OrdinaryDiffEq, Test, Random, LinearAlgebra, LinearSolve Random.seed!(123) -A = 0.01 * rand(3, 3) +const A = 0.01 * rand(3, 3) rn = (du, u, p, t) -> begin - mul!(du, A, u) + du .= A * u end u0 = rand(3) prob = ODEProblem(rn, u0, (0, 50.0)) function precsl(W, p) - Pl = lu(convert(AbstractMatrix, W), check = false) - Pl, IdentityOperator(size(W, 1)) + F = lu(convert(AbstractMatrix, W), check = false) + return F, IdentityOperator(size(W, 1)) end function precsr(W, p) - Pr = lu(convert(AbstractMatrix, W), check = false) - IdentityOperator(size(W, 1)), Pr + F = lu(convert(AbstractMatrix, W), check = false) + IdentityOperator(size(W, 1)), F end function precslr(W, p) - Pr = lu(convert(AbstractMatrix, W), check = false) - Pr, Pr + F = lu(convert(AbstractMatrix, W), check = false) + F, F end +@testset "precs" begin + @testset "$linsolve" for linsolve in (KrylovJL_GMRES(), + KrylovJL_GMRES(precs = precsl), + KrylovJL_GMRES(precs = precsr), + KrylovJL_GMRES(precs = precslr)) + sol = @test_nowarn solve(prob, TRBDF2(;linsolve, + smooth_est = false, concrete_jac = true), maxiters=20) + sol = @test_nowarn solve(prob, Rodas5P(autodiff = false; + linsolve, concrete_jac = true), maxiters=30) + end + @testset "$solver" for solver in (Rosenbrock23, FBDF, QNDF) + sol = @test_nowarn solve(prob, solver( + linsolve=KrylovJL_GMRES(precs = precslr), concrete_jac = true), + maxiters=30) + end +end sol = @test_nowarn solve(prob, TRBDF2(autodiff = false)); @test length(sol.t) < 20 @@ -33,61 +49,7 @@ solref = @test_nowarn solve(prob, TRBDF2(autodiff = false, linsolve = KrylovJL_GMRES(), smooth_est = false)); @test length(sol.t) < 20 -sol = @test_nowarn solve(prob, - TRBDF2(autodiff = false, linsolve = KrylovJL_GMRES(precs = precsl), - smooth_est = false, concrete_jac = true)); -@test length(sol.t) < 20 -sol = @test_nowarn solve(prob, - TRBDF2(autodiff = false, linsolve = KrylovJL_GMRES(precs = precsr), - smooth_est = false, concrete_jac = true)); -@test length(sol.t) < 20 -sol = @test_nowarn solve(prob, - TRBDF2(autodiff = false, linsolve = KrylovJL_GMRES(precs = precslr) - , smooth_est = false, concrete_jac = true)); -@test length(sol.t) < 20 sol = @test_nowarn solve(prob, QNDF(autodiff = false, linsolve = KrylovJL_GMRES(), concrete_jac = true)); @test length(sol.t) < 25 -sol = @test_nowarn solve(prob, - Rosenbrock23(autodiff = false, - linsolve = KrylovJL_GMRES(precs = precslr), - concrete_jac = true)); -@test length(sol.t) < 20 -sol = @test_nowarn solve(prob, - Rodas4(autodiff = false, linsolve = KrylovJL_GMRES(precs = precslr), - concrete_jac = true)); -@test length(sol.t) < 20 - -sol = @test_nowarn solve(prob, TRBDF2(autodiff = false)); -@test length(sol.t) < 20 -sol = @test_nowarn solve(prob, TRBDF2(autodiff = false, linsolve = KrylovJL_GMRES())); -@test length(sol.t) < 20 -sol = @test_nowarn solve(prob, - TRBDF2(autodiff = false, linsolve = KrylovJL_GMRES(), - smooth_est = false)); -@test length(sol.t) < 20 -sol = @test_nowarn solve(prob, - TRBDF2(autodiff = false, linsolve = KrylovJL_GMRES(precs = precsl), - smooth_est = false, concrete_jac = true)); -@test length(sol.t) < 20 -sol = @test_nowarn solve(prob, - TRBDF2(autodiff = false, linsolve = KrylovJL_GMRES(precs = precsr), - smooth_est = false, concrete_jac = true)); -@test length(sol.t) < 20 -sol = @test_nowarn solve(prob, - TRBDF2(autodiff = false, linsolve = KrylovJL_GMRES(precs = precslr), - smooth_est = false, concrete_jac = true)); -@test length(sol.t) < 20 -sol = @test_nowarn solve(prob, - QNDF(autodiff = false, linsolve = KrylovJL_GMRES(), - concrete_jac = true)); -@test length(sol.t) < 25 -sol = @test_nowarn solve(prob, - Rosenbrock23(autodiff = false, linsolve = KrylovJL_GMRES(precs = precslr), - concrete_jac = true)); -@test length(sol.t) < 20 -sol = @test_nowarn solve(prob, - Rodas4(autodiff = false, linsolve = KrylovJL_GMRES(precs = precslr), - concrete_jac = true)); -@test length(sol.t) < 20