Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

59
Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions Incompressible Newtonian viscous flows are governed by the Navier-Stokes equations u ∂t +(u ·∇)u = - 1 ρ p + ν 2 u + f , (1) ∇· u =0, (2) where u, p, ρ, ν and f are the velocity vector, pressure, density, kinematic viscosity and body forces respectively. The equations as written are independent of coordinate system, but they look exactly the same using Cartesian coordinates. Of equally great importance, at least in chapter 3, are the Navier-Stokes equations in cylindrical coordinates. The cylindrical coordinates, r, θ, z, are given in terms of the Cartesian coordinates x, y, z as x = r cos θ, y = r sin θ, z = z. The Cartesian position vector is thus x = r cos θi + r sin θj + zk. The unit vectors in cylindrical coordinates are i r = dx dr | dx dr | = cos θi + sin θj , i θ = dx | dx | = - sin θi + cos θj , i z = dx dz | dx dz | = k. The velocity vectors in Cartesian and cylindrical coordinates read respectively u(x,y,z,t)= u x i + u y j + u z k u(r, θ, z, t)= u r i r + u θ i θ + u z i z The gradient and the divergence of the velocity vector ∇· u in cylindrical coordinates are given respectively by = i r ∂r + i θ 1 r ∂θ + i z ∂z (3) ∇· u = 1 r ∂rv r ∂r + 1 r ∂v θ ∂θ + ∂v z ∂z (4) Suggested assignment 1 Show that the following expressions are true u ·∇ = v r ∂r + 1 r v θ ∂θ + v z ∂z (5) 2 = 1 r ∂r r ∂r + 1 r 2 2 ∂θ 2 + 2 ∂z 2 (6) 1

Transcript of Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

Page 1: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

Chapter 3 - Solutions of the Newtonian viscous-flow equa-tionsIncompressible Newtonian viscous flows are governed by the Navier-Stokes equations

∂u

∂t+ (u · ∇)u = −1

ρ∇p+ ν∇2u + f , (1)

∇ · u = 0, (2)

where u, p, ρ, ν and f are the velocity vector, pressure, density, kinematic viscosity and bodyforces respectively. The equations as written are independent of coordinate system, but they lookexactly the same using Cartesian coordinates. Of equally great importance, at least in chapter 3,are the Navier-Stokes equations in cylindrical coordinates. The cylindrical coordinates, r, θ, z, aregiven in terms of the Cartesian coordinates x, y, z as

x = r cos θ,y = r sin θ,z = z.

The Cartesian position vector is thus

x = r cos θi + r sin θj + zk.

The unit vectors in cylindrical coordinates are

ir =dxdr

|dxdr |= cos θi + sin θj,

iθ =dxdθ

|dxdθ |= − sin θi + cos θj,

iz =dxdz

|dxdz |= k.

The velocity vectors in Cartesian and cylindrical coordinates read respectively

u(x, y, z, t) = uxi + uyj + uzk

u(r, θ, z, t) = urir + uθiθ + uziz

The gradient ∇ and the divergence of the velocity vector ∇ ·u in cylindrical coordinates are givenrespectively by

∇ = ir∂

∂r+ iθ

1r

∂θ+ iz

∂z(3)

∇ · u = 1r

∂rvr∂r

+ 1r

∂vθ∂θ

+ ∂vz∂z

(4)

Suggested assignment 1 Show that the following expressions are true

u · ∇ = vr∂

∂r+ 1rvθ

∂θ+ vz

∂z(5)

∇2 = 1r

∂r

(r∂

∂r

)+ 1r2

∂2

∂θ2 + ∂2

∂z2 (6)

1

Page 2: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

2h x

y

Figure 1: Laminar plane channel flow.

Suggested solution:

u · ∇ = (vrir + vθiθ + vziz) ·(ir∂

∂r+ iθ

1r

∂θ+ iz

∂z

)u · ∇ = ir · irvr

∂r+ iθ · iθ

vθr

∂θ+ iz · izvz

∂z

u · ∇ = vr∂

∂r+ 1rvθ

∂θ+ vz

∂z

The cylindrical unit vectors are orthogonal, so the only nonzero terms are those with ik · ik fork = r, θ, z.

To find the Laplacian use the formula for divergence of a vector and insert for Eq. (3)

∇2 = ∇ · ∇

∇2 = 1r

∂r ∂∂r∂r

+ 1r

∂ 1r∂∂θ

∂θ+∂ ∂∂z

∂z

∇2 = 1r

∂r

(r∂

∂r

)+ 1r2

∂2

∂θ2 + ∂2

∂z2

Suggested assignment 2 Start from Eq. (1) and derive the momentum equations for Cylindricalcoordinates. The results are given in App B of White.

Laminar parallel shear flowsThe Navier-Stokes equations are nonlinear because of the convective term, (u ·∇)u, and in generalnot analytically solvable for most problems in fluid mechanics. The equations can be solvedanalytically when the convective term is zero and for a few other simplified flows. In chapter 3 ofWhite we start by considering the types of flow where convection is zero.

The convection term is never negligible for turbulent flows, where the flow rapidly changesdirection in a seemingly chaotic fashion. We will get back to turbulent flows in Chapter 6. Fornow we assume the flow is laminar. For a laminar flow the convection term will be zero for aparallel shear flow where the geometry is infinite in at least one direction and the velocity vector isparallel to the walls of the geometry. For example, a pipe flow or a plane channel flow as shown inFig. 1, where there is only one nonzero component of the velocity vector, and the velocity vectoris parallel to the surrounding walls. The gradient of this velocity component is normal to the wall

2

Page 3: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

and as such u · ∇u = 0 and the Navier-Stokes equations reduce to the linear equations

∂u

∂t= −1

ρ∇p+ ν∇2u + f , (7)

∇ · u = 0. (8)

Since the equations are linear it should not be surprising to find that there are many analyticalsolutions available for laminar parallel shear flows.

If the only nonzero velocity component is in the x-direction, then u = (u, 0, 0) and theNavier-Stokes equations reduce to

∂u

∂t= −1

ρ

∂p

∂x+ ν∇2u+ fx, (9)

∂u

∂x= 0. (10)

which is also valid for the axial component of cylindrical coordinates (see Ch. 3-2.2). There aretwo types of parallel shear flows: Couette and Poiseuille. Couette flows are driven by movingwalls. Friction, i.e., drag or viscous forces are then responsible for "dragging" the fluid with adirection aligned with the wall. For Poiseuille flows the driving force is a pressure gradient thatcan be generated using a pump.

Couette flows

We will first look at a steady plane Couette flow, like in Chapter 3-2.1, where the height of theplane channel is 2h. There is no applied pressure and no gravitational forces in the x-direction, sothe Navier-Stokes equations reduce further to

∇2u = 0, (11)∂u

∂x= 0, (12)

with boundary conditions u(−h) = 0 and u(h) = U (see Fig. 3-1 in [7]). The exact solution ofthese equations is

u(y) = U

2

(1 + y

h

). (13)

We will now solve the Couette flow numerically using FEniCS, which is a software used for solvingdifferential equations with the finite element method (http://fenicsproject.org). An excellenttutorial for quickly getting started with FEniCS can be found here [1].

FEniCS solves PDEs by expressing the original problem (the PDEs with boundary andinitial conditions) as a variational problem. The core of the recipe for turning a PDE into avariational problem is to multiply the PDE by a function v, integrate the resulting equation overthe computational domain (typically called Ω), and perform integration by parts of terms withsecond-order derivatives. The function v which multiplies the PDE is in the mathematical finiteelement literature called a test function. The unknown function u to be approximated is referredto as a trial function. The terms test and trial function are used in FEniCS programs too.

In this course we will learn how to use the FEniCS software, but the focus will be on thephysics of flow. We will use FEniCS to generate numerical solutions that we can easily playwith to enhance our understanding of what the mathematical equations represent, but we willnot go through the inner details of the finite element method. For those interested in a deeperunderstanding, the finite element method is taught in, e.g., INF5620 and INF5650.

In the current case of a Couette flow we will solve Eq. (11). We assume here for completenessthat the equation has an additional constant source f

∇2u = f. (14)

3

Page 4: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

We now multiply the Poisson equation by the test function v and integrate over the domainΩ = [−h, h], ∫

Ω(∇2u)v dx =

∫Ωfv dx . (15)

Note that dx is used to represent a volume integral. For Cartesian coordinates dx is equal todxdydz, whereas for cylindrical coordinates it equals rdrdθdz.

Next we apply integration by parts to the integrand on the left hand side with a second-orderderivative, ∫

Ω(∇2u)v dx = −

∫Ω∇u · ∇v dx+

∫∂Ω

∂u

∂nv ds, (16)

where ∂u∂n is the derivative of u in the outward normal direction at the boundary (here at y = ±h).

The test function v is required to vanish on the parts of the boundary where u is known, which inthe present problem implies that v = 0 for y = ±h. The second term on the right-hand side ofEq. (16) therefore vanishes for the current problem and we are left with

−∫

Ω∇u · ∇v dx =

∫Ωfv dx , (17)

which is also referred to as the weak form of the original boundary value problem (∇2u = fwith boundary conditions). The finite element method discretizes and solves this weak form ofthe problem on a domain divided into non-overlapping cells. In 2D we typically apply triangles,whereas in 3D tetrahedrons are applied. For 1D problems like the Couette flow we simply dividethe computational domain Ω into non-overlapping intervals.

The final step required for building a finite element solution is to choose an appropriate functionspace for our solution. A function space can for example be piecewise linear functions or piecewisepolynomials of a higher degree. Different function spaces can be chosen for the trial and testfunctions, but in general they only differ on the boundaries. The test and trial spaces V and Vare in the present problem defined as

V = v ∈ H1(Ω) : v = 0 on y = ±h, (18)V = v ∈ H1(Ω) : v = 0 on y = −h and v = U on y = h , (19)

Briefly, H1(Ω) is known as the Sobolev space containing functions v such that v2 and ||∇v||2have finite integrals over Ω. You will learn more about the Sobolev space in a basic finite elementcourse. For now it will be sufficient to know that you need to choose a function space and forfluid flow it is usually appropriate to choose a space consisting of piecewise linear or quadraticpolynomials.

Note that the proper mathematical statement of our variational problem now goes as follows:Find u ∈ V such that

−∫

Ω∇u · ∇v dx =

∫Ωfv dx ∀v ∈ V . (20)

Implementation The entire implementation that solves the variational problem (20) is givenin Listing 1. If this bit of code is stored in a textfile called "Couette.py", the program can be runby typing "python Couette.py" on the command line of a bash shell in the same folder as the file isstored. Alternatively one can enter an environment like Python or IPython (recommended: installwith "sudo apt-get install ipython") and execute the script there with "run Couette".[....] ipython /* start ipython in a regular bash shell */In [1] run Couette /* execute script in ipython shell */

A more thorough tutorial for the Poisson equation is given in [2]. Here we will repeat only themost necessary steps. The first thing we need to do is to import all basic FEniCS functionalityinto the python environment

from dolfin import *

4

Page 5: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

"""Couette flow"""from dolfin import *

h = 1.N = 10mesh = IntervalMesh (N, -h, h)V = FunctionSpace (mesh , ’CG ’, 1)u = TrialFunction (V)v = TestFunction (V)

def bottom (x, on_boundary ):return near(x[0], -h) and on_boundary

def top(x, on_boundary ):return near(x[0], h) and on_boundary

U = 1.bcs = [ DirichletBC (V, 0, bottom ),

DirichletBC (V, U, top)]

u_ = Function (V)solve (- inner (grad(u), grad(v))*dx == Constant (0)*v*dx , u_ , bcs=bcs)

u_exact = project ( Expression ("U/2*(1+x[0]/h)", U=U, h=h), V)

plot(u_ , title =" Couette flow")plot(u_ - u_exact , title =" Error couette flow")

Code Listing 1: Couette.py

This is typically the first line of most FEniCS scripts as it imports all necessary functionalitylike Interval,FunctionSpace,Function,DirichletBC,UnitSquare and much, much more. Acomputational mesh is then generated by dividing the computational domain (Ω = [−h, h]) into Nequally sized intervals, each of size 2h/N

h = 1.N = 10mesh = Interval (N, -h, h)

We now choose a piecewise linear solution by defining a function space over the meshV = FunctionSpace (mesh , "CG", 1)u = TrialFunction (V)v = TestFunction (V)

Second order polynomials or higher may be chosen by using a higher number here, but for thecurrent problem this will not enhance the accuracy since the analytical solution is linear. Thetrial and test functions u and v are then declared, just as described leading up to Eq. (20).

The current problem assigns a value for u on both boundaries, which is mathematically termedDirichlet boundary conditions. To implement these Dirichlet conditions we first need to specifywhere the boundaries are using two python functions

def bottom (x, on_boundary ):return near(x[0], -h) and on_boundary

def top(x, on_boundary ):return near(x[0], h) and on_boundary

Here x is an array representing position. It is an array of length equal to the number of spatialdimensions of the mesh. In our case it is an array of length 1. The boundary conditions arecreated using the FEniCS function DirichletBC.

U = 1.

5

Page 6: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

Figure 2: Numerical solution of the Couette flow.

bcs = [ DirichletBC (V, 0, bottom ),DirichletBC (V, U, top)]

Note that by using brackets [ ] the two boundary conditions are placed in a python list named bcs.The variational problem is solved by creating a Function to hold the solution and then callingthe function solve.

u_ = Function (V)solve (- inner (grad(u), grad(v))*dx == Constant (0)*v*dx , u_ , bcs=bcs)

The u− Function has N + 1 unknowns, which are the solutions at the N + 1 nodes of the mesh.However, it is important to remember that the finite element solution is not restricted to the nodesof the mesh. The finite element solution is the piecewise continuous linear profiles, well definedover the entire elements. You can look at the discrete solution at the nodes on the command lineas a numpy array using

w = u_. vector (). array ()print w

or plot the piecewise linear solution usingplot(u_ , title =" Couette ", interactive =True)

The numerical result is shown in Fig. 2. The exact solution is given in Eq. (13). We can put theexact solution in a FEniCS Function by projecting an Expression onto the same function spaceas the numerical solution:

u_exact = project ( Expression ("U/2*(1+x[0]/h)", U=U, h=h), V)

The Functionu_exact will now contain N + 1 values, just like u−, and if we have computedcorrectly these values should be more or less the same as in u−. A plot of the numerical solutionminus the exact solution shows that the computed solution is exact down to machine precision≈ 10−16. This is to be expected since the solution is linear and we are assuming a piecewise linearfinite element solution.

6

Page 7: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

Couette flow between axially moving concentric cylinders

The next example in Chapter 3-2.2 is the flow between axially moving concentric cylinders.The equation is the same as for the regular Couette flow in 3-2.1, but the coordinate system iscylindrical. There is no applied pressure gradient and the flow is described by the Poisson equationwith no source.

∇2u = 0, (21)1r

∂r

(r∂u

∂r

)= 0. (22)

The two cylinders have diameters r0 and r1, where r0 < r1. The Dirichlet boundary conditions areu(r = r0) = u0 and u(r = r1) = u1. The solution to Eq. (22) can be found by integrating twice

u(r) = C1 ln(r) + C2, (23)

where the two integration constants are found using the boundary conditions leading to

C1 = U1 − U0

ln(r1/r0)

C2 = U0ln(r1)

ln(r1/r0) − U1ln(r0)

ln(r1/r0)

which inserted into Eq. (23) gives

u(r) = U0ln(r1/r)ln(r1/r0) + U1

ln(r/r0)ln(r1/r0) . (24)

Equation (24) is exactly the sum of Eqs. (3-18) and (3-19), which is a result of the governingequation being linear.

The variational formulation of the problem reads

−∫

Ω∇u · ∇v dx =

∫Ωfv dx , (25)

but in Cylindrical coordinates the volume integral needs to be transformed (dx = rdr2πL,assuming the cylinder has length L) and the variational problem becomes

−∫

Ω∇u · ∇v rdr =

∫Ωfvr dr . (26)

Note that the gradient requires no special treatment since the gradient component in the r-directionis unchanged in cylindrical coordinates (see Eq. (3)).

A FEniCS implementation for axially moving concentric cylinders is shown in Listing 2.

Suggested assignmentsWritten assignments Problems 3-1, 3-2 and 3-3 in White [7].

Problem 3-1 Solve for a non-Newtonian Couette flow, where the stress tensor is computed as

τ = K

(dudy

)n, (27)

where n is an integer different from 1.The momentum equation for any stress tensor in a Couette flow is

0 = ∇ · τ. (28)

7

Page 8: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

"""Couette flow between two axially moving cylinders"""from dolfin import *import pylabparameters [’reorder_dofs_serial ’] = False

r0 = 0.2r1 = 1.u0 = Constant (1)u1 = Constant (1)mesh = IntervalMesh (1000 , r0 , r1)V = FunctionSpace (mesh , "CG", 1)u = TrialFunction (V)v = TestFunction (V)

def inner_boundary (x, on_boundary ):return near(x[0], r0) and on_boundary

def outer_boundary (x, on_boundary ):return near(x[0], r1) and on_boundary

bc0 = DirichletBC (V, u0 , inner_boundary )bc1 = DirichletBC (V, u1 , outer_boundary )

r = Expression ("x[0]")F = inner (grad(v), grad(u)) * r * dx == Constant (0) * v * r * dx

u_ = Function (V)

# Compute all three subproblems (3-2) and plot in the same figurepylab . figure ( figsize =(8,4))for u00 , u11 in zip ([1, 1, 1],[1, -1, 2]):

u0. assign (u00)u1. assign (u11)solve (F, u_ , bcs =[bc0 , bc1 ])pylab .plot(u_. vector (). array () , mesh. coordinates ())

pylab . legend (["(a)", "(b)", "(c)"], loc=" lower left")pylab . xlabel (" Velocity ")pylab . ylabel ("r")pylab . savefig ("problem3 -2.pdf")

u_exact = (u1 -u0)*ln(r)/ln(r1/r0) + u0 - (u1 -u0)*ln(r0)/ln(r1/r0)u_exact = project (u_exact , V)

Code Listing 2: AxiallyMovingCyl.py

8

Page 9: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

1.0 0.5 0.0 0.5 1.0 1.5 2.0Velocity

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1.0r

(a)(b)(c)

Figure 3: Velocity fields for axially moving cylinders. (a) U0 = U1, (b) U1 = −U0, (c) U1 = 2U0.

For one-dimensional Couette flow aligned with the x-direction and homogeneous in the z-direction,the equation reads

0 = dτdy , (29)

which means that τ is a constant with respect to y and thus

K

(dudy

)n= K2, (30)

where K2 is a new constant. In other words

dudy = K3

(= (K2/K)1/n

), (31)

and thusu = K3y +K4. (32)

The solution is the same as for Newtonian flows regardless of n.

Problem 3-2 The analytical solution has already been computed in Eq. (24). We plot the resulthere in Fig. 3.

Problem 3-3 The temperature equation reduces to

0 = κ

r

ddr

(r

dTdr

)+ µ

(duzdr

)2. (33)

Inserting for Eq. (24) we have

ddr

(r

dTdr

)= − µU2

0

κr ln2(r1/r0). (34)

Integrate twice to obtain

T = − µU20

2κ ln2(r1/r0)ln2(r) + C1 ln(r) + C2, (35)

and determine constants using the two boundary conditions.

9

Page 10: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

"""Flow between rotating concentric cylinders"""from dolfin import *

r0 = 0.2; r1 = 1mesh = IntervalMesh (100 , r0 , r1)V = FunctionSpace (mesh , ’CG ’, 1)u = TrialFunction (V)v = TestFunction (V)x = Expression ("x[0]")w0 = Constant (1.); w1 = Constant (0.1)T0 = Constant (8); T1 = Constant (10)mu = Constant (0.25); k = Constant (0.001)u_ = Function (V)T_ = Function (V)F = inner (grad(v), grad(u))*x*dx + u*v/x*dxFT = inner (grad(v), grad(u))*x*dx - mu/k*v*x*( u_.dx(0)-u_/x)**2*dx

def inner_bnd (x, on_bnd ):return on_bnd and x[0] < r0+ DOLFIN_EPS

def outer_bnd (x, on_bnd ):return on_bnd and x[0] > 1- DOLFIN_EPS

bci = DirichletBC (V, r0*w0(0), "std :: abs(x[0]-0.2) < 1.e-12")bco = DirichletBC (V, r1*w1 , outer_bnd )bcTi = DirichletBC (V, T0 , inner_bnd )bcTo = DirichletBC (V, T1 , outer_bnd )

solve (lhs(F) == rhs(F), u_ , bcs =[bci , bco ])solve (lhs(FT) == rhs(FT), T_ , bcs =[ bcTi , bcTo ])

# Compute exact solution given in (3.22)ue = project (r0*w0 *( r1/x-x/r1)/(r1/r0 -r0/r1) +

r1*w1 *(x/r0 -r0/x)/(r1/r0 -r0/r1), V)

