MCS 507  Individual Computer Project 1  Fall 2004
LU Decomposition Solve & Iterative Refinement
for Industrial Chemical Reactor Application:
MATLAB and/or Programming Computation
MATLAB and/or Program with both Outputs are
Due Friday 24 September 2004 in Class
Some Comment Corrections: 12 September 2004
.
General Project Objectives: Often in Industry,
solutions are developed for small scale test problems using some
high level computational system like MATLAB and later solutions
for larger production problems are developed using an intermediate
level programming language like C or perhaps Fortran so that the final
product is more efficient for large scale production problems, i.e.,
problems that are very large with many computing runs.
Problem Options:
 MATLAB Small Scale & Programming Large Scale:
Hence, develop a procedure for the following project using MATLAB
and then use the MATLAB procedure to develop a larger scale
programming language (like in C or other scientific language such
as FORTRAN, but MATLAB may also be used for the large scale problem too) procedure.
 Entirely in MATLAB:
Alternatively, you can do the problem
entirely in MATLAB by finding the largest size problem you can run
on the system of your choice based upon the initial test problem,
but give justification for using the largest size.
 Entirely in Ch:
Another alternative is to use the Ch Language System which combines
the benefits of Unix, C and MATLAB in one selfcontained package
for MSwindows and other operating systems and is free for academic
use.
(Developed by Prof. Harry Cheng of UC/Davis; he is a UIC Ph.D. in ME,
Prof. K. Gupta was his primary advisor and Hanson was his secondary advisor).
Project Statement:
An industrial chemical diffusion reactor has been modeled as a partial
differential equations, reduced to a linear algebraic problem, a*Z = b,
bZ finite differences and
requires a numerical solution in terms of a LU decomposition solution
technique since the solution procedure may be performed multiple
times for different parameter values that do not affect the
 Coefficient Matrix:
a = [a(i,j)]_{n×n}.
The reactor has a 2dimensional
crosssection that is rectangular (L1×L2 meters) with the following
parameter values:
General Instructions:
 Small Scale MATLAB Test Case Part:
