Chebfun2: Exploring Constant Coefficient PDEs on Rectangles Alex Townsend Oxford University

advertisement
.
.
.
.
..
.
Chebfun2: Exploring Constant Coefficient
PDEs on Rectangles
Alex Townsend
Oxford University
with Sheehan Olver, Sydney University.
FUN13 workshop, 11th of April 2013
Alex Townsend
Constant coefficient PDEs
0/11
. A simplified history of the Chebfun project
.
.
Piecewise smooth
(2010)
.
.
.
Endpoint
singularities
(2010*)
Blow up
functions
(2011)
Reducing regularity
.
Chebfun
.
(2004)
.
.
Nonlinear ODEs
(2012)
Linear ODEs
(2008)
Chebgui
(2011*)
Ordinary differential equations
.
.
.
Piecewise
smooth
.
Arbitrary
domains
Chebfun2
(2013)
.
.
Linear PDEs
.
Nonlinear PDEs
Two dimensions
Alex Townsend
Constant coefficient PDEs
1/11
. Chebop and Chebop2: Overall workflow
L = chebop(@(x,u) diff(u,2)-x.*u, [-30 30]);
L.lbc = 1; L.rbc = 0;
u = L \ 0;
.
Convert
handle. into
discretisation
instructions
.
Construct discretisation A ∈ Rn×n
.
Impose bcs
and solve
Ãx = b
% Airy eqn
% bcs
% u = chebfun
.
Converged
to the
solution?
.yes
.
Construct
a chebfun
.no, increase n
[Driscoll, Bornemann, & Trefethen, 2008], [Birkisson & Driscoll, 2012]
Alex Townsend
Constant coefficient PDEs
2/11
. Chebop and Chebop2: Overall workflow
L = chebop(@(x,u) diff(u,2)-x.*u, [-30 30]);
L.lbc = 1; L.rbc = 0;
u = L \ 0;
.
Convert
handle. into
discretisation
instructions
.
Construct discretisation A ∈ Rn×n
.
Impose bcs
and solve
Ãx = b
% Airy eqn
% bcs
% u = chebfun
.
Converged
to the
solution?
.yes
.
Construct
a chebfun
.no, increase n
[Driscoll, Bornemann, & Trefethen, 2008], [Birkisson & Driscoll, 2012]
L = chebop2(@(u) diffx(u,2)+diffy(u,2)+100*u);
L.lbc = 1; L.rbc = 1; L.ubc = 1; L.dbc = 1;
u = L \ 0;
.
Convert
handle. into
discretisation
instructions
.
.
Impose bcs
and solve
matrix
equation
Construct a
m by n generalised Sylvester
matrix equation
.
% Helmholtz
% bcs
% u = chebfun2
Converged
to the
solution?
.yes
.
Construct
a chebfun2
.no, increase m or n or both
Alex Townsend
Constant coefficient PDEs
2/11
. The numerical rank of a matrix, function, and operator
For an m × n matrix,
∑
. Numerical Rank
min(m,n)
A=
σj uj vjT
≈
j=1
.k.
∑
σj uj vjT ,
σk+1 < tol.
j=1
For a function of two variables (this is what Chebfun2 uses),
!
f (x, y ) =
∞
∑
σj uj (y )vj (x) ≈
.k.
∑
j=1
σj uj (y )vj (x).
j=1
For operators acting on functions of two variables,
!
L=
∞
∑
σj Lyj
⊗
Lxj
j=1
≈
.k.
∑
σj . Lyj ⊗.. Lxj .
j=1
.
Discretise by a 1D spectral method [Olver & T., 2013]
.
Alex Townsend
Constant coefficient PDEs
3/11
. Determining the rank of a PDE operator
Given a PDE with constant coefficients of the form,
L=
N N−j
∑
∑
j=0 i=0
aij
∂ i+j
,
∂ i x∂ j y
We can rewrite this as
L = D(y )T AD(x),
.A. = (aij ) ,
.
Find by AD, thanks A. Birkisson
 0

∂ /∂x 0


