Você está na página 1de 4

MASSACHUSETTS INSTITUTE OF TECHNOLOGY

DEPARTMENT OF MECHANICAL ENGINEERING


CAMBRIDGE, MASSACHUSETTS 02139
2.29 NUMERICAL FLUID MECHANICS FALL 2009
QUIZ 1 Monday, October 19, 2009
The goals of quiz 1 are to: (i) ask some general higher-level questions to ensure you understand broad concepts and are
able to discuss such concepts and issues with others familiar with numerical fluid mechanics; (ii) show that you can
apply methods and schemes that you learned in idealized computational problems; and (iii), evaluate if you can read
numerical codes and recognize what they accomplish. Partial credit will be given to partial answers (e.g. accurate
descriptions in words of computations required but not carried out).
A. Short Concept Questions
Problem I (20 points)
Please provide a brief answer to the following questions (a few words to a couple sentences would
be enough: equations can be used but are not needed).
a) In a floating point representation, is the magnitude of the absolute round-off error constant?
b) Is the stress tensor in the Navier-Stokes equations symmetric? Why?
c) Define what preconditioning of A x =b is and briefly explain why it can accelerate the
convergence of a linear solver for A x =b?
, i.e. = +
1 i+
, d) If gradient descent methods are utilized to solve a linear system Ax = b x
i+1
x
i

i+
v
1
how does one usually determine the line-search coefficient
i+1
?
e) Provide an example of a parabolic partial differential equation.
f) If you update your finite difference scheme from a scheme of order of accuracy p to a scheme of
order of accuracy 2p, do you expect that your total errors will become twice as small?
B. Idealized Computational Problems
Problem II: Total Numerical Error in a Forward Euler Scheme. (20 points)
a) Using the first-order forward Euler finite-difference, write the difference scheme for the first
d f
derivative f ' = , keeping the leading term of the truncation error (you can denote h = t ).
dt
b) Assume that the round-off error in the evaluation of a function f t
i
is equal to E
i
and bounded ( )

by E: i.e. f ( ) t = f t ( ) + E where f

( ) t is the function value rounded by the computer and


i i i i
d f
E . Express the total error of the difference scheme derived in a) for and determine E
i
dt
an upper bound for this total error in terms of , and f ''( ) , where [ , t t t E h
i i
+ ] ).
Consider now the following differential equation:
d f
= cos( t) (1)
dt
c) Using b), determine the time-step h for which one obtains an optimal total error (Hint: in this
case,
2
). Very briefly comment on how the result depends of E and . If numerical f ''( )
values help you, you can assume that E=10
-16
.
d) Consider now the use of the finite difference scheme derived in b) to integrate equation (1).
Show that the total error after n time steps is bounded by an expression that is a function of
n h E , , and . Very briefly comment on the dependence of the result in terms of E and , e.g.
when do round-off errors become of similar size than truncation errors?
- 1 -



















Problem III: Gauss Elimination & LU decomposition for positive symmetric matrices (15 points)
k
a) Show that if a matrix A is positive definite, the intermediate matrices a
ij
( )
computed by Gauss
elimination or by LU decomposition remain symmetric.
b) If A is symmetric, but not positive definite, is the result obtained in a) always true?
Problem IV: Linear Solver for Block Tridiagonal Matrices (25 points)
Many flow problems are governed by more than a single scalar equation and are of dimensions
higher than one. Such systems, when discretized with implicit schemes, often lead to a block
tridiagonal system of equations such as:

F
1
G
1

x
1

d
1


E F G x d
2 2 2 2 2



E F G x = d
(2)

i i i i

i



E F G x d

N1 N1 N1

N1

N1

E F

x

d

N N N N
E F G
i
are M x where
i
, ,
i
x M submatrices and
i
and d
i
are M x 1 subvectors (vectors of size M).
a) By block LU decomposition (Gauss eliminating the sub-matrices E
i
), prove by recursion that the
block tridiagonal matrix can be converted into the lower and upper block tridiagonal matrices,

I

F'
1
G
1


I F' G
2 2 2

L = and U = , where the submatrices

I F' G
N1 N1 N1

I F'
N N

