@@ -14,14 +14,14 @@ D = Differential(t)
1414 u0 = [x => 1.0 , y => 1.0 ]
1515 p = [α => 1.5 , β => 1.0 , δ => 3.0 , γ => 1.0 ]
1616 tspan = (0.0 , 10.0 )
17- prob = ODEProblem (sys, u0, tspan, p )
17+ prob = ODEProblem (sys, [u0; p], tspan )
1818 sol = solve (prob, Tsit5 ())
1919
2020 sys2 = liouville_transform (sys)
2121 sys2 = complete (sys2)
2222
2323 u0 = [x => 1.0 , y => 1.0 , sys2. trJ => 1.0 ]
24- prob = ODEProblem (sys2, u0, tspan, p , jac = true )
24+ prob = ODEProblem (sys2, [u0; p], tspan , jac = true )
2525 sol = solve (prob, Tsit5 ())
2626 @test sol[end , end ] ≈ 1.0742818931017244
2727end
5353
5454 M1 = structural_simplify (M1; allow_symbolic = true )
5555 M2 = structural_simplify (M2; allow_symbolic = true )
56- prob1 = ODEProblem (M1, [M1. s => 1.0 ], (1.0 , 4.0 ), [] )
57- prob2 = ODEProblem (M2, [], (1.0 , 2.0 ), [] )
56+ prob1 = ODEProblem (M1, [M1. s => 1.0 ], (1.0 , 4.0 ))
57+ prob2 = ODEProblem (M2, [], (1.0 , 2.0 ))
5858 sol1 = solve (prob1, Tsit5 (); reltol = 1e-10 , abstol = 1e-10 )
5959 sol2 = solve (prob2, Tsit5 (); reltol = 1e-10 , abstol = 1e-10 )
6060 ts = range (0.0 , 1.0 , length = 50 )
125125 Dx = Differential (Mx. x)
126126 u0 = [Mx. y => 0.0 , Dx (Mx. y) => 1.0 , Mx. t => 0.0 ]
127127 p = [v => 10.0 ]
128- prob = ODEProblem (Mx, u0 , (0.0 , 20.0 ), p ) # 1 = dy/dx = (dy/dt)/(dx/dt) means equal initial horizontal and vertical velocities
128+ prob = ODEProblem (Mx, [u0; p] , (0.0 , 20.0 )) # 1 = dy/dx = (dy/dt)/(dx/dt) means equal initial horizontal and vertical velocities
129129 sol = solve (prob, Tsit5 (); reltol = 1e-5 )
130130 @test all (isapprox .(sol[Mx. y], sol[Mx. x - g * (Mx. t)^ 2 / 2 ]; atol = 1e-10 )) # compare to analytical solution (x(t) = v*t, y(t) = v*t - g*t^2/2)
131131end
138138 Mx = structural_simplify (Mx; allow_symbolic = true )
139139 Dx = Differential (Mx. x)
140140 u0 = [Mx. y => 0.0 , Dx (Mx. y) => 1.0 , Mx. t => 0.0 , Mx. xˍt => 10.0 ]
141- prob = ODEProblem (Mx, u0, (0.0 , 20.0 ), [] ) # 1 = dy/dx = (dy/dt)/(dx/dt) means equal initial horizontal and vertical velocities
141+ prob = ODEProblem (Mx, u0, (0.0 , 20.0 )) # 1 = dy/dx = (dy/dt)/(dx/dt) means equal initial horizontal and vertical velocities
142142 sol = solve (prob, Tsit5 (); reltol = 1e-5 )
143143 @test all (isapprox .(sol[Mx. y], sol[Mx. x - g * (Mx. t)^ 2 / 2 ]; atol = 1e-10 )) # compare to analytical solution (x(t) = v*t, y(t) = v*t - g*t^2/2)
144144end
200200
201201 _f = LinearInterpolation ([1.0 , 1.0 ], [- 100.0 , + 100.0 ]) # constant value 1
202202 M2s = structural_simplify (M2; allow_symbolic = true )
203- prob = ODEProblem (M2s, [M2s. y => 0.0 ], ( 1.0 , 4.0 ), [ fc => _f, f => _f])
203+ prob = ODEProblem (M2s, [M2s. y => 0.0 , fc => _f, f => _f], ( 1.0 , 4.0 ) )
204204 sol = solve (prob, Tsit5 (); abstol = 1e-5 )
205205 @test isapprox (sol (4.0 , idxs = M2. y), 12.0 ; atol = 1e-5 ) # Anal solution is D(y) ~ 12 => y(t) ~ 12*t + C => y(x) ~ 12*√(x) + C. With y(x=1)=0 => 12*(√(x)-1), so y(x=4) ~ 12
206206end
227227 Mx = structural_simplify (Mx; allow_symbolic = true )
228228 Dx = Differential (Mx. x)
229229 u0 = [Mx. y => 0.0 , Dx (Mx. y) => 1.0 , Mx. t_units => 0.0 , Mx. xˍt_units => 10.0 ]
230- prob = ODEProblem (Mx, u0, (0.0 , 20.0 ), [] ) # 1 = dy/dx = (dy/dt)/(dx/dt) means equal initial horizontal and vertical velocities
230+ prob = ODEProblem (Mx, u0, (0.0 , 20.0 )) # 1 = dy/dx = (dy/dt)/(dx/dt) means equal initial horizontal and vertical velocities
231231 sol = solve (prob, Tsit5 (); reltol = 1e-5 )
232232 # compare to analytical solution (x(t) = v*t, y(t) = v*t - g*t^2/2)
233233 @test all (isapprox .(sol[Mx. y], sol[Mx. x - g * (Mx. t_units)^ 2 / 2 ]; atol = 1e-10 ))
300300 new_sys = change_independent_variable (sys, sys. x; add_old_diff = true )
301301 ss_new_sys = structural_simplify (new_sys; allow_symbolic = true )
302302 u0 = [new_sys. y => 0.5 , new_sys. t => 0.0 ]
303- prob = ODEProblem (ss_new_sys, u0, (0.0 , 0.5 ), [] )
303+ prob = ODEProblem (ss_new_sys, u0, (0.0 , 0.5 ))
304304 sol = solve (prob, Tsit5 (); reltol = 1e-5 )
305305 @test sol[new_sys. y][end ] ≈ 0.75
306306end
0 commit comments