Вы находитесь на странице: 1из 6

MASSACHUSETTS INSTITUTE OF TECHNOLOGY

DEPARTMENT OF MECHANICAL ENGINEERING


CAMBRIDGE, MASSACHUSETTS 02139
2.29 NUMERICAL FLUID MECHANICS FALL 2011

Problem Set 1
Grading Note: Please provide your solutions either as hand-written/hard-copy solutions or by submitting
online. MATLAB codes should be submitted online. 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.

Problem 1 Do problems 3.7 and 3.8 in Chapra and Canale, page 76.
Problem 2
Consider the steady heat transfer within a thin rectangular flat plate whose sides are kept at fixed
temperatures. Three sides of the plate are at 0oC and the last one at T1 = 80oC. The dimensions of
the rectangular plate are a = 5 m and b = 4 m. For the given boundary conditions T(x,y) can be
expressed analytically by Fourier series (Erwin Kreyszig, Advanced Engineering Mathematics,
John Wiley and Sons, 1993):

T ( x, y )

4T 1

n 1

sin[(2n 1)
(2n 1)

x
a

] sinh[(2n 1)

]
a
b
sinh[(2n 1) ]
a

For the following numerical computations, divide the length a into 40 segments and the width
b into 32 segments. Use the limited precision addition function (radd.m) for adding two terms.
a) Determine and plot (e.g. 3-D surface plot) the temperature distribution T(x,y) within the plate
using 2 significant digits in the radd function in the following two ways:
i. Carrying out the summation from n = 1 to n = 20.
ii. Carrying out the summation in the reverse order, i.e. from n = 20 to n = 1.
b) Determine the difference in the results of these two summation procedures and generate a
surface plot for this difference. Which method gives more accurate results? Why?
MATLAB help: Look at meshgrid and surf commands in MATLAB.
Problem 3 Do problem 4.12 in Chapra and Canale, page 105.

Problem 4
a) Do problem 4.15 in Chapra and Canale, page 105.
b) Carry out a similar analysis as in a), but using the standard error approach. For this
particular channel example, do your conclusions change?
Problem 5. Do problem 8.33 in Chapra and Canale.
Problem 6
It is common in computations to determine random access memory (RAM) requirements.
a) Calculate the RAM (in megabytes) necessary to store a multidimensional array of size 100 x
100 x 100 x 1000 (for example a discretized temperature field in 4d: 3d in space and 1000
time steps). This array is double precision, and each value requires a 64-bit word. Recall that
a 64-bit work = 8 bytes and 1 megabyte = 106 bytes.
b) If your laptop has 3.5Gb of RAM, could you store the array in a) in your RAM?
For your information, when your memory requirements exceed the size of the available RAM,
the CPU often uses swap space. Swap space is usually a portion of the disk space used for such
temporary storage location, with the caveat that access to disk is much slower than RAM access.
Problem 7: (Round off Errors in Orthogonalization)
This problem is designed to study the effect of round off errors on an orthogonalization process.
Given a set of linearly independent vectors v1 , v2 ,, vn , each of size m1 with n m ,
orthogonalization refers to the generation of orthogonal vectors u1 , u2 ,, un each of size m1
such that they span the same n dimensional subspace of R m as vectors vi , i 1, 2,.., n . We define
the inner product of two vectors ui and u j as: ui , u j uiT .u j
and u j are said to be orthogonal if, ui , u j 0, for all i j . In addition, this

Two vectors

orthogonal set of vectors is said to be orthonormal, if, || ui ||

ui , ui 1, i 1, 2,.., n .

The Gram-Schmidt process is a method to orthonormalize a given set of vectors. A nave


implementation of this method (let us call this GS1) works as follows:
u1 v1

u2 v2
u3 v3

v2 , u1
u1 , u1

u1

v3 , u1
v ,u
u1 3 2 u2
u1 , u1
u2 , u2

...
n 1

un vn
i 1

vn , ui
ui
ui , ui

This method generates a set of orthogonal vectors ui , i 1, 2,..., n . Another version of this
method, (let us call this GS2) is:
u
e1 1
u1 v1
|| u1 ||
u2 v2

v2 , e1
e1
e1 , e1

e2

u2
|| u2 ||

u3 v3

v3 , e1
v ,e
e1 3 2 e2
e1 , e1
e2 , e2

e3

u3
|| u3 ||

...
vn , ei
ei
ei , ei

n 1

un vn
i 1

en

un
|| un ||

This method generates a set of orthogonal vectors ui and a set of orthonormal vectors

