Homework No. 2 Computational Fluid Dynamics For Environmental Flows

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 17

Homework No.

2
Computational Fluid Dynamics for Environmental Flows
Jorge ESCOBAR-VARGAS
Cornell University
April 4, 2007

Consider the one dimensional diffusion equation


∂C ∂2C
=α 2 (1)
∂t ∂x
where C is the concentration of a tracer/contaminant and α is a diffusivity. The boundary condi-
tions are
C(x = 0, t) = 0
C(x = L, t) = 0
Let the initial condition be:
C(x, t = 0) = exp(−0.5(x − x0 )2 /λ20 )
where λ0 is a characteristic length scale. This simple 1-d problem could be viewed as an idealized
model of turbulent diffusion/dispersion of some localized contaminant distribution in a lake, river
or stuary with a constant free-stream velocity. Set L = 500m and λ0 = 50m. Use α = 0.01m2/s
as a typical value for your turbulent diffusivity. Your contaminant is centered at x 0 = 250m

Problem 1
Find the analytical solution to equation 1 with the specified boundary conditions and initial con-
dition using separation of variables.

To solve equation 1 by separation of variables, the concentration (C) has to be function of two
variables, for example X and T such as
C(x, t) = X(x)T (t)
Taking into account the separation, equation 1 can be written as
∂ ∂2
(X(x)T (t)) = α (X(x)T (t))
∂t ∂x2
∂T (t) ∂ 2 X(x)
X(x) = α (2)
∂t ∂x2
Dividing each term of 2 by αX(x)T (t) we obtain
1 ∂T (t) 1 ∂ 2 X(x)
= (3)
αT (t) ∂t X(x) ∂x2
equation 3 represents the separated variables, which can be solved independently. Note that both
sides of equation 3 have to have the same result, for example k, then
1 ∂T (t) 1 ∂ 2 X(x)
= =k (4)
αT (t) ∂t X(x) ∂x2

1
equation 4 also can be written as

dT (t)
− kαT (t) = 0 (5)
dt
d2 X(x)
− kX(x) = 0 (6)
dx2
Equation 5 can be solved in the following way

dT (t)
= kαT (t)
Z dt
dT
Z
= kαdt
T
ln T = kαt + A

when t = 0 → T = T0
A = ln T0
then
T = T0 ekαt (7)
if
k = −λ2
2
α2 t
T = T0 e−λ (8)
Equation 6 can be solved in the following way:

If we say that
d
m=
dx
and taking into account that k = −λ2 then equation 6 can be written as

(m2 + λ2 )X = 0 (9)

which mean two possible solutions for m


m = λi
m = −λi
then, equation 6 has a solution of the form

X = Aeλix + Be−λix (10)

Making use of Euler’s identity (Leonhard Euler 1707-1783)

eiθ = cos θ + i sin θ

equation 10 is

X = A(cos λx + i sin λx) + B(cos −λx + i sin −λx)


= A cos λx + B cos λx + Ai sin λx − Bi sin λx
= (A + B) cos λx + (A − B)i sin λx
(11)

if
A + B = A1
(A − B)i = A2

2
then
X = A1 cos λx + A2 sin λx (12)
Now, with equations 8 and 12, the solution of 1 is of the form
2
C(x, t) = e−λ αt
(A1 cos λx + A2 sin λx) (13)
In this moment, we have an infinite number of solutions for equation 1. But, if we impose the
boundary conditions, and the initial conditions we can obtain the solution for 1.

The boundary conditions are:


C(x = 0, t) = 0
C(x = L, t) = 0
Replacing the first condition in equation 13
2 2
C(0, t) = e−λ αt
(A1 cos 0 + A2 sin 0) = A1 e−λ αt
=0 (14)
then
A1 = 0 (15)
Now, applying the second BC, and taking into account 15
2
C(L, t) = e−λ αt
(A2 sin λL) = 0 (16)
In this case the condition is fulfilled if
sin λL = 0
and it is possible only when
π 2π 3π 4π
λ = ± ,± ,± ,± ,···
L L L L
then