# Compute exact solution given in (3.23)Tn = project ((T_ -T0)/(T1 -T0), V)PrEc = mu*r0 **2*w0 **2/k/(T1 -T0)Te = PrEc*r1 **4/(r1 **2-r0 **2)**2*((1-r0 **2/x**2) -

(1-r0 **2/r1 **2)*ln(x/r0)/ln(r1/r0)) + ln(x/r0)/ln(r1/r0)Te = project (Te , V)

print "\ nError velocity = ", errornorm (u_ , ue , degree_rise =0)print " Error temperature = ", errornorm (Tn , Te , degree_rise =0)print "??? Should be close to zero .\n"

plot(u_ , title =" Computed angular velocity ")plot(ue , title =" Exact angular velocity (3.22)")plot(Tn , title =" Computed temperature ")plot(Te , title =" Exact temperature (3.23)")

# Since I cannot reproduce the temperature I have recomputed# (3.23) analytically . I plot that result hereC1 = w0 -r1 **2*(w1 -w0)/(r0 **2-r1 **2)C2 = r1 **2*(w1 -w0)/(1-r1 **2/r0 **2)C3 = (T1 -T0+C2 **2*mu/k*(1/r1 **2-1/r0 **2))/ln(r1/r0)C4 = T0 + C2 **2*mu/k/r0 **2-C3*ln(r0)Tee = project ((-C2 **2*mu/k/x**2+C3*ln(x)+C4 -T0)/(T1 -T0), V)plot(C1*x+C2/x, mesh=mesh , title =" Recomputed velocity ")plot(Tee , mesh=mesh , title =" Recomputed temperature ")

print "\ nError recomputed temperature = ", errornorm (Tn , Tee)print " Which is a strong indication that (3.23) is wrong !!"

Code Listing 3: RotatingCylinders.py

10

Page 11: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

Computer exercise Validate the analytical results (3-22) and (3-23) in Chapter 3-2.3 of White[7], for flow between rotating concentric cylinders. Can you reproduce Eq. (3-23)? Suggestedsolution is given in Listing 3.

Poiseuille flowsPoiseuille flows are driven by pumps that forces the fluid to flow by modifying the pressure. Fluidsflow naturally from regions of high pressure to regions of low pressure. Typical examples arecylindrical pipe flow and other duct flows. Figure 1 illustrates a fully developed plane channelflow. Fully developed Poiseuille flows exists only far from the entrances and exits of the ducts,where the flow is aligned parallel to the duct walls. If we assume the flow is in the x-direction, asshown in Fig. 3-6 of [7], then the velocity vector is u(y, z, t) = (u(y, z, t), 0, 0) and Navier-Stokesequations can be simplified to

∂u

∂t= ν∇2u− 1

ρ

dpdx, (36)

∂u

∂x= 0, (37)

The equations are still linear because the flow is aligned in one direction and convection is thuszero. The only difference from Couette flow is that there is a non-zero source term in the pressuregradient. The transient term on the left hand side is zero for stationary flows.

The total volume flow, Q, through any duct is found by integrating the velocity over the entirecross section, C, of the duct

Q =∫

CudA. (38)

Using Eq. (38) it is also possible to define an average velocity, u, through the duct

u = Q

A. (39)

The average velocity is subsequently used to define the Reynolds number and certain frictionfactors - engineering tools used to classify duct flow.

The circular pipe

For a steady cylindrical pipe flow with radius r0 the solution to Eq. (36) is found simply byintegrating twice and applying boundary conditions:

ν

r

ddr

(r

dudr

)= 1ρ

dpdx, (40)

ddr

(r

dudr

)= r

µ

dpdx, (41)

rdudr = r2

2µdpdx + C1, (42)

dudr = r

2µdpdx + C1

r, (43)

u(r) = r2

4µdpdx + C1 ln(r) + C2, (44)

where C1 and C2 are integration constants. The constant C1 must be zero for the flow at thecenter of the pipe to remain finite. The condition at the wall u(r0) = 0 gives

C2 = − r20

4µ∂p

∂x, (45)

11

Page 12: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

which leads to the final expression for the pipe flow

u(r) = − 14µ

∂p

∂x

(r20 − r2) (46)

Combined Couette and Poiseuille flow

It is possible to combine an applied pressure gradient with moving walls. Such flows are termedcombined Couette-Poiseuille flows and they are governed by the Poiseuille Eq. (36). The solutionto a combined Couette-Poiseuille flow can be found as the sum of a Couette solution uc usingzero pressure gradient and a homogeneous Poiseuille solution up using zero velocity on walls. Fora plane channel with u(h) = U and u(−h) = 0 the solution is thus found by solving the twoproblems

∇2uc = 0, uc(h) = U, uc(−h) = 0, (47)

∇2up = 1µ

dpdx, up(±h) = 0. (48)

The combined solution u = uc + up is the solution to the original problem. This can be seenby summing Eq. (47) and Eq. (48) and also evidently u(h) = uc(h) + up(h) = U and similarilyfor y = −h. The superposition is possible simply because the governing equation is linear. Theprinciple is used also for transient flows in both Chapters (3-4) and (3-5).

Noncircular ducts

For steady and fully developed duct flows the governing equation is simply the Poisson equation

∇2u = 1µ

dpdx. (49)

The equation is linear and very easy to solve numerically for any shape of the duct. There isalso a great number of analytical solutions available for noncircular duct flows, solutions that canbe used to verify the quality of the numerical software. The duct solutions are often used forspecifying inlet profiles to much more complicating geometries, where the flow enters the geometrythrough a duct.

In Listing 4 we show a FEniCS code used to solve Eq. (49) for a rectangular duct spannedas −a 6 y 6 a and −b 6 z 6 b . Of interest here is the computation of the very complicatedanalytical expression for the velocity given as

u(z, y) = 16a2

µπ3

(−dp

dx

) ∞∑i=1,3,5,...

(−1)i−1

2

[1− cosh(iπz)/2a

cosh(iπb)/2a

]× cos(iπy)/2a

i3. (50)

The FEniCS implementation of this exact solution overloads the Expression class and you shouldrecognize Eq. (50) in the overloaded eval method. Here x is an array of the coordinates and x[0]and x[1] represent y and z respectively. Unfortunately, the Python Expression u_exact is quiteslow to interpolate due to the non-vectorized for-loop. For this reason, a C++ version of the sameExpression is implemented instead, which speeds up the program with a factor of 45.

Analysing the error. In Listing 4 we compute the errornorm that compares the computedfinite element solution with the exact solution. This error will depend on the mesh size and theorder of the polynomial approximation. The error should disappear in the limit of a highly resolvedmesh or for very high order polynomials. Given the polynomial order, the rate at which the errordisappears can be computed by performing experiments with meshes of different resolution. Weassume that the error for a mesh of element size hi can be written as Ei = Chri , where C is aconstant. We now want to find the order r of which the error disappears with mesh refinement.

12

Page 13: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

from dolfin import *from numpy import cosh , cosset_log_active ( False )

dpdx = Constant (-0.01)mu = Constant (0.01)a = 2b = 1

factor = 16 .*a*a/mu(0)/pi **3*(- dpdx(0))class u_exact ( Expression ):

def eval (self , value , x):u = 0for i in range (1, 500 , 2):

u += ((-1)**((i-1)/2)*(1-cosh(i*pi*x[1]/2./a)/cosh(i*pi*b/2/a))*cos(i*pi*x[0]/2./a)/i**3)

value [0] = u * factor

# Much faster C++ versionue_code = ’’’class U : public Expression

public :

double a, b, mu , dpdx;

void eval(Array <double >& values , const Array <double >& x) const

double u = 0.;double factor = 16 .*a*a/mu/pow(DOLFIN_PI , 3)*(- dpdx);for (std :: size_t i=1; i<600; i=i+2)

u += pow(-1, (i-1)/2 % 2)*(1.-cosh(i* DOLFIN_PI *x[1]/2./a)/cosh(i* DOLFIN_PI *b/2./a))*cos(i* DOLFIN_PI *x[0]/2./a)/pow(i, 3);

values [0] = u* factor ;

; ’’’u_c = Expression ( ue_code )u_c.a = float (a); u_c.b = float (b)u_c.mu = float (mu(0)); u_c.dpdx = float (dpdx(0))

def main(N, degree =1):mesh = RectangleMesh ( Point (-a, -b), Point (a, b), N, N)V = FunctionSpace (mesh , ’CG ’, degree )u = TrialFunction (V)v = TestFunction (V)F = inner (grad(u), grad(v))*dx + 1/mu*dpdx*v*dxbc = DirichletBC (V, Constant (0), DomainBoundary ())u_ = Function (V)solve (lhs(F) == rhs(F), u_ , bcs=bc)

# u_e = interpolate ( u_exact () , V)u_e = interpolate (u_c , V)bc. apply (u_e. vector ())u_error = errornorm (u_e , u_ , degree_rise =0)return u_error , mesh.hmin ()

E = []; h = []; degree = 2for n in [5, 10 , 20 , 40 , 80 ]:

ei , hi = main(n, degree = degree )E. append (ei)h. append (hi)

from math import log as lnfor i in range (1, len(E)):

r = ln(E[i]/E[i-1])/ln(h[i]/h[i-1])print "h=%2.2E E=%2.2E r=%.2f" %(h[i], E[i], r)

Code Listing 4: RectangleDuct.py

13

Page 14: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

The order r can be found by computing Ei for two different hi’s, i.e., Ei = hri and Ei−1 = hri−1,and then isolate r:

r = ln(Ei/Ei−1)ln(hi/hi−1) . (51)

Running Listing 4 the rectangle problem is solved for a range of meshes and the output ish=4.47E-01 E=6.40E-03 r=1.76h=2.24E-01 E=1.69E-03 r=1.92h=1.12E-01 E=4.29E-04 r=1.98h=5.59E-02 E=1.08E-04 r=1.99

showing the second order accuracy that is to be expected from using piecewise linear elements.Changing the degree in the FunctionSpace to 2 the order should be three and the output quitecorrectly reads:

h=4.47E-01 E=2.14E-04 r=3.13h=2.24E-01 E=2.63E-05 r=3.03h=1.12E-01 E=3.27E-06 r=3.01h=5.59E-02 E=4.04E-07 r=3.02

Suggested assignmentsWritten assignments Problems 3-4 and 3-5 in White [7].

Problem 3-4 The problem reads: solve Eq. (22) with boundary conditions u(0) = U andu(∞) = 0. The solution is given in Eq. (23) and inserted for the boundary conditions we need tofind C1 and C2 such that

u(0) = U = C1 ln(0) + C2, (52)u(∞) = 0 = C1 ln(∞) + C2. (53)

The first condition requires C1 = 0 and thus C2 = U . The second condition requires C2 = 0,which is a contradiction. It is not possible to satisfy both boundary conditions. Physically, theboundary layer that is being dragged by the rod will continue to grow indefinitely and there is nosteady state solution possible for this problem.

