0% found this document useful (0 votes)
166 views132 pages

Sryedida CFD Lectures

This document discusses various methods for solving systems of linear equations, including direct and iterative methods. Direct methods include Gaussian elimination, LU decomposition, and Cholesky decomposition. Iterative methods include stationary iteration methods like Jacobi and Gauss-Seidel, as well as conjugate gradient and generalized minimal residual. The document also covers preconditioning techniques to improve the convergence of iterative methods.

Uploaded by

Ajay Vasanth
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)
166 views132 pages

Sryedida CFD Lectures

This document discusses various methods for solving systems of linear equations, including direct and iterative methods. Direct methods include Gaussian elimination, LU decomposition, and Cholesky decomposition. Iterative methods include stationary iteration methods like Jacobi and Gauss-Seidel, as well as conjugate gradient and generalized minimal residual. The document also covers preconditioning techniques to improve the convergence of iterative methods.

Uploaded by

Ajay Vasanth
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/ 132

Solvers

Y V S S Sanyasiraju
Associate Professor
Department of Mathematics
IIT Madras, Chennai 600036
Early Methods

Cramers rule

Matrix inversion methods

February 19, 2010 [email protected] 2


Methods to solve large systems

Direct methods

Iterative methods

February 19, 2010 [email protected] 3


Coefficient Matrix Structure

Triangular

Diagonal

February 19, 2010 [email protected] 4


Elementary Transformations

Interchange of two rows

Multiplying a row by a nonzero constant

Adding to one row a multiple of another

February 19, 2010 [email protected] 5


Direct Methods

Elimination Methods

Decomposition Methods

February 19, 2010 [email protected] 6


Gauss Elimination

There are two basic steps in Gauss elimination

Forward elimination : Converting the given system into


upper triangular form. ( Algorithm )

Back substitution : Finding the unknown vector in reverse


order( the last element first and so on ). ( Algorithm )

Next

February 19, 2010 [email protected] 7


Forward Elimination
for k = 1, 2, . . ., n-1 do
for i = k+1, k+2, . . ., n do
z = aik/akk
aik = 0; bi = bi z*bk
for j = k+1, k+2, . . ., n do
aij=aij z*akj
end
end
end back

February 19, 2010 [email protected] 8


Back Substitution

for i = n, n-1, . . . , 1 do
n
bi a
j =i +1
i, j xj
xi =
end ai ,i

back

February 19, 2010 [email protected] 9


Drawback

If any of the diagonal element of the coefficient matrix A


is zero or close to zero then the elements of the rows below
this diagonal become very large in magnitude. These
quantities with large magnitude are difficult to handle
because of the finite storage capacity of the computers.

February 19, 2010 [email protected] 10


Remedy Pivoting

Partial (scaled row) pivoting

Complete pivoting

February 19, 2010 [email protected] 11


Scaled Row Pivoting

Solve the permuted linear system

PAx = Pb

where P is a permutation matrix derived


from the permutation array.
February 19, 2010 [email protected] 12
Permutation Array

{
si = max ai , j = max ai ,1 , ai ,2 ,K , ai ,n
1 j n
} (1 i n)

ai , j
Pivotal Row = pi = max for 1 i n
i jn si
P = { p1 , p2 ,K , pn }

February 19, 2010 [email protected] 13


Tri-diagonal systems _Thomas Algorithm
Consider the system Ax = d such that

A is a tri-diagonal matrix like diag{a b c}

Forward Elimination
ac ad
bi = bi i i 1 , di = di i i 1
bi 1 bi 1
Back Substitution
( di ci xi +1 )
xi =
bi

February 19, 2010 [email protected] 14


Decomposition

LU Decomposition

Cholesky Decomposition

February 19, 2010 [email protected] 15


LU Decomposition

In this method the coefficient matrix A is written as a product


of lower triangular matrix L and an upper triangular matrix
U so that Ax = b becomes LUx = b. Once L and U are
known, we can write
Ux = y
Ly = b

February 19, 2010 [email protected] 16


Finding L and U

j 1

lij = aij - lik ukj (for i < 1)


k =1

i1
uij = aij - lik ukj (for i > 1)
k=1

uii = 1

Gauss elimination Vs LU decomposition


February 19, 2010 [email protected] 17
Cholesky Decomposition