λn = ±
L
The solution will be the contribution of each one of the following modes
nπ 2
 nπx 
Cn (x, t) = An e−( L ) αt sin (17)
L
And the final solution is
∞  nπx 
2
A n e −( )

X
αt
C(x, t) = L sin (18)
n=1
L
But, here we have not solved An . It can be solved using the initial condition
C(x, t = 0) = exp(−0.5(x − x0 )2 /λ20 )
Reeplacing it in 18 we obtain

X  nπ 
C(x, 0) = Φ(x) = An sin x (19)
n=1
L

Using the properties of the inner product in orthogonal polynomials, we can multiply each side of
equation 19 by sin πmx/L obtaining
Z L  mπ  Z LX ∞  nπ   mπ 
Φ(x) sin x dx = An sin x sin x
0 L 0 n=1 L L
Z L  mπ 
= Am sin2 x dx
0 L
L
= Am (20)
2

3
then
L
2  mπ 
Z
Am = Φ(x) sin x dx
L 0 L
2 L −0.5(x − x0 )2
Z    mπ 
= exp 2 sin x dx (21)
L 0 λ0 L
Replacing 21 in 18, the final expression for the analytical solution of Helmholtz equation is
∞  nπx  Z L −0.5(x − x0 )2
 
2 −( nπ 2  nπ 
e L ) αt sin
X
C(x, t) = exp sin x dx (22)
n=1
L L 0 λ20 L

The integral corresponding to the coefficient An was solved using the multiple segment trapezoidal
rule, which has the following form
Pn−1
f (x0 ) + 2 i=1 f (xi ) + f (xn )
I ≈ (b − a) (23)
2n
For this problem, taking into account the information given, 23 becomes
Pn−1
2 i=1 f (xi )
I ≈L (24)
2n
being n the number of elements used in the discretization. Note that in 24 the functions at the
boundaries are not calculated because their values are zero, due to the boundary conditions of the
problem.

The following graphic presents the result of the analytical solution at t = 125000.

0.7

0.6

0.5
Concentration

0.4

0.3

0.2

0.1

0
0 100 200 300 400 500
X

It will be the comparison point for the error analysis in the subsequent problems.

Problem 2
Apply the forward in time discretization of the time derivative on the LHS of 1, using the concen-
tration at time levels (n) and (n + 1). Now, write the RHS as of function of time level (n + 1)
only (this is what we call a fully implicit scheme). Rewrite the resulting equation in form of a
Helmholtz equation.

We start with equation 1


∂C ∂2C
=α 2 (25)
∂t ∂x

4
Applying forward discretization to the time derivative, and taking the RHS as of function of time
level (n + 1), the following expresion is obtained

C n+1 − C n ∂ 2 C n+1
=α (26)
∆t ∂x2
If the RHS is function of the time level (n + 1), then 26 can be rewritten as

Cn ∂ 2 C n+1 C n+1
− =α − (27)
∆t ∂x2 ∆t
dividing by α every term, and if
Cn
Fn = −
α∆t
1
ε=
α∆t
we obtain
∂ 2 C n+1
Fn = − εC n+1 (28)
∂x2
which is Helmholtz equation.

Problem 3
Consider a uniform grid with N +1 grid points. Apply the central in space 2nd order finite difference
scheme to the Helmholtz equation. Use lower order backward/forward in space finite difference
schemes at the boundaries. Write the resulting equation in matrix form. Solve the resulting tridi-
agonal system of equations using either an LU or conjugate gradient solver.

Using the above discretization advance your solution in time until t = λ20 /2α. As a timestep
use that provided by the stability constraint for a fully explicit scheme, already discusses in class.
Starting with a minimum value of N = 50 repeat this process for N = 100, 200, 400, 800, 1600. For
your final time, on a log-log diagram, plot the evolution of the L∞ norm of the error as a function
of N. For N = 400, perform two additional runs, one with half and one with double the time step
to determine the role of timestepping on the error.

