You are on page 1of 5

ChE 3E04 – Process Model Formulation and Solution

Fall 2012 – Homework 4


Due: Tuesday, Nov 13, 4:00pm to the dropbox Note: to be performed in groups of up to three.
Grading:100 pts. Weight: 5% of total course grade.

OBJECTIVES

Learn and demonstrate skills with:


 Multivariate regression

SUBMISSION

The method of submission of your answer for each question or part of question will vary. Typically,
anything that can be checked by computer will be submitted to Avenue to Learn, and anything
which must be viewed by humans will be submitted in hardcopy.

[A2LQuiz] - This symbol means to submit your answer to the online quiz on Avenue to Learn

[A2LDropBox] - This symbol means to submit your answer to the drop box on Avenue to Learn

[ONPaper] - This symbol means to submit your answer in hard copy.

Always have all names and student numbers on any printed out / hardcopies.

PART 1

You are developing a process which uses the water gas shift reaction to produce H2 from CO, in
which steam is reacted with CO to form H2 and CO2:

H2O + CO ⇌ CO2 + H2

The reaction is mildly exothermic and reversible, and highly sensitive to both pressure and
temperature. In the lab, you formulate a series of experiments where you change the inlet
temperature and pressure of an equimolar mixture of H2O and CO, and then measure the percent
conversion of CO into CO2. You generate a series of data like the following:

Independent Independent Dependent


Variable: Variable: Variable:
Temperature (K) Pressure (bar) % Conversion
395.53 43.17 0.96651
420.06 47.01 0.936984
449.82 41.63 0.858825

1|Page
…except that you collect a very large number of data points (on the order of 1-2 thousand). The
data are not at regularly spaced intervals because you could not control the pressure and
temperature with that much precision.

The file “GetScenario1.m” contains the data in Matlab format (get from the Content section of
Avenue to Learn). You can call it like this:

[X,Y] = GetScenario1();

Where X is a matrix with two columns: Column 1 (X(:,1)) is the temperatures and Column 2
(X(:,2)) is the pressures. Y is a column vector containing the corresponding % conversion values.

Q1) 5 points – Start by looking at the experimental data in 3D as data points in matlab. You can use
the Delaunay and trimesh functions to do this. Actually, here’s the code, enjoy your free points:

[X,Y] = GetScenario1();
newgrid = delaunay(X(:,1), X(:,2));
trimesh(newgrid,X(:,1),X(:,2),Y,'Marker','.','MarkerSize',2 ...
,'MarkerEdgeColor','Black','FaceColor','None','LineStyle','None');

You can use the 3D rotator tool to see the nonlinearities and general shape.

Now: we are going to create a generic multivariate regression code which find a multivariate
polynomial shape which best fits the data. In this assignment, we will keep it very general… we
will write the code for any number of dimensions (in the above example, there are 2, temperature
and pressure) and write the code so that the regression polynomial in each dimension can be of any
order.

Q2) 10 points [ONPaper] – As discussed in class, we will create a regression polynomial of the form:

f(x1,x2,…,xND) = a0 + a1,1 x1 + a1,2 x12 + …. a1,N(1)x1N(1) + a2,1 x2 + a2,2 x22 + …. a2,N(2)x2N(2) + …

+ aD,1 xD + aD,2 xD2 + … + aD,N(D) xDN(D)

Where a0 is a constant and ai,j is a constant corresponding to dimension i and polynomial


coefficient j. Or in compact notation, it can be written this way:

∑∑

Where D is the number of dimensions and N is a Dx1 vector showing the order of each polynomial
in each dimension. So for this question only, let’s assume we’re fitting a 3rd order polynomial in x1
(temperature) and a 2nd order polynomial in x2 (pressure). Then:

a) What is the value of D?

b) What is N?

2|Page
c) Write out the full function above using those assumptions. It will help you see the
patterns.

d) How many unknown variables are in this example? Write them out if it helps.

