A short program for the automatic calculation of pH in solutions having

Citation data is made available by participants in Crossref's Cited-by Linking service. For a more comprehensive list of citations to this article, us...
0 downloads 0 Views 2MB Size
Derivation of a General Formula

gram. Table 1presents a typical set of student experimental results. The program is available from Project SERAPHIM.

Consider an aqueous solution of L acids (H,A, HmB,. . .). The apparent dissociation constants are:

A Short Program for the Automatic Calculation of pH in Solutions Having Many Acids or Bases

and the total concentration of each acid is

Juan Mlguel Campanarlo and Reyes Ballesteros Universldad de Aicala 28871 Alcala de Henares Madrid. Spain Much time in analvtical and eeneral chemistry courses is devoted to introduring students to methods to calculate the oH of solutions. Althoueh the whole theoretical framework is frequently presented; calculations very rarely deal with solutions in which more than one monoprotic acid is involved. When several hydrogen ions are dissociated from the acid, different approximations are usually carried out in order to facilitate calculations. When there are several acids in solution, a set of formulas is presented to students comprising different possible cases (e.g., strong acidlweak acid, weak acidlweak acid). This does nothing but increase arhitrariness and decrease the logical meaning of the subject to be learned. As a consequence, many students, and even graduates, have difficulties in selecting the formula that will he most convenient in a special case. Thus, it is not rare that students use rote learning strategies instead of meaningful ones. A new approach using computational methods is presented in this paper. In the same way that modern calculators have removed logarithm tables (essential in the past for pH calculations) from classrooms, it is useful to introduce computers into laboratory and classroom as a calculation tool. Students' understanding of general principles and scientific theories is preferable t o devoting their efforts to carrying out overwhelming calculations that contrihute little to their scientific training, which can even increase students' tendency toward using formulas without a full understanding of general principles. For example, i t is not surprising that a student could obtain pH = 9 from a 10-9 M HC1 solution. This student has followed the rule: "When dealing with a strong acid, the hydrogen ion concentration is the same as acid concentration." H e or she has forgotten, or never understood, that when an acid concentration is very low, the concentration of the hydrogen ion from water is greater than that from the acid itself, however strong it is. All these problems can he overcome by using computational methods. In this paper we describe a short GW-BASIC program for pH calculation. Mass adion law and the electroneutrality condition are the basis of classical methods for the derivation of equations that may be used for pH calculations. However, the problem has never been treated as a whole. and. as we have already pointed out, different approxima;ionshave been used. The short GW-BASIC proeram nresented here tries to facilitate thestudents pH calcurations in problems dealing with an arbitrary number of acids without the common specifications that we have already seen. This new approach takesaccount ofall the dissociations that contribute to hydrogen ion concentration. Furthermore, the strong acids are treated in the same way as the weak ones by assuming an arbitrarily high constant without additional simplifications. The program can also quickly compute the concentration of any chemical species in solution.

Hydrogen ion concentration is solution is [Ht] = [OH-].,

