Sie sind auf Seite 1von 26

P RELIMINARY C OMPUTATIONAL T ECHNIQUES Finite Differences Modules

Computational Fluid Dynamics

Ramesh Vulavala
D. J. Sanghvi College of Engineering

May 17, 2016

Ramesh Vulavala DJSCE Mumbai 1


P RELIMINARY C OMPUTATIONAL T ECHNIQUES Finite Differences Modules

I NTRODUCTION

P RELIMINARY C OMPUTATIONAL T ECHNIQUES


Finite Differences

Finite Differences Modules


Modules

Ramesh Vulavala DJSCE Mumbai 2


P RELIMINARY C OMPUTATIONAL T ECHNIQUES Finite Differences Modules

I NTRODUCTION
A general problem involving the flow of fluids along with
heat and/or mass transfer is specified usually with a set
of initial and boundary conditions. .

I The mathematical description of such a problem results in


a set of partial differential equations.
I The initial and boundary conditions are expressed as
algebraic equations.
I The first step in solving these type of problems is to
discretise the equations.
I In case of unsteady state problems the PDEs are first
converted into a set of ODEs.
I The process of discretisation introduces an error.
Ramesh Vulavala DJSCE Mumbai 3
P RELIMINARY C OMPUTATIONAL T ECHNIQUES Finite Differences Modules

F INITE D IFFERENCES

I The most common finite difference approximations are


obtained from Taylor Series:
 2 
(x)2
 3 
(x)3
 
u u u
ui+1,j = ui,j + x+ + +
x i,j x2 i,j 2 x3 i,j 6

I This is an exact expression for ui+1,j if (i) the number of


terms is infinite and the series converges and/or (ii)
x 0

Ramesh Vulavala DJSCE Mumbai 4


P RELIMINARY C OMPUTATIONAL T ECHNIQUES Finite Differences Modules

F INITE D IFFERENCES
I Consider the function:
f (x) = sin 2x
I At x = 0.2, f (x) = 0.9511
I At x = 0.22, f (x) = 0.9823
I Using the first two terms, we estimate:
f
f (x + x) = f (x) +x
x
f (0.22) = f (0.2) + 2 cos[2(0.2)](0.02) = 0.9899
I Using the first three terms, we get:
f 2 f (x)2
f (x + x) = f (x) + x + 2
x x 2
f (0.22) = f (0.2) + 2 cos[2(0.2)](0.02)
(0.02)2
4 2 sin[2(0.2)] 0.9824
Ramesh Vulavala DJSCE Mumbai 2 5
P RELIMINARY C OMPUTATIONAL T ECHNIQUES Finite Differences Modules

F INITE D IFFERENCES

I The finite difference approximation for the first derivative


can be written as:
 2   3 
ui+1,j ui,j (x)2
 
u u (x) u
=
x i,j | x {z } x2 i,j 2 x3 i,j 6
approx.
| {z }
truncation error

I The lowest order term in the truncation error involves x


to the first power. Therefore the approximation:

ui+1,j ui,j
 
u
=
x i,j x

is called first-order accurate.

Ramesh Vulavala DJSCE Mumbai 6


P RELIMINARY C OMPUTATIONAL T ECHNIQUES Finite Differences Modules

F INITE D IFFERENCES

I Mathematically this is represented as:

ui+1,j ui,j
 
u
= + O(x)
x i,j x

I This is called forward finite difference as it uses information


to the right of ui,j .
I Hence this is called the first-order forward difference
approximation.

Ramesh Vulavala DJSCE Mumbai 7


P RELIMINARY C OMPUTATIONAL T ECHNIQUES Finite Differences Modules

F INITE D IFFERENCES

I Consider the following Taylor series expansion:


 2 
(x)2
 3 
(x)3
 
u u u
ui1,j = ui,j x+ +
x i,j x2 i,j 2 x3 i,j 6

I From this we can write:


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

I As expected, this is called the first-order backward difference


approximation.

Ramesh Vulavala DJSCE Mumbai 8


P RELIMINARY C OMPUTATIONAL T ECHNIQUES Finite Differences Modules

F INITE D IFFERENCES

I Subtracting the second Taylor series from the first, we get:

3u (x)3
   
