rob bastiaans june 4, 2008 - tu/epiet/edu/dos/pdf/cfd-4m050.pdf · rob bastiaans june 4, 2008....

21
CFD for heat and flow problems (4M050) Rob Bastiaans June 4, 2008

Upload: others

Post on 17-Mar-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Rob Bastiaans June 4, 2008 - TU/epiet/edu/dos/pdf/CFD-4M050.pdf · Rob Bastiaans June 4, 2008. Chapter 1 Introduction to CFD 1.1 What is CFD? Computational °uid dynamics (CFD)1 is

CFD for heat and flow problems (4M050)

Rob Bastiaans

June 4, 2008

Page 2: Rob Bastiaans June 4, 2008 - TU/epiet/edu/dos/pdf/CFD-4M050.pdf · Rob Bastiaans June 4, 2008. Chapter 1 Introduction to CFD 1.1 What is CFD? Computational °uid dynamics (CFD)1 is

Chapter 1

Introduction to CFD

1.1 What is CFD?

Computational fluid dynamics (CFD)1 is one of the branches of fluid mechanics that uses numericalmethods and algorithms to solve and analyze problems that involve fluid flows. Computers areused to perform the millions of calculations required to simulate the interaction of fluids and gaseswith the complex surfaces used in engineering. Even with simplified equations and high-speedsupercomputers, only approximate solutions can be achieved in many cases. Ongoing research,however, may yield software that improves the accuracy and speed of complex simulation scenariossuch as transonic or turbulent flows. Validation of such software is often performed using a windtunnel.

The fundamental basis of any CFD problem are the Navier-Stokes equations, which define anysingle-phase fluid flow. These equations can be simplified by removing terms describing viscosityto yield the Euler equations. Further simplification, by removing terms describing vorticity yieldsthe full potential equations. Finally, these equations can be linearized to yield the linearizedpotential equations.

1.2 Potential of CFD

It is possible to directly solve the Navier-Stokes equations for laminar flows and for turbulent flowswhen all of the relevant length scales can be resolved by the grid (a Direct numerical simulation).In general however, the range of length scales appropriate to the problem is larger than eventoday’s massively parallel computers can model. In these cases, turbulent flow simulations requirethe introduction of a turbulence model. Large eddy simulations (LES) and the Reynolds-averagedNavier-Stokes equations (RANS) formulation, with the k-? model or the Reynolds stress model,are two techniques for dealing with these scales.

In many instances, other equations are solved simultaneously with the Navier-Stokes equations.These other equations can include those describing species concentration (mass transfer), chemicalreactions, heat transfer, etc. More advanced codes allow the simulation of more complex casesinvolving multi-phase flows (e.g. liquid/gas, solid/gas, liquid/solid), non-Newtonian fluids (suchas blood), or chemically reacting flows (such as combustion).

1.3 Turbulence models

Turbulent flow produces fluid interaction at a large range of length scales. This problem meansthat it is required that for a turbulent flow regime calculations must attempt to take this intoaccount by modifying the Navier-Stokes equations. Failure to do so may result in an unsteady

1This text is partially taken from www.wikipedia.org

1

Page 3: Rob Bastiaans June 4, 2008 - TU/epiet/edu/dos/pdf/CFD-4M050.pdf · Rob Bastiaans June 4, 2008. Chapter 1 Introduction to CFD 1.1 What is CFD? Computational °uid dynamics (CFD)1 is

simulation. When solving the turbulence model there exists a trade-off between accuracy andspeed of computation.

1.3.1 Direct numerical simulation

Direct numerical simulation (DNS) captures all of the relevant scales of turbulent motion, so nomodel is needed for the smallest scales. This approach is extremely expensive, if not intractable,for complex problems on modern computing machines, hence the need for models to represent thesmallest scales of fluid motion.

1.3.2 Reynolds-averaged Navier-Stokes

Reynolds-averaged Navier-Stokes equations (RANS) is the oldest approach to turbulence modeling.An ensemble version of the governing equations is solved, which introduces new apparent stressesknown as Reynolds stresses. This adds a second order tensor of unknowns for which various modelscan provide different levels of closure. It is a common misconception that the RANS equationsdo not apply to flows with a time-varying mean flow because these equations are ’time-averaged’.In fact, statistically unsteady (or non-stationary) flows can equally be treated. This is sometimesreferred to as URANS. There is nothing inherent in Reynolds averaging to preclude this, but theturbulence models used to close the equations are valid only as long as the time scale of thesechanges in the mean is large compared to the time scales of the turbulent motion containing mostof the energy.

RANS models can be divided into two broad approaches:1. Boussinesq hypothesis: This method involves using an algebraic equation for the Reynolds

stresses which include determining the turbulent viscosity, and depending on the level of sophisti-cation of the model, solving transport equations for determining the turbulent kinetic energy anddissipation. Models include k − ε (Spalding), Mixing Length Model (Prandtl) and Zero Equation(Chen). The models available in this approach are often referred to by the number of transportequations they include, for example the Mixing Length model is a ”Zero Equation” model becauseno transport equations are solved, and the k − ε on the other hand is a ”Two Equation” modelbecause two transport equations are solved. 2. Reynolds stress model (RSM): This approachattempts to actually solve transport equations for the Reynolds stresses. This means introductionof several transport equations for all the Reynolds stresses and hence this approach is much morecostly in CPU effort.

1.3.3 Large eddy simulation

Large eddy simulations (LES) is a technique in which the smaller eddies are filtered and aremodeled using a sub-grid scale model, while the larger energy carrying eddies are simulated. Thismethod generally requires a more refined mesh than a RANS model, but a far coarser mesh thana DNS solution.

1.4 Discretization

The most fundamental consideration in CFD is how one treats a continuous fluid in a discretizedfashion on a computer. One method is to discretize the spatial domain into small cells to forma volume mesh or grid, and then apply a suitable algorithm to solve the equations of motion(Euler equations for inviscid, and Navier-Stokes equations for viscous flow). In addition, sucha mesh can be either irregular (for instance consisting of triangles in 2D, or pyramidal solidsin 3D) or regular; the distinguishing characteristic of the former is that each cell must be storedseparately in memory. Where shocks or discontinuities are present, high resolution schemes such asTotal Variation Diminishing (TVD), Flux Corrected Transport (FCT), Essentially NonOscillatory(ENO), or MUSCL schemes are needed to avoid spurious oscillations (Gibbs phenomenon) in thesolution.