In this problem we begin with equation

∂2C
− εC = F (29)
∂x2
The disctretization schemes for the second derivetive are described as follow
• For the left boundary
∂2C Ci − 2Ci+1 + Ci+2
= (30)
∂x2 ∆x2
• For interior points
∂2C Ci−1 − 2Ci + Ci+1
= (31)
∂x2 ∆x2
• For the right boundary
∂2C Ci−2 − 2Ci−1 + Ci
= (32)
∂x2 ∆x2
Using the schemes presented above, equation 29 in discrete form is
• For the left boundary
(1 − ε∆x2 )Ci − 2Ci+1 + Ci+2 = ∆x2 F (33)

5
• For interior points
Ci−1 − (2 + ε∆x2 )Ci + Ci+1 = ∆x2 F (34)

• For the right boundary

Ci−2 − 2Ci−1 + (1 − ε∆x2 )Ci = ∆x2 F (35)

In matrix form is
(1 − ε∆x2 )
    
−2 1 0 0 0 C1 F1
 1 −(2 + ε∆x2 ) 1 0 0 0  C2
   F2
.. ..
    
 .. .. .. 
=
 
 (36)


 0 . . . 0 0 

 
 .
 .
 0 0 0 1 −(2 + ε∆x2 ) 1   CN   FN 
0 0 0 1 −2 (1 − ε∆x2 ) CN +1 FN +1

Boundary conditions are applied and the system of equations is solved the number of time steps
stablished for the problem, which depends on the number of elements employed for the simulation.
The RHS vector change each time step. The resluts are presented in the following graphics for
N = 50, 100, 400, 800, 1600.

0.8

0.6
Conc

0.4

0.2

0
0 100 200 300 400 500
X

The dotted line represents the initial condition, whereas the other lines represent each one of the
solutions for t = 125000.

The evolution of the L∞ norm as a function of N is presented in the following graphic.

-2
10
FD

-3
10

500 1000 1500


N

6
Finally, when half of the time step and double of time step is used for N = 400 the L∞ norm
decrease when the timestep decrease, and in the same form, if the timestep increase, the value of
the norm increase. From this point, it can be said that timestepping affect the response of the
system. The following plot presents the behavior for this situation

0.0019

0.00185

LinfFD
0.0018

0.00175

0.0017

1 2 3 4
dt

An strange behavior is observed when the timestepping is very small, in this case of the order of
0.25 ∗ dt. The L∞ norm increase its magnitude at a similar level of 4 ∗ dt. This behavior can be
due to roud of eeror propagated during the calculations.

Problem 4
Now follow the procedure outlines in the hand-out to write out a FEM/SEM discretization of the
Helmholtz equation, i.e. :

a) Write out the weak form of your equation subject to the prescribed boundary conditions.

As in the previous problem, we start with Helmholtz equation

∂2C
− εC = F (37)
∂x2
subject to the following boundary conditions

C(x = 0, t) = 0

C(x = L, t) = 0
The weighted residual formulation for Helmholtz equation will be
Z L 2 
∂ C
− εC − F vj dx = 0 (38)
0 ∂x2

where vj represents the test functions.

Now, in order to obtain the weak form of the weighted residual formulation of Helmholtz equa-
tion, an integration by parts has to be performed to the term that contains a second derivative.
It can be done as follows
Z L 2   L Z L  
∂ C ∂C ∂C ∂vj
vj dx = vj − dx (39)
0 ∂x2 ∂x 0 0 ∂x ∂x

7
replacing 39 in 38 we obtain
Z L  Z L    
∂C ∂vj ∂C ∂C
− εCvj dx = − F vj dx + vj − vj (40)
0 ∂x ∂x 0 ∂x L ∂x 0

which is the general weak form of the weighted residual formulation of Helmholtz equation.
Now, if boundary conditions are taken into account, the second and third term of the right
hand side of 40 desapear. Then
Z L  Z L
∂C ∂vj
− εCvj dx = − F vj dx (41)
0 ∂x ∂x 0