Problem 3-5 Solve the momentum equation for the angular velocity

d2uθdr2 + duθ/r

dr = 0 (54)

with boundary conditions u(R) = ωR and u(∞) = 0. The solution to this equation is given byWhite [7]

uθ(r) = C1r + C2

r(55)

The boundary conditions are then

uθ(R) = ωR = C1R+ C2

R,

uθ(∞) = 0 = C1∞+ C2

which leads to C1 = 0 and C2 = ωR2 and thus the angular velocity

uθ = ωR2

r,

which agrees with the solution of a potential vortex.

14

Page 15: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

The pressure is found from the r-momentum equation

dpdr = ρu2

θ

r,

dpdr = ρω2R4

r3

which can be integrated to

p(r) = −ρω2R4

2r2 + C1

and where the constant can be found by assuming p(R) = p0 such that

p(r) = p0 + ρω2R2

2

(1− R2

r2

),

which is what we would find using Bernoulli’s equation for a potential vortex (p0 + 0.5ρ(ωR)2 =p+ 0.5ρu2).

Computer exercise In White [7] Chap. 3-3.3 there are 6 analytical solutions provided for 6different types of ducts. In this weeks computer assignment you are asked to verify the analyticalsolutions (3-47), (3-49) and (3-52). Experiment with higher order "CG" elements (the solution isthen higher order continuous piecewise polynomials) and compute the errornorm. Does the errorvanish for higher order polynomials for all ducts or does it remain constant?

Unsteady duct flowsUnsteady plane shear flows are experienced by fluids where the driving forces are suddenly orcontinuously changed. A fluid initially at rest will for example respond to a sudden increase inthe pressure gradient (we suddenly start the pump) and the volume flow through the duct willthen increase monotonically until steady state is reached. The applied pressure gradient may alsovary in time. Another scenario is that a wall is suddenly or continuously set in motion, draggingwith it the fluid initially at rest. Common for these flows is that the transient term in Eq. (36)cannot be neglected.

Starting flow in a cylindrical pipe

When a fluid initially at rest suddenly is exposed to a constant pressure gradient, the fluid willstart to move as a response to the applied forces and the flow will increase for some time untilthe steady state Poiseuille flow profile (46) is reached. For convenience we modify this equationslightly here and write it for the steady velocity us as

us = um(1− r2) , (56)

whereum = − r

20

4µ∂p

∂x(57)

and r = r/r0. We use the superposition principle and split the equation into two contributions

u(r, t) = v(r, t) + us(r), (58)

where u(r, t) is the complete solution and v(r, t) is the solution to the homogeneous Eq. (36) incylinder coordinates:

∂v

∂t= ν

(∂2v

∂r2 + 1r

∂v

∂r

), (59)

15

Page 16: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

subject to boundary condition v(r0, t) = 0 and initial condition v(r, 0) = −us(r). The equationcan be non-dimensionalized by multiplying with r2

0/ν and using t = tν/r20 and r = r/r0

∂v

∂t= ∂2v

∂r2 + 1r

∂v

∂r. (60)

Equation (60) can be solved using a separation of variables v(r, t) = V (r)T (t). Inserted intoEq. (60) we obtain

VdTdt

= T

(d2V

dr2 + 1r

dVdr

), (61)

V T = T

(V′′

+ 1rV′), (62)

T

T=V′′ + 1

rV′

V, (63)

where the dot and apostrophe represent ordinary derivatives with respect to t and r respectively.Since the left hand side depends only on t and the right hand side only on r, both sides must beequal to a constant. It turns out that the constant must be negative to satisfy the appropriateboundary conditions. We call the new constant −λ2 and obtain the two separate ordinarydifferential equations

T + λ2T = 0, (64)

r2V′′

+ rV′+ λ2r2V = 0. (65)

The first equation has solutionT (t) = e−λ

2 t. (66)

The second equation can be rewritten using x = rλ and chain rule differentiation leading to

x2V′′

+ xV′+ x2V = 0, (67)

with the apostrophe here being a derivative with respect to x. Equation (67) is Bessel’s differentialequation of zero order. The solution to Bessel’s equation is the Bessel function of the first kind oforder zero

J0(x). (68)

A solution to V becomesV (r) = AJ0(λr), (69)

where A is a constant. We now need to make sure that the boundary and initial conditions aresatisfied. The boundary condition requires V (1) = J0(λ) = 0. Figure 4 shows how the Besselfunction behaves. Apparently it looks somewhat like a damped cosine function with multipleroots that we call λk. The first four roots are located at x = 2.4048, 5.5201, 8.6537, 11.7915corresponding to λ1, λ2, λ3, λ4. One general solution is thus

V (r) = AkJ0(λkr) (70)

with a total solutionv(r, t) = AkJ0(λkr)e−λ

2k t. (71)

Since the equations are linear we can use superposition and obtain a total solution simply bysumming over multiple possible solutions

v(r, t) =∞∑k=1

AkJ0(λkr)e−λ2k t. (72)

16

Page 17: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

Figure 4: Plot of the Bessel function of first kind of zero order.

We now have a solution consisting of many constants that satisfy the boundary condition. Itremains to close these constants using the initial condition v(r, 0) = −um(1− r2).

We have∞∑k=1

AkJ0(λkr) = −um(1− r2) (73)

and we want to find Ak. To this end we use orthogonality∫ 1

0xJn(λkx)Jn(λmx)dx = 0 for k 6= m (74)

and orthonormality ∫ 1

0xJn(λkx)Jn(λkx)dx =

J2n+1(λk)

2 . (75)

If Eq. (73) is multiplied by rJ0(λmr) and integrated from zero to unity we get∫ 1

0rJ0(λmr)

∞∑k=1

AkJ0(λkr)dr = −∫ 1

0um(1− r2)rJ0(λmr)dr. (76)

We now use (74) to eliminate all terms on the left hand side where k 6= m and insert for (75). Theresult is a closed expression for Ak

Ak = − 2J2

1 (λk)

∫ 1

0rJ0(λkr)um(1− r2)dr. (77)

The integral on the right hand side can be evaluated exactly (details left out for now) leading to

Ak = −4umJ2(λk)λ2kJ

21 (λk) = − 8um

λ3kJ1(λk) (78)

The final solution to starting flow in a cylinder, Eq. (59), becomes

u(r, t) = um(1− r2)−∞∑k=1

8umJ0(λkr)λ3kJ1(λk) e−λ

2k t (79)

in agreement with Eq. (3-96) in White [7].

17

Page 18: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

Pipe flow due to an oscillating pressure gradient

Consider now the same problem as in the previous section, but with a pressure gradient that isoscillating in time

∂p

∂x= −ρKeiωt, (80)

where i =√−1 and

eiωt = cosωt+ i sinωt. (81)The governing equation for the cylinder is thus

∂u

∂t= Keiωt + ν

(∂2u

∂r2 + 1r

∂u

∂r

). (82)

We now want solve Eq. (82) with no-slip boundary conditions on the cylinder walls. We willneglect the initial condition and look only for a long-term steady oscillatory solution on the form

u(r, t) = eiωtV (r). (83)

That is, we look for a solution where all the transient behaviour is governed by an oscillatingpressure gradient proportional to eiωt.

Inserting for Eq. (83) in Eq. (82) and using the same nomenclature as in the previous sectionwe obtain

V iωeiωt = Keiωt + νeiωt(V ′′ + 1

rV ′)

V iω = K + ν

(V ′′ + 1

rV ′)

r2V ′′ + rV ′ − iω

νr2V = −Kr

2

ν.

Using x = r√iω/ν and chain rule differentiation the equation can be rewritten as

x2V ′′ + xV ′ − x2V = −Kx2

iω, (84)

where the apostrophe now represents differentiation with respect to x. This equation looks verymuch like a modified Bessel equation [3] of zero order. The only difference is the right hand side,which should be zero. To get rid of the right hand side we use another change of variables

V = V + K

iω(85)

and insert this in Eq. (84) such that

x2V ′′ + xV ′ − x2V = 0. (86)

The solution to the modified Bessel equation of zero order is the modified Bessel function of thefirst kind (the second kind cannot be used since this function is infinite for x = 0) of zero order,I0, so

V (x) = AI0(x), (87)or in terms of the ordinary Bessel function:

V (x) = AJ0(−ix), (88)

where A is a constant. With this result we can now express the total solution as

u(r, t) = eiωt(AI0(r

√iω/ν) + K

). (89)

18

Page 19: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

The boundary condition requires u(r0, t) = 0, which determines A:

A = − K

iωI0(r0√iω/ν)

. (90)

Inserted into Eq. (89) we are left with

u(r, t) = Keiωt

(1− I0(r

√iω)

I0(r0√iω/ν)

), (91)

or

u(r, t) = Keiωt

(1−

J0(r√−iω/ν)

J0(r0√−iω/ν)

), (92)

in accordance with Eq. 3-98 in White [7].The Bessel function can be found in the toolbox scipy.special. The solution is computed in

Listing 5 and the result is shown in Fig. 5 for a relatively large normalized ω = ωr20/ν = 10. A

smaller value of ω will result in velocity profiles closer to the steady Poiseuille profile umax(1− r2).

from numpy import *from pylab import *from scipy . special import jv

r0 = 1w = 0.1K = 1.0nu = 0.01r = linspace (0, r0 , 50)ws = w * r0 **2 / nu

def u(t):return K/1j/w*exp(1j*w*t)*(1-jv(0, r*sqrt(-1j*w/nu))/jv(0,

r0*sqrt(-1j*w/nu)))

figure ( figsize =(6, 4))ll = []for i in range (6):

print 1/w*i*2*pi/6plot(u(i/(6*w)*2*pi), r)ll += [r"t = 0 · τ ". format (i)]

legend (ll)axis ([-15 , 25 , 0, 1])xlabel (" Velocity ")ylabel (" Radial position ")

show ()

Code Listing 5: plotCylOscillatingGradient.py

Unsteady flows with moving boundaries

In the previous section the driving force for the oscillating flow was the pressure gradient. Transientbehaviour can also be obtained for Couette type flows, where the velocity of the walls are either

(1) Suddenly accelerated to a constant velocity uwall = U0.

(2) Oscillated as a function of time, i.e., uwall = f(t).

The governing equation for these types of flow is the homogeneous heat equation

∂u

∂t= ν∇2u. (93)

19

Page 20: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

Figure 5: Velocity profiles in a pipe with an oscillating pressure gradient. The parameterτ = 2π/w/6, such that an entire period is obtained for t = 6τ .

We consider only parallel shear flows in Cartesian coordinates, where the velocity vector isu = (u(y, t), 0, 0) and the equation is reduced to

∂u

∂t= ν

∂2u

∂y2 . (94)

There are many different solutions available for this 1D heat equation, depending on the boundaryand initial conditions of the problem. Most solutions make use of the Fourier series, the Fourierintegral or Fourier transforms, see, e.g., Kreyszig [6].

As a first example of flow that is suddenly accelerated to a constant velocity, consider a infiniteplane normal to the y-axis located at y = 0 and initially at rest at t = 0. The plane is thensuddenly accelerated to a constant velocity U0 in the x-direction and remains at this velocityfor all t > 0. Above the plane, for y > 0, the fluid is initially at rest. Friction and the no-slipboundary condition will make the flow above the plane increase in speed. Far away from the planethe velocity will be zero, i.e., u(∞, t) = 0. This means that the velocity will never reach a steadystate, and the boundary layer over the plane will continue to grow for all time.

We can find the solution as before using a separation of variables, but first we normalize thevelocity

v(y, t) = u− U0

U0, (95)

such that the boundary condition at y = 0 becomes homogeneous, i.e., v(0, t) = 0 for t > 0. ThePDE for v is still Eq. (94).

Start by separating variablesv(y, t) = T (t)V (y). (96)

Inserted into Eq. (94) we getT

νT= V ′′

V= K, (97)

where K is a constant. To obtain physically realistic solutions, the constant needs to be negative.This can be understood looking first at the transient part:

T = KνT, (98)

20

Page 21: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

with solutionT (t) = eKνt. (99)

If K is positive, then the velocity will grow without bounds and without energy being added tothe system. For the second equation we have

V ′′ −KV = 0. (100)

If K is positive, then the solution is

V (y) = A sinh(√Ky) +B cosh(

√Ky). (101)

The boundary condition V (0) = 0 requires B = 0. The remaining term A sinh(√Ky) grows

without bounds as y −→∞, which is not in agreement with v(∞, t) = −1 and we have to assumethat K is a negative constant that we can write as K = −λ2. The solutions to the separatedordinary differential equations become

T (t) = e−λ2νt, (102)

V (y) = A sin(λy) +B cos(λy). (103)

The constants need to be found using boundary and initial conditions. The boundary conditionV (0) = 0 leads to B = 0 and as such one solution reads

v(y, t) = A sin(λy)e−λ2νt. (104)

To satisfy the initial condition we need to use more than one solution and through the superpositionprinciple we can simply add solutions. A periodic Fourier series for v reads

v(y, t) =∞∑k=1

Ak sin(λky)e−λ2kνt, (105)

where Ak are constants, λk = kπ/L and L is the length of the periodic domain.However, our domain is not periodic and it is unbounded for y −→ ∞. It turns out that

for infinite domains and non-periodic solution, it is advantageous to work with Fourier integralsinstead. A Fourier integral for our problem reads

v(y, t) =∫ ∞

0A(λ) sin(λy)e−λ

2νtdλ. (106)

and the "constant" A(λ) is a continuous function of λ. Since v only contains sinuses it is an oddfunction. As such, even though we are only interested in the domain y > 0 we can define an initialcondition for v(y, 0) over the entire −∞ < y <∞ as an odd function

v(y, 0) = 1− 2H(y) =∫ ∞

0A(λ) sin(λy)dλ, for−∞ < y <∞, (107)

where H(y) is the Heaviside function. This way v(y, 0) = 1 for y < 0, v(y, 0) = −1 for y > 0 andby symmetry v(0, 0) = 0. Through orthogonality and the initial condition we can find A(λ) as(see Kreyszig [6])

A(λ) = − 2π

∫ ∞0

sin(λy′)dy′. (108)

Inserted into the total solution we get

v(y, t) = − 2π

∫ ∞0

∫ ∞0

sin(λy′)dy′ sin(λy)e−λ2νtdλ, (109)

21

Page 22: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

Figure 6: Plot of the initial condition for function v(y, 0) = 1− 2H(y).

which can be rewritten by changing the order of integration as

v(y, t) = − 2π

∫ ∞0

∫ ∞0

sin(λy′) sin(λy)e−λ2νtdλdy′. (110)

The inner integral can be transformed using sin(λy) sin(λy′) = 0.5(cosλ(y − y′)− cosλ(y + y′))

v(y, t) = − 2π

∫ ∞0

∫ ∞0

e−λ2νt 1

2 (cosλ(y − y′)− cosλ(y + y′)) dλdy′. (111)

The inner integrals can then be computed exactly since∫ ∞0

e−λ2νt cosλ(y − y′)dλ =

√π

4νte−(y−y′

2√νt

)2

, (112)

and ∫ ∞0

e−λ2νt cosλ(y + y′)dλ =

√π

4νte−(y+y′

2√νt

)2

. (113)

The solution now reads

v(y, t) = −√

14πνt

∫ ∞0

(e−(y−y′

2√νt

)2

− e−(y+y′

2√νt

)2)dy′. (114)

Using integration by substitution, the integrals can be reorganized into error functions

erf(z) = 2√π

∫ z

0e−u

2du, (115)

if we simply use a change of variables

u = y − y′

2√νt,

dudy′ = − 1

2√νt

(116)

u′ = y + y′

2√νt,

dudy′ = 1

2√νt

(117)

The integrals become ∫ ∞0

e−(y−y′

2√νt

)2

dy′ = −2√νt

