Simulation and data reduction programs

The least expensive way to enrich the undergraduate chemistry curriculum is with simulation and data reduction programs. These programs are not necess...
1 downloads 0 Views 4MB Size
I

K. Jeffrey Johnson

University of Pittsburgh Pinsburgh, PA 15260

Simulation and Data Reduction Programs

The least expensive way to enrich the undergraduate chemistry curriculum is with simulation and data reduction programs. These programs are not necessarily interactive and do not have the same objectives and software requirements of CAI programs ( I ). The lead article in this series (2) introduced the acronvms NTCA and CELSIM for non-tutorial computer applications and computer-enhanced learning via simulation. The programs described in this article could he classified as NTCA or CELSIM programs. Most simulation and data reduction pronams that are used in undergraduate chemistry instruction are short, that is, less than 200 statements, and do not involve complex algorithms. The majority of the 75 programs in the author's library of simulation and data reduction programs were written in collahoration with undereradnate students. Thev are all written in Fortran and are relatively easy to transport. Most of them could he readilv translated into Basic bv an undergraduate who is familiar with both languages. ~ i m h a t i o na n l d a t a r e duction oroerams have been written for ~roarammable cal. .. . . culiltors, micronmpurerr, minicomputers, and maxi\wnputers. Kearly ewry i s s u e d i h i Jr.!irnol ~ in the pnst dt.c:id~has had an artr Ieur notedescrihin:: s simulation or data reduction r ~ r w r a nSeveral ~. hooks are ilvnildble in which -pmgrami of this ;ortare described (3-16). Simulation and data reduction programs are arbitrarily classified here into four categories: function evaluation, data reduction, computer-simulated experiments, and all others. The function evaluation . oroerams allow students to v a n the " parameters of a mathematical model of a chemical system to discover the response of the system to arbitrary changes in the parameters. The data reduction programs extend the students' calculating ability so that a more sophisticated treatment of experimental data is possible. Computer-simulated ex~erimentsare used to allow students to interact with experimental data, either as a prelahoratory exercise, or to simulate experiments that cannot he done in the undergraduate laboratory because of time, safety, or expense constraints. The "other" classification is necessary for those programs that defy classification into one of these three categories.

this kinetic system. The input includes the four rate constants, the number of entries in the table and the time increment. The program tabulates the concentrations of A, B , and C, and plots the results using "teletype graphics". A sample execution of this program is given in Figure 1. T h e pedagogical power of such a program is that it allows students to arbitrarily manipulate the parameters of the mathematical model to see what happens in response. This

............~**......*******~.~**.****..

-

Concentration

Tine 0.000

0.500

1.00

Function Evaluation Programs

Function evaluation programs involve a mathematical function, Here y is the dependent variable, x is the independent variable. and a,. .. a?. -.etc. are the oarameters of the mathematical model. Consider, for example, the following kinetic system, k,*\

bU,

X1,

'.*

A-B-C

Here the ohjwtiw is t t l ~ I ~ s e rthe w nmrentration prdilrs of A, l3,and C 3a n functhn of the fuur rntt! cun>t:lnts. A clusedform rxprescim is a\.ailahle 1171for mirial c o d r i m s

In this case there are three dependent variables, ( A , B , and C .)..one indenendent variable (time) and four Darameters (the four rate constants). A prbgrah has been written to simulate 406 / Journal of Chemical Education

Figure 1. Sample execution of a program simulatingthe kineticsof a two-step equilibrium.

program can he used to obtain answers to such questions as the following. 1) Under what conditions is the steady state assumption valid? 2) How fast is equilibrium reached with various values of the

specific rate constants? 3) Under what conditions does a maximum in B occur?

Tahle 1contains brief descriptions of ten function evaluation programs which have been used a t the University of Pittsburgh. Closed-form expressions are available for four of the programs in Tahle 1;CONTOUR, NERNST, NMR, and SOL. BOX uses the iterative hinarv bisection method to find the roots of a transcendental function. ENTROPY uses a matrix diaeonalization routine to find the orincinal moments of inertia Ghich are needed to calculate thdrotational entropy of the molecule. GASEQ, HNA, and HNATRN use the Newton-Raphson iterative method to find a root of a polynomial, and VDWGAS uses a closed-form cubic equation routine. Reference (3) contains detailed documentation for these proerams and ap~roximatelv40 more simulation and data rkduition programs.

