Sei sulla pagina 1di 5

University of Delaware Department of Mathematical Sciences MATH 305 Applied Math for Biomedical, Biomolecular and Chemical Engineering

Matlab Assignment #2 (Due 03/27/2014)


This assignment aims at introducing Matlab ODE solvers. You are asked to solve a batch reactor problem using Matlab. In addition, you are asked to use Matlab to solve systems of linear algebraic equations. 1. Batch reactor. Consider a batch reactor with three chemicals A, B, C. Let cA (t), cB (t) and cC (t) be the concentrations of the three chemicals in the reactor at time t . The rate of conversion is assumed to be as given in the diagram below (the ki are non-negative rate constants). So this is similar to the CSTR problem, except there is no inow or outow.
k1 A k2 B k4 k 3 C

Using mass balances, as before, we model the Batch Reactor as a system of ODEs (make sure you fully understand how to derive this system) dcA = k1 cA + k2 cB dt dcB = k1 cA (k2 + k3 )cB + k4 cC dt dcC = k3 cB k4 cC . dt (1) (2) (3)

Given initial concentrations of A, B, C in the reactor, our goal is the study of questions such as What are the concentrations of A, B, C in the reactor at time t ? What are the long run concentrations of A, B, C in the reactor? How does the behavior of the reactor change as the ki are changed (i.e. if we consider a dierent set of reaction rates)?

University of Delaware Department of Mathematical Sciences MATH 305 Applied Math for Biomedical, Biomolecular and Chemical Engineering

You will be able to answer these questions once you have determined the concentrations of A, B, C in the reactor at any time t . For the long-term behavior of the reactor you might expect that the reactor will settle down to an equilibrium in steady-sate you will explore this idea as well. For this assignment, you will be asked to nd a numerical approximation of the solution using Matlab ODE solvers, and to compare with the exact solution when available. You will also be asked to solve for the steady-state(s) and compare to the long run concentrations. In class, you are about to learn how to obtain the exact solution for linear systems such as (1)(3) above. To simplify the notation, we introduce the concentration vector cA (t) c(t) = cB (t) . cC (t) You can assume that the expression below is the exact solution to the batch reactor system (1)(3). c(t) = 1 v1 + 2 e2 t v2 + 3 e3 t v3 , (4)

where the i are arbitrary constants (determined from the initial conditions), 1 = 0 , 2 and 3 are the eigenvalues of the reaction matrix, and vi are the corresponding eigenvectors. It is not hard to show that 2,3 = s s2 4p . 2 (5)

Here s = k1 + k2 + k3 + k4 is the sum of the ki , and p = k1 k3 + k1 k4 + k2 k4 . Note that s and p are positive numbers. Also s2 > 4p ; in fact s2 4p = (k1 + k2 k3 k4 )2 + 4k2 k3 > 0 . Hence 3 < 2 < 0 (these eigenvalues are real negative), because s > Therefore, lim c(t) = 1 v1 .
t

s2 4p .

It is easy to show that k2 /k1 v1 = 1 . k3 /k4 2 (6)

University of Delaware Department of Mathematical Sciences MATH 305 Applied Math for Biomedical, Biomolecular and Chemical Engineering

Questions For each question (a)(c) below answer with complete sentences and proper justication. (a) Can you predict the long term concentrations of A, B, C in the reactor? (b) Can you predict the ratios of the concentrations of A, B, C in the reactor in the long run? (c) Does the answer to (b) depend on the initial concentrations? (d) Note that the value of 1 can be determined from the initial concentrations by appealing to the mass balance principle the sum of the concentrations remains constant for all t . Prove this mathematically from the equations (1)(3). (e) Assume the reaction constants to be k1 = 2, k2 = 1, k3 = 2, k4 = 2, and that the initial concentrations of A, B, C in the reactor are given by 2 (7) c(0) = c0 = 3 . 10 For this particular choice you can verify (using paper and pencil) that the exact solution to the initial value problem (IVP) is given by (4) with 1 1 1 2 = 2 , 3 = 5 , v1 = 2 , v2 = 0 , v3 = 3 . (8) 2 1 2 You do not need to submit the work for this, but it is highly recommended that you verify the facts in (8) above. It follows that the solution to the IVP is 3 2e2t + e5t . 6 3e5t c(t) = (9) 2t 5t 6 + 2 e + 2e Use Matlabs ode45 solver to nd an approximate solution to the system with the values chosen above, and compare the solution with the exact 3

University of Delaware Department of Mathematical Sciences MATH 305 Applied Math for Biomedical, Biomolecular and Chemical Engineering

solution given by (9). Show the comparison by plotting both the exact and the approximate solutions on the same graph. Plot for time large enough to show the time-asymptotic values of the concentrations. Describe in words the behavior of the concentrations of each species. You may try (for fun) to decide whether the results make sense, given the relative sizes of the reaction rates. The m-le for this problem should be a script m-le called HWQ1E.m. (f ) Fix three reaction rates at a time as given in part (e), and vary the other to nd out how the solution changes choose one value below and one value above the original value of each rate constant. Show the results through plots to compare the dierent solutions on the same graphs. Describe in words how the behavior of the reactor is aected by changes in reaction rates. The m-le for this problem should be a script m-le called HWQ1F.m. 2. Solve the following linear systems of equations for the given unknowns by setting up the equations in matrix form, Ax = b. Solve in Matlab by using the command x = A\b whenever possible. Recall that, for the case of an n n system, a unique solution exists if and only if det A = |A| = 0. If the matrix is singular, you can try the rref command. (a) Use Matlab to solve for the steady-state(s) of the system (1)(3) using the values of the rate constants given in part (e) of Problem 1 above. Compare with the long run of the system found from (9). The m-le for this problem should be a script m-le called HWQ2A.m. (b) A 3 3 system with a unique solution 3x1 + x2 2x3 = 1 x1 + 2 x2 x3 = 0 2x1 + x3 = 5 The m-le for this problem should be a script m-le called HWQ2B.m. (c) An over specied system with 3 equations and 2 unknowns. The solution in this case is the least squares solution. 4x1 + 2x2 = 3 x1 x2 = 1 3x1 4x2 = 7 4

University of Delaware Department of Mathematical Sciences MATH 305 Applied Math for Biomedical, Biomolecular and Chemical Engineering

The m-le for this problem should be a script m-le called HWQ2C.m. (d) A singular 3 3 system with an innite number of solutions; Matlab warns that the matrix is singular. Use the rref command to nd all solutions. x1 + 2 x2 + 3 x3 = 1 4x1 + 3x2 + 2x3 = 2 5x1 + 5x2 + 5x3 = 3 The m-le should be a script m-le called HWQ2D.m.

Check list for submission


Include the Matlab codes used. Codes well documented with comments are best. Plot of the concentrations vs. time with proper labeling, etc., done with Matlab; include the corresponding Matlab code. Table of values of the rate constants used in part (f ) of Problem 1. Check that your report is well organized, neatly presented and complete, including all the pertinent discussion and interpretation of the results.

Potrebbero piacerti anche