Vous êtes sur la page 1sur 34

2.

29 Numerical Fluid Mechanics Fall 2011 Lecture 7


REVIEW of Lecture 6
Material covered in class: Differential forms of conservation laws
Material Derivative (substantial/total derivative)
Conservation of Mass
Differential Approach
Integral (volume) Approach
Use of Gauss Theorem
Incompressibility
Reynolds Transport Theorem
Conservation of Momentum (Cauchys Momentum equations)
The Navier-Stokes equations
Constitutive equations: Newtonian fluid
Navier-stokes, compressible and incompressible
Numerical Fluid Mechanics PFJ L Lecture 7,
2.29
1
1

Integral Conservation Law for a scalar |

d

}
|dV =

dt
CM
)
fixed fixed
Advective fluxes Other transports (diffusion, etc)
Sum of sources and
("convective" fluxes)
sinks terms (reactions, et
( . ) .
CV CS CS CV
d
dV v n dA q n dA s dV
dt
| |
| | + = +

} } } }



c)

CV,
fixed
s

,
v
Applying the Gauss Theorem, for any arbitrary CV gives:

c|
+ V.(|v) = V . q + s
ct
| |

q
|
For a common diffusive flux model (Ficks law, Fouriers law):

q
|
= V k |
c|
Conservative form
+ V. (|v) = V . ( kV|) + s
of the PDE ct
|
Numerical Fluid Mechanics PFJ L Lecture 7,
2.29
2
2

ong conservative
Strong-Conservative form
of the Navier-Stokes Equations (| v)
d


Cons. of Momentum:
vdV + v vn dA ( . ) = p ndA + t .ndA + gdV
} } } } }
CV CS CS CS CV
dt


=


Applying the Gauss Theorem gives:
= Vp + V.t + g dV
}
CV
( )

cv


For any arbitrary CV gives:
+ V.( vv) = V + V.t g p +
ct
With Newtonian fluid +incompressible +constant :
CV,
fixed
s

,
v

cv
Momentum:
+ V.(vv) = Vp + V
2
v + g
ct
q
|

Mass:
V = .v 0
Numerical Fluid Mechanics PFJ L
Lecture
7, 3
2.29
Equations are said to be in str form if all terms have the form of the divergence
of a vector or a tensor. For the i
th
Cartesian component, in the general Newtonian fluid case:
2
.( ) .
3
j j
i i
i i j i i i i
j i j
u u
v u
v v p e e e g x e
t x x x


| |
| |
c c
c c
+ V = V + + + |
|
|
|
c c c c
\ .
\ .

With Newtonian fluid only:
3


Navier-Stokes Equations:
For an Incompressible Fluid with constant viscosity
V(x,y,z) Fluid Velocity Field
Navier-Stokes Equation
Conservation of Mass
Dynamic Pressure P =P
actual
-gz
Kinematic viscosity v
Density
Hydrostatic Pressure:
- g z for z positive upward
Numerical Fluid Mechanics PFJ L Lecture 7,
2.29
4
4

V=
Incompressible Fluid
Pressure Equation
Navier-Stokes Equation
Conservation of Mass
Divergence of Navier-Stokes Equation
Dynamic Pressure Poisson Equation
V)= -

More general than Bernoulli Valid for unsteady and rotational flow
Numerical Fluid Mechanics PFJ L Lecture 7,
2.29
5
5

Incompressive Fluid
Vorticity Equation
Vorticity
Navier-Stokes Equation
curl of Navier-Stokes Equation
Numerical Fluid Mechanics PFJ L Lecture 7,
2.29
6
6

Inviscid Fluid Mechanics
Eulers Equation
Navier-Stokes Equation: incompressible, constant viscosity
If also inviscid fluid
Eulers Equations
Numerical Fluid Mechanics PFJ L Lecture 7,
2.29
7
7

Inviscid Fluid Mechanics
Bernoulli Theorems
Theorem 1
Theorem 2
Irrotational Flow, incompressible
Steady, Incompressible, inviscid,
no shaft work, no heat transfer
Flow Potential
Define
Introduce P
T
=
Thermodynamic
Navier-Stokes Equation
pressure
X
Along stream lines and vortex lines
Numerical Fluid Mechanics PFJ L Lecture 7,
2.29
8
8

