Skip to content

Commit 65c4220

Browse files
Merge pull request #976 from tinosulzer/domain-sets
domain deprecations
2 parents 9915d6d + fcc0e5e commit 65c4220

File tree

8 files changed

+25
-45
lines changed

8 files changed

+25
-45
lines changed

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ DiffRules = "b552c78f-8df3-52c6-915a-8e097449b14b"
1414
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
1515
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
1616
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
17+
DomainSets = "5b8099bc-c8ec-5219-889f-1d9e522a28bf"
1718
IfElse = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173"
1819
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
1920
LabelledArrays = "2ee39098-c373-598a-b85f-a56591580800"
@@ -50,6 +51,7 @@ DiffEqJump = "6.7.5"
5051
DiffRules = "0.1, 1.0"
5152
Distributions = "0.23, 0.24, 0.25"
5253
DocStringExtensions = "0.7, 0.8"
54+
DomainSets = "0.5"
5355
IfElse = "0.1"
5456
JuliaFormatter = "0.12, 0.13"
5557
LabelledArrays = "1.3"

docs/src/systems/PDESystem.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,19 @@ PDESystem
3939

4040
Domains are specifying by saying `indepvar in domain`, where `indepvar` is a
4141
single or a collection of independent variables, and `domain` is the chosen
42-
domain type. Thus forms for the `indepvar` can be like:
42+
domain type. A 2-tuple can be used to indicate an `Interval`.
43+
Thus forms for the `indepvar` can be like:
4344

4445
```julia
45-
t IntervalDomain(0.0,1.0)
46+
t (0.0,1.0)
4647
(t,x) UnitDisk()
4748
[v,w,x,y,z] VectorUnitBall(5)
4849
```
4950

5051
#### Domain Types (WIP)
5152

52-
- `IntervalDomain(a,b)`: Defines the domain of an interval from `a` to `b`
53+
- `Interval(a,b)`: Defines the domain of an interval from `a` to `b` (requires explicit
54+
import from `DomainSets.jl`, but a 2-tuple can be used instead)
5355

5456
## `discretize` and `symbolic_discretize`
5557

src/ModelingToolkit.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ export runge_kutta_discretize
158158
export PDESystem
159159
export Reaction, ReactionSystem, ismassaction, oderatelaw, jumpratelaw
160160
export Differential, expand_derivatives, @derivatives
161-
export IntervalDomain, ProductDomain, , CircleDomain
162161
export Equation, ConstrainedEquation
163162
export Term, Sym
164163
export SymScope, LocalScope, ParentScope, GlobalScope

src/domains.jl

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,17 @@
1-
abstract type AbstractDomain{T,N} end
1+
import DomainSets: Interval, Ball, infimum, supremum
22

3-
struct VarDomainPairing
4-
variables
5-
domain::AbstractDomain
6-
end
7-
Base.:(variable::ModelingToolkit.Num,domain::AbstractDomain) = VarDomainPairing(value(variable),domain)
8-
Base.:(variables::NTuple{N,ModelingToolkit.Num},domain::AbstractDomain) where N = VarDomainPairing(value.(variables),domain)
9-
10-
## Specific Domains
11-
12-
struct IntervalDomain{T} <: AbstractDomain{T,1}
13-
lower::T
14-
upper::T
15-
end
16-
17-
18-
struct ProductDomain{D,T,N} <: AbstractDomain{T,N}
19-
domains::D
20-
end
21-
(args::AbstractDomain{T}...) where T = ProductDomain{typeof(args),T,length(args)}(args)
3+
@deprecate IntervalDomain(a,b) Interval(a,b)
4+
@deprecate CircleDomain() Ball()
225

23-
struct CircleDomain <: AbstractDomain{Float64,2}
24-
polar::Bool
25-
CircleDomain(polar=false) = new(polar)
6+
# type piracy on Interval for downstream compatibility to be reverted once upgrade is complete
7+
function Base.getproperty(domain::Interval, sym::Symbol)
8+
if sym === :lower
9+
@warn "domain.lower is deprecated, use infimum(domain) instead"
10+
return infimum(domain)
11+
elseif sym === :upper
12+
@warn "domain.upper is deprecated, use supremum(domain) instead"
13+
return supremum(domain)
14+
else
15+
return getfield(domain, sym)
16+
end
2617
end

src/systems/pde/pdesystem.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ bcs = [u(t,0) ~ 0.,# for all t > 0
2828
Dt(u(0,x)) ~ 0. ] #for all 0 < x < 1]
2929
3030
# Space and time domains
31-
domains = [t ∈ IntervalDomain(0.0,1.0),
32-
x ∈ IntervalDomain(0.0,1.0)]
31+
domains = [t ∈ (0.0,1.0),
32+
x ∈ (0.0,1.0)]
3333
3434
pde_system = PDESystem(eq,bcs,domains,[t,x],[u])
3535
```

test/domains.jl

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

test/pde.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ eq = Dt(u(t,x)) ~ Dxx(u(t,x))
99
bcs = [u(0,x) ~ - x * (x-1) * sin(x),
1010
u(t,0) ~ 0, u(t,1) ~ 0]
1111

12-
domains = [t IntervalDomain(0.0,1.0),
13-
x IntervalDomain(0.0,1.0)]
12+
domains = [t (0.0,1.0),
13+
x (0.0,1.0)]
1414

1515
pdesys = PDESystem(eq,bcs,domains,[t,x],[u])

test/runtests.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ using SafeTestsets, Test
1818
@safetestset "ReactionSystem Test" begin include("reactionsystem_components.jl") end
1919
@safetestset "JumpSystem Test" begin include("jumpsystem.jl") end
2020
@safetestset "ControlSystem Test" begin include("controlsystem.jl") end
21-
@safetestset "Domain Test" begin include("domains.jl") end
2221
@safetestset "Modelingtoolkitize Test" begin include("modelingtoolkitize.jl") end
2322
@safetestset "Constraints Test" begin include("constraints.jl") end
2423
@safetestset "Reduction Test" begin include("reduction.jl") end

0 commit comments

Comments
 (0)