Skip to content

Commit

Permalink
cleanup test
Browse files Browse the repository at this point in the history
  • Loading branch information
oscardssmith committed Sep 1, 2024
1 parent 5bf3cdf commit a3ff4c1
Showing 1 changed file with 24 additions and 62 deletions.
86 changes: 24 additions & 62 deletions test/interface/linear_nonlinear_tests.jl
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

0 comments on commit a3ff4c1

Please sign in to comment.