## Description

Homework Assignment #1

Solving Linear Systems

Use Matlab to solve these problems. Generate script which is organized and commented.

You can make one m file for the entire assignment or separate m files for each problem. Turn in the m files AND pdf files of the output (using the publish function). Zip files together and turn in one file through blackboard.

1. (Just some practice with plots and matrices) Write a Matlab script to generate a vector x that has values from 1 to 20 in increments of 2. Generate a three column matrix Z that has random numbers ranging from 1 to 50 in its first column, the square of those values in its second column, and the square root of the values in the first column in its third column. Make a plot of the elements of x versus the second column of Z.

2. The set of balance equations below arise from force balances on a spring and mass systems. Assume the problem is scaled such that all the terms are dimensionless. Your interest is in analyzing the system for functions and parameters that result in singularities or sensitivity in the system.

๏ญ ๏ญ3×1 2×2 ๏ซ ๏ฝx3 5

2×1 ๏ซ f ( )x ๏ซ ๏ฝ๏ญx3 2

4×1 ๏ซ ๏ญx2 2×3 ๏ฝ 7

a. For the case that f ( )x ๏ฝ๏กx2 , this system is a linear system and can be written as

Ax = b. You need to determine if there are values of ๏ก that leave the system illconditioned. Generate a plot of a scalar measure of the condition of the system as a function of the parameter ๏ก. Be sure to explain what you are doing in the comments of your code. Is there a value of ๏ก that causes the system to be illconditioned?

3. Consider a CSTR with a feed stream at volumetric flow rate of ๏ฎ containing reactants at molar concentrations of CA,in; a reactor volume V; concentrations in the reactor of Ci where i = A, B or C. The reactor is well mixed so the exit stream is at the same concentration as the reactor itself C(t) and the system is isothermal. Two reactions occur in the reactor with the following kinetic parameters:

k1 k2

A๏ฎ ๏ฎB C

the reactions are first order, so the molar rate of production of the product of each reaction, per unit volume, is proportional to the molar concentration of the reactant. Write out the mass balances on each species and simplify the steady state balances into a single matrix equation, A c = co.

a) Write a Matlab script that produces a plot of the concentration of species C in the reactor as a function of the residence time of the reactor, ๏ด๏ = V/๏ฎ, for the case that k1 = 3 hr-1, k2 = 0.1 min-1 and CA,in = 3 mol/L. Choose a range of ๏ด that shows a significant change in CC.

b) Produce a plot of Cc as a function of the ratio of rate constants, k2/k1 for the case that ๏ด = 30 sec and k1 = 0.5 min-1. Cover a range of k2 that shows a significant change in CC.

4. Write a routine to perform Gauss elimination. This should be written as a function that takes A and b as inputs and has an output of the vector of unknowns x. The routine should check the sizes of the matrices to see that they are consistent. Partial pivoting should be performed. Add features to alert the user to singular systems and ill-conditioned systems.

3a b๏ญ ๏ซ ๏ซ ๏ฝ3c d 6

6 9 2a๏ซ ๏ญ ๏ฝc d 13

๏ญ12 10 5a๏ญ c๏ซ ๏ฝd 17

72 8 48 19a b๏ญ ๏ซ c๏ญ d ๏ฝ93

5. In class, we discussed the use of the method of finite differences to solve differential problems, specifically pressure drive flow between two plates. Set up the necessary matrices and solve for the steady state velocity profile for the situation that the two plates are stationary, the fluid is water, the gap between the plates is 150 microns and the pressure drop is 1 atm per 3 inches. Calculate and plot the velocity profile for (a) 4 nodes and (b) 15 nodes. Comment on how many nodes are required to determine the velocity profile accurately.

6. Consider the following reaction rate versus temperature data taken by a technician in your lab. Use the expression given to determine the pre-exponential factor, ko, and the activation energy EA. Take the natural logarithm of both sides and model this as a linear algebra problem A x = b. Find the least squares fit to the data using the pseudoinverse of A (see section 1.3.7 from Graham & Rawlings, on BB site) and state the values and units of the two parameters. Plot the data (points) and the leastsquares fit (line) on the same plot.

# Temp (K) Rate Constant, k (s-1)

1 430 0.0026

2 450 0.0118

3 470 0.0460

4 480 0.0873

5 490 0.1800

Arrhenius kinetic equation k k๏ฝ o exp๏ฆ๏ง๏จ๏ญRETA ๏ถ๏ท๏ธ

R=8.314 J/K

## Reviews

There are no reviews yet.