Conceptualizing Kinetics with Curve Fitting

Dec 12, 1998 - A recent article in this Journal has urged that curve fitting be used for the identification and analysis of zero-, first-, and second-...
0 downloads 0 Views 85KB Size
Information • Textbooks • Media • Resources edited by

Computer Bulletin Board

Steven D. Gammon University of Idaho Moscow, ID 83844

Conceptualizing Kinetics with Curve Fitting

W

Ed Vitz Department of Chemistry, Kutztown University, Kutztown, PA 19530

A recent article in this Journal has urged that curve fitting be used for the identification and analysis of zero-, first-, and second-order reactions (1) in place of the traditional strategy of linearization of the data followed by linear least squares analysis. Another article (2) briefly outlined nonlinear curve fitting procedures in spreadsheets. It is the purpose of this article to carry the trend suggested by these articles to its logical conclusion and demonstrate the pedagogical advantages of using Excel in both introductory and advanced chemistry courses to either simulate or analyze kinetics data. The following paragraphs show how an Excel worksheet can be used to determine whether a reaction is first, second, or third order by curve-fitting methods, which simultaneously determine the rate constant. To help students understand and visualize the process, four traces are displayed on one Excel graph or “chart”: one represents experimental data, and three others are generated by zero-, first-, and second-order mathematical models with user-chosen initial concentrations and rate constants. The user can watch as the selected model curve is gradually brought to as close a match with the experimental curve as possible by successive iterations of the fitting routine, which is called “Solver” in Excel. A second use of the same template is essentially “manual, visual curve fitting”, where the user can choose the order, initial concentration, and rate constant and see what the effect will be on the shape of the model curve. Students can gain a more intuitive understanding of kinetics by immediately seeing the effect of changes in these three parameters. This approach serves as an introduction to both the use of the template and to the basis for curve-fitting techniques, so it will be described first. Using the Template To Model Kinetics Processes Figure 1 shows the header for an Excel template that models zero-, first-, and second-order reactions having rate constants k z, k f, and k s and initial concentrations Cz , Cf, and Cs , respectively. Values for these constants can be entered in the parameter tables on the right. The graph is automatically generated from concentrations calculated for each time in column A by integrated forms of the rate equations entered in columns C, D, and E, starting in row 20. These equations use the rate constant and initial concentration entered in the parameter tables. The user can immediately see the effect on the graph of changing either the rate constant or initial concentration in the parameter tables, so this template serves W

Supplementary materials for this article are available on JCE Online at http://jchemed.chem.wisc.edu/Journal/issues/1998/ Dec/abs1661.html.

as an excellent kinetics model or simulation. It shows easily that second-order reactions tail off less quickly than first-order reactions, while zero-order reactions come to completion in a finite time. It can be observed, for example, that entering initial concentrations of 1.0 M and k = 0.0693 will generate a zero-order reaction that comes to completion in less than 20 minutes; a first-order reaction with a half-life of 10 minutes so that only 0.0625 M remains after 40 minutes (and virtually none after 8 half-lives); or a second-order reaction that still has more reactant after 200 minutes than the firstorder after 40. This sort of “play” leads to an intuitive feel for kinetics that is not as easily gotten by comparing straightline plots of C vs t, ln C vs t, and 1/C vs t. These and several other suggestions for student use of the template are included in an exercise worksheet in the same Excel workbook. Using the Template for Curve Fitting The main advantage of the template is that it can be used to mathematically fit a model curve to an array of experimental values and return the values of k (and Co, if desired) which give the best fit. The experimental values are entered in column B and plotted along with the three model traces, so that the template can be used to calculate the sum of the squared residuals (SSR) between the array of calculated values and the data. The calculated SSR value is included in the parameter tables at the top right of the template. Excel’s Solver function can then be used (as described in the instructions below) to minimize the SSR by changing the values of k and Co. If the “Show Iteration Results” option is selected, the user can watch the model curve contort itself to “try to fit” the data, as new values of k and Co with ever lower SSRs are calculated. This conveys the essence of curve fitting to the student, since it essentially automates the modeling exercise described above. If the program is not successful at fitting one model to the data, another can be tried until satisfactory statistics (or a reasonable visual fit, depending on the course level) are obtained. For example, if the data represent a second-order reaction with Cs = 0.5 and k = 0.1, a zeroorder model will be very difficult to apply. If estimates of Cs close to 0.5 and k = 0.1 are chosen, Excel will converge on a “best fit” but the straight line will clearly not match the data; a student would conclude that these data do not represent a zero-order process and would proceed by attempting to fit a first- or second-order model to the data. For some initial guesses, the Solver routine will diverge rather than converging on a minimum SSR value, and a message will appear to that effect. The initial concentration may be treated as a constant, so that it cannot be varied by the curve-fitting routine, but

