@@ -7,7 +7,7 @@ using ModelingToolkit: t_nounits as t, D_nounits as D
77import ModelingToolkit: process_constraints
88
99# ## Test Collocation solvers on simple problems
10- solvers = [MIRK4, RadauIIa5, LobattoIIIa3 ]
10+ solvers = [MIRK4, RadauIIa5]
1111daesolvers = [Ascher2, Ascher4, Ascher6]
1212
1313let
@@ -149,32 +149,32 @@ let
149149 bvpi3 = SciMLBase. BVProblem {true, SciMLBase.AutoSpecialize} (lksys, [x (t) => 1. ], tspan; guesses = [y (t) => 1. ], constraints)
150150 bvpi4 = SciMLBase. BVProblem {true, SciMLBase.FullSpecialize} (lksys, [x (t) => 1. ], tspan; guesses = [y (t) => 1. ], constraints)
151151
152- @btime sol1 = solve (bvpi1, MIRK4 (), dt = 0.01 )
153- @btime sol2 = solve (bvpi2, MIRK4 (), dt = 0.01 )
154- @btime sol3 = solve (bvpi3, MIRK4 (), dt = 0.01 )
155- @btime sol4 = solve (bvpi4, MIRK4 (), dt = 0.01 )
152+ sol1 = @btime solve ($ bvpi1, MIRK4 (), dt = 0.01 )
153+ sol2 = @btime solve ($ bvpi2, MIRK4 (), dt = 0.01 )
154+ sol3 = @btime solve ($ bvpi3, MIRK4 (), dt = 0.01 )
155+ sol4 = @btime solve ($ bvpi4, MIRK4 (), dt = 0.01 )
156156 @test sol1 ≈ sol2 ≈ sol3 ≈ sol4 # don't get true equality here, not sure why
157157
158158 bvpo1 = BVProblem (lotkavolterra, bc, [1 ,2 ], tspan, p)
159159 bvpo2 = BVProblem (lotkavolterra, genbc_oop, [1 ,2 ], tspan, p)
160- bvpo3 = SciMLBase. BVProblem {false, SciMLBase.FullSpecialize} (lksys, [x (t) => 1. ], tspan, parammap ; guesses = [y (t) => 1. ], constraints)
160+ bvpo3 = SciMLBase. BVProblem {false, SciMLBase.FullSpecialize} (lksys, [x (t) => 1. ], tspan; guesses = [y (t) => 1. ], constraints)
161161
162- @btime sol1 = solve (bvpo1, MIRK4 (), dt = 0.05 )
163- @btime sol2 = solve (bvpo2, MIRK4 (), dt = 0.05 )
164- @btime sol3 = solve (bvpo3, MIRK4 (), dt = 0.05 )
162+ sol1 = @btime solve ($ bvpo1, MIRK4 (), dt = 0.05 )
163+ sol2 = @btime solve ($ bvpo2, MIRK4 (), dt = 0.05 )
164+ sol3 = @btime solve ($ bvpo3, MIRK4 (), dt = 0.05 )
165165 @test sol1 ≈ sol2 ≈ sol3
166166end
167167
168168function test_solvers (solvers, prob, u0map, constraints, equations = []; dt = 0.05 , atol = 1e-4 )
169169 for solver in solvers
170170 println (" Solver: $solver " )
171- @btime sol = solve (prob, solver (), dt = dt, abstol = atol)
171+ sol = @btime solve ($ prob, $ solver (), dt = $ dt, abstol = $ atol)
172172 @test SciMLBase. successful_retcode (sol. retcode)
173173 p = prob. p; t = sol. t; bc = prob. f. bc
174174 ns = length (prob. u0)
175175 if isinplace (bvp. f)
176176 resid = zeros (ns)
177- bc! (resid, sol, p, t)
177+ bc (resid, sol, p, t)
178178 @test isapprox (zeros (ns), resid; atol)
179179 else
180180 @test isapprox (zeros (ns), bc (sol, p, t); atol)
@@ -203,35 +203,35 @@ let
203203 D (y (t)) ~ - γ * y (t) + δ * x (t) * y (t)]
204204
205205 u0map = []
206- tspan = (0.0 , 10 .0 )
206+ tspan = (0.0 , 1 .0 )
207207 guesses = [x (t) => 4.0 , y (t) => 2. ]
208208
209209 @mtkbuild lksys = ODESystem (eqs, t)
210210
211- constraints = [x (6. ) ~ 3.5 , x (3. ) ~ 7. ]
211+ constraints = [x (. 6 ) ~ 3.5 , x (. 3 ) ~ 7. ]
212212 bvp = SciMLBase. BVProblem {true, SciMLBase.AutoSpecialize} (lksys, u0map, tspan; guesses, constraints)
213- test_solvers (solvers, bvp, u0map, constraints; dt = 0.1 )
213+ test_solvers (solvers, bvp, u0map, constraints; dt = 0.05 )
214214
215215 # Testing that more complicated constraints give correct solutions.
216- constraints = [y (2. ) + x (8. ) ~ 2 . ]
217- bvp = SciMLBase. BVProblem {false, SciMLBase.FullSpecialize} (lotkavolterra , u0map, tspan, parammap ; guesses, constraints)
218- test_solvers (solvers, bvp, u0map, constraints)
216+ constraints = [y (. 2 ) + x (. 8 ) ~ 3. , y (. 3 ) + x (. 5 ) ~ 5 . ]
217+ bvp = SciMLBase. BVProblem {false, SciMLBase.FullSpecialize} (lksys , u0map, tspan; guesses, constraints, jac = true )
218+ test_solvers (solvers, bvp, u0map, constraints; dt = 0.05 )
219219
220- constraints = [α * β - x (6. ) ~ 0.5 ]
221- bvp = SciMLBase. BVProblem {true, SciMLBase.AutoSpecialize} (lotkavolterra , u0map, tspan, parammap ; guesses, constraints)
220+ constraints = [α * β - x (. 6 ) ~ 0.0 , y (. 2 ) ~ 3. ]
221+ bvp = SciMLBase. BVProblem {true, SciMLBase.AutoSpecialize} (lksys , u0map, tspan; guesses, constraints)
222222 test_solvers (solvers, bvp, u0map, constraints)
223223
224224 # Testing that errors are properly thrown when malformed constraints are given.
225225 @variables bad (.. )
226226 constraints = [x (1. ) + bad (3. ) ~ 10 ]
227- @test_throws Exception bvp = SciMLBase. BVProblem {true, SciMLBase.AutoSpecialize} (lotkavolterra , u0map, tspan, parammap ; guesses, constraints)
227+ @test_throws Exception bvp = SciMLBase. BVProblem {true, SciMLBase.AutoSpecialize} (lksys , u0map, tspan; guesses, constraints)
228228
229229 constraints = [x (t) + y (t) ~ 3 ]
230- @test_throws Exception bvp = SciMLBase. BVProblem {true, SciMLBase.AutoSpecialize} (lotkavolterra , u0map, tspan, parammap ; guesses, constraints)
230+ @test_throws Exception bvp = SciMLBase. BVProblem {true, SciMLBase.AutoSpecialize} (lksys , u0map, tspan; guesses, constraints)
231231
232232 @parameters bad2
233233 constraints = [bad2 + x (0. ) ~ 3 ]
234- @test_throws Exception bvp = SciMLBase. BVProblem {true, SciMLBase.AutoSpecialize} (lotkavolterra , u0map, tspan, parammap ; guesses, constraints)
234+ @test_throws Exception bvp = SciMLBase. BVProblem {true, SciMLBase.AutoSpecialize} (lksys , u0map, tspan; guesses, constraints)
235235end
236236
237237# Cartesian pendulum from the docs.
0 commit comments