2

Page 4: Rob Bastiaans June 4, 2008 - TU/epiet/edu/dos/pdf/CFD-4M050.pdf · Rob Bastiaans June 4, 2008. Chapter 1 Introduction to CFD 1.1 What is CFD? Computational °uid dynamics (CFD)1 is

The stability of the chosen discretization is generally established numerically rather than an-alytically as with simple linear problems. Special care must also be taken to ensure that thediscretization handles discontinuous solutions gracefully. The Euler equations and Navier-Stokesequations both admit shocks, and contact surfaces.

Some of the discretization methods being used are:

• Finite volume method (FVM). This is the ”classical” or standard approach used most oftenin commercial software and research codes. The governing equations are solved on discretecontrol volumes. FVM recasts the PDE’s (Partial Differential Equations) of the N-S equationin the conservative form and then discretize this equation. This guarantees the conservationof fluxes through a particular control volume. Though the overall solution will be conserva-tive in nature there is no guarantee that it is the actual solution. Moreover this method issensitive to distorted elements which can prevent convergence if such elements are in criticalflow regions. This integration approach yields a method that is inherently conservative (i.e.quantities such as density remain physically meaningful):

∂t

∫ ∫ ∫Q dV +

∫ ∫F dA = 0, (1.1)

Where Q is the vector of conserved variables, F is the vector of fluxes (see Euler equationsor Navier-Stokes equations), V is the cell volume, and A is the cell surface area.

• Finite element method (FEM). This method is popular for structural analysis of solids,but is also applicable to fluids. The FEM formulation requires, however, special care toensure a conservative solution. The FEM formulation has been adapted for use with theNavier-Stokes equations. Although in FEM conservation has to be taken care of, it is muchmore stable than the FVM approach. Subsequently it is the new direction in which CFDis moving. Generally stability/robustness of the solution is better in FEM though for somecases it might take more memory than FVM methods.

In this method, a weighted residual equation is formed:

Ri =∫ ∫ ∫

WiQdV e (1.2)

where Ri is the equation residual at an element vertex i , Q is the conservation equationexpressed on an element basis, Wi is the weight factor and Ve is the volume of the element.

• Finite difference method. This method has historical importance and is simple to program.It is currently only used in few specialized codes. Modern finite difference codes makeuse of an embedded boundary for handling complex geometries making these codes highlyefficient and accurate. Other ways to handle geometries are using overlapping-grids, wherethe solution is interpolated across each grid.

∂Q

∂t+

∂F

∂x+

∂G

∂y+

∂H

∂z= 0 (1.3)

Where Q is the vector of conserved variables, and F , G, and H are the fluxes in the x, y,and z directions respectively.

• Boundary element method. The boundary occupied by the fluid is divided into surface mesh.

• High-resolution schemes are used where shocks or discontinuities are present. To capturesharp changes in the solution requires the use of second or higher order numerical schemesthat do not introduce spurious oscillations. This usually necessitates the application of fluxlimiters to ensure that the solution is total variation diminishing.

3

Page 5: Rob Bastiaans June 4, 2008 - TU/epiet/edu/dos/pdf/CFD-4M050.pdf · Rob Bastiaans June 4, 2008. Chapter 1 Introduction to CFD 1.1 What is CFD? Computational °uid dynamics (CFD)1 is

1.5 CFD with COMSOL

COMSOL is a finite element package for solving typical fluid and solid mechanical problems. For-merly it was called FEMLAB and initially it was build on the basis of MATLAB. With COMSOLit is possible to solve predefined systems of equations, but also user defined partial differentialequations (PDE’s) can be incorporated. By solving a set of PDE’s governing multiple physics,also multi-physics problems can be solved, either predefined or user defined. Geometries can bedefined in 1D, 2D and 2D axisymmetric mode and also in 3D. However in 3D it is difficult toobtain computational solutions due to grid limitations (computer-capacity). Moreover in manycases fundamental insights can be gained in one or two dimensions. Because COMSOL works in aquite intuitive way it is an easy package to solve CFD problems when there is no experience withCFD at all.

1.6 Problems to be solved

In this course we will look at several problems of different nature and difficulty. First we willstart with convection-diffusion equations. We will treat these kind of problems in MATLABas well as in COMSOL. The MATLAB exercise is a good way of getting some understandingof discretization, the programming of discretized problems and the associated accuracy. Theconvection-diffusion will also be considered for a problem involving conduction in two materials.After treating convection-diffusion we will have a look at a problem with a wave-equation and thenwith a non-linear convection-diffusion problem: The Burgers-equation. After these 1D problems wewill turn over to 2D systems. First we will have a look at stationary laminar flow; the developmentlength in a piper flow, then unsteady laminar flows; the von Karman vortex street. After this wewill look at turbulent mixing with a RANS turbulence model. We end with an assignment inwhich an unsteady natural convection problem has to be solved and a compressible flow aroundan airfoil.

1.7 Literature on CFD

• CFD-Wiki http://www.cfd-online.com/Wiki/Main Page

• J.H. Ferziger and M. Peric, Computational Methods for Fluid Dynamics. Springer, 1996.

• C. Hirsch, Numerical Computation of Internal and External Flows. Vol. I and II. JohnWiley & Sons, Chichester, 1990.

• P. Wesseling, Principles of Computational Fluid Dynamics. Springer, 2001.

• C. Cuvelier, A. Segal and A. A. van Steenhoven, Finite Element Methods and Navier-StokesEquations. Kluwer, 1986.

4

Page 6: Rob Bastiaans June 4, 2008 - TU/epiet/edu/dos/pdf/CFD-4M050.pdf · Rob Bastiaans June 4, 2008. Chapter 1 Introduction to CFD 1.1 What is CFD? Computational °uid dynamics (CFD)1 is

Chapter 2

Numerical solution ofconvection-diffusion equations

We study a one-dimensional convection-diffusion equation of the form:

∂c

∂t+ v

∂c

∂x= D

∂2c

∂x2, (2.1)

where c is the unknown quantity, t the time, x the spatial coordinate and v and D are constants.As domain for the solution we take : t > 0 and 0 < x < 1. In order to find a unique solution weneed additional conditions at the boundaries of this domain. As boundary conditions at x = 0and x = 1 we take Dirichlet conditions. That means that the solution is given there at all times:c(0, t) = A and c(1, t) = B. Moreover we need an initial condition: c(x, 0) = f(x) with f agiven function. Depending on the application this equation describes convection and diffusion ofmatter with c denoting the concentration of a substance, or convection and diffusion of heat withc denoting temperature.

We are in search of a numerical solution method for this equation. To this end we define aset of discrete values of x and t where we want to find the solution. Let’s say that we divide thespatial domain in N uniform intervals, by xj = j∆x for j = 1, . . . , N +1. What is in this case thedistance between two grid points, ∆x? As discrete time steps we use: tn = n∆t for n = 0, 1, . . ..The solution in a discrete point c(xj , tn) is denoted by cn

j . In this problem there is a differencebetween the two coordinates: the spatial coordinate is bounded on both sides, where a boundarycondition is given. On the other hand the time goes to infinity and only one initial solution isgiven. Sometimes the name evolution equation is given to an equation of this type. It indicatesthat the solution changes (evolves) in time.

The solution method reflects this asymmetry between space and time. We start by makinga spatial discretization of the equation. Let’s denote by cj(t) the solution at grid point xj as afunction of time. We have to find a set of ordinary differential equations, one for each cj(t). Sincec1(t) and cN+1(t) are known we need N − 1 equations for N − 1 unknowns. In order to find anexpression for dcj/dt we need to find approximations for the spatial derivatives ∂c

∂x and ∂2c∂x2 in grid

point xj . These approximations can be found from a Taylor series expansion of cj+p around cj :

cj+1 = c(xj + ∆x) = c(xj) + ∆x

(∂c

∂x

)

j

+12(∆x)2

(∂2c

∂x2

)

j

+ . . .

and

cj−1 = c(xj −∆x) = c(xj)−∆x

(∂c

∂x

)

j

+12(∆x)2

(∂2c

∂x2

)

j

+ . . .

If we subtract these two expressions, we find as an approximation for the first derivative in grid

5

Page 7: Rob Bastiaans June 4, 2008 - TU/epiet/edu/dos/pdf/CFD-4M050.pdf · Rob Bastiaans June 4, 2008. Chapter 1 Introduction to CFD 1.1 What is CFD? Computational °uid dynamics (CFD)1 is

point xj : (∂c

∂x

)

j

≈ cj+1 − cj−1

2∆x.

Since the two points used in the approximation are on both sides of grid points xj this method isused central differencing. In a similar way it can be shown that

(∂2c

∂x2

)

j

≈ cj+1 − 2cj + cj−1

(∆x)2.

By taking more terms in the Taylor series into account it is easy to show that the errors madein this approximation is second order in ∆x. That means that if twice as many grid points areused the error is reduced by a factor of 4. This discretization method leads to a set of ordinarydifferential equations for cj :

dcj

dt= −v

cj+1 − cj−1

2∆x+ D

cj+1 − 2cj + cj−1

(∆x)2(2.2)

for j = 2, 3, . . . , N . Together with the two boundary conditions they form indeed a closed systemof differential equations.

Next we turn to the numerical solution of this set of ordinary differential equations. The mostsimple method also considers a Taylor series, but now in time. There holds:

cj(tn+1) = cj(tn + ∆t) = cj(tn) + ∆tdcj

dt(tn) + . . . ,

but we know an approximation for dcj/dt and substitute the right-hand side of (2.2) at time leveltn:

cn+1j = cn

j − v∆tcnj+1 − cn

j−1

2∆x+ D∆t

cnj+1 − 2cn

j + cnj−1

(∆x)2. (2.3)

If we start at time level t0 = 0 the solution is known for all xj through the initial condition and(2.3) can be applied in all grid points, since the right-hand side is completely known. So thatmeans that c1

j is known for all j and we can start with the new time step. This time-steppingmethod is known as Euler-forward. Since only known terms appear on the right-hand side of (2.3)it is called an explicit method.

A schematic matlab program to solve (2.1) in this way looks like:

% first the parameters are defined:

N=...dx=1/N;dt=...v=...D=...A=...B=...Nsteps=...x=0:dx:1;

% next the initial solution:

c(:,1)=f(x);time=0;plot(x,c(:,1))pause(0.1)

6

Page 8: Rob Bastiaans June 4, 2008 - TU/epiet/edu/dos/pdf/CFD-4M050.pdf · Rob Bastiaans June 4, 2008. Chapter 1 Introduction to CFD 1.1 What is CFD? Computational °uid dynamics (CFD)1 is

% then the time stepping starts:

for step=1:Nsteps

c(2:N,step+1)=c(2:N,step)-v*....c(1,step+1)=A;c(N+1,step+1)=B;time=time+dt;

plot(x,c(:,step+1))pause(0.1)

end

Exercise A

Make this program EulerF1.m in matlab for A = 1, B = 0 and f(x) = exp(−10x2). Calculate thesolution for v = D = 1.

At the end of the program the solution is stored in the two dimensional array c(1 : N + 1, 1 :Nsteps + 1). If a fine grid is used and many time steps this takes a lot of memory. Memory canbe saved by storing only two one-dimensional arrays c(1 : N + 1) and cold(1 : N + 1), because inthe time integration only time levels N + 1 and N are required, as result and input respectively.

Exercise B

Make a program EulerF2.m using only the two solutions c(1 : N + 1) and cold(1 : N + 1). Showwith this program that a stable solution can only be obtained if the time step ∆t is small enough.For stability it must hold that ∆t < α(∆x)p for some integer p and a constant α which dependson v and D. Determine p by varying ∆x and finding (by trial and error) the maximum possibletime step. Take for example ∆x = 1/10 and 1/20.

This stability problem is exactly the main drawback of this Euler-forward method. By chang-ing the Taylor series by expanding around the solution at the new time level, it can be shownthat

cj(tn) = cj(tn+1 −∆t) = cj(tn+1)−∆tdcj

dt(tn+1) + . . . ,

which leads to:

cn+1j = cn

j − vcn+1j+1 − cn+1

j−1

2∆x∆t + D

cn+1j+1 − 2cn+1

j + cn+1j−1

(∆x)2∆t. (2.4)

This method is called Euler-backward and it is stable for all values of the time step, but it is animplicit method, since most of the terms at the right-hand side are at the new time level and thusunknown. If we move all terms at the new time level to the left-hand side, we end up with asystem of equations of the form:

a+cn+1j+1 + a0c

n+1j + a−cn+1

j−1 = cnj

for j = 2, 3, . . . , N together with the boundary conditions cn+11 = A and cn+1

N+1 = B. The coeffi-cients a+, a0 and a− are constants which can easily be found from (2.4). This system of equationscan be written as a matrix-vector equation of the form

Mc = r,

7

Page 9: Rob Bastiaans June 4, 2008 - TU/epiet/edu/dos/pdf/CFD-4M050.pdf · Rob Bastiaans June 4, 2008. Chapter 1 Introduction to CFD 1.1 What is CFD? Computational °uid dynamics (CFD)1 is

where c is a vector containing the unknown solution at the new time level, r is the known right-hand side and M is a matrix. To see this we write the equations as:

cn+11 = A

a−cn+11 +a0c

n+12 +a+cn+1

3 = cn2

a−cn+12 +a0c

n+13 +a+cn+1

4 = cn3

. . .a−cn+1

N−1 +a0cn+1N +a+cn+1

N+1 = cnN

cn+1N+1 = B.

The matrix has only three non-zero elements on each row. If in a matlab program the matrixis filled and the right-hand side, the solution is easy to obtain using

c=M\r.

Note that the matrix does not depend on the solution. So we only have to fill it at the start ofthe program.

Exercise C

Make a program EulerB.m in matlab which solves the convection-diffusion equation with the Eulerbackward method and show that this program is stable for all values of the time step ∆t.

Although a stable solution is obtained the solution at large values of the time step is not ac-curate. The accuracy of the method can be improved by a combination of the Euler-forward andEuler backward method. This method is called Crank-Nicolson and it is given by:

cj(tn+1) = cj(tn) +12∆t

(dcj

dt(tn+1) +

dcj

dt(tn)

).

It can be implemented in the same way as the Euler-backward method. The matrix changes onlyby a factor 1

2 in some places, and the right-hand side becomes more complicated.

Exercise D

• Write a matlab program CN.m that solves (2.1) with the Crank-Nicolson method. Showthat the method is stable for all values of the time step.

• Compare the solutions for v = 1 and v = −1 (take D = 1 in both cases) and explain thedifferences.

• Compare the solutions for D = 1 en D = 0.01 for both v = 1 and v = −1 and explain thedifferences. Investigate the accuracy of the result for D = 0.01 by changing the number ofgrid points.

• Change the program in such a way that only the stationary solution (for t →∞) is calculatedand compare this solution with the analytical solution.

The analytical solution of the stationary problem can be found in the following way. It satisfiesthe equation:

Dd2c

dx2= v

dc

dx= 0

and boundary conditions c(0) = 1 and c(1) = 0. In order to solve this problem we define y = dcdx .

Substitution in the differential equation gives:

dy

dx=

v

Dy

8

Page 10: Rob Bastiaans June 4, 2008 - TU/epiet/edu/dos/pdf/CFD-4M050.pdf · Rob Bastiaans June 4, 2008. Chapter 1 Introduction to CFD 1.1 What is CFD? Computational °uid dynamics (CFD)1 is

with solutiony(x) = C1e

vx/D,

where C1 is a constant. Integration with respect to x gives

c(x) =DC1

vevx/D + C2

with C2 another constant. The two constants can be found from the boundary conditions. Thefinal solution is then given by:

c(x) =ev/D − evx/D

ev/D − 1.

9

Page 11: Rob Bastiaans June 4, 2008 - TU/epiet/edu/dos/pdf/CFD-4M050.pdf · Rob Bastiaans June 4, 2008. Chapter 1 Introduction to CFD 1.1 What is CFD? Computational °uid dynamics (CFD)1 is

Chapter 3

Exercises I; One-dimensionalproblems in COMSOL

Deze week lossen we enkele eendimensionale problemen op met behulp van COMSOL.

1. Eendimensionale convectie-diffusievergelijkingBegin met het probleem van vorige week. Omdat Femlab de op te lossen variabele u noemt,zullen we dat hier ook doen:

∂u

∂t+ v

∂u

∂x= D

∂2u

∂x2,

met v = 1 en D = 1. Het domein is 0 < x < 1 en t > 0. Als beginvoorwaarden nemen we

u(x, 0) = exp(−10x2)

en als randvoorwaardenu(0, t) = 1

enu(1, t) = 0.

Op het standaardrooster kun je al een nauwkeurige oplossing vinden. Neem nu D = 0.01 enpas het rooster zo aan (ook met lokale verfijning) dat de oplossing nauwkeurig is. Vergelijkde eindoplossing (voor heel grote t hangt de oplossing niet meer van de tijd af) met deanalytische oplossing.

2. Twee materialenVervolgens bekijken we een 1D time-dependent heat transfer probleem in een staaf die uittwee verschillende materialen bestaat: koper voor 0 < x < 0.1 en ijzer voor 0.1 < x < 0.2.Neem als randvoorwaarden T = 0 op x = 0 en T = 10(1− exp(−t/2)) op x = 0.2. Verder isde beginvoorwaarde T = 0 en neem geen warmtebron. Kies de tijd met stappen van 2 tott = 100. Bereken de oplossing en verklaar wat je ziet op het grensvlak van de twee materialen.Wat is de juiste randvoorwaarde op het grenspunt? Verklaar deze fysisch. Bereken ook deeindoplossing (voor t → ∞) door de juiste randvoorwaarde op x = 0.2 te nemen en destationaire oplossing te berekenen en vergelijk deze met de analytische oplossing.

3. Eendimensionale golfvergelijkingWe bekijken de 1D wave equation. Neem als domein −5 < x < 5 met als randvoorwaardenu = 0 op x = −5 en op x = 5. Neem verder da = c = 1 en f = 0 in de vergelijking en alsbeginvoorwaarde u = exp(−2x2) en ut = 0. Bereken de oplossing met stapjes van 0.5 tott=20. Vergelijk deze oplossing met die waarbij ∂u/∂x = 0 op x = 5.

10

Page 12: Rob Bastiaans June 4, 2008 - TU/epiet/edu/dos/pdf/CFD-4M050.pdf · Rob Bastiaans June 4, 2008. Chapter 1 Introduction to CFD 1.1 What is CFD? Computational °uid dynamics (CFD)1 is

4. Golven in twee materialenWe bekijken de 1D wave equation in twee materialen: Kies in 0 < x < 10: da = c = 1 enf = 0 en in 10 < x < 20: da = 1, c = 4 en f = 0. Neem randvoorwaarden u = sin(t)op x = 0 en u = 0 op x = 20 en beginvoorwaarden gelijk aan 0. Kies tijdstappen van 0.5en bekijk wat er gebeurt met de golven op het grensvlak. Wat is de randvoorwaarde daar?Verklaar de resultaten.

5. BurgersvergelijkingTenslotte bestuderen we de niet-lineaire convectie-diffusievergelijking

∂u

∂t+ u

∂u

∂x= ν

∂2u

∂x2

op het domein 0 < x < 1 met u(0, t) = 1, u(1, t) = −1 en u(x, 0) = cos(πx). Onderzoek hoede oplossing van ν afhangt (ν = 1, ν = 0.1, ν = 0.01, ν = 0.001). Gebruik hierbij zonodig(lokale) roosterverfijning. Verklaar de resultaten.

11

Page 13: Rob Bastiaans June 4, 2008 - TU/epiet/edu/dos/pdf/CFD-4M050.pdf · Rob Bastiaans June 4, 2008. Chapter 1 Introduction to CFD 1.1 What is CFD? Computational °uid dynamics (CFD)1 is

Chapter 4

Exercises II; Navier-Stokesequations

1. Intreelengte bij pijp- en kanaalstromingIn deze opdracht bekijken we wat de intreelengte is bij Poiseuillestroming. We doen ditvoor stroming in een kanaal en in een pijp. Gebruik voor kanaalstroming onder 2D Chem-ical Engineering, Cartesian coordinates, Momentum balance, Navier-Stokes. Definieer alsdomein een rechthoek met voldoende lengte. De boven- en onderrand zijn no-slip wanden,op de uitstroomrand is de druk voorgeschreven en op de instroomrand de snelheid in destroomrichting. Gebruik een constante instroomsnelheid die zo groot is dat het Reynoldsge-tal gebaseerd op de snelheid, de hoogte van het kanaal en de eigenschappen van water gelijkis aan een waarde tussen 10 en 100.

Laat eerst zien dat de oplossing van de vergelijking alleen van het Reynoldsgetal afhangt alsde oplossing op de juiste manier geschaald is. Neem hiertoe twee verschillende waarden voorde kanaalhoogte en instroomsnelheid die wel hetzelfde Reynoldsgetal opleveren.

Bereken vervolgens de oplossing bij een bepaalde waarde van Re en onderzoek hoe dezeoplossing afhangt van het rekenrooster. Werk in de rest van de opgave met een rekenroosterdat een voldoende nauwkeurige oplossing geeft.

In het begin van het kanaal verandert de uniforme beginsnelheid geleidelijk in een Poiseuilleprofiel.Bedenk zelf een definitie voor intreelengte die een kwantitatief resultaat geeft en onderzoekhoe de intreelengte afhangt van Re voor 10 < Re < 100. Controleer dat de snelheid na deintreelengte goed overeen komt met een Poiseuilleprofiel. Vergelijk de gevonden afhankeli-jkheid met literatuur.

Doe tenslotte hetzelfde voor pijpstroming. Dit kan in de 2D axial symmetric versie vanFEMLAB. De lijn x = 0 is nu een symmetrierand en de stroomrichting moet de y-richtingzijn.

2. Stroming rond een cilinderDe stroming rond een cilinder kent verschillende regimes, afhankelijk van het Reynoldsgetal.Zoek dit na in de literatuur. In deze opdracht gaan we een aantal van de laminaire regimesmet femlab simuleren. Gebruik hiervoor de module transient incompressible Navier-Stokesonder Fluid Dynamics. Definieer de cilinder als een cirkel met diameter 0.1 meter en zetdie in een kanaal met breedte 0.4 meter. Kies de instroomrand niet te ver voor de cirkel ende uitstroomrand voldoende ver om te kunnen bestuderen wat er achter de cirkel gebeurt,bijvoorbeeld van 0.2 meter voor tot 2 meter na het middelpunt van de cirkel. Leg op deinstroomrand een Poiseuilleprofiel voor de snelheid op en schrijf op de uistroomrand de drukvoor. Varieer het Reynoldsgetal door de viscositeit te veranderen. Begin bij het kleinsteReynoldsgetal dat je wilt bestuderen en gebruik steeds de oplossing van de laatst berekendeals startoplossing om rekentijd te besparen. De rekentijd van dit probleem is namelijk groot.

12

Page 14: Rob Bastiaans June 4, 2008 - TU/epiet/edu/dos/pdf/CFD-4M050.pdf · Rob Bastiaans June 4, 2008. Chapter 1 Introduction to CFD 1.1 What is CFD? Computational °uid dynamics (CFD)1 is

Het rekenrooster moet voor dit probleem erg fijn zijn. Kies bij mesh parameters daartoe 0.05voor Max. edge size, general, 1.2 voor mesh growth rate en 0.2 voor mesh curvature factor.Bij lage Reynoldsgetallen is de stroming stationair en kan als stationair probleem opgelostworden. Voor grotere Reynoldsgetallen is de stroming nog wel laminar maar tijdafhankelijk.Om de berekening sneller te laten lopen kun je bij solver parameters in het veld voor absoluttolerance: u 1e-4 v 1e-4 p inf invullen. Onderzoek hoe de frequentie van de oplossing afhangtvan het Reynoldsgetal en vergelijk dit met literatuur.

13

Page 15: Rob Bastiaans June 4, 2008 - TU/epiet/edu/dos/pdf/CFD-4M050.pdf · Rob Bastiaans June 4, 2008. Chapter 1 Introduction to CFD 1.1 What is CFD? Computational °uid dynamics (CFD)1 is

Chapter 5

Exercises III: Turbulent flows

1. Een jetWe bekijken eerst de stroming in een turbulente jet. Als geometrie nemen we een rechthoekwaarbij een deel van een zijde de instroomopening van de jet is. Vanwege de tweede op-dracht kiezen we binnen Multiphysics het Chem: k-epsilon model en Chem: convection anddiffusion. Gebruik Draw Line om de geometrie te definieren. Klik dan de punten (0,0),(0.005,0), (0.15,0), (0.15,0.2) en (0,0.2) aan en tenslotte de rechtermuis. De y-as gebruikenwe als symmetrielijn. De gehele geometrie is eigenlijk tweemaal zo groot, maar omdat deoplossing symmetrisch is, hoeven we maar de helft te berekenen.Kies onder de knop Multiphysics het k-epsilon model. De randvoorwaarden zijn op de in-stroomrand: u = 0, v = 1, k = 0.01

√u2 + v2 + 1e− 6 en d = 0.0001

√u2 + v2 + 1e− 6.

De rest van de onderkant is een vast wand met Logarithmic wall function met h als layerthickness. De linkerrand is symmetrierand en de bovenrand heeft als uitstroomrand p = 0.Voor de rechterrand bekijken we twee verschillende situaties: een vaste wand, net als deonderrand, en een vrije rand die als Neutral gemodelleerd kan worden.Nu wordt het model ingevoerd. Neem ρ = 1, ν = 1/20000 en F = 0. Om de berekening sta-biel te houden moet artifiele diffusie gebruikt worden in de vergelijkingen voor de turbulentegrootheden. Vul hiervoor in: 0 0 0.5h2 en 0.5h2. Dit zijn de waarden die gebruikt wordenin de vier vergelijkingen (voor u, v, k en d met k de turbulente kinetische energie en d dedissipatie, h is de typische roosterafstand). Kies δ = 0.5h.Vervolgens wordt het rooster aangemaakt. Er komt alleen een zinnige oplossing uit als hetrooster geschikt gekozen wordt. Kies bij Mesh parameters 0.01 als Maximum edge size,general en 1.1 als Mesh growth rate. Klik op More en vul in 1 0.005 bij Max element sizefor edges (dit betekent dat edge 1 0.005 als maximale mesh grootte heeft, dit is de sym-metrierand) en 2 5 als Number of elements per edge (rand 2 is de instroomrand). Druk opRemesh en OK. Als alles goed is gegaan heeft het rooster 995 nodes en 1868 elements.Kies bij solver parameters 0.65 als relaxation parameter en klik op Log u,v,p,k,e values enkies als Logged coordinate bijvoorbeeld 0 0.02. Dat betekent dat na iedere iteratiestap dewaarden in dat punt naar het scherm worden geschreven. Op die manier kan de conver-gentie enigszins bekeken worden. Het berekenen van de oplossing duurt lang. Bewaar dezeoplossingen dan ook goed. Je hebt ze later nog nodig. Save het .mat file. Zo kan het laternog gebruikt worden.Vergelijk de oplossingen voor beide randvoorwaarden met elkaar. Beschrijf en verklaar deverschillen. Kijk bijvoorbeeld naar stroomlijnen, vectorplaatjes van de snelheid en v alsfunctie van x op verschillende waarden van y. Bekijk ook de turbulente grootheden k end en de eddy viscosity. In welke gebieden is de eddy viscosity groot ten opzichte van dekinematische viscositeit?

2. Diffusie in een jetNu gaan we met de al berekende oplossingen van de turbulente stroming berekenen hoe

14

Page 16: Rob Bastiaans June 4, 2008 - TU/epiet/edu/dos/pdf/CFD-4M050.pdf · Rob Bastiaans June 4, 2008. Chapter 1 Introduction to CFD 1.1 What is CFD? Computational °uid dynamics (CFD)1 is

twee stoffen zich mengen. Laad eerst het gewenste .mat file en klik onder Multiphysics opConvection and diffusion. Nu kunnen de randvoorwaarden en modelconstanten voor hetconvectie-diffusiemodel ingevoerd worden. Zorg bij Solver parameters ervoor dat alleen hetconvectio-diffusion model wordt opgelost en gebruik de berekende waarden van de snelheiden dergelijke door op de restartknop te drukken.We nemen aan dat de ene helft van de instroomopening (die met x > 0) uit stof 1 bestaaten de andere helft (waarin we niet de stroming berekend hebben) uit stof 2. Dit kan gemod-elleerd worden door c = 1 te kiezen op de instroomrand en c = 1/2 op de symmetrierand.Als in de oplossing c = 1 betekent dat nu dus dat in dat punt alleen stof 1 zit, c = 0 betekentalleen stof 2, en een andere waarde duidt op een mengsel. Bedenk zelf de juiste randvoor-waarden op de overige randen.Kies bij subdomain settings u = u en v = v als convectiecoefficienten. De stof beweegt danmet de stroming mee. Klik Streamline diffusion aan om de berekening stabiel te houden.Voor de diffusieconstante kunnen verschillende mogelijkheden genomen worden. Bijvoor-beeld geen diffusie (Di = 0), constante diffusie (Di = ν) of turbulente diffusie. Bij dezelaatste mogelijkheid wordt aangenomen dat de diffusiviteit evenredig is met de turbulenteviscositeit: Di = α0.09k2/d. Vergelijk de oplossing voor deze verschillende gevallen. Wat ishet effect van verschillende waarden voor α, bijvoorbeeld 0.1, 1 en 10? Wat is het verschiltussen de verschillende randvoorwaarden voor de stroming? Vergelijk bijvoorbeeld concen-tratieprofielen als functie van x bij vaste y.

15

Page 17: Rob Bastiaans June 4, 2008 - TU/epiet/edu/dos/pdf/CFD-4M050.pdf · Rob Bastiaans June 4, 2008. Chapter 1 Introduction to CFD 1.1 What is CFD? Computational °uid dynamics (CFD)1 is

Chapter 6

Assignment: Compressible flowsand natural convection

6.1 Euler equations