e) How many unknown variables will there be for a given N and D? In other words, write an
expression for how you can calculate the previous answer for any D and N. You can use
proper math format, pseudocode, or matlab code to answer.

Q3) 5 points [ONPaper]- Write the equation for the SSE = sum of square error for any D and N. I
recommend you use the compact form shown on the previous page. I suggest you use the following
notation for your x data:

is the value of xl at data point k raised to the power of m. So for the table on the first
page, for l=1 (temperature), k=2 (row 2 of the table), and m=3 (the third power), you get the value
equal to 420.063. As another hint, you should have three summations in your answer. If you have to
make up any variables, define them.

Q4) 5 points [ONPaper]- Write the expression for . Keep it in generic terms (of D and N).
Optional: Rearrange the expression so that it becomes a series of linear terms in the form Ax=b (you
will only have one equation, but you can still write it as a row vector times a column vector equals a
constant b). This may help later.

Q5) 5 points - Write the expression for . Keep it in generic terms (of D and N).
Optional: Rearrange the expression so that it becomes a series of linear terms in the form Ax=b (you
will only have one equation, but you can still write it as a row vector times a column vector equals a
constant b). This may help later. Note: keep i and j separate from l and m![ONPaper]

Q6) 5 points [ONPaper] – How many total equations are then in Q4 and Q5 to be solved?

Q7) 40 points [ONPaper] [A2LDropBox]– Now, adding to your MATLAB code, write a program which
creates the model by solving for the unknown polynomial coefficients. Ensure that your matlab
code works for any number of data points, number of dimensions D, and polynomial ordering N,
which you will be changing later. For this problem, use a 3rd order polynomial in temperature and a
2nd order polynomial in pressure.

Submit a surface chart of your regression function on the same chart as the actual data. The
regression should be a surface and the data should be points. For example, the following sequence
of commands should pretty much do it (if you used the same commands I gave in Q1 first):

hold on;
trisurf(newgrid,X(:,1),X(:,2),YP,'Marker','None','EdgeColor','None');
xlabel('Temp (K)');
ylabel('Press (bar)');
zlabel('%% Conv');

3|Page
Where YP is the vector of predicted conversions using your model, matching the actual data vector
Y. The type of graph I am looking for is like this THOUGH THIS IS JUST AN EXAMPLE, THE
NUMBERS WILL BE DIFFERENT:

Q8) 5 points [ONPaper]- Report the goodness-of-fit (R2) value the model to four significant figures.
Note that your sum of square errors should be 0.0109 or similar if you have done it correctly.

Q9) 5 points . [ONPaper]- Report the MODEL PREDICTED value of x for T = 420 K and P = 40 bar to
four significant figures

Q10) 5 points – [ONPaper] Create a new model and report the new R2 value for a 2nd order
polynomial in temperature and a 1st order polynomial (line) in pressure.

PART 2

Going back to your experiment, you now consider the molar ratio of steam to CO as a third
independent variable, since adding more steam can push the equilibrium to the right and cause
additional reaction. So you go back and collect data for three dimensions, which will appear in the
following form.

4|Page
For example, three of the data points look like the following:

Independent Independent Independent Dependent


Variable: Variable: Variable: Variable:
Temperature (K) Pressure (bar) H2O/CO Ratio % Conversion
395.2661 39.92 0.799295 0.793164
401.5328 45.00 1.46577 0.992092
450.4147 46.68 1.599167 0.992848

Q11) 5 points – [ONPaper] Create a new regression model using this new experimental data and
report the new R2 value for a 2nd order polynomial in temperature and a 2st order polynomial (line)
in pressure and a 3rd order polynomial in steam/CO ratio. You will no longer be able to plot the
result, but you should be able to create the model. If you did part 1 correctly then this step should
take you no more than a minute or two.

Q12) 5 points – [ONPaper], For the above, predict the % conversion of CO at T=410K, P=36bar, and
steam/CO ratio = 1.2 to three significant figures. As a hint, the SSE should be 0.1890.

Submit your code to Ave to Learn [A2LDropBox]

5|Page

You might also like