Académique Documents
Professionnel Documents
Culture Documents
Author:
Javier I. Camacho Hernandez
Contents
1 Spectral Methods 3
1.1 Method of Weighted Residual(MWR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Basis Function Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.3 Spectral Schemes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.4 Pseudo-Spectral Approximation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.5 Lagrangian Polynomial Basis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.6 Differentiation Matrix DN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.7 Multi-dimension . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1
7 2D Pseudo-Spectral Galerkin Method 21
7.1 Discretization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
7.2 Matlab Implementation (2D Galerkin Method) . . . . . . . . . . . . . . . . . . . . . . . . 22
7.2.1 Set-up Grid and Differentiation Matrix . . . . . . . . . . . . . . . . . . . . . . . . 22
7.2.2 Dirichlet Boundary Condition Implementation . . . . . . . . . . . . . . . . . . . . 22
7.2.3 Direct Solver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
7.3 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
7.3.1 Collocation Points Representation . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
7.3.2 A Matrix Inspection(Before/After BCs Implementation) . . . . . . . . . . . . . . 23
7.3.3 Numerical vs Analytical . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
7.3.4 Error Distribution Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
7.3.5 Convergence Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2
1. Spectral Methods
In this section it is describe the discretization in general terms, in order to explain the properties that both
method,pseudo-spectral collocation and Galerkin Method, has in common and the specific differences will
be explained at the corresponding sections.
L (x) = f (x) x (1.1)
n
(x)
X
= (x) = ai i (x) i = 0, 1, 2, , n (1.2)
i=0
L (x) f (x) = R(x) 6= 0 (1.3)
Z
R(x)Wi (x) dx = 0 (1.4)
Where:
L:Differential Operator
i (x):Basis functions/Trial Functions/Expansions Functions
The main purpose it is to approximate the (x) by (x) which is a linear combination of the basis
functions selected from a linearly independent set (Orthogonal). The MWR force the residual to zero in
some average sense over the domain .The number of Wi (x) is exactly equal of the number of unknown
constants ai in (x).
3
1.2 Basis Function Selection
The expansion basis functions i (x) in the Spectral Method are infinitely global functions and mutually
orthogonal with respect the positive weight functions Wi (x). The selection procedure of the basis
functions is differ between the multiple spectral schemes,the Galerkin,Collocation and Tau Methods.
Zb (
1, if m = n
n (x)m (x)w(x) dx (1.5)
0, otherwise
a
Where:
N ):Approximation solution of (x) (x)
= N
hi (x):Basis functions
i :Interpolation coefficients.
xi :Sampling points (Collocation Points in the case of the collocation method).
The unknowns i are the approximated values of the function (x) at the sampling points xi .In the
pseudo-spectral approximation the basis functions hi has to satisfy the requirements hi = ij N = i .
In a similar manner as the Spectral Methods, the approximations of the unknown coefficients i in the
Pseudo-Spectral approximations can be calculated by using Collocation,Galerkin or Tau schemes.
The advantage of the pseudo-spectral with respect the spectral method is that,the procedure enables
to solve directly for the function values i at the sampling points xi , which is often preferred over the
indirect approach of spectral methods, where one has to first calculate the interpolation coefficients ai .
4
1.5 Lagrangian Polynomial Basis
As it mentioned before the basis functionshi = ij N = i ,so that the solution directly gives the
function values at the sampling points. The implemented basis functions are the Lagrangian Polynomials
p(x) and they are defined by the following expression:
N N
1 Y Y
pj (x) = (x xk ) , aj = (xi xk ) (1.7)
aj
k=0,k6=j k=0,k6=j
N
0 X
pj (x) = pj (x) (x xk )1 (1.10)
k=0,k6=j
It is denoted the function values vi = p(xi ) at the grid point xi ,and the corresponding derivative wi =
0
p (xi ). This is a linear operation from v to w,further more this operation can be represented by a
differentiation matrix.
w = DN v (1.12)
0
The Eq.(1.9) can be compared with the Eq.(1.12),it is clear that the polynomial pj (x) correspond to the
Dij term. The differentiation matrix Dij it is calculated by substituting the sampling or collocations
points in Eq.(1.10).This procedure it is performed in this report, by implementing the provided Matlab
files (MimeticpolyVal.m,LegendreVal.m,GLLnodes.m) (this files are not include in the report).
1.7 Multi-dimension
This section is a brief explanation on how to extend the 1D problem to a 2D.The dimension is extended
by using the tensor product rule to obtain a tensor product grid from the 1D grid. The discrete Laplace
operator in a 2D = [1, 1] can be formulated by using the tensor product:
2 2
LN = I DN + DN I (1.13)
5
2. 1D Diffusion Problem Definition
The main purpose of this problem is to use pseudo-spectral collocation method(CM) and Spectral Finite
Element Method (Galerkin Method(GM))to solve a 1-D steady diffusion problem (Elliptic PDE).In both
cases the collocations points (for CM) and the nodes for the quadrature rule (for GM)are the roots of a
Gauss-Lobatto Legendre(GLL) polynomial,which are defined in the domain [1, 1].
Governing Equation
2 (x) = sin(x) = f (x) (2.1)
Domain
= [1, 1] (2.2)
Analytical Solution
1
(x) = sin(x) (2.4)
2
L (x) = f (x) x (2.5)
N
X
N (x) = i hi (x) = p(x) i = 0, 1, , 2 , N (2.6)
i=0
6
3. 1D Pseudo-Spectral Collocation Method
3.1 Discretization
d2 (x)
= f (x) x : [1, 1] (3.1)
dx2
N
X
2
Dij j (x) = f (xi ) i = 0, 2, , N (3.3)
j=0
This is a linear system of equations, and the matrix coefficients is a full matrix.The solution it is
implemented by a direct solver method (Gaussian elimination in Matlab.)
7
3.3 Matlab Implementation(1D Collocation Method)
3.3.1 Set-up Grid and Differentiation Matrix
8
3.4 Results
3.4.1 Collocation Points Representation
0.4
Nodes = 16
0.3
0.2
0.1
-0.1
-0.2
-0.3
-0.4
-0.5
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
x
10
12
14
16
0 2 4 6 8 10 12 14 16
nz = 256
10
12
14
16
0 2 4 6 8 10 12 14 16
nz = 226
9
3.4.3 Numerical vs Analytical
0.05
||Error||2 = 1.1753e-12
(x)
0 Nodes = 16
-0.05
-0.1
-0.15
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
x
-5
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
x
100
10-5
||Error|| 2
10-10
10-15
10 20 30 40 50 60 70 80 90 100
N
10
4. 1D Pseudo-Spectral Galerkin Method
4.1 Discretization
Strong Formulation
uxx (x) = f (x) x : [1, 1] (4.1)
Insert Test Function v and integrate on both sides
Z Z
uxx v dx = f v dx (4.2)
As it mentioned before in the pseudo-spectral Galerkin scheme the selected basis and test functions are
the same. h = v
N
X
u = up hp (x) (4.5)
p=0
N
X
v= vp hp (x) (4.6)
p=0
Following the definition of the pseudo-spectral methods,polynomial basis function has to satisfy the
function values in the sampling points,by fulfilling the Kronecker delta property.
hp (xq ) = pq (4.7)
Derivatives of the approximations (u(x)) functions and the test (v)
N N
X hq (xq ) X
ux (xq ) = up = Dpq uq (4.8)
i=0
x p=0
N N
X hq (xq ) X
vx (xq ) = vp = Dpq vq (4.9)
p=0
x p=0
11
Substitution of the derivatives,vq cancel out and Kronecker delta changes indexes.
N
X N
X
wn Dnp up Dnq vq = wn f (xn )vq qn vq (4.12)
n=0 n=0
N
X N
X
wn Dnp up Dnq = wq fq (4.13)
n=0 n=0
Matrix Form
DT D~u = f~ (4.14)
Where:
is the diagonal matrix created with the weights from the quadrature.
D is the differentiation matrix.
f~ is the source term evaluated at the sampling points.
DT D~u = A (4.15)
f~ = b (4.16)
A~u = ~b (4.17)
Boundary Conditions Implementations
The Galerkin method produce a symmetric A matrix.The boundary conditions are implemented by
imposed the entries to zero in the ith row in the A matrix and in the symmetry is achieved by imposed
the entries to zero in the ith column too.
12
4.2 Matlab Implementation(1D Galerkin Method)
4.2.1 Set-up Grid and Differentiation Matrix
13
4.3 Results
4.3.1 Sampling Points Representation
0.4
Nodes = 16
0.3
0.2
0.1
-0.1
-0.2
-0.3
-0.4
-0.5
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
x
10
12
14
16
0 2 4 6 8 10 12 14 16
nz = 256
10
12
14
16
0 2 4 6 8 10 12 14 16
nz = 198
14
4.3.3 Numerical vs Analytical
0.05
||Error||2 = 1.1753e-12
(x)
0 Nodes = 16
-0.05
-0.1
-0.15
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
x
-5
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
x
100
10-5
||Error|| 2
10-10
10-15
10 20 30 40 50 60 70 80 90 100
N
15
5. 2D Diffusion Problem Definition
The main purpose of this problem is to use pseudo-spectral collocation method(CM) and Spectral Finite
Element Method (Galerkin Method(GM))to solve a 2-D steady diffusion problem (Elliptic PDE).In both
cases the collocations points (for CM) and the nodes for the quadrature rule (for GM)are the roots of a
Gauss-Lobatto Legendre(GLL) polynomial,which are defined in the domain [1, 1]2 .
The problem is defined in a 2D domain = [1, 1]2 with an homogeneous Dirichlet boundary
condition(DBCs),and it is required to perform a discretization,and MATLAB implementation in order
to solve the governing equation.
Governing Equation
2 (x, y) = sin(x)sin(x) = f (x, y) (5.1)
Domain
= [1, 1]2 (5.2)
Analytical Solution
1
(x, y) = sin(x)sin(y) (5.4)
2 2
16
6. 2D Pseudo-Spectral Collocation Method
6.1 Discretization
L (x, y) = f (x, y) x and y (6.1)
As it mentioned in the 1D case, the extension of the problem from 1D to 2D imply that a tensor product
is performed.
2 2
LN = I DN + DN I (6.2)
17
6.3 Results
6.3.1 Collocation Points Representation
1
Total Nodes = 256
0.8
0.6
0.4
0.2
-0.2
-0.4
-0.6
-0.8
-1
50
100
150
200
250
50
100
150
200
250
18
6.3.3 Numerical vs Analytical
0
0.8 0.03 -0.03
0
-0.0
1
0.0
0.04 -0.04
1
0.03
3
0.6
-0.0
0.01
-0.01
-0.03
0.03
-0.02
0.02
4 -0.
0.0 04
0.02
0.4
0.04 4
-0.0
0
0.0 01
1 0.02 -0.02 -0.
0
0.01 0 -0.01
0.01 -0.01
0
y
0 0 0 0
-0.01 0 0.01
-0.01 0.01
-0.02 0.02
-0.2 -0. 2
-0.03 -0
02 0.0 0.03
0
-0.0
.0
0.01
03
4 3 0.04
-0.0
0.
1
2
-0.4
0.02
-0.0
0.01
-0.01
0.
.0
0
-0
4
-0.6 -0
.0
03
0
3 -0.04 0.04
0.
0.
02
-0.03 0.03
0
-0.8 0.0
-0.02 -0.02 0 1 0.02
-0. 1 0.02
-0.01 0.01 0.01
-0.01
-1 0 0 0 0 0 0
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
x
-0.05 -0.04 -0.03 -0.02 -0.01 0 0.01 0.02 0.03 0.04 0.05
19
6.3.4 Error Distribution Analysis
0 0 1e-13 0 0
-1e-13
0.8
1e-13
-1e-13
0 -1e-
0
0 13 0
-1e-13 1 -
33 1e2e-13 2e
0
0 -2e-1 0 -1 0
0
0
0
3
0.6 0 -1 0 1
213e e3- -1e e-13
0
1e-1 3 -1
3 1e-1
2e-1
3e 3 -1e-13 1e- -13 -2 e-1 3
1
1e-13 -2e-13 3
3
-1e-1 0
0 -13
0- 0
0 0 1e 0 0
0
0.4 3 -1 -13 -1e-1
-1e e-1 3 e 3
-1 1 -2e-13 0 1 2e-13 3
-2e-13 3 1e-12e-13
-1e-1 0 3
0
-1e-13 0 3 1e-1 3
0 3 -1e 1e-1
0.2 1e-13
1e-1
-13 -1e-13 0 0
1e-13
-1e-13
1e-13 0 -2e-13 -1e-13
0
2e-13 1e-13 0 -1e-13
1e-13 -1e-13
0
y
0 0 0 0 0 0
-1e-13 -1e-13 -1e-13 0 1e-13 1e-13
-2e-13 1e-13
2e-13 1e-13
-1e-13 0 0 1e-13
-0.2 0 -1e-13 -1e 3 0 -1e 0
3 0 3 -13 -1
1e-1 -2e-13e-13 -13
1e-1
2e-13 1e-12e-13
-2e-13
0
3 -1e
-0.4 0 1e-10 -1e-1 -1
3
3 2e -1e
-1 3 0 -13 0
1e-13
-1e-13 -2e-13 3 1e 1 -13 0 3 1e3-1
2e-13
0
e- e-1
0 -2 0 3
0
0
-1e
3
-1e 3
-13
1e-1
-1e-1
-13 13 -13 -1 -13
0
-1
-0.6 1e 2e-13 - 1e -1e
2e -2e-13
e
0 -13 0 1e 0
-1
0
3
3
0 1e
0
-13 0
-1e-13 1e-13
0
1e-13
0 -1e-13 0
0
0 0
-0.8 0 0 0
0
0
0 0 0 0 0
0 0 0
-1 0 0 0 0
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
x
-3.6 -2.88 -2.16 -1.44 -0.72 0 0.72 1.44 2.16 2.88 3.6
10-13
100
10-5
||Error|| 2
10-10
10-15
5 10 15 20 25 30 35 40 45 50
N
20
7. 2D Pseudo-Spectral Galerkin Method
7.1 Discretization
L (x, y) = f (x, y) x and y (7.1)
Matrix Form
DT 1 D~u = 2 f~ (7.2)
W = diag(w) (7.3)
1 = W (7.4)
2 = 1 1 (7.5)
Where:
is the diagonal matrix created with the weights from the quadrature.
D is the differentiation matrix.
DT 1 D~u = A (7.6)
2 f~ = b (7.7)
As it mentioned in the 1D case, the extension of the problem from 1D to 2D imply that a tensor product
is performed.
L2 = 1 A + A 1 (7.8)
L2 ~u = ~b (7.9)
21
7.2 Matlab Implementation (2D Galerkin Method)
7.2.1 Set-up Grid and Differentiation Matrix
22
7.3 Results
7.3.1 Collocation Points Representation
1
Total Nodes = 256
0.8
0.6
0.4
0.2
-0.2
-0.4
-0.6
-0.8
-1
50
100
150
200
250
50
100
150
200
250
23
7.3.3 Numerical vs Analytical
0
0. 4
0.6 04 .0
-0
-0.03
-0.02
0.03
0.02
0.02
-0.0
0.4 0.0 .04
4 -0
0
-0
.0
01
0.0 0.03 1 -0.03 1
0.2 .0
0.
1 -0
0.02 -0.02
0.01 -0.01
0
y
0 0 0 0
-0 .01 -0.0 0.01
-0.02 1 0.01 0.0 2
-0.2 -0.03 0.03
0
-0.4
0.02
-0.02
-0.0
0.04
0.04
-0.0 3
02
-0.6
3
-0
0.0
0.0
.0
-0.
2
3 0.03
1
-0.0
-0
0.0
0
01
.0
-0.8 0.0
-0.
1
1
-0.02 0.02
-0.01 0.01
-1 0 0
-1 -0.5 0 0.5 1
x
-0.05 -0.04 -0.03 -0.02 -0.01 0 0.01 0.02 0.03 0.04 0.05
24
7.3.4 Error Distribution Analysis
-1e-1
0 1e-13 30
1e-13
0.8 -1e-1
13 1e-1
0
1
-1 30 -1e- 3 0 e-13
13
3
e
2e
-1
e-
-1
0.6 0 0
0
0 3
-2
0
3
10e- 1e-13
-1e-1
-13
0 -13
2e
13 0 2e-13 -13
-2e -1e
-1
-2e
0 0
3
3 1e-13
0.4 -1e-13 -1e-13 0 1e-13
-13 1 0 2e-13 2e-
e -2e- 13
0
-2
0
1e-13
-1e0
-1e-
0.2 0 3 0
1e-13 2e-13 1e-1 -13 13
-2e-13 -1e-
13
1e-13 -1e-13
0
y
0 0 0 0
-13 -2e-13 -1e-13 1e-13 2e-13 1e-13
-1e
1 3 1e-1
-0.2 0 -1e-01e-13 0 3 0
0
21ee--13 -1e-13 3
2e-1 -13 -1e-1 13
0
13 3 e-
-2e - 2
-0.4 0 -13 1e-103
3
3 e 1e-
2e-
-1 -1 -13 2e-1
1e-13
-2e-1
13
-1e-1
-1e-13
3
-1e -2e
1e-13
13
1e-13 e-13
0 1e-1 2e 0 0-1 -13 130
3
-0.6 0
0 3 -1
3 e -1e-
0 -2
0 -1e-1 3 01e-13
0
0
-0.8 0 0
0
0
0 0 0 0
-1 0 0 0 0
-1 -0.5 0 0.5 1
x
-1.95 -1.56 -1.17 -0.78 -0.39 0 0.39 0.78 1.17 1.56 1.95
10-12
100
10-5
||Error|| 2
10-10
10-15
5 10 15 20 25 30 35 40 45 50
N
25