We berekenen de stroming rond de doorsnede van een vliegtuigvleugel. Kies onder ChemicalEngineering, Cartesian, Momentum Balance, Compressible Euler, Stationary. Maak eerst eenvleugel. Bijvoorbeeld: draw arc en klik achtereenvolgens op (-1,0), (-1,0.2) en (-0.5,0.2), drawcubic Bezier curve en klik achtereenvolgens op (-0.5,0.2), (0,0.2), (0.7,0.1) en (1,0) en dan op derechterknop van de muis. Herhaal dit met negatieve y-waarden en voeg de twee stukken samen.Schaal met factor 1/2 in beide richtingen en transleer over (0.5,0). Nu heb je een geschikte vormvan een vleugel, maar je mag ook zelf een vorm bedenken. Neem dan in ieder geval een scherpeachterrand. Kies als buitenrand een rechthoek met −1 < x < 4 en −2 < y < 2.

Definieer constanten Machin=0.8, rhoin=1, pin=1, alpha=0,uin=Machin*sqrt(1.4*pin/rhoin)*cos(alpha*pi/180) envin=Machin*sqrt(1.4*pin/rhoin)*sin(alpha*pi/180). Dit zijn het Machgetal van de inkomendestroming, de dichtheid en druk ver van de vleugel, de invalshoek (in graden) en de snelheidscom-ponenten ver van de vleugel. Machin en alpha kunnen veranderd worden.Randvoorwaarden: op een subsone instroomrand moeten ρ, u en v voorgeschreven worden, op eensupersone instroomrand alle variabelen, op een subsone uitstroomrand alleen de druk, en op eensupersone uitstroomrand niets. Op de vleugel geldt de slipvorwaarde.Vergelijkingen: Kies ηa = 0.01 voor artificiele diffusie. Laat de rest ongewijzigd. Kies als begin-voorwaarden de oplossing ver van de vleugel.Bereken de oplossing voor verschillende combinaties van Machin en alpha. Bereken met name deliftkracht en weerstandskracht. Deze vind je door p*nx en p*ny te integreren over de lijnen die devleugel definieren. Bedenk dat de weerstandskracht niet in de x-richting staat en de liftkracht nietin de y-richting, maar evenwijdig en loodrecht op de inkomende stroming. Gebruik mesh adaptionom de oplossingen te verbeteren. Neem 3000 als maximum number of elements, meshinit als refine-ment method en L2 norm als Error norm. Teken bij vaste Machin de liftkracht en weerstandkrachtals functie van alpha.

6.2 Natural convection

Als laatste probleem bekijken we natuurlijke convectie in een vierkant. Kies binnen MultiphysicsIncompressible Navier-Stokes en heat transfer. Het domein is een vierkant van 0.01 meter lengtegevuld met water (zoek alle benodigde eigenschappen ervan op). Op de wanden is de snelheidgelijk aan nul. Zwaartekracht staat in de negatieve y-richting. De linkerwand heeft temperatuur283 K en de rechterwand 303 K. De andere wanden zijn geısoleerd. Om het warmteprobleem

16

Page 18: Rob Bastiaans June 4, 2008 - TU/epiet/edu/dos/pdf/CFD-4M050.pdf · Rob Bastiaans June 4, 2008. Chapter 1 Introduction to CFD 1.1 What is CFD? Computational °uid dynamics (CFD)1 is

aan het snelheidsprobleem te koppelen moeten krachten aan de vergelijkingen toegevoegd worden:een convectieve term aan het warmteprobleem: Q = −ρC(u ∗ Tx + v ∗ Ty), waarbij Tx en Tyafgeleiden van de temperatuur naar x en y voorstellen, en een term in Navier-Stokes die het effectvan de variabele massadichtheid in rekening brengt: Fy = αρg(T − T0), met T0 = 293K eenreferentietemperatuur en α de kubieke uitzettingscoefficient. Kies een maximum mesh size van0.001 en neem een tijdstap van 0.5 tot t = 10. Neem als beginoplossing T = 293K en u = v = 0.Gebruik voor de tijdintegratie ode23s.Beschrijf en verklaar de resultaten. Zoek op wat voor dit probleem de relevante dimensielozeparameter is en onderzoek hoe de oplossing verandert bij verandering van deze parameter. Watgebeurt er als de temperatuur van de boven- en onderwand verschillend genomen wordt?

Het is vrij eenvoudig om een systeem van geforceerde convectie dimensieloos te maken. Inde vergelijking is dan de enige parameter het Reynoldsgetal en problemen zijn dan equivalent alsde geometrie gelijk is en het Reynoldsgetal. Voor complexere problemen, zoals bij natuurlijkeconvectie is dit iets lastiger. In de bijlage staat hoe je dit kunt doen voor het bovenstaandeprobleem. Er zijn dan twee dimensieloze getallen van belang, het Rayleigh getal en het Prandtlgetal. Het is aardig om het probleem zowel in dimensieloze als in dimensievolle grootheden op telossen. Omdat het geschaalde probleem vaak met getallen werkt die in de orde van 1 liggen is hetgeschaalde probleem vaak nauwkeuriger op te lossen met behulp van een computer. Je zou ditkunnen checken.

17

Page 19: Rob Bastiaans June 4, 2008 - TU/epiet/edu/dos/pdf/CFD-4M050.pdf · Rob Bastiaans June 4, 2008. Chapter 1 Introduction to CFD 1.1 What is CFD? Computational °uid dynamics (CFD)1 is

Chapter 7

Appendix I: Dimensieloos makenvan een buoyancy probleem

De Navier Stokes vergelijkingen met dichtheidsverschillen zien er als volgt uit,

∂ui

∂xi= 0 (7.1)

∂ui

∂t+ uj

∂ui

∂xj= − 1

ρ0

∂p

∂xi− g

ρ

ρ0δi3 + ν

∂2ui

∂x2i

(7.2)

In deze vergelijkingen is aangenomen dat de dichtheidsverschillen er alleen toe doen in combi-natie met de zwaartekracht g. Buiten deze term wordt verondersteld dat de dichtheidsverschillenklein zijn. We behouden hier dus in essentie de incompressibele vergelijkingen. Deze aannamewordt ook wel de Boussinesq approximatie genoemd (naar Joseph Valentin Boussinesq, Franswiskundige en fysicus, 1842-1929). Er kan nu echter een achtergrondimpuls van de vergelijkingworden afgetrokken. Dit is het gedeelte wat geassocieerd is met de hydrostatische druk. Daardoorveranderd feitelijk de druk van betekenis; de nieuwe druk is verdisconteerd met de hydrostatischedruk. We hebben dan

