MASSACHUSETTS INSTITUTE OF TECHNOLOGY
DEPARTMENT OF MECHANICAL ENGINEERING
CAMBRIDGE, MASSACHUSETTS 02139
2.29 / 2.290 NUMERICAL FLUID MECHANICS — SPRING 2021
Problem Set 2
Issued: Thursday, March 4, 2021 Due: Friday, March 19, 2021
Grading Note: Please provide your solutions either as hand-written/hard-copy solutions or by submitting
via Stellar. MATLAB codes should be submitted via Stellar. The bulk of the grades will be given to detailed
explanations and to algorithms and numerical schemes that capture the essence of the numerical problems.
We know that successful coding of numerical schemes can be time consuming and prone to small errors.
Such small errors or omissions in a code will not be heavily penalized.
The goals of this Problem Set are to: (i) review vector calculus and conservations laws; (ii) learn and utilize
methods for solving linear algebraic systems; and (iii) apply these methods to simple differential equations
in fluid mechanics and heat transfer.
Problem 5 is not required for the 2.290 undergraduate version of the course.
Problem 1: Numerical Modeling of Nonlinear Advection-Reaction Epidemics
To study, control, and prevent epidemics (e.g. in humans, river fish, other animals, etc.), it is common to
employ conservation-law-based differential models. Here, we consider a one-dimensional in space and
time problem, and divide the population studied into the healthy concentration H ( x, t ) and infected
concentration I ( x, t ) . The epidemic model is then:
H H
+ vH = −aHI + rH 2 − d H H
t x (1a-b)
I I
+ vI = aHI − d I I
t x
where: vH and vI are the total advection speeds (flow plus behavior) of the healthy and infected
concentrations, respectively; aHI models the rate at which the healthy become infected (rate assumed
proportional to the healthy and infected concentrations, with an infection rate coefficient a); rH 2 models
the quadratic reproduction of the healthy population with rate coefficient r; and d H H and d I I models
the linear death rate of the healthy and infected concentrations with coefficients d H and d I , respectively.
Discretize time as tn = n t , n = 0,1, and space as xi = i x, i = 1, , m , and assume that all
coefficients, vH , vI , a, r, d H , and d I , are constants.
a) Using the first-order backward finite difference scheme for all temporal derivatives and the second-
order central finite difference scheme for all spatial derivatives, and evaluating all reaction terms in
the right-hand-side at time tn +1 , please discretize the PDE system (1a-b).
b) Obtain the leading order terms of the truncation error for the healthy concentration eq. (1a).
c) Fixing the time-step t , you reduce x to numerically evaluate the spatial convergence rate but
observe no convergence. Using your result in b), briefly explain when this could happen.
d) At each time-step, to solve the finite difference nonlinear equations you obtained in a), you decide to
employ a fixed-point iteration. Write down the fixed-point iteration scheme in matrix form.
Page 1 of 5
e) If in d), you instead decide to use a Newton-Raphson scheme, please write down the scheme in matrix
form and evaluate the Jacobian matrix for the present finite difference nonlinear equations (Do not
spend time inverting the matrix).
Problem 2 (Reference: Matrix Computations by Gene Golub and Charles Van Loan)
Suppose we partition an n-by-n matrix A as follows
A11 A12
A=
A21 A22
where A11 is r-by-r, A22 is (n− r)-by-(n −r) and A21 and A12 of compatible dimensions. Assume that A11 is
nonsingular and has a LU factorization. Suppose that A21 is eliminated row by row by applying r steps of
Gauss elimination, the result of this process being:
A11* A12*
A =
*
*
0 A22
*
Show that the bottom-right (n − r)-by-(n − r) block of the result, A22 , is the matrix S defined by S = A22 −
−1
A21A11 A12, which is called the Schur complement of A11 in A.
Problem 3 (Reference: Numerical Linear Algebra by Lloyd N. Trefethen and David Bau, III, and
Chapra and Canale)
Gauss elimination can be used to compute the inverse A−1 of a nonsingular matrix , though it
is not often necessary to do so.
a. Describe a 3-steps algorithm (pseudo-code) to compute A−1 by solving a system of m equations using
LU decomposition. Show that its asymptotic operation count is 8m3/3 flops.
b. Taking advantage of the fact that L and U have zeros above and below the diagonal, respectively, and
that I is diagonal (L, U and I are sparse matrices), describe a variant of your algorithm that would take
advantage of sparsity in some of the steps of the algorithm and so reduce the asymptotic operation count
to 2m3 flops.
c. Suppose one wishes to solve n systems of equations Axj = bj. As seen in lecture, a block system AX =
B with is equivalent and can be efficiently solved. What is the asymptotic operation count
(a function of m and n) for doing this (i) directly from the LU factorization applied to AX = B and (ii)
with a preliminary computation of A−1?
d. The following system of equations is designed to determine concentrations (the c’s in g/m3) in a series
of coupled reactors as a function of the amount of mass input to each reactor (the right hand side in
g/day),
15c1 - 3c2 - c3 = 3800
-3c1 + 18c2 - 6c3 = 1200
-4c1 –c2 +12c3 = 2350
i. Solve this system of equations by LU decomposition without pivoting.
ii. Determine the matrix inverse of this system and use it to determine the solution.
iii. How much will the concentration in reactor 3 be reduced if the rate of mass input to reactors 1
and 2 is reduced by 500 and 250 g/day, respectively?
iv. If you had to compute the solution of part iii. by only using either the LU decomposition or the
inverse of A (computed in part i. and part ii. above), will one of these approaches lead to a faster
solution?
Page 2 of 5
Problem 4 (Modified from Chapra and Canale, Problems 10.12 and 10.15)
a) Determine and compare the A F
(Euclidean/Frobenius norm), A 1 and A for
−6 −2 5
[ A] = 8 1.1 −2.5
−3 −1 10.3
Scale the matrix by making the maximum element in each row equal to one.
b) Consider the following system
1 4 9 16 25
4 9 16 25 36
A = 9 16 25 36 49
16 25 36 49 64
25 36 49 64 81
i) Determine its condition number using the row-sum norm. Do not normalize the system.
ii) How many digits of precision will be lost due to ill-conditioning?
iii) Repeat i), but scale the matrix by making the maximum element in each row equal to one.
Problem 5: Conditioning of symmetric positive definite matrices. (only for the graduate version,
2.29)
In scientific and engineering computations, one of the most important classes of matrices is the
symmetric positive definite one. Recall that a matrix A is positive definite if x T Ax 0 x 0 .
Considering such a symmetric positive definite matrix A with eigenvalues 1 2 n 0 :
a) Obtain the 2-norm (spectral radius) of A, i.e. A 2 , in terms of its eigenvalues.
b) Using a), express the condition number of A in terms of its eigenvalues.
c) Based on your result in b), is a positive definite matrix always well-conditioned? Briefly
discuss.
d) What is the minimum condition number of A? To what kind of matrices could this
correspond to? Briefly state why such matrices are a favorite in numerical algebra.
Problem 6: Vector Calculus Exercise
a) Evaluate the divergence .v , the curl v and the Newtonian viscous stresses xx and xy
2
( ij = − . u ij + 2 eij ) for the following two-dimensional velocity fields (where α is an arbitrary
3
constant): i) u = y v = 0 ii) u = x v = − y
Identify which field is irrotational ( v = 0 ) or solenoidal ( .v = 0 ).
Page 3 of 5
b) Prove the following vector identities. It is easiest if you utilize the index (Einstein) notation and the
summation convention1. Several of these identities were utilized in lecture. They are often used in the set-
up of real (numerical) fluid mechanics problems.
i) . ( v) = 0 True for any vector v (divergence of a curl)
ii) ( ) = 0 True for any scalar (curl of a gradient)
iii) 2 v = (. v ) − ( v ) This is another way to write the Laplacian 2 v
iv) . ( v) = . v + . v Divergence of the product of a scalar by a vector (chain rule)
v) .( u v) = u. v + v . u Divergence of vector-vector dyadic product (chain rule)
c) Considering the intensive variable (i.e. Φ per unit of mass), show using the Reynolds Transport
Theorem and the continuity equation that, for a control volume CV fixed in an inertial frame, the following
holds (another form of the Theorem):
D D
Dt CM
dV =
CV Dt
dV
Problem 7 (Modified from Fluid Mechanics (4th) by Frank White, Problem 3.59)
When a pipe flow suddenly expands from A1 to A2, low speed, low-friction eddies appear in the corners
and the flow gradually expands to A2 downstream (see figure).
Pressure ~ p1
CV
p1, V1, A1 p2, V2, A2
i) Using the suggested control volume for incompressible steady flow and assuming that pp1 on the
A1 A1
corner annular ring as shown, show that the downstream pressure is given by p2 = p1 + V12 (1 − ).
A2 A2
Neglect wall friction.
ii) Compare your above result with the result obtained using the Bernoulli equation. Which one is more
reasonable and why?
1
A hand-out, Appendix A from Bird et al, “Summary of Vector and Tensor Notation, was provided in case you are
not yet very familiar with these notations (see for example pg 719-726).
Page 4 of 5
Problem 8: (Modified from Chapra and Canale, Problem 12.38)
Linear algebraic equations often arise in the numerical solution of differential equations. Consider for
example the following differential equation which derives from the energy balance along a thin fin (see
figure),
d 2T T0=25C Tn=100C
2
+ h (Ta − T ) = 0
dx
where: T is temperature (°C), x is
distance along the rod (m), h is a
heat transfer coefficient between
the fin and the ambient air (m-2),
and Ta is the temperature of the
surrounding air (°C). This is the
‘fin equation’ for convective x
cooling of an extended surface.
x=0 m Ta=5 C
a) Develop an analytical solution x=20 m
for this equation. Solve for
coefficients symbolically (you do not need to simplify your coefficients).
2T T ( x + x ) − 2T ( x ) + T ( x − x )
b) Substitute the centered finite difference 2 = in the above differential
x ( x ) 2
fin equation. Re-arrange terms to have all known values on the right hand side (RHS) and all unknowns
on the LHS. What are the coefficients in front of each unknown? You can provide your answer in terms
of a “computational cell,” e.g. in a table similar to the following:
x − x x x + x
Coefficient a1 a2 a3
This gives the coefficients in the ‘A’ matrix for the interior nodes, where AT=b, with ‘A’ as the
coefficient matrix, ‘T’ as the vector of temperatures, and ‘b’ as the RHS vector.
c) Implement part b) in MATLAB using the linear system solver (Lin_sys_solver.m) that we provide you
(with appropriate tolerance) or using your favorite language. What is the name of the algorithm used in
this Lin_sys_solver.m?
d) Plot your solution for a 20-m rod with Ta=5, T(x=0)=25, T(x=20)=100, and h=[0.4, 0.04, 0.02, 0.00001]
using 6 nodes. For your plots, graph both the analytical solution (using a solid line) and the numerical
solution [using markers, e.g. plot(Solution,’*’)]. You can either plot all the solutions on a single graph, or
on four separate graphs.
e) Briefly give a physical interpretation of the effect of the different values of h on the temperature
profile? (A sentence or two will be fine, referring to your plots in part d).
f) Examine the ‘A’ matrix you created and comment on its structure (MATLAB’s “spy” command may
be useful here). How does it affect computations?
g) Could you have used the Thomas algorithm for solving this problem? If yes, briefly discuss its cost in
comparison to that of the algorithm used in lin_sys_solver.m.
Page 5 of 5