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

Partial Dierential Equations Solution by Finite Dierence Method Discretization

Abu Hasan Abdullah January 3, 2009

Abu Hasan Abdullah

2008

Introduction
What is discretization? Process by which a closed-form mathematical expression is approximated by analogous (but dierent) expressions which prescribe values at only a nite number of discrete points or volumes in the domain Recall Navier-Stokes equations derived in Chapter 2. They are PDEs governing the uid motion and as derived, they are of the closed-form mathematical expression, see next.

Abu Hasan Abdullah

2008

Introduction
D + V = 0 Dt Du p xx yx zx = + + + + fx Dt x x y z (1)

(2)

Dv p xy yy zy = + + + + fy Dt y x y z Dw p xz yz zz = + + + + fz Dt z x y z
Abu Hasan Abdullah 2008

(3)

(4)
2

Introduction
D V2 e+ Dt 2 T k x x T k y y T k z z

= q +

(uxx) (vyx) (wzx) (up) (vp) (wp) + + + + + x y z x y z

(uxy ) (vyy ) (wzy ) (uxz ) (vyz ) (wzz ) + + + + + + x y z x y z (5) Discretization will transform the partial derivatives in these PDEs into approximate algebraic dierence quotients
Abu Hasan Abdullah 2008 3

Numerical Solution of PDE


Problems governed by PDE may be classied into two categories 1. equilibrium problems 2. marching problems

Abu Hasan Abdullah

2008

Numerical Solution of PDE Equilibrium Problems


Equilibrium or steady-state or jury problems are those in which a solution of a given PDE is desired in a closed domain subject to a prescribed set of boundary conditions They are boundary value problems Examples: steady-state temperature distributions, incompressible inviscid ows, and equilibrium stress distributions in solids Mathematically, they are governed by elliptic PDE

Abu Hasan Abdullah

2008

Numerical Solution of PDE Marching Problems


Marching or propagation problems are transient or transient-like problems where the solution of a PDE is required on an open domain subject to a set of initial conditions and a set of boundary conditions They are initial value or initial boundary value problems Solution must be computed by marching outward from initial data surface while satisfying the boundary conditions Mathematically, they are governed by either hyperbolic or parabolic PDE

Abu Hasan Abdullah

2008

Numerical Solution of PDE Discretization Schemes


Very few analytical solutions of PDE are available. Numerical solutions, employing various numerical methods, are used to overcome this limitation Various schemes using various numerical methods are available 1. nite dierence 2. nite element 3. nite volume FINITE DIFFERENCE will be outlined

Abu Hasan Abdullah

2008

Dierence Quotients of Derivatives


Partial derivative in PDE is replaced with suitable algebraic dierence quotient i.e. nite dierence Most common nite-dierence representations of derivatives are based on Taylors series expansions If ui,j denotes x-component velocity at point (i, j), then ui+1,j at point (i + 1, j) is given by expanding Taylor series about point (i, j) ui+1,j = ui,j + u x x +
i,j

2u x2

(x)2 + i,j 2!

3u x3

(x)3 + . . . (6) i,j 3!

Abu Hasan Abdullah

2008

Dierence Quotients of Derivatives


Solving Eq. (6) for (u/x)i,j u x ui+1,j ui,j 2u = x x2
nite dierence

i,j

(x) 2! i,j

3u x3

(x)2 ... 3! i,j

(7)

truncation error

or u x ui+1,j ui,j = + O(x) x (8)

i,j

Abu Hasan Abdullah

2008

Dierence Quotients of Derivatives


If we approximate the partial derivative to rst-order accuracy u x ui+1,j ui,j x (9)

ij

then the truncation error in Eq. (7) is being neglected

Abu Hasan Abdullah

2008

10

Dierence Quotients of Derivatives


Now, ui1,j at point (i 1, j) may be similarly obtained by expanding Taylor series about point (i, j) ui1,j = ui,j + = ui,j u x u x (x) +
i,j

2u x2

(x)2 + 2! i,j 3u x3

3u x3

(x)3 + ... 3! i,j

x +
i,j

2u x2

(x)2 i,j 2!

(x)3 + ... i,j 3! (10)

Solving Eq. (10) for (u/x)i,j u x


Abu Hasan Abdullah 2008