U = LT

A must be symmetric & positive definite

February 19, 2010 [email protected] 18


Operational count (Complexity)
Forward elimination
no. of divisions = n = n(n+1)/2

no. of multiplications = n (n-1) = n (n+1)(n-1)


Back substitution 3
no. of multiplications = (n-1) = n(n-1)/2

Total multiplications & divisions = n (n2 + 3n -1)


3
Complexity of Gauss elimination is O( )
n3
February 19, 2010 [email protected] 3 19
Ill - conditioned systems
Since the numbers stored in a computer are subjected to
round off errors the matrices A and b cannot be stored
exactly.
Let A and b are the round off errors in A and b respectively

(A + A) x = b + b

|| x$ - x || || ( A + A )-1 - A-1|| || b || + || ( A + A )-1 || || b ||


where || . || is any matrix norm
February 19, 2010 [email protected] 20
Ill - conditioned systems continued

) || A 1 ||
|| x - x || ( || A-1A|| + || b || )
(1|| A1A||)

)
|| x x || || b || || A || k (A )
+
|| x || || b || || A || 1 || A 1 A ||

where k(A) = ||A|| ||A-1|| is called the condition number of A.


A system with large k(A) is called an ill-conditioned
system.
February 19, 2010 [email protected] 21
Example
Consider 2.1x + 1.8y = 2.1
6.2x + 5.3y = 6.2

max eigen value = 74.18, min eigen value = 0.000012

max ev
k(A) = = 2472.73
min ev

solution = (1, 0)T


(with b2 = 6.23) solution = (2.8 - 2.1)T
February 19, 2010 [email protected] 22
Iterative methods

Stationary iteration matrix methods

Partially stationary iteration matrix methods

Non-stationary iteration matrix methods (ADI method)

February 19, 2010 [email protected] 23


Stationary Iteration matrix methods

Richardson Method x = (I-A)x+b = x + r; r = b - Ax

Jacobi Method Q = D-1(L+U)

Gauss - Siedel Method Q = (D-L)-1U

SOR Method Q = (I - D-1L)-1((1- )I+ D-1U) where 0 < w < 2

February 19, 2010 [email protected] 24


Convergence

A necessary and sufficient condition for the


convergence of any iterative scheme
(x=Gx+c, G is the iteration matrix) is the
spectral radius of the iterative matrix must
be less than one.

Sufficient condition : Diagonal Dominance

February 19, 2010 [email protected] 25


P.S.I.M methods
Consider all the vectors which are expressed as a linear
combination of the successive iterates of

= Q + C as

(t) = ak,i (k)


k=0

is called the partially stationary iterative procedure.

February 19, 2010 [email protected] 26


Various P S I M Methods

Conjugate Gradient method (CG)


Generalized Minimal Residual method (GMRES)
Bi-Conjugate Gradient method (BiCG)
Quasi-Minimal Residual method (QMR)
Bi-Conjugate Gradient Stabilized method (Bi-CGSTAB)

February 19, 2010 [email protected] 27


Preconditioners

The convergence rate of any iterative method depends on


spectral properties of the coefficient matrix. If we can alter
these spectral properties more favorably by pre-multiplying
or post - multiplying with a matrix with out altering the
solution then such a transformation is called preconditioning

February 19, 2010 [email protected] 28


Preconditioners

Jacobi preconditioning mi,j = ai,j if i = j


=0 otherwise

SSOR preconditioning M = (D+L)D-1(D+L)T

Incomplete factorization M = LU

(for CG replace r0 with M1-1r0 in the initial residual)

February 19, 2010 [email protected] 29


Preconditioning
Example 1
Dirichlet problem on a rectangle

2U = 0, 0 x 1, 0 y 1

Boundary conditions
U(x,1) = U(y,1) = U(0,y) = 0 and
U(x,0) = x(x-1)
February 19, 2010 [email protected] 30
Preconditioning

Nodes CGM PRE-1 PRE-2 PRE-3


20 28 28 19 13
30 42 42 28 18
50 70 70 45 28

February 19, 2010 [email protected] 31


Example 2 Neumann problem for a rectangle

2U = 0, 0 x 1, 0 y 1

Boundary conditions:
Ux(x,1) = sin3 y and
U(1,y) = U(0,y) = U(x,0) = 0

