14
Dominique Thévenin / Gábor Janiga [email protected] Computational Fluid Dynamics (CFD): Introduction, Discretization www.bp.com 0 L 0 L 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1 0.5 0 -0.5 -1 2 Introduction !This is a generic introduction. It is only possible to understand CFD "hands-on" . !Many possibilities for such "hands-on": " during this course (starting in 2 weeks), " during the final project, " possibly during Studien-, Diplom-, Master- or Doktorarbeiten " and later during your career! 3 Application Examples Aerospace Automotive Biomedical industry Chemical processing Electronics Environment Food Fuel cells HVAC Mixing Oil & Gas Power generation Pumps Sport Turbomachinery ... 4 Computational Fluid Dynamics/CFD Computational Fluid Dynamics (CFD) Experimental Fluid Mechanics Analytical Fluid Mechanics 5 Computational Fluid Dynamics/CFD Computational Fluid Dynamics (CFD) Engineering (Fluid Mechanics) Mathematics Computer Science 6 Organization !Introduction !Importance of CFD !Tools for help !Discretization

Computational Fluid Dynamics (CFD): Introduction,read.pudn.com/downloads690/ebook/2782189/CFD1...7 Fluid vs. Structure simulation!We will only consider fluids in this lecture.!But

  • Upload
    others

  • View
    10

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Computational Fluid Dynamics (CFD): Introduction,read.pudn.com/downloads690/ebook/2782189/CFD1...7 Fluid vs. Structure simulation!We will only consider fluids in this lecture.!But

Dominique Thévenin / Gábor Janiga

[email protected]

Computational Fluid Dynamics (CFD): Introduction,

Discretizationwww.bp.com

0 L0

L

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6

1

0.5

0

-0.5

-1

IMPRS Seminar, 22.11.2011 | 11 / 26

Jet

Model Spread Rate S =dY1/2

dX Rel. Difference [%]

Experiment 0.1047 -

Standard 0.1142 9.07

RNG 0.1309 25.02

Realizable 0.1130 7.93

Realizable (Optimized) 0.1121 7.07

Abbildung 4.7: Stromlinien

Abbildung 4.8:

Abbildung 4.9:

2

Introduction!This is a generic introduction. It is only possible to understand CFD "hands-on" .!Many possibilities for such "hands-on":

" during this course (starting in 2 weeks)," during the final project," possibly during Studien-, Diplom-, Master- or Doktorarbeiten" and later during your career!

3

Application Examples

• Aerospace

• Automotive

• Biomedical industry

• Chemical processing

• Electronics

• Environment

• Food

• Fuel cells

• HVAC

• Mixing

• Oil & Gas

• Power generation

• Pumps

• Sport

• Turbomachinery

• ...4

Computational Fluid Dynamics/CFD

Computational Fluid Dynamics

(CFD)

Experimental Fluid Mechanics

AnalyticalFluid Mechanics

5

Computational Fluid Dynamics/CFD

Computational Fluid Dynamics

(CFD)

Engineering(Fluid Mechanics)

Mathematics Computer Science

6

Organization!Introduction

!Importance of CFD

!Tools for help

!Discretization

Page 2: Computational Fluid Dynamics (CFD): Introduction,read.pudn.com/downloads690/ebook/2782189/CFD1...7 Fluid vs. Structure simulation!We will only consider fluids in this lecture.!But

7

Fluid vs. Structure simulation!We will only consider fluids in this lecture.

!But the methods used to investigate numerically fluids and structures are in fact similar, sometimes identical.

!Differences appear later:" other conservation equations," sometimes specific solvers.

!This general introduction is valid for both fluids and structures.8

Computational performance!Continuous progress in all directions

At home In supercomputing centers

9

Measuring performance!MIPS : million of instructions per second

" depends of how instructions are coded!Mflops : million of floating point operations per second

" but all operations do not have the same difficulty (addition much faster than division)

