html

# Reaction Simulation

This is a graphic user interface for learning about three new capabilities of the MATLAB Statistics Toolbox. They are:

Designed Experiments.

Response Surface methods.

Nonlinear modelling.

The interface has three figure windows:

¥ Reaction Simulator

¥ Trial and Error Data

¥ Experimental Design Data

The Reaction Simulator figure has several controls for running a virtual chemical reaction. There are three sliders with associated data entry boxes to control the partial pressures of the chemical reactants: Hydrogen, n-Pentane, and Isopentane. The RUN button performs one reactor run at the current settings.

Exercise 1: Trial and Error Optimization

Do several processing runs. The results of each run will appear in the Trial and Error Data figure. After each run change one or more slider settings. Try to learn how changes in each reactant affect the reaction rate. See if you can find the settings that maximize the reaction rate over the allowable ranges of the reactants.

After doing several runs you can plot your results using the plot menu at the bottom of the Trial and Error Data figure. You can also analyze your data using the Analyze button in this figure.

Exercise 1: Questions

What are the settings of the optimal process? What reaction rate do you predict at these settings? How comfortable are you with your predictions?

Exercise 2: Optimization Using a Designed Experiment

Now press the Do Experiment button in the Experimental Design Data figure. After a short wait you will see a table of reactant settings appear in the figure. The Reaction Simulator will then perform all of these processing runs automatically and record the results in the Reaction Rate column.

After doing the experimental runs you can plot your results using the plot menu at the bottom of the figure. You can also analyze your data using either the Response Surface or the Nonlinear Model buttons.

Exercise 2: Questions

How do the Response Surface and Nonlinear models compare? Do they agree on the settings of the optimal process? What reaction rate do you predict at these settings? How precise are your answers compared to the results of the Trial and Error approach?

Designed Experiments

# Designed Experiments

The MATLAB Statistics Toolbox supports factorial and d-optimal design of experiments.

In the reaction simulator you can run a d-optimal experiment by choosing Design Experiment from the popup menu labeled Model.

The command in reactsim is below:

settings = cordexch(3,18,'quadratic');

This generates the matrix SETTINGS which is 3 by 18. That is, there are 18 runs for three variables. The string variable, 'quadratic' indicates that you wish to fit a full quadratic model in three variables.

The form of this model is:

y = b0 + b1*x1 + b2*x2 + b3*x3 + ... (linear terms)

b12*x1*x2 + b13*x1*x3 + b23*x2*x3 + ... (interaction terms)

b11*x1.^2 + b22*x2.^2 + b33*x3.^2 (quadratic terms)

Here is the M-file help for cordexch.

Response Surface Methodology

# Response Surface Methodology

Response Surface Methodology (RSM) is a tool for understanding the quantitative relationship between multiple input variables and one output variable.

Consider one output, z, as a polynomial function of two inputs, x and y.

z = f(x,y) describes a two dimensional surface in the space (x,y,z). Of course, you can have as many input variables as you want and the resulting surface becomes a hyper-surface.

It is difficult to visualize a k-dimensional surface in k+1 dimensional space when k>2. The function RSTOOL is a GUI designed to make this visualization more intuitive.

Here is the M-file help for rstool

Nonlinear Modelling

# Nonlinear Modelling

RSM is an empirical modelling approach using polynomials as local approximations to the true input/output relationship.

In some cases, we may have a relevant theory that allows us to make a mechanistic model. Often such models are nonlinear in the unknown parameters.

The data generated by the reaction simulator does not come from a polynomial model. The model describes the reaction rate as a function of hydrogen, n-pentane and isopentane partial pressure is the Hougen-Watson model.

It is difficult to visualize a k-dimensional nonlinear surface in k+1 dimensional space when k > 2. The function NLINTOOL is a GUI designed to make this visualization more intuitive.

Here is the M-file help for nlintool

cordexch help

# Help for CORDEXCH

CORDEXCH D-Optimal design of experiments.

CORDEXCH(NFACTORS,NRUNS,MODEL) creates a d-optimal experimental design using the coordinate exchange algorithm.

[SETTINGS, X] = CORDEXCH(NFACTORS,NRUNS,MODEL) generates the factor settings matrix, SETTINGS, and the associated design matrix, X. The number of factors, NFACTORS, and desired number of runs, NRUNS. The optional string input, MODEL, controls the order of the regression model. By default, CORDEXCH returns the design matrix for a linear additive model with a constant term. MODEL can be following strings:

interaction - includes constant, linear, and cross product terms.

quadratic - interactions plus squared terms.

purequadratic - includes constant, linear and squared terms.

cordexch help

# Help for RSTOOL

RSTOOL Interactive fitting and visualization of a response surface.

RSTOOL(X,Y,MODEL,ALPHA) is a prediction plot that provides a multiple input polynomial fit to (X,y) data. It plots a 100(1 - ALPHA) percent global confidence interval for predictions as two red curves. The default model is linear. MODEL can be following strings:

interaction - includes constant, linear, and cross product terms.

quadratic - interactions plus squared terms.

purequadratic - includes constant, linear and squared terms.

The default value for ALPHA is 0.05, which produces 95% confidence intervals.

RSTOOL(X,Y,MODEL,ALPHA,XNAME,YNAME) The optional inputs XNAME and YNAME contain strings for the X and Y variables respectively.

Drag the dotted white reference line and watch the predicted values update simultaneously. Alternatively, you can get a specific prediction by typing the "X" value into an editable text field.

Use the pop-up menu labeled Model to interactively change the model.

Use the pop-up menu labeled Export to move specified variables to the base workspace.

nlintool help

# Help for NLINTOOL

NLINTOOL Fits a nonlinear equation to data and displays an interactive graph.

NLINTOOL(X,Y,MODEL,BETA0,ALPHA) is a prediction plot that provides a nonlinear curve fit to (x,y) data. It plots a 100(1 - ALPHA) percent global confidence interval for predictions as two red curves. BETA0 is a vector containing initial guesses for the parameters. The default value for ALPHA is 0.05, which produces 95% confidence intervals.

NLINTOOL(X,Y,MODEL,BETA0,ALPHA,XNAME,YNAME) The optional inputs XNAME and YNAME contain strings for the X and Y variables respectively.

You can drag the dotted white reference line and watch the predicted values update simultaneously. Alternatively, you can get a specific prediction by typing the "X" value into an editable text field. Use the pop-up menu labeled Export to move specified variables to the base workspace.

Hougen model

# M-file Help for hougen.m

HOUGEN Hougen-Watson model for reaction kinetics.

YHAT = HOUGEN(BETA,X) gives the predicted values of the reaction rate, YHAT, as a function of the vector of parameters, BETA, and the matrix of data, X. BETA must have 5 elements and X must have three columns.

The model form is:

y = (b1*x2 - x3/b5)./(1+b2*x1+b3*x2+b4*x3)

Here b1, b2,...,b5 are the unknown parameters and x1, x2, and x3 are the three input variables.

Reference:

[1] Bates, Douglas, and Watts, Donald, "Nonlinear Regression Analysis and Its Applications", Wiley 1988 p. 271-272.