chemical education community is linear regression analysis (18).The sample execution in Figure 2 is typical. One advantage of such a program is that students are forced t o consider the errors associated with their results. For example, the use of such a program makes it feasible to require that a student report his or her rate constant as 6.1 f 0.2 sec-1, in order to avoid having it reported as 6.12594 sec-1. Another exam~leof a data reduction oroaam that has heen used successfull; for several years at t i e Gniversity of Pittsbureh is a oroeram to reduce acid-base titration data. The d e n t s in'thesophomore-level quantitative analysis course use a program to approximate the two thermodynamic dissociation constants of P-alanine from titration data they have collected in the laboratory. The two dissociation reactions are: H3NCHRCOOH+ * Hf

+ H3NCHRCO0

KI

H3NCHRCO0 = H+ + H2NCHRCOOKz Here HaNCHRCOO represents 0-alanine in the zwitterion form. The equilibrium constants are

Data Reduction Programs

Data reduction woerams read student data and oerform the required m a t h e k a & l analysis. Such programs add a new dimension to. the calculatine Dower of students and allow a more sophisticated treatment of experimental data than would be feasible without a computer program. Probahly the most popular data reductibn program in the

Table 1. Name BOX

CONTOUR

ENTROPY

Ten Function Evaluation Programs Description

Calculates eigenvalues and eigenvectars of a particle in a finite and infinite weli. Parameters: mass of the particle, width of the weli, magnitude of the well potentiai. Physical chemistry. Calculates and displays using "teletype graphics" electron density contour plots of Certain atomic, hybrid, and molecular orbitals. Parameters: the orbital, the effective nuclear charge, and for molecular orbitals, the intwnuclear distance. Genetel and physical chemistry. Calculates the molar entrow of a qas from spectroscooie data. Parameters numoor of atoms onthe malec~lo.mearily, and COnrOmaleS of eaCn atom re1at:ve to an ilrolrary orqin, tempera w e . oresue.. wmmew l a n a , muh 0 ic tv and the 1-ndamenm , vibration frequencies. ~kysicalchem;stry.' Solves gas phase equilibrium problems associated with the reaction

K 2 = (OH+)(OH~NCHRCOO-)

aHaNCHRC00 Two titrations are performed

-

Part I. HsNCHRCOO + HC HsNCHRCOOHC Part 11. HzNCHRCOO + OHH20 + HsNCHRCOOA standard HCl solution is used as the titrant in Part I, and a standard NaOH solution is the titrant in Part 11. The input data includes the initial concentration and volume of the amino acid solution, the concentration of the titrant (HCI or NaOH), and the titration data, i.e., the volume of the titrant

.

GASEQ

aA+bB=cC+dD

HNA

6

Parameters: a, b, c, and d; initial number of moles of A, B. C, and D: the absolute temperature: the volume; and an initial approximation to the equilibrium extent of reaction in moles. General and physical chemistry. Solves the set of acid dissociation, buffer, and base hydrolysis problems involving the acid systems HA. H2A, and H.A. Parameters: total concentrations of all acid and sodium salt species present, the relevant acid dissociation constants, and an initial aooroximation to the eouilibrium oH. General and analvtical . ChCmlElry Smualea m e weak ac &strong oara t tration rfrtamr involving hA, n,A and ?13A Parameters nmber of actd c protons, concPntratlon an0 vo "me of aclo ac d d saoc at on constants and concentratio; of base. ~ e n e r aand i analytical chemistry. Cabuiates the potential of thereversibieelectrode MIM*inan aqueous ammonia solution as a function of pH. Parameters: the charge and coordination number of the metal, the standard reduction potential and the stepwise metal-ammonia formation constants. General and analytical chemistry. Simulates AB. ABa ABa AaX2,and A& NMR specha. Paramp ters: chemical shifts and cwpling constants. Organic and physical Chemistry. ,, as a function of pH. The Calculates the solubility of the salt MA anion A'- hydrolyzes to form zacids. HA"-']-. H2A'FZ' . . . . , H,A. Parameters: ionic charges, solubility product, and the acid dissociation constants. General and analytical chemistry. Solves the van der Waals equation of state. Parameters: van der Waals constants, temperature, pressure. General and physical rhamishv

.

HNATRN

NERNST

NMR

SOL

VOWGAS

The uariancr ,IF Thc

i

bhr

Cir

is

coirrlation c n ~ F F i r i e n t ir xiil

wlil

0.04271

0.9999 Y i i l

a+h'xiii

oifr

..*..*..*. *...*.................*,**.*., Figure 2. Sample execution of a linear regression analysis.

Volume 57. Number 6. June 1980 1

407