!No real standard, difficult to measure, often a mixture…!Typically :

" o(Gflops) = 109 flops: PC, workstations" o(Tflops) = 1012 flops: "average" supercomputer" o(Pflops) = 1015 flops: high-end supercomputer

10

Moore's law!Co-founder of Intel, Moore declares that circuit integration, and therefore computing power, doubles every 18 months

4/11/12 11:07 AMTransistor_Count_and_Moore's_Law_-_2011.svg

Page 1 of 1file:///Users/dozer/Desktop/Transistor_Count_and_Moore's_Law_-_2011.svg

11

Moore's law (2/2)!It is the same to say that computing power is multiplied by 10 every 5 years... !Today, less than 10% of all chips are inside computers! Mobile phones, playstations and washing machines control the market...

12

Organization!Introduction

!Importance of CFD

!Tools for help

!Discretization

Page 3: Computational Fluid Dynamics (CFD): Introduction,read.pudn.com/downloads690/ebook/2782189/CFD1...7 Fluid vs. Structure simulation!We will only consider fluids in this lecture.!But

13

In the european industry!In 1996, large poll throughout the european industry. Results still valid.!Question : "What is the importance of numerical simulation for your field of activity?"!About 1000 answers. Only a few extracts of this report are presented here.

14

Global importance!Question : "Quantify the importance of numerical simulation for your field of activity"

" Essential! ! 46%" Very important! 34%" Moderate! ! 16%" Weak! ! ! 4%

15

Domains of activity!Question : "What are the domains where numerical simulation is essential for survival?" In ( ), the "weight" of numerics...

" Aeronautics and space! ! ! ! (40%)" Energy!! ! ! ! ! (25%)" Chemistry! ! ! ! ! ! (15%)" Car industry! ! ! ! ! ! (15%)" Petroleum and Mining industry! ! ! (5%)" Environment! ! ! ! ! ! (5%)"! ! ! ...

16

Type of applications!Question : "In which domains are you mainly using numerical simulation ?"

" CFD (Computational Fluid Dynamics)! 45%" Simulation of structures! ! ! 30%" Electro-magnetical simulations! ! 17%" Others! ! ! ! ! ! 8%

17

Problems!Question : "What are your main problems in the frame of numerical simulations?"

" costs! ! ! ! ! ! ! 32%" limited performance of computers! ! ! 22%" limited accuracy of physical models! ! 16%" difficulty to integrate simulation in the loop! 11%" not enough good engineers in the field! ! 6 %" ...

18

Evolutions in the world!All data available on http://www.top500.org

Page 4: Computational Fluid Dynamics (CFD): Introduction,read.pudn.com/downloads690/ebook/2782189/CFD1...7 Fluid vs. Structure simulation!We will only consider fluids in this lecture.!But

19

Performance Development

20

Projected Performance Development

21

Continents - Performance

22

Domains of applicationsType! ! ! Power (Gflops)

Finance! ! 1 557 548Weather! ! 1 296 394Energy! ! 994 907 Geophysics! ! 771 151Telecom! ! 445 943Aerospace! ! 309 700 Automobile! ! 174 308WWW!! ! 146 097

23

Organization!Introduction

!Importance of CFD

!Tools for help

!Discretization

24

Principles!You will have to conceive, now and later, good simulation tools !A few basic principles to increase your efficiency for code development. Development steps:

" 1) what should this code do?" 2) what is already available?" 3) what could help me?" 4) conceive clean interfaces" 5) many tests and validation!" 6) importance of making full documentation available

Page 5: Computational Fluid Dynamics (CFD): Introduction,read.pudn.com/downloads690/ebook/2782189/CFD1...7 Fluid vs. Structure simulation!We will only consider fluids in this lecture.!But

25

1) What should this code do?!When using computers to solve a problem, the first step is not to boot the computer and start typing!First step: input-output

" what are the available information, what are the requested results?

!Second step: requested accuracy" will often control the computing cost

