1+ using MethodOfLines, Test, ModelingToolkit
2+
3+ @testset " count differentials 1D" begin
4+ @parameters t x
5+ @variables u (.. )
6+ Dt = Differential (t)
7+
8+ Dx = Differential (x)
9+ eq = Dt (u (t,x)) ~ - Dx (u (t,x))
10+ @test first (MethodOfLines. differential_order (eq. rhs, x. val)) == 1
11+ @test isempty (MethodOfLines. differential_order (eq. rhs, t. val))
12+ @test first (MethodOfLines. differential_order (eq. lhs, t. val)) == 1
13+ @test isempty (MethodOfLines. differential_order (eq. lhs, x. val))
14+
15+ Dxx = Differential (x)^ 2
16+ eq = Dt (u (t,x)) ~ Dxx (u (t,x))
17+ @test first (MethodOfLines. differential_order (eq. rhs, x. val)) == 2
18+ @test isempty (MethodOfLines. differential_order (eq. rhs, t. val))
19+ @test first (MethodOfLines. differential_order (eq. lhs, t. val)) == 1
20+ @test isempty (MethodOfLines. differential_order (eq. lhs, x. val))
21+
22+ Dxxxx = Differential (x)^ 4
23+ eq = Dt (u (t,x)) ~ - Dxxxx (u (t,x))
24+ @test first (MethodOfLines. differential_order (eq. rhs, x. val)) == 4
25+ @test isempty (MethodOfLines. differential_order (eq. rhs, t. val))
26+ @test first (MethodOfLines. differential_order (eq. lhs, t. val)) == 1
27+ @test isempty (MethodOfLines. differential_order (eq. lhs, x. val))
28+ end
29+
30+ @testset " count differentials 2D" begin
31+ @parameters t x y
32+ @variables u (.. )
33+ Dxx = Differential (x)^ 2
34+ Dyy = Differential (y)^ 2
35+ Dt = Differential (t)
36+
37+ eq = Dt (u (t,x,y)) ~ Dxx (u (t,x,y)) + Dyy (u (t,x,y))
38+ @test first (MethodOfLines. differential_order (eq. rhs, x. val)) == 2
39+ @test first (MethodOfLines. differential_order (eq. rhs, y. val)) == 2
40+ @test isempty (MethodOfLines. differential_order (eq. rhs, t. val))
41+ @test first (MethodOfLines. differential_order (eq. lhs, t. val)) == 1
42+ @test isempty (MethodOfLines. differential_order (eq. lhs, x. val))
43+ @test isempty (MethodOfLines. differential_order (eq. lhs, y. val))
44+ end
45+
46+ @testset " count with mixed terms" begin
47+ @parameters t x y
48+ @variables u (.. )
49+ Dxx = Differential (x)^ 2
50+ Dyy = Differential (y)^ 2
51+ Dx = Differential (x)
52+ Dy = Differential (y)
53+ Dt = Differential (t)
54+
55+ eq = Dt (u (t,x,y)) ~ Dxx (u (t,x,y)) + Dyy (u (t,x,y)) + Dx (Dy (u (t,x,y)))
56+ @test MethodOfLines. differential_order (eq. rhs, x. val) == Set ([2 , 1 ])
57+ @test MethodOfLines. differential_order (eq. rhs, y. val) == Set ([2 , 1 ])
58+ end
59+
60+ @testset " Kuramoto–Sivashinsky equation" begin
61+ @parameters x, t
62+ @variables u (.. )
63+ Dt = Differential (t)
64+ Dx = Differential (x)
65+ Dx2 = Differential (x)^ 2
66+ Dx3 = Differential (x)^ 3
67+ Dx4 = Differential (x)^ 4
68+
69+ α = 1
70+ β = 4
71+ γ = 1
72+ eq = Dt (u (x,t)) + u (x,t)* Dx (u (x,t)) + α* Dx2 (u (x,t)) + β* Dx3 (u (x,t)) + γ* Dx4 (u (x,t)) ~ 0
73+ @test MethodOfLines. differential_order (eq. lhs, x. val) == Set ([4 , 3 , 2 , 1 ])
74+ end
0 commit comments