u
ui+1,j ui1,j = 2 x + 2 +
x i,j x3 i,j 6

I From this, we can obtain:


ui+1,j ui1,j
 
u
= + O(x)2
x i,j 2x

I This is the second-order central difference approximation.

Ramesh Vulavala DJSCE Mumbai 9


P RELIMINARY C OMPUTATIONAL T ECHNIQUES Finite Differences Modules

F INITE D IFFERENCES
Similar expressions can be obtained for derivatives with respect
to y:
I Forward differences
ui,j+1 ui,j
 
u
= + O(y)
y i,j y

I Backward differences
ui,j ui,j1
 
u
= + O(y)
y i,j y

I Central differences
ui,j+1 ui,j1
 
u
= + O(y)2
y i,j 2y

Ramesh Vulavala DJSCE Mumbai 10


P RELIMINARY C OMPUTATIONAL T ECHNIQUES Finite Differences Modules

F INITE D IFFERENCES FOR S ECOND D ERIVATIVES

I The two Taylor series expansions can be added to obtain:

2u 4u (x)4
   
2
ui+1,j + ui1,j = 2ui,j + (x) + +
x2 i,j x4 i,j 12

I Solving for the second derivative, we get:

2u ui+1,j 2ui,j + ui1,j


 
= + O(x)2
x2 i,j (x)2

I An analogous expression for the derivative w.r.t. y is given


as:  2 
u ui,j+1 2ui,j + ui,j1
= + O(y)2
y2 i,j (y)2

Ramesh Vulavala DJSCE Mumbai 11


P RELIMINARY C OMPUTATIONAL T ECHNIQUES Finite Differences Modules

F INITE D IFFERENCES M ODULES

ui+1,j ui,j
 
u
=
x i,j x

j+1
ui,j ui+1,j
j
x
j1

.
0 i1 i i+1

Ramesh Vulavala DJSCE Mumbai 12


P RELIMINARY C OMPUTATIONAL T ECHNIQUES Finite Differences Modules

F INITE D IFFERENCES M ODULES

ui,j ui1,j
 
u
=
x i,j x

j+1
ui1,j ui,j
j
x
j1

.
0 i1 i i+1

Ramesh Vulavala DJSCE Mumbai 13


P RELIMINARY C OMPUTATIONAL T ECHNIQUES Finite Differences Modules

F INITE D IFFERENCES M ODULES

ui+1,j ui1,j
 
u
=
x i,j 2x

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

.
0 i1 i i+1

Ramesh Vulavala DJSCE Mumbai 14


P RELIMINARY C OMPUTATIONAL T ECHNIQUES Finite Differences Modules

F INITE D IFFERENCES M ODULES

ui,j+1 ui,j
 
u
=
y i,j y

ui,j+1
j+1
y ui,j
j

j1

.
0 i1 i i+1

Ramesh Vulavala DJSCE Mumbai 15


P RELIMINARY C OMPUTATIONAL T ECHNIQUES Finite Differences Modules

F INITE D IFFERENCES M ODULES

ui,j ui,j1
 
u
=
y i,j y

j+1
ui,j
j
y ui,j1
j1

.
0 i1 i i+1

Ramesh Vulavala DJSCE Mumbai 16


P RELIMINARY C OMPUTATIONAL T ECHNIQUES Finite Differences Modules

F INITE D IFFERENCES

ui,j+1 ui,j1
 
u
=
y i,j 2y

ui,j+1
j+1
ui,j
j
2y ui,j1
j1

.
0 i1 i i+1

Ramesh Vulavala DJSCE Mumbai 17


P RELIMINARY C OMPUTATIONAL T ECHNIQUES Finite Differences Modules

M IXED D ERIVATIVES
I Differentiating the first expansion w.r.t. y, we get:
     2 
u u u
= + x
y i+1,j y i,j xy i,j
 3 
(x)2
 4 
u u (x)3
+ + +
x2 y i,j 2 x3 y i,j 6

I Similarly, differentiating the second expansion w.r.t. y, we


get:
     2 
u u u
= x
y i1,j y i,j xy i,j
 3 
(x)2
 4 
u u (x)3
+ +
x2 y i,j 2 x3 y i,j 6