k
and F'
k
are defined as:
F'
1
=F
1
Block LU Decomposition
1
= ( ' ) F' =F G k E F =2,3,..., N
k k k1 k k k k 1
Prove that the resulting LU system LU x =d can then be solved as follows (defining Ux =y ):
Forward Substitution y =d y =d y i =2,3,..., N
1 1 i i i i 1
1 1
Back Substitution x = (F' ) y , x = (F' ) ( y Gx ) i N 1,...,1 =
N N N i i i i i +1
Note that you can answer parts b) and c) below without proving a).
b) Compute the dominant order of the operation count for scheme a).

By how much does scheme a)


reduce the operation count relative to that of full Gauss Elimination (which is (2
3
for a O n / 3)
matrix of size n)? (Hint: the operation count for a matrix inverse is O n
3
) for a matrix of size n (2 ).
c) If M corresponds to the number of spatial dimensions of the flow problem, one could decouple
the system defined by equation (2) into solving M successive scalar tridiagonal systems of size N
each. What would then be the order of the operation count? (Hint: recall that the operation count
of the Thomas algorithm is (8 ) ). O n for a matrix of size n

You can count each operation (multiplication, division, addition or subtraction) as one operation count.
- 2 -




















































C. Numerical code Evaluation Problems
Problem III.1: Finite Difference solution using MATLAB (20 points)
Read the following MATLAB function to solve for a specific equation using a particular algorithm:
f unct i on [ u] = GS_Ht _I nt ( omega, X, Nx, T, Nt , nu, f , ui , bcs)
%I NPUTS:
% omega: Sol ver par amet er , si ze( omega) = 1
% X: Si ze of domai n [ 0 X] , si ze( X) = 1
% Nx: Number of i nt er i or nodes, si ze( Nx) = 1
% T: Fi nal t i me, si ze( T) = 1
% Nt : Number of t i mest eps, si ze( Nt ) = 1
% nu: Equat i on par amet er , si ze( nu) = 1
% f : Funct i on handl e f ( x, t )
% ui : I ni t i al u val ue, si ze( ui ) = [ Nx, 1]
% bcs: Boundar y condi t i ons, si ze( bcs) = [ 2, 1]
maxi t er = 10000; EPS = sqr t ( eps) ;
dx = X/ ( Nx+1) ; dt = T/ ( Nt ) ;
D = di ag( ones( Nx , 1) *( 1/ dt + 2*nu/ dx^2) ) ; %Cr eat e di agonal mat r i x
L = di ag( ones( Nx- 1, 1) *( - nu/ dx^2) , - 1) ; %Cr eat e l ower di agonal mat r i x
U = di ag( ones( Nx- 1, 1) *( - nu/ dx^2) , 1) ; %Cr eat e upper di agonal mat r i x
%I ni t i al i ze and pr e- comput e
u = zer os( Nx+2, Nt +1) ;
u( : , 1) = ui ;
C=( D+omega*L) ^- 1;
B=C*( - omega*U+( 1- omega) *D) ;
%Not e: A=L+D+U st ays f i xed, but next we sol ve a new Ax=b at ever y t i me st ep
f or i =1: Nt
i t er = 0;
b = f ( dx: dx: X- dx , dt *i ) ' + u( 2: end- 1, i ) / dt ;
b( 1) = b( 1) + nu/ dx^2*bcs( 1) ;
b( end) = b( end) + nu/ dx^2*bcs( 2) ;
u( 1 , i +1) = bcs( 1) ;
u( end, i +1) = bcs( end) ;
uol d = u( 2: end- 1, i ) +1;
whi l e nor m( u( 2: end- 1, i +1 ) - uol d ) / sqr t ( Nx) > EPS && i t er < maxi t er
i t er = i t er + 1;
uol d = u( 2: end- 1, i +1) ;
u( 2: end- 1, i +1) = B*u( 2: end- 1, i +1 ) + omega*C*b;
end
end
a) Which partial differential equation is being solved? And which finite-difference schemes are
being used to discretize it? (Hint: the scheme is implicit in time)
b) What type of boundary condition is implemented?
c) Which algorithm is used to solve the discretized linear system of equations at each time step?
(Hint: see the omega).
- 3 -




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.

Você também pode gostar