Letters to the editor

To the Editor: The computer program described by Bard and King. [TEE JOURNAL, 42, 127 (1965)l for chemical equi- librium calculations is timely and va...
6 downloads 13 Views 1MB Size
LETTERS To the Editor: The computer program described by Bard and King [TEE JOURNAL, 42, 127 (1965)l for chemical equilibrium calculations is timely and valuable since programming is becoming an ever more important tool for the chemist. I wish to comment here on two aspects of the approach taken in this article. First, the technique of Bard and King is based on the existence of two "master variables" which are the

624

/

Journal of Chemical Educution

initially unknown concentrations of two chemical species in an equilibrium system. The system of simultaneous equations governing the concentrations of all the species present then has the property that the concentrations of the remaining species can be calculated directly from the master variables using all but two of the simultaneous equations. The assigned and computed values of the unknowns are then checked for consistency in the two remaining equations and the

values of the master variables are altered systematically until these two equations are satisfied. It should he noted, however, that in a great many equilibrium prohlems only one master variable is required. For illustration, in the tribasic acid computation of Bard and King, Example 1, the equilibrium conditions are K, = [H+l[OH-I (1)

and the electrical neutrality and material balance conditions are, respectively, 3

[Hf]

n[&-.A-s]

=

+ [OH-]

(3)

Newton-Raphson method, the authors mention the convergence problems associated with these last two approaches. This problem, which is either divergence or slow convergence, can be largely circumvented in equilihrium calculations by the use of an appropriate technique for the extrapolation of several successive approximations (see "Numerical Methods," by R. A. BUCKINGHAM, Sir Isaac Pitman & Sons, Ltd., London, 1957, p. 258). I n the case of iteration, for example, if xo,XI, and x2 are three successive approximations to a root x, it can be assumed that the errors in this sequence approximate a geometric progression, i.e., z-xg=a z - X I = a?

(8)

n=l

Eliminating a and r from these three equations in three unknowns results in where C, the total acid concentration, is 0.2 M. If a value is assigned to [H+] only, the [OH-] can be calculated from equation (1) as (5) [OH-] = KJH+I-' Using equation (Z), the concentration of three acid ions can be written as [H,,A-"1 = K.[H,,A-"+'I[H+l-' = B.[HAI[H+l(6)

nK,. n

withn

=

1,2,3, and 8,

=

Substituting equation

i= I

for the approximate limit of the sequence. If this extrapolation is carried out after every third successive approximation and the result is used as the next approximation, then a rapidly converging sequence can be generated from a slowly converging one, or a converging sequence can be generated from a diverging one.

J. G. EBERHART

(6) into (3) and solving for [H,A]

from which [ H A ] can be calculated using the previous values of [H+] and [OH-]. With this result the acid ion concentrations can he calculated from equation (6). All the original equations have been used to this point except (4), which then gives the value of C associated with the original choice of [H+]. The value of [H+] can then he varied systematically as done by Bard and Ring to find the [H+] assignment necessary to produce a total concentration of C = 0.2 M . This alternative approach involves somewhat more preliminary algebra than that of Bard and King but a considerable economy of computing results; the calculations can even he made on a desk calculator, perhaps with the aid of a plot of [H+]versus C. I n Example 2, however, two master variables are required due to the greater complexity of the simultaneous equations. Thus a general computer program would require the use of two master variablesbut could be easily modified to employ only one with sufficiently simple equilibrium computations. Second, in comparing their systematic trial-anderror approach with the method of iteration and the

E~ITOR'S NOTE: The exchange of correspondence on these pages relates to an article in the March issue. The general theme, the use of computers for equilibrium calculations, is also that of the two preceding papers in this issue. We offer apologies to readers and correspondents for the delay until these sevenpages all could appear together.

To the Editor: The computer program by Bard and King [THIS JOURNAL, 42, 127 (1965)l illustrates two very important points concerning the solution of scientific prohlems by the use of high-speed digital computers. When a computer is used for solving a problem we usually use methods quite different from those we would use for solving the same problem by hand or on a desk calculator. Further, if we are going to the trouble to write a computer program, it is worth while to select a general method which is applicable to a large class of prohlems, so that the program will be useful for problems beyond a specific narrow application. The problem which Bard and King discuss, that of finding the concentrations of various species in an equilihrium mixture, was considered by White, Johnson, and Dantzig [J. C h a . Phys., 28, 751 (1958)l by quite different methods several years ago. Since the equilihrium condition represents a minimum in the Gibbs free energy of the system, they solve the problem by minimizing the free energy. They discuss two numerical methods, the method of steepest descent and the method of linear programming, both of which are quite general and efficient methods for solving this problem. As was pointed out by Eberhart above, even if the present form of the equations are used, iteration or Newton-Raphson or some similar method could be found which would converge rapidly. Furthermore, Volume 42, Number 1 1 , November 1965

/

625