!Deduce the kind of algorithm that is suitable" solution method? For which kind of computer?

26

2) What is already available?!You have now all the needed ideas on paper!Is a numerical tool available (in the Lab, in the University, on the Web...), fulfilling all requirements?

" If yes and if free: problem is solved!" if it involves a licence fee: are you ready to pay?

!In any case there are surely many libraries, code elements, that you can find either locally or on the Web!

" free: use them!" with licence fee: you must decide…but it could spare a lot of time and difficulties

27

2) What is already available?!Example of libraries

" free: for example http://www.netlib.org, one of the largest in the world for mathematical libraries" with licence fee: for example http://www.nag.com. Available at the OvG-University" many others, see for example (for Matlab) http://www.mathtools.net

28

3) What could help me?!Having good tools is essential for good results. In particular:

" a good compiler: very important to get fast codes. A good compiler can even correct some of your mistakes!" a good debugger: very useful to identify mistakes, bugs and possible conflicts" a good editor: is much more comfortable!

!If possible, everything integrated (in order to get all the information concerning variable modifications, memory allocation,...)

29

3) What could help me?!For small tests or short codes, it is very pleasant to have access to at least one of these tools

" Matlab (http://www.mathworks.com): engineering computations. We will use it!" Mathematica (http://www.wolfram.com): for analytical/mathematical developments." Maple (http://www.maplesoft.com): in between both previous codes.

!For "engineering", the combination Matlab + Maple is quite perfect. Available at the Lab/the University.

30

4) Clean interfaces!Hierarchical coding is essential for recycling pieces of codes and for a better debugging

Main part

1 2 3 4 ...Main logicalsub-steps

3-1 3-2 3-3Elementary sub-functions

Page 6: Computational Fluid Dynamics (CFD): Introduction,read.pudn.com/downloads690/ebook/2782189/CFD1...7 Fluid vs. Structure simulation!We will only consider fluids in this lecture.!But

31

4) Clean interfaces!Information transfer between these levels must be clear and clean!It is then possible to reuse for example piece 3-3 in another code Main part

1 2 3 4 ...Main logicalsub-steps

3-1 3-2 3-3Elementary sub-functions

32

4) Clean interfaces!Another advantage

" coupling large, already existing codes" with clean interfaces, the evolution of variables and the dependencies can be easily checked

code "atmosphere", developed by A in 2000

code "ocean", developed by B in 2001

33

5) Many tests and validation!!Often heard

" "I'm finished, I have compiled the code."!This is certainly a necessary step, but not a sufficient one...!You have to prove:

" that your code fulfills the initial requirements" that the obtained accuracy is sufficient

!For that, you must carry out tests for all possible domains of applications!See later: validation

34

6) Documentation!Even if they do in fact nothing, comments are perhaps the most important part of a code.!A code without comments and documentation is worthless…For professionals, 30 to 50% of all the coded text "only" contains information on methods, aims, variables, references...!Test it yourself: write a "semi-complex" code (one thousand lines) without comments nor documentation. I bet that you need more than one week to reuse it in one year.!Comments must be complemented by a user's manual. Or you will be the only user of this code ever...

35

Organization!Introduction

!Importance of CFD

!Tools for help

!Discretization

Channel Flow: Analytical Solution

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6

1

0.5

0

-0.5

-1 v [m/s]

H [m]

36

Page 7: Computational Fluid Dynamics (CFD): Introduction,read.pudn.com/downloads690/ebook/2782189/CFD1...7 Fluid vs. Structure simulation!We will only consider fluids in this lecture.!But

Computational Mesh

38

Three families!For solving partial differential equations (PDE), three main families are employed" finite differences" finite volumes" finite elements

![Note: other techniques exist for special cases]!These three methods are different, but related!They have specific advantages/disadvantages

39

Three families!Therefore, due to specific arguments, but also due to tradition, one or the other of these methods is retained!We show here only a very brief introduction "with hand-waving"!Further information during the next weeks...

