-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
67 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using BoundaryValueDiffEq, OrdinaryDiffEq, LinearAlgebra, Test | ||
|
||
f(u, p, t) = [p[1] * u[1] - p[2] * u[1] * u[2], p[3] * u[1] * u[2] - p[4] * u[2]] | ||
function f!(du, u, p, t) | ||
du[1] = p[1] * u[1] - p[2] * u[1] * u[2] | ||
du[2] = p[3] * u[1] * u[2] - p[4] * u[2] | ||
end | ||
|
||
bc(sol, p, t) = [sol[1][1] - 1, sol[end][2] - 2] | ||
function bc!(res, sol, p, t) | ||
res[1] = sol[1][1] - 1 | ||
res[2] = sol[end][2] - 2 | ||
end | ||
twobc((ua, ub), p) = ([ua[1] - 1], [ub[2] - 2]) | ||
function twobc!((resa, resb), (ua, ub), p) | ||
resa[1] = ua[1] - 1 | ||
resb[1] = ub[2] - 2 | ||
end | ||
|
||
u0 = Float64[0, 0] | ||
tspan = (0.0, 1.0) | ||
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) | ||
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) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.