0% found this document useful (0 votes)
47 views40 pages

CFD Lec5

The document summarizes the central difference discretization and error analysis for the 1D Poisson equation with various boundary conditions. It discusses: 1) The central difference discretization of the Poisson equation and its matrix formulation. 2) Consistency and stability analysis showing the discretization error is O(Δx^2). 3) Influence of errors in the right hand side f and analysis of relative error. 4) Extension to Dirichlet-Neumann and inhomogeneous boundary conditions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views40 pages

CFD Lec5

The document summarizes the central difference discretization and error analysis for the 1D Poisson equation with various boundary conditions. It discusses: 1) The central difference discretization of the Poisson equation and its matrix formulation. 2) Consistency and stability analysis showing the discretization error is O(Δx^2). 3) Influence of errors in the right hand side f and analysis of relative error. 4) Extension to Dirichlet-Neumann and inhomogeneous boundary conditions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 40

Poisson equation in 1D

Dirichlet problem
( 2
− ∂∂xu2 = f in Ω = (0, 1)
u(0) = 0, u(1) = 0

Central difference discretization


(
− ui−1 −2ui +ui+1
(∆x)2 = fi , i = 1, . . . , N − 1
u0 = uN = 0
2 −1
 
1  −1 2 −1 
Au = f, A=  −1 2 −1 
(∆x)2  ...

−1 2
Error analysis

Let u(xi ) be the exact solution at the mesh point xi . The local
truncation error of the CD approximation is O(∆x)2 , i.e.,

u(xi−1 ) − 2u(xi ) + u(xi+1 )


− = fi + (∆x)2 pi
(∆x)2

The solution vectors u = {ui } and uex = {u(xi )} satisfy

Au = f, Auex = f + (∆x)2 p

The error e = uex − u satisfies the linear system

Ae = (∆x)2 p, ei = u(xi ) − ui
Error analysis

The global error is measured using a norm, e.g., the Euclidean norm
v
u n 2
uX
kvk = t vj , v ∈ Rn
j=1

The CD discretization of the 1D Poisson equation is consistent

∆x → 0 ⇒ kAuex − f k = (∆x)2 kpk → 0

The discretization is stable if there exists a constant C > 0 s.t.

kuex − uk ≤ CkAuex − f k
Error analysis

The matrix A is non-singular and symmetric. The natural norm


induced by the Euclidean vector norm k · k is the spectral norm

−1 1
A = , λmin = min{|λ1 |, . . . , |λN −1 |}
λmin

Ae = (∆x)2 p kek = (∆x)2 A−1 p



≤ (∆x)2 A−1 kpk = A−1 kAuex − f k


The finite difference discretization Au = f is stable if

∃C > 0 s.t. kA−1 k ≤ C


Error analysis

The CD approximation of ∂xx yields


 
4 2 πN −j
λj = sin , λmin = λN −1
(∆x)2 2 N

For large N (on a fine mesh) we have

4 2
 π  4  π 2
λN −1 = sin ≈ = π2
(∆x)2 2N (∆x)2 2N

This proves stability and convergence


1 1
kuex − uk ≤ 2
kAuex − f k = 2 (∆x)2 kpk
π π
Error analysis

Assume that there is an error δf in the right-hand side f

The resulting solution u + δu satisfies the linear system

A(u + δu) = f + δf, Au = f

Similarly to the analysis of the approximation error, we have


1
Aδu = δf, kδuk ≤ kδf k
π2
The system is well-conditioned w.r.t. the absolute error
Error analysis

To estimate the relative error, divide by kuk


 
kδuk 1 kδf k 1 kf k kδf k
≤ 2 = 2
kuk π kuk π kuk kf k

The ratio of kf k and kuk determines the sensitivity of the relative


error to relative changes in f

It is possible that the problem is well-conditioned w.r.t. absolute


error but ill-conditioned w.r.t. relative error
Other boundary conditions

Dirichlet-Neumann problem
( ∂2u
− ∂x2 = f in Ω = (0, 1)
∂u
u(0) = 0, ∂x (1) =0

Central difference discretization of the Poisson equation


ui−1 − 2ui + ui+1
− = fi , i = 1, . . . , N
(∆x)2

Discretization of the Neumann boundary condition


uN +1 − uN −1 uN −1 − uN 1
=0 ⇒ − = fN
2∆x (∆x)2 2
Other boundary conditions

The matrix form of the linear algebraic system becomes

Au = f, A ∈ RN ×N , u, f ∈ RN

The matrix A is tridiagonal, symmetric positive-definite


2 −1
 
−1 2 −1
1  −1 2 −1

A=
 
(∆x)2 
 ... 
−1 2 −1

−1 1

The smallest eigenvalue λmin is again O(1)


Local error analysis

Consider the Taylor expansion about the point x = 1

∂u (x − 1)2 ∂ 2 u
u(x) = u(1) + (x − 1) (1) + (1)
∂x 2 ∂x2
(x − 1)3 ∂ 3 u
+ (1) + . . .
6 ∂x3
The local truncation error is given by O(∆x)

∂2u u(xN −1 ) − u(xN )


2
(1) = −2 + O(∆x)
∂x (∆x)2

How does it influence the global error?


Global error analysis

Let u(xi ) be the exact solution at xi . We have

u(xi−1 ) − 2u(xi ) + u(xi+1 )


− = fi + (∆x)2 pi
(∆x)2
for i = 1, . . . , N − 1. The last equation is

u(xN −1 ) − u(xN ) 1
− 2
= fN + ∆xqN
(∆x) 2

Let u = {ui } and uex = {u(xi )} be solutions of

Au = f, Auex = f + (∆x)2 p + ∆xq


Global error analysis

The approximation error e = uex − u satisfies

Ae = (∆x)2 p + ∆xq

Let e(p) and e(q) be solutions of

Ae(p) = (∆x)2 p

Ae(q) = ∆xq

By linearity, we have Ae = A(e(p) + e(q) ) and therefore

e = e(p) + e(q)
Global error analysis

The approximation error e(p) arises at inner points


1
ke(p) k ≤ C(∆x)2 kpk, C= = O(1)
λmin

The approximation error e(q) arises at the point xN = 1


(q) (q) (q)
ei−1 −2ei +ei+1
− (∆x)2 = 0, i = 1, . . . , N − 1
(q) (q)
eN −1 −eN
− (∆x)2 = ∆xqN

The exact solution of the linear system is


(q)
ei = i(∆x)3 qN , i = 1, . . . , N
Global error analysis

(q)
Substituting ei = i(∆x)3 qN into the linear system, we obtain
(q) (q) (q)
e − 2ei + ei+1
− i−1 = −(i − 1 − 2i + i + 1)(∆x)qN = 0
(∆x)2
(q) (q)
eN −1 − eN
− = −(N − 1 − N )(∆x)qN = ∆xqN
(∆x)2

(q)
Since xi = i∆x, we have ei = (∆x)2 xi qN . It follows that

kek = ke(p) + e(q) k ≤ (∆x)2 (Ckpk + qN kxk)


Inhomogeneous boundary conditions

Consider the Dirichlet boundary condition

u(0) = g1

Substitution into the first equation yields


 u0 −2u1 +u2
− (∆x)2 = f1 2u1 − u2 g1
⇒ = f1 +
u0 = g1 (∆x)2 (∆x)2

The first component of the right-hand side f changes

The matrix A is the same as in the case g1 = 0


Inhomogeneous boundary conditions

Consider the Neumann boundary condition


∂u uN +1 − uN −1
(1) = g2 , = g2
∂x 2∆x

Substitution into the first equation yields


(
− uN −1 −2u N +uN +1
(∆x)2 = fN uN −1 − uN 1 g2
⇒ − 2
= fN +
uN +1 = uN −1 + 2∆xg2 (∆x) 2 ∆x

The first component of the right-hand side f changes

The matrix A is the same as in the case g2 = 0


Inhomogeneous boundary conditions

Consider the Robin boundary condition


∂u
(1) + αu(1) = g3
∂x
uN +1 − uN −1
+ αuN = g3
2∆x

Substitution into the last equation yields

uN −1 − (1 + α∆x)uN 1 g3
− 2
= fN +
(∆x) 2 ∆x

The matrix A and the right-hand side f change


Convection-diffusion in 1D

0.9

Dirichlet problem 0.8


Pe=0
Pe=10
Pe=100
( 2 0.7

− ∂∂xu2 = −P e ∂u
∂x in (0, 1) 0.6

u(0) = 0, u(1) = 1 0.5

0.4

0.3

0.2

For the time being let P e ≥ 0 0.1

0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

Exact solution and its derivative


eP e x − 1 du P e eP e x
u(x) = , = Pe
eP e − 1 dx e −1
Convection-diffusion in 1D

The exact solution satisfies the maximum principle

0 ≤ u(x) ≤ 1 ∀x ∈ (0, 1)

A boundary layer forms near x = 1 at large Peclet numbers

du P e eP e
Pe  1 ⇒ (1) = P e ≈ Pe
dx e −1

This is an example of a singularly perturbed problem


Convection-diffusion in 1D

First-order BD-CD discretization


ui − ui−1 ui−1 − 2ui + ui+1
Pe − =0
∆x (∆x)2

Second-order CD-CD discretization


ui+1 − ui−1 ui−1 − 2ui + ui+1
Pe − =0
2∆x (∆x)2

Dirichlet boundary conditions

u0 = 0, uN = 1
Convection-diffusion in 1D

1.2

Pe=100, exact
1
h=10−1, 1st−order
h=10−1, 2nd−order
0.8 h=10−2, 1st−order
h=10−2, 2nd−order
0.6

0.4

0.2

−0.2

−0.4

−0.6

−0.8
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Convection-diffusion in 1D

The CD solution oscillates and the sign changes at each node

The BD gradient is not as steep as that of the exact solution

As the mesh is refined, oscillations in the CD solution disappear


and the slopes of the BD solution become steeper

The error of the CD approximation decreases quadratically

The error of the BD approximation decreases linearly


Convection-diffusion in 1D

Finite difference discretization


aui−1 + bui + cui+1
= 0, i = 1, . . . , N − 1
(∆x)2

auN −2 + buN −1 c
uN = 1 ⇒ 2
=−
(∆x) (∆x)2

Coefficients of the linear system

a b c
BD-CD −1 − P e∆x 2 + P e∆x −1
CD-CD −1 − P e∆x
2 2 −1 + P e∆x
2
Convection-diffusion in 1D

Matrix form of the linear system Au = f


b c 0
   
1  a b c   0 
A=  a b c , f =  0 
(∆x)2  ...
  · 
c
a b − (∆x) 2

The entries of the coefficient matrix A satisfy

a < 0, b > 0, a+b+c=0

A is tridiagonal but not symmetric for P e > 0


Analysis of the discrete problem

Consider a discretization leading to the linear system

aui−1 + bui + cui+1 = 0, i = 1, . . . , N − 1

The solution of this discrete problem is a polynomial of the form

ui = α + βri , i = 0, 1, . . . , N

The constants are determined using the boundary conditions

u0 = 0, uN = 1
Analysis of the discrete problem

Substitution of ui = α + βri into the i-th equation yields

α(a + b + c) + β(ari−1 + bri + cri+1 ) = 0

where
a+b+c=0 ⇒ cr2 − (a + c)r + a = 0

The roots of this quadratic equation are


p
(a + c) ± (a + c)2 − 4ac (a + c) ± (a − c)
r1,2 = =
2c 2c
Analysis of the discrete problem

The equation cr2 − (a + c)r + a = 0 has two roots


a
r1 = , r2 = 1
c
The root r = r2 does not satisfy the boundary conditions for

ui = α + βri

Substituting r = r1 into this formula, we obtain


 a i
ui = α + β
c
Analysis of the discrete problem

The Dirichlet boundary conditions are given by


 a N
u0 = α + β = 0, uN = α + β =1
c
The corresponding values of α and β are
1 1
α=− , β=
a N a N
 
1− c 1− c

The solution of the discrete problem is


a i

1− c
ui = , i = 1, . . . , N
a N

1− c
Analysis of the discrete problem

Solution of the difference equations


P  a i  a N
ui = , P =1− , Q=1−
Q c c
a < 0, b > 0, a+b+c=0

a
In the case c < 0, we have c >0
a
c >1 ⇒ P < 0, Q < 0, 0 < ui < 1
a
c <1 ⇒ P > 0, Q > 0, 0 < ui < 1

The solution satisfies the maximum principle


Analysis of the discrete problem

Solution of the difference equations


P  a i  a N
ui = , P =1− , Q=1−
Q c c
a < 0, b > 0, a+b+c=0

a
In the case c > 0, we have c <0
a
a + c = −b < 0 ⇒ c < −a ⇒ c < −1

Alternating signs: if ui > 0 then ui±1 < 0

The solution violates the maximum principle


Analysis of the discrete problem

In the case c = 0, the difference equations reduce to


a
ui = − ui−1 = 0, i = 1, . . . , N − 1
b

Invoking the Dirichlet boundary conditions, we find that

u0 = u1 = · · · = uN −1 = 0, uN = 1

The maximum principle holds but the solution is inaccurate


Summary

In the case c > 0, violations of the maximum principle are possible;


the matrix A is not diagonally dominant

a < 0, b > 0, b = −a − c ⇒ |b| < |a| + |c|

In the case c ≤ 0, violations of the maximum principle are ruled out;


the matrix A is diagonally dominant

a < 0, b = −(a + c) ⇒ |b| = |a| + |c|

The case c = 0 should be avoided for accuracy reasons


Analysis of the CD-CD scheme

Equations of the difference scheme


ui+1 − ui−1 ui−1 − 2ui + ui+1
Pe − =0
2∆x (∆x)2

This discretization corresponds to c = −1 + P e∆x


2 . The sufficient
(not necessary) condition of the maximum principle is

c≤0 ⇔ P e∆x ≤ 2

If P e is very large, the mesh size ∆x must be very small

It is worthwhile to refine the mesh just in subdomains where


violations of the maximum principle would occur otherwise
Analysis of the BD-CD scheme

Equations of the difference scheme


ui − ui−1 ui−1 − 2ui + ui+1
Pe − =0
∆x (∆x)2

For this discretization c = −1 regardless of the mesh size

The maximum principle is satisfied but the error is O(∆x)

For accuracy reasons ∆x must be chosen very small; otherwise


the solution will be strongly smeared by numerical diffusion

In contrast to CD-CD local mesh refinement is insufficient


Analysis of the BD-CD scheme

Taylor expansions for ui±1 = u(xi±1 )


(∆x)2 ∂ 2 u (∆x)3 ∂ 3 u
     
∂u
ui±1 = ui ± ∆x + ± + ...
∂x i 2 ∂x2 i 6 ∂x3 i

Residual of the difference equation


   2 
ui − ui−1 ui−1 − 2ui + ui+1 ∂u ∂ u
Pe − = P e −
∆x (∆x)2 ∂x i ∂x2 i
| {z }
=0
 2 
P e∆x ∂ u
− + O(∆x)2 = O(∆x)
2 ∂x2 i
Analysis of the BD-CD scheme

The BD-CD scheme is a first-order accurate approximation to

∂u ∂ 2 u
Pe − =0
∂x ∂x2
but a second-order accurate approximation to

P e∆x ∂ 2 u
 
∂u
Pe − 1+ =0
∂x 2 ∂x2

The numerical diffusion coefficient P e∆x


2 is proportional to the
mesh size ∆x and tends to zero very slowly
Upwind difference scheme

The analysis of the BD-CD scheme was performed for P e > 0

If P e < 0, then a = −1 − P e∆x may assume positive values

The maximum principle holds for any ∆x if the convective term is


discretized using the first-order upwind difference approximation

backward difference, P e > 0
upwind difference =
forward difference, Pe < 0

Upwind difference approximations of second and higher order may


produce oscillations in the vicinity of steep gradients
Adaptive schemes

Equations of the difference scheme

(1 + ωi−1/2 )(ui − ui−1 ) + (1 − ωi+1/2 )(ui+1 − ui )


Pe
2∆x
ui−1 − 2ui + ui+1
− = 0, i = 1, . . . , N − 1
(∆x)2

backward difference for ωi±1/2 = 1, central difference for


ωi±1/2 = 0, forward difference for ωi±1/2 = −1

optimal choice of ωi±1/2 depends on the solution


Nonuniform meshes

So far we considered difference approximations on uniform meshes

For accuracy and efficiency reasons, it is worthwhile to use meshes


designed to equidistribute local truncation errors

i ≈ , i = 1, . . . , N − 1

Taylor expansion reveals that i depends not only on ∆x but also on


the derivatives of the exact solution at xi

Hence, the use of nonuniform meshes is generally required to achieve


a (nearly) uniform distribution of local errors
Nonuniform meshes

To balance i , the local mesh size ∆xi = xi − xi−1 should be small


if derivatives of u are large and large if derivatives are small

Since the exact solution is unknown, the magnitude of the derivatives


needs to be estimated in terms of approximate solution values

The location of boundary layers is usually known a priori but large


derivatives are also found in internal layers and moving fronts

If the mesh is nonuniform, the finite difference approximations


considered so far require generalization and further analysis

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy