Skip to content

Commit 5d082ab

Browse files
committed
up
1 parent 50504ab commit 5d082ab

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

src/systems/diffeqs/abstractodesystem.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ end
917917
function SciMLBase.BVProblem{iip, specialize}(sys::AbstractODESystem, u0map = [],
918918
tspan = get_tspan(sys),
919919
parammap = DiffEqBase.NullParameters();
920-
constraints = nothing, guesses = nothing,
920+
constraints = nothing, guesses = Dict(),
921921
version = nothing, tgrad = false,
922922
callback = nothing,
923923
check_length = true,
@@ -929,7 +929,7 @@ function SciMLBase.BVProblem{iip, specialize}(sys::AbstractODESystem, u0map = []
929929
if !iscomplete(sys)
930930
error("A completed system is required. Call `complete` or `structural_simplify` on the system before creating an `BVProblem`")
931931
end
932-
!isnothing(callbacks) && error("BVP solvers do not support callbacks.")
932+
!isnothing(callback) && error("BVP solvers do not support callbacks.")
933933

934934
iv = get_iv(sys)
935935
constraintsts = nothing
@@ -964,7 +964,7 @@ function SciMLBase.BVProblem{iip, specialize}(sys::AbstractODESystem, u0map = []
964964
pidxmap = Dict([v => i for (i, v) in enumerate(ps)])
965965

966966
# Indices of states that have initial constraints.
967-
u0i = has_alg_eqs(sys) ? collect(1:length(sts)) : [stidxmap[k] for k in keys(u0map)]
967+
u0i = has_alg_eqs(sys) ? collect(1:length(sts)) : [stidxmap[k] for (k,v) in u0map]
968968
ni = length(u0i)
969969

970970
bc = if !isnothing(constraints)
@@ -994,7 +994,7 @@ function SciMLBase.BVProblem{iip, specialize}(sys::AbstractODESystem, u0map = []
994994
end
995995
end
996996

997-
return BVProblem{iip}(f, bc, u0, tspan, p; kwargs1..., kwargs...)
997+
return BVProblem{iip}(f, bc, u0, tspan, p; kwargs...)
998998
end
999999

10001000
get_callback(prob::BVProblem) = error("BVP solvers do not support callbacks.")

test/bvproblem.jl

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,14 @@ end
4444
### Testing on pendulum
4545
let
4646
@parameters g=9.81 L=1.0
47-
@variables θ(t) = π / 2
47+
@variables θ(t) = π / 2 θ_t(t)
4848

49-
eqs = [D(D(θ)) ~ -(g / L) * sin(θ)]
49+
eqs = [D(θ) ~ θ_t
50+
D(θ_t) ~ -(g / L) * sin(θ)]
5051

5152
@mtkbuild pend = ODESystem(eqs, t)
5253

53-
u0map ==> π / 2, D(θ) => π / 2]
54+
u0map ==> π / 2, θ_t => π / 2]
5455
parammap = [:L => 1.0, :g => 9.81]
5556
tspan = (0.0, 6.0)
5657

@@ -74,9 +75,9 @@ let
7475
end
7576
end
7677

77-
###################################################
78-
### ODESystem with Constraint Equations, DAEs with constraints ###
79-
###################################################
78+
##################################################################
79+
### ODESystem with constraint equations, DAEs with constraints ###
80+
##################################################################
8081

8182
# Cartesian pendulum from the docs.
8283
# DAE IVP solved using BoundaryValueDiffEq solvers.
@@ -90,19 +91,19 @@ let
9091

9192
tspan = (0.0, 1.5)
9293
u0map = [x => 1, y => 0]
93-
parammap = [g => 1]
94-
guesses ==> 1]
94+
pmap = [g => 1]
95+
guess ==> 1]
9596

96-
prob = ODEProblem(pend, u0map, tspan, pmap; guesses)
97-
sol = solve(prob, Rodas5P())
97+
prob = ODEProblem(pend, u0map, tspan, pmap; guesses = guess)
98+
osol = solve(prob, Rodas5P())
9899

99-
bvp = SciMLBase.BVProblem{true, SciMLBase.AutoSpecialize}(pend, u0map, tspan, parammap; guesses)
100+
bvp = SciMLBase.BVProblem{true, SciMLBase.AutoSpecialize}(pend, u0map, tspan, parammap; guesses = guess)
100101

101102
for solver in solvers
102-
sol = solve(bvp, solver(), dt = 0.01)
103+
sol = solve(bvp, solver(), dt = 0.001)
103104
@test isapprox(sol.u[end], osol.u[end]; atol = 0.01)
104105
conditions = getfield.(equations(pend)[3:end], :rhs)
105-
@test [sol[conditions][1]; sol[x][1] - 1; sol[y][1]] 0
106+
@test isapprox([sol[conditions][1]; sol[x][1] - 1; sol[y][1]], zeros(5), atol = 0.001)
106107
end
107108

108109
bvp2 = SciMLBase.BVProblem{false, SciMLBase.FullSpecialize}(pend, u0map, tspan, parammap)

0 commit comments

Comments
 (0)