+ All Categories
Home > Documents > Preliminary Computational Technique Numerical Methods · Analytic solution– linear equation,...

Preliminary Computational Technique Numerical Methods · Analytic solution– linear equation,...

Date post: 19-Oct-2020
Category:
Upload: others
View: 4 times
Download: 0 times
Share this document with a friend
23
HC Chen 2/3/2020 Chapter 3A: Finite-Difference 1 Chapter 3 Preliminary Computational Technique Numerical Methods Analytic solution – linear equation, simple geometry, simple initial and boundary conditions Analytic solution techniques – separation of variables, Green function, Laplace transform, Theory of characteristics, … Complex geometry Complex equations (nonlinear, coupled) Complex initial / boundary conditions No analytic solutions Numerical methods needed !!
Transcript
Page 1: Preliminary Computational Technique Numerical Methods · Analytic solution– linear equation, simple geometry, simple initial and boundary conditions Analytic solution techniques–

HC Chen 2/3/2020

Chapter 3A: Finite-Difference 1

Chapter 3

Preliminary Computational

Technique

Numerical MethodsAnalytic solution – linear equation, simple

geometry, simple initial and boundary conditionsAnalytic solution techniques – separation of

variables, Green function, Laplace transform, Theory of characteristics, …

Complex geometryComplex equations (nonlinear, coupled)Complex initial / boundary conditions

No analytic solutionsNumerical methods needed !!

Page 2: Preliminary Computational Technique Numerical Methods · Analytic solution– linear equation, simple geometry, simple initial and boundary conditions Analytic solution techniques–

HC Chen 2/3/2020

Chapter 3A: Finite-Difference 2

Numerical MethodsObjective: Accuracy at minimum cost

(not at any cost!)

Numerical Accuracy (error analysis)Numerical Stability (stability analysis)Numerical Efficiency (minimize cost)Validation (model/prototype data, field data,

analytic solution, theory, asymptotic solution)Reliability and Flexibility (reduce preparation

and debugging time)Flow Visualization (graphics and animations)

OVERVIEWOverview of the computational solution procedures

Governing Equations ICS/BCS

DiscretizationSystem of Algebraic Equations

Equation (Matrix) Solver

Approximate Solution

Continuous Solutions

Finite-Difference

Finite-Volume

Finite-Element

Spectral

Boundary Element

Discrete Nodal Values

Tridiagonal

ADI

SOR

Gauss-Seidel

Conjugate gradient

Gaussian elimination

Ui (x,y,z,t)

p (x,y,z,t)

T (x,y,z,t)

or

(,,, )

Page 3: Preliminary Computational Technique Numerical Methods · Analytic solution– linear equation, simple geometry, simple initial and boundary conditions Analytic solution techniques–

HC Chen 2/3/2020

Chapter 3A: Finite-Difference 3

3.1 Discretization1. Time derivativesalmost exclusively by finite-difference methods

2. Spatial derivativesFDM (Finite-Difference Methods)FVM (Finite-Volume Methods)FEM (Finite-Element Methods)FAM (Finite-Analytic Methods)Spectral MethodsBoundary Element Methods, etc.

Analytic solution

3.1.1 Converting Derivatives to Discrete Algebraic Equations

Heat Equation

Unsteady, one-dimensionalParabolic PDEMarching in time, elliptic in spaceThe simplest system to illustrate both the

“propagation” and “equilibrium” behaviors

1x0 xT0xT

dt1T bt0T

x

T

t

T

o

2

