Skip to content

Commit 67d8164

Browse files
committed
formatting
1 parent 0cb4893 commit 67d8164

File tree

2 files changed

+28
-25
lines changed

2 files changed

+28
-25
lines changed

src/systems/diffeqs/abstractodesystem.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,6 @@ function SciMLBase.BVProblem{iip, specialize}(sys::AbstractODESystem, u0map = []
512512
eval_expression = false,
513513
eval_module = @__MODULE__,
514514
kwargs...) where {iip, specialize}
515-
516515
if !iscomplete(sys)
517516
error("A completed system is required. Call `complete` or `structural_simplify` on the system before creating an `BVProblem`")
518517
end
@@ -528,12 +527,12 @@ function SciMLBase.BVProblem{iip, specialize}(sys::AbstractODESystem, u0map = []
528527
if cbs !== nothing
529528
kwargs1 = merge(kwargs1, (callback = cbs,))
530529
end
531-
530+
532531
# Construct initial conditions.
533532
_u0 = u0 isa Function ? u0(tspan[1]) : u0
534533

535534
# Define the boundary conditions.
536-
bc = if iip
535+
bc = if iip
537536
(residual, u, p, t) -> (residual .= u[1] .- _u0)
538537
else
539538
(u, p, t) -> (u[1] - _u0)
@@ -544,11 +543,13 @@ end
544543

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

547-
@inline function create_array(::Type{Base.ReinterpretArray}, ::Nothing, ::Val{1}, ::Val{dims}, elems...) where dims
546+
@inline function create_array(::Type{Base.ReinterpretArray}, ::Nothing,
547+
::Val{1}, ::Val{dims}, elems...) where {dims}
548548
[elems...]
549549
end
550550

551-
@inline function create_array(::Type{Base.ReinterpretArray}, T, ::Val{1}, ::Val{dims}, elems...) where dims
551+
@inline function create_array(
552+
::Type{Base.ReinterpretArray}, T, ::Val{1}, ::Val{dims}, elems...) where {dims}
552553
T[elems...]
553554
end
554555

test/bvproblem.jl

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,49 +4,51 @@ using ModelingToolkit: t_nounits as t, D_nounits as D
44

55
solvers = [MIRK4, RadauIIa5, LobattoIIIa3]
66

7-
@parameters α = 7.5 β = 4. γ = 8. δ = 5.
8-
@variables x(t) = 1. y(t) = 2.
7+
@parameters α=7.5 β=4.0 γ=8.0 δ=5.0
8+
@variables x(t)=1.0 y(t)=2.0
99

10-
eqs = [D(x) ~ α*x - β*x*y,
11-
D(y) ~ -γ*y + δ*x*y]
10+
eqs = [D(x) ~ α * x - β * x * y,
11+
D(y) ~ -γ * y + δ * x * y]
1212

13-
u0map = [:x => 1., :y => 2.]
14-
parammap = [ => 7.5, => 4, => 8., => 5.]
15-
tspan = (0., 10.)
13+
u0map = [:x => 1.0, :y => 2.0]
14+
parammap = [ => 7.5, => 4, => 8.0, => 5.0]
15+
tspan = (0.0, 10.0)
1616

1717
@mtkbuild lotkavolterra = ODESystem(eqs, t)
1818
op = ODEProblem(lotkavolterra, u0map, tspan, parammap)
1919
osol = solve(op, Vern9())
2020

21-
bvp = SciMLBase.BVProblem{true, SciMLBase.AutoSpecialize}(lotkavolterra, u0map, tspan, parammap; eval_expression = true)
21+
bvp = SciMLBase.BVProblem{true, SciMLBase.AutoSpecialize}(
22+
lotkavolterra, u0map, tspan, parammap; eval_expression = true)
2223

2324
for solver in solvers
2425
sol = solve(bvp, solver(), dt = 0.01)
2526
@test isapprox(sol.u[end], osol.u[end]; atol = 0.01)
26-
@test sol.u[1] == [1., 2.]
27+
@test sol.u[1] == [1.0, 2.0]
2728
end
2829

2930
# Test out of place
30-
bvp2 = SciMLBase.BVProblem{false, SciMLBase.AutoSpecialize}(lotkavolterra, u0map, tspan, parammap; eval_expression = true)
31+
bvp2 = SciMLBase.BVProblem{false, SciMLBase.AutoSpecialize}(
32+
lotkavolterra, u0map, tspan, parammap; eval_expression = true)
3133

3234
for solver in solvers
3335
sol = solve(bvp2, solver(), dt = 0.01)
34-
@test isapprox(sol.u[end],osol.u[end]; atol = 0.01)
35-
@test sol.u[1] == [1., 2.]
36+
@test isapprox(sol.u[end], osol.u[end]; atol = 0.01)
37+
@test sol.u[1] == [1.0, 2.0]
3638
end
3739

3840
### Testing on pendulum
3941

40-
@parameters g = 9.81 L = 1.
41-
@variables θ(t) = π/2
42+
@parameters g=9.81 L=1.0
43+
@variables θ(t) = π / 2
4244

4345
eqs = [D(D(θ)) ~ -(g / L) * sin(θ)]
4446

4547
@mtkbuild pend = ODESystem(eqs, t)
4648

47-
u0map ==> π/2, D(θ) => π/2]
48-
parammap = [:L => 1., :g => 9.81]
49-
tspan = (0., 6.)
49+
u0map ==> π / 2, D(θ) => π / 2]
50+
parammap = [:L => 1.0, :g => 9.81]
51+
tspan = (0.0, 6.0)
5052

5153
op = ODEProblem(pend, u0map, tspan, parammap)
5254
osol = solve(op, Vern9())
@@ -55,14 +57,14 @@ bvp = SciMLBase.BVProblem{true, SciMLBase.AutoSpecialize}(pend, u0map, tspan, pa
5557
for solver in solvers
5658
sol = solve(bvp, solver(), dt = 0.01)
5759
@test isapprox(sol.u[end], osol.u[end]; atol = 0.01)
58-
@test sol.u[1] ==/2, π/2]
60+
@test sol.u[1] == / 2, π / 2]
5961
end
6062

6163
# Test out-of-place
6264
bvp2 = SciMLBase.BVProblem{false, SciMLBase.FullSpecialize}(pend, u0map, tspan, parammap)
6365

6466
for solver in solvers
6567
sol = solve(bvp2, solver(), dt = 0.01)
66-
@test isapprox(sol.u[end],osol.u[end]; atol = 0.01)
67-
@test sol.u[1] ==/2, π/2]
68+
@test isapprox(sol.u[end], osol.u[end]; atol = 0.01)
69+
@test sol.u[1] == / 2, π / 2]
6870
end

0 commit comments

Comments
 (0)