!"

!t+

! ("u)

!x= 0

40

1) Finite differences!The oldest method for PDE!Already described by Euler in the 18th century (long before computers...)!Starting point" The conservation equation (or transport equation) for each point (local)

!For example 1D continuity equations

time space direction

density x-velocity

41

1) Finite differences!We must cover the spatial domain with a numerical grid!For example, to solve on [0,L ] :

x 0 L !N grid points, not necessarily equally-spaced!Noted xi, for i = 1,…,N

x1 x5 x12

42

1) Finite differences!Of course, our variables (velocity, density) are continuous in space in the real world!But numerical solving can only give discrete values!We will only obtain values for the variables at the grid points xi , values noted !i or ui

x 0 L

!1 u5 !12

Page 8: Computational Fluid Dynamics (CFD): Introduction,read.pudn.com/downloads690/ebook/2782189/CFD1...7 Fluid vs. Structure simulation!We will only consider fluids in this lecture.!But

43

1) Finite differences!Similar discretization needed in time!For example, to solve on [0,T ] :

t 0 T !There are P points in the time grid, not necessarily equally spaced (the time-step can vary)!Noted t i, for i = 1,…,P

t1 t5 t12

44

1) Finite differences!Again, velocity or density are of course continuous in time in the real world!But solving can only lead to a discrete solution!We will only obtain variable values for the times t i , noted ! i or u i

!Beware: not a power!

t 0 T

!1 u 5 !12

45

1) Finite differences!Combining space and time…!The notation u53 designates the value of the velocity at point x5 and time t 3...

x 0 L 0

T

u89

!1412

46

1) Finite differences!We now must discretize the PDE!And therefore replace partial derivatives by approximate expressions using only the discrete time- and space-values!The classical approximation relies on Taylor's series.

!"

!t+

! ("u)

!x= 0

!"

!t

!

!"i

!t

"k

!"k

i " "k!1

i

(tk " tk!1)

!k!1

i= !k

i +!

tk!1! tk

"

#

"!i

"t

$k

+ ...

47

1) Finite differences! First term

then

! Taylorʼs series

48

1) Finite differences

x 0 L 0

T !1412

Time derivative usespresent value and pastvalue at the pointconsidered

!

!"i

!t

"k

!"k

i " "k!1

i

(tk " tk!1)

Page 9: Computational Fluid Dynamics (CFD): Introduction,read.pudn.com/downloads690/ebook/2782189/CFD1...7 Fluid vs. Structure simulation!We will only consider fluids in this lecture.!But

! ("u)

!x

(!u)k

i!1= (!u)k

i+ (xi!1 ! xi)

!

" (!u)k

"x

"

i

+ ...

(!u)k

i+1= (!u)k

i+ (xi+1 ! xi)

!

" (!u)k

"x

"

i

+ ...

49

1) Finite differences! Second term (spatial)

! Left-hand Taylorʼs series

! Right-hand Taylorʼs series !

! ("u)k

!x

"

i

!

("u)k

i+1" ("u)k

i!1

(xi+1 " xi!1)

50

1) Finite differences

Combine forequally-spacedgrid

(!u)k

i+1= (!u)k

i+ (xi+1 ! xi)

!

" (!u)k

"x

"

i

+ ...

(!u)k

i!1= (!u)k

i+ (xi!1 ! xi)

!

" (!u)k

"x

"

i

+ ...

51

1) Finite differences

x 0 L 0

T !1412

Space derivative usesneighbor values atpresent time

!

! ("u)k

!x

"

i

!

("u)k

i+1" ("u)k

i!1

(xi+1 " xi!1)

52

1) Finite differences!Note: an infinite number of solutions can be retained. Depends on how many (and which) points are used to approximate the derivative.!Here the "simplest" solution: first-order upwind in time, second-order centered in space!Order o: when multiplying the number of grid points by m, the theoretical error is divided by m o

!Second-order in space:" doubling the number of grid points, the error should be divided by 4" more details to come during next weeks...

!ki ! !k!1

i

(tk ! tk!1)+

!ki+1u

ki+1 ! !k

i!1uki!1

(xi+1 ! xi!1)= 0

53

1) Finite differences!Final discretization

!We "only" need to solve this system in order to obtain the new solution at time t k, then go on for the next iteration...

from k-1 to k...

!"

!t+

! ("u)

!x= 0

54

!Advantages :" the easiest method" possible to reach high-order using many points (in this case, very high precision)

!Disadvantages :" limited to very simple grids and geometries (structured)

!Used for:" basic research, teaching" few industrial applications

1) Finite differences

Page 10: Computational Fluid Dynamics (CFD): Introduction,read.pudn.com/downloads690/ebook/2782189/CFD1...7 Fluid vs. Structure simulation!We will only consider fluids in this lecture.!But

55

!Quite old ...!Starting point:" Conservation equations for a control volume (macroscopic)

!For example continuity equation:

volume V

surface A

normal unity vector n!!!

V

!"

!tdV +

!!A

"v · n dA = 0

components (u,v,w)

2) Finite volumes

