Skip to content

Commit 940f9d8

Browse files
Merge pull request #575 from SciML/pdesystem
start PDESystem documentation
2 parents e0bbacc + 039be84 commit 940f9d8

File tree

3 files changed

+139
-1
lines changed

3 files changed

+139
-1
lines changed

docs/src/basics/FAQ.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,20 @@ lowered array? You can use the internal function `varmap_to_vars`. For example:
2121
```julia
2222
pnew = varmap_to_vars([β=>3.0, c=>10.0, γ=>2.0],parameters(sys))
2323
```
24+
25+
## Embedding data into a symbolic model
26+
27+
Let's say for example you want to embed data for the timeseries of some
28+
forcing equations into the right-hand side of and ODE, or data into a PDE. What
29+
you would do in these cases is use the `@register` function over an interpolator.
30+
For example, [DataInterpolations.jl](https://github.com/PumasAI/DataInterpolations.jl)
31+
is a good library for interpolating the data. Then you can do:
32+
33+
```julia
34+
spline = CubicSpline(data,datat)
35+
f(t) = spline(t)
36+
@register f(t)
37+
```
38+
39+
This will make `f(t)` be a function that Symbolics.jl will not attempt to trace.
40+
One should also consider defining the derivative to the function, if available.

docs/src/systems/PDESystem.md

Lines changed: 79 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,81 @@
11
# PDESystem
22

3-
`PDESystem` is still a work in progress.
3+
`PDESystem` is the common symbolic PDE specification for the SciML ecosystem.
4+
It is currently being built as a component of the ModelingToolkit ecosystem,
5+
6+
## Vision
7+
8+
The vision for the common PDE interface is that a user should only have to specify
9+
their PDE once, mathematically, and have instant access to everything as simple
10+
as a finite difference method with constant grid spacing, to something as complex
11+
as a distributed multi-GPU discrete Galerkin method.
12+
13+
The key to the common PDE interface is a separation of the symbolic handling from
14+
the numerical world. All of the discretizers should not "solve" the PDE, but
15+
instead be a conversion of the mathematical specification to a numerical problem.
16+
Preferably, the transformation should be to another ModelingToolkit.jl `AbstractSystem`,
17+
but in some cases this cannot be done or will not be performant, so a `SciMLProblem` is
18+
the other choice.
19+
20+
These elementary problems, such as solving linear systems `Ax=b`, solving nonlinear
21+
systems `f(x)=0`, ODEs, etc. are all defined by SciMLBase.jl, which then numerical
22+
solvers can all target these common forms. Thus someone who works on linear solvers
23+
doesn't necessarily need to be working on a DG or finite element library, but
24+
instead "linear solvers that are good for matrices A with properties ..." which
25+
are then accessible by every other discretization method in the common PDE interface.
26+
27+
Similar to the rest of the `AbstractSystem` types, transformation and analyses
28+
functions will allow for simplifying the PDE before solving it, and constructing
29+
block symbolic functions like Jacobians.
30+
31+
## Constructors
32+
33+
```@docs
34+
PDESystem
35+
```
36+
37+
### Domains (WIP)
38+
39+
Domains are specifying by saying `indepvar in domain`, where `indepvar` is a
40+
single or a collection of independent variables, and `domain` is the chosen
41+
domain type. Thus forms for the `indepvar` can be like:
42+
43+
```julia
44+
t IntervalDomain(0.0,1.0)
45+
(t,x) UnitDisk()
46+
[v,w,x,y,z] VectorUnitBall(5)
47+
```
48+
49+
#### Domain Types (WIP)
50+
51+
- `IntervalDomain(a,b)`: Defines the domain of an interval from `a` to `b`
52+
53+
## `discretize` and `symbolic_discretize`
54+
55+
The only functions which act on a PDESystem are the following:
56+
57+
- `discretize(sys,discretizer)`: produces the outputted `AbstractSystem` or
58+
`SciMLProblem`.
59+
- `symbolic_discretize(sys,discretizer)`: produces a debugging symbolic description
60+
of the discretized problem.
61+
62+
## Boundary Conditions (WIP)
63+
64+
## Transformations
65+
66+
## Analyses
67+
68+
## Discretizer Ecosystem
69+
70+
### NeuralPDE.jl: PhysicsInformedNN
71+
72+
[NeuralPDE.jl](https://github.com/SciML/NeuralPDE.jl) defines the `PhysicsInformedNN`
73+
discretizer which uses a [DiffEqFlux.jl](https://github.com/SciML/DiffEqFlux.jl)
74+
neural network to solve the differential equation.
75+
76+
### DiffEqOperators.jl: MOLFiniteDifference (WIP)
77+
78+
[DiffEqOperators.jl](https://github.com/SciML/DiffEqOperators.jl) defines the
79+
`MOLFiniteDifference` discretizer which performs a finite difference discretization
80+
using the DiffEqOperators.jl stencils. These stencils make use of NNLib.jl for
81+
fast operations on semi-linear domains.

src/systems/pde/pdesystem.jl

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,53 @@
1+
"""
2+
$(TYPEDEF)
3+
4+
A system of partial differential equations.
5+
6+
# Fields
7+
$(FIELDS)
8+
9+
# Example
10+
11+
```
12+
using ModelingToolkit
13+
14+
@parameters t, x
15+
@variables u(..)
16+
Dxx = Differential(x)^2
17+
Dtt = Differential(t)^2
18+
Dt = Differential(t)
19+
20+
#2D PDE
21+
C=1
22+
eq = Dtt(u(t,x)) ~ C^2*Dxx(u(t,x))
23+
24+
# Initial and boundary conditions
25+
bcs = [u(t,0) ~ 0.,# for all t > 0
26+
u(t,1) ~ 0.,# for all t > 0
27+
u(0,x) ~ x*(1. - x), #for all 0 < x < 1
28+
Dt(u(0,x)) ~ 0. ] #for all 0 < x < 1]
29+
30+
# Space and time domains
31+
domains = [t ∈ IntervalDomain(0.0,1.0),
32+
x ∈ IntervalDomain(0.0,1.0)]
33+
34+
pde_system = PDESystem(eq,bcs,domains,[t,x],[u])
35+
```
36+
"""
137
struct PDESystem <: ModelingToolkit.AbstractSystem
38+
"The equations which define the PDE"
239
eqs
40+
"The boundary conditions"
341
bcs
42+
"The domain for the independent variables."
443
domain
44+
"The independent variables"
545
indvars
46+
"The dependent variables"
647
depvars
48+
"The parameters"
749
ps
50+
"The default values of the parameters"
851
default_p
952
@add_kwonly function PDESystem(eqs, bcs, domain, indvars, depvars, ps = SciMLBase.NullParameters(), default_p = nothing)
1053
new(eqs, bcs, domain, indvars, depvars, ps, default_p)

0 commit comments

Comments
 (0)