..
D(x) = 
.
.
∂ N /∂x N
Hence, if A = UΣV T is the truncated SVD of A then
(
)
(
) (
)
L = D(y )T UΣV T D(x) = D(y )T U Σ V T D(x) .
This low rank representation for L tells us how to discretize and
solve the PDE.
.
Alex Townsend
Constant coefficient PDEs
4/11
. Examples
Helmholtz is of rank 2,
uxx + uyy + 100u = (uxx + 50u) + (uyy + 50u) .
The SVD obtains the rank 2 expression,
(
)
uxx + uyy + 100u = 100.009.. −0.009..uyy − 0.999..u (−0.009..uxx − 0.999..u)
(
)
+ 0.009.. 0.999..uyy − 0.009..u (0.009..uxx − 0.999..u) .
.
.
Rank
1:
.
Rank 3:
Almost everything else
ODEs
Trivial PDEs
.
Rank 2:
Laplace
Helmholtz
Transport
Heat
Wave
.
.
Alex Townsend
The method of separation
of variables is useful.
Constant coefficient PDEs
5/11
. Construct a m by n generalised Sylvester matrix equation
If the PDE is Lu = f , where L is of rank-k then we solve for
X ∈ Rm×n in,
k
∑
σj Aj XB
. jT = F ,
Aj .∈ Rm×m , . Bj ∈ Rn×n .
j=1
.
solution’s coefficients
(
.
1D spectral discretization of Lyj , Lxj .
)
Aj =
Alex Townsend
Constant coefficient PDEs
6/11
. Matrix equation solvers
Rank-1: A1 XB1T = F . Solve A1 Y = F , then B1 X T = Y T .
Rank-2: A1 XB1T + A2 XB2T = F . Generalised Bartels–Stewart
algorithm [Gardener, Laub, Amato, & Moler, 1992]
Rank-k, k ≥ 3: Solve mn × mn system with ‘\’ in Matlab.
2
Time to solve matrix equation
10
O(m2 n2 )
O(m3 + n3 )
Solve time
0
10
O(mn)
−2
10
k=1
k=2
k≥3
−4
10
500
Alex Townsend
1000
m&n
1500
2000
Constant coefficient PDEs
7/11
. Have we converged? (simplified version)
Increase m and n until the tail of the solution’s Chebyshev
coefficients is near/below machine precision, and then truncate.
Always 2j + 1−→
←−−−−−−− Truncated
coefficients
These coefficients can then be used by Chebfun2 to construct a
low rank function approximation [T. & Trefethen, 2013].
Alex Townsend
Constant coefficient PDEs
8/11
. Overview and recap
L = chebop2(@(u) diffx(u,2)+diffy(u,2)+100*u);
L.lbc = 1; L.rbc = 1; L.ubc = 1; L.dbc = 1;
u = L \ 0;
.
Convert
handle. into
discretisation
instructions
.
.
Impose bcs
and solve
matrix
equation
Construct a
m by n generalised Sylvester
matrix equation
.
% Helmholtz
% bcs
% u = chebfun2
Converged
to the
solution?
.yes
.
Construct
a chebfun2
.no, increase m or n or both
Alex Townsend
Constant coefficient PDEs
9/11
. Demo
DEMO
Alex Townsend
Constant coefficient PDEs
10/11
. Future Work
I would like to be able to do “vector-valued PDEs” such as
Stokes equation: For Ω = [−1, 1] × [−1, 1],
∫
1
∫
−∇2~u + ∇p = ~f in Ω,
∇ · ~u = 0 in Ω,
~u = 0 on ∂Ω,
1
p(x, y )dxdy = 0
−1
in Ω.
−1
Aiming for the following Chebfun2 syntax:
N = chebop2v(@(u,p) [-lap(u) + grad(p); div(u)]);
N.lbc = 0; N.rbc = 0; N.ubc = 0; N.dbc = 0;
N.bc = @(u,p) sum2(p);
uu = N \ [f;0];
Alex Townsend
Constant coefficient PDEs
11/11
. References
[Birkisson & Driscoll, 2012] Automatic Fréchet differentiation
for the numerical solution of boundary-value problems, (ACM
Trans. Math. Softw., 2012).
[Driscoll, Bornemann, & Trefethen, 2008] The chebop system
for automatic solution of differential equations (BIT Numer.
Math., 2008).
[Gardener, Laub, Amato, & Moler, 1992] Solution of the
Sylvester matrix equation AXB T + CXD T = E , (ACM Trans.
Math. Softw., 1992).
[Olver & T., 2013] A fast and well-conditioned spectral method,
(to appear in SIAM Review, 2013).
[T. & Trefethen, 2013] An extension of Chebfun to two
dimensions, (submitted, 2013).
Alex Townsend
Constant coefficient PDEs
12/11
Download