JChemEd.chem.wisc.edu • Vol. 75 No. 12 December 1998 • Journal of Chemical Education

1661

Information • Textbooks • Media • Resources

Figure 1. Fitting kinetics data to zero-, first-, and second-order equations.

as is often the case in kinetics data analysis, it may be better to use the experimental initial concentration as an estimate only and let the routine vary it to obtain the best fit. Initial and very late data points are often suspect or even impossible to determine, and curve fitting can reveal their inconsistency with other data or provide good estimates of their values (3). The template can also be used to generate kinetics data sets for analysis by students. The equation that is used to generate the model data in columns C, D, and E can be copied into column B to generate data sets for analysis. After the selected equation is copied from cell C20, D20, or E20 into cell B20, it can be edited to replace k z, k f , or ks with just “k”, and C z, C f, or Cs with “Co”. The values of k and C o are entered and displayed in a fourth parameter table in the template, but they can be easily hidden from students if necessary. The Excel random number generator could be used to add “noise” to the data to simulate experimental values. The values calculated by the equations in column B are displayed as the “data” trace on the graph, so that a curve with known initial concentration, rate constant, and order can be generated for use in the curve-fitting exercise. In summary, this strategy for teaching kinetics presents models that students can “play” with, producing zero-, first-, or second-order plots instantaneously for any rate constant or initial concentration. It is an excellent tool for determining the order and rate constant that best fits an array of empirical data, providing a wealth of statistical information on the goodness of fit. And finally, it provides a “feel” for the curvefitting process that is not attainable with conventional curvefitting programs, by showing the contortions that the model curve goes through while the routine minimizes the residuals. The LIMSport Program (4–10) developed at Kutztown University uses Lotus 1-2-3/DOS or Excel/Windows spreadsheets for both data acquisition and analysis in undergraduate laboratories. Data are imported directly into the spreadsheet by native spreadsheet commands, so that students learn to use standard software in the laboratory, such as the Excel template described here, that will serve them well throughout their professional careers. We have written data acquisition DLLs or driver sets to enable this spreadsheet data acquisition.

1662

Instructions for Kinetics Curve Fitting 1. Enter kinetics data in columns A and B. Column A will contain time values starting in cell A20, and column B will contain some parameter that changes with time (concentration, activity, absorbance, etc.) starting in B20. The parameter tables are set up in columns H and I, and the cells are given descriptive names (I2 and I3, containing the zeroorder rate constant and initial concentration, are named “kz” and “Cz”, for example). Locations are defined for the SSRs for the three models, and formulas are entered to calculate them. For example, cell I4 contains the formula for the zero order model, (“SSRz”), “=SUM(G20:G218)”. 2. The template uses the time values to calculate zero-, first-, and second-order decay curves with the corresponding Excel equations in columns E, D, and C, starting at row 20: Order

Integrated Equation Excel Equation

Zero

C t = Co – kt

=IF(($I$3᎑$I$2*$A20)>=0,$I$3᎑$I$2*$A20,0)

First

C t = Coe᎑kt

=Cf*EXP(᎑kf*$A20)

Second C t = Co /(Co kt + 1) =Cs/((Cs*ks*$A20)+1)