ei , i 1, 2,..., n . Finally, the Modified Gram Schmidt (MGS) process is another method for
orthogonalization of vectors. It is very similar to the classic Gram Schmidt process. In this
method, uk , k 1, 2,..., n is computed as follows:
vk , u1
u1
u1 , u1

1
uk vk

uk , u2
1

uk uk

u2 , u2

u2

...
k 2

uk

k 3

uk

uk

k 1

k 2

k 3

, uk 2

uk 2 , uk 2
k 2

uk uk

uk

uk

uk 2
, uk 1

uk 1 , uk 1

uk 1

Similar to the Gram-Schmidt orthogonalization, ui s are generated sequentially for i 1, 2,..., n .


As an example, to calculate u3 one would first calculate u3(1) and u3(2) using:
1

u3

v ,u
v3 3 1 u1 ,
u1 , u1

u3 , u2
1

u3 u3 u3

u2 , u2

u2

Answer the following questions:


a) Generate a random matrix V (m n) using the rand function in MATLAB. Use the command
rand('state',100)
V
before generating the matrix . This sets the seed of the random number generator to 100 and
ensures that every student generates the same matrix.
b) Implement the Gram-Schmidt orthogonalization (GS1) for the following values of
:
i. m = 2000, n = 2
ii. m = 20000, n = 5
iii m = 200000, n = 10
In each case, after generating the vectors uk and ek , k 1, 2,..., n , calculate the n n matrices U
and E in which U ij uiT u j and Eij eiT e j . Now, set the diagonal elements of these matrices to
zero and print the resultant matrices. These matrices serve as a check for the orthogonality of the
generated vectors. What do you observe?
c) Repeat Part b), by implementing GS2 instead of GS1. What do you notice?
d) Implement the Modified Gram-Schmidt method for the same matrix V for all the values of

m, n in part b). Again, please use the command

rand('state',100)
before generating V. What do you observe?
e) Briefly explain the results you observe in parts b), c) and d). Which method is superior? Can
you briefly explain why?
Problem 8: Root finding, Finite Difference, and Time integration.
A significant model of population growth was derived in 1838 by Belgian Pierre-Francois
Verhulst. His model eliminated the unrealistic effects of unlimited exponential growth. He
suggested that when a population increases, there is a tendency for individuals to compete with
each other and so reduce growth. His model has come to be known as the logistic growth
equation.
Consider a turtles population modeled by such a logistic growth equation:
x
x

f ( x, t ) rx 1
t
K
where:
x is the number of turtles in the population
K = 800 is the carrying capacity
r = 0.1 is the growth rate

a) Using Taylor series, apply the forward, backward, and central differences to the first order
(time) derivative in the above equation and derive the corresponding discrete timeintegration schemes. Re-arrange the terms such that the unknown values (at future time
steps) are on the left-hand side and known values are on the right-hand side.
b) The backwards difference formula requires the evaluation of the function f(x,t) at a time in
the future where the value of x is unknown. This results in a root-finding problem. Write a
function NewtonRaphson that has a header of the type:
Function x = NewtonRaphson(f, df, x0, TOL, maxit)
f is the function handle of the function whose root you require
Where:
df is the function handle of the derivative of f
x0 is an initial guess value and x the final value
TOL is the error tolerance
Maxit is the maximum number of iterations
A skeleton of this function can be downloaded from the Stellar site.
c) Compute the number of turtles from time 0 to time 120 years using the forward, central, and
backwards difference schemes. Use 30, 60, 120, and 240 time intervals (that is t 120 / 30
, for example). For each of these four time step cases, plot the Population vs. Time values
of the backward, central, and forward difference schemes and of the analytical solution (all
four estimates on the same graph for each time step case). Discuss the results as the number
of time intervals increase. Initially, we have two turtles and the exact analytical solution is
given by:
2 e rt
x (t )
1 2 ( e rt 1) / K
We mainly provide you this so you can initialize the time integration with the central
difference (you need two time-steps to start the scheme). You can also use the forward
difference solution to initialize (which would be common practice), either way is fine.
d) Plot the L2 norm of the error versus the number of time steps used for the three schemes on
the same graph. Use a loglog() plot.
For the L2 norm use: norm(x-xexact)/sqrt(# intervals+1). Here x is a vector containing the
solution at each timestep. That is, x has a length= (#intervals+1). So, calculating the error
for forward difference using 30 intervals you will get a single number.
e) Determine the order of convergence for each scheme. Do they converge at the expected
order?
f) For which scheme and for which number of divisions do you obtain the fewest turtles at 100
years? (Do you think your colleagues would be happy if you used this numerical solution in
your population growth research?)

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.

Вам также может понравиться