February 19, 2010 [email protected] 32


Preconditioning

Nodes CGM PRE-1 PRE-2 PRE-3


20 1097 1086 472 172
30 2570 2579 972 365
50 7420 7444 2867 994

February 19, 2010 [email protected] 33


Example 3

Uxx + Uyy +5U = 0, 0 x 1, 0 y 1

U(x,0) = x(x-1) and


U(x,1) = U(1,y) = U(1,x) = 0

February 19, 2010 [email protected] 34


Preconditioning

Nodes CGM PRE-1 PRE-2 PRE-3


20 15 15 11 9

February 19, 2010 [email protected] 35


Text Books

Golub G and Van Loan C, Matrix computations, John


Hopkins University press, 1989
Duff I S, Erisman A M and Reid J K, Direct methods for
sparse matrices, Oxford University Press, 1986
Hageman L and Young D, Applied Iterative methods,
Academic Press, 1981
Varga R, Matrix Iterative analysis, Prentice-Hall, 1962

February 19, 2010 [email protected] 36


Pressure Correction Schemes
Sanyasiraju Y V S S, Associate Professor
Department of Mathematics, IIT Madras
Navier Stokes Equations
Steady, incompressible and viscous fluid flow is
governed by

Continuity equation .u = 0
1
Momentum equation (u.)u = p + u
Re
1
Energy equation (u.)T = T
Pr
where u (velocity vector), (gradient), T (Temperature),
(Laplace operator), Re (Reynolds number), Pr(Prandtle number)
Non-Dimensional Integral form
(Two-Dimensional)
u dv + v dv = 0

p 1
(u.)u dv = x dv + Re u dv
p 1
(u.)v dv = y dv + Re v dv
1
(u.)T dv = Pr T dv
where is the control volume
CheckerboardPressurefield
GridGeneration:Staggeredgrid
Staggered Grid
Typical u, v and p-cells
At center node of u control
volume
p p P pW
= 0
x x
At center node of v control
volume

p p P p S
= 0
y y
GaussDivergencetheorem

p u u j nds
( ) 1
=
(uu )i + (vu ) j nds dV + i+
u u
x Re u x y

p v v j nds
( ) 1
(uv)i + (vv) j n ds =
^
dV + i+
v v
y Re v x y

( (u)i + (v) j ) nds


=0
p
xMomentumEquation
1 u u u u p
Feue Fwuw + Fnun Fs us = ( A) ( A) + ( A) ( A) s Vu
Re x x y y x
e w n

u +u
i, J i 1, J where Fs are mass fluxes of the
Fw = Aw corresponding cell face
2
u +u
i +1, J i, J
Fe = Ae
2
v +v
I, j I 1, j
Fs = As
2
v +v
I , j +1 I 1, j + 1
Fn = An
2
Diffusiveandpressurepartsofx
momentumequation.
u (u E u P )
=
x e x
u (u P uW )
=
x w x
u (u u )
= N P

y n
y
u (u u ) p ( pe pw) V u = x y

y
= P

y
S
=
s
x x
Interpolation at Cell Interfaces

Upwind Difference Scheme (UDS)


Central Difference Scheme (CDS)
Linear Upwind Difference Scheme (LUDS)
Quadratic Upstream Interpolation for Convective
Kinematics (QUICK) Scheme [ Han et al (1981),
Pollard and Siu (1982) and Hayase et al (1992) ]
(QUICK)
Velocitycomponentsatcellfaces
(QUICKscheme)
u e = e ( u i , J + S e+ ) + (1 e ) ( u i + 1 , J + S e )
uw = w ( u i 1 , J + S w+ ) + (1 w ) ( u i , J + S w )
u n = n ( u i , J + S n+ ) + (1 n ) ( u i , J + 1 + S n )
u s = s ( u i , J 1 + S s+ ) + (1 s ) ( u i , J + S s )

where Ss are source terms and.

if
k = 1 Fk > 0
k = 0 if
Fk < 0
for k=e, w, n, s.
SourceTerms

