1
+ using ModelingToolkit, OrdinaryDiffEq, ODEInterfaceDiffEq, SpecialFunctions
2
+ using Test
3
+
4
+ # Testing for α < 1
5
+ # Uses example 1 from Section 7 of https://arxiv.org/pdf/2506.04188
6
+ @independent_variables t
7
+ @variables x (t)
8
+ D = Differential (t)
9
+ tspan = (0. , 1. )
10
+
11
+ function expect (t, α)
12
+ return (3 / 2 * t^ (α/ 2 ) - t^ 4 )^ 2
13
+ end
14
+
15
+ α = 0.5
16
+ eqs = (9 * gamma (1 + α)/ 4 ) - (3 * t^ (4 - α/ 2 )* gamma (5 + α/ 2 )/ gamma (5 - α/ 2 ))
17
+ eqs += (gamma (9 )* t^ (8 - α)/ gamma (9 - α)) + (3 / 2 * t^ (α/ 2 )- t^ 4 )^ 3 - x^ (3 / 2 )
18
+ sys = fractional_to_ordinary (eqs, x, α, 10 ^- 7 , 1 )
19
+
20
+ prob = ODEProblem (sys, [], tspan)
21
+ sol = solve (prob, radau5 (), abstol = 1e-10 , reltol = 1e-10 )
22
+
23
+ time = 0
24
+ while (time <= 1 )
25
+ @test isapprox (expect (time, α), sol (time, idxs= x), atol= 1e-3 )
26
+ time += 0.1
27
+ end
28
+
29
+ α = 0.3
30
+ eqs = (9 * gamma (1 + α)/ 4 ) - (3 * t^ (4 - α/ 2 )* gamma (5 + α/ 2 )/ gamma (5 - α/ 2 ))
31
+ eqs += (gamma (9 )* t^ (8 - α)/ gamma (9 - α)) + (3 / 2 * t^ (α/ 2 )- t^ 4 )^ 3 - x^ (3 / 2 )
32
+ sys = fractional_to_ordinary (eqs, x, α, 10 ^- 7 , 1 )
33
+
34
+ prob = ODEProblem (sys, [], tspan)
35
+ sol = solve (prob, radau5 (), abstol = 1e-10 , reltol = 1e-10 )
36
+
37
+ time = 0
38
+ while (time <= 1 )
39
+ @test isapprox (expect (time, α), sol (time, idxs= x), atol= 1e-3 )
40
+ time += 0.1
41
+ end
42
+
43
+ α = 0.9
44
+ eqs = (9 * gamma (1 + α)/ 4 ) - (3 * t^ (4 - α/ 2 )* gamma (5 + α/ 2 )/ gamma (5 - α/ 2 ))
45
+ eqs += (gamma (9 )* t^ (8 - α)/ gamma (9 - α)) + (3 / 2 * t^ (α/ 2 )- t^ 4 )^ 3 - x^ (3 / 2 )
46
+ sys = fractional_to_ordinary (eqs, x, α, 10 ^- 7 , 1 )
47
+
48
+ prob = ODEProblem (sys, [], tspan)
49
+ sol = solve (prob, radau5 (), abstol = 1e-10 , reltol = 1e-10 )
50
+
51
+ time = 0
52
+ while (time <= 1 )
53
+ @test isapprox (expect (time, α), sol (time, idxs= x), atol= 1e-3 )
54
+ time += 0.1
55
+ end
56
+
57
+ # Testing for example 2 of Section 7
58
+ @independent_variables t
59
+ @variables x (t) y (t)
60
+ D = Differential (t)
61
+ tspan = (0. , 220. )
62
+
63
+ sys = fractional_to_ordinary ([1 - 4 * x + x^ 2 * y, 3 * x - x^ 2 * y], [x, y], [1.3 , 0.8 ], 10 ^- 6 , 220 ; initials= [[1.2 , 1 ], 2.8 ])
64
+ prob = ODEProblem (sys, [], tspan)
65
+ sol = solve (prob, radau5 (), abstol = 1e-8 , reltol = 1e-8 )
66
+
67
+ @test isapprox (1.0097684171 , sol (220 , idxs= x), atol= 1e-3 )
68
+ @test isapprox (2.1581264031 , sol (220 , idxs= y), atol= 1e-3 )
0 commit comments