11using OrdinaryDiffEq, Test, Random, LinearAlgebra, LinearSolve
22Random. seed! (123 )
33
4- A = 0.01 * rand (3 , 3 )
4+ const A = 0.01 * rand (3 , 3 )
55rn = (du, u, p, t) -> begin
6- mul! (du, A, u)
6+ du . = A * u
77end
88u0 = rand (3 )
99prob = ODEProblem (rn, u0, (0 , 50.0 ))
1010
1111function precsl (W, p)
12- Pl = lu (convert (AbstractMatrix, W), check = false )
13- Pl , IdentityOperator (size (W, 1 ))
12+ F = lu (convert (AbstractMatrix, W), check = false )
13+ return F , IdentityOperator (size (W, 1 ))
1414end
1515
1616function precsr (W, p)
17- Pr = lu (convert (AbstractMatrix, W), check = false )
18- IdentityOperator (size (W, 1 )), Pr
17+ F = lu (convert (AbstractMatrix, W), check = false )
18+ IdentityOperator (size (W, 1 )), F
1919end
2020
2121function precslr (W, p)
22- Pr = lu (convert (AbstractMatrix, W), check = false )
23- Pr, Pr
22+ F = lu (convert (AbstractMatrix, W), check = false )
23+ F, F
2424end
2525
26+ @testset " precs" begin
27+ @testset " $linsolve " for linsolve in (KrylovJL_GMRES (),
28+ KrylovJL_GMRES (precs = precsl),
29+ KrylovJL_GMRES (precs = precsr),
30+ KrylovJL_GMRES (precs = precslr))
31+ sol = @test_nowarn solve (prob, TRBDF2 (;linsolve,
32+ smooth_est = false , concrete_jac = true ), maxiters= 20 )
33+ sol = @test_nowarn solve (prob, Rodas5P (autodiff = false ;
34+ linsolve, concrete_jac = true ), maxiters= 30 )
35+ end
36+ @testset " $solver " for solver in (Rosenbrock23, FBDF, QNDF)
37+ sol = @test_nowarn solve (prob, solver (
38+ linsolve= KrylovJL_GMRES (precs = precslr), concrete_jac = true ),
39+ maxiters= 30 )
40+ end
41+ end
2642
2743sol = @test_nowarn solve (prob, TRBDF2 (autodiff = false ));
2844@test length (sol. t) < 20
@@ -33,61 +49,7 @@ solref = @test_nowarn solve(prob,
3349 TRBDF2 (autodiff = false , linsolve = KrylovJL_GMRES (),
3450 smooth_est = false ));
3551@test length (sol. t) < 20
36- sol = @test_nowarn solve (prob,
37- TRBDF2 (autodiff = false , linsolve = KrylovJL_GMRES (precs = precsl),
38- smooth_est = false , concrete_jac = true ));
39- @test length (sol. t) < 20
40- sol = @test_nowarn solve (prob,
41- TRBDF2 (autodiff = false , linsolve = KrylovJL_GMRES (precs = precsr),
42- smooth_est = false , concrete_jac = true ));
43- @test length (sol. t) < 20
44- sol = @test_nowarn solve (prob,
45- TRBDF2 (autodiff = false , linsolve = KrylovJL_GMRES (precs = precslr)
46- , smooth_est = false , concrete_jac = true ));
47- @test length (sol. t) < 20
4852sol = @test_nowarn solve (prob,
4953 QNDF (autodiff = false , linsolve = KrylovJL_GMRES (),
5054 concrete_jac = true ));
5155@test length (sol. t) < 25
52- sol = @test_nowarn solve (prob,
53- Rosenbrock23 (autodiff = false ,
54- linsolve = KrylovJL_GMRES (precs = precslr),
55- concrete_jac = true ));
56- @test length (sol. t) < 20
57- sol = @test_nowarn solve (prob,
58- Rodas4 (autodiff = false , linsolve = KrylovJL_GMRES (precs = precslr),
59- concrete_jac = true ));
60- @test length (sol. t) < 20
61-
62- sol = @test_nowarn solve (prob, TRBDF2 (autodiff = false ));
63- @test length (sol. t) < 20
64- sol = @test_nowarn solve (prob, TRBDF2 (autodiff = false , linsolve = KrylovJL_GMRES ()));
65- @test length (sol. t) < 20
66- sol = @test_nowarn solve (prob,
67- TRBDF2 (autodiff = false , linsolve = KrylovJL_GMRES (),
68- smooth_est = false ));
69- @test length (sol. t) < 20
70- sol = @test_nowarn solve (prob,
71- TRBDF2 (autodiff = false , linsolve = KrylovJL_GMRES (precs = precsl),
72- smooth_est = false , concrete_jac = true ));
73- @test length (sol. t) < 20
74- sol = @test_nowarn solve (prob,
75- TRBDF2 (autodiff = false , linsolve = KrylovJL_GMRES (precs = precsr),
76- smooth_est = false , concrete_jac = true ));
77- @test length (sol. t) < 20
78- sol = @test_nowarn solve (prob,
79- TRBDF2 (autodiff = false , linsolve = KrylovJL_GMRES (precs = precslr),
80- smooth_est = false , concrete_jac = true ));
81- @test length (sol. t) < 20
82- sol = @test_nowarn solve (prob,
83- QNDF (autodiff = false , linsolve = KrylovJL_GMRES (),
84- concrete_jac = true ));
85- @test length (sol. t) < 25
86- sol = @test_nowarn solve (prob,
87- Rosenbrock23 (autodiff = false , linsolve = KrylovJL_GMRES (precs = precslr),
88- concrete_jac = true ));
89- @test length (sol. t) < 20
90- sol = @test_nowarn solve (prob,
91- Rodas4 (autodiff = false , linsolve = KrylovJL_GMRES (precs = precslr),
92- concrete_jac = true ));
93- @test length (sol. t) < 20
0 commit comments