S = ( u i 2 , J 2 u i 1, J + 3u i , J )
+ 1
S = ( ui,J 2 2ui,J 1 + 3ui,J )
+ 1 w
8
s
S w = ( u i +1, J 2 u i , J + 3u i 1, J )
8 1
8
Ss = ( ui,J +1 2ui,J + 3ui,J 1 )
1
8
S = ( ui 1, J 2ui , J + 3ui +1, J ) S = ( ui , J 1 2ui , J + 3ui , J +1 )
+ 1 +1
e n
8 8
Sn = ( ui , J +2 2ui , J +1 + 3ui , J )
1
Se = ( ui + 2, J 2ui +1, J + 3ui , J )
1

8 8
Discretised xandymomentum
equations
ai , J ui , J = anb u nb ( p I 1, J p I , J ) Ai , J + bi , J

a I , j v I , j = anb vnb ( p I , J 1 p I , J ) AI , j + bI , j
where

u i,J , v I ,J are centre nodes and u nb , v nb are


neighboring nodes of u and v control volumes respectively.
Coefficientsinxmomentum
equation
a i 1, J y
F +
R e x
w w

a i +1, J y
(1 )F +
R e x
e e

x
ai , J 1 F +
R e y
s s

x
ai , J +1 (1 )Fn +
Re y
n

bi , J = Fnb ( nb S nb
+
+ (1 nb ) S nb

)
ai , J = anb + Fe Fw + Fn Fs
SIMPLE
Semi-Implicit Method for
Pressure Linked Equations
FirststepinSIMPLEalgorithm
Guess pressure field p * and initial velocities and use
them to solve momentum equations to get guessed
velocity components.

a u = a u + ( p

i ,J i ,J

nb nb

I 1, J

p ) Ai ,J + bi ,J
I ,J

a v
I ,J I ,J = a v + ( p

nb nb

I , J 1

p ) AI , j + bI , j
I ,J

*
where u * and v are guessed velocities.
Define pressure correction p ' and velocity u ' , v '
corrections
p = p + p , u = u + u , v = v + v
where p , u , v are correct pressure and correct
velocities respectively.
CorrectionFormulae
Substituting correct pressure field yields correct velocities

a i,J u i,J = a nb
u n b + ( p I 1, J p I , J ) A i , J + b i , J
a I ,J v I ,J = a nb
v n b + ( p I , J 1 p I , J ) A I , j + b I , j

Subtracting momentum equations involving guessed quantities from


above equations correction formulae can be written as

a i , J u i , J = a n b u ' n b + ( p I 1 , J p I , J ) A i , J
'
a I , j v ' I , j = a n b v n b + ( p I , J 1 p I , J ) A I , j
SIMPLEApproximation
Omission of following terms is the main approximation
of the SIMPLE

a nbu 'nb a v
nb nb

After approximation correction formulae will be


u 'i , J = d i , J ( p ' I 1, J p ' I , J )
v ' I , j = d I , j ( p ' I , J 1 p ' I , J )

Ai,J AI , j
where d i,J = d I ,J =
ai,J a I , j
VelocityCorrection

