Você está na página 1de 46

MA3004 part 3: Computational

Fluid Dynamics (CFD)


conducted by

Martin Skote
Assistant Professor
School of Mechanical & Aerospace Engineering

Contact: mskote@ntu.edu.sg
67904271, N3-02b-58

Computational Fluid
Dynamics: An Introduction
to; The Finite Volume
Method 2nd ed
Author

: H K Versteeg
W Malalasekera

Publisher : Pearson
ISBN

: 9780131274983

Now available at NTU bookstore (Popular)


The book contains much more material than what we can cover
in the course. The lecture slides contain more detailed
derivations than in the book. The lecture slides contain more
introductory material than the book.

Computational Fluid Dynamics


MA3004 (part 3) is an introduction to CFD. Two routes for obtaining
more knowledge from me:
MA7222 PhD course (theory)
FYP (hands-on using software)
MA3004 part 3: Computational Fluid Dynamics
Computational:
We need numerical methods to do CFD
Finite volume method (lecture 3-9)
Fluid Dynamics:
We need to know which PDEs to solve
Navier-Stokes equations General transport equation (lecture 2)
3

Lecture 1: Introduction
What is CFD.
What is numerical methods.

What is computational fluid dynamics?


Computational fluid dynamics (CFD) is the science of predicting fluid
flow by solving the mathematical equations (PDEs) which govern
the flow using a numerical process. [The analytical solution using
methods from part 1 cannot be obtained.]
The result obtained by CFD is used for:
Conceptual studies of new designs.
Troubleshooting.
Optimization of design.
Research: finding new knowledge about nature/physics.
CFD analysis complements testing and experimentation.
Reduces the total effort required in the laboratory.
CFD is performed using software on computers.
5

CFD software
Fluent, STAR-CCM+
Tutorials first
Layout of CAE Lab 2

Note: N3.2-01-34 means Block N3.2, First Level, Room 34


6

CFD software
Shareware CFD
http://www.cfd-online.com/Links/soft.html
http://www.cfdreview.com/links.shtml#Software
Simple interactive example: Wtunnel app

Example: Automotive Engineering


External aerodynamics

Example: Civil And Environmental


Engineering
Flow of air and water around the Itsukushima Torii (Gate), a large 17-m high
wooden structure located in the sea near Hiroshima, Japan

Example: Sports
Swimming

10

Example: Sports
Cycling

11

Research Example: Biology


Insects

12

Research Example: Earth Sciences


Ocean-Atmosphere coupling, climate change

13

Benefits of CFD
Ability to study systems where controlled experiments are difficult or
impossible to perform (e.g. climate change)
Ability to study systems under hazardous conditions at and beyond their
normal performance limits (e.g. accident scenarios)
Ability to simulate ideal conditions.
CFD provides the ability to isolate or exclude specific phenomena
(e.g. gravity set to zero).
Practically unlimited level of detail of results
Experiments only permit data to be extracted at a limited number of
locations in the system (e.g. pressure and temperature probes, heat flux
gauges, etc.).
CFD allows the analyst to examine a large number of locations in the
region of interest, and yields a comprehensive set of flow parameters for
examination.

14

Limitations of CFD
Physical models.
The CFD solutions can only be as accurate as the physical
models on which they are based. Is the PDE an accurate model of
the physics?
Numerical errors.
Solving equations on a computer introduces numerical errors
which will go to zero as the grid (mesh) is refined. (But we want as
coarse mesh as possible in order to save time).

15

Numerical methods
Translate physics to a mathematical formulation PDE
Transform the task of solving the PDE into a numerical problem
using a grid (mesh)
Apply the boundary conditions
Solve the numerical problem with computers
Present the results by plotting the value of variables

Engineering problem: Three-dimensional (3D) PDE


In this course: One-dimensional (1D) PDE

16

Obtaining answers to PDEs:


Consider a PDE formulated for ( ) (1D problem)
Analytical work: The analytical answer would be ( ), so that for
any we get a value of
Example analytical answer:

( x) =( x 4 ) + 2
2

In this example can take any value between 1 and 10

17

Obtaining answers to PDEs:


