Escolar Documentos
Profissional Documentos
Cultura Documentos
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
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).
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.