Skip to content

Commit ecf80af

Browse files
Merge pull request #30 from xtalax/master
Fix tests
2 parents b1d5d33 + 32067b5 commit ecf80af

File tree

3 files changed

+80
-4
lines changed

3 files changed

+80
-4
lines changed

Project.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ version = "0.1.0"
55

66
[deps]
77
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
8+
DiffEqOperators = "9fdde737-9c7f-55bf-ade8-46b3f136cc48"
89
DomainSets = "5b8099bc-c8ec-5219-889f-1d9e522a28bf"
910
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1011
ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
@@ -17,11 +18,11 @@ Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
1718
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1819

1920
[compat]
20-
OrdinaryDiffEq = "6"
21-
ModelingToolkit = "8"
22-
SymbolicUtils = "0.19"
23-
SafeTestsets = "0.0.1"
2421
DomainSets = "0.5"
22+
ModelingToolkit = "8"
2523
NonlinearSolve = "0.3"
24+
OrdinaryDiffEq = "6"
25+
SafeTestsets = "0.0.1"
2626
SciMLBase = "1"
27+
SymbolicUtils = "0.19"
2728
Symbolics = "4"

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ if GROUP == "All" || GROUP == "MOLFiniteDifference"
1717
@time @safetestset "MOLFiniteDifference Interface: 1D HigherOrder" begin include("pde_systems/MOL_1D_HigherOrder.jl") end
1818
@time @safetestset "MOLFiniteDifference Interface: 1D Partial DAE" begin include("pde_systems/MOL_1D_PDAE.jl") end
1919
@time @safetestset "MOLFiniteDifference Interface: Stationary Nonlinear Problems" begin include("pde_systems/MOL_NonlinearProblem.jl") end
20+
@time @safetestset "MOLFiniteDifference Utils" begin include("utils_test.jl") end
2021
end
2122

2223
end

test/utils_test.jl

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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

Comments
 (0)