ui , J = ui*, J + d i , J ( p 'I 1, J pI , J )
vI , j = vI*, j + d I , j ( p 'I , J 1 pI , J )

Similarly

u i +1, J = u i*+1, J + d i +1, J ( p ' I , J p I +1, J )


v I , j +1 = v I*, j +1 + d I , j +1 ( p ' I , J p I , J +1 )
Pressure correction in continuity
equation
Discretized continuity equation
[(uA) (uA) ] + [(vA) (vA) ] = 0
i +1, J i, J I , j +1 I, j
Substituting correct velocities into above equations and
rearranging and identifying the coefficients of pressure
correction we get pressure correction equation as
a I , J p I , J = a I + 1, J p I + 1, J + a I 1, J p I 1, J + a I , J + 1 p I , J + 1 + a I , J 1 p I , J 1 + b I , J
where
a I + 1, J = ( dA ) i + 1, J a I , J +1 = ( dA ) I , j + 1 No necessity for
a I 1, J = ( dA ) i , J a I , J 1 = ( dA ) I , j any pressure BCs

a I , J = a I 1, J + a I + 1, J + a I , J + 1 + a I , J 1

b 'I ,J = ( u * A ) i,J ( u * A ) i+1,J + ( v * A ) I , j ( v * A ) I , j +1


Convergence:
Pressure correction equation converges under relaxation i.e.
p new = p + p p
u new
= u u + (1 u )u n 1

v new = v v + (1 v ) v n 1
Similarly for velocity component

Under relaxation of discretised momentum equations takes form


ai,J a
u i , J = a n b u n b + ( p I 1, J p I , J ) Ai , J + [(1 u ) i , J ]u in, J 1 + b i , J
u u
aI, j aI, j
v
vI , j = a n b v n b + ( p I , J 1 p I , J ) A I , j + [(1 v )
v
] v In,j1 + b I , j

Under relaxation pressure is also affected by velocity therefore d


terms of pressure correction equation becomes
Ai, Ju Ai+1, Ju AI , j v AI , j +1v
di, J = di+1, J = dI , j = dI , j +1 =
ai, J ai+1, J aI , j aI , j +1
OutlineoftheSIMPLE
Guess pressure field.
Solve under relaxed discretized momentum
equations using guessed pressure to obtain
approximate velocity field.
Solve pressure correction equation using
computed velocity field in source terms.
Correct the pressure and velocity .
Repeat the procedure from step 2 till the
convergence
SIMPLERevised
Discretised Momentum Equations
Pseudo Velocities
Pressure Equation
SIMPLER (Algorithm)
START
Initial Guess , u , v

STEP1:Calculate pseudo velocities-discretised


u i , J =
a nb u nb + bi,J
a i,J

v I , j =
a nb v nb + b I , j
aI,j

u , v
STEP 2:Solve pressure equation
a I , J p I , J = aI 1, J pI 1, J + aI +1, J p I +1, J + a I , J 1 p I , J 1 + a I , J +1 p I , J +1 + bI , J

p
A
SET p*=p

STEP3:Solve discretised momentum equation


ai , J u i , J = nb nb I 1 J I , J ) Ai , J + bi , J
a u
+ ( p
, p

ai , J v I , J = nb nb I J 1 I , J ) AI , J + bI , J
a v
+ ( p
, p


u ,v

STEP 4: solve pressure correction equation


aI , J pI , J= aI 1, J pI 1, J +aI +1, J pI +1, J +aI , J 1 pI , J 1 +aI , J +1 pI , J +1 +bI , J

p
A
A
STEP 3: correct and velocities

u i , J = u i , J + d i , J ( p I 1 , J p I , J )

v I , j = v I , j + d I , j ( p I , J 1 p I , J )
p = p, u = u
v = v

p, u, v
NO
Convergence?
YE S
stop
SIMPLER (Algorithm)
TestProblem LidDrivenCavityFlow

u=1,v=0

u=0,v=0 u=0, v=0

u=0, v=0
Streamlines and Vorticity contours at Re = 100.
Velocity components at the
center of the cavity
Vorticity and streamlines at Re = 1000.
References
Han et al, A comparison of hybrid and quadratic upstream differencing in high
Reynolds number elliptic flows, Compu. methods Appl.Mech. Eng., 29, 81-95, (1981).

Hayase T et al, A consistently formulated QUICK scheme for fast and stable
convergence using finite volume iteration, Journal of computational physics, 98, 108-
118, (1992).

Pollard A and Siu A L W, The calculation of some laminar flows using various
discretisation schemes, Compu. methods Appl.Mech. Eng., 35, 293-313, (1982).

Versteeg H K, Malalasekera W, An introduction to CFD: The finite volume method,


Addison Wesley Longman Limited, England (1995).
THANK YOU

[email protected]
Consistency, Stability & Convergence
of the Numerical Schemes

Dr. YVSS Sanyasiraju


Associate Professor
Department of Mathematics, IIT Madras
Elliptic Equations

2u 2u
Consider the two dimensional Laplace equation, + =0
x 2
y 2

Applying central difference approximation, we obtain,

ui+1, j 2ui, j + ui1, j ui, j+1 2ui, j + ui, j1


+ =0
x 2 2
y

2ui, j 1 + ui1, j + ui, j + ui+1, j + 2ui, j +1 = 0


where = x
y
and = 2(1 + 2 )
i = 0 ,1, K m
j = 0 ,1, K n

February 19, 2010 [email protected] 2


Leads to a linear system

AU = B
U = (u1,1 u2,1 u3,1 u1,2 u2,2 u3,2 u1,3 u2,3 u3,3 )
B = (u0,1 2u1,0 , 2u2,0 , u4,1 2u3,1 , u0,2 , 0 , u4,2 ,
u0,3 2u1,4 , 2u2,4 , u4,3 2u3,4 )
1 0 2
0 0 0 0 0

1 1 0 2
0 0 0 0
0 1 1 0 2
0 0 0

2
0 1 1 0 2
0 0
A=
0 2
0 1 1 0 2 0

0 0 2
0 1 1 0 2

0 0 0 2
0 1 1 0

0 0 0 0 2
0 1 1

0 0 0 0 0 2
0 1
February 19, 2010 [email protected] 3
Necessary & sufficient condition for
the Iterative schemes to be convergent

x ( n +1) = Gx ( n ) + c G is the iterative matrix


e( n +1) = Ge( n ) e is the error vector
e( n +1) = Ge( n ) = G 2 e( n 1) = L = G n e0
n
e (0)
= ck vk if G has n lin.ind. eigen vectors vk
k =1
n
e (n)
= ck kn vk
k =1

lim ( n )
for e =0 we need k < 1
n

February 19, 2010 [email protected] 4


Sufficient condition

G 1
Diagonal Dominance of A
where A is the coefficient matrix

February 19, 2010 [email protected] 5


Parabolic Equations

Consider the one-dimensional unsteady diffusion equation

u u 2
2 = 0
t x

February 19, 2010 [email protected] 6


Explicit Schemes
1) FTCS Scheme:

uin+1 = uin + r (uin1 2uin + uin+1)


t
where r = 2
x

February 19, 2010 [email protected] 7


Explicit Schemes

2) Richardson Method:

1
( u in + 1 u in 1 )
2t

= ( u in+ 1 2 u in + u in 1 )
x2

February 19, 2010 [email protected] 8


Implicit Schemes

n +1
n +1
+ n +1
1 i +1
( u 2 u u )
(uin +1 u n ) = i i 1
t x 2 + (1 )(uin+1 2uin + uin1 )

=0 Explicit scheme
=1/2 Crank Nicholson scheme
=1 Fully implicit scheme

February 19, 2010 [email protected] 9


Two Dimensional Parabolic Equation

u u u
2 2
2 + 2 = 0
t x y

February 19, 2010 [email protected] 10


1) FTCS Scheme:

1 n+1
t ( ) 1
( )
ui, j ui, j = 2 uin+1, j 2uin, j + uin1, j +
n
x
1
y 2
n
( n n
)
ui, j +1 2ui, j + ui, j 1

February 19, 2010 [email protected] 11


2) Crank-Nicolson Scheme:
Its similar to that of 1-D scheme, except that weve to
approximate 2nd order derivative along y-direction too.