b) You will now use Galerkin WRM. How do your test functions relate to your interpolating func-
tions?. Write out the appropiate nodal expansion of your solution.

The Galerking formulation states that test functions are the same as interpolating functions,
then if it is assumed that the function C can be described as the finite sum
N
X +1
C(x) = Ĉi φi (42)
i=1

then
vj = φ j
Taking into account this assumption, equation 41 can be written as
N +1 Z L   Z L
X ∂φi ∂φj
+ εφi φj dx Ĉi = − F φj dx (43)
i=1 0 ∂x ∂x 0

c) Partition your domain in M elements each one having N − th order interpolants. Choose
M = 100 for starters. Now consider your Galerkin formulation locally for each element. Write
out the resulting system of linear equations. What is the general form of the local stiffness
matrix?

If we call from 43
L 
∂φi ∂φj
Z
Kji = + εφi φj dx (44)
0 ∂x ∂x
and Z L
bj = − F φj dx (45)
0
is obtained the matrix form of the Galerkin weighted residual formulation of Helmholtz equation,
which is of the form
N
X +1
Kji Ĉi = bj (46)
i=1

In order to work with each element independently, it is necessary to create a local or natural
coordinate system ξ for each one of the elements. The new system will be within the interval
[−1, 1], in such way that
x − xj−1
ξ = 2 −1 (47)
∆xj
dξ 2
= (48)
dx ∆xj

8
With this new coordinate system the solution within each element, e.g. j can be expressed as
N
X +1
C j (ξ) = Ĉi φi (49)
i=1

if we choose the Lagrange interpolation functions as basis functions (φ = h), the expansion will
be
N
X +1
C j (ξ) = Ĉi hi (ξ) (50)
i=1
where
K
Y ξ − ξi
hj (ξ) = (51)
ξ
i=1 j
− ξi
i6=j
where K represents the order of the number of nodes per element. For this case, linear functions
are choosen to solve the problem, then K = 2, and the basis functions for the problem are
2
Y ξ − ξi ξ − ξ2 ξ−1 1−ξ
h1 (ξ) = = = = (52)
ξ − ξi
i=1 j
ξ1 − ξ 2 −1 − 1 2
i6=1
2
Y ξ − ξi ξ − ξ1 ξ+1 1+ξ
h2 (ξ) = = = = (53)
ξ
i=1 j
− ξ i ξ 2 − ξ 1 1 + 1 2
i6=2

Equation 44 can be reexpressed in the following way


Kij = Dij + εMij
where
L
∂φi ∂φj
Z
Dij = dx (54)
0 ∂x ∂x
Z L
Mij = φi φj dx (55)
0
Now, equations 54 and 55 can be written in terms of 52 and 53. Also, due to the properties of
Lagrange polynomials, the interpolation functions are non zero only within each element, then
the integration limits change to [xj−1 , x − j].
Z xj
∂hi (ξ) ∂hj (ξ)
Dji = dx
xj−1 ∂x ∂x
Z 1
∂hi (ξ) ∂hj (ξ)
= dx
−1 ∂x ∂x
Z 1
∂hi (ξ) ∂ξ ∂hj (ξ) ∂ξ ∂x
= dξ
−1 ∂ξ ∂x ∂ξ ∂x ∂ξ
Z 1
2 ∂hi (ξ) ∂hj (ξ)
= dξ (56)
∆x −1 ∂ξ ∂ξ
Z xj
Mji = ε hi (ξ)hj (ξ) dx
xj−1
Z 1
= hi (ξ)hj (ξ) dx
−1
Z 1
∂x
= hi (ξ)hj (ξ) dξ
−1 ∂ξ
1
∆x
Z
= hi (ξ)hj (ξ)dξ (57)
2 −1

9
For linear elements, i, j = 1, 2, then matrices 54 and 55 look like
R1 1 R1 !
2 −1 4 dξ − −1 14 dξ
Dji = R1 1 R1 1 (58)
∆x − −1 4 dξ −1 4

 
1 1 −1
= (59)
2∆x −1 1
R1 R1 !
2 2
∆x (1 − ξ) dξ (1 − ξ )dξ
Mji = R−1
1 R−1
1 (60)
2 −1
(1 − ξ 2 )dξ −1
(1 − ξ)2 dξ
 