Numerical solution using a grid (mesh) with computers:
(we do not seek the analytical solution)
Example of numerical solution:
10 numbers for value of at
10 different points (the grid points).

1 at x1
2 at x2
3 at x3
4 at x4
5 at x5

The numbers obtained are not the


same numbers we get with the
analytical expression. The numerical
solution is an approximation.
In this example: 1 = 1, 2 = 2, 3 = 3 10 = 10

18

The grid (numerical mesh)


In the examples: 100 000 to 10 000 000 points on a threedimensional mesh.
In this course: 5 points on the x-axis (one-dimensional).
If we understand the method for a 1D problem on five points, we
have also understood it for a 3D problem on millions of grid points.
The variable in CFD can be velocity u,v,w, pressure p, density ,
temperature T.
In this course will represent a concentration of something being
transported. Example: milk in coffee, pollutants in the air. ( can
also be the temperature T). This will be clarified in lecture 2.
19

The grid (numerical mesh)


In the examples: 100 000 to 10 000 000 points on a threedimensional mesh.

In this course: 5 points on the x-axis (one-dimensional).

20

Transform the PDE into a


numerical problem
PDE for ( )
Transform to a numerical problem using a grid (mesh):

PDE

a11
2
a1
0

0
0

a12
a22
a23
0
0

a32
a33
a34
0

0
a43
a44
a45

0 1 S 1

0 2 S 2
0 3 = S 3

a54 4 S 4
a55 5 S 5

All the coefficients and


have numerical values which
depend on the PDE, the grid,
and the boundary conditions.

This matrix problem consists of five coupled equations.


S3
Example: Equation number 3: a232 + a333 a434 =
The value of at each point is related to the values at the two points
beside it (except for the boundary points where the
21
BC is used.)

Transform the PDE into a


numerical problem
To do this transformation we need a numerical method
Finite Volume Method (FVM)
How to get the coefficients and with the FVM is the topic of
Lectures 3 to 8

22

Transform the PDE into a


numerical problem
To obtain the answer we need to solve the system of linear equations
a11
2
a1
0

0
0

a12

0
a32
a33
a34

a22
a23

0
0
a43
a44
a45

0 1 S 1

0 2 S 2
0 3 = S 3

a54 4 S 4
a55 5 S 5

Five equations for five


unknowns.

Answer we get:
1
x1

x
2
2
3 at point x3

4
x4
5
x5

How to obtain this answer is the topic of Lecture


9. This is a well suited problem for a computer
because no thinking is required. Thus, instead
of solving a PDE analytically by thinking hard,
we let the computer use rapid number
crunching to solve the numerical problem.

23

Transform the PDE into a


numerical problem
This transformation was performed even before computer existed.
In 1922, Lewis Fry Richardson developed the first numerical
weather prediction system.
Division of space into grid cells.
Simplified equations.
His model's enormous calculation requirements led Richardson to
propose a solution he called the forecast-factory.
The "factory" would have filled a vast stadium with 64,000 people.
Each one, armed with a mechanical calculator, would perform part
of the calculation.

24

The leader (or conductor) would orchestrate this symphony of


equations by shining a beam of light on areas of the globe where
calculation was moving too fast or falling behind.

Transform the PDE into a


numerical problem
PDE for ( )
How to transform the PDE to a numerical problem?
The PDE will contain derivatives:
d

dx

How do we convert this into a formulation containing


1 , 2 , 3 (the values of at the grid points 1 , 2 , 3 )?

26

Transform the PDE into a


numerical problem: discretize
( x)

Notation:

( xi ) = i
( xi 1 ) = i 1

The exact derivative at is

given by which is the

d i i 1
=


dx i x xi xi 1

slope of the solid red curve.


We approximate this value by
utilizing the value to the left
(at 1 ) of the point

(gives the slope of the dashed


blue curve).

The smaller is, the better the approximation is. See Appendix
27
L1A.

Example of discretization: Grid


Equation :

d
=
dx

What we
seek are:

BC:

1
(=
x 0)= =
A

1
x1

x
2
2
3 at point x3

4
x4
5
x5