The “IF” statement in the zero-order equation prevents negative values. A chart is defined for column A as the independent variable, and columns B, C, D, and E as dependent variables. Try putting various values in the cells labeled kz, Cz (k and Co for a zero-order reaction) and observe the corresponding plot. Repeat for kf, Cf (first order) and ks, Cs (second order). 3. Columns F, G, and H are used to calculate the squares of the residuals. That is, the entry in cell H (for the zeroorder residual squared) would be “=(E20-B20)^2.” 4. To determine if the data reflect zero-order kinetics, Excel’s Solver function will try to match values calculated with the equation Ct = Co – kt to the data. Excel does this by varying the values of k and Co and calculating all values of Ct. The difference between the Ct values and experimental values are calculated, the differences are squared and added to give the SSR. The same calculation is repeated until the SSR is minimized, showing that values calculated with the equation Ct = Co – kt have been “fit” to the experimental data as closely as possible. To do this select Tools_Solver. Highlight the default entry in Target Cell, then click on the cell containing the SSR z (e.g., “$I$4”) to enter SSR z as the value to be minimized. Click the min radio button. Highlight the default cells dis-

Journal of Chemical Education • Vol. 75 No. 12 December 1998 • JChemEd.chem.wisc.edu

Information • Textbooks • Media • Resources

played in the By Changing Cells entry and replace them by selecting the cells containing kz,Cz ($I$2:$I$3 in this case). Now click on Options and choose Show Iteration Results, so that you will see the results of each iteration on the plot. Click on the Quadratic estimates, Forward derivatives, Newton search buttons, click OK to close the Options box, and finally click on Solve to initiate curve fitting. Excel help can be consulted for background information on these selections. Excel pauses occasionally during the curve-fitting process to allow user input, displaying the message “Solver paused, current solution values displayed on worksheet”. Normally, one would note the values of k, C, and SSR that had been calculated to that point, then click on the Continue button, repeating this procedure until the SSR is below the minimum specified value. The procedure above allowed the curve-fitting program to vary the initial concentration to give a model that best fits the data. It may be desirable to enter only $I$2 in the By Changing Cells dialog box, entering the experimental value for the initial concentration in cell I3. 5. Repeat step 4 for the first-order curve-fitting process, where Excel will attempt to fit the model equation Ct = Coe᎑kt to the data. In this case, Minimize SSRf by changing kf and Cf. 6. Repeat for the second-order curve-fitting process, where Excel will attempt to fit the model equation C t = Co/(Cokt + 1) to the data. In this case, Minimize SSR s by changing ks and Cs.

Acknowledgment I gratefully acknowledge National Science Foundation support (DUE-9652855; see http://www.kutztown.edu/~vitz/ limsport/limsrefs.html ) for development of the LIMSport laboratory manual, which will include the present work. Literature Cited 1. Coleman, W. F. J. Chem. Educ. 1996, 73, 243. 2. Machuca-Herrera, J. O. J. Chem. Educ. 1997, 74, 448–449. 3. Noggle, J. H. Practical Curve Fitting and Data Analysis: Software and Self-Instruction for Scientists and Engineers; Prentice Hall: Englewood Cliffs, NJ, 1993; pp 37, 126–127. 4. Vitz, E. J. Chem. Educ. 1992, 69, 744. 5. Vitz, E. J. Chem. Educ. 1993, 70, 63. 6. Vitz, E.; Reinhard, S. J. Chem. Educ. 1993, 70, 245. 7. Vitz, E.; Reinhard, S. J. Chem. Educ. 1993, 70, 758. 8. Vitz, E.; Betts, T. J. Chem. Educ. 1994, 71, 412. 9. Vitz, E. J. Chem. Educ. 1994, 71, 879. 10. Vitz, E.; Chan, H. J. Chem. Educ. 1995, 72, 920.

JChemEd.chem.wisc.edu • Vol. 75 No. 12 December 1998 • Journal of Chemical Education

1663