and the observed pH. The program echoes the input data for verification purposes, and prints a table containing observed volume and pH, the ionic strength of the solution, the univalent activity coefficient, and the calculated thermodynamic dissociation constants. The program also calculates the average value and standard deviation of the dissociation constant. The sample execution of this program shown in Figure 3 contains only the first part of the two-part sequence. The calculations involved here are sufficiently tedious that they would probably not he required of students without the assistance of a comouter oroeram. This oroeram is one of . . many examples that could he cited of how computer programs are used to extend the exoectations of students in lahoratorv courses without significantly increasing the time demands of these courses.

-

experiments that have heen used by studentsat the University of Pittsburrh - in -general andlor analvtical chemistrv courses. These programs provide access by students to chemical concepts and calculations that can enrich both the lecture and laboratory components of chemistry courses.

........................................ his program simulates the determination o f the percentage of acetic acid in a sample of vinegar.

mar is your name? Analyst

.J.

Eello J. Analyst. standardization of N ~ O H Solution

1.

Computer-Simulated Experiments

Computer programs can he written to simulate experiments in the sense that simulated data are tabulated and/or plotted, and the student is required to reduce the data and draw the appropriate conclusions. These programs are not designed to replace experiments. Rather, they provide a pre-lab exercise if the experiment will he performed by the students, or a homework exercise if the experiment cannot be performed for some reason. Consider, for example, an experiment to determine the percent by weight of acetic acid in a sample of commercial vinegar. It is not difficult to write a computer program to generate the output shown in Figure 4. There are four variables in this simulatedexperiment: the percentage acetic acid in the vinegar sample, the concentration of the titrant (NaOH): the weights of the orimarv standard. ; ;he "ex~erimental potassium acid phtIkate ( K ~ P ) and error" that is suoerimoosed on the calculated volume of NaOH. These vtll;es ark all calculated hy a random nurnher eenerator which is initialized usinr the student's name. The student executes the main (ACETIC), and analyzes the data a t his or her leisure. The oromam ACEANS prompts the student for the results and repli& with a congraiulat&y message if the relative errors in the average weight percentage and the standard deviation are within a snecified tolerance. Table 2 contains descriptions of ten computer-simulated

~ h r e esamples of KHP w e r e weighed and dissolved using 50.00 m1e of "20. =he following titration data were obtained. Titration

11.

Vol. NaOH (mls.)