56

!The spatial domain is covered by a grid, i.e., a group of neighboring control volumes!In 1D, finite volumes and finite differences are in practice identical. Therefore a 2D example: in this case, a control "volume" becomes a control surface!The grid follows the boundaries of the control volumes. But the values of the variables are often defined at the centers of these volumes, therefore not at the grid points.

2) Finite volumes

2) Finite Volume Discretization

57

2) Finite Volume Discretization

58

Simple 2D Configuration

59 60

Simple 2D Configuration

Page 11: Computational Fluid Dynamics (CFD): Introduction,read.pudn.com/downloads690/ebook/2782189/CFD1...7 Fluid vs. Structure simulation!We will only consider fluids in this lecture.!But

P EW

N

S

61

Simple 2D Configuration

62

!To solve on [0,Lx ]x[0,Ly ] :

0 Lx

Grid point Variables!, u, v

0

Ly

2) Finite volumes

63

!We want to solve the integrated conservation equation on each volume

0 Lx 0

Ly

V

!!!V

!"

!tdV +

!!A

"v · n dA = 0

2) Finite volumes

64

!Back to one control volume

0 Lx 0

Ly

V

2) Finite volumes

65

!We must compute:" 4 surface integrals (here 1D)" 1 volume integral (here 2D)

2) Finite volumes

V

66

!Volume integral:" simply (value at center x volume)

V

2) Finite volumes

Page 12: Computational Fluid Dynamics (CFD): Introduction,read.pudn.com/downloads690/ebook/2782189/CFD1...7 Fluid vs. Structure simulation!We will only consider fluids in this lecture.!But

67

!Surface integral:" compute the value at the volume boundary by simple interpolation between neighbors" integral is simply (value x surface)

V

2) Finite volumes

68

!Finally, in this case, only values at neighboring points are needed to approximate the integrals

V

!!!V

!"

!tdV +

!!A

"v · n dA = 0

2) Finite volumes

69

!When summing this conservation equation on all volumes, we of course obtain again the same conservation equation for the full domain (opposite signs for n for neighboring control volumes)!We therefore only need to express the volume and surface integrals using the discrete variable values

!!!V

!"

!tdV +

!!A

"v · n dA = 0

2) Finite volumes

70

!Note again: an infinity of possibilities exist to approximate the integrals" depends on the number (and choice) of neighboring points" depends on the way to approximate values at points where they are not known

!Here the simplest: linear interpolation, second order in space, order in time unknown.

2) Finite volumes

71

2) Finite volumes!Advantages:

" still simple" the nearest to physics (ensures directly conservation!)" possible for complex geometries and grids"ensures directly conservation

!Disadvantages:" difficult to reach high orders

