1
- using ModelingToolkit, OrdinaryDiffEq, ODEInterfaceDiffEq, SpecialFunctions
1
+ using ModelingToolkit, OrdinaryDiffEq, ODEInterfaceDiffEq, SpecialFunctions, LinearAlgebra
2
2
using Test
3
3
4
4
# Testing for α < 1
@@ -55,31 +55,37 @@ while(time <= 1)
55
55
time += 0.1
56
56
end
57
57
58
- # # Testing for example 2 of Section 7
59
- # @independent_variables t
60
- # @variables x(t) y(t)
61
- # D = Differential(t)
62
- # tspan = (0., 220.)
58
+ # Testing for example 2 of Section 7
59
+ @independent_variables t
60
+ @variables x (t) y (t)
61
+ D = Differential (t)
62
+ tspan = (0. , 220. )
63
63
64
- # sys = fractional_to_ordinary([1 - 4*x + x^2 * y, 3*x - x^2 * y], [x, y], [1.3, 0.8], 10^-8, 220; initials=[[1.2, 1], 2.8]; matrix=true)
65
- # prob = ODEProblem(sys, [], tspan)
66
- # sol = solve(prob, radau5(), abstol = 1e-8, reltol = 1e-8)
64
+ sys = fractional_to_ordinary ([1 - 4 * x + x^ 2 * y, 3 * x - x^ 2 * y], [x, y], [1.3 , 0.8 ], 10 ^- 8 , 220 ; initials= [[1.2 , 1 ], 2.8 ]; matrix= true )
65
+ prob = ODEProblem (sys, [], tspan)
66
+ sol = solve (prob, radau5 (), abstol = 1e-8 , reltol = 1e-8 )
67
67
68
- # @test isapprox(1.0097684171, sol(220, idxs=x), atol=1e-5)
69
- # @test isapprox(2.1581264031, sol(220, idxs=y), atol=1e-5)
68
+ @test isapprox (1.0097684171 , sol (220 , idxs= x), atol= 1e-5 )
69
+ @test isapprox (2.1581264031 , sol (220 , idxs= y), atol= 1e-5 )
70
70
71
- # #Testing for example 3 of Section 7
72
- # @independent_variables t
73
- # @variables x_0(t)
74
- # D = Differential(t)
75
- # tspan = (0., 5000.)
71
+ # Testing for example 3 of Section 7
72
+ @independent_variables t
73
+ @variables x_0 (t)
74
+ D = Differential (t)
75
+ tspan = (0. , 5000. )
76
+
77
+ function expect (t)
78
+ return sqrt (2 ) * sin (t + pi / 4 )
79
+ end
80
+
81
+ sys = linear_fractional_to_ordinary ([3 , 2.5 , 2 , 1 , .5 , 0 ], [1 , 1 , 1 , 4 , 1 , 4 ], 6 * cos (t), 10 ^- 5 , 5000 ; initials= [1 , 1 , - 1 ])
82
+ prob = ODEProblem (sys, [], tspan)
83
+ sol = solve (prob, radau5 (), abstol = 1e-5 , reltol = 1e-5 )
76
84
77
- # function expect(t)
78
- # return sqrt(2) * sin(t + pi/4)
79
- # end
85
+ @test isapprox (expect (5000 ), sol (5000 , idxs= x_0), atol= 1e-5 )
80
86
81
- # sys = linear_fractional_to_ordinary([3, 2.5, 2, 1, .5, 0], [1, 1, 1, 4, 1, 4], 6*cos(t), 10^-5, 5000; initials=[1, 1, -1])
82
- # prob = ODEProblem(sys, [], tspan)
83
- # sol = solve(prob, radau5(), abstol = 1e-5, reltol = 1e-5)
87
+ msys = linear_fractional_to_ordinary ([3 , 2.5 , 2 , 1 , .5 , 0 ], [1 , 1 , 1 , 4 , 1 , 4 ], 6 * cos (t), 10 ^- 5 , 5000 ; initials= [1 , 1 , - 1 ], matrix = true )
88
+ mprob = ODEProblem (sys, [], tspan)
89
+ msol = solve (prob, radau5 (), abstol = 1e-5 , reltol = 1e-5 )
84
90
85
- # @test isapprox(expect(5000), sol (5000, idxs=x_0), atol=1e-5)
91
+ @test isapprox (expect (5000 ), msol (5000 , idxs= x_0), atol= 1e-5 )
0 commit comments