Programmable calculators: Some practical aspects of simulated

Swinburne Collegeof Technology. Hawthorn, Victoria 3122. Australia. Programmable. Calculators. Some practical aspects of simulatedexperiments. Compute...
0 downloads 0 Views 2MB Size
I. G. McWilliam Swinburne College of Technology Howthorn, Victoria 3122 Austrolio

I

Programmable C U ~ ~ U + O ~ S Some practical aspects

of

simulated experiments Computer simulation ( I ) allows the investigation by a student of experiments which cannot be conveniently done in the undergraduate laboratory hecause of limitations imposed by time, cost, or experimental difficulties. I t also provides an opportunity for the student to investigate rapidly and without manipulative limitations the behavior of a laboratory experiment under a wide range of operating conditions. By this means he can decide what the important variables are, and their desirable experimental values, before he carries out the time-consuming laboratory He thereby participates in the alK important planning phase of the experiment; an experience which undereraduates eain all too infreauentlv. The developm&t of large scale integrated circuits, the basis of modern "fourth generation" computers, has made possible the production of relatively cheap bench-top electronic calculators. With the incorporation of memories for the storage of information and means for repeatedly retracing the steps in a calculation ("programming"), a wide range of experiments can now he simulated with machines costing on the order of $600-1000 (2). Furthermore, there have been substantial decreases in the prices of these calculators over the past two years and this trend can be expected to continue. Programmable calculators vary widely in the facilities they offer. Some have a range of inbuilt functions, of which the most important for the chemist are and log X. Others have only but this can be used to generate the other two functions by approximation methods. In that case, these functions should be available as subroutines which can he called as required by the main program. In comparison with a computer, the number of memories and the allowable number of program steps are severely limited, typical values being ten memories and 200 program steps. This limits the range of applications, and some Dromams need to be desimed to economize on memory and/& program space requirements. Nevertheless, the Maxwell-Boltzmann distrihution function for molecular velocities (3)

m,

can be calculated on the Canon 164P programmable calculator, which has only four memories, no inbuilt expo-

482

/ Journal of Chemical Edocafion

nential, and a maximum of 64 program steps, by rearranging the expression to give

which eliminates redundant calculations. The conditions which prevail in the simulation of a laboratorv exneriment should be similar to those found in the labora"tory. This implies that appropriate errors should be included in the simulation results. The distribution of errors should approximate a normal distribution, and a function is required to generate these errors since there is insufficient canacitv in small calculators to store tables of errors. The nonreversibility of time is also a limitation which should he respected if we desire to provide realistic conditions. For example, in kinetics exercises it is frequently desirable that the student be prevented from repeating earlier calculations unless the entire experiment is repeated. A similar situation exists in simulated titrations. Some form of "nonreturn function" may therefore be necessary, although many recent programmable calculators have inhuilt logic, or jump, functions which provide this facility.

. -

Generation of e - X For X < 1, e c X can he obtained from the expansion

The rate of convergence of this series depends on the value of X. For X E 1 a large number of terms are required to achieve a reasonable degree of accuracy but for X E 0 the first few terms are adequate. The latter situation can be achieved, and the expansion can be used for X > 1. if the left-hand side of the above ex~ressionis re-

Presented at the Royal Australian Chemical Institute Symposium on "Trends in Chemical Education," University of Queensland, May 16-18,1973. Division of zero by zero stops the 164P calculator, and gives zero on the 167P.

0

m

tm

mxc

TIME Figure 2. Simulation of firrt-order reaction

Figure 1. Distribution of errors.

and the expansion is carried out in terms of X/N (4). For most chemical calculations the first three terms of the above expansion are sufficient. The expression is rearranged to give e-x

-