∫ ∞y

2√νt

e−u2du, (118)

= −√νtπ

(1− erf

(y

2√νt

))(119)

22

Page 23: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

Figure 7: Velocity profiles for flow over a plane that is suddenly accelerated from zero to U0.

and ∫ ∞0

e−(y+y′

2√νt

)2

dy′ = 2√νt

∫ ∞y

2√νt

e−u2du, (120)

=√νtπ

(1− erf

(y

2√νt

)). (121)

Putting it all together we finally obtain

v(y, t) = −√

14πνt

(−√νtπ)

(−2)erf(

y

2√νt

), (122)

= −erf(

y

2√νt

). (123)

The original unnormalized velocity becomes

u(y, t) = U0

(1− erf

(y

2√νt

)), (124)

in agreement with Eq. 3-107 in White [7]. Profiles for the velocity above the plane is shown inFig. 7.

Suggested assignmentsWritten assignments Consider the homogeneous heat equation with inhomogeneous boundaryconditions

∂u

∂t− ν ∂

2u

∂y2 = 0, for 0 ≤ y ≤ L

u(y, 0) = φ(y),u(0, t) = g,

u(L, t) = h

where g and h are constants. Find the general solution u(y, t). Hint: use a function U(y) =1/L[(L− y)g+ yh] and find the solution of v(y, t) = u(y, t)−U(y). The equation for v(y, t) is thesame as for u(y, t), but now with homogeneous boundary conditions.

23

Page 24: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

Figure 8: Velocity profiles for flow over a plane that is suddenly accelerated from zero to U0. Plotof the entire solution including the unphysical domain.

Optional (difficult), find the general solution if g and h are functions of time. Two hints to theoptional assignment are

• Hint 1: use a function U(y, t) = 1/L[(L− y)g(t) + yh(t)] and find the solution of v(y, t) =u(y, t) − U(y, t). The equation for v(y, t) should be obtained as an inhomogeneous heatequation with homogeneous boundary conditions.

• Hint 2: Use Duhamel’s principle to solve the inhomogeneous heat equation. Duhamel’sprinciple states that the solution to the inhomogeneous heat equation can be found throughsolving just the homogeneous part. An inhomogeneous heat equation for v(y, t) reads

∂v

∂t− ν ∂

2v

∂y2 = f(y, t), for 0 ≤ y ≤ L (125)

v(y, 0) = φ(y),v(0, t) = v(L, t) = 0,

We can solve instead the homogeneous part

∂vh

∂t− ν ∂

2vh

∂y2 = 0, for 0 ≤ y ≤ L (126)

vh(y, 0) = φ(y),vh(0, t) = vh(L, t) = 0,

using for example a separation of variables vh(y, t) = S(t)V (y). The solution will evolvefrom the initial condition φ and we thus expect the solution in a small increment of time tobe expressed as vh(y, t) = S(t)φ(y). Duhamel’s principle then states that the solution to theinhomogeneous problem can be computed as

v(y, t) = vh(y, t) +∫ t

0S(t− s)f(y, s)ds,

where S(t− s)f(y, s) is the homogeneous solution we found earlier, but computed from theinitial condition f(y, s) instead of φ. One may think of

∫ t0 S(t−s)f(y, s)ds as a superposition

in time. Initialize using f(y, s) and then move the solution an infinitesimal time forwardusing the homogeneous solution. By linearity, or superposition in time, one may add up, orintegrate, the solution in time.

24

Page 25: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

Duhamel’s principle can be justified by computation. Insert for the inhomogeneous solution inEq. (125)

∂v

∂t− ν ∂

2v

∂y2 =

∂vh

∂t− ν ∂

2vh

∂y2 +(∂

∂t− ν ∂

2

∂y2

)(∫ t

0S(t− s)f(y, s)ds

)Use Leibniz rule for differentiation under the integral sign on the last part

∂v

∂t− ν ∂

2v

∂y2 = S(t− t)f(y, t) +∫ t

0

(∂

∂t− ν ∂

2

∂y2

)S(t− s)f(y, s)ds,

= S(0)f(y, t) = f(y, t).

The integral is zero since the integrand S(t−s)f(y, s) is known to be a solution of the homogeneousheat equation.

Suggested solution Introducing the function U(y, t) = 1/L[(L− y)g(t) + yh(t)] and v(y, t) =u(y, t)−U(y, t) we obtain an inhomogeneous heat equation with homogeneous boundary conditionsas given in Eq. (125). The right hand side function, boundary conditions and initial conditionscan be found straight forward as

f(y, t) = −∂U∂t

= −(1− y

L)g′(t) + y

Lh′(t)

v(y, 0) = φ(y) = φ(y)−U(y, 0),v(0, t) = v(L, t) = 0.

The solution to the homogeneous part of the problem can be found using separation of variablesvh(y, t) = T (t)V (y)

T

νT= V ′′

V= −λ2

and thus T (t) = e−λ2νt. The boundary conditions give V (y) = A sin(λy) and to satisfy initial

conditions we need to use superposition and a range of solutions. The homogeneous solution thusreads

vh(y, t) =∞∑n=1

An sin(λny)e−λ2nνt, (127)

where we can find An using the initial condition and orthogonality, i.e., multiply vh(y, 0)(= φ(y))by sin(λmy) and integrate to obtain

An = 1L

∫ L

−Lφ(y) sin(λny)dy, (128)

= 2L

∫ L

0φ(y) sin(λny)dy, (129)

where the last step follows if φ(y) is an odd function.The solution to the inhomogeneous part of the problem reuses the homogeneous solution, but

replaces φ(y) with f(y, s) when computing the coefficients through Eq. (129). We thus replace Anwith Bn(t) and compute it as

Bn(t) = 2L

∫ L

0sin(λny)f(y, t)dy (130)

Using superposition in time the inhomogeneous solution is thus

vp(y, t) =∫ t

0

∞∑n=1

e−λ2nν(t−s)Bn(s) sin(λny)ds, (131)

and the general solution to our original problem is

u(y, t) = vh(y, t) + vp(y, t) + U(y, t). (132)

25

Page 26: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

Specific solution Consider the specific solution where g(t) = U0 cos(ωt), h(t) = 0 and φ(y) =U0(1− y/L). The problem now reads for v(y, t) = u(y, t)−U(y, t)

∂v

∂t− ν ∂

2v

∂y2 = f(y, t) = U0ω(1− y

L) sin(ωt), for 0 ≤ y ≤ L (133)

v(y, 0) = U0(1− y

L)− U0(1− y

L) = 0,

v(0, t) = v(L, t) = 0,

and naturally the homogeneous solution is identically zero, i.e., vh(y, t) = 0. The inhomogeneouscontribution to the total solution is found by computing Eq. (130) and Eq. (131). Both integralscan be obtained using Wolfram alpha, the first one reads

Bn(t) = 2L

∫ L

0sin(λny)U0ω(1− y

L) sin(ωt)dy,

= 2U0ω sin(ωt)λnL

.

Inserted into Eq. (131) one obtains

vp(y, t) = 2U0ω

L

∫ t

0

∞∑n=1

sin(λny)λn

e−λ2nν(t−s) sin(ωs)ds, (134)

which Wolfram alpha tells me is equal to

vp(y, t) = 2U0ω

L

∞∑n=1

sin(λny)λn

(νλ2

n sin(ωt)− ω cos(ωt) + ωe−λ2nνt

ω2 + λ4nν

2

). (135)

The total solution is thus u(y, t) = vp(y, t) + U0 cos(ωt)(1− y/L).

Computer assignment Choose suitable g and h and compare the analytical solution from thewritten assignment with a numerical implementation.

Transient problems Transient problems are usually solved in FEniCS using a finite differenceapproximation of the time derivative. The time dimension can be discretized using constant discretetime intervals of length 4t, and we look for solutions at the discrete times t = [0,4t, 24t, ..., T −4t, T ] = k4t, for k = 0, 1, 2, ..., N − 1, N , 4t = T/N . The solutions at the N + 1 differenttimesteps are similarly written as uk. Using finite differences for the time derivative, a variationalform of the heat equation reads∫

Ω

uk − uk−1

4tvdx = −ν

∫Ω∇uk− 1

2 · ∇vdx, (136)

where the right hand side is computed at the midpoint between timesteps k and k − 1 usingnotation uk− 1

2 = (uk + uk−1)/2. Note that when the solution is computed, we start at the initialcondition at k = 0, where the initial condition u0 is known and u1 is unknown. When u1 issubsequently computed and known, we are ready to move on to the next solution u2 and so on.In other words, uk is always the unknown we are trying to compute and uk−1, uk−2, ... are allconsidered to be known. In FEniCS the unknown uk is represented in Forms as a TrialFunction,whereas all knowns are represented as Functions. A variational form for the heat equation inFEniCS may look like:

u = TrialFunction (V)v = TestFunction (V)u_ = Function (V) # Known solution at ku_1 = Function (V) # Known solution at k-1

26

Page 27: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

dt = Constant (0.1)nu = 0.01U = 0.5*(u+u_1)F = inner (u - u_1 , v)*dx + dt*nu* inner (grad(U), grad(v))*dx

The solution of the form must be placed inside a loop, advancing the solution forward in time,something like:

t = 0while t < T:

t += dtsolve (lhs(F) == rhs(F), u_ , bcs)# Advance solution to next timestep :u_1. vector () [:] = u_. vector () [:]

The python functions lhs and rhs are used to extract bilinear (terms containing both trial-and testfunctions) and linear (terms containing only testfunction and no trialfunction) formsrespectively. The last line of code copies all the values from u_ to u_1. Note that uk is theunknown we look for at timestep k. In the variational form uk is represented as an unknownTrialFunction. However, when the variational form has been solved, the known solution can befound in the Function u_ and we are then finished with timestep k. When we now move on tothe next timestep, the solution we just found becomes the solution at the previous timestep, i.e.,at k − 1. This is why we copy all values from u_ to u_1 as our final task in the time loop.

Suggested solution to computer assignment is given in Listing 6.

Fluid oscillation above an infinite plate

An infinite plate oscillates with a velocity u(0, t) = U0 cos(ωt), which is the boundary condition tothe fluid flow set in motion above the plate. We look for a "steady state" solution u = (u(y), 0, 0),meaning that we look for a solution independent of initial conditions. This problem is also referredto as Stokes second problem.

Since the plate oscillates with frequency cos(ωt) a justified guessed solution is

u(y, t) = f(y)eiωt.

Inserted into the unsteady 1D heat equation we obtain

fiωeiωt − νf′′eiωt = 0,

f′′− iω

νf = 0

A general solution to this problem is

f(y) = Ae−√

iων y +Be

√iων y,

where only the first leads to physically realistic real solutions for y −→∞, such that B = 0. Theboundary condition at y = 0 leads to

u(0, t) = f(0)eiωt = Aeiωt,

where the real part then requires A = U0 and as such

u(y, t) = U0e−√

iων y+iωt

Unsteady flow between two infinite plates

Consider two infinite plates separated by a distance h containing fluid initially at rest at t = 0. Att = 0 the velocity of the lower plate at y = 0 is suddenly accelerated to a velocity of U0 and thefluid above the plate starts to move due to friction and the no-slip boundary condition. The flow

27

Page 28: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

from dolfin import *import numpy

U0 = 1.L = 1.nu = 0.01w = 0.1mesh = IntervalMesh (40 , 0, L)V = FunctionSpace (mesh , ’CG ’, 1)u = TrialFunction (V)v = TestFunction (V)

T = 100.N = 200dt = T / Nt = 0.g = Constant (U0* numpy .cos(w*t))h = 0

bc0 = DirichletBC (V, g, "std :: abs(x[0]) < 1e -12")bcL = DirichletBC (V, h, "std :: abs(x[0]-) < 1e -12". format (L))u_ = interpolate ( Expression ("U0 *(1-x[0]/L)", U0=U0 , L=L), V)

class u_exact ( Expression ):def eval (self , value , x):

value [0] = U0 *(1-x[0]/L)*cos(w*t)f = 0for i in range (1, 20):

Ln = i*pi/Ldf = sin(Ln*x[0])/Ln *(( -w*cos(w*t) + Ln **2*nu*sin(w*t)

+ w*exp(-Ln **2*nu*t)) / (w**2 + Ln **4*nu **2))f += df

value [0] += f*2*U0*w/L

F = inner (u-u_ , v)*dx + dt*nu* inner (v.dx(0), 0.5*(u.dx(0) + u_.dx(0)))*dxequation = lhs(F) == rhs(F)ue = Function (V)uex = u_exact ()for t in numpy . linspace (dt , T, N):

g. assign (U0* numpy .cos(w*t))solve (equation , u_ , bcs =[bc0 , bcL ])plot(u_ , title =" Velocity ")ue. vector () [:] = interpolate (uex , V). vector () [:]plot(ue , title = " Exact U")print " Errornorm = ", errornorm (u_ , ue , degree_rise =0)

interactive ()

Code Listing 6: HeatInhomogenBC.py

28

Page 29: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

will approximate the steady linear Couette solution U0(1− y/h) as t −→ ∞. Find the velocitybetween the plates as a function of time and space.

The velocity, u = (u(y), 0, 0), is parallel to the walls and described by the 1D heat equation

∂u

∂t− ν ∂

2u

∂y2 = 0, for 0 ≤ y ≤ h

u(y, 0) = 0, 0 < y < h

u(0, t) = U0,

u(h, t) = 0

Through a shift of variables and using the steady Couette solution v(y, t) = u(y, t)− U0(1− y/h),the problem can be redefined with homogeneous boundary conditions

∂v

∂t− ν ∂

2v

∂y2 = 0, for 0 ≤ y ≤ h

v(y, 0) = −U0(1− y/h), 0 < y < h

v(0, t) = 0,v(h, t) = 0

We can solve this problem easily using separation of variables v(y, t) = T (t)V (y). Inserted intothe heat equation we obtain as before

T

νT= V ′′

V= −λ2

and two ordinary differential equations for T and V

T (t) = e−λ2νt,

V (y) = A sin(λy) +B cos(λy).

The boundary conditions give us B = 0 and λ = λn = nπ/h for n = 1, 2, . . .. Using superpositionwe get the total solution for v(y, t):

v(y, t) =∞∑n=1

An sin(λny)e−λ2nνt,

where the coefficients are found using the initial condition and orthogonality. That is, multiplyv(y, 0) by sin(λm), integrate from 0 to h and isolate An:

An = −2U0

h

∫ h

0sin(λny)(1− y/h)dy

An = −2U0

The total solution is then

u(y, t) = U0(1− y/h)− 2U0

π

∞∑n=1

sin(λny)n

e−λ2nνt.

Similarity solutions

Similarity solutions are obtained when the number of independent variables describing a problemis reduced by at least one. We will first illustrate this by revisiting Stokes first problem - A fluidinitially at rest in an infinite domain (y −→∞) is suddenly set in motion by an infinite flat plate

29

Page 30: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

located at y = 0. We have already found the solution to this problem using Fourier integrals. Thesolution is given in Eq. (124) and repeated here

u(y, t) = U0

(1− erf

(y

2√νt

)).

We will now look at this problem again and try to find a solution using a similarity approach.First define a similarity variable

η = y

2√νt,

and observe that the solution can be written in terms of merely one variable

u(η) = U0 (1− erf(η)) .

Usually we don’t know the solution and have to guess a similarity variable. Having defined η, theheat equation can be rewritten using chain rule differentiation

dudη

∂η

∂t− ν

(d2u

dη2

(∂η

∂y

)2+ du

dη∂2η

∂y2

)= 0.

The partial derivatives of η are

∂η

∂t= − η2t ,

∂η

∂y= 1

2√νt,

∂2η

∂y2 = 0.

Inserting this into the above leads to and ordinary differential equation for u(η), which is exactlywhat we were hoping to achieve

2ηdudη + d2u

dη2 = 0.

