Skip to content

Commit 91f17e3

Browse files
test: restore working MTKBase BVP assertions (#4843)
Co-authored-by: ChrisRackauckas-Claude <accounts@chrisrackauckas.com>
1 parent 59cea9e commit 91f17e3

1 file changed

Lines changed: 20 additions & 40 deletions

File tree

lib/ModelingToolkitBase/test/bvproblem.jl

Lines changed: 20 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -32,33 +32,21 @@ daesolvers = [Ascher2, Ascher4, Ascher6]
3232
lotkavolterra, [u0map; parammap], tspan
3333
)
3434

35-
if @isdefined(ModelingToolkit)
36-
for solver in solvers
37-
sol = solve(bvp, solver(), dt = 0.01)
38-
@test isapprox(sol.u[end], osol.u[end]; atol = 0.01)
39-
@test sol[[x, y], 1] == [1.0, 2.0]
40-
end
41-
else
42-
for solver in solvers
43-
@test_broken solve(bvp, solver(), dt = 0.01)
44-
end
35+
for solver in solvers
36+
sol = solve(bvp, solver(), dt = 0.01)
37+
@test isapprox(sol.u[end], osol.u[end]; atol = 0.01)
38+
@test sol[[x, y], 1] == [1.0, 2.0]
4539
end
4640

4741
# Test out of place
4842
bvp2 = SciMLBase.BVProblem{false, SciMLBase.AutoSpecialize}(
4943
lotkavolterra, [u0map; parammap], tspan
5044
)
5145

52-
if @isdefined(ModelingToolkit)
53-
for solver in solvers
54-
sol = solve(bvp2, solver(), dt = 0.01)
55-
@test isapprox(sol.u[end], osol.u[end]; atol = 0.01)
56-
@test sol[[x, y], 1] == [1.0, 2.0]
57-
end
58-
else
59-
for solver in solvers
60-
@test_broken solve(bvp2, solver(), dt = 0.01)
61-
end
46+
for solver in solvers
47+
sol = solve(bvp2, solver(), dt = 0.01)
48+
@test isapprox(sol.u[end], osol.u[end]; atol = 0.01)
49+
@test sol[[x, y], 1] == [1.0, 2.0]
6250
end
6351
end
6452

@@ -346,17 +334,13 @@ end
346334
@test_broken costfn(sol, prob.p, _t) (sol(0.6; idxs = x(t)) + 3)^2 + sol(0.3; idxs = x(t))^2
347335

348336
bvp = SciMLBase.BVProblem{true, SciMLBase.AutoSpecialize}(lksys, [u0map; parammap], tspan)
349-
if @isdefined(ModelingToolkit)
350-
sol = solve(bvp, MIRK4(), dt = 0.05)
351-
@test SciMLBase.successful_retcode(sol)
337+
sol = solve(bvp, MIRK4(), dt = 0.05)
338+
@test SciMLBase.successful_retcode(sol)
352339

353-
costfn = ModelingToolkitBase.generate_bvp_cost(
354-
lksys; expression = Val{false}, wrap_gfw = Val{true}
355-
)
356-
@test costfn(sol, bvp.p) (sol(0.6; idxs = x(t)) + 3)^2 + sol(0.3; idxs = x(t))^2
357-
else
358-
@test_broken solve(bvp, MIRK4(), dt = 0.05)
359-
end
340+
costfn = ModelingToolkitBase.generate_bvp_cost(
341+
lksys; expression = Val{false}, wrap_gfw = Val{true}
342+
)
343+
@test costfn(sol, bvp.p) (sol(0.6; idxs = x(t)) + 3)^2 + sol(0.3; idxs = x(t))^2
360344

361345
### With a parameter
362346
@parameters t_c
@@ -374,17 +358,13 @@ end
374358
log(sol(0.56; idxs = y(t)) + sol(0.0; idxs = x(t))) - sol(0.4; idxs = x(t))^2
375359

376360
bvp = SciMLBase.BVProblem{true, SciMLBase.AutoSpecialize}(lksys, [u0map; parammap], tspan)
377-
if @isdefined(ModelingToolkit)
378-
sol = solve(bvp, MIRK4(), dt = 0.05)
379-
@test SciMLBase.successful_retcode(sol)
361+
sol = solve(bvp, MIRK4(), dt = 0.05)
362+
@test SciMLBase.successful_retcode(sol)
380363

381-
costfn = ModelingToolkitBase.generate_bvp_cost(
382-
lksys; expression = Val{false}, wrap_gfw = Val{true}
383-
)
384-
@test costfn(sol, bvp.p) log(sol(0.56; idxs = y(t)) + sol(0.0; idxs = x(t))) - sol(0.4; idxs = x(t))^2
385-
else
386-
@test_broken solve(bvp, MIRK4(), dt = 0.05)
387-
end
364+
costfn = ModelingToolkitBase.generate_bvp_cost(
365+
lksys; expression = Val{false}, wrap_gfw = Val{true}
366+
)
367+
@test costfn(sol, bvp.p) log(sol(0.56; idxs = y(t)) + sol(0.0; idxs = x(t))) - sol(0.4; idxs = x(t))^2
388368
end
389369

390370
@testset "Parameter estimation" begin

0 commit comments

Comments
 (0)