Skip to content

Commit ce86d8c

Browse files
Merge pull request #414 from SciML/straydiffs
Handle D(0.001) type of post rule subsitutions
2 parents 16ffb05 + 7a7f959 commit ce86d8c

File tree

7 files changed

+14
-15
lines changed

7 files changed

+14
-15
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "MethodOfLines"
22
uuid = "94925ecb-adb7-4558-8ed8-f975c56a0bf4"
33
authors = ["Alex Jones, <[email protected]>"]
4-
version = "0.11.3"
4+
version = "0.11.4"
55

66
[deps]
77
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"

src/MethodOfLines.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ using ModelingToolkit: operation, iscall, arguments, variable, get_metadata, get
77
parameters, defaults, varmap_to_vars
88
using SymbolicIndexingInterface
99
using SymbolicUtils, Symbolics
10-
using Symbolics: unwrap, solve_for, expand_derivatives, diff2term, setname, rename
10+
using Symbolics: unwrap, symbolic_linear_solve, expand_derivatives, diff2term, setname, rename
1111
using SymbolicUtils: operation, arguments
1212
using IfElse
1313
using StaticArrays

src/discretization/generate_ic_defaults.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function PDEBase.generate_ic_defaults(tconds, s::DiscreteSpace,
1111
indexmap = Dict([args[i] => i for i in 1:length(args)])
1212
D = ic.order == 0 ? identity : (Differential(t)^ic.order)
1313
defaultvars = D.(s.discvars[depvar(ic.u, s)])
14-
broadcastable_rhs = [solve_for(ic.eq, D(ic.u))]
14+
broadcastable_rhs = [symbolic_linear_solve(ic.eq, D(ic.u))]
1515
out = substitute.(
1616
broadcastable_rhs, valmaps(s, depvar(ic.u, s), ic.depvars, indexmap))
1717
vec(defaultvars .=>

src/scalar_discretization.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function discretize_equation_at_point(
4343
boundaryrules,
4444
valmaps(s, eqvar, depvars, II, indexmap))
4545
try
46-
return substitute(pde.lhs, rules) ~ substitute(pde.rhs, rules)
46+
return expand_derivatives(substitute(pde.lhs, rules)) ~ substitute(pde.rhs, rules)
4747
catch e
4848
println("A scheme has been incorrectly applied to the following equation: $pde.\n")
4949
println("The following rules were constructed at index $II:")

src/system_parsing/pde_system_transformation.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ function generate_bc_rules(bcs, v)
271271
deriv = bc.order == 0 ? identity : (Differential(bc.x)^bc.order)
272272
bcrule_lhs = deriv(operation(bc.u)(v.args[operation(bc.u)]...))
273273
bcterm = deriv(bc.u)
274-
rhs = solve_for(bc.eq, bcterm)
274+
rhs = symbolic_linear_solve(bc.eq, bcterm)
275275
bcrule_lhs => rhs
276276
end
277277
end

test/pde_systems/MOL_Mixed_Deriv.jl

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,15 @@ using ModelingToolkit: Differential
3434
dx = (xmax - xmin) / 20
3535
discretization = MOLFiniteDifference([x => dx], t, advection_scheme = WENOScheme())
3636

37-
@test_broken (discretize(pdesys, discretization) isa ODEProblem)
38-
# prob = discretize(pdesys, discretization)
39-
# sol = solve(prob, FBDF())
37+
prob = discretize(pdesys, discretization)
38+
sol = solve(prob, FBDF())
4039

41-
# xdisc = sol[x]
42-
# tdisc = sol[t]
43-
# usol = sol[u(t,x)]
40+
xdisc = sol[x]
41+
tdisc = sol[t]
42+
usol = sol[u(t,x)]
4443

45-
# asol = [assf(t, x) for t in tdisc, x in xdisc]
46-
# @test_broken usol ≈ asol atol = 1e-3
44+
asol = [assf(t, x) for t in tdisc, x in xdisc]
45+
@test_broken usol asol atol = 1e-3
4746
end
4847

4948
@testset "Test 01: Dt(u) ~ Dxy(u)" begin

test/pde_systems/MOLtest2.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ using Test
4040
diff_eq = ∂t(c(x, t)) ~ ∂x(D * ∂x(c(x, t)))
4141
@named pdesys = PDESystem(diff_eq, bcs, domains, [x, t], [c(x, t)])
4242
discretization = MOLFiniteDifference([x => Δx], t)
43-
@test_broken (discretize(pdesys, discretization) isa ODEProblem)
43+
@test (discretize(pdesys, discretization) isa ODEProblem)
4444
end
4545

4646
@testset "Test 02: ∂t(c(x, t)) ~ ∂x(D * ∂x(c(x, t)))" begin
@@ -63,7 +63,7 @@ using Test
6363
diff_eq = ∂t(c(x, t)) ~ ∂x(D₀ / (1.0 + exp* (c(x, t) - χ))) * ∂x(c(x, t)))
6464
@named pdesys = PDESystem(diff_eq, bcs, domains, [x, t], [c(x, t)])
6565
discretization = MOLFiniteDifference([x => Δx], t)
66-
@test_broken (discretize(pdesys, discretization) isa ODEProblem)
66+
@test (discretize(pdesys, discretization) isa ODEProblem)
6767
end
6868

6969
@testset "Test 05: ∂t(c(x, t)) ~ ∂x(1/x * ∂x(c(x, t)))" begin

0 commit comments

Comments
 (0)