You are on page 1of 43

Lecture 1:

1.4 What is CFD?


CFD is the science of predicting the behavior of fluid flows by solving the governing
equations (Navier-Stokes) of their flow numerically. in brief, it is the process of
converting the continuous partial differential equations into algebraic equations and
then solving them with a computer.

1.5 Why perform CFD?


Option 1:
option 2:
Option 3:

build/test many designs on the track


build many designs, test in a wind tunnel, and test some on the track
CAD designs, tested in CFD, then wind tunnel, then track

Navier-Stokes Equations conservation of momentum, energy, and continuity

m
= m
out vA

dM
dm d ( mv )
= F F=ma, m=mv ,
=
dt
dt
dt
V + h= QW

Lecture 2: Governing Equations of


Fluid Motion
2.1 Brief Calculus Review
= ( x , y , z , t )

chain rule given a function

d=

dx+
dy+
dz+
dt
x
y
z
t

we can then solve for the derivative we are interested in, for example if we wanted

t , we divide both sides by

dt

d dx dy dz
=
+
+
+
dt x dt y dt z dt t

Divergence operator

^ ^ ^
i+
j+
k
x y x

i.e. given a vector

^ ^j+ w k^

V =u i+v

u v w
(
V )=
V= +
+
x y z

2.2 substantial derivative


the substantial derivative is an important concept in aerodynamics. Consider a fluid
property that is independent of the amount of matter (i.e. mass of fluid) (aka
intensive)
if is a fluid property independent of mass but varies in space and time then:

= ( x , y , x , t )
the substantial derivative of an intensive fluid property is defined as the time rate
of change following a moving fluid element

d dx dy dz
=
+
+
+
dt t x
dt y
dt z
dt
u

=
+
u+
v+
w
dt t x
y
z
D
D
=
+ V ( )
=
+(
V )
Dt t
Dt t

in other words the substantial derivative denoted by

D
Dt

is nothing more than the

total derivative