This ordinary differential equation must be solved using boundary conditions u(0) = U0 andu(∞) = 0. Define first h(η) = du/dη and rewrite the ODE as

2ηh+ dhdη = 0.

Separate variables and integrate to obtain

dudη = Ae−η

2.

Integrate one more time to obtain

u(η) = Aerf(η) +B

Inserting for the boundary conditions we finally get the original solution derived with much moreeffort in Eq. (124).

Suggested assignmentsWritten assignments Problem 3-15, 3-16, 3-17 from White [7].

Suggested solutions

30

Page 31: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

Problem 3-15 Since the boundary conditions are independent of x we may assume a parallelshear solution of the form u = (u(y), 0, 0), with ∂p/∂x = 0. The momentum equation reduces to

0 = µ∇2u+ ρg sin θ,

where θ is the angle of the plate with the horizontal. The boundary conditions are u(0) = 0 anddu/dx(h) = 0. Integrate twice to obtain

u = −ρg sin θy2

2µ +Ay +B

The boundary conditions are then used to find A and B. The first, u(0) = 0, gives us B = 0 andthe second

dudy

(y = h) = 0 = −ρg sin θhµ

+A

A = ρg sin θhµ

and thus the final velocity profile

u(y) = ρg sin θy2µ (2h− y)

The volumetric flow rate Q per unit width is found through

Q =∫ h

0u(y)dy

Q = ρgh3 sin θ3µ

Problem 3-16 Assume negligible pressure gradient in z-direction since the film is thin and thepressure outside the film is constant atmospheric pressure. The momentum equation in z-directionreads

µ

r

ddr

(r

dudr

)+ ρg = 0.

Integrate twice to obtain

u(r) = −ρgr2

4µ +A ln r +B.

The boundary conditions are no-slip at the wall and no shear at the free surface. The second onegives us

dudr (y = b) = −ρgb2µ + A

b= 0

A = ρgb2

The no-slip boundary condition gives us

u(a) = 0 = −ρga2

4µ + ρgb2

2µ ln a+B

B = ρga2

4µ −ρgb2

2µ ln a,

31

Page 32: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

which leads to the final expression for the velocity

u(r) = ρg

4µ(a2 − r2)+ ρgb2

2µ ln ra

The volumetric flow rate can be found through

Q = 2π∫ b

a

u(r)rdr

Q = . . .

Problem 3-17 Like in Problem 3-15 the velocity is given as

u1 = −ρ1g sin θy2

2µ1+A1y +B1,

u2 = −ρ2g sin θy2

2µ2+A2y +B2.

The boundary conditions are now

u1(0) = 0,u1(h1) = u2(h1),

µ1du1

dy (h1) = µ2du2

dy (h1)

du2

dy (h1 + h2) = 0.

The first one gives B1 = 0. The remaining leads to three equations for three unknowns. They are:

−ρ1g sin θh21

2µ1+A1h1 = −ρ2g sin θh2

12µ2

+A2h1 +B2,

−ρ1g sin θh1

µ1+A1 = −ρ2g sin θh1

µ2+A2

−ρ2g sin θ(h1 + h2)µ2

+A2 = 0

A2 is given by the last equation. Inserting this into the previous gives us A1

A1 = −ρ2g sin θh1

µ2+ ρ2g sin θ(h1 + h2)

µ2+ ρ1g sin θh1

µ1

A1 = g sin θ(ρ2h2

µ2+ ρ1h1

µ1

)And A1 and A2 inserted into the first gives us B2

B2 = −ρ1g sin θh21

2µ1+A1h1 + ρ2g sin θh2

12µ2

−A2h1

Plane stagnation flow

Another well known and much used similarity solution is the streamfunction ψ(x, t), that is mostoften used for two-dimensional flows, where it is defined through

u = ∂ψ

∂y, v = −∂ψ

∂x. (137)

32

Page 33: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

In 2D the only non-zero component of the vorticity vector, ωz, is computed as

ωz = ∂v

∂x− ∂u

∂y, (138)

If this definition is combined with Eq. (137) we obtain a Poisson equation for the streamfunction

∇2ψ = −ωz. (139)

The streamfunction is much used for inviscid irrotational flows, where the vorticity componentωz = 0. However, the definition of the streamfunction is equally valid for viscous flows.

An illustration of plane stagnation flow is given in Fig. (3-24) of [7]. For inviscid flows thesolution is trivially obtained as

ψ = Bxy, u = Bx, v = −By, (140)

where B is a positive constant. Make sure to check that the solution satisfies both Eq. (139) (withzero right hand side) and the continuity equation

∂u

∂x+ ∂v

∂y= 0. (141)

For viscous flows it is somewhat more complicated, since the right hand side of Eq. (139) isnonzero. To find the solution for viscous flows we also need to consider the momentum equationsin two dimensions

u∂u

∂x+ v

∂u

∂y= −1

ρ

∂p

∂x+ ν

(∂2u

∂x2 + ∂2u

∂y2

),

u∂v

∂x+ v

∂v

∂y= −1

ρ

∂p

∂y+ ν

(∂2v

∂x2 + ∂2v

∂y2

). (142)

These equations are nonlinear due to the two underlined terms and coupled through the continuityequation. Note that there are three equations for the three unknowns u, v, p, so the equations areclosed. We will now look for a similarity solution through a modification of the streamfunction ofthe form

ψν = Bxf(y), u = ∂ψν∂y

= Bxdf

dy, v = −∂ψν

∂x= −Bf. (143)

Using an apostrophe for the derivative of f with respect to y one has immediately

∂u

∂x= Bf

′,

∂u

∂y= Bxf

′′,

∂2u

∂x2 = 0, ∂2u

∂y2 = Bxf′′′,

∂v

∂x= 0, ∂v

∂y= −Bf

′,

∂2v

∂x2 = 0, ∂2v

∂y2 = −Bf′′.

We immediately see that the continuity equation is satisfied. Inserting for the streamfunction inEq. (142) we obtain

B2x(f′)2 −B2xff

′′− νBxf

′′′= −1

ρ

∂p

∂x,

B2ff′+ νBf

′′= −1

ρ

∂p

∂y

The last equation here states that ∂p/∂y is only a function of y and thus

∂2p

∂x∂y= 0. (144)

33

Page 34: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

The momentum equation in the x-direction can be simplified by dividing through by −νBx

f′′′

+ B

ν

(ff′′− (f

′)2)

= 1νBxρ

∂p

∂x(145)

The left hand side is only a function of y and as such we need the right hand side also as a functionof only y. For this to happen it is evident that the pressure derivative ∂p/∂x = constxh(y), whereh(y) is some function of y. However, from Eq. Eq. (144) it follows that h must be a constant aswell and as such the right hand side of Eq. (145) must be constant. Since the right hand side isconstant, this means that the left hand side also must be a constant.

Treating the right hand side as a constant we can compute its value using the boundaryconditions f ′ = 1, f ′′ = f

′′′ = 0 for y −→ ∞ (the first follows from freestream conditionuviscous = uinviscid). Inserted for the boundary conditions we obtain finally

f′′′

+ B

ν

(ff′′− (f

′)2)

= −Bν. (146)

Note that Eq. (146) is an exact equation for stagnation flow, since no terms have been elimi-nated in its derivation. The equation is nonlinear, which calls for iterative numerical solutiontechniques. The equation can be nondimensionalized using length- and velocityscales

√ν/B and√

νB respectively, and the dimensionless variables

η = y

√B

ν, ψ = xF (η)

√Bν. (147)

We can now easily obtain

f(y) = F

√ν

B,

f′

= dF

dy

√ν

B= F

√B

ν

√ν

B= F

′,

f′′

= dF′

dy= F

′′

√B

ν,

f′′′

= dF′′

dy= F

′′′B

ν.

Inserted into Eq. (146) we obtain the dimensionless equation

F′′′

+ FF′′

+ 1− (F′)2 = 0, (148)

that can be solved using boundary conditions F (0) = F′(0) = 0 and F ′(∞) = 1.

Axisymmetric stagnation flow

The plane stagnation flow discussed in the previous section is stagnant for a line in the z-planelocated at x = 0. Axisymmetric stagnation flow is similar in form, but only stagnant in a singlepoint located at x = y = z = 0. This axisymmetric flow is what you obtain by pointing a gardenhose directly towards a plane wall (neglecting gravity). The equations are similar to the plane flow,but may be simplified using cylindrical coordinates. A streamfunction in cylindrical coordinatescan be defined through

ur = −1r

∂ψ

∂z, uz = 1

r

∂ψ

∂r(149)

For axisymmetric flows with uθ = 0 the continuity equation reads

1r

∂rur∂r

+ ∂uz∂z

= 0.

34

Page 35: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

Inserting for Eq. (149) it is easily verified that continuity is satisfied.The streamfunction for axisymmetric inviscid flow towards a stagnation point is given as

ψ = −Br2z

which leads to velocity components

ur = Br, uz = −2Bz

For viscous flows one may obtain a dimensionless similarity solution using

ψ = −r2F (η)√Bν, η = z

√B

ν.

Inserting into the momentum equation for ur the mathematics are very much like in the previoussection leading to

F′′′

+ 2FF′′

+ 1− (F′)2 = 0. (150)

This differs from plane stagnation flow only by the factor 2.

Numerical solution of nonlinear equationsEquation (148) and Eq. (150) are nonlinear and no analytical solutions are known. Very fewtechniques are actually available for solving nonlinear equations analytically and as such we usuallyhave to rely on numerical methods to obtain solutions for real fluid flows. Reynolds AveragedNavier-Stokes equations, that will be discussed thoroughly in chapter 6 of White [7], are basicallyNavier-Stokes equations with a nonlinear viscosity coefficient. In this section we will consider twoof the most important techniques for iteratively solving nonlinear equations: Picard and Newtoniterations.

The general procedure for obtaining solutions to nonlinear equations is to guess an initialsolution and then successively recompute new and hopefully better approximations to the solution.This is illustrated nicely with Newton’s method (also called Newton-Raphson’s method). Considera nonlinear function f(x) of one variable x (e.g., f(x) = x2 − 1 or f(x) = x sin(x)− 1), where oneis interested in finding the roots x such that f(x) = 0. Newton’s method boils down to making aninitial guess x0 that does not satisfy our equation (i.e., f(x0) 6= 0) and from this initial guess wesuccessively compute better approximations to the final root:

Guessx0, n = 0while not f(xn) ≈ 0 do

xn+1 = xn −f(xn)f ′(xn)

n = n+ 1

That is, compute x1 from x0 and check if the solution is close enough to the root. If not, computex2 using x1 as initial condition. Repeat until f(xn) ≈ 0.

When PDEs are solved numerically we obtain through discretization a system of many equationsfor many variables. Newton’s method extends easily to systems of equations as well. Consider 2equations with two unknowns written compactly as F (x)

F (x) =x2 + 2xy = 0,x+ 4y2 = 0,

(151)

where x = (x, y)T . The vector F has two components (the two equations) and there are twounknowns. We can compute the derivative of F with respect to x

Jij = ∂Fi∂xj

=(

2x+ 2y 2x1 8y

). (152)

35

Page 36: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

The derivative is often called the Jacobian. Newton’s method for these two equations (or anysystem of equations) is simply

J(xk)(xk+1 − xk) = −F (xk), (153)

or with index notation for equation i

Jkij(xk+1j − xkj ) = −F ki , (154)

where the k index signals that both J and F are computed using the solution at iteration step k.There is no summation on repeated k’s.

A discrete finite element solution of the function u can be written as

u(x) =N∑i=0

uivi(x), (155)

where vi are the testfunctions. The solution has N + 1 unknowns ui, or "degrees of freedom", thatfor a linear Lagrange element are the values at the vertices of the mesh. When a PDE containingboth trial- and testfunctions is assembled in FEniCS a set of N + 1 linear equations arise for theseunknowns. We will now see how nonlinear equations can be handled by FEniCS.

Nonlinear Poisson equation

Consider the nonlinear Poisson equation

−∇ · (q(u)∇u) = f(u), (156)

where q and f may be nonlinear functions of u. Using testfunction v as in Eq. (18) and neglectingthe boundary term the variational form reads∫

Ωq(u)∇u · ∇vdx =

∫Ωf(u)vdx. (157)

This is a nonlinear variational form and we need to solve it iteratively.

Newton’s method Consider first Newton’s method for solving the nonlinear Poisson equation.We use the notation uk for the known solution at iteration step k and u the unknown trialfunctionas before in Eq. (19). For Newton’s method we write the variational form solely in terms of knownfunctions

F (uk; v) =∫

Ωq(uk)∇uk · ∇vdx−

∫Ωf(uk)vdx. (158)

F (uk; v) is a linear form in that it does not contain the unknown u, only the testfunction v. It is anonlinear form in terms of the known Function uk though. The Jacobian of F (uk; v) is computedis FEniCS as

u_ = Function (V)v = TestFunction (V)F = inner (q(u_)*grad(u_), grad(v))*dx - inner (f(u_), v)*dxJ = derivative (F, u_ , u)

where q(u_) and f(u_) are some python functions returning the coefficient of the equation andthe source respectively. The function q might for example be coded like

def q(u):return 1+u

which of course must appear in the script before creating the form F. A complete implementationthat solves the nonlinear Poisson equation on the unit interval x=[0, 1] is shown in Listing 7.Note that everything below the line with solve(F== 0, u_, [bc0, bc1]) actually can be replacedsimply by using this very compact call. The part from J = derivative(F,u_,u) and out isincluded here simply to illustrate how Newton’s method works in practise.

36

Page 37: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

from dolfin import *

mesh = UnitIntervalMesh (10)V = FunctionSpace (mesh , ’CG ’, 1)u = TrialFunction (V)v = TestFunction (V)

bc0 = DirichletBC (V, Constant (0), "std :: abs(x[0]) < 1e -10")bc1 = DirichletBC (V, Constant (1), "std :: abs(x[0]-1) < 1e -10")

def q(u):return 1+u**4

u_ = interpolate ( Expression ("x[0]"), V)F = inner (grad(v), q(u_)*grad(u_))*dx## solve (F == 0, u_ , [bc0 , bc1 ])

J = derivative (F, u_ , u)du = Function (V)error = 1; k = 0while k < 100 and error > 1e -12:

A = assemble (J)b = assemble (-F)[bc. apply (A, b, u_. vector ()) for bc in [bc0 , bc1 ]]solve (A, du. vector () , b)u_. vector ().axpy(1., du. vector ())error = norm(du. vector ())print " Error = ", errork += 1

Code Listing 7: nonlinearNewton.py

Picard iterations

For Picard iterations we have to linearize the variational form in Eq. (157) ourself. Let us firstlinearize such that the coefficient is known:

F (u; v) =∫

Ωq(uk)∇u · ∇vdx−

∫Ωf(uk, u)vdx (159)

The first term on the rhs of F (u; v) is bilinear in that it contains both trial- and testfunctions uand v. The equation is also linear in u, which is necessary for FEniCS to accept it. Note that thefunction f could be linear in u as well. For example, if f(u) = u2, then we can linearize it likef(u) = u · uk. Picard iterations are implemented as Newton up to the point where the form iscreated. The remaining part of the Picard code reads:

F = inner (grad(v), q(u_)*grad(u))*dxk = 0u_1 = Function (V)while k < 100 and error > 1e -12:

solve (F == Constant (0)*v*dx , u_ , [bc0 , bc1 ])error = errornorm (u_ , u_1)u_1. assign (u_)print " Error = ", k, errork += 1

The Function u_1 holds the previous solution and u_1.assign(u_) copies all values from thenewly computed u_ to u_1.

On my laptop computer Newton’s method requires 4 iterations to converge, whereas Picardrequires 12. This is quite typical. Newton’s method is known to be very efficient when it actuallyfinds the solution, but it often diverges if the initial guess is not close enough to the final solution.Picard is known to approach the solution more slowly, but in return it is usually more robust inthat it finds the solution from a broader range of initial conditions.

37

