computer series, 158 PHCALC: A Computer Program For Acidlbase Equilibrium Calculations James E. Kipp Baxter Healthcare Corporation Pharmaceutical Sciences R&D Round Lake, IL 60073 Previous articles on the estimation of pH and acid-base equilibria ( 1 4 )have been invaluable in modeling and interpreting solution kinetics, preparing buffer solutions, and understanding pH-solubility phenomena, among others. The ionic equilibrium problem becomes unwieldy usine - .pen-and-paper . . methods as the number of equilibria increases. In most cases, assumptions are made to simplifi the prnhlem and minimize the computational enbrt. However, most problems encountered in practical work are of sufficient complexity that erroneous simplifications easily can be made (9). We wish to present a program, PHCALC, which has proven to be a powerful tool in the pharmaceutical formulation lab. The program uses a matrix method for ionic equilibrium calculation which greatly simplifies setting up the proper set of simultaneous equations for solution. By using matrix algebra, the generation of an intermediate polynomial is circumvented. The solution of any acid-base equilibrium problem requires solving a set of simultaneous equations consisting of all equilibrium (mass action) expressions, mass balance expressions, and an expression for electroneutrality if calculation of [H+Iis desired. If the pH is unknown, then the set of equations is non-linear with respect to [Ht1. For example, in the pH calculation for a solution containing only polypmtic acid, H.A, n equilibrium conditions apply: Ki =
IH+I[H,,A-~I IH,A~?
JAMES P. &R;( Arizona State University Tempe, AZ 85287-1604
The set of mots contains a feasible solution for the hydmnium ion concentration. For simple problems, such as the calculation of titration curves for a mixture of acids titrated with strong base, the set of equations readily can be reduced to a single equation, and a root-finding algorithm (e.g., Newton-Raphson) applied (5).When a complex mixture ofweak acids and bases is considered, however, reduction to a single equation is not straight-forward. Computational methods which reliably set up the proper system of equations for any acid-base equilibrium problem, and solve directly without intermediate derivation of a polynomial, are needed. Matrix algebra is well-suited to this task, and many fast algorithms exist for solution of simultaneous equations. First, consider the simpler case in which pH is known. Only mass balance and the equilibrium expressions need be considered. All equations are linear, and the system can be solved uniquely by setting up the equations in matrix form. Equations 1and 2 can be rewritten as:
and,
A matrix equation, AS = C, which is equivalent to the system of eqs 3.5, and 6, can be formulated where:
(1)
and
Integer n is the number of acidic protons; i and j are integers, where l