∆x 2 1
= (61)
6 1 2

Finally, the general form of the local stiffness matrix for linear elements is
   
1 1 −1 ∆x 2 1
Kij = +ε (62)
2∆x −1 1 6 1 2

d) Consider N = 1 (i.e. linear finite elements). Compute the elements of the stiffness matrix
analitically. You can compute the RHS either analitycally or numerically. However, you do not
want to use matrix diagonalization here. Can you explain why? Perform the global assembly
of the stiffness matrix.

The RHS, equation 45, can is calculated in the following way


Z 1
bj = − F hj (ξ) dx
−1
Z 1 N
X +1
= − (fi hi (ξ))hj (ξ) dx
−1 i=1
N +1 1
∂x
X Z
= − fi hi (ξ)hj (ξ) dξ (63)
i=1 −1 ∂ξ

For this case, two nodes linear elements, the RHS is


 Z 1 Z 1 
∆x ∆x
b1 = − f 1 h1 (ξ)h1 (ξ) dξ + f2 h2 (ξ)h1 (ξ) dξ
−1 2 −1 2
 
∆x ∆x
= − f1 + f2 (64)
3 6
 Z 1 Z 1 
∆x ∆x
b2 = − f 1 h2 (ξ)h1 (ξ) dξ + f2 h2 (ξ)h2 (ξ) dξ
−1 2 −1 2
 
∆x ∆x
= − f1 + f2 (65)
6 3
(66)

The final system of equations is of the form (i.e. for three elements)
 1 1
   1 
k11 k12 0 0 C1 b1
1
k21 1 2 2 C2  b12 + b21 
k 22 + k 11 k 12 0   =  2
 2 2 3 3 
 (67)
 0 k21 k22 + k11 k12 C3  b2 + b31 
3 3
0 0 k21 k22 C4 b32

where the superindex represents the element associated to the component of the stiffness matrix
or RHS vector.

10
Concerning the matrix diagonalization, in this case is not used because we are evaluating the
integrals analytically. If we want to use diagonalization in this case we have to use 2 Gauss
points for the evaluation of the integral, which means a trapezoidal surface that compared with
the parabilic one of the integrands, can introduce some error in calculations.

As in part 3, advance your solution in time until t = λ20 /2α. Repeat this process for M =
200, 400, 800, 1600. Adjust your time stepping accordingly. For your final time, on a log-log
diagram, plot the evolution of the L∞ norm of the error as a function of M × N .

The results for the Finite Element Method approach are presented in the following figure

0.8

0.6
Conc

0.4

0.2

0
0 100 200 300 400 500
X

As in the case of the finite difference method, the dotted line represents the initial condition,
whereas the other lines represent each one of the solutions for t = 125000. The behavior of
the solution is very close to the analytical one, and if the solution is viewed from a practical
point, the increment in the number of elements do not imply a significative improvement in the
accuracy of the solution. It can be observed in the L∞ norm graphic.

0.015

0.01

0.005
FEM

500 1000 1500


N

In this case, the behavior of the L∞ norm for N = 1600 was unexpected. One of the reasons
of this behavior can be that for the computation of the analytical solution the trapezoidal rule
was used to calculate the coefficients of the expansion, which introduce error into the solution.

If the timestepping is analized, the following behavior is found for N = 400

11
0.00225

0.0022

0.00215

0.0021

FEM
0.00205

0.002

0.00195

0.0019

0.00185
-1 0 1 2 3 4 5
dt