Page 38: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

Stokes flowFlows at very low Reynolds numbers are often called Stokes flow. If the Navier-Stokes equationsare nondimensionalized using the characteristic velocity U and length scale L, the equations canbe simplified as

Re(∂u

∂t+ (u · ∇)u

)= −∇p+ ∇2u, (160)

∇ · u = 0, (161)

where u = u/U , t = tU/L, x = x/L, p = p/(µU/L) and Re = ρUL/µ. The spatial derivativeis taken with respect to x, which explains the tilde on the nabla operator. The assumption forStokes flow is that the Reynolds number is very small Re << 1, such that the acceleration termon the left hand side of Navier-Stokes can be neglected. Stokes flow is therefore governed, ondimensional form, by

µ∇2u = ∇p, (162)∇ · u = 0. (163)

Conveniently there is a FEniCS demo available for solving the Stokes equations in a three-dimensional cubic domain. In this demo the velocity and pressure are solved using a coupledsystem of equations. That is, both Eq. (162) and Eq. (163) are solved simultaneously as opposedto in a segregated, sequential manner. Since Eq. (162) is a vector equation, this means that weare actually solving 4 equations (if the domain is 3D) simultaneously. Both u and p are treated asunknowns (TriaFunctions) using a MixedFunctionSpace:

V = VectorFunctionSpace (mesh , ’CG ’, 2)Q = FunctionSpace (mesh , ’CG ’, 1)VQ = V * Q # The Mixed space , alternative writing :#VQ = MixedFunctionSpace ([V, Q])u, p = TrialFunctions (VQ)v, q = TestFunctions (VQ)

Notice that the velocity functionspace has higher degree than the pressure functionspace. Thisdistinction is necessary in order to solve the Stokes flow using a mixed formulation. A mixedLagrange functionspace where V and Q are of the same order is unstable. Make sure to try thisout and observe the pressure.

The variational formulation for the Stokes equations is found by multiplying Eq. (162) withTestFunction v and Eq. (163) with TestFunction q and then integrating over the domain

µ

∫Ωv · ∇2udx =

∫Ωv · ∇p dx,∫

Ωq∇ · udx = 0.

Both the Laplacian and pressure gradient are integrated by parts

µ

∫Γv · (∇u · n) ds− µ

∫Ω∇v : ∇udx =

∫Γv · pnds−

∫Ωp∇ · v dx,∫

Ωq∇ · udx = 0,

where n is the normal vector out of the domain and the colon represents an inner product(contraction) of two second order tensors. The boundary integral can be written as∫

Γv · (pI − µ∇u) · nds

38

Page 39: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

and you should recognize (pI − µ∇u) · n as part of the total stress τ = −pI + µ(∇u + ∇uT )acting on the surface with normal vector n. In finite element communities the boundary condition(pI − µ∇u) · n = 0 is called pseudo-traction or a do-nothing boundary condition. It is often usedon outlets where we are simply interested in letting the fluid escape with as little interference ofboundary conditions as possible. It is called do-noting because you don’t have to do anything toenforce it, just simply omit the boundary terms and solve the two equations

µ

∫Ω∇v : ∇udx−

∫Ωp∇ · v dx = 0,∫

Ωq∇ · udx = 0.

In FEniCS we may solve these two equations (one vector and one scalar equation) coupled withthe Form

F = mu* inner (grad(v), grad(u))*dx - inner (div(v), p)*dx - inner (q, div(u))*dx

Note that terms involving TestFunction v end up in the vector equation, whereas terms containingTestFunction q end up in the scalar equation. All terms defined in F are bilinear, in that theyall contain one TestFunction and one TrialFunction. The sign of the velocity divergence hasbeen set to negative, because this leads to a symmetric coefficient matrix, which is favourable foriterative solvers.

To solve the equations we need to create a Function in the mixed functionspace to hold thesolution, for example like this:

up_ = Function (VQ)solve (lhs(F) == rhs(F), up_ , bcs)u_ , p_ = up_. split ()plot(u_)

The boundary conditions will of course depend on the problem being solved. Note that you cannotset Dirichlet boundary conditions for both velocity and pressure simultaneously, since that wouldbe an over specification. A no-slip boundary condition on a solid wall located at y = 0 for atwo-dimensional problem can be set like

bc = DirichletBC (VQ.sub(0), Constant ((0, 0)), "std :: abs(x[1]) <1e -12")

Likewise, a Dirichlet boundary condition on pressure can be set using VQ.sub(1).In the mandatory assignments we will compute Stokes flow and make use of the stream function

ψ(x, t) defined in Eq. (137). The Poisson equation for the streamfunction Eq. (139), can betransformed to a variational form by multiplying with a TestFunction ψv and then integratingover the domain using integration by parts ∫

Ωψv∇2ψdx = −

∫Ωψvωzdx,

−∫

Ω∇(ψv) · ∇(ψ)dx+

∫Γψv∇ψ · nds = −

∫Ωψvωzdx. (164)

Here n is the normal vector pointing outwards from the external boundary. The normal can beused directly in FEniCS forms through, e.g., n=FacetNormal(mesh).

By taking the curl of Eq. (162) and using that the curl of a gradient is always zero, an equationfor the vorticity vector ω is obtained

∇2ω = 0.

Likewise, by taking the divergence (not gradient as it says in White [7]) of Eq. (162) we obtain anequation for the pressure

∇2p = 0,

which follows since ∇ · ∇2u = ∇2(∇ · u) = 0. For Stokes flow both the pressure and the vorticityare governed by homogeneous Laplace equations. For 2D flows we also know the equation for the

39

Page 40: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

streamfunction ∇2ψ = −ωz. Inserting this into the Laplace equation for ωz we obtain

∇4ψ = 0, (165)

which is a biharmonic equation for the streamfunction. Obviously, if ψ is a solution to ∇4ψ = 0,then −ψ is a solution as well. In other words, the direction of flow along a streamline is arbitraryand only fixed due to boundary conditions. Reversing the direction of the flow (like we do in themandatory assignment) will not change the streamlines, but the values will get the opposite sign.

Stokes paradox states that it is not possible to obtain steady solutions to ∇4ψ = 0 for 2Dflows with both free stream and no-slip boundary conditions. Stokes paradox is, like d’Alembert’sparadox, really only a paradox because the equations do not represent real physical flow, justapproximations in the limit. It follows from Stokes paradox that inertia can never be neglectedfor 2D flows with both free stream and no-slip boundary conditions.

Creeping flow past a sphere

Stokes flow past a sphere of radius a is a 3D flow and thus solutions to ∇4ψ = 0 may be found eventhough there is no-slip on the sphere wall and free stream far away. In spherical polar coordinatesthe stream function, ψ, is defined through

ur = 1r2 sin θ

∂ψ

∂θ, uθ = − 1

r sin θ∂ψ

∂r. (166)

The streamfunction equation becomes for spherical coordinates(∂2

∂r2 + 1r

∂2

∂θ2 −cot θr2

∂θ

)2

ψ = 0, (167)

with boundary conditions

∂ψ

∂r= ∂ψ

∂θ= 0, for r = a,

ψ = 12Ur

2 sin2 θ + const, for r ←→∞.

Using separation of variables White reports that the solution to this problem reads

ψ = 14Ua

2 sin2 θ

(a

r− 3r

a+ 2r2

a2

),

and thus we obtain the velocity components from Eq. (166)

ur = U cos θ(

1 + a3

2r3 −3a2r

),

uθ = U sin θ(−1 + a3

4r3 + 3a4r

)A few important notes

• The velocity is independent of ρ and µ, which is actually true for all creeping flows.

• There is perfect symmetry of the streamlines past the sphere. No wake and no separation.

• The velocity is everywhere smaller than the free stream. This is contrary to inviscid flowswhere the velocity is maximum at the top and bottom of the sphere. For Stokes flow thevelocity will here be zero due to no-slip.

40

Page 41: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

• The effect of the sphere can be observed at enormous distances away from the sphere. Atr = 10a the velocity is still 10% lower than the free stream.

The pressure can be computed from the momentum equations in radial and θ-direction∂p

∂r= µ

(∇2ur −

2urr2 −

2r2∂uθ∂θ− 2uθ cot θ

r2

),

∂p

∂θ= µr

(∇2uθ + 2

r2∂ur∂θ− uθ

r2 sin2 θ

)Insert for ur and uθ and integrate both equations, using boundary conditions, to obtain

p(r, θ) = p∞ −3µaU2r2 cos θ, (168)

where p∞ is the pressure in the free stream. From Eq. (168) it is evident that the pressure ishighest at the front (left hand side) of the sphere where θ = π, and lowest at the rear where θ = 0.The pressure difference sets up a force acting on the sphere in the streamwise direction. The totalforce acting on the sphere is a vector that can be computed as

F =∫

Γτ · ndA,

where as before the total stress is composed of pressure and friction through the stress tensorτ = −pI + µ(∇u+∇uT ). The normal to the surface of the sphere is everywhere aligned with ther-direction such that we can write

Fp + Fτ =∫

Γ

(−pI + µ(∇u +∇uT )

)· ndA,

=∫ π

0(τrr + τrθ)2πa2 sin θdθ,

where τrr and τrθ are the pressure and friction stresses respectively. This follows since the pressureforce is always acting normal to the plane and shear acts in the tangent plane. Remember thatτij is a force acting in the j-direction on a plane having i as the normal direction.

The pressure has already been computed. The remaining shear stress can be computed inspherical coordinates as

τrθ = µ

(1r

∂ur∂θ

+ ∂uθ∂r− uθ

r

),

= −µU sin θr

3a3

2r3 .

The total force acting in the streamwise direction is computed by inserting for τrr and τrθ leadingto two simple integral as

Fx = |Fp| cos θ + |Fτ | sin θ

= 3µUπa(

23 + 4

3

),

= 6µπUa.

In other words, the drag force consists of 2/3 friction and 1/3 pressure.

Mandatory assignments due 9/3 2016Mandatory assignment (i) Verify the analytical solutions (3-47), (3-49) and (3-52) in White[7]. Experiment with higher order "CG" elements (the solution is then higher order continuouspiecewise polynomials) and compute the errornorm. Report tables of the error vs mesh size(mesh.hmin()) and comment on the order of accuracy. See Listing (4) for how to compute theerrors.

41

Page 42: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

Mandatory assignment (ii) Solve Eq. (148) and Eq. (150) using both Picard and Newtoniterations. Hint: Define a new variable H = F ′ and solve a coupled system of equations for Hand F . Start for example like this:

from dolfin import *L = 4mesh = IntervalMesh (50 , 0, L)V = FunctionSpace (mesh , ’CG ’, 1)VV = V * V # Mixed space for H and Ffh = TrialFunction (VV) # TrialFunction for the Mixed spacef, h = split (fh) # split into components in the spacevf , vh = TestFunctions (VV)

Mandatory assignment (iii) Assume low Reynolds number and use FEniCS to compute anumerical solution of Stokes flow for a driven cavity. The domain of the cavity is [0, 1]× [0, 1] andthe dynamic viscosity µ = 100. The domain consists of 4 solid walls, where the top lid (y = 1 and0 < x < 1) is moving at speed u = (1, 0). The remaining 3 walls are not moving. Compute thestreamfunction and find the center of the vortex, i.e., the point where the streamfunction goesthrough a minimum. For the driven cavity the value of the streamfunction can be set to zero onthe entire exterior domain.

Note that the boundary condition on ψ follows from the very definition of the streamfunctionEq. (137), where it should be understood that the variable ψ will only need to be known up to anarbitrary constant. If ψ is a solution, then ψ + C gives exactly the same velocity field since thepartial derivative of a constant (here C) is zero. As such we can put an "anchor" on the solutionby specifying that ψ = 0 at the corner where x = 0, y = 0. It then follows that ψ will be zero onthe entire domain. Along the left hand border, where x = 0 and 0 ≤ y ≤ 1, we have the boundarycondition on velocity stating that u = ∂ψ/∂y = 0. Since the gradient of ψ is 0 along the borderit follows that ψ = 0 along this border. Similarly, for the top lid v = −∂ψ/∂x = 0, and thus ψmust be equal to 0 for the entire top lid. The same procedure applies to the last two bordersand consequently ψ = 0 for the entire border. Note that the value does not have to be zero, anyconstant value may be chosen.

Mandatory assignment (iv) Assume low Reynolds number and use FEniCS to compute anumerical solution of Stokes flow creeping past a step (see Fig. 3-37 in [7]). A mesh for thegeometry is shown in Fig. 9. The height of the step is 0.1L. The height and width of therectangular geometry is 0.5L and L respectively. Use Re = UL/µ = 0.01 (setting density tounity) as in Fig. 3-37 in [7]. Set the velocity of the top (at y = 0.5L) to constant u = (1, 0). Usepseudo-traction for the inlet located at x = 0 and the outlet located at x = L. No-slip for thebottom wall.

Create a suitable mesh using for example Gmsh, Triangle. If you have the latest version ofFEniCS installed it is also possible to create this mesh directly by subtracting rectangles (seedemo) or by creating a SubMesh of a RectangleMesh. However, a tool like Gmsh is more flexibleand it is easy to generate meshes that have higher density near corners, as shown in Fig. 9. Once,e.g., a Gmsh mesh MyGmshMesh.msh has been created it can be converted to a dolfin meshMyDolfinMesh.xml using the dolfin-convert tool. The command "dolfin-convert -h" presents a listof formats that can be converted to dolfin mesh through the dolfin-convert tool.[....] dolfin - convert MyGmshMesh .msh MyDolfinMesh .xml

(a) Compute the streamfunction and find the center location of the standing vortex. Report theresult (e.g., in a table) as a function of mesh density. Hint: solve problem by enforcing boundaryconditions weakly. Use definition in Eq. (137) and n=FacetNormal(mesh) to implement the weakboundary form (second term on left of Eq. (164)).

(b) Make a contour plot, similar to Fig. 3-27 in [7], of the streamfunction. Hint: Dump resultto VTK-format and plot contours using paraview. To create a VTK-file for the streamfunction

42

Page 43: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

Figure 9: Mesh for a backwards facing step.

solution Function psi:f = File("psi.pvd")f << psi

(c) Compute the velocity flux in and out of the domain. Is mass being conserved? Hint: tocompute the flow through left and right domains we need to integrate the solution over thesedomains only

u =∫

ΓudA.

Surface integrals like this can be computed in FEniCS by making use of SubDomains and aFacetFunction:

def left(x, on_boundary ):return x[0] < 1e -12 and on_boundary

Left = AutoSubDomain (left)mf = FacetFunction (" size_t ", mesh)mf. set_all (0)Left.mark(mf , 1)ds = ds[mf]

Briefly, this code creates a FacetFunction that has an integer value on all facets (in 2D thatmeans all the edges) in the mesh ("size_t" may have to be replaced by "uint" depending onyour version of dolfin). The SubDomain Left is created by feeding an inside function (left) to theAutoSubDomain function. Left.mark(mf,1) sets the value of all facets on the left boundary to1. Using these tools we can now integrate over the left boundary exclusively. For example, tocompute the area of the inlet do

A = assemble ( Constant (1)*ds(1), mesh=mesh)

(d) Reverse the direction of the flow using u = (−1, 0) for the top boundary. Does this change thelocation of the vortex? Explain the result.

(e) Compute the normal stress on the bottom wall. Is there any difference depending on the

43

Page 44: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

direction of the flow? Is this realistic for real flows of moderate Reynolds numbers?The normal stress on the wall is computed as∫

Γ(τ · n) · nds, (169)

where the stress tensor τ = −pI + µ(∇u +∇uT ).

Suggested assignmentsWritten assignments Problems 4-1 and 4-3 in White [7].

Suggested solutions

Problem 4-1 Repeat the integral momentum analysis of the flat plate in Sec. 4-1 for theassumed velocity profile

u

U= 3y

2δ −12

(yδ

)3,

