Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Oct 2, 2023
1 parent 1bcc1d9 commit bc87422
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 25 deletions.
56 changes: 34 additions & 22 deletions test/misc/type_stability.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,41 @@ p = [1.0, 1.0, 1.0, 1.0]
bcresid_prototype = (zeros(1), zeros(1))

# Multi-Point BVP
mpbvp_iip = BVProblem(f!, bc!, u0, tspan, p)
mpbvp_oop = BVProblem(f, bc, u0, tspan, p)

@inferred solve(mpbvp_iip, Shooting(Tsit5()))
@inferred solve(mpbvp_oop, Shooting(Tsit5()))
@inferred solve(mpbvp_iip, MultipleShooting(5, Tsit5()))
@inferred solve(mpbvp_oop, MultipleShooting(5, Tsit5()))

for solver in (MIRK2(), MIRK3(), MIRK4(), MIRK5(), MIRK6())
@inferred solve(mpbvp_iip, solver; dt = 0.2)
@inferred solve(mpbvp_oop, solver; dt = 0.2)
@testset "Multi-Point BVP" begin
mpbvp_iip = BVProblem(f!, bc!, u0, tspan, p)
mpbvp_oop = BVProblem(f, bc, u0, tspan, p)

@testset "Shooting Methods" begin
@inferred solve(mpbvp_iip, Shooting(Tsit5()))
@inferred solve(mpbvp_oop, Shooting(Tsit5()))
@inferred solve(mpbvp_iip, MultipleShooting(5, Tsit5()))
@inferred solve(mpbvp_oop, MultipleShooting(5, Tsit5()))
end

@testset "MIRK Methods" begin
for solver in (MIRK2(), MIRK3(), MIRK4(), MIRK5(), MIRK6())
@inferred solve(mpbvp_iip, solver; dt = 0.2)
@inferred solve(mpbvp_oop, solver; dt = 0.2)
end
end
end

# Two-Point BVP
tpbvp_iip = TwoPointBVProblem(f!, twobc!, u0, tspan, p; bcresid_prototype)
tpbvp_oop = TwoPointBVProblem(f, twobc, u0, tspan, p)

@inferred solve(tpbvp_iip, Shooting(Tsit5()))
@inferred solve(tpbvp_oop, Shooting(Tsit5()))
@inferred solve(tpbvp_iip, MultipleShooting(5, Tsit5()))
@inferred solve(tpbvp_oop, MultipleShooting(5, Tsit5()))

for solver in (MIRK2(), MIRK3(), MIRK4(), MIRK5(), MIRK6())
@inferred solve(tpbvp_iip, solver; dt = 0.2)
@inferred solve(tpbvp_oop, solver; dt = 0.2)
@testset "Two-Point BVP" begin
tpbvp_iip = TwoPointBVProblem(f!, twobc!, u0, tspan, p; bcresid_prototype)
tpbvp_oop = TwoPointBVProblem(f, twobc, u0, tspan, p)

@testset "Shooting Methods" begin
@inferred solve(tpbvp_iip, Shooting(Tsit5()))
@inferred solve(tpbvp_oop, Shooting(Tsit5()))
@inferred solve(tpbvp_iip, MultipleShooting(5, Tsit5()))
@inferred solve(tpbvp_oop, MultipleShooting(5, Tsit5()))
end

@testset "MIRK Methods" begin
for solver in (MIRK2(), MIRK3(), MIRK4(), MIRK5(), MIRK6())
@inferred solve(tpbvp_iip, solver; dt = 0.2)
@inferred solve(tpbvp_oop, solver; dt = 0.2)
end
end
end
3 changes: 2 additions & 1 deletion test/shooting/orbital.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ for autodiff in (AutoForwardDiff(), AutoFiniteDiff(; fdtype = Val(:central)),
AutoSparseForwardDiff(), AutoFiniteDiff(; fdtype = Val(:forward)),
AutoSparseFiniteDiff())
nlsolve = NewtonRaphson(; autodiff)
@time sol = solve(bvp, Shooting(DP5(); nlsolve); force_dtmin = true, abstol = 1e-13, reltol = 1e-13)
@time sol = solve(bvp, Shooting(DP5(); nlsolve); force_dtmin = true,
abstol = 1e-13, reltol = 1e-13)
cur_bc!(resid_f, sol, nothing, sol.t)
@test norm(resid_f, Inf) < TestTol

Expand Down
6 changes: 4 additions & 2 deletions test/shooting/shooting_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ end

@testset "Shooting with Complex Values" begin
# Test for complex values
function f1!(du, u, p, t)
function f1!(du, u, p, t)
du[1] = u[2]
du[2] = -u[1]
return nothing
Expand All @@ -102,6 +102,8 @@ end
resid[2] = sol(t₁)[1] - 1
return nothing
end

tspan = (0.0, 100.0)
u0 = [0.0, 1.0] .+ 1im
bvp = BVProblem(f1!, bc1!, u0, tspan)
resid_f = Array{ComplexF64}(undef, 2)
Expand Down Expand Up @@ -169,7 +171,7 @@ end
end

@testset "Ray Tracing BVP" begin
# Example 1.7 from
# Example 1.7 from
# "Numerical Solution to Boundary Value Problems for Ordinary Differential equations",
# 'Ascher, Mattheij, Russell'

Expand Down

0 comments on commit bc87422

Please sign in to comment.