Ramesh Vulavala DJSCE Mumbai 18


P RELIMINARY C OMPUTATIONAL T ECHNIQUES Finite Differences Modules

M IXED D ERIVATIVES

I Subtracting the second from the first, we get:


 2   4 
(x)3
   
u u u u
=2 x+2 +
y i+1,j y i1,j xy i,j x3 y i,j 6

I Solving for the second mixed derivative, we can write:


   
u u
 2   4 
u y i+1,j y i1,j u (x)2
= +
xy i,j 2x x3 y i,j 6

Ramesh Vulavala DJSCE Mumbai 19


P RELIMINARY C OMPUTATIONAL T ECHNIQUES Finite Differences Modules

F INITE D IFFERENCES

I Higher-order-accurate difference expressions result in


more computer time for each itereation step.
I On the other hand, a higher-order difference scheme might
require a smaller number of grid points, to obtain
comparable overall accuracy.
I Higher order schemes may result in a higher-quality
solution.

Ramesh Vulavala DJSCE Mumbai 20


P RELIMINARY C OMPUTATIONAL T ECHNIQUES Finite Differences Modules

B OUNDARY C ONDITION

Consider a part of the boundary in a flow field as shown:

u4
3y
u3
2y
u2
y
u1
.
0

Ramesh Vulavala DJSCE Mumbai 21


P RELIMINARY C OMPUTATIONAL T ECHNIQUES Finite Differences Modules

B OUNDARY C ONDITION
I We wish to estimate the derivative of u w.r.t. y at the
boundary:  
u u2 u1
= + O(y)
y 1 y
I However, this would be of first-order accuracy only.
I Suppose we approximate u as a polynomial at the
boundary:
u = a + by + cy2
I When this is applied at the boundary, we get, since y = 0:
u1 = a
I Similarly, we get:
u2 = a + b y + c(y)2
u3 = a + b(2y) + c(2y)2

Ramesh Vulavala DJSCE Mumbai 22


P RELIMINARY C OMPUTATIONAL T ECHNIQUES Finite Differences Modules

B OUNDARY C ONDITION

I Solving for b, we get:

3u1 + 4u2 u3
b=
2y
I From the polynomial, we get:
 
u
= b + 2cy
y
I Evaluating at the boundary, we have:
 
u 3u1 + 4u2 u3
=b=
y 1 2y

Ramesh Vulavala DJSCE Mumbai 23


P RELIMINARY C OMPUTATIONAL T ECHNIQUES Finite Differences Modules

B OUNDARY C ONDITION

I Consider a Taylor Series expansion around the boundary


point:

2u y2 3u y3
     
u
u(y) = u1 + y+ + +
y 1 y2 1 2 y3 1 6

I Comparing with the polynomial, we note tat it is accurate


to O(y)3 .
I Therefore we can write:
 
u 3u1 + 4u2 u3
= + O(y)2
y 1 2y

I Therefore it is called second-order one-sided finite difference


formula.
Ramesh Vulavala DJSCE Mumbai 24
P RELIMINARY C OMPUTATIONAL T ECHNIQUES Finite Differences Modules

B OUNDARY C ONDITION
I Consider the viscous flow of air over a flat plate. At a
given station in the flow direction, the variation of flow
velocity, u, in the direction perpendicular to the plate, the y
direction, is given by:
y in cm u in m/s
0 0
0.254 45.8846
0.508 87.4075
0.762 124.9771
Calculate the shear stress at the wall, w , by using (i)
first-order forward differences, and (ii) second-order
one-sided differences. If the exact variation is given by the
following expression, calculatre the error in each case:
u = 482.1936(1 exp(y/L)) in m/s with L = 2.54 cm.
Ramesh Vulavala DJSCE Mumbai 25
P RELIMINARY C OMPUTATIONAL T ECHNIQUES Finite Differences Modules

D ISCRETISATION
n+1
Tj1 Tjn+1 n+1
Tj+1

n
Tj1 Tjn n
Tj+1
nt
n1
Tj1 Tjn1 n1
Tj+1

2t

.
0 x 2x jx
Ramesh Vulavala DJSCE Mumbai 26

Das könnte Ihnen auch gefallen