Disadvantage: This scheme leads to a penta-diagonal system which is


non-economical to solve.

February 19, 2010 [email protected] 12


2) Alternate Direction Implicit (ADI) Method:

1
(ui, j ui, j ) = 2 (uin++1,1/j 2 2uin, +j 1/ 2 + uin+1,1/j 2 ) +
1 n +1/ 2 n
t / 2 x
1
(ui, j +1 2ui, j + ui, j 1 )
n n n
y 2

1 1
(ui, j ui, j ) = 2 (uin++1,1/j 2 2uin, +j 1/ 2 + uin+1,1/j 2 ) +
n+1 n+1/ 2
t / 2 x
1 n +1 n +1 n +1
(ui, j +1 2ui, j + ui, j 1 )
y 2

February 19, 2010 [email protected] 13
Convergence
U Exact solution
u Numerical solution

Solution is convergent whenever uU at a


grid point when the step lengths tend to zero

February 19, 2010 [email protected] 14


Lax Equivalence Theorem
Richtmyer and Morton (1967) gave an
equivalence theorem which states that for a
well posed linear, initial value problem with
a consistent discretisation, stability is the
necessary and sufficient condition for
convergence of the numerical scheme.

February 19, 2010 [email protected] 15


Consistency & Stability
consistency forces the convergence of the
exact solution of the underlying numerical
scheme to the solution of the differential
equation.
stability is concerned with the unbounded
growth or controlled decay of the errors
associated with the solution

February 19, 2010 [email protected] 16


Checking Consistency

Consistency of any numerical scheme can be


verified by looking at the truncation error of
the scheme at any grid point

Truncation error: is defined by the difference


between the exact and numerical solutions
(local)