2

),(),(

),(,),(

T

Page 4: Preliminary Computational Technique Numerical Methods · Analytic solution– linear equation, simple geometry, simple initial and boundary conditions Analytic solution techniques–

HC Chen 2/3/2020

Chapter 3A: Finite-Difference 4

Parabolic EquationConvective Transport Equation

T = temperature, = T = concentration, = DT = vorticity, = T = momentum, = T = turbulent kinetic energy, = + t

T = turbulent energy dissipation, = + t/

2

2

2

2

TTu

T

x

T

x

Tu

t

T

8

Fourier Analysis One-Dimensional Heat Equation

General solution in Fourier series

Characteristic polynomial

t x xxT uT T 0

jn x j t n2j n

1T x t T i x i t

4ˆ( , ) exp ( ) exp ( )

( ) ( )2 2t x x x t x

2x x

tt x

i iu i i u 0

0 (second derivative)0 dt

1dx (first derivative)u 0

u

Page 5: Preliminary Computational Technique Numerical Methods · Analytic solution– linear equation, simple geometry, simple initial and boundary conditions Analytic solution techniques–

HC Chen 2/3/2020

Chapter 3A: Finite-Difference 5

9

Fourier Analysis Two-Dimensional Heat Equation

General solution in Fourier series

Characteristic polynomial

Pure diffusion (u=v=0)

t x y xx yyT uT vT T T 0( )

ˆ exp ( ) exp ( ) exp ( )jkn x j y k t n3j k n

1T T i x i y i t

8

2 2t x y x y

2 2x y t x y

2 2x y

t x y

i iu iv i i

i u v 0

0

u v 0

( ) ( )

( )

Elliptic in space

Characteristic surface

Advection-Diffusion Convective Transport Equation

2

2

x

T

x

Tu

t

T

Diffusion of pollutenin a still lake (u = 0)

Diffusion/convection of polluten in a river

Page 6: Preliminary Computational Technique Numerical Methods · Analytic solution– linear equation, simple geometry, simple initial and boundary conditions Analytic solution techniques–

HC Chen 2/3/2020

Chapter 3A: Finite-Difference 6

DiscretizationChoose suitable step size and time incrementReplace continuous information by discrete

nodal valuesConstruct discretization (algebraic) equations

with suitable numerical methodsSpecify appropriate auxiliary conditions for

discretization equationsClassification of PDE is importantSolve the system of “well-posed” equations by

matrix solver

)t,x(TT

)t,x(T

njnj :Numerical

:Exact

3.1.2 Spatial DerivativesFinite-difference: Taylor-series expansionFinite-element: low-order shape function

and interpolation function, continuous within each element

Finite-volume: integral form of PDE in each control volume

Spectral method: higher-order interpolation, continuous over the entire domain

Spectral element: finite-element/spectralPanel method, Boundary element method

Convert PDE to algebraic equations

Page 7: Preliminary Computational Technique Numerical Methods · Analytic solution– linear equation, simple geometry, simple initial and boundary conditions Analytic solution techniques–

HC Chen 2/3/2020

Chapter 3A: Finite-Difference 7

3.1.3 Time DerivativesOne-sided (forward or backward) differences

Two-level schemesThree-level schemesRunge-Kutta mehtodsAdams-Bashforth-Moulton predictor-

corrector methodsUsually no advantages in using higher-order

integration formula unless the spatial discretization error can be improved to the same order

t

TT

t

T

t

TT

t

T1n

jnj

nj

1nj

or

Finite-Difference MethodsReplace derivatives by differences

j j+1 j+2j-1j-2

1j 2jj1j

2j

1jx 2jx jx1jx

Page 8: Preliminary Computational Technique Numerical Methods · Analytic solution– linear equation, simple geometry, simple initial and boundary conditions Analytic solution techniques–

HC Chen 2/3/2020

Chapter 3A: Finite-Difference 8

2 31 2 3

21 2 3 1

2 3 2

( ) ( ) ( ) ( ) ( )

( ) 2 ( ) 3 ( ) ( )

( ) 2 6 ( ) ( ) / 2!

o o o o o o

o o o

o o

f x a a x x a x x a x x a f x

f x a a x x a x x a f x

f x a a x x a f x

3 3

( ) ( )1

0

( ) 6 ( ) / 3!

( ) ( !) ( 1) ( 1) 2 ( ) ( ) / !

( ) ( )

o

m mm m o m o

m om

f x a a f x

f x m a m m m a x x a f x m

f x a x x

( )

0

( )( )

!

mm mo

om

f xx x

m

Taylor series expansionConstruction of finite-difference formulaNumerical accuracy: discretization error

xo x

Truncation ErrorsTaylor series

Truncation error

How to reduce truncation errors?(a) Reduce grid spacing, use smaller x = xxo

(b) Increase order of accuracy, use larger n

( )

( ) ( )( ) ( ) ( ) ( ) ( ) ( )

! !

( )( ) ,

!

2 3o o

o o o o o

nno

o o

x x x xf x f x x x f x f x f x

2 3

x xf x a x b a x b

n

( )( )( ) ,

( )!

n 1n 1o

E

x xT f a b

n 1

Page 9: Preliminary Computational Technique Numerical Methods · Analytic solution– linear equation, simple geometry, simple initial and boundary conditions Analytic solution techniques–

HC Chen 2/3/2020

Chapter 3A: Finite-Difference 9

Finite-Differences xo = xj , x = xj+1 = xj + x

xo x

( ) ( )( ) ( )

!

( ) ( )( ) ( )

!

mmo

om 0

m mj

j 1 j mm 0

f xf x x x

m

f x xf x f x x

x m

!

)()(

j0mm

mm

1jx

T

m

xxT

3.2 Approximation to Derivatives

Partial differential equations: dx, dtFinite-difference equations: x, tTime and spatial derivatives

(i) Taylor series expansion(ii) General Technique – Methods of

undetermined coefficientsDiscretization errors Numerical accuracy

Page 10: Preliminary Computational Technique Numerical Methods · Analytic solution– linear equation, simple geometry, simple initial and boundary conditions Analytic solution techniques–

HC Chen 2/3/2020

Chapter 3A: Finite-Difference 10

3.2.1 Taylor series expansionTruncated Taylor series – truncation error

x x

t

1njT

njT n

1jT n

1jT

j j+1j-1n

n+1

( ) )

