@@ -4,49 +4,51 @@ using ModelingToolkit: t_nounits as t, D_nounits as D
44
55solvers = [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)
1818op = ODEProblem (lotkavolterra, u0map, tspan, parammap)
1919osol = 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
2324for 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 ]
2728end
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
3234for 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 ]
3638end
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
4345eqs = [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
5153op = ODEProblem (pend, u0map, tspan, parammap)
5254osol = solve (op, Vern9 ())
@@ -55,14 +57,14 @@ bvp = SciMLBase.BVProblem{true, SciMLBase.AutoSpecialize}(pend, u0map, tspan, pa
5557for 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 ]
5961end
6062
6163# Test out-of-place
6264bvp2 = SciMLBase. BVProblem {false, SciMLBase.FullSpecialize} (pend, u0map, tspan, parammap)
6365
6466for 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 ]
6870end
0 commit comments