February 19, 2010 [email protected] 17


Consistency

if the truncation error is zero when the


step lengths tend to zero then the
numerical scheme converges to the
given differential equation and hence it
is consistent

February 19, 2010 [email protected] 18


Consistency (illustration)
U 2U
1D unsteady diffusion = 2
t x

x, t space and time coordinates


U temperature distribution
thermal diffusivity (say, =1 )

February 19, 2010 [email protected] 19


Consistency (illustration)
Numerical scheme

n +1 t n
u = u + 2 (ui 1 2ui + ui +1 )
n n n

x
i i

Local Truncation Error

n
1 u 1
2
u 4
Ti n = t 2 x 2 4
2 t 12 x i

February 19, 2010 [email protected] 20


Order of the scheme

O(t , x ) 2

February 19, 2010 [email protected] 21


Consistency - counter example

(t )
u n+1
i =u n1
i +
x 2 ( uin1 2 ( uin+1 + (1 )uin1 ) + uin+1 )
n
t u x u
2 3
t u t u
2 4
t 4
2 2 3
Ti =
n
+ (2 1) 2 + 2 2 + O( 2 , x , t )
4

6 t 12 x
3 4
x t x t x i

as x tends to zero, the truncation error does


not become zero

February 19, 2010 [email protected] 22


Stability
Numerical solutions are in general prone to
two types of errors

Discretisation error

Rounding error (due to the rounding of


numbers incurred at each step of the
computation)

February 19, 2010 [email protected] 23


Stability
It is reasonable to assume that the Discretisation is
controlled or been kept at a reasonable order, then
we can say that the numerical scheme is stable if
there is a limit to the magnification of the rounding
error Rn as the number of time iterations increase to
i
infinity, that is if the growth of is bounded as n
increases to . However a much easier way to test
the stability is to test the boundedness of the
solution

February 19, 2010 [email protected] 24


Stability

Matrix method

Von Neumanns method (Fourier series method).

February 19, 2010 [email protected] 25


Matrix Method
n 1
u = Au
n

1 2r r
r 1 2 r r

r 1 2r r
A=
L L L L L L L
r 1 2r r

r 1 2 r

February 19, 2010 [email protected] 26


Matrix Method
n 1
e = Ae
n

e =Ae n n 0

n
e = ci vi
0

i =1
n n
e n = An ci vi = ci n vi
i =1 i =1

2 i 1
1 + r 4sin 1 r
2N 2
February 19, 2010 [email protected] 27
Numerical Example
Solve the 1D unsteady diffusion with initial conditions
u = 2x when 0 x ,
u = 2(1-x) when x 1 boundary conditions
u = 0 at x=0 and x=1 for all t>1
Exact solution:


8 1 1
u = 2 2 sin i ( sin i x ) e i 2 2t

i =1 i 2

February 19, 2010 [email protected] 28


February 19, 2010 [email protected] 29
x=0 x=.1 x=.2 x=.3 x=.4 x=.5 x=.6

T=0.00 0 0.2 0.4 0.6 0.8 1.0 0.8

T=0.01 0 0.2 0.4 0.6 0.8 0.6 0.8

T=0.02 0 0.2 0.4 0.6 0.4 1.0 0.4

T=0.03 0 0.2 0.4 0.2 1.2 -0.2 1.2

T=0.04 0 0.2 0.0 1.4 -1.2 2.6 -1.2

Table 7.1 Solution with r = 1.0

February 19, 2010 [email protected] 30


Gerschgorins Theorems
The largest of the moduli of the eigenvalues
of the square matrix A cannot exceed the
largest sum of the moduli of the elements
along any row or any column.
Let Ri be the sum of the moduli of the
elements along the ith row excluding the
diagonal element ai,i. Then each eigenvalue
of A lies inside or on the boundary of at
least one of the circles | - aii | = Ri.

February 19, 2010 [email protected] 31


Von Neumanns method
If the boundary conditions are periodic this
method expresses an initial line of errors in
terms of a complex finite Fourier series in the
form N ji


I
en
j
N

j = N

where I =sqrt(-1) , is the amplitude of the jth


harmonic, j/N = is the spatial phase angle
and i stands for the spatial node number

February 19, 2010 [email protected] 32


Von Neumanns method (cont..)