Some doubts appear looking the figure because its behavior was not expected. The first one is
whether the solver introduce errors in the solution. For both cases, Finite Differences and FEM,
the Thomas algorithm was implemented to solve the porblem, because the stiffness matrix is
tridiagonal. Another possibility can be some error in the calculation of the analytical solution
due to the numerical integration performed to get the coefficients.
e) Now repeat step 4(d) for spectral elements, i.e. N = 8 or larger. Again, adjust your timestep
accordingly. Use Gauss-Lobatto-Legendre quadrature to numerically compute the elements of
your stiffness matrix. Perform the necessary mass matrix diagonalization to make your life eas-
ier. Plot the GLL grid on the canonical interval [−1, 1] for N = 8, 16, 32. Why is the grid-point
distribution biased towards the end-points of this interval?

For the case of spectral elements the starting point is the weak form of the Galerkin weighted
residual method, but in this opportunity the solution will be obtained using high order poly-
nomials, and the integration over each subdomain will be calculated numerically using the
advantages of the Gauss-Lobatto-Legendre points.

Using this approach, the spectral interpolation within each subdomain is of the form
P
X
C j (ξ) = j
Cm hm (ξ) (68)
m=1

where
P
Y ξ − ξn
hm (ξ) = (69)
ξm − ξ n
n=1,n6=m

being ξm the location of the Gauus-Lobatto-Legendre point within the interval [−1, 1].

Replacing ?? in 56
1
2 ∂hm (ξ) ∂hn (ξ)
Z
Dmn = dξ (70)
∆x −1 ∂ξ ∂ξ
but in this case
N +1
∂hm (ξi ) X
= Dij hm (ξj ) (71)
∂ξ j=1

then 70 becomes
1 N +1 N +1
2
Z X X
Dmn = Dij hm (ξj ) Dij hn (ξj ) dξ (72)
∆x −1 j=1 j=1

12
Evaluating numerically the integral using Gauss quadrature, is obtained
 
N +1 N +1 N +1
2 X X X
Dmn = Dij hm (ξj ) Dij hn (ξj ) wi (73)
∆x i=1 j=1 j=1

where wi is the weight corresponding to each one of the Gauss points within the interval [−1, 1].
But taking into account that Lagrange polynomials are one in the evaluation point and zero
everywhere, the final expression for the diffusion matrix is
N +1
2 X
Dmn = (Dim hm (ξm )Din hn (ξn )) wi (74)
∆x i=1

Now, for the Mass matrix, taking into account that we are working with linear mapping (taken
from handout)

1
∂x
Z
j
Mmn = hm (ξ)hn (ξ) dξ
−1 ∂ξ
N +1
∂x X
≈ (hm (ξp )hn (ξp )wp )
∂ξ p=1
N +1
∂x X
= (δmp δnp wp )
∂ξ p=1
∂x
= δmn wm (75)
∂ξ
which mean that Mass matrix becomes diagonal when you use the same number of points for
the calculation of the integral as well as the number of collocation points.

Finally, for the RHS, the spectral expansion was performed in the following way
Z xj
bj = F φj dx
xj−1
N +1
!
Z xj X
= F i φi φj dx
xj−1 i=1
N +1 1
∂x
X Z
= Fi hi (ξ)hj (ξ) dξ
i=1 −1 ∂ξ
N +1 Z 1
∆x X
= Fi hi (ξ)hj (ξ)dξ
2 i=1 −1
 
N +1 N +1
∆x X  X
= Fi hi (ξ)hj (ξ)wj  (76)
2 i=1 j=1

The assembling was performed in the same way that in the case of the Finite Element approach,
but taking into account that in this case the local stiffness matrices vary in size depending on
the polynomial degree used for the interpolation. Like in the FEM case, the superposition of
components of local matrices is carried out only in the extreme nodes.

The solution for Helmholtz equation using p-fem (spectral) approximation for (M = 100, N =
8), (M = 50, N = 8),(M = 50, N = 16) are presented in the following graphic.

13
1

0.8

0.6

Conc
0.4

0.2

0
0 100 200 300 400 500
X