+ [H,_,A-] + 2[H,_,A2-1 + 3[H,_,A3-]

+ . . . + n[A"-] + [H,_,B-] + 2[H,_,B2-] + 3[H,_,B3q + . . .+ m[Bm-1 + (other acids)

(5)

The first term of eq 5 is the hydrogen ion concentration from the dissociation of water. The remaining terms represent the contribution of successive dissociations of each of the acids in the solution. The hydroxyl ion concentration from Hz0 can be obtained from the K , constant:

A similar equation for a solution containing a given numYm-, . .) can he written in the following ber of bases (Zn-, form:

.

+ [HZ'"-"-] + ~[H,z'"-~'-]+ 3[H3Z'"-3'-] + . ..+ n[H,Z] + [HY'"-"-] + 2[HZY'm-2)-]+ 3[H3Y'm-3)-]

[OH-] = [OH-],,

+ . ..+ m[H,Y] + (other bases)

(6)

In eq 5, the H,-,A- ion concentration can be calculated from eq 3 and from the group in eq 1.

Reducing eq 7 to a common denominator we obtain

and

~

1038

Journal of Chemical Education

If we r e p e a t t h i s c a l c u l a t i o n f o r H,-zAZ-, . .. , Bm-, . . . , we can H,_3A3-, . . .An-, H,-,B-, Hm_~B2-, see that the denominator for each species always has the same mathematical expression as in eq 8. The numerator for the H.-,A,- ion is formed by the j 1addend of the denomi-

+

nator. Then, the general equation of [H,-jAj-L_,, is the wellknown expression (5):

value of pH, and, if the user wants, once a final value has been computed for the hydrogen ion concentration, the program starts to calculate the concentration of any chemical species.

A Spreadsheet Type I/O Interface for C, Fortran, and Pascal The same result can he obtained from eo 2 and eo 4 for each one of L acids in solution. B~replacing 2 1 these &pressions in eq 5, the next general expression is obtained

I-!

L represents the total numher of actds in solution; P, is the number of hydrogen atoms of acid number y in the solution, and K... is its dissociation constant number i. \Ve obtain an equation expressing hydrogen ion concentration as a function of hvdroeen ion concentration. which can he iterativelv solved.'fod~so,thehydrogen ion~oncentrationtermon thk left side is moved to the rieht side. and a function of hvdrogen ion concentration is obtained. Then, the bisection method is used. Two extreme estimates of hydrogen ion concentration are assumed, and two values of tGe function are computed. Next, the interval between the estimates is halved, and those values in which the product of the function values a t the interval limits is always negative are taken as the new extremes. This nrocess is reoeated until two oH values that differ only in a'given small amount are found.kn arbitrarilv hieh K,, constant is assumed for the calculation when an acid-is v& strong. Once the hydrogen ion concentration has been comouted. the concentration of anv chemical species in solution can be calculated from eq 9. We often need to compute the pH of polyprotic acids in the laboratory. I t is necessary to make approximations in order to carry out these calculations. The method we propose here avoids this sort of approximation, although eq 10 can be considerably simplified in some cases (strong monoprotic acids). This calculation method, of course, can be applied in the same way to solutions having many bases. While eq 5 is different for bases (eq 6 ) , t h e generic equation of [H,Z("-j'-lj5, and C1 as the total base concentration, can be written as a function of OH- ion concentration according to the expression: Y.

Kbli is defined according Kb,, = K,IK,, and Klj is the apparent dissociation constant number i of the corresponding acid of the base. Thus, for a solution with many bases, a general equation similar t o eq 10 can be obtained from eq 6. I t is only necessary to replace [H+] with [OH-] to do so. The calculation algorithm works for solutions containing many acids and for solutions containing many bases by writing [Ht] or [OH-] and the corresponding constants. T o carry out the calculations it is useful to write a computer oroaram. The listine of a GW-BASIC promam for IHMPC an> compatibles C&I be secured by k i t i n g to the first author or from Project SERAPHIM. The program obtains a

Roy Karl

Laurentian University Sudbury, ON, Canada P3E 2C6 Coding YO for any complete program is always a chore since the program should have editing capabilities for input and the output layout should be pleasing to the eye and be properly organized. In addition to easily coded 110, the program should have error recovery procedures so that invalid input will not cause the computer to hang or cause the program to abort back to the operating system. Most BASIC, FORTRAN, and C noncommercial programs support interactive line editing input hut more complex noncommercial oroerams often resort to innut done via the readine of a file khGh has been previouslybrepared with the aid of an ASCII text editor. Erroneous input can thus be easily corrected and the program run again until all of the errors are eliminated. The outout is directed to the screen or orinter on the user's command: Error recovery procedures can be coded into these proerams but coding error recovery routines is often tedious and laborious and the usefulness of error recovery procedures is of questionable value if the input is via an ASCII text file. The success of commercial spreadsheet programs is partly attributable to their ability to let theuser define the layout of the input and output and to their almost perfect error recovery procedures. Becausethe spreadsheet programs are so versatile, one generally now writes a template for the spreadsheet program rather than a program in a high-level language such as BASIC. However, spreadsheet programs do have two important limitations; first, the applications are limited to those that can be programmed using the functions available within the spreadsheet oromam and second, spreadsheet program execution is v&slow compared to dedicated compiled language programs. Considering the versatility of spreadsheet programs, the ideal solution would seem to be an Application Program Interfaces (API) . . to the snreadsheet nroeram. These API's would allow the user t o write a compiled language user program that would get its input from the spreadsheet cells, proceed with the calculations, and finally feed the output back to the spreadsheet cells. Unfortunately, such API's are generally not available to anyone but commercial software development houses, and, if one is obtained, then the API is specific to one single spreadsheet program. The obvious answer to the I10 dilemma in FORTRAN and C is to write a spreadsheet-type interface module that contains all the spreadsheet commands hut no spreadsheet functions. "SSIO," availahle from Project SERAPHIM, is a spreadsheet-type InputIOutput interface written in Microsoft C. SSIO isdesigned to bea "front end" toenter data into the user application program and t(, he a "backend" to enable the user aoolication to disolav . . the outnut in the SSIO cells. SSIO features include: A spreadsheet-typescreen with cells labeled by columns and rows standard s~readsheetcommands needed to msnioulate the cells (see Fie. 5 for a samole screen with main command menu) lieatio,. at ion l'roiram lnreriace IAIW module [hat simplifies the user pwgrammer'r interiaee with the cell* and allona the user programmer to create menus and prompts and to query the user for range input. SSIO and its API are contained in an object module library that is fully compatible with Microsoft C or QuickC, FOR&

.

~

~~~

~

~

Volume 67 Number 12 December 1990

1037