Skip to content

Commit 306e559

Browse files
committed
Update README
1 parent 1f227de commit 306e559

4 files changed

Lines changed: 72 additions & 16 deletions

File tree

README.md

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,6 @@ prob = BVProblem(simplependulum!, bc!, [pi / 2, pi / 2], tspan)
3737
sol = solve(prob, MIRK4(), dt = 0.05)
3838
```
3939

40-
```julia
41-
tspan = (0.0, 1.0)
42-
function lotka_volterra!(du, u, p, t)
43-
du[1] = 1.5 * u[1] - 1.0 * u[1] * u[2]
44-
du[2] = -3.0 * u[2] + 1.0 * u[1] * u[2]
45-
end
46-
function bc!(residual, u, p, t)
47-
residual[1] = u[1] - 1.0
48-
residual[2] = u[2] - 1.0
49-
end
50-
prob = BVProblem(
51-
lotka_volterra!, bc!, [4.0, 2.0], tspan, lcons = [0.0, 0.0], ucons = [Inf, Inf])
52-
sol = solve(prob, MIRK4(; optimizer = Ipopt.Optimizer()), dt = 0.05)
53-
```
54-
5540
## Available Solvers
5641

5742
For the list of available solvers, please refer to the [DifferentialEquations.jl BVP Solvers page](https://docs.sciml.ai/DiffEqDocs/stable/solvers/bvp_solve/). For options for the `solve` command, see the [common solver options page](https://docs.sciml.ai/DiffEqDocs/stable/basics/common_solver_opts/).
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

lib/BoundaryValueDiffEqCore/src/utils.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,6 @@ algorithm used. It returns either a `NonlinearProblem` or an `OptimizationProble
652652
function __construct_internal_problem(prob::AbstractBVProblem, alg, loss, jac,
653653
jac_prototype, resid_prototype, y, p, M::Int, N::Int)
654654
T = eltype(y)
655-
# multiple shooting always use iip
656655
iip = SciMLBase.isinplace(prob)
657656
if !isnothing(alg.nlsolve) || (isnothing(alg.nlsolve) && isnothing(alg.optimize))
658657
nlf = NonlinearFunction{iip}(loss; jac = jac, resid_prototype = resid_prototype,

test/misc/dynamic_optimization.jl

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
@testitem "Linear systems" begin
2+
using BoundaryValueDiffEq
3+
using OptimizationMOI, Ipopt
4+
end
5+
6+
@testitem "Rocket launch" begin
7+
using BoundaryValueDiffEq
8+
using OptimizationMOI, Ipopt
9+
10+
tspan = (0.0, pi / 2)
11+
function simplependulum!(du, u, p, t)
12+
θ = u[1]
13+
= u[2]
14+
du[1] =
15+
du[2] = -9.81 * sin(θ)
16+
end
17+
function bc!(residual, u, p, t)
18+
residual[1] = u(pi / 4)[1] + big(pi / 2)
19+
residual[2] = u(pi / 2)[1] - big(pi / 2)
20+
end
21+
u0 = BigFloat.([pi / 2, pi / 2])
22+
multi_point_bvp = BVProblem(simplependulum!, bc!, u0, tspan)
23+
24+
@testset "BigFloat compatibility with Multi-point BVP" begin
25+
for solver in [MIRK4(), RadauIIa5(), LobattoIIIa4(nested_nlsolve = true)]
26+
sol = solve(multi_point_bvp, solver, dt = 0.05)
27+
@test SciMLBase.successful_retcode(sol.retcode)
28+
end
29+
end
30+
31+
function f!(du, u, p, t)
32+
du[1] = u[2]
33+
du[2] = u[1]
34+
end
35+
function bca!(resid_a, u_a, p)
36+
resid_a[1] = u_a[1] - 1
37+
end
38+
function bcb!(resid_b, u_b, p)
39+
resid_b[1] = u_b[1]
40+
end
41+
bvp_function = BVPFunction(f!, (bca!, bcb!), bcresid_prototype = (zeros(1), zeros(1)), twopoint = Val(true))
42+
tspan = (0.0, 1.0)
43+
two_point_bvp = BVProblem(bvp_function, BigFloat.([1.0, 0.0]), tspan)
44+
45+
@testset "BigFloat compatibility with Two-point BVP" begin
46+
for solver in [MIRK4(), RadauIIa5(), LobattoIIIa4(nested_nlsolve = true)]
47+
sol = solve(two_point_bvp, solver, dt = 0.05)
48+
@test SciMLBase.successful_retcode(sol.retcode)
49+
end
50+
end
51+
52+
function second_f!(ddu, du, u, p, t)
53+
ϵ = 0.1
54+
ddu[1] = u[2]
55+
ddu[2] = (-u[1] * du[2] - u[3] * du[3]) / ϵ
56+
ddu[3] = (du[1] * u[3] - u[1] * du[3]) / ϵ
57+
end
58+
function second_bc!(res, du, u, p, t)
59+
res[1] = u(0.0)[1]
60+
res[2] = u(1.0)[1]
61+
res[3] = u(0.0)[3] + 1
62+
res[4] = u(1.0)[3] - 1
63+
res[5] = du(0.0)[1]
64+
res[6] = du(1.0)[1]
65+
end
66+
u0 = BigFloat.([1.0, 1.0, 1.0])
67+
tspan = (0.0, 1.0)
68+
prob = SecondOrderBVProblem(second_f!, second_bc!, u0, tspan)
69+
@test_broken sol4 = solve(prob, MIRKN4(), dt = 0.01)
70+
@test_broken SciMLBase.successful_retcode(sol4.retcode)
71+
end

0 commit comments

Comments
 (0)