Skip to content

Commit e79b9fe

Browse files
committed
Began test fix
1 parent 47f0659 commit e79b9fe

File tree

5 files changed

+31
-69
lines changed

5 files changed

+31
-69
lines changed

Project.toml

Lines changed: 1 addition & 0 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"

src/MethodOfLines.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module MethodOfLines
22
using LinearAlgebra
33
using SciMLBase
44
using DiffEqBase
5+
using DiffEqOperators
56
using ModelingToolkit
67
using SymbolicUtils, Symbolics
78
import DomainSets

src/discretization/differential_discretizer.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Use DiffEqOperators to generate weights and calculate derivative orders
22
struct DifferentialDiscretizer{T}
33
approx_order
4-
map::Dict{Num, DerivativeOperator}
5-
nonlinlapmap::Tuple{DerivativeOperator, DerivativeOperator}
4+
map::Dict{Num, DiffEqOperators.DerivativeOperator}
5+
nonlinlapmap::Dict{Num, NTuple{2, DiffEqOperators.DerivativeOperator}}
66
orders::Vector{T}
77
end
88

@@ -11,8 +11,8 @@ function DifferentialDiscretizer(pde, s, discretization)
1111
d_orders(x) = reverse(sort(collect(union(differential_order(pde.rhs, x), differential_order(pde.lhs, x)))))
1212

1313
# central_deriv_rules = [(Differential(s)^2)(u) => central_deriv(2,II,j,k) for (j,s) in enumerate(s.nottime), (k,u) in enumerate(s.vars)]
14-
differentialmap = Array{Pair{Num,DerivativeOperator},1}()
15-
nonlinlap = Array{Pair{Num, NTuple{2,DerivativeOperator}}}(undef, nparams(s))
14+
differentialmap = Array{Pair{Num,DiffEqOperators.DerivativeOperator},1}()
15+
nonlinlap = Array{Pair{Num, NTuple{2,DiffEqOperators.DerivativeOperator}}}(undef, nparams(s))
1616
orders = Int[]
1717
# Hardcoded to centered difference, generate weights for each differential
1818
# TODO: Add handling for upwinding

test/components/finite_diff_schemes.jl

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,40 @@ indvars = [x, t]
77
nottime = [x]
88
depvars = [u]
99

10-
Dx = Differential(x)
10+
Dx(d) = Differential(x)^d
1111
Dt = Differential(t)
1212

1313
t_min= 0.
1414
t_max = 2.0
1515
x_min = 0.
16-
x_max = 2.
16+
x_max = 20.0
1717

18-
dx = 0.1
18+
dx = 1.0
1919
order = 2
2020

2121
domains = [t Interval(t_min, t_max), x Interval(x_min, x_max)]
2222

2323

24-
@testset "Test 01: discretization of variables, center aligned grid" begin
25-
pde = Dt(u) ~ Dx(u)
26-
# Test centered order
27-
disc = MOLFiniteDifference([x=>dx], t; centered_order=order)
28-
29-
s = MethodOfLines.DiscreteSpace(domains, depvars, indvars, nottime, disc)
30-
31-
derivweights = MethodOfLines.DifferentialDiscretizer(pde, s, disc)
32-
33-
II = s.Igrid[10]
34-
35-
rules = MethodOfLines.generate_finite_difference_rules(II, s, pde, derivweights)
36-
disc_pde=substitute(pde.lhs,rules) ~ substitute(pde.rhs,rules)
24+
@testset "Test 01: Cartesian derivative discretization" begin
25+
weights = []
26+
push!(weights, ([-0.5,0,0.5], [1.,-2.,1.], [-1/2,1.,0.,-1.,1/2]))
27+
push!(weights, ([1/12, -2/3,0,2/3,-1/12], [-1/12,4/3,-5/2,4/3,-1/12], [1/8,-1.,13/8,0.,-13/8,1.,-1/8]))
28+
for d in 1:3
29+
for a in [2,4]
30+
pde = Dt(u) ~ Dx(d)(u)
31+
# Test centered order
32+
disc = MOLFiniteDifference([x=>dx], t; centered_order=order)
33+
34+
s = MethodOfLines.DiscreteSpace(domains, depvars, indvars, nottime, disc)
35+
36+
derivweights = MethodOfLines.DifferentialDiscretizer(pde, s, disc)
37+
38+
II = s.Igrid[10]
39+
40+
rules = MethodOfLines.generate_finite_difference_rules(II, s, pde, derivweights)
41+
@show rules
42+
disc_pde=substitute(pde.lhs,rules) ~ substitute(pde.rhs,rules)
43+
@show disc_pde
44+
end
45+
end
3746
end

test/regression_test.jl

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)