i,j

ui,j ui1,j + O(x) = x

(11)

11

Dierence Quotients of Derivatives


In most applications in CFD, rst-order accuracy as in Eq. (11) is not sucient. Second-order accuracy central dierences are normally used. A nite dierence quotient of second-order accuracy is constructed by subtracting Eq. (10) from Eq. (6) ui+1,j ui1,j u =2 x 3u x + 2 x3 i,j (x)3 + ... 3! i,j (12)

Abu Hasan Abdullah

2008

12

Dierence Quotients of Derivatives


Second-order central rst dierence with respect to x is obtained by writing Eq. (12) as u x ui+1,j ui1,j = + O(x)2 2x (13)

i,j

Second-order central rst dierence with respect to y is obtained, through similar construction, and written as u y =
i,j

ui,j+1 ui,j1 + O(y)2 2y

(14)

Abu Hasan Abdullah

2008

13

Dierence Quotients of Derivatives


Second-order central second dierence with respect to x is 2u x2 =
i,j

ui+1,j 2ui,j + ui1,j + O(x)2 (x)2

(15)

Second-order central second dierence with respect to y is 2u y 2 =


i,j

ui,j+1 2ui,j + ui,j1 + O(y)2 (y)2

(16)

Abu Hasan Abdullah

2008

14

Dierence Quotients of Derivatives


Second-order central dierence for mixed derivative is 2u xy =
i,j

ui+1,j+1 ui+1,j1 ui1,j+1 + ui1,j1 + O[(x)2, (y)2 ] 4xy (17)

Abu Hasan Abdullah

2008

15

Using Finite Dierence Method to Solve PDE Steps


1. Physical region of problem divided into a grid of nodes, whose shape is much inuenced by nature of physical problem being solved, Figure 1; structured grid reects some type of consistent geometrical regularity unstructured grid where grid points are located in a very irregular fashion 2. Governing PDEs transformed into corresponding coordinate system that best t chosen physical grid pattern, then expressed in nite dierence form i.e. in this sense, the original PDEs have been discretized!. Coordinate transformation may take place here

Abu Hasan Abdullah

2008

16

(a) Structured

(b) Unstructured

Figure 1: Grid.

Abu Hasan Abdullah

2008

17

Using Finite Dierence Method to Solve PDE Steps


3. For example take the PDE governing transient temperature distribution in one spatial dimension 2T T 2 =0 t x which can be expressed as a central dierence
PDE

(18)

n n (Ti+1 2Tin + Ti1) T 2T Tin+1 Tin 2 =0 t x t (x)2


dierence equation

(19)

Abu Hasan Abdullah

2008

18

Using Finite Dierence Method to Solve PDE Steps


4. The nite dierence form of the governing PDE is then applied at each of nodes, whose functional values are related to those nearby 5. As a consequence of this application, a system of linear algebraic equations developed which can be solved for unknown function values after proper BC and/or IV applied

Abu Hasan Abdullah

2008

19

Using Finite Dierence Method to Solve PDE Coordinate Transformation


Cartesian coordinate system (x, y, z) most widely used Polar coordinate system very helpful in a variety of engineering problems Other non-standard coordinate system is also possible to cater for dierent physical orientations of the problem This calls for transformation of coordinate system from one form (in most cases the cartesian) into another (polar, skewed, etc.) We will cover this in greater details in the next chapter
Abu Hasan Abdullah 2008 20

Using Finite Dierence Method to Solve PDE Solution Techniques


Dierence equations formed from the discretization of PDE may be solved using one of these two techniques 1. explicit approach 2. implicit approach We will use the parabolic 1-D heat conduction equation of Eq. (18) T 2T = 2 t x to show dierences in the two approaches
Abu Hasan Abdullah 2008 21

Using Finite Dierence Method to Solve PDE Explicit Solution Technique


Discretize Eq. (18) into a dierence equation
n n Ti+1 2Tin + Ti1

Tin+1 and re-arrange Tin+1 =

Tin

(x)2

(20)

Tin

t n n + Ti+1 2Tin + Ti1 (x)2

(21)

where n is the time level


Abu Hasan Abdullah 2008 22

Using Finite Dierence Method to Solve PDE Explicit Solution Technique