D
DT
T
)T
= +(
V )
=
+(
V

Dt t
Dt
t

local
derivative

convective
derivative

2.3 continuity equation


in developing the continuity equation we follow three steps:
1. state the fundamental physical principle
2. apply it to a suitable model of the flow
3. obtain equations to satisfy the principle
For continuity:
1. mass is conserved
2. we have 4 different ways of modelling the flow:
a. finite volume fixed in space with fluid moving through it
b. finite control volume moving with the fluid so that the fluid particles
are always in the same CV
c. infinitesimal fluid element fixed in space with the fluid moving in it
(models that dont move with the fluid result in a form of the equation
known as conservation equations
d. infinitesimal fluid element moving along streamline with velocity V,
moving with the fluid (non-conservation form)

Lecture 3: Derivation of the


Governing equations (continued)
3.1 review of the substantial derivative
for temperature, our intensive fluid property we have

[ 3.1 ] DT = T + V
T

Dt

local
derivative

convective
derivative

3.2 Finite Volume, Fixed in space


as we have shown last lecture, this is nothing more than the total derivative with
respect to time (using the chain rule). physically, [3.1] states that the fluid element
temperature is changing because the temperature itself may be fluctuating with
time (local derivative) AND because the fluid is moving to another point in the flow
field where the temperature is different (convective derivative)

net mass flows out timerate of decrease


of CV through CS = of massinside CV
[ LS]
[ RS]
perpendicular
V
)= ( Area of Surface ) ( surface )
mass flow rate ( m

d ^s points normal
vnds= v d ^s (ds by convention)
therefore, if flow exits,

v d s^

is positive, and if flow is entering, then it is negative

net mass flow will be the summation of S:

d s^
m=
V
s

for the right side consider a very small element inside out CV,

dm=d V m= d V
V

dv

its mass will be:

m=

d
dt

{ }

[ 3.2 ]

d V

d V + V d ^s =0
V

3.3 continuity Moving CV


for this flow model, where our CV is moving with the fluid and mass is neither
created nor destroyed we can say that the mass of the CV does not change with
time:

[ 3.3 ] D

Dt

[ ]

d V =0

3.4 Continuity Fixed infinitesimally small element


net mass flow out of d V

= time rate of decrease in mass inside

mass ( u ) dydz

mass out = u+

( u )
dx dydz
x

in the x-direction the net mass flow out is:

u+

( u )
( u )
dx dydz [ ( u ) dydz ] =
dxdydz
x
x

similarly for y-direction:

( v )
dxdydz
y
and z-direction:

( w )
dxdydz
z
therefore net mass flow through the element:

[ LS ] =

( u ) ( v ) ( w )
+
+
d xdydz
x
y
z

dV

[ RS ] =


dxdydz
t

LS=RS

[ 3.4 ]

+ (
V)
t

3.5 continuity moving infinitesimally small element


since out small element is moving with the flow (mass inside is fixed) then the rate
of change of mass inside the element is zero

( V )
d

( V )= V
+
=
dt
t
t

( V )
[ 3.5 ] + 1
=0
t

Lecture 4: governing equations


continued
4.1 momentum equation
Physical principle:

F=ma

using an infinitesimally small moving element


body forces act at a distance (gravity, magnetism)
surface forces act directly on the surface of the element (pressures, shear)
convention:

ij

denotes a stress in j direction normal to I axis.

the net surface for in the x direction is then:

[ (

p p+

)]

[(

P
dx dydz + xx + xx dx xx + +++
x
x

[
]

F x=

P xx yx zx
+
+
+
dxdydz + f x dxdydz
x x y z
body forces

surface forces

[ 4.1 ]

Du P xx yx zx
=
+
+
+
+ Fx
Dt
x
x y z

Lecture 5: Governing Equations


Continued
5.1 Brief vector algebra review
Recall the vector identity for the divergence of the product of a scalar times a
vector:

)=u (
) u
( uV
V )+ ( V

5.2 The momentum equation continued


From last lecture we had:

Du P xx yx zx
=
+
+
+
+ f x
Dt
x
x y z

Du
du
=
V u
Dt
dt

Also:

( u )
u

=
+u
t
t
t

u ( u )

=
u
t
t
t

Recall our vector identity:

(
V ) u= ( u
V )u (
V)

Du ( u )

)
=
u
u (
V ) + ( u V
Dt
t
t

( u )

u
+(
V ) + ( u
V)
t

Du ( u )
)
=
+ ( u V
Dt
t

Going back to our x-direction equation from lecture 4, and substituting for the left
hand side:

( u )
P xx yx zx
+ ( u
V )=
+
+
+
+ f x
t
x
x y z

Isaac Newton stated that the sheer stress in a fluid is proportional to the time rate
of strain (i.e. velocity gradients). Such fluids are known as Newtonian fluids. Fluids
that are not proportional are known as non-Newtonian fluids (blood, shampoo, ink,
some salad dressings). Most fluids in our application are Newtonian. For Newtonian
fluids we have the Stokes equations (1845)

xx = ( ) +2

u
x

xy =

yy = ( )+2

v
y

xz =

zz = ( )+ 2

w
z

yz=

[
[
[

]
]
]

v u
+
= yx
x y
u w
+
= zx
x x
w v
+
= zy
y z

Where is the molecular viscosity coefficient and is the second viscosity


coefficient.
Stokes hypothesis is that:

Lecture 6: governing equations


continued
6.1: the momentum equations
if we sub in the equations for

ij

into our momentum equation from the last

lecture, we can obtain the momentum equation in terms of our flow field variables:
in the x direction:

( u ) ( u 2) ( uv ) ( uw )
P
u

w
+
+
+
=
+
( )+ 2
+
( )+ 2
+
( )+ 2
+p
t
x
y
z
x x
x y
y z
z

] [

] [

6.2 Energy Equations:


we start by stating our physical principle and applying. here we use the
infinitesimally small fluid element moving with the flow (if you recall it yields the
differential non conservative form)
physical principle: energy is conserved, apply this to a fluid element moving with
the flow

A=B+C

rate of change of energy = net flux of heat + rate of work done on element + surface forces
inside fluid element
into element
due
work in simple terms is a force acting on an object to move it a certain distance.

W =Fd

=F distance =FV
W
time

net work done by pressure in the x-direction:

[ (

uP uP+

)]

( uP )
( uP )
dx dydz=
dxdydz
x
x

similarly for sheer stress:

[(

u yx +

u yx ) dy u yx dxdz =
(
( u yx ) dxdydz
y
y

same for normal stress.


considering all forces in the x direction:

( uP ) ( u xx ) ( u yx ) ( u zx )
+
+
+
dxdydz=C x
x
x
y
z

Lecture 7: Energy Equation


Continued
the net rate of work done on the moving fluid element is the sum of the
contributions in all 3 directions including body forces:

[(

C=

( uP ) ( vP ) ( ) ( u xx ) ( u yx ) ( u zx ) ( v xy ) ( v yy ) ( v zy ) ( w xz ) ( w yz ) ( w

+
+
+
+
+
+
+
+
+
x
y
z
x
y
z
x
y
z
x
y

B term is due to:


1. volumtric heating such as absorbtion/emmision of radiations
2. heat transfer across the element surfaces due to thermal gradints (thermal
condictivity)
we define

as the rate of volumetric heat addition per unit mass

Volume heating= q dxdydz

qx

where

is defined as heat transferred by thermal

conduction per unit mass per area (heat flux in x)


net heat transfer due to conduciton is then:

[ (

q x q x +

)]

q x
q x
dx dydz=
dxdydz
x
x

sum of all the componants will yeild:

heat of fluid element = q x + q y + q z dxdydz


by thermal conduction
x y z

recall fourriers law:

q x =k

T
T
, q y =k
, etc
x
y

where k is the thermal conductivity


recall we are after the net flux of heat:

B= q +

( ) ( ) ( )]

T
k
+
k
+
k
dxdydz
x x y y z z

lastly, the A term has 2 contributions:


1. internal energy due to random molecular motion

2. Newtonian kinematic energy due to translational motion of the fluid element

1
v2
2

since we are following the fluid element, the time rate of change is the substantial
derivative

A=

D
V2
e+
dxdydz
Dt
2

Lecture 8: towards solving the


governing equations of the flow
8.1 review of some mathematical concepts
Substantial derivative (flow of fluid variable )

D
=
+
V time rate of change of
Dt
t
local

convective

Divergent vector identity where

is a scalar and

is a vector

( a
F ) (a
F )+ (
F a )
Divergent Theorem from vector calculus (Gauss Theorem) a surface integral can be
expressed as a volume integral:

F d S = F d V
S

8.2 The physical meaning of the divergence of velocity


(
V)
Consider a CV moving with the fluid
and the CV is always made up of the
same fluid particles as it moves with
the flow; hence its mass is fixed,
invariant with time. However, its
volume (V) and control Surface (S) are
changing with time as it moves to
different regions of the flow where
different values of exist. I.e. its
volume of fixed mass is constantly
increasing or decreasing its volume
and changing shape.

Consider an infinitesimal element of the surface (ds) , moving at local velocity

then:

change volume V =[
(
V t ) n^ ] ds

altitude

base
area

V t d s
Over the increment

the total change in volum is equal to the summation of all

over the control surface; i.e. the surface integral:

t ) d s
d V = ( V
s

If we divide by

the result is physically the rate of change of the moving

control volume

DV
d s
= V
Dt
s
And using the divergence theorem:

DV

= (
V ) dV
Dt
V
If we imagine that the CV is shrunk to an infinitesimally small volume, with a volume

(still moving with the flow) then:

D( V )
) d V

= ( V
Dt
V
If

V
V

is small enough such that

is essentially the same through ought

then:

D ( V )
) V
=( V
Dt
1 D ( V )
(
V )=
V Dt
Therefore,

is physically the time rate of change of the volume of the moving

fluid per unit volume?

8.3 manipulation of the different forms of the governing


equations
Recall from lecture 3, for continuity:
Conservative integral form:

[ 3.2 ]

d V + V ds=0
t V
s

Non-conservative integral form:

[ 3.3 ] D

Dt

[ ]

d V =0

Conservative differential form

[ 3.4 ]

+ (
V )=0
t

Non-conservative differential form

[ 3.5 ]

D
+
V =0
Dt

Since all four equations were derived to solve the same physical principle, they are
therefore equal and can be converted from one to another with some manipulation:

E.g. converting [3.2] to [3.4]

d V + V ds=0
t V
s
Density is fixed in space so we can move the derivative inside:

t d V + V ds=0
V

Using gauss theorem:

V ds= ( V ) d V
s

Then we have:

+(
V ) d V =0
t

This integral can only be zero if the integrand is zero at every point, therefore:

+
V =0
t

E.g. converting [3.4] to [3.5]


Employ the vector identity:

(
V ) (
V )+ (
V )

Subbing into [3.4] we get:

+(
V ) +(
V )=0
t

D
Dt

D
=0
+ V
Dt

Lecture 9: solving the governing


equations and fundamentals of
numerical methods
Governing equations and Figures are posted on CU Learn

9.1 Forms of GE particularly suited for CFD


Examine the conservation form of each of the GEs. We note that they all have the
same generic form given by:

[ 9.1 ]

u F G H
+
+
+
=J
t x y z

Equation [9.1] can represent the entire system of GEs in conservation form if u, F, G,
H, and J are interpreted as column vectors then:

[ ][

2
u + P xx
u
v
vu xy
u=
, F=
w
wu xz
2
V
V2
T
e+

e
+
u
+ Pu
2
2
x

The rest is available on CuLearn

9.2 Overview of Discretization Schemes


We will now discuss hoe the GEs can be solved numerically. The 1 st step is to define
the appropriate equation (e.g. compressible/incompressible viscid/inviscid
steady/transient) once the equations have been selected one has to decide how to
discretize the equations.
Discretization is the process where the continuous differential equations are
approximated by a system of algebraic equations for the variables at some discrete
locations in tie and space. There are many approaches, but the most common for
CFD applications are Finite difference methods, finite volume method, and finite
element method.

9.3 finite difference method

FDM is the oldest method. Good for simple geometries where it is easiest to
implement. The starting point is the differential conservative form. The solution is
governed by a grid with nodes spaced at a finite distance apart. At each point the
DE is approximated by replacing the PDs with approximations, which all functions
are terms in the neighbouring grid nodes. The result is one algebraic equation per
grid point and a certain number of neighbouring grid points appearing as unknowns.
Taylor series expansion is commonly used to obtain the approximations of the
derivatives. Examples will be done in class.

Lecture 9 Continued
9.4 Finite Volume Methods
The starting point for FVM is the integral form of the GE. The domain is divided into
a finite number of continuous CVs. the CV can be polyhedral, tetrahedral, or
hexahedral. For each CV the variable values are approximated at a computational
node at the centroid of the CV (cell centered method) or at the nodes of the CV
(node centered FV). Interpolation is then used to express values at the CV surfaces.
Advantages of the FV method are that it is suitable to any fluid or grid, so that
complicated geometries can be accommodated. A disadvantage is that FV
discretization requires higher than second order systems which are harder to
develop in 3D. Thus for a given grid it can have reduced accuracy.

9.5 Finite Element Method


Similar to FV method, however the variation of a flow variable within an element is
approximated with a polynomial (instead of node-centered and cell-centered
methods). This is also good for complex geometries, but the resulting equations are
complicated and can take a while to solve.

9.6 computational grids in CFD


The three methods discussed all sub-divide the solution domain into discrete
locations in space through a form of a computational grid. The computational grid
has arguable the largest effect on the accuracy of the CFD simulation and improves
the convergence rate. There are several parameters that are used to determine the
quality of a grid for CFD. Some of the most important ones:
Cell Volume:
small enough so
region of interest to the flow

the volume of the grid cell. The volume should be


that many cells are contained in the

Orthogonality of grid lines:


greatest

how orthogonal the grid lines are to the direction of


change in the flow.

Cell aspect ratio:


concern for
large AR implies highly

the ration of a cells height to width ratio. Of more


triangular faced elements (tetrahedral). A
skewed cells.

Skewedness of Cells:
highly skewed
results in errors when the

how large the angle is between the cell faces. In


cells, there will be a small angle, which
sine/cosines are taken.

Rate of change of cell volume:

change in volume of one cell to another.

9.6.1 Structured grids


Are composed of congruent parallelograms (2D) or parallel pipes (3D). Each cell can
be addressed by an index (i, j, k) each cell has co-ordinates (dx, dy, dz) representing
grid spacing.

9.6.2 Unstructured Grids


an unstructured grid is constructed from simple shapes: triangles, tetrahedral (3D),
or polyhedral. rather than nodes being identified by a set of indices, unstructured
grids use a list of connectivity that specifies the way a given set of indices make up
an element. n unstructured grid provides maximum flexibility and complicated
geometry can be mapped easily with an unstructured grid, unstructured grids are
typically more complicated to solve due to the connectivity matrix that needs to be
resolved.

Lecture 10: Properties of numerical


Methods
whatever discretization method is chosen it must possess certain properties to
ensure the solution is accurate:

10.1 consistency
the difference between the exact continuous PDE and the approximate discrete
equation is termed the truncation error. the magnitude of error is a function of the
grid spacing. for a method to be consistent the error must approach zero as the grid
spacing heads to zero

10.2 order of accuracy


if the discrete approximation for the most important discretized equation is
proportional to

( x )n or ( t )n , we call the method an nth order approximation

10.3 stability
a discretization scheme is table if it does not magnify small errors in numerical
calculations. magnification of errors will cause the solution to diverge.

10.4 convergence
a numerical method is convergent if the difference in the solution of the discretized
equation and the exact solution tends to zero as grid spacing goes to zero.
convergence can be tested by refining a mesh.

10.5 conservation
as the equations that are solved are conservation laws, the numerical solution
should ensure that conservation is respected. conservation places a constraint on
the solution error. because if mass, momentum, and energy are conserved within
the solution domain errors can improperly redistribute the qualities only.

10.6 boundedness
the solution to the DE must lie within proper bounds. physically non-negative
quantities (pressure, density) must always be positive. the ability of the
discretization scheme to respect these bounds is termed boundedness

10.7 accuracy
The solutions of the DE are only approximate so an amount of error is associated
with any numerical method

Lecture 11: Physical Behavior of


PDE
There are 2 main types of behavior: equilibrium problems and marching problems.

11.1 Equilibrium Problems


These are steady state problems in which the solution to the PDE is desired in a
closed domain that is subject to a set of boundary conditions.
Key property:
the

Must reach steady state and be that a disturbance somewhere in


solution changes the behavior somewhere else.

11.2 Marching Problems


in marching problems, the solution for the PDE is fixed by a set of initial boundary
conditions, and the time dependant solutions is obtained by marching forward in
time. In these problems the solution is transient.
E.g. moving waves or unsteady equations, disturbances may not be transmitted
everywhere in the flow field, but can only influence a particular region, called
domain of dependence

11.3 Classification of PDE


To identify whether a PDE is an equilibrium equation or marching problem, we need
to know how the information is transmitted within the problem space, generally the
PDE. We do this by classifying them into different types.

2
2
2

+b
+c
+d
+e
+f +g=0
2
2

xdy

x
y
x
dy

Where a, b, c, d, e, f, and g may be constants or functions of (x, y) i.e. a linear


equation.
The behavior of the PDE is largely governed by the second derivative terms, if we
re-arrange the equation we get:

2
2
2

+b
+c
= d
+e
+ f + g =H
2
2

xdy

x
y
x
dy

The transmission of info occurs along lines called characteristic lines or simple
characteristics.
the equations for the characteristic curves are given by:

dy b b 24 ac
=
dx
2a
We can see that

( b2 4 ac )

plays a major role in the nature and existence of the

characteristics. we can distinguish three cases:

( b2 4 ac ) >0

2 real characteristics, Hyperbolic - marching

( b2 4 ac ) =0

1 real characteristic, Parabolic - marching

( b2 4 ac ) <0

no real characteristics, elliptic equilibrium

Example 1:
Consider the following PDE:

2 2
+ 2 =0
2
x y

What type of PDE is the above at


Solution:

a= y ,b=0, c=1
D=( b24 ac )
D=04 ( y )(1)

( x , y )=(1,1) ?

D=4 y
At

( 1,1 ) , D=4 eppiliptic


D<0 therefore equilibrium problem

11.4 Application of Fluid Flow Problem


Generally the NS governing equations are elliptic for steady flows and parabolic for
unsteady flow:
Flow Type
Viscous
Inviscid
Thin Shear Layer

Steady
Elliptic
M<1 elliptic
M>1 hyperbolic
parabolic

Unsteady
Parabolic
Hyperbolic
parabolic

Example 2:
The equation that governs the potential function in steady, inviscid, isentropic
flow past a slender body with a free stream Mach number
2

( 1M )


+
=0
x2 d y2

verify the PDE is elliptic when

M >1

A=( 1M ) , B=0, C=1


D=4 (1M )
at
at

M >1 hyperbolic
M <1 elliptic

is:

Lecture 13: the Finite Element


Method
13.1 basic concept of the finite difference
all conservation equations have a similar structure and can be regarded as special
cases of a generic transport equation

( u j )

+
=

+q
t
x j
xj xj

where is the diffusivity of and we assume that ,

u j , ,q

are known. this

may not be true as the velocity field may not have been computed yet and the
properties of the fluid may depend on the temperature or velocity field. but as we
will see, the iterative schemes used to solve the equations assume that is the
only unknown and fix all other variable at their last known value (calculated at the
previous iteration)
the first step is to discretize the domains. If we use a structured gird for 1D:

the first derivative


(x) at that point

( x )

at a point is the slope of the tangent to the curve of

( )

xi

= lim

x 0

( xi + x ) ( x i )
x

13.2 generating the difference equations through Taylor


series expansion

13.2.1 first derivative


(x)

recall from calculus that a continuous differential equation

can be expressed

as a Taylor series:
2

+ ( xx i ) n
( xx i ) 2 ( xxi ) 3

( x )= ( x i ) + ( xx i )
+
+
+...

+
x i
2!
3!
n!
x2 i
x3 i
xn

( )

( )

( )

where H denotes higher order terms equally by replacing


obtain an expression for at

( )

with

( x+1 ) we can

x i+1

( xi +1x i ) 2

( xi +1 )= ( x i ) + ( x i+1x i )
+
+
2
x i
2!
x i

( )

similar expressions can be found for

( )
x i1

and

x i2 , etc...

the above equations can be re-arranged to solve for


2

( x )

i x i+1 xi 2
( x i+1x i ) 3

= i+1
+
+
+ H [ Forward ]
2
3
x i x i+1x i
2
2
x i
x i

( )

if we write TD for

( )

(x i1)

( )

we get an expression for

( x )

in terms of

x i1 ,x i

i1 xi x i1 2
( x ix i1 ) 3

= i
+
+
+ H [backwards]
2
3
x i x ix i1
2
2
x i
x i

( )

( )

and in terms of

x i+1

and

( )

x i1

2
2
i+1 i1 ( x i+1x i ) ( xi x i1 ) 2

=
+
+ H [Centered ]
x i x i+1x i1
2 ( x i+1x i1 )
x2 i

( )

( )

Lecture 13 Continued
the equations for forward differencing scheme (FDS), BDS, and CDS are all exact if
all terms on the right hand side are retained. The higher order terms are multiplied
by the grid spacing to some power.
Assuming the distance between grid points is small, the higher order terms shall be
small and can be truncated to obtain the following approximations of the first
derivative:

i+1 i
(FDS)
i+1x i

( x ) x
i

i i1 ( BDS )
x i x ix i1

( )

i+1 i1
(CDS)
i+1x i1

( x ) x
i

the terms dropped from the right hand side constitute the truncation error. The
principal source of truncation error I the term with the lowest exponent (largest
number). If this term has an exponent m, the scheme is said to be m th order
accurate.
example:
what is the order accuracy of FDS BDS and CDS
FDS m=1 1st order dropped
1

( xi +1x i ) 2

( )
x2

m=1 1st

BDS

( xi xi1 ) 2
CDS

( )
x2

m=2 2nd
2

( xi +1x i ) ( x ix i1 ) 2
2 ( x i+ 1xi 1 )
x2

( )

13.2.2 Approximating second derivatives


the second term appears in the diffusion term of our general transport equation. To
estimate the second derivative it is convenient to consider that it is the slope of the
tangent of the curve representing the first derivative.

( )

2
x

(
(
x )
x )
=
i+1 /2

i1 /2

1
( x x )
2 i+1 i1

and similar for the others. the second derivative reduces to:

i+1 ( xi xi1 ) + i ( x i+1x i ) i ( x i+1x i1 )


2
1
x i
( x x )( x x )( x x )
2 i i1 i +1 i i +1 i1
2

( )

if the spacing between points in the grid is the same, and equal to

x , then the

equation becomes

2 i + i1
2
i+1
2
x i
( x )2

( )

13.3 Discretization Error for FDS


Since the discretization equations represent approximations to the original
differential equation the exact solution does not satisfy the FD equation]. For a
discretization of and grid spacing h the following is

= + dh
d

Where

represents the difference between the discretized and exact solution.

(I.e. error)

dh =

h 2 h
p

2 1

; p=

log ( 2 h 4 h )
log 2

Lecture 14: solution of linear


elliptic equations via FD
In general elliptic equations are steady state Laplace equations.

2 =0 is an

example of an elliptic equation. It governs the steady state conduction and inviscid
incompressible flow.
The equation we will consider in this lecture is the 2D steady state heat equation
that governs the steady state temperature distribution T in a solid

2 T 2 T
0 x 1
+ 2 =0
2
0 y1
x y
subject to the following Boundary Conditions:

T=

T 1 if x=0 T 3 if y=0
T 2 if x=1 T 4 if y=1

14.2 apply finite difference


Discretization begins by placing a grid in the solution domain with a spacing in the x
and y directions of x and y we then replace the derivative with the approximation
difference equations obtained in the previous lecture:

T i+1, j2 T i, j +T i1, j T i , j+12 T i , j +T i , j1


+
=0
( x )2
( y )2
This formula used 5 computational points In the grid, and the truncation error is of
the order
because

O[ ( x )2 , ( y )2 ] . Lets use x= y=0.1 , resulting in an 11x11 grid,


x= y

T i +1, j +T i1, j +T i , j1+T i , j+14 T i , j =0


In this example there are 81 interior points where T is unknown. For each unknown
we can write a differential equation so that our problem is one of solving the system
of differential equations for the 81 unknowns.
mathematically this can be expressed as

a11 T 1+ a12 T 2+ +a1 n T n=C1


a21 T 1+ a22 T 2 ++a 2 n T n=C 2

an 1 T 1 +a n2 T 2+ +ann T n =Cn
Or in matrix form:

[ A ] T =C

14.3.1 Direct Methods


Cramers Rule one of the most elementary for solving an algebraic system of
equations but very time consuming

(n+1)!

operations where n is the number of

unknowns; Not practical for CFD.


Gaussian Elimination very useful/efficient.

14.3.2 Iterative Methods


one guesses the solution, and then uses the equation to systematically improve it

Gaussian-Seidel
Jacobi

Lecture 15: Solution of linear


parabolic equations via Finite
Differences
15.1 Introduction
Recall from previous lectures that parabolic equations are a group of equilibrium
equations where one real characteristic exists and the domain of
dependence/region of influence is limited by time. Hence parabolic equations are
general time-dependant equations. We will consider the time dependent 1-D heat
equation:

T
2 T
[ 15.1 ] = 2
t
x

subject to:

BC T (0, t)=T (1, t)=1


IC T ( x , 0 )=f (x)

This equation can be used to model in a rudimentary fashion the parabolic


boundary layer equations. conventionally there is an exact analytical solution:

[ 15.2 ] T ( x ,t )= A n e k t sin ( kx )
n =1

where:
1

A n=2 f ( x ) sin ( kx ) dx
0

k =n
comparing the finite difference methods to this exact solution provides us with a
measure of the accuracy of the method used for our discretization.

15.2 Finite Difference applied to parabolic equations


15.2.1 Explicit methods
Simple explicit method - uses a one-sided difference for the temporal derivative
in [15.1] and central difference for the spatial difference.

n+1

T j T j T j +12T j +T j1
=
2
t
( x)
Here, j is used a spatial index in the x-direction and n is used as the temporal index
in the t-direction. The subscript is used to denote the time iteration. The simple
explicit method has an order of accuracy of

O[ t , ( x )2 ]

(1st order accurate). The

scheme is stable whenever:

1
t
0 r where ,r =
2
( x )2

Dufort-Frankel Method:
This method uses information at two previous time steps to achieve second order
accuracy both in time and space with an error of

O[ ( t ) , ( x ) ]

( 1+2 r )=T n1
T n+1
+2 ( T nj+1T n1
+T nj1 )
j
j
j
Explicit methods (like the presented above), march the solution forward in the
temporal direction from initial data line, one point at a time.
Note: For parabolic equations this may be problematic
15.2.2 Implicit methods
Simple implicit method:
The simplest implicit scheme for solving the 1-D heat equation:
n +1

n +1

n+1

T j T j
( T j+1 2T j +T j 1 )
=
t
( x )2
n+1

This scheme is

O [ ( t )2 , ( x )2 ]

and is unconditionally (i.e. always) stable.

Gant - Nicholson Method:


n +1
n
n
n
n
T n+1
( T nj+1+1T n+1
j +T j1) + ( T j1T j +T j1 )
j T j
0
=
t
2 ( x )2

This scheme makes use of trapezoidal differencing to achieve 2 nd order accuracy


with error

O[ ( t )2 , ( x )2 ] .

15.2.3 Methods for multidimensional parabolic equations

The 2D heat equation is given by:

T
2 T 2 T
=
+
t
x2 y2

if we apply the simple explicit method:

n
T n+1
T n 2 T i , j +T ni1, j T ni+1, j2 T i , j +T ni1, j
j T j
= i+1, j
+
t
( x )2
( y )2

such a scheme is stable if:

1
1
1
+

2
2
2
(x) ( y)

The stability condition reduces to

1
2

and makes the explicit method even more

impractical for multi-dimensional parabolic equations.


The implicit schemes are stable but yield a system of linear equations that do not
have tridiagonal form and are computationally expensive to solve.

(see supplementary notes for alternating direction implicit)

Lecture 16: solution of linear


hyperbolic equations via FD
methods
16.1 review of hyperbolic equations
Recall from previous lectures that hyperbolic equations have 2 characteristics. The
traditional or classic hyperbolic equation is the 1D wave equation:

[ 16.1 ]

2 2 2
=c
2
2
t
x

For simplicity we will instead use a first order equation with similar properties:

[ 16.2 ]

u
u
+c
=0 c >0
t
x

this linear hyperbolic equation describes a wave propagating in the x-direction with
a velocity c. it can be used in rudimentary fashion to model non-linear equations
governing inviscid flow. for the remainder of the lecture we will refer to [16.2] as the
wave equation.

16.2 1st order accurate explicit scheme


Euler explicit method uses FDS for the temporal derivative and CDS for the spatial
derivative.

1
( st order )
n+1
n
n
u j u j
u un
2
+c j+1 j1 =0 error :O [ t , ( x ) ]
t
2x
Unfortunately this scheme is unconditionally unstable and thus is worthless or
hyperbolic equations.
First order upwind method
Lets modify the Euler explicit method by using a backwards differencing
approximation, for the spatial derivative, assuming the wave equation is positive:
n
u n+1
u nj unj1
j u j
+c
=0 c> 0
t
x

This scheme is 1st order accurate

O [ ( t )2 , ( x )2 ]

A Von-Neumann stability analysis shows that this method is stable provided:

0 1 =c

T
x

Lax-method
The Euler explicit method can be made stable by replacing
term

(u nj+1 +unj1 )/2

unj

with an average

n
n
u n+1
un u n
j ( u j +1+ u j1 ) /2
+c j+1 j1 =0
t
2x

This explicit 1st order

O [ ( t )2 , ( x )2 /2 ]

and is stable if

|| 1

16.3 2nd order accurate explicit schemes


leap frog method
n1
u n+1
unj+1u nj1
j u j
+c
=0
2 t
2 x

2nd order accurate

O [ ( t )2 , ( x )2 ]

and is stable for

|| 1

McCormack method
previous schemes were all one step. this method is 2-step, where a value of
is predicted in the 1st step and corrected in the 2nd
the McCormack method is called a predictor-corrector scheme
Predictor:

1=un ( un un )
un+
j
n
j +1
j

Corrector:
n+ 1

uj =

1 n n+1
n+1
n+1
u + u ( u j u j1 )
2 j j

2nd order accurate

O [ ( t )2 , ( x )2 ]

and is stable for

2nd order upwind method (similar to McCormack)


predictor:

u j =un ( u j u j1 )
n+ 1

Corrector:
1
un+
j =

1 n n+1
un+1
) ( un2 un un )
u + u ( un+1
j
j1
j
j 1
j2
2 j j

Combining the two:

|| 1

1
un+
j

1
1
n
n
n
un+
( 1 ) ( unj 2 unj1unj 2 )
j =u j ( u j u j1 ) +
2
Stable for

02

Lecture 17: Finite Volume Methods


1:
the integral form of the conservation equation is the basis for the finite volume
method.

net rate of decrease of


due

t d V dt + n ( u ) dA d t across the boundaries = n ( grad ( ) ) dA dt


t
CV
t A
t A

rate of increase of
the CV

rate of increase of due diffusion across the boundaries

17.1 FVM for 1D steady state diffusion


the equation for steady state diffusion of a property in 1D is given by:

dA + S d V =0
d
dx

CV

17.2 Spatial Grid


To solve this equation, the solution domain is sub-divided into a finite number of
small control volumes CV, by a grid which, in contrast to the finite difference
method Defines the CV boundaries, not the computational nodes. there are two
approaches:
One: defines the location of the nodes then constrains the CV around the
nodes so that the boundaries of the CV are centered between nodes.

+ S d

t CV

net rate
creationof
intern
sourc

Two: defines the locations of the CV and assigns the computational nodes to
the centroids of the CVs
the advantage of the first approach is that the centered difference approximations
of derivatives at CV faces are more accurate because the faces are midway
between the points.
the advantage of the second approach is that the nodal value represents the mean
over the entire CV to a higher accuracy because it is located at the centroid of the
CV. The second variant is more common and will be used here.

17.3 Discretization

typical CV notation used for a 1D grid


a general node is denoted by P. its neighbours to the east and west faces of the cv
are denoted by lower case e and w respectively. the distances between nodes W
and P and P and E are denoted

x PE

and

. similarly the distances between

the east and west faces of the CV and pint P are denoted
respectively. the control volume width is

s x

and

s x pe

within the notation defined we can derive the following:

d
d
dA+ S d V =( A ) ( A )
d
dx
dx
dx
A

CV

+ S V

where A is the cross sectional area of the control volume of the CV. this discretized
equation has clear physical meaning: it states that the diffusive flux of leaving
east minus that entering the west is equal to the generation of . in other words, it
is a balance equation for within the CV.
the fact that the discretized equation has this built in physical meaning is a very
attractive feature of FVM.

Lecture 17 Continued FVM II


in order to derive a useful expression for the above equation, expressions for the

d
dx

diffusion coefficient and the gradient

at the east/west faces are required.

Following the established notation, values of and are evaluated and defined at
the node locations P W E etc. to approximate the fluxes through the CV faces we
must assume something about the distribution of and between nodal points. A
common approximation is that these properties vary linearly between nodes.
Assuming a uniform grid, the face values of and are therefore approximated by:

w=

W + P
+
e= E p
2
2

and the diffusive flux terms are:

e p
PW

= A e e
A
= Aw w
x e
x PE
x w
x

)(

the source term may be approximated by:

S V =Su + S p P

subbing into the equation:

Ae e

e p
P W
Aw w
+ ( Su + S p P )=0
x PE
x

re-arranging:

w
e
A e + w A w S P P=
A w w +
A S
x PE
x PW
x PW
x PE e e u

) (

) (

this equation can be further simplified by defining the coeficients of

E ,w,P :
P P = W w + e e + S u [canonical FVM ]

PWE

as

e=

Ae w = w A w p= w + e S P
x PE
x PW

we can eventually express the equation for the canonical FVM as:

p p = nb nb + Su
nb

where the subscript nb denoted the cell neighbours W and E

17.4 Discussion points


the above equation guarantees conservation over the indicidual CV. this is an
attractive advantage of FVM that finite diferenece doesnt have

17.5 solution of the discretized equation


the discrete algebraic equation represented by [17.3] results in a system of
equations that must be solved to obtain discrete values of and each CV in the
solution domain. there are discrete and iterative methods (in supplemental notes)

Lecture 18: Numerical Stability


Von-Neumann stability analysis:
the starting point for our analysis is the explicit approximation to the 1D heat
equation.
n +1

[ 18.1 ]

T j T j u j+1 2u j +u j1
=
2
t
( x)

This can be re-written as:


n+1

[ 18.2 ] T j =T nj +

T n
u 2unj +u nj1 )
2 ( j+1
( x)

Let the exact solution of this equation be denoted D. this is the solution that would
be obtained using a computer with infinite accuracy. (i.e. an infinite number of
floating point digits). Similarly, denote the numerical solution using a real machine
with finite accuracy as N. if the analytical solution of the PDE is denoted A then:

[ 18.3 ] Discritization Error= AD

[ 18.4 ] Round off Error=ND


we can pose the question of stability as follows:
does the round off error grow as the computations are being performed?
if always yes unconditionally unstable
sometimes, depends on

x, y,z

conditionally stable

if always no unconditionally stable


we denote the round off error or just error by

then we can state:

[18.5] N =D+
this computed numerical solution must satisfy the difference equation [18.2].

t
n
n
[ 18.6 ] Dnj +1+ n+1
Dnj +1+ nj+1 2 Dnj 2 nj + D nj1+ nj1 ]
j =D j + j +
2[
x

if we subtract [18.6] from [18.2] we get:

[ 18.7 ] nj +1= nj +

t
+ nj+12 nj + nj1 ]
2[
x

Now lets represent


n

at

j =e

nj

by a sinusoid.

i ( x ) k

where:

i=1
k =the wave number(2 divided by wavelength)
by using this definition for

into [18.7] we get:

[ 18.8 ] n +1= nj [ 12 r ( 1cos ) ]


r=

t
, =kx
x2

if the round off error does not grow in time (stable) we can state:

| |

t n +1
1
tn

from equation [18.8] this means:

[ 18.9 ]|12r ( 1cos )| 1

( )|
|
14 r sin 2

1
2

G is the amplification factor.


so the amplification factor G, governs the stability of the scheme. for stability

|G|1

14 r sin 2

( 2 )|1

1
r for this scheme be stable
2
Von-Neumann can be conducted for other schemes:
simple Explicit Method:

G=1+2 r ( cos 1 )
simple implicit method:
1

G=[ 1+2 r (1cos ) ]

Crank-Nicholson method:

G=

1r ( 1cos )
1+r ( 1cos )

You might also like