Potential Flows
Integral Equations
Irrotational Flow
Flow Potential
Conservation of Mass
Laplace Equation
Mostly Potential Flows:
Only rotation occurs at
boundaries due to viscous terms
In 2D:
c| c|
Velocity potential : u = , v =
cx cy
c c
Stream function : u = , v =
cy cx
Since Laplace equation is linear, it can be solved by superposition of flows, called
panel methods
What distinguishes one flow from another are the boundary conditions and the
geometry: there are no intrinsic parameters in the Laplace equation
Numerical Fluid Mechanics PFJ L Lecture 7,
2.29
9
9

Potential Flow
Boundary Integral Equations
Greens Theorem
S
n
V
Greens Function
Homogeneous Solution
Boundary Integral Equation
Discretized Integral Equation
Linear System of Equations
Panel Methods
Numerical Fluid Mechanics PFJ L Lecture 7, 10
10
2.29

Systems of Linear Equations
Motivation and Plans
Direct Methods for solving Linear Equation Systems
Cramers Rule (and other methods for a small number of equations)
Gaussian Elimination
Numerical implementation
Numerical stability
Partial Pivoting
Equilibration
Full Pivoting
Multiple right hand sides, Computation count
LU factorization
Error Analysis for Linear Systems
Condition Number
Special Matrices: Tri-diagonal systems
Iterative Methods
Jacobis method
Gauss-Seidel iteration
2.29
Convergence
Numerical Fluid Mechanics PFJ L Lecture 7, 11
11


Motivations and Plans
Fundamental equations in engineering are conservation laws
(mass, momentum, energy, mass ratios/concentrations, etc)
Can be written as System Behavior (state variables) = forcing
Result of the discretized (volume or differential form) of the
Navier-Stokes equations (or most other differential equations):
System of (mostly coupled) algebraic equations which are linear or
nonlinear, depending on the nature of the continuous equations
Often, resulting matrices are sparse (e.g. banded and/or block matrices)
Lectures 3 and 4:
Methods for solving f(x)=0
or
f(x)=0
f =
(
( ), f x ( ) b To be used for systems of equations: f(x)=b, i.e: f x ( ),..., f x
)
=
1 2 n
Here we first deal with solving Linear Algebraic equations:
Ax = b or AX = B
Numerical Fluid Mechanics PFJ L Lecture 7, 12
12
2.29

Motivations and Plans
Above 75% of engineering/scientific problems involve
solving linear systems of equations
As soon as methods were used on computers => dramatic advances
Main Goal: Learn methods to solve systems of linear algebraic
equations and apply them to CFD applications
Reading Assignment
Part III and Chapter 9 of Chapra and Canale, Numerical Methods for
Engineers, 2006.
For Matrix background, see Chapra and Canale (pg 219-227) and
other linear algebra texts (e.g. Trefethen and Bau, 1997)
Other References :
Any chapter on Solving linear systems of equations in CFD
references provided.
For example: chapter 5 of J. H. Ferziger and M. Peric, Computational
Methods for Fluid Dynamics. Springer, NY, 3
rd
edition, 2002
Numerical Fluid Mechanics PFJ L Lecture 7, 13
13
2.29

Direct Numerical Methods
for Linear Equation Systems
Ax = b or AX = B
Main Direct Method is: Gauss Elimination
Key idea is simply to combine equations so as to eliminate unknowns
First, lets consider systems with a small number of equations
Graphical Methods
Two equations: intersection of 2 lines
Three equations: intersection of 3 planes
Useful to illustrate issues:
no solution / infinite solutions (singular) or ill-conditioned system
Numerical Fluid Mechanics PFJ L Lecture 7, 14
14
2.29
1
2
x
1
+ x
2
= 1
1
2
x
1
+ x
2
= 1
1
2
x
1
+ x
2
= 1
1
2
1
2
x
1
+ x
2
=
2.3
5
x
1
+ x
2
= 1.1
x
1
+ 2x
2
= 2
x
2
x
1
x
2
x
1
x
2
x
1
Image by MIT OpenCourseWare.

Direct Methods for Small Systems:
Determinants and Cramers Rule
Linear System of Equations:
a a
11 12
= a a a a
Recall, for a 2 by 2 matrix, the determinant is:
D =
11 22 21 12
a a
21 22
Recall, for a 3 by 3 matrix, the determinant is:
a a a
11 12 13
a a a a a a
22 23 21 23 21 22
D = a a a = a
11
a
12
+ a
13 21 22 23
a a a a a a
32 33 31 33 31 32
a a a
31 32 33
Numerical Fluid Mechanics PFJ L Lecture 7, 15
15
2.29