Grid:
=
x=0

L 1
= = 0.2
5 5

x1 0.1
x 0.3
2
x3 = 0.5

x4 0.7
x5 0.9

x=L=1

The grid we use:

The grid can have many points with varying distances. We


use a simple grid in all of the examples. The specific
distribution of points in the grid will be clarified in Lecture 3.

28

Example of discretization
Equation :

d
=
dx

BC:

1
(=
x 0)= =
A

Grid:
=
x=0

x=L=1

The equation should be


fulfilled at each point:

d
i =
dx i

i = 1, 2,3, 4,5

d i i 1

dx i xi xi 1

Using

we get the discretized equation:

i =

i i 1
xi xi 1
29

Example of discretization
Equation :

d
=
dx

BC:

Grid:

1
(=
x 0)= =
A

Discretized equation:

=
x=0

i =

i i 1
xi xi 1

i 1 =
A xi x=
x/2
i=1 ( Point 1) :=
i 1
i 1
i 2 =
1 xi x=
x
i=2 ( Point 2 ) :=
i 1
i 1
i 3 =
2 xi x=
x
i=3 ( Point 3) :=
i 1
i 1
i 4 =
3 xi x=
x
i=4 ( Point 4 ) :=
i 1
i 1
i 5 =
4 xi xi 1 = x
i=5 ( Point 5 ) :=
i 1

x=L=1

A
x/2

Point 2: 2 =2 1
x

Point 3: 3 =3 2
x

Point 4: 4 =4 3
x

Point 5: 5 =5 4
x
Point 1: 1 =1

30

Example of discretization
1. Collect the unknowns on the left hand side:

Point 1: 1 ( x / 2 1) =
A
Point 2: 1 + 2 ( x 1) =
0
Point 3: 2 + 3 ( x 1) =
0
Point 4: 3 + 4 ( x 1) =
0
Point 5: 4 + 5 ( x 1) =
0

2. Insert the
known values:
= 1
= 0.2

1 ( 0.1 1) =
1
1 + 2 ( 0.2 1) =
0
2 + 3 ( 0.2 1) =
0
3 + 4 ( 0.2 1) =
0
4 + 5 ( 0.2 1) =
0

3. Formulate as a matrix problem:

0
0
0
0 1 1
0.9
1
0
0.8
0
0
0

2
0
1
0
0 3 = 0
0.8


0
0
1
0.8
0

4 0
0
0
1
0.8 5 0
0

1 1.1111
1.3889
2

3 = 1.7361

2.1701
4

5 2.7127

Computers are great at solving this problem, even if it is


big (millions of equations). Example: QED Solver app.

31

Comparison with general matrix


problem (slide 21):
This coefficient is
different due to BC.
a11
2
a1
0

0
0

a12
a22
a23
0
0

0
a32
a33
a34
0

0
0
a43
a44
a45

0
0
0
0
0 0.9

0.8
0
0
0
0 1
1
0
0
0.8
0 = 0

0
1
0.8
0
a54 0
0
0
1
0.8
a55 0

S 1 1
2
S 0
S3 = 0
4
S 0
S 5 0

Most coefficients are


identical in bands.

32

Is the numerical solution correct?


Blue solid line: analytical solution ( ) = exp()
Red crosses: numerical solution

5 points in the grid

20 points in the grid

PDE for ( ) was transformed to a numerical problem by using a grid


The more points in the grid, the better approximation to the analytical
solution
33

Are we done now?

In principle yes.
This method is called the finite difference method (FDM).
A better method is the finite volume method (FVM).
We will use a similar approximation of the derivative in the derivation
of FVM coefficients.
The FVM will also generate a matrix problem:
a11
2
a1
0

0
0

a12
a22
a23
0
0

0
a32
a33
a34
0

0
0
a43
a44
a45

0 1 S 1

0 2 S 2
0 3 = S 3

a54 4 S 4
a55 5 S 5

For one-dimensional (1D) problems, FDM and FVM gives the same
matrix problem.
34

Central differencing scheme


More accurate discretisation because we use information on both
sides of the point.
Notation:

( xi ) = i
( xi +1 ) = i +1
( xi 1 ) = i 1