In MATLAB (see help resources below), use LU decomposition
function "[L,U,P] = lu(a)" where "P" is the pivot matrix
such that "P*a = L*U" approximately,
and the forward with backward solve steps like
"Y_{1} = L\P*b" and
"Z_{1} = U\Y_{1}"
(backslash alert, see "help \"),
to get an approximate solution "Z_{1}" for "Z"
to the smaller test problem "a*Z = b".
Then, use one iterative refinement with the residual
"r_{1} = b  a*Z_{1}",
and another solve for the approximate error solution "e_{1}"
for "e_{}" in "L*U*e=P*r_{1}" using the same LUdecomposition.
Get the second approximation to the exact solution "Z",
"Z_{2} = Z_{1} + e_{1}",
the infinitynorm of the difference "Z_{2}  Z_{1}",
the infinitynorm of the first relative residual "r_{1}/b",
and the
infinitynorm of the second relative residual "r_{2}/b",
 Small Scale Output:
Hand in your printed MATLAB (*.m file) code and output with explanatory
comments for documentation. (Code documentation is very important in
Industry.)
Report your output in 5 significant digits by print formatting using
exponential notation, unless you are tabulating a column of numbers that
do not contain very small or very large numbers. Errors and changes should
always be printed in enotation for professional industrial output. In this
project the approximate solutions, "Z_{1}" and
"Z_{2}", must be printed in enotation (use fprintf in
both MATLAB (or variants in C and Fortran languages).
 Large Scale Part:
 Programming Language:
If you are going to use a programming procedure (C, F or equivalent),
solve the large scale version of "a*Z = b" using the Numerical Recipes,
or similar, LU decomposition program procedure "ludcmp" and the backsolve
companion "lubksb" (or equivalent procedures: it is recommended that you modify
these codes to remove special NRC conversion header utilities that are
only simulations Fortran style for the conversion to C, C++ or F.
 OR MATLAB at Maximal Array Size:
If you are doing a MATLAB large scale version, doing the largest matrix
"a" possible on your system, then make sure your code is in maximal
arrayvector format, since MATLAB is more efficient in the format due
to background use of LAPACK.
 Either Case: Use your LU decomposition for the initial
solution "Z_{1}" as well as the single iterative refinement
to compute second approximation to the exact solution "Z",
"Z_{2} = Z_{1} + e_{1}",
and compute the infinitynorm of the difference
"Z_{2} = Z_{1}_{1}",
the infinitynorm of the difference "Z_{2}  Z_{1}",
the infinitynorm of the first relative residual "r_{1}/b",
and the
infinitynorm of the second relative residual "r_{2}/b",
 Plot test, and if possible large scale, results for
"Z_{1}", say using
MATLAB's surf or mesh 3D plotting functions, on the original rectangular
model, i.e., convert the LU solution
"Z_{1} = [Z_{1}(i)]_{n×1}"
to rectangular form
"Urect =[urect(i1,i2)]_{n1×n2}"
as a function of
"x1 = [i1*h1]_{n1×1}" and
"x2 = [i2*h2]_{n2×1}",
adding the boundary condtions "u = 0" on the rectangular boundaries,
"x1=0", x2=0" "x1=L1" and "x2=L2".
 Hand In: your printed programming code and truncated
output with explanatory comments for documentation together with
your MATLAB test.
 Printing Output:
In order to conserve printing and paper resources, you need only
print out the coefficient matrix "a", right hand side vector "b" and
solution "Z" for i = 1 to n in steps of "K = (n1)/(nml1)", designed
to make large scale values comparable to small scale values, and the
same for the column index "j" of "a", where "nml = 3*4" is the MATLAB
(ml) array size. You will have to fold the printing of the rows
of a in half, at least.
 Computer Precision:
In your code calculations, you must use at least double precision
(64 bit; MATLAB is double by default), since float or single is
not suitable for "nontoy" problems. Report your output in 5
significant digits by print formatting using exponential notation,
unless you are tabulating a column of numbers that do not contain
very small or very large numbers. Errors and changes should always
be printed in enotation for professional output. The solution "Z"
must be printed in enotation.
Project Report:
Your report needs the following parts:
 Cover Page: Put a project title, your name, your affiliation,
date and other identifying information on this individual computer project.
What you submit must be your own work (this in NOT a group project),
else points will be deducted for similar work, i.e.
your grade will receive a discount.
 Executive Summary: This is about a page briefly summarizing the
project and results for a busy boss
.
This should be in the form of
a page outline or itemized list for easy and fast reading. This summary
is not the same thing as an abstract. To give the boss a taste of the
results, show a graph of the most important results.
 Project Description or Introduction:
Describe the project in your own
words as an introduction to your report, in sufficient depth so that
a reader such as yourself would understand it.
 Methods: Describe the methods used to solve the problem,
giving both advantages and disadvantages in a fair manner. Describe the
theory and model behind the computer problem.
 Results: Describe the nature of the results
and illustrate them with
appropriate tables or plots. You can use MATLAB for plotting both your MATLAB
and C or equivalent results, importing the latter's output date
into MATLAB. Clearly label tables and plot figures. Also give the
maximum and minimum of "u" in both small and large scale cases.
 Discussion of Results: Discuss the results,
including how they can be
used elsewhere for different industrial applications.
 Acknowledgements: Acknowledge what resources you used in this
project, including what versions of MATLAB and C or equivalent that you
used, the operating system, the computer or hardware platform,
persons consulted (this is important to help avoid deductions for plagerism),
and any other resources (references are listed in the next section) used.
 Conclusions: List what you have learned from this project
and explain why it is significant.
 References: Cite all books, scientific papers, websites and
other library or web resources that you used. Give author, title, journal
name or book publisher or URL where appropriate, and date of publication or
web access.
 Appendices: Include MATLAB and C or equivalent documented
source code and output.
Project Resources:
 UIC PCLabs MATLAB available software. Also check out your
departmental or laboratory computers such as in EECS and MSCS.

MATLAB Help Page (Hanson).

(NRC): William H. Press et al.,
Numerical Recipes in C, C++ or F: The Art of Scientific Computing,
CambridgeU. Press, ISBN: 0521431085 (See UIC TextBookStore or
www.amazon.com price: $57.95 last year;
also available for F77 and/or F90; Disk of programs available in
Fortran and nonstandard fortran translated C);
(See www.amazon.com or similar online bookstores).
Also, available at
 UIC Libraries 430 SEO:
 QA76.73.C15 N865 1992 Main Library for C;
 QA297.N866 1992 Math Library 430 SEO for Fortran;
 Online for NRC or NRF or NRF90:

Google Numerical Recipies or MATLAB. Many students have
"googled" online
to find NR information and codes. For example, search for "ludcmp.c" or
"ludcmp.f".

C/C++ Help Page (Hanson).
 Fortran Help Page (Hanson).

Ch Homepage,
a combined Unix, C and MATLAB like package, so no additional software,
no C compiler, no Unix system or no MATLAB, are needed, even in MSwindows.
The primary interface is a Unixlike terminal window in which commands
can be issued, including the execution of C programs.
The Ch command names are typically longer than MATLAB names.
Web Source: http://www.math.uic.edu/~hanson/mcs507/cp1f04, .html
MCS 507 HomePage: http://www.math.uic.edu/~hanson/mcs507/
Email Comments or Questions (MCS 507 only, please) to
hanson A T math uic edu .