!Applications:" research and teaching" most commercial CFD codes. More to come (Fluent)!

!u ! f = 0

72

3) Finite elements!The most rigorous method from a mathematical point of view!Partly related to finite volumes. The grid can be identical.!Starting point:

" variational (or weak) formulation of the conservation equations

!A simple example (like heat transfer or pressure Poisson equation):

variable source term

Page 13: Computational Fluid Dynamics (CFD): Introduction,read.pudn.com/downloads690/ebook/2782189/CFD1...7 Fluid vs. Structure simulation!We will only consider fluids in this lecture.!But

u (x, t) =Nnodes!

j=1

uj (t) Fj (x)73

3) Finite elements!Space is again covered by elementary, contiguous domains ("elements")!To simplify this complex method, example in 1D!Difference to finite volumes:

" 1) at each grid point, we associate a known basis function Fj(x) for node j , with j = 1,…,Nnodes

" 2) the unknown is the value of the variable at node j, here uj

" 3) the solution on the full domain is then found back by

74

3) Finite elements!In 1D, grid is obvious!The basis functions:

" must be compact (local)" are generally chosen as low-degree polynomials (typically degree 1: linear, maximum 2...)

grid point

0 Lx

value of variables

1

0 0

linear basisfunction F1

F3 F4 F2

75

3) Finite elements!In 2D, grid elements are often chosen as triangles (easy to mesh complex geometries) and irregular

mesh grid

0 Lx

Ly

value of variables

1

0

76

3) Finite elements!The residual R is computed from the present values of the unknown u as

!The aim is to find the value of u, hence the values at all nodes ui , leading to a zero-residual.

R = !u ! f

! Lx

0

"

d2u

dx2! f

#

Fj dx = 0

77

3) Finite elements!We therefore try to find a set of values uj leading to a minimum global residual!We therefore consider the integral

!

du

dxFj

"Lx

0

!

# Lx

0

$

du

dx

dFj

dx

%

dx

!

! Lx

0

(f Fj) dx = 0

78

3) Finite elements!Integration by parts

becomes

=0 by construction of Fj by j = 2,…,Nnodes -1

! Lx

0

"

d2u

dx2! f

#

Fj dx = 0

Page 14: Computational Fluid Dynamics (CFD): Introduction,read.pudn.com/downloads690/ebook/2782189/CFD1...7 Fluid vs. Structure simulation!We will only consider fluids in this lecture.!But

! Lx

0

"

du

dx

dFj

dx

#

dx =

=

i=j+1!

i=j!1

ui

" xj+1

xj!1

#

dFi

dx

dFj

dx

$

dx

79

3) Finite elements!There are only two integrals left. The first one

Reminder: j = 2,…,Nnodes -1

Stiffness matrix

=i=j+1!i=j!1

fi

" xj+1

xj!1

(FiFj) dx

! Lx

0

(f Fj) dx =

80

3) Finite elements!For the second integral

Mass matrix

81

3) Finite elements!Knowing the basis functions Fj, it would now be possible to write the discrete equations...!Again: an infinity of solutions are possible for that.

" depends on the choice of the elements and on the choice of the basis functions

!Here more or less the simplest possible solution" more to come (Comsol/FEMLAB)

82

3) Finite elements!Advantages:

" mathematically the best method" leads to accurate indicators concerning accuracy, grid quality,..." possible for complex geometries and grids

!Disadvantages :" the most difficult method (to understand/to use)

!Applications:" many commercial codes (about 100% for structures, perhaps 20% for fluids, in particular incompressible)

83

Comparison

!Finite differences and finite volumes are strongly related" even identical in 1D

!Finite volumes and finite elements are related" there are even mixed methods using both" same kind of applications...

84

Specificities!Finite differences:

" teaching and research" high accuracy for simple geometries

!Finite volumes" fluids (compressible and incompressible)" complex geometries

!Finite elements" structures " fluids (incompressible)" complex geometries