In Eq. (21) LHS = unknown properties at time level n + 1 RHS = known properties at time level n Eq. (21) allows direct calculation of Tin+1 which is sequentially applied to all grid points, i = 1, 2, . . . in the problem domain. This is an explicit approach Thus, in an explicit approach each dierence equation contains only ONE unknown which can be explictly solved in a straightforward manner
Abu Hasan Abdullah 2008 23

Figure 2: An explicit nite-dierence module.

Abu Hasan Abdullah

2008

24

Using Finite Dierence Method to Solve PDE Implicit Solution Technique


Discretize Eq. (18) again but this time writing its spatial dierence on RHS in terms of average properties between time level n and n + 1, into a dierence equation
n+1 n+1 1 1 1 n n (Ti+1 + Ti+1) + 2 (2Tin+1 2Tin) + 2 (Ti1 + Ti1) Tin+1 Tin = 2 t (x)2 (22)

Eq. (22) represents one form of the Crank-Nicolson dierencing and is ONE n+1 n+1 equation with THREE unknownsTi+1 , Tin+1, Ti1 Eq. (22) applied at a grid point does not stand alone, i.e. it cannot solve for Tin+1
Abu Hasan Abdullah 2008 25

Using Finite Dierence Method to Solve PDE Implicit Solution Technique


n+1 n+1 Re-arrange Eq. (22) to collect all unknowns (i.e. Ti+1 , Tin+1, Ti1 ) on LHS

t t t n+1 n+1 n+1 Ti1 1 + Ti+1 + Ti 2(x)2 (x)2 2(x)2 = Tin t n n Ti+1 2Tin + Ti1 2(x)2 (23)

Abu Hasan Abdullah

2008

26

Using Finite Dierence Method to Solve PDE Implicit Solution Technique


Re-write Eq. (23) as
n+1 n+1 ATi1 BTin+1 + ATi+1 = Ki

(24)

where t A= 2(x)2 t B =1+ (x)2 K = Tin t n n Ti+1 2Tin + Ti1 2(x)2

Abu Hasan Abdullah

2008

27

Figure 3: An implicit nite-dierence module.

Abu Hasan Abdullah

2008

28

Using Finite Dierence Method to Solve PDE Implicit Solution Technique


Now apply Eq. (24) sequentially to grid points 2 through 6, Figure 3, and collect all the known constants to RHS at grid point 2: at grid point 3: at grid point 4: at grid point 5: at grid point 6: BT2 + AT3 = K2 AT1 AT2 BT3 + AT4 = K3 AT3 BT4 + AT5 = K4 AT4 BT5 + AT6 = K5 AT5 BT6 = K6 AT7 (25) (26) (27) (28) (29)

with T1 and T7, being stipulated boundary conditions, known


Abu Hasan Abdullah 2008 29

Using Finite Dierence Method to Solve PDE Implicit Solution Technique


Eqs. (25)(29) are ve equations for ve unknownsT2, T3, T4, T5, T6and they form a system of linear equations B A 0 0 0 T2 K2 AT1 A B A T3 0 0 K3 0 A B A 0 K4 (30) T4 = 0 0 A B A T5 K5 0 0 0 A B T6 K6 AT7
known coecient matrix unknowns known constants

Solution of the system of equations denoted by Eq. (30) involves manipulation of the known coecient matrix (notice the tridiagonal)
Abu Hasan Abdullah 2008 30

Homeworks
Read through Chapter 4 of Computational Fluid Dynamics (1995), Anderson, J.D. and discuss briey the meaning of 1. structured grids 2. unstructured grids 3. rst-order-accurate nite-dierence expression 4. second-order-accurate nite-dierence expression 5. truncation error and its inuence on your CFD calculation

Abu Hasan Abdullah

2008

31

Homeworks
Using central-dierence approximations, nd the solution of the wave equation, represented by a second-order hyperbolic equation:

2 2 = , x t2
subject to the boundary conditions

0x1

(0, t) = 0 (1, t) = 0
and initial conditions

t>0 t>0

(x, 0) = sin x (x, 0) = 0 t

0x1 0x1

Abu Hasan Abdullah

2008

32

Figure 4: 2-D nite dierence discretization

Abu Hasan Abdullah

2008

33

You might also like