t
n +1 Ii
e = e n Ii
+ 2 ( n e I ( i +1) 2 n e I ( i ) + n e I ( i 1) )
x

n +1
g = 1 for all
n

1 2r (1 cos ) 1
February 19, 2010 [email protected] 33
Couette flow

u u 2
= 2 , = 0.000217m / s
2

t y
IC : u = 40m / s at y=0
u=0, 0<y h
BC: u = 0 at y = h and u = 40m / s at y = 0

February 19, 2010 [email protected] 34


February 19, 2010 [email protected] 35
February 19, 2010 [email protected] 36
February 19, 2010 [email protected] 37
Hyperbolic Equations :

1-D 1st order wave Equation:

u u
+ a = 0, a > 0
t x

February 19, 2010 [email protected] 38


Explicit Schemes
1) FTFS:

1 n+1
(ui ui ) = c(ui +1 ui )
n n n
t
a t
where c =
x

February 19, 2010 [email protected] 39


Explicit Schemes
1) FTCS:

1 n+1
(ui uin ) = c(uin+1 uin1 )
t
a t
where c =
x

February 19, 2010 [email protected] 40


Explicit Schemes
1) FTBS:

1 n+1
(ui uin ) = c(uin uin1 )
t
a t
where c =
x

February 19, 2010 [email protected] 41


Explicit Schemes
4) Lax Method:

1 n c n
uin+1 = (ui 1 + ui +1 ) (ui +1 uin1 )
n
2 2
(Taken average of uin1 and uin+1 in place of uin to
maintain stability.)

February 19, 2010 [email protected] 42


Explicit Schemes
5) Midpoint Leapfrog method:

1 n +1 n 1 c n
(ui ui ) = (ui +1 ui 1 )
n
2 t 2

February 19, 2010 [email protected] 43


Explicit Schemes
6) Lax-Wendroff Method:

n+1 c c2
ui = ui
n
(ui+1 ui1) +
n n
(ui+1 2ui + ui1)
n n n
2 2

February 19, 2010 [email protected] 44


February 19, 2010 [email protected] 45
Implicit Schemes
1) FTCS (Eulers):

c n+1 n+1
uin+1 uin = (ui +1 ui 1 )
2
a t
c=
x

February 19, 2010 [email protected] 46


Implicit Schemes
2) Crank Nicolson Scheme:

c n+1 n+1 c n+1 c c


ui1 ui ui = ui1 ui
n n
+ ui+1
n
4 4 4 4

February 19, 2010 [email protected] 47


February 19, 2010 [email protected] 48
Numerical Example
u u
+a = 0, a = 300m / s
t x
subject to the initial conditions
0
0 x 50
( x 50)
at t = 0, u ( x) = 100sin 50 x 110
60
110 x 300
0

Boundary conditions
0 x=0
t=0 u(x)=
0 x = 300

February 19, 2010 [email protected] 49


February 19, 2010 [email protected] 50
CFL (Courant Friedrichs Lewy) condition
p

D A i C

n +1
u i = au + bu + cu
n
i 1
n
i
n
i +1

February 19, 2010 [email protected] 51


CFL condition

Slope of PD >= Slope of PA

1 t

a h
a t
1 c 1
h

February 19, 2010 [email protected] 52


Numerical Example

u u
+u = 0
t x
u( x,0) = 1, 0 x 2
u( x,0) = 0, 2 x 4
February 19, 2010 [email protected] 53
February 19, 2010 [email protected] 54
2D Wave Equation
2u 2 u
2
=a
t 2 x 2
subject to the initial conditions
0
0 x 100
( x 100)
at t = 0, u ( x) = 100sin 100 x 220
120
220 x 300
0
u
at t=0, =0
t
Boundaryconditions
0 x=0
t=0 u(x)=
0 x = 300

February 19, 2010 [email protected] 55


February 19, 2010 [email protected] 56
References
Smith G D, Numerical solution of partial differential
equations: Finite difference methods, Oxford press,
second edition reprinted 1984.

Richtmyer R D and Morton K W, Difference


methods for initial value problems, Interscience
publishers, 1967.

Chung T J, Computational Fluid Dynamics,


Cambridge University Press, 2002.

February 19, 2010 [email protected] 57


Thank you

February 19, 2010 [email protected] 58

You might also like