The general behavior of the solution is correct, but when the L∞ norm is calculated for this
approach, its magnitudes are bigger than the expected ones. Based on this result the following
question arose: what is the error introduced in the analytycal solution when the coefficients
of it are calculated via trapezoidal rule? Can this solution be taken as an analytical solution?
What if Gauss quadrature is used to evaluate the integral in the analytical solution?. The next
plot presents the behavior of the L∞ norm for the spectral approach for (M = 50, N = 8),
(M = 50, N = 12),(M = 50, N = 16), (M = 50, N = 20).

0.0042

0.004
SEM

0.0038

0.0036

0.0034

400 500 600 700 800 900 1000


N

The following graphic presents the spatial distribution of Gauss-Lobatto-Legendre points for
N = 8, 16, 32

14
-1.5 -1 -0.5 0 0.5 1 1.5
Canonical Interval

The special distribution of these points is due to what is called the Runge effect, which are
strong oscillations (singularities) of high order Lagrange polynomials near the boundaries if the
interval between interpolation points is constant, for that reason and looking for a well behavior
of the interpolant, it is necessary to redistribute the interpolation points in order to get the
best approximation for a given continuous function.
f) Repeat the above step for N = 16, 32 with M × N not exceeding 1600.
g) For a given degree of accuracy, which method (FD/FEM/SEM) would require the fewest grid-
points? For a total of 1600 grid points, which method provides the highest accuracy?

One of the advantages od Spectral elements is that you can fix a number of grid points and
increase the number of the interpolant within grid points, based on that, it can be said that
spectral approache requires less grid points for a desire degree of approximation. Now, for a
total of 1600 grid points, the spectral approach is better if is used a polynomial higher than 2
to interpolate the function between grid points.
h) In the SEM what provides a greater gain in accuracy, doubling M (h-refinement) or N (p-
refinement)? Althought it may not be as evident in your 1D problem, is h or p-refinement most
costly in terms of time? Can you explain why?

The gain in accuracy in SEM mainly is due to the increase of the polynomial degree (N ).
But the price that we have to pay for it, is an increase of the size and number of bands of the
stiffness matrix, which is directly related with computational cost.
i) EXTRA CREDIT: How does timestepping impact the accuracy of a N = 32 SEM discretization?

Taking into account that L∞ norm for SEM can be influenced by the numerical integration
performed within the analytical solution, a test was developed to see the impact of time step-
ping in the accuracy of the solution, the results are shown in the following plot

15
0.014

0.012

0.01

Linf
0.008

0.006

0.004

0.002
0.5 1 1.5 2 2.5 3
dt

where the x axis is in log scale. From this result can be said that timestepping has an impact
in the solution even when the time scheme is implicit.

Discussion
In this section a general discussion of the results obtained for the different solutions of 1D-Helmholtz
equation is presented.

The following graphic presents the behavior of the L∞ norm for FD/FEM/SEM.

-2
10
FD, FEM, SEM

10-3

500 1000 1500


N

Like was mentioned above, the behavior of the spectral approach do not reveal what is expected
from theory. In the case of time-stepping for FD and FEM the L∞ norm decrease in magnitude
when the time step became small until certain point where the error increased again, which can be
due to the round-off error. For the spectral approach the behavior was according with what was
expected.

Based on the conclusion of time stepping, one question becomes interesting: How much the solver
can affect the solution, because for the first two cased the Thomas algorithm was used, whereas
for the spectral case, the GMRES solver was used to solve the system of equations. How much the
round-off error is propagated within the Thomas Algorithm?.

Another point that was interesting is how much the number of terms used in the analytical solution
are necessary to get a reliable answer?, and how big is the error introduced in the solution when
the trapezoidal rule is employed to get the coeficients of the analytical solution?

16
Some numerical tests have to be developed to get the answers for this questions. For the doubt
about the number of terms involved in the analytical solution, a preliminary exercise was done
in which the solution was cakculated with 5 times more terms, and the response of the system
was the same. The test was performed for FD/FEM/SEM and in all cases the same situation
ocurred. Then based on that, it canbe said that the analytycal solution is not strongly affected by
the number of term used to get it, as long as you use enough number of terms.

17

You might also like