The exact derivative at is

given by which is the

d i +1 i 1
=


dx i x xi +1 xi 1

slope of the solid red curve.


We approximate this value by
utilizing the values to the left
(1 ) and to the right (+1 )
of the point
(gives the slope of the dashed
blue curve).
35

Notation
Grid:
=
x=0

x=L

For a general problem we want to describe any point without having to


specify the number.
General point:
P
To the left:
1
W
To the right: +1
E

This notation becomes troublesome, especially in three dimensions. So in


the book they use subscript P to denote a general grid point:

W: west

E: east

36

Notation

Equation:

d
=
dx

i P

Using the more accurate expression


(central differencing scheme) for the derivative:

Gives the discretised equation:

d
d

dx
dx

d i +1 i 1 E W
=


2 x
dx i xi +1 xi 1

E W
d
=
P =
P
2 x
dx P

Before setting up the matrix problem, the equation for each point is formulated with
the indecs P E W replaced with the numbers for that point. Example (point 3):

=
P =
E 4=
W 2
3

(This is what we did on slide 31.)

37

Second order derivative

Equation:

d 2
=
2
dx

For all points on the grid:

d 2
2 = P
dx P

Previously we only had a first order derivative. Here we have a second


order derivative. But we may simply take one derivative at a time.
There is a trick: utilize extra points. These points should not be included in
the final equations.

(If or are included in the equations there would


be more unknowns than equations.)

38

Second order derivative


d 2
Equation:
=
2
dx

/2 /2

Write as one
derivative at a time

d 2 d d
=
2 =
P
dx P dx dx P

Discretisation with central


differencing scheme using
points w and e

e w
d
=
=

x
dx P x

General expression for


any function :

f
df
=
=

dx P x

fe f w
x
39

Second order derivative


d 2
Equation:
=
2
dx

/2 /2

General expression:

Let

df d
=
f
=
dx P dx P

fe f w
x

d d

d
d d
dx e dx w

f =
=
x
dx
dx dx P

The second order PDE


Can now be expressed as:

d d

d 2
dx

e dx w
P
=
P
2 =
x
dx P

(Now there are only first order derivatives in the equation)

40

Second order derivative

With

For all points


2 = P
on the grid: dx P

/2 /2

d E P

=
dx
x

e
P W
d
=

x
dx w

we can rewrite
the equation as:

d 2
=
Equation:
2
dx

d d

dx e dx w
= P
x

E P P W

2P + W
x
x =
=
P E
P
2
x
x

So the discretised equation becomes:

E 2P + W
= P
2
x
41

CFD (part 3) of MA3004 schedule


L1: Introduction to CFD and numerical methods
L2: Fluid Dynamics: PDEs (chapter 2 in the book)
General transport equation
L3-4: Finite Volume Method: diffusion (chapter 4 in the book)
Central difference scheme
L5-6: Finite Volume Method: convection-diffusion (chapter 5 in the book)
Upwind scheme
L7-8: Time dependent problems (chapter 8 in the book)
Implicit method
L9: Solution techniques for a system of linear equations (chapter 7 in the
book)
Iterative methods

42

Conclusion
Physical reality is modeled by PDEs.
CFD is the process of numerically solving the PDEs governing fluid
flow.
Numerical solution is an approximate solution which gets more
accurate the more points there is in the grid (mesh).
To translate the PDE to numerical problem we used the Finite
Difference Method.
In Lecture 3 onward we will use the Finite Volume Method.

43

Appendix L1A
For the motivated students
Not included in the exam

44

The derivative for a linear function

( x) =
x
x

d
=
dx x

The derivative for any function is

given by
=
as 0

Example is given on the next slide.


45

The derivative for any function


The derivative for any function is

given by
=
as 0

Example: () = 2

i i 1 xi2 xi21
=
=
=
x xi xi 1 xi xi 1
x 2 ( x x )
x

Thus:

{ xi =

x; xi 1 = x x}=

x 2 x 2 + 2 xx x 2
=
= 2 x x 2 x as x 0
x

as x 0
x
dx
46

Você também pode gostar