Weight (9.1

Titration of vinegar

Three 10.00 ml aliquotn of vinegar * e r e diluted to 100.00 rnls with A 2 0 . The following titration data were obtained. Titration

volume NaOH

1

24.87 als. 24.54 mls.

2 3

24.96

mls.

NO" 3. Analyst, calculare the average valve of the

percentage by weight o f aceric acid in the vinegar. Also, calculate the standard deviation ol this average.

........................................

The program &CEI\NS will check your results.

Figure 4. Simulation of an experiment to determine percent acetic acid in commercial vinegar.

Table 2. Program A0

Ten Computer-Simulated Experiments Description

Simulates of the reversible kinetic system

!!.

A-B

Bnler the initial volume of the b-alanine solution >,a0

KC

The student calculates E.I, and the enthaipy change for the reaction. Simulates the ChrOmatograDhic determination of an unknown ternary mixture. Smulates the determination of a binary mixture containing NaHC03, Na2C03,andlor NaOH by titratlon with standard HCI solution. Simulates the sl;ectrophotometric determination of the d i s c ciation constant of an indicator. Simulates the equilibrium system

KlNETi

The student determines the equilibrium constant from spectrephotometric data. Caicuiates concentration-time profiles for the reaction

CHROM C03 KA

>7.66

pH

xoni.2 Strength

Activity Coefficient

3.6

.11.49

7.66

1.60

7.11E-03

0.906

11.49

3.42

1.03842

0.888

15.12

1.28

l.llE-02

0.873

3.42

>15.12

1.28

>19.15

1.11

.22.98

2.98

.26.81

2.82

>10.64

2.67

>O

Volume

A+B+C-0

19.15

3.1,

1.61s-02

0.862

22.98

2.98

1.87E-02

0.812

NEUTRO

26.81

1.82

2.11E-02

0.811

QUAL

30.61

2.67

2.3LE-02

0.831

0

SALTS STEEL Figure 3. Sample execution of data reduction program fw ecid-base titration.

408 / Journal of Chemical Education

The studem determines the rate law and the activation enam ". of the reaction. Simulates the analysis of an unknown binary mixture by neutron activation analysis. Simulates a subset of the inorganic qualitative analysis scheme. The student identifies up to 4 of 13 cations Corn groups 1.2. and 1 ". Simulates the analysis of an unknown mixture consisting of NaCI. NaBr. Nal, and NaN03 by potentiometric titration with standard AgNO.. Simulates the spectrophotomehic determination of Mn in a steel sample.

Other Programs An example of a program t h a t does not easily fit into one of the preceding categories is ID, a version of t h e twenty questions game. T h e ohjective of the game is to identify a n unknown inorganic compound by asking aseries of questions, the answers to which are either yes or no. T h e unknown is chosen randomly from 100 inorganic compounds. T h e questions are identified by numher, and are listed below:

1. Does it contain an element from Group I? 2. Does it contain an element from Group II? 3. Does it contain an element from Group Ill? 3. Does it contain an element from Group III? 4. Does it eontain an element from Group IV? 5. Daes it contain an element from Group V? 6. Daes it contain an element from Group VI? 7. Does it contain an element from Group VII? 8. Does it contain an element from Group VIII? 9. Daes it contain an element from period l? 10. Does it contain an element from ~ e r i o d2? -~ ~-~~ 11. Does it eontain an element from period 3? 12. Does it contain an element from period 4? 13. Does it contain an element from period 5? 14. Does it contain an element from period 6? 15. Does it contain a metal? 16. Does it contain an oxyanion? 17. Does it contain a transition metal? 18. Is it an acidic oxide? 19. Is it an acidic salt? 20. Is it a basic oxide? 21. Is it o basic salt? 22. Is it a binary compound? 23. Is it a gas at 2 5 T ? 24. Is it an ionic compound? 25. Is it a liquid at 25"C? 26. Is it a neutral salt? 27. Is it an oxide? 28. Is it n ternary compound? 29. Is it a solid at 25"C? 30. Is it soluble in water? ("Soluble" means that at least 10 g of the compound dissolves in 100 g of water at room temperature. The compound is considered "not soluble" if it reacts with water.) Each question has a numher of points associated with it. The ohjective of the game is t o identify the compound while scoring the minimum numher of points. When the student is ready t o identify the unknown, 0 is entered for the question numher, and the computer prompts for the formula of the compound. If the answer is not correct the student is assessed 5 points and asked whether he or she wants t o continue. Many students are willing t o spend hours a t computer terminals playing Startrek, chess, and other games. There may be a message here for chemical educators. Comments Some of t h e reasons why simulation and data reduction programs have heen so widely implemented are listed below.

1) They are easy to write. The time required to implement and maintain simulation and data reduction programs is considerably less than that for CAI and CATC systems. 2) Most simulation and data reduction programs can be used either in batch or in time-sharing made. If the program is interactive like (JIJAL or ID.. then a time-sharine- svstem is reauired. This ~~. . is not the case lor moat of the programs mentioned above. 3) The lahoralury ruperwnce for must undergraduates ran h~ s~gnKican~ly rnrirhed ~f the student hns wmkecl through c h ~ data analysis hrlore coming tu the lahorntory. 4 ) One task sometmes nut adequately performed by chemical eduraton is the stimulation and challenging ul highly motivated and well-prepared students. Some of the; students are bored with chemistry classes because the lecture is often pitched ta the middle of the class. Computer programs can provide a powerful tool to allow such students to discover how chemical systems respond to arbitrary changes, and to simulate rather involved experiments that these students will find challenging. 5) The eomputer-simulated experiments can be written so that they are self-grading homework exercises. The student works on his or her data until the derived parameters are correct within the allowed error tolerance. These . Draerams have been useful .. both ns required and optional homework .saignments. Many students uill find the timetoearn a 1eu.errrnpomtsmncourse itoptiunal arjignmcnrs are made availnhlr.

.

~~

~

~

~

-

~

~

T h e programs discussed above, the remaining programs in the author's library of simulation and data reduction library, a library of 50 CAI programs written in CATLYSTRIL ( I ) , and a 450-subroutine CATC system (19) are available for a $25 postage and tape handling fee. Some of the author's programs and several more simulation and data reduction programs are available from CONDUIT (20). Literature Clled

19x0. > l r I s ~ r h o nIs . A . Chsmi.rr) v n n aCompanor." Fdrromp. Hartlord CI nn 1976. 'Fortran I V inChrnu,q ' J .nn Y'lle\. Nsu \ ~ r k1971. 51 Mr.. h.,; i t s, l t m r g . I. . e l .I ' R W C s n d C h e m , . ~ " 11 .rrr.t. n \I i n n . Heal m 1975. H ."l'rvhlemin.~~ny i h ~ i ' h y s < aCnsm .lrv " l Y c * l \eu York. 19%. 1 - 1 Rlxk 30 W . I k m 3 C., a 8 1 , ' I n t r ~ d . o ~ W!mI