where δ is the boundary layer thickness. This profile is more realistic than Eq. (4-11) in White [7]since the second derivative of u wrt y is zero, whereas the second derivative of Eq. (4-11) is aconstant. It is more realistic since the momentum equation at the wall reads (see 4-39)

µ∂2u

∂y2 = dpdx = 0

a) Compute θ/x√Re. Insert the new expression for u into Eq. (4-6):

θ =∫ δ

0

u

U

(1− u

U

)dy,

= δ

∫ 1

0

(1.5η − 0.5η3) (1− (1.5η − 0.5η3)

)dη

= 39δ280

Similarly we have

δ∗ =∫ δ

0

(1− u

U

)dy,

= δ

∫ 1

0

(1− (1.5η − 0.5η3)

)dη

= 3δ8 .

To find δ we now use Eqs. (4-9) and (4-10) of White

Cf = τw12ρU

2 = 2 dθdx,

where τw = µ∂u/∂y at y = 0. This gives

1.5µU/δ12ρU

2 = 2 ddx

(39δ280

),

δdδ = 140µ13ρU dx

44

Page 45: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

which is integrated toδ2 = 280µx

13ρUor

δ

x= 4.64√

RexThe two thicknesses δ∗ and θ are found from the previous solutions using the new expression for δ.The other solutions are given in White [7] and not repeated here.

Problem 4-3 Repeat Problem 4-1 and compute Cf using the profile

u = U sin(πy

).

This profile satisfies ∂2u/∂y2 = 0 for y = 0 in addition to the other boundary conditions. Thiswas also true for the cubic profile in Problem 4-1.

Insert the new velocity estimate into expression for θ :

θ =∫ δ

0

u

U

(1− u

U

)dy,

= δ

∫ 1

0sin(πη

2

)(1− sin

(πη2

))dη,

= −4− π2π δ,

= 0.1366δ.

Using again (4-9) and (4-10) it is trivial to show that

Cf = δ

x

√Rex =

√π

0.1366 = 4.80,

which is closer to the exact 5.0 from using Blasius solution.

Chapter 4 - Laminar boundary layersImportant topics of Chapter 4.

• Displacement thickness

• Momentum thickness

• Flat plate integral analysis

• Boundary layer equations

• Flow separation

• Blasius solution

• Falkner-Skan solution

Suggested assignmentsWritten assignments• Derive the boundary layer equations (Eq. (4-32) in [7]) starting from the Navier-Stokesequations.

• Derive the Blasius equation.

• Derive the Falkner-Skan equation.

45

Page 46: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

Computer assignments Implement a nonlinear solver for the Blasius equation. Do the samefor the Falkner-Skan equation and vary the parameter β as shown in Fig. 4-11 in White [7].What happens at β = −0.19884? At −0.19884 ≤ β ≤ 0 there are according to White at least twopossible solutions. One solution is shown in Fig. 4-11a in White. Another solution shows negativevalues for f ′′(0), thus indicating backflow close to the wall. Using different initial guesses for thesolution it should be possible to obtain both solutions.

Suggested solutions The boundary layer equations (Eq. (4-32) in [7]) are derived by mul-tiplying the Navier-Stokes equations by L/U2 and then eliminating all term proportional to1/Re and 1/Re2. This is justified for flows with high Reynolds number. The NS equations arenon-dimensionalized using

x = x

Lu = u

Uv = v

U

√Re

y = y

L

√Re t = tU

Lp = p

ρU2

Term by term the momentum equation in the streamwise (x) direction is multiplied by L/U2

L

U2∂u

∂t= ∂(u/U)∂(tU/L) = ∂u

∂t

L

U2u∂u

∂x= u

U

∂(u/U)∂(x/L) = u

∂u

∂x

L

U2 v∂u

∂y= v

U

√Re

∂(u/U)∂( yL√Re)

= v∂u

∂y

L

U2 ν∂2u

∂x∂x= ν

UL

∂2(u/U)∂(x/L)∂(x/L) = 1

Re

∂2u

∂x2

L

U2 ν∂2u

∂y∂y= ∂2(u/U)∂( yL√Re)∂( yL

√Re)

= ∂2u

∂y2

L

U21ρ

∂p

∂x=∂ pρU2

∂x/L= ∂p

∂x

The second derivative of u in the x-direction is neglected and we end up with

∂u

∂t+ u

∂u

∂x+ v

∂u

∂y= ∂2u

∂y2 −∂p

∂x

In a similar manner it is trivial to show that the continuity equation is unchanged throughnormalization

∂u

∂x+ ∂v

∂y= 0.

whereas the momentum equation in the wall normal direction is found from

L

U2∂v

∂t= 1√

Re

∂v

∂t,

L

U2u∂v

∂x= u√

Re

∂v

∂x,

L

U2 v∂v

∂y= v√

Re

∂v

∂y,

L

U2 ν∂2v

∂x∂x= 1Re

32

∂2v

∂x2 ,

46

Page 47: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

L

U2 ν∂2v

∂y∂y= 1√

Re

∂2v

∂y2 ,

L

U21ρ

∂p

∂y=√Re

∂ pρU2

∂( yL√Re)

=√Re

∂p

∂y.

Dividing all terms by√Re the only term left is ∂p/∂y and thus naturally from the momentum

equation in the wall normal direction we obtain

∂p

∂y= 0.

(Note that there is an error in White Eq. (4-32), where the temperature is also accounted for. InEq. (4-32) the temperature term should be divided by

√Re.)

Derivation of Blasius equation The Blasius solution is derived from the boundary layerequations using a similarity variable

η(x, y) = y

√U

2νx.

The pressure gradient is zero and the stream function and the velocity components are assumedgiven at a constant x-value as

ψ =√

2νUxf(η), u = Uf ′, v =√νU

2x (ηf ′ − f) .

The derivatives of η are

∂η

∂x= −y2

√U

2ν x− 3

2 = − η

2x,

∂η

∂y=√

U

2νx.

These are then used in the partial derivatives of the velocity components

∂u

∂x= ∂u

∂η

∂η

∂x= −Uf

′′ η

2x

∂u

∂y= ∂u

∂η

∂η

∂y= Uf

′′

√U

2νx∂2u

∂y2 = Uf′′′ U

2νxInserting into the momentum equation

Uf ′(−1)Uf′′ η

2x +√νU

2x (ηf ′ − f)Uf′′

√U

2νx = νUf′′′ U

2νx

Multiply by 2x/U2 and rearrange

−f ′f′′η + (ηf ′ − f) f

′′= f

′′′,

f′′′

+ ff′′

= 0

47

Page 48: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

Derivation of Falkner-Skan equations Obtaining the Falkner-Skan equations from theboundary-layer equations is somewhat more complicated. We start by eliminating v using thecontinuity equation with boundary condition v = 0 for y = 0.

v = − ∂

∂x

∫ y

0u(x, y)∂y.

Inserting this expression into the momentum equation in the streamwise direction we obtain

u∂u

∂x− ∂u

∂y

∂x

∫ y

0u(x, y) dy = U

dU

dx+ ν

∂2u

∂y2

This is an integrodifferential equation for the unknown u(x, y). We seek to simplify this intoan ordinary differential equation for the similarity solution f(η). To this end we first make thesubstitutions u(x, y) = U(x)f ′(η) and require that

η = yg(x),∂η

∂x= ηg′

g.

Using this form for u we can insert for all terms in the momentum equation. Most derivatives arestraightforward, but the term with the integral requires special attention. With x held constantin the integration we obtain

− ∂

∂x

∫ y

0u dy = − ∂

∂x

∫ y

0U(x)f ′(η(y)) dy,

= − ∂

∂x

[U(x)

∫ y

0f ′(η(y)) dy

]= − ∂

∂x

[U(x)

∫ η

0f ′(η) dη

g(x)

]= − ∂

∂x

[U(x)g(x)

∫ η

0f ′(η) dη

],

= − ∂

∂x

[U(x)g(x) f(η)|η0

],

= − ∂

∂x

[U(x)g(x) f(η)

],

= −[f(η) ∂

∂x

(U

g

)+ U

gf ′(η)∂η

∂x

]= −ηUf

′g′

g2 − U ′f

g+ Ug′f

g2

The integration either with respect to y or η is always such that x is constant, which permitsmoving functions U, g from under the integration.

Next we plug ∂u∂x = U ′f ′ + Uf ′′η g

g ,∂u∂y = Uf ′′g, ∂

2u∂y2 = Uf ′′′g2 and the integral term into the

momentum equation, which yields

Uf ′(U ′f ′ + Uf ′′η

g′

g

)+ Uf ′′g

(−ηUf

′g′

g2 − U ′f

g+ Ug′f

g2

)= U

dU

dx+ νUf ′′′g2

Second and third term cancel out. Dividing by νUg2 we get

f ′′′ =(Ug′

νg3

)ff ′′ +

(dU/dx

νg2

)((f ′)2 − ff ′′ − 1

)= 0,

48

Page 49: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

which is the Falkner-Skan equation on its most general form. Note that we are not, as suggestedby White, using Leibniz’ rule to obtain this result. (Thanks to Miroslav Kuchta for performingthis detailed derivation!)

A similarity solution is obtained if the coefficients Ug′

νg3 and dU/dxνg2 are independent of x. Falkner

and Skan obtained such a similarity by choosing

η = Cyxa, and U = Kxm,

where m = 2a+ 1 and C and K are constants. The final form of the equation then reads

f′′′

+ ff′′

+ β(

1− (f′)2)

= 0, (170)

whereβ = 2m

1 +m.

Suggested assignmentsComputer assignment Compute the flow past a rotating cylinder. Use a rectangular domainΩ = [0, 6]× [−1, 1] and place the cylinder at (x, y) = (1, 0) with a radius of 0.25. Assume at firststeady creeping flow, walls at y = ±1 and set the velocity on the left hand side (x = 0) to 1− y2.Set the cylinder to rotate against the clock at a constant speed of 1. Compute lift and drag forceson the cylinder. Reverse the direction of the rotation and recompute lift and drag. Now includeconvection and solve the Steady (nonlinear) Navier-Stokes equations for the same problem.

Set the rotation to oscillate with an angular speed of sin πt and compute the unsteady creepingflow past the cylinder. Do the same for unsteady Navier-Stokes and attempt to find the vonKármán street for a steady cylinder.

Chapter 6 - Incompressible turbulent mean flowTurbulent flows are governed by the Navier-Stokes equations. However,

• there are no simplifications possible by dimensional analysis or through similarity solutions,

• no exact definition is known for turbulence,

• turbulent flows are not very well understood.

Turbulent flows are usually "defined" by listing their most characteristic properties. Here iswhat we know

• Turbulence is a flow property and not a fluid property.

• Turbulence is always three-dimensional in space and transient. There is no such thing astwo-dimensional turbulence.

• Turbulence is irregular, with seemingly random and chaotic motion. However, there isorder to the chaos. The flow satisfies the Navier-Stokes equations, so it is apparentlydeterministic. Still, N-S are extremely sensitive to initial and boundary conditions (thebutterfly-effect). The slightest perturbations in initial or boundary conditions leads to acompletely different solution. Thus, turbulence is stochastic even though the Navier-Stokesequations are deterministic.

• Turbulent flows consist to a great deal of vortices and vorticity. Vortex stretching andtilting are 3-dimensional phenomena that characterize turbulent flows and these processescan not happen in 2D. If a vortex tube is stretched it must increase its angular velocity toconserve angular momentum. This can only happen in 3D. In 2D vorticity is (unphysically)a conserved quantity.

49

Page 50: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

• The vortices come in a range of scales. The size of the largest vortices (the largest scales)is determined by the geometry of the flow, whereas the size of the smallest vortices (thesmallest scales) is determined by viscosity.

• The energy cascade. Energy is introduced into the flow on the largest scales and dissipatedon the smallest. Dissipation ε of kinetic energy is defined as

ε = µs : s, where strain s = 0.5(∇u +∇uT

)The strain increases dramatically towards the center of a vortex tube leading to higherdissipation rates in this region.

• Turbulence occur at high Reynolds numbers. The normalized momentum equation reads

∂u

∂t+ (u · ∇)u = −∇p+ 1

Re∇2u + f .

Diffusion is stabilizing as it tends to smear out all gradients. Briefly, perturbations (distur-bances) to the flow are amplified by convection and dampened by viscosity. If the Reynoldsnumber is large, then diffusion is small and convection dominates, leading to unstableturbulent flows. If the Reynolds number is small then viscosity dominates and perturbationsare killed before they can trigger turbulence.

Engineers need to be able to predict the behaviour of turbulent flows. However, in a turbulentflow the velocity u(x, t) and pressure p(x, t) should really be considered as random variables. Inother words, at any point in space and time we will not be able to predict the exact value ofvelocity or pressure. We can, however, predict the statistical properties of these random variables.This is usually accomplished using ensamble averages or Reynolds averaging.

Consider first a turbulent flow that is statistically steady, i.e., the statistical properties of theflow are independent of time. This happens, e.g., for a plane channel flow or a straight pipe flowwhere the applied pressure gradient (the driving force) is held constant. As previously stated, in aturbulent flow the velocity vector u(x, t) can be considered a random variable. If you stand in thesame spot inside the statistically steady turbulent flow and measure one velocity component, thenthe signal might very well look something like shown in Fig. 10, where 1000 samples have beentaken. The arithmetic mean of the velocity over these samples can computed as

〈u〉 (x) = 1N

N∑i=1

u(x, ti)

where u(x, ti) is the velocity at time ti and N = 1000 for the series shown in Fig. 10. If thesampling is done in discrete intervals of time 4t, then ti = i4t. Furthermore, if the samples aretaken at sufficiently long time intervals such that u(x, ti) is uncorrelated with u(x, ti +4t) thenwe talk about an ensamble average as

u(x) = limN→∞

1N

N∑i=1

u(x, ti).

By multiplying through by 4t in both numerator and denominator the ensamble average can alsobe rewritten as

u(x) = limN→∞

1N4t

N∑i=1

u(x, ti)4t,

≈ 1T

∫ T

0u(x, t)dt,

50

Page 51: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

Figure 10: Measurements of turbulent velocity.

51

Page 52: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

where T = N4t is the total sampling time, which typically needs to be larger than the largesttimescales of the flow. It can be seen that for a statistically steady flow the ensamble averagecorresponds to the time average.

For a more general turbulent flow where the statistics can change in time more care needsto be taken in defining the ensamble average because the random variable u(x, t) will in generalbe statistically different from the random variable u(x, t+4t) (e.g., u(x, t) 6= u(x, t+4t)). Toresolve this, consider flipping a coin. If ξ is the random variable where head gives ξ = 1 and tailξ = 0, then the arithmetic average obviously become

〈ξ〉 = 1N

N∑i=1

ξ(i)

where ξ(i) is the result of flip i and as N → ∞ we should get 〈ξ〉 = 0.5. Now, if the coins areidentical then the arithmetic average is obviously the same if one person flips a coin N times or Npersons flip one coin one time. This principle is used in defining an ensamble average for turbulentflows. If, instead of sampling the random variable u(x, t) at N different time intervals, we run Nidentical experiments and sample u(x, t) at the same time and place in all experiments, then thedefinition of the ensamble average will be

u(x, t) = limN→∞

1N

N∑i=1

u(i)(x, t).

For a statistically steady flow this will be identical to the time average and the left hand side willnot be dependent on time.

By using the ensamble average the instantaneous velocity and pressure may be decomposedinto a mean and fluctuating component

u(x, t) = u(x, t) + u′(x, t),p(x, t) = p(x, t) + p′(x, t). (171)

Note that both the instantaneous velocity u(x, t) and the fluctuating velocity u′(x, t) should beconsidered as random variables, whereas the mean velocity u(x, t) is deterministic. Consider anyrandom variable decomposed as φ = φ+ φ′. By definition we have φ′ = 0. This follows since wecan take the average of both sides of Eq. (171) leading to

φ = φ+ φ′,