(1 - XIN

+ X2/2N2Y = (((1 - X/N)z + 1JI2Y

since the latter form can he programmed without using one of the calculator memories. With N = 64, which requires 25 program steps on the Canon calculators, the maximum (absolute) error is 0.00005 for X = 4 ( e r X = 0.01832), and less than 0.00001 for X < 1. Log X

Log X could he obtained in a similar manner by using the expansion 1

1

which requires only one additional program step. There are two distrihution curves for each function because of a peculiarity of the Canon 164P and 167P calculators. In the IMP, ( - X P 2 = - IX1'/2, whereas in the 167P, (-X)'I2 = IX1'/2. The former results in a symmetrical distribution of the errors, whereas the latter gives an asymmetrical distribution. The program steps used to generate the error and to incorporate it into the final result are shown below for the 167P calculator. We shall designate the result of the required calculation as Y and assume that this has already been stored in memory 1. Keyboard Step entry Result 1 RM4 Recall previous enor, E, from memory 4 2 T Ell2

-4

1

F'Z/l

5

RV

Reverse, i.e., interchange numerator and de-

1

In(l+X)- X-5X~+3x~-zx'+...(-1 0 or to stop it if (tz - t d < 0, i.e., if the student attempts to repeat an earliercalc~lation. With calculators which do not have inbuilt logic facilities, similar results can Be obtained by use of one or more of the expressions

Expressions f(i) and ffiii) are positive for X > 0 and zero for X < 0;whereas with expressions ffii) and ffiv) the reverse is the case. Furthermore, expressions ffiii) and f(iu) are dependent on the sign of X, hut not on the absolute value of X. Examples are given in the table below.

6)

X 2 1 0' -1 -2.

4

2 0

0

n

Expression

[ii)

(iii)

(iu/

0 0 0 2

2

U

2

0

0

2

4

0

-

*

*

2

If we have two functions of X, fifX) and fz(X), we can write f,(X) f(iii) f f,(X) f(iu) = 2f,(X) for X > 0 = 2fXX) for X < 0 An expression similar to f(ii), above, arises in the sirnulation of the titration of a strong acid with a strong base in which the program employs the expression (5)

484

/

Journal of Chemical Educafion

where y =. xMI2V and x is the volume of titrant measured from stoichiometry, M is the molar concentration of titrant, and Vis the total volume of solution. Additional Comments The above examples and discussion have stressed the use of programmable calculators for the simulation of experiments. As a bonus, these machines are also always available for general numerical calculations. However, there are two further important applications. The first is to teach students elementary computer programming. The program steps used with these small calculators are very similar to those used with conventional computers, and the small machines can he used for many of the elementary programs which waste time on larger computers. Furthermore, there are no format problems with most programmable calculators. Secondly, instead of asking students to use prepared programs, they can he asked to devise their own. T o do so requires a detailed understanding of the problem, and there is no doubt that this teaches the student much more than just running through a prepared simulation pmcedure. However, it also means that the student must be able to spend a considerable amount of time on one particular problem. This is achieved a t Swinburne by including the development of simulation programs in the final year chemistry projects. Acknowledgment The author thanks the Churchill Trust and the Council of Swinhurne College of Technology which made possible visits to both Hamline and Heriot-Watt Universities during 1972. Mr. F. Bishon of Bleaklev Grev Cor~orationPtv. L;. for the loan of a printer, Mr.'E. ~ a l f r e y m a nfor valiable discussions on the generation of logarithmic and exponential functions, and Miss V. Patton of Monash University who prepared the diagrams. Further work on this project is being funded by a grant from the Australian Commission on Advanced Education. Literature Cited (11 Soe.c.g..Tsbhutt. F.O.,Chem & E ~ R . N P u I48,M(Jan. s. 19,19701. (21 Runqni~f,0 . . 0lsen.R.. and Snsddon, 8 . 5 . C H E M EDUC.. dl,265(19721. 131 Daniel% F.. and Albeny, R. A,, "Physical Chemistry," John Wiiey & Sons, Inc. 3rd ~ d .NY.. . I!~RB.~~~oI-~M. (41 Pallreyma".E.. prrsunalcommunieation. A . R.. . - ~ ~ iof ~~ ~ ii ~ ~iA ~~~~I~~ J ~i R.I.C. S : .~ A,,,l,, , E,, 1 ~ l for~eachers. ~ ~ NO.~ 6.1 9~6 2 . ~ ~1 3 . ~ ~ h ~

,,,

..,

~

~

~