Skip to content

Commit

Permalink
Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Sep 28, 2023
1 parent f09b464 commit 4ca99de
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/algorithms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ end

function MultipleShooting(nshoots::Int, ode_alg; nlsolve = DEFAULT_NLSOLVE_SHOOTING,
grid_coarsening = true)
@assert grid_coarsening isa Bool || grid_coarsening isa Function || grid_coarsening isa AbstractVector{<:Integer} || grid_coarsening isa NTuple{N, <:Integer} where {N}
@assert grid_coarsening isa Bool || grid_coarsening isa Function ||
grid_coarsening isa AbstractVector{<:Integer} ||
grid_coarsening isa NTuple{N, <:Integer} where {N}
grid_coarsening isa Tuple && (grid_coarsening = Vector(grid_coarsening...))
if grid_coarsening isa AbstractVector
sort!(grid_coarsening; rev=true)
sort!(grid_coarsening; rev = true)
@assert all(grid_coarsening .> 0) && 1 grid_coarsening
end
return MultipleShooting(ode_alg, nlsolve, nshoots, grid_coarsening)
Expand Down
12 changes: 8 additions & 4 deletions test/shooting_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,16 @@ bvp3 = TwoPointBVProblem(f1!, bc2!, u0, tspan;
bcresid_prototype = (Array{Float64}(undef, 1), Array{Float64}(undef, 1)))
@test SciMLBase.isinplace(bvp3)
for solver in SOLVERS
sol = solve(bvp3, solver)
@test SciMLBase.successful_retcode(sol; abstol = 1e-6, reltol = 1e-6)
sol = solve(bvp3, solver; abstol = 1e-6, reltol = 1e-6)
@test SciMLBase.successful_retcode(sol)
resid_f = (Array{Float64, 1}(undef, 1), Array{Float64, 1}(undef, 1))
bc2!(resid_f, (sol(tspan[1]), sol(tspan[2])), nothing)
@test_broken norm(resid_f) < 1e-6
@test norm(resid_f) < 1e-4
if solver isa Shooting
@test_broken norm(resid_f) < 1e-6
@test norm(resid_f) < 1e-4
else
@test norm(resid_f) < 1e-6
end
end

# Out of Place
Expand Down

0 comments on commit 4ca99de

Please sign in to comment.