− 1ρ0

∂p

∂z+ g = 0, (7.3)

met oplossing ph = p0 + ρ0gz, waarbij z dan van beneden naar boven loopt. Introductie vanp′ = p− ph, levert dan

− 1ρ0

∂p

∂xi= − 1

ρ0

∂(p′ + ph)∂xi

= − 1ρ0

∂p′

∂xi+ gδi3 (7.4)

en de vergelijking wordt dan

∂ui

∂t+ uj

∂ui

∂xj= − 1

ρ0

∂p′

∂xi− g

ρ− ρ0

ρ0δi3 + ν

∂2ui

∂x2i

(7.5)

Met behulp van de thermische expansie coefficient α,

α =1V

(∂V

∂T

)

p

= −1ρ

(∂ρ

∂T

)

p

, (7.6)

en aannemende dat de druk slechts weinig veranderd kunnen we nu schrijven

ρ0 − ρ

ρ0= −ρ− ρ0

ρ0= α(T − T0). (7.7)

Verder wordt er voor α ook vaak β geschreven en is de volumetrische uitzettingcoefficient vanlucht (als ideaal gas) bij een bepaalde temperatuur T gelijk aan α = β = 1/T . Dit geldt niet voor

18

Page 20: Rob Bastiaans June 4, 2008 - TU/epiet/edu/dos/pdf/CFD-4M050.pdf · Rob Bastiaans June 4, 2008. Chapter 1 Introduction to CFD 1.1 What is CFD? Computational °uid dynamics (CFD)1 is

vloeistoffen. We houden het hier algemeen en schrijven β voor de volumetrische uitzettingscoeffi-cient.

Verder is er natuurlijk ook een temperatuurvergelijking,

∂T

∂t+ uj

∂T

∂xj= κ

∂2T

∂x2i

, (7.8)

met κ = λ/(ρcp). Als we hieruit een snelheidsschaal halen op basis van een balans van convectieen diffusie en de karakteristieke lengte L,

U =κ

L(7.9)

Dit geeft ons dan ook een tijdschaal τ = L/U = L2/κ. Op basis hiervan kunnen we de vergelijkingdimensieloos maken. Dit gebeurt door het invullen van u = Uu∗, x = Lx∗, t = τt∗, T−T0 = ∆TT ∗

en p′ = ρ0U2p∗. We nemen dus ook aan dat er een typisch temperatuurverschil ∆T aanwezig is.

Op deze manier krijgen we,

∂u∗i∂t∗

+ u∗j∂u∗i∂x∗j

= −U2

L

∂p∗

∂x∗i+

L

U2gβ∆TT ∗δi3 +

ν

UL

∂2u∗i∂x∗2i

, (7.10)

wat dan geschreven kan worden als

∂u∗i∂t∗

+ u∗j∂u∗i∂x∗j

= −∂p∗

∂x∗i+ RaPrT ∗δi3 + Pr

∂2u∗i∂x∗2i

, (7.11)

met behulp van het getal van Prandtl, Pr,

Pr =ν

κ(7.12)

en het getal van Rayleigh, Ra,

Ra =gβ∆TL3

νκ. (7.13)

Het getal van Rayleigh is genoemd naar John William Strutt, 3rd Baron Rayleigh, Engelsfysicus, 1842 1919 en het Prandtl getal is genoemd naar Ludwig Prandtl, Duits fysicus, 1875 -1953.

Ook hier geldt weer het gelijkvormigheidsprincipe: Als van een stroming Ra en Pr gelijk zijnen zoals altijd, de geometrie gelijkvormig is, dan is de oplossing gelijk. Merk op dat Pr eenstofeigenschap is en Ra een eigenschap is die met de aandrijving van de stroming te maken heeft.Hoe hoger het Rayleigh getal, hoe harder de convectieve stroming. Bij een hoog Rayleigh getalwordt de stroming turbulent.

Verder moet de temperatuurvergelijking dan ook nog dimesieloos gemaakt worden. Dit resul-teert in

∆Tκ

L2

∂T ∗

∂t∗+

∆Tκ

L2uj

∂T ∗

∂x∗j=

∆Tκ

L2

∂2T ∗

∂x∗2i

, (7.14)

ofwel∂T ∗

∂t∗+ uj

∂T ∗

∂x∗j=

∂2T ∗

∂x∗2i

. (7.15)

Dimensieloos maken van de massabehoudsvergelijking is triviaal. Het totale systeem is nu dusgegeven door de dimensieloze variant van massabehoud, vgl. (??), impulsbehoud, vgl. (??) enenergiebehoud, vgl. (??), gesupplementeeerd met het Rayleigh getal, Ra en het getal van Prandtl,Pr. Vaak wordt ook het Grashof (naar Franz Grashof, Duits ingenieur, 1826 - 1893) getal gebruikt,Gr = Ra/Pr.

19

Page 21: Rob Bastiaans June 4, 2008 - TU/epiet/edu/dos/pdf/CFD-4M050.pdf · Rob Bastiaans June 4, 2008. Chapter 1 Introduction to CFD 1.1 What is CFD? Computational °uid dynamics (CFD)1 is

Chapter 8

Appendix II: Het verslag

1. De rapportages moeten op zichzelf staand leesbaar zijn

2. Omschrijf het doel van de opdracht, de mathematische formulering inclusief geometrie, evtrandvoorwaarde en initiele condities

3. Beschrijf waar je naar gaat kijken en kom hierop terug in de conclusies

4. Verwijs naar figuren in de tekst. De figuren moeten een onderschrift hebben waarin staat water te zien is en met alle verdere relevante informatie erin (figuren van week 1: bijvoorbeeldv,D,N ,∆t, t)

5. Kijk kritisch naar de resultaten, vergelijk resultaten op hetzelfde tijdstip, geen appels metperen vergelijken. Als je rare verschillen ziet bij gebruik van verschillende methodes, verklaardie dan (het mag niet zo zijn dat je gewoon een ”programmeerfout” hebt gemaakt).

6. Probeer goed na te denken over het doel van iedere oefening.

7. Probeer, in het kader van het doel, een logisch verhaal op te bouwen.

8. Probeer relevante conclusies te trekken.

9. Probeer analyses/methodes toe te voegen.

20