Direct Methods for small systems:
Determinants and Cramers Rule
Cramers rule:
Each unknown x
i
in a system of linear algebraic equations
can be expressed as a fraction of two determinants:
Numerator is D but with column i replaced by b
Denominator is D
x
i
=
Example: Cramers Rule, n=2 Numerical case:

a a
11 12
A =

a a
21 22
(
(

i column
th

a b a
11 1 1n
b
2
a b a
n1 n nn
D
Cramers rule becomes impractical for n>3:
The number of operations is of O(n!)
Numerical Fluid Mechanics PFJ L Lecture 7, 16
16
2.29

Direct Methods for large dense systems
Gauss Elimination
Main idea: combine equations so as to
eliminate unknowns systematically
Solve for each unknown one by one
Back-substitute result in the original equations
Continue with the remaining unknowns
Linear System of Equations
General Gauss Elimination Algorithm
i. Forward Elimination/Reduction to Upper
Triangular Systems)
ii. Back-Substitution
Comments:
Well suited for dense matrices
Some modification of above simple algorithm
needed to avoid division by zero and other pitfalls
Numerical Fluid Mechanics PFJ L Lecture 7, 17
17
2.29


Gauss Elimination
Reduction / Forward Elimination
Linear System of Equations
Step 0
If a
11
is non zero, we can eliminate x
1
from the remaining equations 2 to (n-1)
a
i1
by multiplying equation 1 with and subtracting the result from equation i .
a
11
This leads to the following algorithm for Step 1:
Numerical Fluid Mechanics PFJ L Lecture 7, 18
18
2.29


i
j
a
11
is called
pivot element:
Notes:
Gauss Elimination
Reduction / Forward Elimination
Step 1
(is called Pivot equation for step 1)
Result of step 1: last (n-1)
equations have (n-1) unknowns
Pivot a
11
needs to be non-zero
Numerical Fluid Mechanics PFJ L Lecture 7, 19
19
2.29

Gauss Elimination
Reduction: Step k
Recursive repetition of step 1
for successively reduced set
of (n-k) equations:
The result after
completion of step k is:
( 1) k+
First non-zero element on row n:
a
nk , 1 +
x
k
Numerical Fluid Mechanics PFJ L Lecture 7, 20
20
2.29

Gauss Elimination
Reduction/Elimination: Step k
Back-Substitution
Reduction: Step (n-1)
Result after step (n-1) is an
Upper triangular system!
Numerical Fluid Mechanics PFJ L Lecture 7, 21
21
2.29


Gauss Elimination:
Number of Operations
Reduction/Elimination: Step k
: n-k divisions
: 2 (n-k) (n-k+1) additions/multiplications
: 2 (n-k) additions/multiplications
n1 3
| n
2
n |
3
For reduction, total number of ops is: 3(n k) 2( n k) *( n k 1) 2 n O n ( )

+ + =

+
|
=
k =1
\
3 3
.
n
( +1)
n
2
n n ( +1) (2 n n n + 1)
Use:

i = and

i =
i=1
2
i=1
6
Back-Substitution
: (n-k-1)+(n-k)+2=2(n-k) +1 additions/multiplications
n1 n
2
( + 1) n n
Hence, total number of ops is: 1+

(
2( n k) +1
)
= 1+ (n 1)( n +1) = n (

i = )
k =1 i=1
(the first 1 before the sum is for x
n
)
2
3 3
( ( Grows rapidly with n Grand total number of ops is O n ) = O n )
:
3
Most ops occur in elimination step
Numerical Fluid Mechanics PFJ L Lecture 7, 22
22
2.29
2


Gauss Elimination:
Issues and Pitfalls to be addressed
Division by zero:
( )
Pivot elements
k
must be non-zero and should not be close to zero
,
a
k k
Round-off errors
Due to recursive computations and so error propagation
Important when large number of equations are solved
Always substitute solution found back into original equations
Scaling of variables can be used
Ill-conditioned systems
Occurs when one or more equations are nearly identical
If determinant of normalized system matrix A is close to zero, system will be
ill-conditioned (in general, if A is not well conditioned)
Determinant can be computed using Gauss Elimination
Since forward-elimination consists of simple scaling and addition of equations,
the determinent is the product of diagonal elements of the Upper Triangular
System
Numerical Fluid Mechanics PFJ L Lecture 7, 23
23
2.29

Gauss Elimination: Pivoting
Step k
Partial Pivoting by Columns
Row k
Row i
Pivot Elements
Required at
each step!
Numerical Fluid Mechanics PFJ L Lecture 7, 24
24
2.29

Gauss Elimination: Pivoting
Reduction
Partial Pivoting by Columns
Step k
New Row k
Pivot Elements
New Row i
Required at
each step!
A. Partial Pivoting
i. Search for largest available coefficient in column below pivot element
Two Solutions:
ii. Switch rows k and i
B. Complete Pivoting
i. As for Partial, but search both rows and columns
ii. Rarely done since column re-ordering changes order of xs, hence more complex code
Numerical Fluid Mechanics PFJ L Lecture 7, 25
25
2.29




Gauss Elimination: Pivoting Example
(for division by zero but also reduces round-off errors)
Relatively
Example, n=2
close to zero
Direct Gaussian Elimination
Cramers Rule - Exact
n=2
a = [ [ 0. 01 1. 0] ' [ - 1. 0 0. 01] ' ]
tbt.m
b= [ 1 1] '
r =a^( - 1) * b
x=[ 0 0] ;
m21=a( 2, 1) / a( 1, 1) ;
a( 2, 1) =0;
a( 2, 2) = r add( a( 2, 2) , - m21*a( 1, 2) , n) ;
b( 2) = r add( b( 2) , - m21*b( 1) , n) ;
x( 2) = b( 2) / a( 2, 2) ;
x( 1) = ( r add( b( 1) , - a( 1, 2) *x( 2) , n) ) / a( 1, 1) ;
x'
2-digit Arithmetic
1% error
100% error
Numerical Fluid Mechanics PFJ L Lecture 7, 26
26
2.29

Gauss Elimination: Pivoting Example
(for division by zero but also reduces round-off errors)
Partial Pivoting
Interchange Rows
Example, n=2
Cramers Rule - Exact
2-digit Arithmetic
1% error
1% error
See
tbt2.m
Notes on coding:
Pivoting can be done in function/subroutine
Most codes dont exchange rows, but rather keep track of pivot rows
(store info in pointer vector)
Numerical Fluid Mechanics PFJ L Lecture 7, 27
27
2.29

Gauss Elimination: Equation Scaling Example
(normalizes determinant, also reduces round-off errors)
Multiply Equation 1 by 200
Example, n=2
Cramers Rule - Exact
2-digit Arithmetic
1% error
100% error
Element-based Infinity-Norm Normalization
Equations must be normalized for
partial pivoting to ensure stability
This Equilibration is made by
normalizing the matrix to unit norm
Element-based Two-Norm Normalization
See
tbt3.m
Numerical Fluid Mechanics PFJ L Lecture 7, 28
28
2.29

Note: Examples of Matrix Norms
Maximum Column Sum
Maximum Row Sum
The Frobenius norm
The l-2 norm
Numerical Fluid Mechanics PFJ L Lecture 7, 29
29
2.29

Gauss Elimination: Full Pivoting Example
(normalizes determinant, also reduces round-off errors)
Interchange Unknowns
Example, n=2
Cramers Rule - Exact
2-digit Arithmetic
1% error
Pivoting by Rows
Full Pivoting
Find largest numerical value in same row and column and interchange
Affects ordering of unknowns (hence rarely done)
Numerical Fluid Mechanics PFJ L Lecture 7, 30
30
2.29

Gauss Elimination
Numerical Stability
Partial Pivoting
Equilibrate system of equations
Pivoting by Columns
Simple book-keeping
Solution vector in original order
Full Pivoting
Does not necessarily require equilibration
Pivoting by both row and columns
More complex book-keeping
Solution vector re-ordered
Partial Pivoting is simplest and most common
Neither method guarantees stability due to large number
of reccursive computations
Numerical Fluid Mechanics PFJ L Lecture 7, 31
31
2.29

Gauss Elimination:
Effect of variable transform (variable scaling)
Variable Transformation
Example, n=2
Cramers Rule - Exact
2-digit Arithmetic
1% error
100% error
Numerical Fluid Mechanics PFJ L Lecture 7, 32
32
2.29

Systems of Linear Equations
Gauss Elimination
How to Ensure Numerical Stability
System of equations must be well conditioned
Investigate condition number
Tricky, because it can require matrix inversion
Consistent with physics
E.g. dont couple domains that are physically uncoupled
Consistent units
E.g. dont mix meter and m in unknowns
Dimensionless unknowns
Normalize all unknowns consistently
Equilibration and Partial Pivoting, or Full Pivoting
Numerical Fluid Mechanics PFJ L Lecture 7, 33
33
2.29

MIT OpenCourseWare
http://ocw.mit.edu
2.29 Numerical Fluid Mechanics
Fall 2011
For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.

Vous aimerez peut-être aussi