Introduction To Spectral Methods: Eric Gourgoulhon
Introduction To Spectral Methods: Eric Gourgoulhon
Introduction To Spectral Methods: Eric Gourgoulhon
Eric Gourgoulhon
Laboratoire de lUnivers et de ses Theories (LUTH)
CNRS / Observatoire de Paris
Meudon, France
Plan
1. Basic principles
2. Legendre and Chebyshev expansions
3. An illustrative example
4. Spectral methods in numerical relativity
1
Basic principles
x U IRd
(1)
y U,
(2)
N
X
u
n n(x)
n=0
Test functions : family of functions (0, . . . , N ) to define the smallness of the residual
R, by means of the Hilbert space scalar product:
n {0, . . . , N },
(n, R) = 0
All spectral method: trial functions (n) = complete family (basis) of smooth global
functions
Classification according to the test functions n:
Galerkin method: test functions = trial functions: n = n and each n satisfy the
boundary condition : Bn(y) = 0
tau method: (Lanczos 1938) test functions = (most of) trial functions: n = n but
the n do not satisfy the boundary conditions; the latter are enforced by an additional
set of equations.
collocation or pseudospectral method: test functions = delta functions at special
points, called collocation points: n = (x xn).
N
X
n , L
u
k k (n, s) = 0
k=0
N
X
u
k (n, Lk ) (n, s) = 0
k=0
N
X
Lnk u
k = (n, s) ,
k=0
(3)
M
X
bpn gp(y)
p=0
N X
M
X
u
k bpk gp(y) = 0,
k=0 p=0
bpk u
k = 0
0pM
Lnk u
k
= (n, s)
0nN M 1
bpk u
k
= 0
0pM
k=0
The solution (
uk ) of this system gives rise to a function u
=
N
X
k=0
L
u(x) = s(x) +
M
X
p=0
p N M +p(x)
u
k k such that
10
N
X
Lk (xn)
uk = s(xn)
(4)
k=0
The boundary condition is imposed as in the tau method. One then drops M + 1 raws
in the linear system (4) and solve the system
N
X
k=0
N
X
k=0
Lk (xn) u
k
= s(xn)
0nN M 1
bpk u
k
= 0
0pM
11
12
2
Legendre and Chebyshev expansions
13
Families of orthogonal
polynomials on [1, 1] :
Legendre polynomials:
Z 1
Pm(x)Pn(x) dx =
1
2
mn
2n + 1
Chebyshev polynomials:
Z 1
dx
Tm(x)Tn(x)
=
2
1x
1
(1 + 0n) mn
2
[from Fornberg (1998)]
3 2 1
P0(x) = 1, P1(x) = x, P2(x) = x
2
2
14
2
d p
dT
n
n
1 x2
=
Tn(x)
2
dx
dx
1x
Orthogonal family in the Hilbert space L2w [1, 1], equiped with the weight
w(x) = (1 x2)1/2 :
Z 1
(f, g) :=
f (x) g(x) w(x) dx
1
15
N
X
i=0
u(xi)
N
Y
x xj
j=0
j6=i
xi xj
N
Y
i=0
(x xi)
16
Note that
N
Y
i=0
(x xi) =
i=0
1
TN +1(x)
N
2
2i + 1
xi = cos
2(N + 1)
0iN
17
N
X
u
nn(x)
n=0
with (n, u) :=
(5)
18
(6)
i=0
where the xis are the N + 1 zeros of the polynomial N +1 and the coefficients wi are
Z 1
N
X
xij wj =
xi w(x) dx.
the solutions of the linear system
j=0
19
(7)
The actual numerical representation of a function u is then the polynomial formed from
the discrete coefficients:
N
X
IN u(x) :=
u
nn(x) ,
n=0
20
Aliasing error
Proposition: IN u(x) is the interpolating polynomial of u through the N + 1 nodes
(xi)0iN of the Gauss-Lobatto quadrature: IN u(xi) = u(xi) 0 i N
On the contrary the orthogonal projection PN u does not necessarily pass through the
points (xi).
The difference between IN u and PN u, i.e. between the coefficients u
n and u
n, is
called the aliasing error.
It can be seen as a contamination of u
n by the high frequencies u
k with k > N , when
performing the Gauss-Lobato integration (7).
21
22
Legendre:
truncation error :
interpolation error :
Chebyshev:
truncation error :
interpolation error :
C X (k)
ku kL2
kPN u ukL2 m
N
k=0
C
kPN u uk m1/2 V (u(m))
N
m
X
C
kIN u ukL2 m1/2
ku(k)kL2
N
k=0
m
C X (k)
kPN u ukL2w m
ku kL2w
N
k=0
m
C(1 + ln N ) X (k)
kPN u uk
ku k
m
N
k=0
m
C X (k)
kIN u ukL2w m
ku kL2w
N
k=0
m
X
C
kIN u uk m1/2
ku(k)kL2w
N
k=0
23
Evanescent error
From the above decay rates, we conclude that for a C function, the error in the
spectral expansion decays more rapidly than any power of 1/N . In practice, it is an
exponential decay.
Such a behavior is a key property of spectral methods and is called evanescent error.
(Remember that for a finite difference method of order k, the error decays only as
1/N k ).
24
3
An example
... at last !
25
4
+
4u
=
e
+ C,
dx2
dx
x [1, 1]
(8)
and
u(1) = 0
(9)
26
4
X
sn Tn(x)
and
n=0
I4 s(x) =
4
X
sn Tn(x)
n=0
with
2
sn =
(1 + 0n)
dx
Tn(x)s(x)
1 x2
1
and
4
X
2
wiTn(xi)s(xi)
sn =
(1 + 0n) i=0
1
1
w(x) = (1 x2)1/2: {xi} = { cos(i/4), 0 i 4} = 1, , 0, , 1
2
2
27
1.5
0.5
-0.5
-1
-1
-0.5
0.5
x
s0 = 0.03004, s1 = 1.130, s2 = 0.2715, s3 = 0.04488, s4 = 0.005474
28
0.001
0.0005
-0.0005
-0.001
-1
-0.5
0.5
x
sn sn = 2.0 107, 3.2 106, 4.5 105, 5.4 104, 1.0 1012
29
d
=
dx
0
0
0
0
0
1
0
0
0
0
0
4
0
0
0
3
0
6
0
0
0
8
0
8
0
4
0
Akl =
0
0
0
d
=
2
dx
0
0
0
0
0
0
0
0
0
0
4 0 32
0 24 0
0 0 48
0 0 0
0 0 0
d2
d
operator 2 4 + 4 Id on the r.h.s. of Eq. (8)
dx
dx
4
4
12 32
4 16 24 32
0
4
24 48
0
0
4
32
0
0
0
4
30
Each of the i satisfies the boundary conditions: i(1) = i(1) = 0. Note that the
is are not orthogonal.
1 0 1
0 1 0
0
0
Transformation matrix Chebyshev Galerkin: ki = 1
0
1
0
0
0
1
such that i(x) =
4
X
ki Tk (x).
k=0
4
X
k=0
u
k Tk (x) =
2
X
i=0
i i(x)
u
The matrix ki relates the two sets of coefficients via the matrix product u
=
31
Galerkin system
For Galerkin method, the test functions are equal to the trial functions, so that the
condition of small residual writes
3
X
j = (i, s)
(i, Lu s) = 0
(i, Lj ) u
j=0
with
4 X
4
4 X
4
X
X
(i, Lj ) =
(kiTk , Llj Tl) =
kilj (Tk , LTl)
k=0 l=0
4 X
4
X
k=0 l=0
4
4 X
X
k=0 l=0
k=0 l=0
kilj (Tk ,
4
X
m=0
AmlTm) =
4 X
4
X
k=0 l=0
4
kilj
4
X
Aml(Tk , Tm)
m=0
XX
kilj (1 + 0k )Akl =
(1 + 0k )kiAkllj
2
2
k=0 l=0
32
2 0 1 0 0
h
i
Qik := t (1 + 0k )ki = 0 1 0 1 0
2 0 0 0 1
The small residual condition amounts then to solve the following linear system in
0, u
1, u
2):
u
= (u
u
QA
= Q s
4 8 8
0.331625
= 16 16
0 and Q s = 1.08544
with Q A
0
16 52
0.0655592
0 = 0.1596, u
1 = 0.09176, u
2 = 0.02949.
The solution is found to be u
:
The Chebyshev coefficients are obtained by taking the matrix product by
u
0 = 0.1891, u
1 = 0.09176, u
2 = 0.1596, u
3 = 0.09176, u
4 = 0.02949
33
0.5
Exact solution
Galerkin
y = u(x)
0.4
0.3
0.2
0.1
0
-1
-0.5
0.5
sinh 1 2x
e
Exact solution: u(x) = e
e
sinh 2
1 + e2
x
34
bpk =
1 1 1 1 1
1 1 1 1 1
(10)
The Tns being an orthogonal basis, the tau system is obtained by replacing the last
two rows of the matrix A by (10):
u
0
4 4
4
12 32
1
0 4 16 24 32
u
0 0
4
24 48 u
2
=
1 1
1
1
1 u
3
1 1
1
1
1
u
4
s0
s1
s2
0
0
35
0.5
Exact solution
Galerkin
Tau
y = u(x)
0.4
0.3
0.2
0.1
0
-1
-0.5
0.5
sinh 1 2x
e
Exact solution: u(x) = e
e
sinh 2
1 + e2
x
36
LTk (xn) u
k = s(xn)
4 X
4
X
Alk Tl(xn) u
k = s(xn)
k=0 l=0
1 1/ 2 0
1/ 2 1
0
1
0
1
T nl := Tl(xn) = 1
1 1/ 2
0 1/ 2 1
1
1
1
1
1
37
Pseudospectral system
To take into account the boundary conditions, replace the first row of the matrix
T A by b0k and the last row by b1k , and end up with the system
1
1
1
1
1
u
0
1
4 6.82843 15.3137 26.1421 28
u
u
4
4
0
12
12
2
4 1.17157 7.31371 2.14214
28 u
3
1
1
1
1
1
u
4
0
s(x1)
s(x2)
s(x3)
0
38
0.5
y = u(x)
0.4
Exact solution
Galerkin
Tau
Pseudo-spectral
0.3
0.2
0.1
0
-1
-0.5
0.5
sinh 1 2x
e
Exact solution: u(x) = e
e
sinh 2
1 + e2
x
39
y = u(x)
0.4
Exact solution
Galerkin
Tau
Pseudo-spectral
0.3
0.2
0.1
0
-1
-0.5
0.5
40
-2
-4
-6
-8
-10
-12
-14
-16
2
10
12
14
16
18
41
42
4
Spectral methods in numerical relativity
43
Pioneered by Silvano Bonazzola & Jean-Alain Marck (1986). Spectral methods within
spherical coordinates
1990 : 3-D wave equation
1993 : First 3-D computation of stellar collapse (Newtonian)
1994 : Accurate models of rotating stars in GR
1995 : Einstein-Maxwell solutions for magnetized stars
1996 : 3-D secular instability of rigidly rotating stars in GR
44
LORENE
Langage Objet pour la RElativite NumeriquE
A library of C++ classes devoted to multi-domain spectral methods, with adaptive
spherical coordinates.
1997 : start of Lorene
1999 : Accurate models of rapidly rotating strange quark stars
1999 : Neutron star binaries on closed circular orbits (IWM approx. to GR)
2001 : Public domain (GPL), Web page: http://www.lorene.obspm.fr
2001 : Black hole binaries on closed circular orbits (IWM approx. to GR)
2002 : 3-D wave equation with non-reflecting boundary conditions
2002 : Maclaurin-Jacobi bifurcation point in GR
45
Code for producing the figures of the above illustrative example available from Lorene
CVS server (directory Lorene/Codes/Spectral),
see http://www.lorene.obspm.fr
46
47