!

( )

!

nm mMn 1 M 1

j 1mm 0 j

nm mMn M 1

j 1 2mm 0 j

t TT κ ( t

m t

x TT κ ( x)

m x

Truncation errors

Finite-Differences

Forward difference

Backward difference

Central difference

( ) ( ) ( )

! ! !

( )

! ! !

n n nnm m 2 2 3 3n n 4

j 1 jm 2 3m 0 jj j j

n nnm m 2 2 3 3n n

j 1 jm 2 3m 0 jj j

x T T x T x TT T x O x 1

m x x 2 x 3 x

x T T x T x TT T x

m x x 2 x 3 x

( ) ( ) n

4

j

O x 2

( )

( )

( )

( )

n n nj 1 j

j

n n nj j 1

j

n n nj 1 j 1 2

j

n n n n2j 1 j j 1 2

2 2

j

T TTO x

x x

T TTO x

x x

T TTO x

x 2 x

T 2T TTO x

x x

1

2

12

1+2

Page 11: Preliminary Computational Technique Numerical Methods · Analytic solution– linear equation, simple geometry, simple initial and boundary conditions Analytic solution techniques–

HC Chen 2/3/2020

Chapter 3A: Finite-Difference 11

3.2.2 General TechniqueMethod of undetermined coefficients

General expression for discretization formula

3-point symmetric

3-point asymmetric

3-point asymmetric

4-point asymmetric

5-point symmetric

j2 j1 j j+1 j+2

)(

)(

)(

)(

)(

mn2j

n1j

nj

n1j

n2j

n

j

mn2j

n1j

nj

n1j

n

j

mn2j

n1j

nj

n

j

mn2j

n1j

nj

n

j

mn1j

nj

n1j

n

j

xOTeTdTcTbTax

T

xOTdTcTbTax

T

xOTcTbTax

T

xOTcTbTax

T

xOTcTbTax

T

2j1jj1j xxxx

General ProceduresExpand the functional values at xj-2, xj-1, xj+1,

xj+2, etc. about point xj (uniform spacing)

Can be generalized for non-uniform grids

n

j4

44n

j3

33

n

j2

22n

j

nj

n2j

n

j4

44n

j3

33

n

j2

22n

j

nj

n1j

x

T

4

x2

x

T

3

x2

x

T

2

x2

x

Tx2TT

x

T

4

x

x

T

3

x

x

T

2

x

x

TxTT

! !

!

! !

!

Page 12: Preliminary Computational Technique Numerical Methods · Analytic solution– linear equation, simple geometry, simple initial and boundary conditions Analytic solution techniques–

HC Chen 2/3/2020

Chapter 3A: Finite-Difference 12

General ProceduresMethod of undetermined coefficients

Uniform or Non-uniform grid spacing

j4

44j

j3

33j

j2

22j

jjj1j

j4

441j

j3

331j

j2

221j

j1jj1j

x4

x

x3

x

x2

x

xx

x4

x

x3

x

x2

x

xx

! !

!

! !

!

Method of Undetermined Coefficients

2

3

4

!

!

!

j 1 j j 1 j

j j 1j

22 2j j 1

j

33 3j j 1

j

44 4j j 1

j

a b c a b c

a x c xx

1a x c x

2 x

1a x c x

3 x

1a x c x

4 x

j

1j

xaboutand

Expand

1j

Page 13: Preliminary Computational Technique Numerical Methods · Analytic solution– linear equation, simple geometry, simple initial and boundary conditions Analytic solution techniques–

HC Chen 2/3/2020

Chapter 3A: Finite-Difference 13

3-point Symmetric Formula for First Derivative

For consistency

Leading term of truncation error

)Δ(ΔΔ

Δ

)Δ(ΔΔΔ

ΔΔ

)Δ(ΔΔ

Δ

1jj1j

j

1jj1jj

2j

21j

1jjj

1j

21j

2j

1jj

xxx

xc

xxxx

xxb

xxx

xa

0xcxa

1xcxa

0cba

33 ! x6

xx

x3

1xcxae

31jj

33

1j3jj

j

31jj

1jj1jj

j2j

21j1j

21j1j

2j

j x6

xx

xxxx

xxxx

x

3

3-point Asymmetric Formula

j

44

2j1j4

1j

j

33

2j1j3

1j

j

22

2j1j2

1j

j2j1j1j

j2j1jj

x4

1xxcxb

x3

1xxcxb

x2

1xxcxb

xxxcxb

cbacba

4

3

2

!

!

!

j2j1j xaboutandExpand

Page 14: Preliminary Computational Technique Numerical Methods · Analytic solution– linear equation, simple geometry, simple initial and boundary conditions Analytic solution techniques–

HC Chen 2/3/2020

Chapter 3A: Finite-Difference 14

3-point Asymmetric Formula for First Derivative

For consistency

Leading term of truncation error

)(

)(

)(2a

2j1j2j

1j

2j1j

2j1j

2j1j1j

2j1j

22j1j

21j

2j1j1j

xxx

xc

xx

xxb

xxx

xx

0xxcxb

1xxcxb

0cba

33

)(

!

x6

xxx

x3

1xxcxbe

32j1j1j

33

2j1j3

1jj

j

32j1jj

2j1j2j1j

2j2

1j1j2

2j1jj2j1j2j

j

x6

xxx

xxxx

xxxxx2x

x

3

)(

Taylor Series Expansion

j6

66

j5

55

j4

44

j3

33

j2

22

jj2j

j6

66

j5

55

j4

44

j3

33

j2

22

jj1j

x6

x2

x5

x2

x4

x2

x3

x2

x2

x2

xx2

x6

x

x5

x

x4

x

x3

x

x2

x

xx

!

!

!

!

!

!

!

!

!

!

Uniform grid spacing

Page 15: Preliminary Computational Technique Numerical Methods · Analytic solution– linear equation, simple geometry, simple initial and boundary conditions Analytic solution techniques–

HC Chen 2/3/2020

Chapter 3A: Finite-Difference 15

5-point Symmetric Formula

j

66

j

55

j

44

j

33

j

22

jj

2j1jj1j2j

x6

xe64dba64

x5

xe32dba32

x4

xe16dba16

x3

xe8dba8

x2

xe4dba4

xxe2dba2edcba

edcba

6

54

32

!

! !

! !

5-point Symmetric Formula for First Derivative

x3

2db

0cx12

1ea

0e16dba160e8dba8

0e4dba4xe2dba2

0edcba

1/

0e64dba64x

4e32dba32Leading term of

truncation error

Hx30

x88

x12

1

x 5

54

2j1j1j2jj

Page 16: Preliminary Computational Technique Numerical Methods · Analytic solution– linear equation, simple geometry, simple initial and boundary conditions Analytic solution techniques–

HC Chen 2/3/2020

Chapter 3A: Finite-Difference 16

5-point Symmetric Formula for Second Derivative

2

2

2

x2

5c

x3

4db

x12

1ea

0e16dba160e8dba8

xe4dba4

0e2dba20edcba

2/ 2

2x

8e64dba64

0e32dba32Leading term of truncation error

Hx90

x163016

x12

1

x 6

64

2j1jj1j2j2j

2

2

3-point Symmetric Formula for First Derivative

x2

1db

0c

0dbxdb

0dcb 1/

0dbx

1dbLeading term of

truncation error

Hx6

x

x2

1

x 3

32

1j1jj

a = e = 0

Page 17: Preliminary Computational Technique Numerical Methods · Analytic solution– linear equation, simple geometry, simple initial and boundary conditions Analytic solution techniques–

HC Chen 2/3/2020

Chapter 3A: Finite-Difference 17

3-point Symmetric Formula for Second Derivative

2

22

1b c d 0 b dxb d 0

2cb d 2/ x

x

2x

2db

0dbLeading term of truncation error

Hx12

x2

x

1

x 4

42

1jj1j2j

2

2

a = e = 0

3-point Asymmetric Formula for First Derivative

xx

xc

0e4dxe2d

0edc

Δ 21/e /2d

Δ 23/ 1/

x

2e8d

Leading term of truncation error

Hx3

x43

x2

1

x 3

32

2j1jjj

a = b = 0

Page 18: Preliminary Computational Technique Numerical Methods · Analytic solution– linear equation, simple geometry, simple initial and boundary conditions Analytic solution techniques–

HC Chen 2/3/2020

Chapter 3A: Finite-Difference 18

3-point Asymmetric Formula for Second Derivative

2

2

2

2 x / 1e

x /2d

x /1c

x/2e4d

0e2d0edc

x

6e8d

Leading term of

truncation error

Hx

x2x

1

x 3

3

2j1jj2j

2

2

a = b = 0

3.3 Accuracy of the Discretization Process

Numerical Accuracy - truncation error leading term (Tables 3.3 and 3.4)

Example:

Truncation error

nn

n

2Ax2xx

Axx

Ax

xxxxxx

Ax

AeAAAe

uAe

1uTTu

;

Re ,Re

or

Tn

xA

x

T

n

xET

n

jn

nn

!

)(

!

)(..

Ax = Re u x = Rccell Reynolds number or cell Peclet number

L

x

U

uLUxuR

o

oc

****

Page 19: Preliminary Computational Technique Numerical Methods · Analytic solution– linear equation, simple geometry, simple initial and boundary conditions Analytic solution techniques–

HC Chen 2/3/2020

Chapter 3A: Finite-Difference 19

xxx

xx

x eTeTeT , ,

Page 20: Preliminary Computational Technique Numerical Methods · Analytic solution– linear equation, simple geometry, simple initial and boundary conditions Analytic solution techniques–

HC Chen 2/3/2020

Chapter 3A: Finite-Difference 20

Truncation ErrorsSlope: asymptotic rate-of-convergence

xxx

xx

x

eT

eT

eT

)log(loglog )( xmaExaE m

3.3.1 Higher-Order vs Low-Order Scheme

Higher-order formulaeHigher accuracy (for the same grid spacing)

Less efficient (for the same number of elements)

Less stable, may produce oscillatory solutions

May not be more accurate for discontinuity or severe gradients

Relatively little improvements for coarse-grid (large x) or lower-order (small m) solutions

)(

)(

!)(

)!()(

.).(

.).()(

)(

)(

)(

2m

11m

m

2m

1m

11m

m

1m

f

f

1m

x

m

xf

1m

xf

ET

ET

Page 21: Preliminary Computational Technique Numerical Methods · Analytic solution– linear equation, simple geometry, simple initial and boundary conditions Analytic solution techniques–

HC Chen 2/3/2020

Chapter 3A: Finite-Difference 21

Numerical AccuracyCell Reynolds (or Peclet) number

Consider exponential function as an example

Require small Cell Reynolds number (Ax) or large m to achieve higher accuracy

Increasing m is not very effective in comparison with reducing Ax

1m

xA

TA

TA

1m

x

xT

xT

1m

x

ET

ET

TAeAx

TxT

eT

m

1m

m

1m

m

1m

mAxm

m

mm

Ax

)(

)(

.).(

.).(

)(

)(

)(

)(

Numerical Accuracy

x12

7

x12

1800

x12

TT8T8T

dx

Td :point-5

x2

1

x2

10

x2

TT

dx

Td :point-3

dx

Td :exact

2j1j1j2j

ax

1j1j

ax

ax

Higher-order formula is only

marginally better

x x x x

1

Page 22: Preliminary Computational Technique Numerical Methods · Analytic solution– linear equation, simple geometry, simple initial and boundary conditions Analytic solution techniques–

HC Chen 2/3/2020

Chapter 3A: Finite-Difference 22

Numerical EfficiencyOverall efficiencyFast turnaround time

Limitations in computer memory (I/O) and execution time

It may not be feasible to use fine-grid all the time

Lower-order formula together with finer grid may be more effective than higher-order formula with coarse grid

Use non-uniform, adaptive grids

)](tanh[ x1ky

Use Non-uniform adaptive grid for efficient resolution of sharp gradients

Page 23: Preliminary Computational Technique Numerical Methods · Analytic solution– linear equation, simple geometry, simple initial and boundary conditions Analytic solution techniques–

HC Chen 2/3/2020

Chapter 3A: Finite-Difference 23

First-derivative Second-derivative

)](tanh[ x1ky


Recommended