Skip to content

Commit

Permalink
Merge branch 'master' into ap/multiple-shooting
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRackauckas authored Oct 12, 2023
2 parents 54e75da + bdc87f1 commit 4065e9c
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/interpolation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ end
@inline function interpolation(tvals, id::I, idxs, deriv::D, p,
continuity::Symbol = :left) where {I, D}
@unpack t, u, cache = id
cache = id.cache
tdir = sign(t[end] - t[1])
idx = sortperm(tvals, rev = tdir < 0)

Expand Down
33 changes: 33 additions & 0 deletions test/interpolation_test.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using BoundaryValueDiffEq, DiffEqBase, DiffEqDevTools, LinearAlgebra, Test

λ = 1
function prob_bvp_linear_analytic(u, λ, t)
a = 1 / sqrt(λ)
[(exp(-a * t) - exp((t - 2) * a)) / (1 - exp(-2 * a)),
(-a * exp(-t * a) - a * exp((t - 2) * a)) / (1 - exp(-2 * a))]
end
function prob_bvp_linear_f!(du, u, p, t)
du[1] = u[2]
du[2] = 1 / p * u[1]
end
function prob_bvp_linear_bc!(res, u, p, t)
res[1] = u[1][1] - 1
res[2] = u[end][1]
end
prob_bvp_linear_function = ODEFunction(prob_bvp_linear_f!, analytic = prob_bvp_linear_analytic)
prob_bvp_linear_tspan = (0.0, 1.0)
prob_bvp_linear = BVProblem(prob_bvp_linear_function, prob_bvp_linear_bc!,
[1.0, 0.0], prob_bvp_linear_tspan, λ)
testTol = 1e-6

for order in (2, 3, 4, 5, 6)
s = Symbol("MIRK$(order)")
@eval mirk_solver(::Val{$order}) = $(s)()
end

@testset "Interpolation" begin
@testset "MIRK$order" for order in (2, 3, 4, 5, 6)
@time sol = solve(prob_bvp_linear, mirk_solver(Val(order)); dt = 0.001)
@test sol(0.001) [0.998687464, -1.312035941] atol=testTol
end
end
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,10 @@ const GROUP = uppercase(get(ENV, "GROUP", "ALL"))
end
end
end

@time @testset "Interpolation Tests" begin
@time @safetestset "MIRK Interpolation Test" begin
include("interpolation_test.jl")
end
end
end

0 comments on commit 4065e9c

Please sign in to comment.