Date post: | 30-May-2017 |
Category: |
Documents |
Upload: | nishant-manepalli |
View: | 227 times |
Download: | 0 times |
Analysis of Numerical Schemes
Dr. Sreenivas Jayanti
Department of Chemical Engineering
IIT-Madras
Analysis of Numerical Schemes
• Two parts
• Part I: Given a discretization scheme, how to tell that it
will lead to a satisfactory solution?
• Part II: How to solve together the set of continuity,
momentum, energy and other equations?
Need for Analysis
• Discretization of governing equations using FD or FE or FV
techniques gives a set of discretized equations involving variable
values at neighbouring points
• These discretized equations are the ones that are actually solved to
determine the variable values at grid nodes
• Discretization is not unique and for the same PDE, different discretized
equations can be obtained, e.g. discretization can be done to different
orders of accuracy
• Are all discretizations equivalent? Or are some superior? How can we
ensure that the numerical solution is correct?
A Simple Case Study
• Consider the linear convection equation
• Consider three discretization schemes:
0
x
ua
t
u
FTBS : )( 1
1 n
i
n
i
n
i
n
i uuuu
FTCS: 2/)( 11
1 n
i
n
i
n
i
n
i uuuu
FTFS : )( 1
1 n
i
n
i
n
i
n
i uuuu
at/x
Courant no
The True Solution
• Take a = 1 m/s; initial conditions : u(x,0) = f(x)
where f(x) = 1 for 0.1 x 0.2 and f(x) = 0 otherwise
• True solution: initial pulse gets convected in x-direction at 1 m/s
u(x,t) = u(x-at)
t
u
FTBS Solution for 1 at t = 0.1 s
Fig I.1a: FTBS scheme for various Courant numbers at t=0.1 s
-0.2
0
0.2
0.4
0.6
0.8
1
1.2
0.1 0.15 0.2 0.25 0.3 0.35 0.4
x (m)
f(x, 0.1
) 1.00
0.5
0.25
• Peak location predicted correctly, but the square pulse has been “rounded”
• Decreasing amplitude with decreasing
FTBS Solution for 1 at t = 0.1 s
Fig I.1b. FTBS scheme with various Courant numbers at t=0.1 s
-4
-2
0
2
4
0.05 0.1 0.15 0.2 0.25 0.3 0.35
x (m)
f(x, 0.1
) 1.000
1.111
1.125
• Both shape and amplitude predicted poorly for > 1
FTCS Solution for 1 at t = 0.1 s
• Discretization second-order accurate in space but ...
Fig I.2a FTCS scheme with various Courant numbers at t=0.1s
-10
-5
0
5
10
0.15 0.2 0.25 0.3 0.35
x (m)
f(x, t0
)
0.5
0.25
1
FTFS Solution for 1 at t = 0.05 s
• Solution wildly fluctuating for all Courant numbers
Fig I.2b FTFS scheme with various Courant numbers at t=0.05 s.
-400
-200
0
200
400
0.1 0.15 0.2 0.25 0.3
x (m)
f(x
, t0
) 0.5
0.25
1
Need for Analysis Identified
• Different solutions ranging from exact to thoroughly unsatisfactory
obtained for this simple, linear equation
• Behaviour of the solution appears to depend on choice of t and x
• Need a formal analysis to determine the choice of parameters to yield
an accurate solution
• Three conditions for a good solution:
– Consistency : discretized equation pde
– Stability : exact solution of disc eqn computed solution
– Convergence: computed solution exact solution of pde
• Equivalence theorem of Lax (1954):
– For a well-posed linear initial value problem with a consistent
discretization, stability is necessary and sufficient for convergence
• Convergence assures us that grid independent solution = exact solution
of the governing equation
Properties of Numerical Schemes
• Accuracy : error due to discretization
– leading term in the truncation error, e.g, FTCS ~ O (t, x2 )
– non-uniform grids may reduce accuracy by an order
– cannot be eliminated but can be made as small as one wishes
– higher order schemes reduce error only on sufficiently fine grids
– higher accuracy does not mean a better solution; in fact, second
and higher order schemes usually lead to unphysical oscillations
– for the general case, order of accuracy can be obtained by
successively refining grid and expressing error as ~ tp, xq
– in FV method, overall accuracy depends on the approximation of
derivatives and on the accuracy of surface and volume integrals
Properties of Numerical Schemes
• Conservation property:
– conservation law upheld at global as well as at discrete level
– desirable to eliminate spurious source terms
– can be ensured by consistent evaluation of face fluxes so that the
total flux leaving a surface of a control volume is equal to the
total flux entering through the same surface into the
neighbouring cells which have the face as a common boundary
– consistent and inconsistent evaluation of diffusive flux at face I:
I
quadratic interpolation
instead of linear
Properties of Numerical Schemes
• Boundedness:
– solution remains within physical bounds, e.g.,
• turbulent kinetic energy is always 0
• 0 mass fraction 0
– for steady flows without source terms, interior values should be
bound between minimum and maximum occurring on the
boundaries, e.g.
• temperature inside a conducting rod cannot be colder than T at
the cold end and it cannot be hotter than T at the hot end, unless
there is heat source/ sink inside the rod
– boundedness can be ensured by having the same sign for all the
coefficients in a discretized equation
Properties of Numerical Schemes
• Consistency:
– ensures that the discretized equation tends to partial differential
equation as x and t tend to zero
– a consistent scheme means that we are solving the correct equation
in the limit of fine grid spacing
– consistency can be verified by formal Taylor series expansion
e.g., FTFS scheme for the linear convection equation:
n
iuxt
n
i
n
i
n
i
n
i aux
uua
t
uu)(1
1
),(0)(2
)(2
22 xtuax
ut
ixxnitt
Properties of Numerical Schemes
• Stability:
– Error between computed solution and exact solution of the
discretized equation should not be amplified as we march forward
in time
– stability guarantees that the scheme produces a bounded solution if
the exact solution itself is bounded
• Consider D = exact solution of the discretized eqn
N = computed solution using the num scheme
= error = D - N
in = (x,t ) = (ix, nt) = Di
n - Nin
• Then stability requires that
| in+1 / i
n | 1
Stability Analysis
• Stability of a linear equation with constant coefficients is well-
understood and lends itself to simple analysis if the effect of boundary
conditions can be neglected. Under these conditions, von Neumann
stability analysis can be used
• When the effect of boundary conditions has to be taken into account, a
matrix method of stability analysis can be used although this is difficult
to implement in practice as it requires the evaluation of eigenvalues of
large matrices
• For the general non-linear or non-constant coefficient problem, local
stability analysis can be performed on a linearized set of equations
• Only the von Neumann stability analysis is described here. For other
methods, see Hirsch (1988)
Stability Analysis: Formulation
• How to evaluate in and i
n+1 to evalute stability?
• Obtain error evolution equation for the discretization scheme
• Consider FTBS scheme for linear convection equation:
(uin+1 - ui
n ) / t + u0 (uin - ui-1
n ) / x = 0 (1)
• Din = exact soln of (1)
(Din+1 - Di
n ) / t + u0 (Din - Di-1
n ) / x = 0 (2)
• Nin = computed soln of (1) to machine accuracy, we have
(Nin+1 - Ni
n ) / t + u0 (Nin - Ni-1
n ) / x = 0 (3)
Stability Analysis: Formulation
• in = Di
n - Nin Ni
n = Din - i
n
• Substitute in (3) to get
[(Din+1+ i
n+1)-(Din+ i
n)]/ t + u0[(Din +i
n )-(Di-1n +i-1
n )]/x=0
• Rearranging
[(Din+1 -Di
n)]/ t + u0[(Din - Di-1
n )/x
+ [( in+1- i
n)]/ t + u0[(in - i-1
n )]/x = 0
• Since Din satisfies eqn (1) exactly, error eqn is of the same form:
( in+1 - i
n ) / t + u0 ( in - i-1
n ) / x = 0 (4)
• Investigate behaviour of (4) to determine stability
von Neumann Stability Analysis
• In general, in = f(x,t)
• Express (x,t) as a Fourier series (valid for periodic boundaries):
• (x,t) = m( bm ejkmx) j = (-1)
– km = wave no = m/L, m = 0, 1, 2, …., M M = L/x
– bm = amplitude of each wave component
• Since error equation is linear, investigate behaviour of each component
and get overall solution by superposition
• We seek a solution of the form m(x,t) = bm ejkmx = eat ejkmx
• Write min = eant ejkmix and substitute in error eqn (4) to get
von Neumann Stability Analysis
• [eat -1] + [1- e-jkmix ] = 0 = at / x
• min+1 / mi
n = G = amplification factor = eat
• Thus, G = 1- + e-j = km x
• For | G | 1, 0 1
• Scheme stable if 0 = at / x 1
• Courant-Friedrichs-Lewy (CFL) condition
• FTBS scheme conditionally stable
Re
Im
G
FTCS Scheme
• FTCS scheme for linear convection equation:
(uin+1 - ui
n ) / t + u0 (ui+1n - ui-1
n ) / 2 x = 0
• Error equation
(in+1 - i
n ) / t + u0 (i+1n - i-1
n ) / 2x = 0
• Amplification factor
G = 1 - j sin
• Stability: | G|2 = 1+ 2 sin2 > 1
FTCS scheme unconditionally unstable
• Similarly FTFS scheme can be shown to be unconditionally unstable
• Stability behaviour reflected in the Case Study
FTCS Implicit
• FTCS-Implicit scheme for linear convection equation:
(uin+1 - ui
n ) / t + u0 (ui+1n+1 - ui-1
n+1 ) / 2 x = 0
• Error equation
(in+1 - i
n+1 ) / t + u0 (i+1n+1 - i-1
n+1 ) / 2x = 0
• Amplification factor
G - 1 +/2 (ej - e-j ) = 0 or G = 1/ [1 + j sin ]
• Stability: | G|2 = 1/ [1+ 2 sin2] < 1
FTCS Implicit scheme unconditionally stable
• Gain of stability in implicit schemes countered by need to solve
equations simultaneously
Generic 1-d Scalar Transport Equation
• No source terms, const property and constant given velocity:
/t + u/x = / 2/x2 (1)
• FTCS Explicit scheme
(in+1 - i
n ) / t + u (i+1n - i-1
n ) / 2 x = / (i+1n -2 i
n+i-1n ) / x2
• Put = t /( x2) and = u t / x and rearrange to get
in+1 = (+/2) i-1
n + (1-2) in + (-/2) i+1
n
• Amplification factor
G = 1+ 2 [cos(kmx) -1] -j sin (kmx)
• Stability: 1/2 and 2 2
Re
Im
G
Generic 1-d Scalar Transport Equation
• Oscillations are produced with FTCS explicit if 2 Pe 2/ where Pe
= ux/ is the mesh Peclet number
• This loss of boundedness can be cured by
– decreasing grid spacing so that Pe < 2 or by
– using an “upwind” scheme for the convective term
• upwinding for convective term assuming u > 0 yields
(in+1 - i
n ) / t + u (in - i-1
n ) /x = / (i+1n -2 i
n+i-1n ) / x2
• or, in+1 = i-1
n + (1-2- ) in + (+) i+1
n
• Stable, oscillation-free solution if (2 + ) < 1
• Stability analysis becomes more complicated in 2- and 3-d, non-
constant coefficients, non-uniform grids etc.
Part II: Solution of Navier-Stokes Equations
• Equations governing fluid flow are coupled, e.g., we have to solve the
continuity and the three momentum equations together to get a solution
for incompressible, isothermal flows. For highly compressible flows,
the energy equation also has to be solved.
• For compressible flows, a natural coupling exists between the
continuity and momentum equations (2-d case):
• U/ t + E/ x + F/ y = 0 (1) - (4)
U = [ u v Et] T Et = e + V2/2
E = [u u2+p-xx uv-xy (Et+p) -uxx - vxy + qx ]T
F = [v uv-xy v2+p-yy (Et+p) -uxy - vyy + qy ]T
Solution for Compressible Flow
• Discretize eqns. (1) to (4) using. e.g., MacCormack (1969) scheme
Predictor step:
Uijn+1 = Uij
n - t/ x (Ei+1,jn - Ei,j
n) - t/ y( Fij+1n - Fij
n)
Corrector step:
Uijn+1 = 1/2 [Uij
n + Uijn+1 - t/ x (Ei,j
n+1 - Ei-1,jn+1)
- t/ y( Fijn+1 - Fij-1
n+1) ] + O(t2, x2)
• Solve (1) for ; (2) for u; (3) for v and (4) for Et
• Calculate u, v, w, e; p = f(, e) ; T = f(, e)
Extension to Incompressible Flow
• MacCormack (1969) explicit scheme has stability limit given by
– t f (t)CFL/(1+2/Re) , f = safety factor ~ 0.9
– (t)CFL= inviscid CFL limit [u/ x + v/ y + a(1/x2 + 1/ y2)0.5 ]-1
– a = speed of sound
– Re = min (u x/, v y/)
• For nearly incompressible flows, speed of sound (t)CFL0
• Even for implicit methods, (t)max ~ 10 (t)CFL
• Special methods necessary for nearly incompressible flows
Methods for Incompressible Flow
• Evaluation of pressure the main problem:
– Continuity for unsteady incompressible flow : U = 0
no natural equation to evaluate pressure
• Special methods for incompressible flow
– artificial compressibility method
– streamfunction-vorticity method
– pressure equation method
– pressure correction method
• Pressure correction method most popular; extension to compressible
flow exists but not discussed today (see Ferziger & Peric, 1999)
Pressure Correction Method
• Consider the staggered grid arrangement
• Discretize x-mom eqn to yield
aeue = nb(anbunb) + b + Ae(pP-pE) (1)
• Discretize y-mom eqn to yield
anvn = nb (anbvnb) + b + An(pP-pN) (2)
• These can be solved if pressure is known
P E
S
P
N
W P E
S
W
u-cell v-cell
p-cell N
N
E
Pressure Correction Method
• Guess pressure = p* and solve (1) and (2) for u* and v*:
aeue* = nb (anbunb*) + b + Ae(pP*-pE*) (3)
anvn* = nb (anbvnb*) + b + An(pP*-pN*) (4)
• u* and v* from (3) and (4) do not satisfy continuity as p* is guessed
correct guessed presssure: p = p* + p’
u-velocity correction u = u* + u’
v-velocity correction v = v* + v’
• How to get u’ and v’ for a given p’?
– Eqn (1) - eqn (3)
– ae(ue - ue*) = nb (anb(unb - unb*) + Ae[(pP-pP*)-(pE-pE*)] or
– aeue’ = nb (anbunb’) + Ae[(pP’- pE’)] Ae(pP’- pE’)
• Discretize x-mom eqn to yield
aeue = nb(anbunb) + b + Ae(pP-pE) (1)
• Discretize y-mom eqn to yield
anvn = nb (anbvnb) + b + An(pP-pN) (2)
• These can be solved if pressure is known
Pressure Correction Method
• Thus ue’ Ae(pP’- pE’)/ae and vn’ An(pP’- pN’)/an (5)
• Derive pressure correction equation by discretizing continuity
– (ue - uw) y + (vn-vs) x = 0 (6)
• Substitute ue = ue* + u’ etc and substitute eqn (5) for u’ and rearrange
to get the pressure correction equation
aPpP’ = aEpE’ + aWpW’ + aNpN’ + aSpS’ + b (7)
where b = (ue* - uw*) y + (vn*-vs*) x
aE/W = yAe/w/ae/w aN/S = xAn/s/an/s aP = NB aNB
• SIMPLE : Semi-Implicit Method for Pressure-Linked Equations
SIMPLE Algorithm
1. Guess p*, u* and v*
2. Solve disc. x-mom eqn for u*
3. Solve disc. y-mom eqn for v*
4. Solve pressure correction eqn for p’
5. Calculate velocity corrections u’ and v’
6. Calculate other scalars, e.g., T, k ..
7. Update p, u and v and return to 1 if not converged
• Has proved very popular since first proposed by Patankar & Spalding (1968)
• Number of variants exist to improve convergence rate: SIMPLEC, SIMPLER,
SIMPLEST, PISO
• Adapted for collocated grids
• Adapted for compressible flow
• Used in many commercial CFD codes