|
60 | 60 | sol3 = solve(prob3) # LinearProblem uses default linear solver |
61 | 61 | manualscc = reduce(vcat, (sol1, sol2, sol3)) |
62 | 62 |
|
63 | | - sccprob = SciMLBase.SCCNonlinearProblem( |
| 63 | + sccprob1 = SciMLBase.SCCNonlinearProblem( |
64 | 64 | (prob1, prob2, prob3), |
65 | 65 | SciMLBase.Void{Any}.([explicitfun1, explicitfun2, explicitfun3]) |
66 | 66 | ) |
| 67 | + sccprob2 = SciMLBase.SCCNonlinearProblem( |
| 68 | + [prob1, prob2, prob3], |
| 69 | + SciMLBase.Void{Any}.([explicitfun1, explicitfun2, explicitfun3]) |
| 70 | + ) |
67 | 71 |
|
68 | 72 | # Test with SCCAlg that handles both nonlinear and linear problems |
69 | 73 | using SCCNonlinearSolve |
70 | 74 | scc_alg = SCCNonlinearSolve.SCCAlg(nlalg = NewtonRaphson(), linalg = nothing) |
71 | | - scc_sol = solve(sccprob, scc_alg) |
72 | | - @test sol ≈ manualscc ≈ scc_sol |
73 | | - @test scc_sol.original === nothing # default: store_original = Val(false) |
74 | | - |
75 | | - # Test store_original = Val(true) for debugging |
76 | | - scc_alg_debug = SCCNonlinearSolve.SCCAlg( |
77 | | - nlalg = NewtonRaphson(), linalg = nothing, store_original = Val(true), |
78 | | - ) |
79 | | - scc_sol_debug = solve(sccprob, scc_alg_debug) |
80 | | - @test sol ≈ manualscc ≈ scc_sol_debug |
81 | | - @test scc_sol_debug.original !== nothing |
82 | | - @test length(scc_sol_debug.original) == 3 # 3 sub-problems |
| 75 | + @testset "$type" for (type, sccprob) in [("tuple-form", sccprob1), ("array-form", sccprob2)] |
| 76 | + scc_sol = solve(sccprob, scc_alg) |
| 77 | + @test sol ≈ manualscc ≈ scc_sol |
| 78 | + @test scc_sol.original === nothing # default: store_original = Val(false) |
| 79 | + |
| 80 | + # Test store_original = Val(true) for debugging |
| 81 | + scc_alg_debug = SCCNonlinearSolve.SCCAlg( |
| 82 | + nlalg = NewtonRaphson(), linalg = nothing, store_original = Val(true), |
| 83 | + ) |
| 84 | + scc_sol_debug = solve(sccprob, scc_alg_debug) |
| 85 | + @test sol ≈ manualscc ≈ scc_sol_debug |
| 86 | + @test scc_sol_debug.original !== nothing |
| 87 | + @test length(scc_sol_debug.original) == 3 # 3 sub-problems |
83 | 88 |
|
84 | | - # Backwards compat of alg choice |
85 | | - scc_sol = solve(sccprob, NewtonRaphson()) |
86 | | - @test sol ≈ manualscc ≈ scc_sol |
| 89 | + # Backwards compat of alg choice |
| 90 | + scc_sol = solve(sccprob, NewtonRaphson()) |
| 91 | + @test sol ≈ manualscc ≈ scc_sol |
87 | 92 |
|
88 | | - import NonlinearSolve # Required for Default |
| 93 | + import NonlinearSolve # Required for Default |
89 | 94 |
|
90 | | - # Test default interface |
91 | | - scc_sol_default = solve(sccprob) |
92 | | - @test sol ≈ manualscc ≈ scc_sol_default |
| 95 | + # Test default interface |
| 96 | + scc_sol_default = solve(sccprob) |
| 97 | + @test sol ≈ manualscc ≈ scc_sol_default |
| 98 | + end |
93 | 99 | end |
94 | 100 |
|
95 | 101 | @testitem "SCCNonlinearProblem solve without explicit u0 (issue #758)" setup = [CoreRootfindTesting] tags = [:core] begin |
|
0 commit comments