= φ+ φ′,

= φ+ φ′,

that can only be true if φ′ = 0. (Note that the average of an average is still the average.) Someother useful averaging rules are

φ′φ = φ′ φ = 0,

φφ = φφ,

φφ = (φ+ φ′)(φ+ φ′) = φ2 + φ′φ′,

∂φ

∂s= ∂φ

∂s.

The last rule follows since the two operations differentiation and averaging commute, i.e., thederivative of an average is the same as the average of a derivative.

Having defined the average velocity and pressure we are now in a need of equations thatcan be used to predict them. Equations for any statistical measure can be derived directly

52

Page 53: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

by manipulating the Navier-Stokes equations. The equations for u and p are found simply byaveraging NS and introducing Eq. (171). Averaging the continuity equation leads to

∇ · u = ∇ · u = 0

simply because averaging and differentiation commutes. The average of the momentum equationcan be written

∂u

∂t+ (u · ∇)u = −1

ρ∇p+ ν∇2u + f

The density and viscosity are assumed constant. The first term on the left and all terms on theright are averaged by using commutation

∂u

∂t= ∂u

∂t,

1ρ∇p = 1

ρ∇p,

ν∇2u = ν∇2u.

This leaves the nonlinear convection term. Using index notation we can take two fast steps usingcontinuity and commutation

uj∂ui∂xj

= ∂uiuj∂xj

ui∂uj∂xj

= ∂uiuj∂xj

.

Inserting now for Eq. (171) we have

uiuj = (ui + u′i)(uj + u′j) = uiuj + u′iu′j

and thus

uj∂ui∂xj

=∂uiuj + u′iu

′j

∂xj

= uj∂ui∂xj

+∂u′iu

′j

∂xj

Putting it all together we obtain the Reynolds averaged Navier-Stokes equations

∂u

∂t+ (u · ∇)u = −1

ρ∇p+ ν∇2u−

∂u′iu′j

∂xj+ f , (172)

∇ · u = 0 (173)

Mandatory assignments due 11/5 2016Mandatory assignment (i) Implement a nonlinear solver for the Falkner-Skan Eq. (170).

(a) Vary the parameter β and reproduce Fig. 4-11 (a) and (b) in White [7].

(b) What happens at β = −0.19884?. At −0.19884 ≤ β ≤ 0 there are according to White at leasttwo possible solutions. One solution is shown in Fig. 4-11a in White. Another solution showsnegative values for f ′′(0), thus indicating backflow close to the wall. Using different initial guessesfor the solution it should be possible to obtain both solutions. Show these in a plot for β = −0.1.

Mandatory assignment (ii) Perform benchmarks 2.2 a) and 2.2 b) of Schaefer and Turek,1996 and report your results comparing with Table 3 and 4 of the benchmark.

53

Page 54: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

Mandatory assignment (iii) Consider a fully developed turbulent plane channel flow. Thewall friction velocity v∗ =

√ν∂u/∂y

wall= 0.05 and the turbulent Reynolds number Reτ = v∗/ν =

1000.

(a) Use the Mixing length model and implement a solver for a plane turbulent channel flow.

0 = ν∂2u

∂y2 −1ρ

∂p

∂x− ∂u′v′

∂y,

u′v′ = −νT∂u

∂y,

νt = l2|∂u∂y|,

l = κy

(1− exp

(−y

+

A

)),

y+ = yv∗

ν.

The constants κ = 0.41 and A = 26.Hint 1: the pressure gradient is constant and can be computed from v∗ by integrating themomentum equation across the channel.Hint 2: use a mesh skewed towards the walls. You should resolve the solution up to at least y+ = 1(or y ≈ ν/v∗ for the first inner node of the computational mesh). To compute a skewed mesh youcould for example do something like this

from numpy import arctanmesh = IntervalMesh (100 , 0, 1)x = mesh. coordinates ()x[:, 0] = arctan (pi *(x[:, 0])) / arctan (pi)

which gives y+ = 2.31 for first internal node and thus is not dense enough! Modify the mesh andcheck the location of the first inner node to ensure that it’s less than ν/v∗. How many nodes doyou need to ensure y+ < 1 if you use a regularly spaced mesh that is not skewed towards the wall?

(b) Verify that the solution approximates the theoretical results

y+ = u+ for y+ < 5,

u+ = 1κ

ln y+ +B for y+ > 30,

where the "constant" B = 5.5. Can you improve the agreement with the computational resultsby modifying the constants? What is the value of the turbulent viscosity νT at the center of thechannel? Do you believe this value is reasonable?

Mandatory assignment (iv) Derive from first principles• the Reynolds Averaged Navier Stokes equations (Eq. 6-13 in [7])

• the turbulence kinetic energy equation (Eq. 6.17 in [7])

• the Reynolds stress equation (Eq. 6-18 in [7])See, e.g., this book for more details about derivation.

Turbulence modellingTurbulence modelling is all about finding suitable closures, or models, for the Reynolds stresstensor. The Reynolds stress tensor is symmetrical

u′iu′j = u′ju

′i (174)

54

Page 55: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

and thus contains 6 unknown quantities. The Reynolds stress is not really a stress, but it isso called because of the way it appears in the mean momentum equation Eq. (172). The meanmomentum equation can alternatively be rewritten as

ρ

(∂u

∂t+ (u · ∇)u

)= ∇ · τ + ρf , (175)

whereτ ij = −pδij + 2µSij − ρu′iu′j , (176)

is a new term that has dimensions of stress and

Sij = 12

(∂ui∂xj

+ ∂uj∂xi

). (177)

Mathematically then it appears that the total mean stress tensor has been added a third term−ρu′iu′j after the regular pressure and viscous stresses. The term is called a Reynolds "stress", butit is in fact just the contribution of the fluctuating velocities to the mean nonlinear convection.(Note that ρ is required for the term to have dimensions of stress.) By stress we usually mean theinternal forces that fluid particles exert on each other.

The highest level of RANS modelling is usually considered the second moment closures thatsolve transport equations for u′iu′j directly. Second moment closures are outside the scope of thiscourse.

The by far most commonly used turbulence model is the eddy viscosity (first moment) closure

u′iu′j = −2νTSij + 2

3kδij , (178)

where νT is a ’turbulent viscosity’. Turbulence models are usually classified by the number ofadditional PDE’s that are used to model the turbulent viscosity.

The turbulent viscosity is a parameter of the flow and not the fluid. As mentioned before, oneof the most important properties of a turbulent flow is its ability to efficiently mix momentumand scalars, like temperature. Mathematically, the enhanced mixing is manifested through theReynolds stress and it is through Eq. (178) sought modelled as a diffusion process using νT asa positive (≥ 0) mixing rate constant. Inserted into the momentum equation the eddy viscositygives rise to the term

∂u′iu′j

∂xj= − ∂

∂xj

[νt

(∂ui∂xj

+ ∂uj∂xi

)]+ 2

3∂k

∂xi,

and it can be seen that the first term on the right hand side will lead to enhanced mixing (ordiffusion) of ui as long as νT is positive.

Having established an algebraic model for the Reynolds stress (178), we have reduced thenumber of unknowns from 6 to 2 (νT and k). We will now discuss the most common strategies forclosing the remaining terms.

The turbulent viscosity is by dimensional reasoning the product of a velocityscale u and alengthscale l

νT = u · l,

where different interpretations are possible for defining such scales. Remembering that one of the’defining’ properties of turbulence is that it contains a range of scales, such a classification into onesingle velocity- and lengthscale may seem questionable from the very start. Nevertheless, mostturbulence models boil down to finding good approximations for these scales, and the modelledscales are then usually interpreted as the largest scales of turbulence. Many different models exist(including multiscale models, which is beside the scope for this course) and sometimes a timescaletk is used instead of u, but then the two are related through u = l/tk.

Turbulence models are usually classified by the number of additional PDEs that are requiredto establish the proper scales and we will now go through some of the most basic models.

55

Page 56: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

Zero-equation models Zero-equation turbulence models are models that use zero additionalPDEs to model the turbulent viscosity. The Mixing length model was the first such turbulencemodel. For a simple plane shear flow where u is the tangential velocity and y is the wall normaldirection the model reads

u = l

∣∣∣∣dudy

∣∣∣∣ ,νT = l2

∣∣∣∣dudy

∣∣∣∣ . (179)

For a plane shear flow the model is excellent as one may choose

l ≈ y2, for y+ < 5,l ≈ κy, for 30 < y+ < 100,l ≈ 1, for y+ > 100 (180)

where κ = 0.41 is von Kárman’s constant and y is the distance to the wall. Further

v∗ =

√ν∂u

∂ywall

,

y+ = yv∗

ν,

are, respectively, the turbulent wall friction velocity and the distance to the wall in normalized’wall’ units. A Reynolds number based on v∗, Reτ = L · v∗/ν is often used to characterize flow inturbulent plane shear flows.

Several models exist that merge the three domains in Eq. (180) into one single continuousfunction. Van Driest provided a model that merged the first two inner layers using

l = κy

(1− exp

(−y

+

A

)), (181)

where A is a constant set to 26 for flat plate flow. This model should be merged with l = constantfar enough from the wall. Far enough is often chosen when l from Eq. (181) becomes larger thana factor of the mixing layer thickness δ. An often used estimate is when κy = 0.09δ or y = 0.22δ.

The Mixing length model is not a good model for other flows than plane boundary layer flows.For example, in the center of a plane channel the mean velocity gradient is zero due to symmetry(du/dy = 0). The Mixing length model Eq. (179) thus predicts that the turbulent viscosity shouldbe zero in the center of the channel. This is contrary to the experimental observation and intuition,because the turbulent intensity is actually very large in the center.

This flaws of the mixing length model first led to the suggested improvement that thevelocityscale should be proportional to the turbulence intensity and not the mean velocity gradient

u = const ·√k. (182)

The problem now is that this model introduces a new unknown k that requires modelling (whereasthe old model used known quantities l and u). Thus one additional PDE is required for closure ofthe turbulent viscosity.

One-equation models Most one-equation turbulence models solves a transport equation for k,the turbulent kinetic energy. The equation for k has already been derived in previous assignmentsand it is evident that it contains even more unclosed terms. If we start by rewriting the k-equationas

∂k

∂t+ uj

∂k

∂xj=− ∂Tj

∂xj+ P − ε

56

Page 57: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

then the terms on the right hand side are

Tj = 1ρp′u′iδij + 1

2u′iu′iu′j − ν

∂k

∂xj, (183)

P = −u′iu′j∂ui∂xj

, (184)

ε = ν∂u′i∂xj

∂u′i∂xj

. (185)

Here Tj represents turbulent transport, P is production of turbulent kinetic energy and ε is’pseudo’-dissipation of turbulent kinetic energy. The production P is closed since it only containsknown quantities like the Reynolds stress and mean velocity gradients. The first two terms of Tjand ε are unknown and require closure. ε is called ’pseudo’-dissipation since the actual dissipationof k is really 2νs′ijs′ij . The two terms are related through the identity

2νs′ijs′ij = ν∂u′i∂xj

∂u′i∂xj

+ ν∂u′i∂xj

∂u′j∂xi

,

ε = ε+ ν∂u′i∂xj

∂u′j∂xi

.

Since the last term on the rhs is small relative to the first, dissipation and ’pseudo’-dissipation aresimilar for most flows.

The turbulent transport term is usually modelled as gradient diffusion

Tj = −(ν + νt

σk

)∂k

∂xj,

where σk is a constant in the near vicinity of one. Like the name suggests the model enhancesdiffusion of k and serves to smooth out the k field faster than possible simply through regulardiffusion. This corresponds well with our knowledge of turbulence as an efficient mixing process.

The ’pseudo’-dissipation rate scales like

ε ≈ u3

l.

Thus we can find a suitable model for ε simply by inserting for Eq. (182)

ε = (const ·√k)3

l,

ε = const · k3/2

l,

and thusl = const · k

3/2

ε.

By inserting for the velocity- and lengthscales we get the following model for the turbulent viscosity

νT = const ·√kl,

νT = const · k2

ε.

A weakness of the model is that it requires the lengthscale l to be provided from knowledge of theproblem under consideration. For this reason one-equation turbulence models are often referredto as being incomplete. One-equation models are popular for systems where the mixing lengthcan be easily specified, like a plane boundary layer or an aeroplane wing.

57

Page 58: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

Two-equation models Two-equation turbulence models introduce an additional PDE for themissing lengthscale. Since two-equation models do not require any parameter (like l) from previousknowledge of the system, the two-equation models are often referred to as being complete.

The most popular two-equation turbulence models are variations of the k − ε model and thek − ω model. k − ε models solve one PDE for k and an additional for ε. Likewise, k − ω modelssolve PDEs for k and ω, where ω ≈ ε/k. If k and ε are known then

l = k3/2

ε, tk = k

ε, u = l

tk=√k

where tk is a turbulent timescale. The turbulent viscosity is as before determined by

νT = const · u · l = const · k2

ε.

A transport equation for ε can be derived exactly from the Navier-Stokes equations. Theresulting equation contains many new unknowns and here we will not go into detail. Instead wewill here simply report the entire and closed k − ε model with its most common model ’constants’

∂ui∂t

+ uj∂ui∂xj

= ∂

∂xj

[(ν + νT )

(∂ui∂xj

+ ∂uj∂xi

)]− 1ρ

∂p+ 23k

∂xi,

∂k

∂t+ uj

∂k

∂xj= ∂

∂xj

[(ν + νT

σk

)∂k

∂xj

]+ P − ε,

∂ε

∂t+ uj

∂ε

∂xj= ∂

∂xj

[(ν + νT

σε

)∂ε

∂xj

]+ Cε1

P ε

k− Cε2

ε2

k, (186)

∂ui∂xi

= 0,

νT = Cµk2

ε,

Cµ = 0.09, Cε1 = 1.44, Cε2 = 1.92, σε = 1.3, σk = 1.

Unfortunately the model ’constants’ are known to vary from flow to flow and thus often in need oftuning for optimal performance. Nevertheless, two-equation models are complete and the k − εmodel is very much in use in industry for a wide range of flows.

There is a great number of different RANS turbulence models. Some are listed on the page forNASA’s Turbulence Modelling Resources [4] and the wiki [5] for turbulence modeling.

Boundary conditions The average statistics in a turbulent flow have sharp gradients in thenear vicinity of a wall. To properly resolve all statistics the location of the first inner computationalnode needs to be at approximately y+ = 1. This restriction is quite demanding in terms of gridresolution, especially at high Reynolds number. The standard k − ε model, Eq. (186), is not veryaccurate close to walls and many modifications exist to handle this problem. Two main approachesare(1) Do not resolve the flow further than approximately y+ = 30 and use wall functions to

prescribe boundary conditions inside the wall instead of at the wall.

(2) Resolve the flow completely (all the way up to y+ = 1) and introduce damping functions.The wall functions are based on the log-law

u+ = 1κ

ln y+ +B, (187)

which is known to be in close agreement with experiments of regular boundary layers for a rangeof Reynolds numbers. If the first inner node (the first node on the inside of the wall) is located atyp, then the velocity can be computed as

up

u∗= 1κ

ln ypu∗

ν+B, (188)

58

Page 59: Chapter 3 - Solutions of the Newtonian viscous-flow equa- tions

References[1] http://fenicsproject.org/documentation/tutorial.

[2] http://fenicsproject.org/documentation/tutorial/fundamentals.html#the-poisson-equation.

[3] http://mathworld.wolfram.com/ModifiedBesselDifferentialEquation.html.

[4] http://turbmodels.larc.nasa.gov/ Langley Research Center Turbulence Modeling Resource.

[5] http://www.cfd-online.com/wiki/Turbulence_Modeling.

[6] Erwin Kreyszig. Advanced Engineering mathematics. Wiley, 8 edition, 1999.

[7] Frank M. White. Viscous Fluid Flow. McGraw-Hill, third edition, 2006.

59