Skip to content

Commit a9fdfd6

Browse files
committed
up
1 parent f751fbb commit a9fdfd6

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

src/systems/diffeqs/abstractodesystem.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -529,12 +529,12 @@ function SciMLBase.BVProblem{iip, specialize}(sys::AbstractODESystem, u0map = []
529529
kwargs1 = merge(kwargs1, (callback = cbs,))
530530
end
531531

532-
# Construct initial conditions
532+
# Construct initial conditions.
533533
_u0 = u0 isa Function ? u0(tspan[1]) : u0
534534

535-
# Define the boundary conditions
535+
# Define the boundary conditions.
536536
bc = if iip
537-
(residual, u, p, t) -> residual .= u[1] - _u0
537+
(residual, u, p, t) -> (residual .= u[1] - _u0)
538538
else
539539
(u, p, t) -> (u[1] - _u0)
540540
end

test/bvproblem.jl

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,31 @@ using BoundaryValueDiffEq, OrdinaryDiffEq
22
using ModelingToolkit
33
using ModelingToolkit: t_nounits as t, D_nounits as D
44

5-
@parameters σ = 10. ρ = 28 β = 8/3
6-
@variables x(t) = 1 y(t) = 0 z(t) = 0
5+
@parameters α = 7.5 β = 4. γ = 8. δ = 5.
6+
@variables x(t) = 1. y(t) = 2.
77

8-
eqs = [D(x) ~ σ*(y-x),
9-
D(y) ~ x*-z)-y,
10-
D(z) ~ x*y - β*z]
8+
eqs = [D(x) ~ α*x - β*x*y,
9+
D(y) ~ -γ*y + δ*x*y]
1110

12-
u0map = [:x => 1., :y => 0., :z => 0.]
13-
parammap = [:ρ => 28., => 8/3, :σ => 10.]
11+
u0map = [:x => 1., :y => 2.]
12+
parammap = [:α => 7.5, => 4, => 8., :δ => 5.]
1413
tspan = (0., 10.)
1514

16-
@mtkbuild lorenz = ODESystem(eqs, t)
15+
@mtkbuild lotkavolterra = ODESystem(eqs, t)
1716

18-
bvp = SciMLBase.BVProblem{true, SciMLBase.AutoSpecialize}(lorenz, u0map, tspan, parammap)
19-
sol = solve(bvp, MIRK4(), dt = 0.1);
17+
bvp = SciMLBase.BVProblem{true, SciMLBase.AutoSpecialize}(lotkavolterra, u0map, tspan, parammap)
18+
sol = solve(bvp, MIRK4(), dt = 0.01);
2019

21-
bvp2 = SciMLBase.BVProblem{false, SciMLBase.AutoSpecialize}(lorenz, u0map, tspan, parammap)
22-
sol2 = solve(bvp, MIRK4(), dt = 0.1);
20+
bvp2 = SciMLBase.BVProblem{false, SciMLBase.AutoSpecialize}(lotkavolterra, u0map, tspan, parammap)
21+
sol2 = solve(bvp, MIRK4(), dt = 0.01);
2322

24-
op = ODEProblem(lorenz, u0map, tspan, parammap)
25-
osol = solve(op)
23+
op = ODEProblem(lotkavolterra, u0map, tspan, parammap)
24+
osol = solve(op, Vern9())
2625

27-
@test sol.u[end] osol.u[end]
28-
@test sol2.u[end] osol.u[end]
29-
@test sol.u[1] == [1., 0., 0.]
30-
@test sol2.u[1] == [1., 0., 0.]
26+
@test isapprox(sol.u[end],osol.u[end]; atol = 0.001)
27+
@test isapprox(sol2.u[end],osol.u[end]; atol = 0.001)
28+
@test sol.u[1] == [1., 2.]
29+
@test sol2.u[1] == [1., 2.]
3130

3231
### Testing on pendulum
3332

@@ -39,16 +38,17 @@ eqs = [D(D(θ)) ~ -(g / L) * sin(θ)]
3938
@mtkbuild pend = ODESystem(eqs, t)
4039

4140
u0map ==> π/2, D(θ) => π/2]
42-
parammap = [:L => 2.]
41+
parammap = [:L => 2., :g => 9.81]
4342
tspan = (0., 10.)
4443

4544
bvp = SciMLBase.BVProblem{true, SciMLBase.AutoSpecialize}(pend, u0map, tspan, parammap)
46-
sol = solve(bvp, MIRK4(), dt = 0.05);
45+
sol = solve(bvp, MIRK4(), dt = 0.01);
4746

4847
bvp2 = SciMLBase.BVProblem{false, SciMLBase.AutoSpecialize}(pend, u0map, tspan, parammap)
49-
sol2 = solve(bvp2, MIRK4(), dt = 0.05);
48+
sol2 = solve(bvp2, MIRK4(), dt = 0.01);
5049

51-
osol = solve(pend)
50+
op = ODEProblem(pend, u0map, tspan, parammap)
51+
osol = solve(op, Vern9())
5252

5353
@test sol.u[end] osol.u[end]
5454
@test sol.u[1] ==/2, π/2]

0 commit comments

Comments
 (0)