a chemical equilibrium algorithm for highly non-ideal multiphase

14
Geochimrca et Cosmochimica Acfa Vol. 51. pp. 1045 1057 0 Pergamon Journals Ltd. 1987. Printed in U.S.A. 0016-7037/87/$3.W + .oO A chemical equilibrium algorithm for highly non-ideal multiphase systems: Free energy minimization* CHARLES E. HARVIE, JERRY P. GREENBERG and JOHN H. WEARE Department of Chemistry, B-014, University of California, San D iego, La Jolla, CA 92093 , U .S.A. Received February 3, 1986; accepted in revised orm January 13, 1987) Abstract-A method is presented for calculating equilibrium phase assemblages in very nonideal systems. It may be applied to any sy stem for which a thermodynamically consistent model of t he free energy which satisfies the usual Maxwell relations and convexity criterion is available. The algorithm minimizes the Gibbs free energy by independently choosing stable reaction directions. The procedure is described in detail and various numerical problems encountered and strategies for dealin g with them are discu ssed. It will be shown that the necessary and sufficient conditions for solution phase selection may be derived from the values of the Lagrange multipliers correspondin g to constraints on pha ses that are not pres ent in the system. The method for evaluating the solution phase Iagrangian multipliers and choosing the optimum composition with wh ich to br ing the new solution phase into the system involves a separate constrained minimization problem. This method is sufficiently general so that the correct phase assemblage is chosen free from external control. Special pro cedures for adding and removing phases including solution phases are also described. I. INTRODUCTION CHEMICAL MODELS ARE commonly used to interpret field and laboratory measurements. For example, early models based on experimental phase diagrams were used with great success by VAN? HOFT and his stu - dents ( 1905, 1 909) to study marine evaporite systems such as the Z echstein salt deposits and by BOWEN (1928 ) to describe differentiation in silicate melts. Be- cause phase diagrams were used, th ese models could treat only a limited number of component s. More re- cently, a number of workers (GARRELS and THOMP- SON, 1962; HELGESON, 1978; and NORDSTROM ef al., 1979) have developed mathematical models based on equilibrium mass action expres sions which were gen- eral enough to treat systems with many componen ts. Since this work, there has be en a great deal of interest in building chemical models of increased generality. The two important componen ts of such models are (1) the parameterization of a thermodynamically con- sistent set of equations, and (2) the implementation of an efficient algorithm for calculating equilibrium compositio ns (see for example REED, 1982; GHIORSO, 1985; and GREENBERG et af., 1985) . The parameter- ization of an aqueous solution model using the equa- tions of PITZER (1977 ) are described elsewhere (HARVIE and WEARE, 1980; HARVIE et al., 1984; FELMY and WEARE, 1986). These models have been applied to geological problems by HARVIE et al. 1980, 1982) and BRANTLEY et al. (1984). Many algorithms have been proposed for finding the equilibrium composition of a chemical system (SMITH and MISSEN, 1982). For the most part these algorithms have been developed to compute solution * This research was sponsored in part by the American equilibria between solutions and coexisting pure min- eral phases in which the solution species activity coef- ficients ar e slowly vary ing functions of concentration. The reliability of these algorithms generally decreases when they are applied to more complex equilibrium problems. Failure arises from many causes including a lack of general convergen ce criteria, poor selection of reaction directions, and too strong a reliance on the special fo rm of the ideal-solution phase chemica l po- tential. In this article an algorithm of high reliability based on a Newton minimization of the Gibbs free energy is described. The algorithm has been extensively tested on highly nonideal brine systems (HARVIE, 198 1) and on silicate melt solid solution equilibria (GREENBERG et al., 1985) with very high reliability. A somewhat more detailed version of this article is given in GREEN- BERG (1986) . The approach is equivalent to, but some - what more general than, the more comm on approach of solving the mass action equations. In Section II we will derive the converge nce criteria for the minimiza- tion procedure. The method utilizes Lagrange multi- pliers in order to transform the linearly constrained problem into an unconstrained problem. For the most part these methods lead to results that are equivalent to solving the constrained problem. However, the gen- eralization is important for our formal development as well as for the develo pment of the criteria for phase addition. For each step, the algorithm automatically generates a set of orthogonal reaction paths. These reaction di- rections are the result of projection methods that have been previously applied to chemical equilibrium prob- lems (GREENBERG et al., 1985; GHIORSO, 1985) and have in practice been shown to provide stable reaction directions. We will discuss the derivation of these

Upload: joack-raynor

Post on 03-Jun-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: A Chemical Equilibrium Algorithm for Highly Non-ideal Multiphase

8/13/2019 A Chemical Equilibrium Algorithm for Highly Non-ideal Multiphase

http://slidepdf.com/reader/full/a-chemical-equilibrium-algorithm-for-highly-non-ideal-multiphase 1/13

Geochimrca et Cosmochimica Acfa Vol. 51. pp. 1045 1057

0 Pergamon Journals Ltd. 1987. Printed in U.S.A.0016-7037/87/$3.W + .oO

A chemical equilibrium algorithm for highly non-ideal multiphase

systems: Free energy minimization*

CHARLES E. HARVIE, JERRY P. GREENBERG and JOHN H. WEARE

Department of Chemistry, B-014, University of California, San Diego, La Jolla, CA 92093, U.S.A.

Received February 3, 1986; accepted i n revised orm January 13, 1987)

Abstract-A method is presented for calculating equilibrium phase assemblages in very nonideal systems.It may be applied to any system for which a thermodynamically consistent model of the free energy whichsatisfies the usual Maxwell relations and convexity criterion is available. The algorithm minimizes the Gibbsfree energy by independently choosing stable reaction directions. The procedure is described in detail andvarious numerical problems encountered and strategies for dealing with them are discussed. It will be shownthat the necessary and sufficient conditions for solution phase selection may be derived from the values ofthe Lagrange multipliers corresponding to constraints on phases that are not present in the system. Themethod for evaluating the solution phase Iagrangian multipliers and choosing the optimum compositionwith which to bring the new solution phase into the system involves a separate constrained minimizationproblem. This method is sufficiently general so that the correct phase assemblage is chosen free from externalcontrol. Special procedures for adding and removing phases including solution phases are also described.

I. INTRODUCTION

CHEMICAL MODELS ARE commonly used to interpret

field and laboratory measurements. For example, early

models based on experimental phase diagrams were

used with great success by VAN? HOFT and his stu-

dents ( 1905, 1909) to study marine evaporite systems

such as the Zechstein salt deposits and by BOWEN

(1928) to describe differentiation in silicate melts. Be-

cause phase diagrams were used, these models could

treat only a limited number of components. More re-

cently, a number of workers (GARRELS and THOMP-

SON, 1962; HELGESON, 1978; and NORDSTROM ef al.,

1979) have developed mathematical models based on

equilibrium mass action expressions which were gen-

eral enough to treat systems with many components.

Since this work, there has been a great deal of interest

in building chemical models of increased generality.The two important components of such models are

(1) the parameterization of a thermodynamically con-

sistent set of equations, and (2) the implementation of

an efficient algorithm for calculating equilibrium

compositions (see for example REED, 1982; GHIORSO,

1985; and GREENBERG et af., 1985). The parameter-

ization of an aqueous solution model using the equa-

tions of PITZER (1977) are described elsewhere (HARVIE

and WEARE, 1980; HARVIE et al ., 1984; FELMY and

WEARE, 1986). These models have been applied to

geological problems by HARVIE etal.

1980, 1982) andBRANTLEY et al. (1984).

Many algorithms have been proposed for finding

the equilibrium composition of a chemical system

(SMITH and MISSEN, 1982). For the most part these

algorithms have been developed to compute solution

* This research was sponsored in part by the AmericanChemical Society PRF grant 14550-AC2,5-C, DOE grant DE-ACO3-85SF 15522, and the National Science Foundation OCEgrants 85-07902 and 82-08482.

equilibria between solutions and coexisting pure min-

eral phases in which the solution species activity coef-

ficients are slowly varying functions of concentration.

The reliability of these algorithms generally decreases

when they are applied to more complex equilibrium

problems. Failure arises from many causes includinga lack of general convergence criteria, poor selection

of reaction directions, and too strong a reliance on the

special form of the ideal-solution phase chemical po-

tential.

In this article an algorithm of high reliability based

on a Newton minimization of the Gibbs free energy is

described. The algorithm has been extensively tested

on highly nonideal brine systems (HARVIE, 198 1) and

on silicate melt solid solution equilibria (GREENBERG

et al., 1985) with very high reliability. A somewhat

more detailed version of this article is given in GREEN-

BERG (1986). The approach is equivalent to, but some-

what more general than, the more common approach

of solving the mass action equations. In Section II we

will derive the convergence criteria for the minimiza-

tion procedure. The method utilizes Lagrange multi-

pliers in order to transform the linearly constrained

problem into an unconstrained problem. For the most

part these methods lead to results that are equivalent

to solving the constrained problem. However, the gen-

eralization is important for our formal development

as well as for the development of the criteria for phase

addition.For each step, the algorithm automatically generates

a set of orthogonal reaction paths. These reaction di-

rections are the result of projection methods that have

been previously applied to chemical equilibrium prob-

lems (GREENBERG et al ., 1985; GHIORSO, 1985) and

have in practice been shown to provide stable reaction

directions. We will discuss the derivation of these

methods in Section III. While some of the results have

been presented elsewhere in the non-linear program-

ming literature (i.e. GILL and MURRAY, 1974) they

1045

Page 2: A Chemical Equilibrium Algorithm for Highly Non-ideal Multiphase

8/13/2019 A Chemical Equilibrium Algorithm for Highly Non-ideal Multiphase

http://slidepdf.com/reader/full/a-chemical-equilibrium-algorithm-for-highly-non-ideal-multiphase 2/13

I046 C. E. Harvie. J. P. Greenberg and .I, H. Weare

are necessary to derive the results in other sections and

are essential to understanding the algorithm and the

applications to the special case of the chemical equi-

librium problem.

Phase selection presents difficulties for minimization

algorithms, particularly for solid solution phases. We

will present criteria in Section IV to decide when, dur-

ing the course of the algorithm, pure and solution

phases should be precipitated. These phase selection

methods are based on evaluating the Lagrange multi-

pliers corresponding to species that are constrained to

have zero mole numbers. Phase selection procedures

which involve calculating the chemical affinity have

been described (SMITH and MISSEN, 1982: C~HIORSO.

1985: REED, 1982) that are identical to our method

for pure phase selection. For solution phase additionwe have developed a new method that identifies the

solution phase that will result in the greatest initial

decrease in the free energy and provides the optimal

composition at which to introduce it into the system.

We have shown (GREENBERG, 1986) that this method

reduces to the methods of REED ( 1982) and GHIORS~

( 1985) for ideal solutions but is quite different for non-

ideal phases. The method described in this paper as-

sumes that one phase may be brought into the system

at a time. Under certain circumstances, mass balance

may require the simultaneous precipitation of more

than one phase. Such cases are discussed by GREEN-

BERC; 1986).

Several difficulties may arise from the Newton di-

rection calculation. Unstable Newton directions will

result when more phases then are allowed by the Gibbs

Phase Rule are present in the system. We will show in

Section V how a stable direction may be generated by

conditioning the second derivative matrix of the free

energy. Other possible problems that are discussed in

Section V are the phenomena of cycling whereby the

algorithm repeatedly returns to the same assemblage

of phases and the possibility that the free energy doesnot decrease when a full Newton step is taken. We will

present a method that prevents the repeated occurrence

of the same phase asemblage and describe our criteria

for using a line searching procedure that finds an op-

timal step length. Section VII describes an additional

problem that may result from the Newton direction.

Solution species which are present in very small con-

centrations may undergo order of magnitude variations

in directions away from the equilibrium concentra-

tions. Our procedure fixes the concentrations of such

species and, after the problem has converged to the

correct equilibrium assemblage, uses a step similar to

____ __~_~__ - ~~

’ Our algorithm discards all redundant components in orderto obtain a linearly independent set (see the Appendix). Whilecertain mass balance constraints may he redundant and areeliminated in the process of generating reaction directions, itis always important to retain all charge balance constraints inorder to insure that all phases containing charged species re-main neutral.

the phase addition step described in Section \, I to adJust

the concentration of the species.

In Section VI we will describe the calculation ofspe-

cial directions that are modifications of the standard

Newton direction. These directions are used for pre-

cipitating and removing phases and for altering mass

balance. This last procedure is extremely useful Lbr

performing a large number of equilibrium camputa-

tions where good estimates of starting compositions

result in rapid solutions of succeeding problems (r.g

during the calculation of an evaporation sequence or

when incorporated into a hydrodynamic codei.

II. THEORETICAL EQUATIONS ANDCONDITIONS FOR A LOCAL MINIMI.lM

The chemical equilibrium problem for a system alconstant temperature, pressure, and a specified bulk

composition, may be expressed in terms of the follow-

ing constrained minimization problem:

./1

minimize G’= 2 p,II, ’ i /

“’

subject to C Ajln, z 11, I -L 1.VZ, i’

n, > 0 for all J i4I

where C; is the Gibbs free energy. h, is the chemical

potential of species j, nj is the number of moles of spe-

cies j, n’ is the total number of species in the system.

111, s the number of independent components’. .4,, is

the number of moles of component i in one mole ot

species j, Z, is the charge of the jth species in electrolyte

solution phase s, e is the number of electrolyte solution

phases, and bi is the number of moles of each com-

ponent i. The n’ species include species in phases thatare not present in the system. We shall refer to the

constraints described by Eqns. (2) and (3) as mass and

charge balance constraints respectively and to those

described by Eqn. (4) as species constraints. When the

species constraints are satisfied as an equality ({.c. the

concentration is equal to zero) we will refer to them

as active constraints.

We may transform the inequality constraints of Eqn.

(4) into equality constraints by introducing the slack

variables f, (BEIGHTLER and PHILLIPS, 1976. p. 23).

The inequality constraints described by Eqn. (3) are

then replaced by:

nj=t;. li)

When species j is present in the system the correspond-

ing slack variable is nonzero. 1, is equal to zero when

Eqn. (4) is an equality. For any given total composition.

mass and charge balance constraints are never violated

while species constraints may be active (t, = 0) or in-

active (t, > 0) as phases are absorbed or precipitated.

The minimization problem may be solved by using

Eqns. (2), (3) and (4) to directly reduce the number of

Page 3: A Chemical Equilibrium Algorithm for Highly Non-ideal Multiphase

8/13/2019 A Chemical Equilibrium Algorithm for Highly Non-ideal Multiphase

http://slidepdf.com/reader/full/a-chemical-equilibrium-algorithm-for-highly-non-ideal-multiphase 3/13

Non-ideal multiphase systems 1047

variables in the free energy expression. This approach

yields the familiar mass action equations. The numer-

ical stability of this method is in many cases poor.

Usually this occurs because of a poor choice of inde-

pendent and dependent variables in Eqns. (21, (3) and

(4). We will introduce the Lagrangian co~esponding

to the minimization problem given by Eqns. (l-4).

This approach removes the necessity of selecting re-

action directions.

The Lagrangian may be written as (LUENBERGER,

1973):

L=L ii,i,7i,;l,3)=pjFZj-~Ki (Ajinj-b,f

,=I i - l j - l

- 5~ C Zjnj - ~ ( t~ -t f ) (6)i=l j n j =

where Ki s a Lagrangian multipIier for a mass balance

constraint, ni is a multiplier for a charge balance con-

straint, and tij is a Lagrangian multiplier for the jth

species constraint. The effect of using the Lagrangian

approach is to treat the problem as an unconstrained

optimization over all variables including the Lagran-

gian multiplies.

The stationary points of the Lagrangian are obtained

by differentiating L with respect to all variables and

setting the derivatives equal to zero. This gives:

f3Lan = 0 = pi - &&w; - wi

1 i- l

species 1 n a non-electrolyte phase

dLz = 0 = / Js] i A] iK i VsZ] W]

I i =

species 1 in electrolyte phase s

dL

d,1”0’ ~Ajlnj-1? I= l,Cj=]

dLI l ,h=O= C ZjTZj 1= 1,e

j i n

dLt=O=2w,t, I= l,n”

1

1= l,n,.

(7)

(8)

(9)

(10)

(11)

* The notation C = (Z/A) means that the columns of theAmatrix are appended to the 2 matrix to form the C matrixwhere the Z and A matrices have the same number of rows.(If Z is an n’ X a matrix and A is an n’ X b matrix, C is an n”

ii..X a + b) matrix). The notation 7 = = srgmfies that the 7

Kvector is constructed by appending the elements of the ii vectorto those of the ij vector. The matrix I) has elements 1 or 0depending on the phases present (see Table I). The vector 3in Eqn. (12) contains only those elements of wj in Eqn. (7)which are nonzero. The D matrix transforms the Z in Eqn.(12) into that defined in Eqn. (7).

Equations (8), (9) and (11) are the mass balance, charge

balance, and non-negativity constraints on the chem-

ical equilibrium problem. When these constraints are

satisfied, the Lagrangian reduces to the free energy

function. Therefore the stationary points of the La-

grangian yield the stationary points of the free energy.

From Eqns. (IO-1 1) it is seen that at a stationary

point if tl is not equal to zero (species 1 is present), wI

is equal to zero. On the other hand, if wI is not equal

to zero, tl is equal to zero (species 1 is constrained to

be zero). Thus the values of wI will be non-zero when

species I is not present in the system. This is an im-

portant result that will be used in Section IV to derive

conditions for phase selection. The variables lj only

appear in the formal development (Eqns. 10 and 11).

In the actual procedure only the mole numbers arecalculated.

For convenient, Eqns. (7) may be written in matrix

notation as:

ii=c;+03 (12)

where D is the matrix of species constraints, C = (ZIA)

is the matrix of charge and mass balance constraints

li.and Z is the matrix of charge constraints. 7 = : IS the

K

vector of charge and mass balance Lagrangian multi-

pliers.* It is convenient to describe the constraints in

the form of Eqn. (12) since the constraints combined

into the C matrix are never altered throughout the

course of solving the problem while the constraints

described by the D matrix are dropped as new phases

are brought into the system or added as phases are

removed.

An example of the formation of the C and D matrices

in a silicate melt system is given in Table 1. In this

example, the mineral phases CaMgSi20b (diopside) and

MgzSi04 (fo~te~te~ have precipitated (for simplicity

we will neglect solid solution) while the mineral phases

SiO2 (cristobalite, for example) and MgO (periclase)have not precipitated. They therefore have species

constraints which are represented by the D matrix.

Equations (7-l 1) are necessary and sufficient con-

ditions for a local minimum. A global minimum is

obtained when no other root to the above equations

has a more negative Lagrangian or free energy value.

In the context of the chemical equilibrium problem, a

local minimum is a solution for a particular set of

phases while a global minimum represents the equi-

librium phase assemblage with the lowest possible free

energy. Our strategy is to minimize over a particular

set of phases and then determine whether other phases

should be included in the system. In the next two sec-

tions, we will describe our algorithm for minimizing

the free energy over a given phase assemblage and the

criteria for a global minimum.

III. THE MINIMIZATION ALGORITHM

A feasible point is defined to be any system com-

position that satisfies all mass, charge balance and spe-

Page 4: A Chemical Equilibrium Algorithm for Highly Non-ideal Multiphase

8/13/2019 A Chemical Equilibrium Algorithm for Highly Non-ideal Multiphase

http://slidepdf.com/reader/full/a-chemical-equilibrium-algorithm-for-highly-non-ideal-multiphase 4/13

104x C. E. Harvie. J. P. Greenberg and J. H. Weare

Table 1. Example: The Formation of the Mass Bal-mce and Species Constraint Matrices (Systemw-MgO-CaO).

Species

SiO,(liq)

NW

CaO(kq)EdgSizO,(s)4 O )

. 0,(s)

&O(s)

ties constraints (Eqns. 2. 3 and 4). while a feasible

direction is a direction in composition space along

which these equations are not violated. in this section

we will derive conditions for a feasible direction which

will bring the compositions to a local minimum in the

free energy. We will see that when this procedure is

implemented, the algorithm automatically generates

stable reaction directions.

Let the vector 7?(lr) epresent a feasible point for all

species in the system on the kth minimization itera-

tion and nck+‘) the composition on the k + lth step.

We may then define the step direction vector 3 as fol-

lows:

(k+lI _ (k,nj - nj + <?JIF iz 1.n’_ (1.3)

(0 5 (Y 5 I ).

Operating on Eqn. (13) with C’ yields:

We also wish to impose the condition that the active

species constraints (Eqn. 4) are not violated by the step

direction. This gives:

DTj Tk = 0. (IS)

We can combine the C and D matrices to form the n’

X m matrix (CID) where m is the number of indepen-

dent mass, charge balance, and species constraints. By

a theorem of linear algebra pck’ can be expanded in a

set of vectors which span the null space of (CID) cor-

responding to Eqns. (14) and (15) (STRANG, 1980.

chapter 2). The coefficients of this expansion will be

determined by minimization of the free energy.

In order to obtain a set of vectors with which to

expand p(k) we perform the following factorization 01

the constraint matrix, suggested by GILL and MURRA)’

( 1974). Consider the matrix Q defined by:

0:

; I

/R,, R,?‘,

Q* CI D) = Q: (CID) = R = 1 RZ2 / (16)

\u:‘;o 1

where Q is an (n’ X n’) orthonormal matrix that has

been partitioned into the Q, . Q2and Q1 matrices and

where the upper part of R is an (II? X n7) upper trr-

angular matrix and the lower part is an ((n’ ,i ) % ril)

matrix consisting only of zero elements. R III turn has

been partitioned into the upper triangular matrices K, i

177, X rn,) and Rz2 (m - IJI, F’ ill w,) a> urll as the

1~7, X ~7 - m, matrix R12. A method for generating the

Q matrix which transforms (CID) into upper triangular

form is given by the Householder transformation

(STRANG. 1980, p. 291). The column vectors of the Qmatrix have properties which are important to the tur-

ther development of the problem. These properties,

may be found from Eqn. (16) and are summarized in

Table 2. From Eqn. (16) the rows of Q: are orthogonal

to the columns of C and II. Therefore the gows ot

Q: form vectors which span the null space ot ((‘//I)

A feasible direction 3 may therefore be expanded in

the columns of Q, as:

+ IP=V,‘T- I iI

where x3 is a vector of coefficients. Any chorcc tar theprojected direction 2, will not violate the constraints

described by Eqns. (2), (3) and (3).

Q, may also be used to evaluate the convcrgencc

criteria for a local minimum. Since Eqns. (2). (3), and

(4), are always satisfied, we only have to consider con-

vergence for Eqn. ( 12). Operating on Eqn. t 1-T)with

Q: gives:

Q:r; == ; iiX

since from Table 2 Q: is orthogonal to C’ and f). Eqn.

( 18) is analogous to the usual chemical balance equa-

tion: V’

Cp,V,i=() I i.I : 1’2,

1

where r’jl is the stoichiometric coefficient for- the jth

species taking part in the ith reaction and r is the total

number of reactions. Thus the elements of Qf are or-

thonormal stoichiometric coefhcients. An example ot

the reaction directions generated by this method using

a simple aqueous system is given in Table 3

Page 5: A Chemical Equilibrium Algorithm for Highly Non-ideal Multiphase

8/13/2019 A Chemical Equilibrium Algorithm for Highly Non-ideal Multiphase

http://slidepdf.com/reader/full/a-chemical-equilibrium-algorithm-for-highly-non-ideal-multiphase 5/13

Non-ideal multiphase systems 1049

We will now use Newton’s method to find a feasible

descent direction. Newton’s method utilizes the second

order approximation to the chemical potential (the

gradient):

$k+i)(first order)= I;(k)+@fiijfk) (20)

where His the matrix of second derivatives of the free

energy with respect to the mole number (the Hessian

matrix):

At present the program calls a routine that evaluates

the Hessian analytically. If this is not possible, nu-

merical approximation procedures external to the main

program that return Hessian element values must besupplied. The second order approximation to the local

minimum at the k + I th iteration is obtained by sub-

stituting Eqn. (20) into Eqn. (12):

#k’?(k) + ji (k)= C;(k) + DG (k)_ (22)

We may solve for iijck) y operating on Eqn. (22) with

Q: to yield:QJH’k)$tk) + Q: (k’ =: 0 (23)

Using Eqn. (17) we obtain:

Q~H(k’Q, ~’ = -Q;i;(“‘.

(24)Q:HQ3 is a square matrix which may be factored and

inverted in order to solve for xik). Equation (17) may

then be used to obtain Ftki. We shall refer to Q:HQ3

as the projected Hessian matrix and to Q& as the pro-

jected gradient.

From this point our algorithm proceeds by successive

Newton steps towards a local minimum. (A flow chart

is given in Fig. 1.) When a local minimum is ap-

proached as determined by the size of the elements of

Q$ (see Section V.2) we may calculate 2, which will

provide the information required for phase addition(see Section IV). The multipliers for species constraints

Table 3. Example: The (CID) Manix and the Generation of Reaction

DirecUons (System H20-Kk’i~-C~.

Onho~onal Reactions

.6107 Na’ + 3646 Cl- + .2461 KCI = .6107 N I + .2461 K+

.3452 Nat + -6059 CI- + X07 K+ = .04X? NaCl + S607KCl

3 We have found (see Section V) that it is advantageous toestimate the value of the multipliers before a local minimumis reached in order to speed up the phase selection process.Though Eqn. (12) does not hold away from a local minimum,we use Eqn. (27) to obtain approximate values for the mul-tipliers.

may be calculated by operating with Qr on Eqn. (12)

to give:Q;z = Q:Di; (25)

since Q: is orthogonal to C. We partition the chemical

potential vector into two vectors consisting of the

chemical potentials of those species that are present in

the system (pp) and those that are constrained (pnp).

We then obtain:2; = Fp* f RpnP 26)

where F is a matrix that maps jip onto the chemical

potential vector containing all species (f;). If Eqn. (26)

is substituted into Eqn. (25) we obtain:

Q:FjiP= Q:D(i; - i inp). (27)

Q:D is upper triangular. We may thus solve for zj

- cnp by back substitution.3 Since i;“” is known for aparticular composition of the phase to be added. ?Z an

be calculated.

Another relationship that will be useful in the fol-

lowing section may be derived from Eqn. (27). From

Eqn. (27) ij - pnp 1sfunction only of the chemical

potentials that are present. From Eqn. (12) this term

is equal to:

5 Cji t i -(Wj - ). (28)i-l

Therefore the sum f: Cjiti is not a function of the

i=lchemical potentials of the phases that are not present.

IV. PHASE SELECTION AND THE CONDITIONSFOR A GLOBAL MINIMUM

The general method that we will describe here for

selecting the correct phase assemblage is applicable for

the selection of any type of phase (gas, pure mineral,

liquid, or solid solution) and is relatively simple to

implement. Let us assume that we have a phase assem-

blage such that Eqns. (7-I 1)are satisfied (a local min-

imum). We must now decide whether or not other

phases should be brought into the system by deter-

mining whether the free energy of the system will de-

crease if we add an infmitesimal amount of a phase

whose mole numbers are currently set to zero. Species

may be treated individually when they correspond to

pure sohd phases that have not precipitated. For so-

lution phases, all the species in the phase must be added

simultaneously in order to avoid infinite chemical po-

tentials of solution species at zero concentration. We

will first consider single species (mineral) addition. In

this treatment we will assume that mass balance con-

straints do not prevent any single phase from precip-itating alone. For example, a reaction may occur in

which one phase disproportionates into several phases.

If single phase precipitation is not possible, a strategy

must be developed that allows more than one phase

to precipitate simul~neously (GREENBERG, 1986).

The change in the free energy resulting from an in-

finitesimal change in the mole numbers is given by the

differential of the free energy:

dG = 5 pj dnj 29),=I

Page 6: A Chemical Equilibrium Algorithm for Highly Non-ideal Multiphase

8/13/2019 A Chemical Equilibrium Algorithm for Highly Non-ideal Multiphase

http://slidepdf.com/reader/full/a-chemical-equilibrium-algorithm-for-highly-non-ideal-multiphase 6/13

C. E. Hake, J. P. Greenberg and J. H. Weare

FIG. 1, The flow chart for the primal chemical equilibrium algorithm.

where the sum is over all species. Substituting the value

for /+ from Eqn. ( 12) gives

n’ mc

dG = 2 ( 2 Cjiti + wj)dnj (30)

Eqn. (14) shows that for a direction that does not

violate charge and mass balance constraints, the first

term on the right vanishes giving:

dG = ujdn, (31)

where we have considered the addition of mineral spe-

cies j alone. If uj is greater than or equal to zero, when

Eqns. (7-11) are satisfied, then precipitating mineral j

alone will not lower the free energy. A simple exampleof mineral addition is given in Table 4.

Equation (3 1) may be written as:

(32)

This form for g is useful for understanding the phys-J

ical significance of a pure mineral species multiplier

and emphasizes the importance of the result in Eqns.

(27-28). As an example, let us assume that our system

consists of a silicate liquid containing MgO, CaO. and

SiOZ. We wish to test whether or not precipitating pro-toenstatite will lower the free energy. In this example

Page 7: A Chemical Equilibrium Algorithm for Highly Non-ideal Multiphase

8/13/2019 A Chemical Equilibrium Algorithm for Highly Non-ideal Multiphase

http://slidepdf.com/reader/full/a-chemical-equilibrium-algorithm-for-highly-non-ideal-multiphase 7/13

Non-ideal multiphase systems 1051

we will assume that protoenstatite is a pure mineral

(MgzSizOs). In the liquid we will assume that there is

a chemical species Mg2Si206. Since the liquid phase is

present in the system, the corresponding w values for

all species in the liquid are zero. Therefore from Eqn.

(12):

fiMg&O6(1) c CMg&O~(l)i~i~ (33)i=l

Since this liquid species has the same combination of

components as the solid species, Eqn. (33) may be usedmc

to substitute for C Cjiti in Eqn. (32). Eqn. (32) mayi=l

then be written as:

dG

dn= (~Mg,SizO&) - HMg$i206(1)) (34)

M8zsi20&)

or in terms of the solubility product for protoenstatite:

dG

dnM82si206(s)= RT(ln Kp - In &lg$4~0&)) (35)

whereaMg&06(1)s the activity of the Mg2Si206 species

in the liquid. Therefore w for a pure mineral corre-

sponds to the negative of the natural log of the satu-

ration ratio (see Table 4 for another example). This

expression is identical to GHIORSO’S 1985) expressionfor the chemical affinity of precipitation.

In many instances there may not be one single cor-

responding species in a liquid phase. Consider the same

system as above except that the species in the melt are

MgO( l), CaO( l), and SiO*( 1) and where we have de-

fined our components as MgO, CaO, and SiOz. For

this model, Eqn. (32) becomes:

dG

dn= (~Mg&O&) - zcMgO - k02) (36)

Mssi2osW

where the factors of “2” come from the constraint ma-nic C since there are two “molecules” each of com-

ponent MgO and SiOZ in every “molecule” of MgzSi20e

(see Table 5). Since the chemical species Si02(l) and

MgO(1) are in a phase that is present, we have from

Eqn. (12):

pMgO(I) = %SO (37)

and

PSiOz(l) = fSi02. (38)

If these two equations are substituted into Eqn. (36)

we obtain:

dG

dn= (wMe&O&) - 2C(MgO(l)- 2PSiO,(lj). (39)

MSzSi206W

As in the first example Eqn. (39) may be written in

terms of the solubility product:

dG

dn= fWln f& - In (~hgWl,a&l)))* (40)

MmShO&)

The second type of constraint removal corresponds

to the addition of a solution phase. In such a situation

the wys for the species in phase s will depend on the

composition of phase s. For a solution phase Eqn. (3 1)

becomes a sum over all species in the phase including

the solvent:

dGdG = 7 dn, 4 = F o&j

.J m phase s. (41)

If we bring a phase into the system at constant com-

position, Eqn. (41) becomes in terms of mole fractions:

dG = d( N”) 2 WjXjj in s

=

d(N”)[ C .Wj(pj(X)- 5 Cjiti)] (42)1 I” s i=l

where d(N”) is the differential of the total number of

moles in the phase being added to the system, Xj is the

mole fraction of species j, and the value of each wj has

been obtained from Eqn. (12). In Eqn. (42) the last

term on the right hand side is fixed by the composition

of the phases that are present (see Eqns. 27-28).

Any choice of composition for the solution that is

not present which will give a negative value for dG in

Eqn. (42) will indicate that the phase is a candidate

for addition. In order to choose among a set of solutionphases we must find the compositions with the most

negative dG. Since we are interested in the optimal

improvement in the free energy, the quantity in pa-

renthesis in Eqn. (42) is minimized over the mole frac-

tions of the species in the solution phases that are not

present in a subminimization program subject to the

constraint that the sum of the mole fractions in the

phase to be added equals one. This minimization de-

termines the optimal composition of the solution phase

to be added. However if the minimum value is positive

Page 8: A Chemical Equilibrium Algorithm for Highly Non-ideal Multiphase

8/13/2019 A Chemical Equilibrium Algorithm for Highly Non-ideal Multiphase

http://slidepdf.com/reader/full/a-chemical-equilibrium-algorithm-for-highly-non-ideal-multiphase 8/13

1052 c‘. E. Harvie. J. P. Greenberg and J. H. Weare

then there is no direction which will decrease the free

energy. For solution phases containing charged species,

a charge balance constraint must also be added. This

additional constraint may be formulated in terms of

the general degeneracy problem and is discussed else-

where GREENBERG, 1986).

The criteria for phase addition may now be sum-

marized in terms of the following optimization prob-

lem:

X”= minimum 2 Xj(Pj(X) -- 2 C;,t,) (43), n 1. 87

subject to c .“i;= I. (44)1 n.3

The Lagrangian corresponding to this problem is:

L(X.X)= 2 Xj(/dj(X)- 2 Cj,ti)--A ( C .Vl_ I) (45)j in E /- 1 I I” <

where X” is defined as the phase multiplier. Differen-

tiating the Lagrangian with respect to X, setting the

derivatives equal to zero, and using the Gibbs-Duhem

equation gives the value of X:

X”= @” - C C,,t, = q ‘” j in phase s. (46),=I

i.e. all the wj’s in the phase are equal to the phase mul-tiplier X at the minimum of Eqn. (45). If Eqn. (46) is

substituted into Eqn. (42) we find that the derivative

of the free energy with respect to the total number of

moles in the phase is equal to the phase multiplier X:

g = c x,X” = AS = o?J j ins. (47)J111

Thus if X” s less than zero the system is supersaturated

with respect to phase s and if X” is greater than zero

the system is undersaturated with respect to phase s.

The physical significance of the phase multiplier may

be illustrated by considering the same example dis-

cussed previously except now we will introduce a pro-

toenstatite solid solution containing in addition to

MgzSizOs the species diopside (CaMgSiZOs). In addition

to Eqns. (37-38) we must now also consider the CaO

component. From Eqn. (12) we have:

/.&o0, = ,%a~ (48)

Since we now have a solid solution phase consisting

of two species Eqn. (46) becomes:

AS= &;s,$& - 2&&o - 2ESio2 (49)

and

hS = & gSi206 - EMgO - CCaO - &hO2~ (50)

Substituting Eqns. (37), (38) and (48) into Eqns. (49)

and (50) we obtain expressions similar to Eqn. (40):

x” = RT In KMglsilog- Ina OOP O_dl,

aMg*Si206(SSY” 1151)A”T In KCaM ei 206 In

aMgO(l kaO(l b Odl)

Qk gSi .(~~)mi” II

(52)

where KM psi206nd KCaM ei 206 re the equilibrium con-

stants for the distribution of Mg&Os and CaMgSizOd

respectively between the liquid and solid phases. In

Eqns. (5 1) and (52), the activities of the two solid so-

lution species are obtained from the subminimization

program defined by Eqns. (43) and (44). This example

is presented in more detail in Table 5. Again. the form

of Eqn. (51) and Eqn. (52) is similar to a saturation

ratio for the individual species.

Recently, REED (1982) has presented conditions for

addition of an ideal solution. In another article

GREENBERG, 1986) we expand upon the properties of

the phase multiplier for ideal and nonideal solutions

and show the relation between our criteria and that of

REED (1982).

When all phase and simple constraint multipliershave been calculated, they are compared. If the one

with the lowest value is less than zero, the species cor-

responding to that multiplier are brought into the sys-

tem (pure phases multipliers are scaled according to

the corresponding solution phase species that make up

the pure phase). When all phase multipliers are positive

we have reached a global minimum.

V. NUMERICAL DIFFICULTIES

Many of the numerical problems of the chemical

equilibrium algorithm are solved by the choice of re-action directions given by the columns of Qj. None-

theless, significant numerical problems may arise in

certain situations. In this section we will discuss some

common difficulties associated with the implementa-

tion of the above procedure.

I. Poorl _v ondit i oned projected Hessian matr i -

The chemical equilibrium problem is, as a general

rule, poorly conditioned. The solution to Eqn. (24)

depends on the inverse of the projected Hessian matrix.

The numerical accuracy of an inversion algorithm de-

pends on the eigenvalues of the matrix to be inverted.

Eigenvalues of the projected Hessian matrix depend

on the selection of the matrix Q and can range from

zero to infinity. To achieve numerical stability these

eigenvalues must be controlled. Among the various

possibilities we have tested the above method for gen-

erating reaction directions (i.e. the procedure for gen-

erating Q given by Eqn. 16) appears to minimize the

value of the condition number (the ratio of the largest

to smallest eigenvalue) with the least numerical com-

plication. However, numerical problems can still occur.Large positive projected Hessian eigenvalues exist when

solution species approach zero (note that the eigen-

values for a solution phase Hessian are proportional

to l/n where n is the mole number for the species).

For example, in the carbonate system on the acid side,

the concentration of COT2 is negligible. At this point.

the algorithm may become unstable. In this situation

we fix the mole number of such species equal to a

small positive number and add a species constraint. A

similar technique has been suggested by GWORSO

Page 9: A Chemical Equilibrium Algorithm for Highly Non-ideal Multiphase

8/13/2019 A Chemical Equilibrium Algorithm for Highly Non-ideal Multiphase

http://slidepdf.com/reader/full/a-chemical-equilibrium-algorithm-for-highly-non-ideal-multiphase 9/13

Non-ideal multiphase systems 1053

(1985). In effect, this requires the program to find new

reaction directions via Eqns. (17) and (24) which em-

phasize the major species that are present. An efficient

algorithm for updating the Q matrix is given in the

Appendix. Updating the reaction directions is relatively

simple since the C matrix remains unchanged. After

the solution to the problem has been found, the equi-

librium concentration of the low concentration species

are calculated from the chemical potentials of the larger

species (see Section VII).

Another conditioning problem arises when the Gibbs

phase rule is violated (i.e. more phases are present then

are allowed by the phase rule). In this case the condition

number of the projected Hessian will become infinite

because there is a zero eigenvalue. We may see why

this is the case by again considering Eqn. ( 18). Duringthe calculations, the estimate of the solution is given

by the first order approximation of the chemical po-

tentials (Eqn. 20). The first order equivalent of Eqn.

(18) is:

Q:T;(k”)(first order) = 0. (53)

If there are more phases present at any iteration than

allowed by the phase rule, there will be more equations

in Eqn. (53) than there are unknowns. Therefore, there

is no solution for this iteration of the algorithm since

the projected Hessian is singular. This is discussed inmore detail in GREENBERG (1986).

Situations where the projected Hessian becomes

singular because of violations of the phase rule may

occur rather frequently during the course of an evap-

oration or a crystallization sequence. For example, in

the two component MgO-SiOz system a peritectic point

exists where forsterite (Mg,SiO& enstatite (Mg&O,)

and a silicate melt are in equilibrium. If the algorithm

has just calculated equilibria between liquid and for-

sterite above the peritectic point and in the next prob-

lem the temperature is taken to be below the peritectic,

the algorithm will first precipitate the protoenstatite

phase. (Note that in each individual problem the tem-

perature is fixed.) At this point the projected Hessian

will be singular because three phases are present. In

such a case we condition the projected Hessian matrix

according to the procedure of GILL and MURRAY

(1974). With this modification the program will remove

a phase. Gill and Murray use a modified Cholesky fac-

torization in order to insure that the eigenvalues of the

modified projected Hessian are larger then zero. The

effect of this procedure is to add small positive numbers

to the diagonal elements of the projected Hessian ma-trix such that the matrix becomes positive definite and

produces a well defined descent direction. While this

procedure results in a direction vector with a large

magnitude (because of the small value of the deter-

minant) second derivative information is preserved.

The magnitude of the direction vector is not important

since this step leads to the removal of a phase. We

determine the step length by moving the concentrations

to the nearest phase boundary: a point at which a spe-

cies mole number corresponding to a pure phase be-

comes equal to zero, or equal to a small number if the

species is in a solution phase. At this point the phase

is removed. We have found, as with normal descent

steps, that second derivative information is essential

for efficient phase removal. The direction calculated

by this method is similar to that which would have

been obtained if a small amount of an additional com-

ponent had been added to the system thereby increasing

the number of degrees of freedom while not affecting

the thermodynamic behavior of the system (thus sat-

isfying the phase rule and producing a positive definite

projected Hessian).

2. Cycling

Another problem that may be encountered during

the course of the minimization procedure is cycling or

zigzagging. In an attempt to select the correct equilib-

rium phase assemblage early, phases are brought into

the system prior to the attainment of a local minimum

when the corresponding multipliers are sufficiently

negative. Since the multipliers are only estimates at

such a point, this procedure may choose phases that

are subsequently removed before a local minimum is

reached. While experience has shown that the mag-

nitude of the multipliers may undergo large fluctuations

when the composition is far from a local minimum,

multiplier estimates when the solution is close to equi-librium (as determined from the magnitude of the ele-

ments of Q:p) provide good estimates for the phase

assemblage at the global minimum. Since the size of

the elements of Q:r( determine the accuracy of the

local minimum estimate, we do not allow a phase to

precipitate when the absolute value of its multiplier is

less then the maximum absolute value of the elements

in Q:p. Nonetheless, in succeeding iterations the same

phases may be selected and removed repeatedly. Con-

sequently precautions are taken so that each phase may

only precipitate once before a local minimum is at-

tained (ZOUTENDIJK, 1959, p. 73). In such cases the

phase with the next most negative multiplier which

satisfies the above condition is added.

3. Step length modification for a poor Newton step

Under certain circumstances it may be necessary to

modify the value of CYn Eqn. (13) which is initially

set equal to 1 for each iteration. Three conditions may

arise that will result in a smaller step length: (1) A

species becomes less than the boundary value when a

full step is taken; (2) A step is taken that results in achange in a solution species of many orders of mag-

nitude; (3) The free energy increases with a full step.

The first condition prevents the mole number of a

species from becoming negative or, in a solution spe-

cies, so small that an enormous chemical potential re-

sults. In this case the step length is set such that the

mole number of this species becomes equal to the

boundary value. The second condition is a precaution

against making enormous changes in a solution species

that may be the result of a poor Newton direction. In

Page 10: A Chemical Equilibrium Algorithm for Highly Non-ideal Multiphase

8/13/2019 A Chemical Equilibrium Algorithm for Highly Non-ideal Multiphase

http://slidepdf.com/reader/full/a-chemical-equilibrium-algorithm-for-highly-non-ideal-multiphase 10/13

1054 C. E. Hake, J. P. Greenberg and J. H. Weare

such a circumstance the step length is shortened so

that no solution species changes beyond a fixed order

of magnitude at any step. The third condition arises

when a poor direction results in an increase in the free

energy. We then use a line searching procedure that

utilizes a succession of linear approximations along

the calculated direction to obtain a step length that

lowers the free energy. When a minimum is reached

a new Newton direction is calculated.

VI. SPECIAL STEPS

In some circumstances special step directions must

be calculated in which the mass balance or species

constraints are changed. In such situations a Newton

step may be taken but because Eqns. ( 14) and (15) nolonger apply, p’ may no longer be expanded on the null

space of (C/D) alone. However, since the n’ ortho-

normal vectors of Q forms a linearly independent basis

set, 13 may be expanded as

P = Q,;i, + Qzf, + Q,xs (54)

In this section we shall discuss cases where it is nec-

essary to calculate 8, and f2. Any non-zero value in

any of the elements of a, will in general perturb all

constraints, while any non-zero element in x2 will

change the mole numbers of at least one species con-

straint. We have already seen that elements in x, will

not violate any constraints. We will now use Eqn. (54)

to calculate a feasibility step, a phase addition step and

a phase removal step.

I. Feasibility step

The feasibility step allows for the use of an initial

starting point which may be a good approximation to

the equilibrium configuration but infeasible with re-

spect to the mass balance equations. For example, in

an evaporation sequence, the mass balance of the initial

problem is defined by the solution composition and

any mineral and gas phases that are present. The so-

lution to this problem is a good approximation to the

next problem in which some water has been removed.

However, this solution does not satisfy the new mass

balance requirements. The feasibility step allows us to

obtain a feasible starting point for the new problem

while taking advantage of the information gained from

the equilibrium compositions of the previous system.

Let S(i) represent the bulk composition of the system

whose equilibrium composition has already been cal-

culated with mole numbers 7i”‘, and let -h(9 representthe bulk composition of the system whose equilibrium

assemblage we wish to calculate with mole numbers

nf. We then have:cT ~’ = XII,

(55)

and:CT+” = 5’” (56)

or:CT@“‘_ 3i”‘) = Ax. (57)

We define j? as Zi’” - #I’. The vector p’ is therefore the

direction that takes the system from the initial com-

position to the final composition when a full step is

taken. Operating with CT on both sides of Eqn. (54)

we find:

c”~=Aa=CrQ,a,. (58)

From Eqn. ( 16) we see that C”Q, is a lower triangular

matrix. Therefore, 3, may easily be solved for by using

back substitution. We then solve for x2. On a fusibility

step. we impose the condition that no species con-

straints are violated. Therefore, operating on both sides

of Eqn. (54) with 0’ gives:

0’3 = D’Q,$, + D’Q2~, = 0. (S

Since D’Q2 is lower triangular, and 2, is known, Eqn.

(59) is easily solved. The method for solving the ziusing a modified Newton direction is described in sub-

section 4. If a full step is taken, the system composition

is feasible for the current problem and the standard

minimization procedure can begin. If a full step could

not be taken because a species goes to the boundan,

a constraint is added and a new feasibility direction is

calculated. (A method for efficiently adding and de-

leting species constraints by means ofthe Householder

transformation is described in the Appendix.

,? Phase addition

Both the phase addition step and the following phase

removal step efficiently replace the more common ap-

proach of removing or adding the phase and restarting

the program from an arbitrary initial feasible point. If

a pure mineral phase is to be brought into the system.

the corresponding element in j is set equal to a

positive number proportional to the magnitude of the

mineral multiplier. If a solution phase is to enter the

system, it is brought in at a constant composition which

is determined by the mole fractions which minimize

the Lagrangian for the sub-minimization problem

(Eqns. 43 and 44). Each element in the j? vector cor-

responding to species in the phase that is to be brought

into the system is given by:

p, = 1:\, (60,

where c is a proportionality constant that will determine

the total amount of the phase to be added. In our pro-

gram we chose this number to be equal to the absolute

value of X for a solution phase and the absolute value

of w for a pure mineral.

For the phase addition step, mass and charge balance

constraints are not changed but species constraints are.Therefore, all the elements in 2, in Eqn. (54) are equal

to zero. x2 is solved for by operating on Eqn. (54) with

DT:

DTj5=DTQ2& (611

D73 is a vector that contains only constrained species.

The only non-zero elements in DTp’are for species in

the phase that is being added to the system. The present

Q matrix corresponds to constrained species being fixed

at any value. At the beginning of the phase addition

Page 11: A Chemical Equilibrium Algorithm for Highly Non-ideal Multiphase

8/13/2019 A Chemical Equilibrium Algorithm for Highly Non-ideal Multiphase

http://slidepdf.com/reader/full/a-chemical-equilibrium-algorithm-for-highly-non-ideal-multiphase 11/13

Non-ideal multiphase systems 1055

step, their mole numbers are equal to zero but with

the change (Eqn. 60) they assume values greater then

zero. Expanding the remaining p’ vector in & will not

change the mole numbers determined from Eqn. (6 1)

(see subsection 4). After the phase addition step is taken

the species constraints for all species in the incoming

phase whose mole numbers are greater than that of

the boundary value are relaxed and the Q matrix is

updated.

from the linear mass and charge balance constraints.

We will now describe the method for solving for z3

which is used in all special directions. We solve for

z3 by substituting Eqn. (54) into Eqn. (23):

Q:N(Q,S,+Q*~*+Q~~3,=-Q:r;.62)

Inverting the projected Hessian matrix in Eqn. (62)

yields the solution for $, :

3. Phase removal

When a pure mineral hits the boundary as the result

of a Newton step, a constraint is added, effectively re-

moving the phase. When a solution species hits the

boundary a decision must be made regarding whether

the entire phase should be removed or whether only

the single species should be constrained on the bound-

ary (consider for example the situation of the Oj’

species in acidic solutions). If the total number of moles

in the solution phase is smaller than a number which

is established by trial and error, a phase removal step

is attempted. First, all the elements of 3 which corre-

spond to the phase being removed are set equal to the

negative of the mole number of the species in the cur-

rent step. Next all species in the phase are added to

the constraint set and the Q matrix is updated. In this

way, a full step exactly removes the phase from the

system. Furthermore, since the composition of the

phase is now fixed, the chemical potentials for all spe-

cies in the phase are fixed. As a result, problems with

logarithmic singularities are avoided. This step again

efficiently utilizes the information of the previous step

in contrast to a method which removes the phase and

restarts the problem from an arbitrary feasible point.

a,=Q:HQ; [(-Q:~-Q:H(Q,a1+Q2~2))1.63)

(a) (b)

When a special direction is calculated we set term (a)

equal to zero. Because of Eqn. ( 18) term (a) is small if

the system is close to a local minimum. This is true

for a phase addition step since we only estimate phase

multipliers and species constraints when we are rela-

tively close to a local minimum. For a feasibility step

term (a) will be zero since the previous problem has

been solved and therefore convergence has been

achieved. For a phase removal step term (a) is nonzero

in general. However, a phase removal step is always

an extremely small step relative to the major species

present in the system. Therefore, we set term (a) equal

to zero even for this case.

VII. THE CALCULATION OF SPECIES AT VERY

LOW CONCENTRATIONS

If the calculated phase removal step results in an

initial increase in the free energy, all the constraints

that have been added for the phase removal step are

deleted except for the species that initially went to theboundary during the course of the previous step and

a regular Newton step is calculated. If it is found that

the free energy can be lowered by taking less than a

full step, a line search procedure is used to find the

optimum decrease in the free energy along the calcu-

lated step length (see Section V). In this case, species

whose mole numbers are less then the boundary value

after the step is taken retain their constraints while

constraints are removed for those species whose mole

numbers are above the boundary value.

In Section V we described a numerical problem en-

countered when the mole number of a species in a

solution phase goes to zero. In such instances special

care must be taken in order to maintain numerical

stability. We avoid this problem by not allowing so-

lution phase species to go below a designated boundary

value. For example, in an acidic solution, the concen-

tration of the CO;* ion at equilibrium is extremely

small and might be sufficiently small enough to be fixed

at the boundary in our algorithm (a number which is

established by trial and error).

After solving the equilibrium problem with this spe-

cies fixed we refine the solution composition with a

special step. This step is calculated by assuming that

the activity coefficients are constant and by using the

chemical potentials of the major ions to calculate the

equilibrium chemical potential of the low concentra-

tion species. In this example the chemical potential of

the CO;’ ion at equilibrium is given in terms of

HCOj and H+:

As with a phase addition step we expand p’ in terms

. -.+of 6 2 and b 3. 62 s calculated using Eqn. (6 1) where in

the case of a solution phase removal, the non-zero ele-

ments of DTp’ correspond to the negative of the mole

numbers of the species in the phase that is being re-

moved. The method for solving for Js is described in

the following section.

4. Mod$ed Newton direction

b+ZO;2, = &HCO; ) - &H+, . (64)

If HCO; and H+ are in excess compared to COT’ then

the activity coefficient of COT2 may be assumed to be

a known function of the concentrations of the major

species. The concentration of Co;2 can then be esti-

mated from the activity calculated from Eqn. (64).

From Eqn. ( 12) the chemical potential of a species

at a minimum is

m,In the special directions described in subsections 1,

2 and 3,x, and x2 in Eqn. (54) have been determined/.Lj= 2 Cjiti + W1 (65)

j=.

Page 12: A Chemical Equilibrium Algorithm for Highly Non-ideal Multiphase

8/13/2019 A Chemical Equilibrium Algorithm for Highly Non-ideal Multiphase

http://slidepdf.com/reader/full/a-chemical-equilibrium-algorithm-for-highly-non-ideal-multiphase 12/13

1056 C. E. Harvie. J. P. Greenberg and J. H. Weare

where wj is positive. If we write the chemical potential

in terms of activity coefficients Eqn. (65) becomes:

pF+RTln(x-p)+RTln(y,)= C(;,C,+W, (66)

where .x; designates the concentration of the species

at the boundary and yj is the activity coefficient. When

this species is at equilibrium wj is equal to zero:

,,i.

~c:+RTln(.~:)$KTln(y,)- c(‘,,c: (67)

where .~f is the approximation to the equilibrium con-

centration. The activity coefficient will be approxi-

mately constant with a small change in _\;. since it is

determined by the concentrations of the species in SO-

lution that are present in larger amounts. Similarly.

since species j is held fixed C C;,t, is a function of the1--i

chemical potentials of the species in large concentra-

tions (Eqns. 27-28), which change very little with

changes in the concentration of species j. Assuming

then that the mass and charge balance multipliers and

the activity coefficients are constant, subtracting Eqn.

(66) from Eqn. (67) and rearranging the terms yields

an expression for .X’ as a function of .Y” and w,:

.Yl = V.o(pc-w,lRn)~J ’ 1 (68~

After the calculations corresponding to Eqn. (68) are

performed a special direction, similar to that for a phase

addition step is calculated. In this case the elements of

0’3 are determined from Eqn. (68). A special direction

is then calculated that satisfies Eqn. (68) and does not

violate charge and mass balance. This procedure is re-

peated until the species multipliers are sufficiently

small.

Editoriul handling: G. R. Holdren. Jr.

REFERENCES

BEIGHTLER . and PHILLIPSD. T. (I 976) .@plied (;cometr~c

Programming. John Wiley and Sons.BOWENN. L. (1928) The Evolution oflgneous Rocks Prince-

ton University Press.BRANTLEY ., CRERAR D., MLLER N. and WEARE J. H.

(1984) Geochemistry of a marine evaporite: Bocana de Vi-rills, Peru. J. Sediment. Petrol. 54, 447-462.

FELMY A. R. and WEARE . H. (1986) The prediction of boratemineral equilibria in natural waters: Application to SearlesLake, California. Geochim Cosmochim .4cta 50, 277 I -2784.

GARRELSR. M. and THOMPSONM. E. (1962) A chemicalmodel for seawater at 25°C and one atmosphere total pres-sure. Amer. J. Sci. 260, 57-66.

GILL P. E. and MURRAY W. (1974) Newton-tvpe methodsfor unconstrained and lineally c&strained c$timization.Math. Prog. 7, 31 l-350.

GHIORSO M. S. (1985) Chemical mass transfer in magneticprocesses. I. Thermodynamic relations and numerical al-gorithms. Contrib. Mineral. Petrol. 90. 107-120.

GREENBERG. P. (1986) The design of chemical equilibtiumcomputation algorithms and investigations into the mod-eling of silicate phase equilibria. Ph.D. dissertation IJni-versity of California, San Diego.

GREENBERG. P., WEARE . H. and HARVIEC. E. (1985) Anequilibrium computation algorithm for complex highlynonideal systems. Application to silicate phase equilibria.High Temp. Sri. 20, 141-162.

HARVIEC. E. (I 98 I) Theoretical investigations in geochem-istry and atom surface scattering. Ph.D. dissertation. LJni\ .Microfilm. Int.. Ann Arbor. MI #AAD82-03026.

HARVIE C. E. and WEARE J. H. (1980) The prediction ofmineral solubilities in natural waters: The Na-K-Mg-Ca-Cl-S04-HZ0 systems from zero to high concentration at25°C. GeoLhim. C(xmochim. .Acta 44, 98 l-997

HARVIEC. E.. WEARE J. H.. HARDIE I.. A. and F.‘llc;s~t~H. P. (1980) Evaporation of seaw-ater: Calculated mineralsequences. Science 208, 498-500.

HARVIEC. E., EUGSTERH. P. and WEARE . H. ( I U&2)Min-era1 equilibria in the six-component systems, Na-K-Mg-Ca-Cl-SO,,-HZ0 at 25°C. II. Compositions of the saturatedsolutions. Geochim. Cosmochim. Acta 46, 1603-l 6 18.

HARVIE C. E.. MILLER N. and WEARE J. H. (1984) Theprediction of mineral solubilities in natural waters: The Na-K-Mg-Ca-H-Cl-SO,-OH-HCOI-Co3-CO1-H,O system tohigh ionic strengths at 25°C. Geochim. (‘osmoc~him. l~‘ia48,723-75 I.

HELGESONH. C. (1978) Summary and critique ot ihe thrr-modynamic properties of rock-forming minerals. ,lf?,t~

J. Sci. 27gA, 1-229.LUENBERGER . G. (1973) Introduc?wn fo Lirreur I& /Vcw

lineur Programming. Addison-Wesley.NORDSTROM . K.. PLUMMER L. N., WIGL.L:L1. ill. 1

WOLERYT. J.. BALL . W.. JENNE E. A.. BASSl’iI R. 1CRERARD. A., FLORENCE . M., FRITZB., HOFFMANM..HOLDRENG. R. JR., AFON G. M.. MA~TIC;ODS. V..

MCDUFF R. E.. MORELF., REDDYM. M.. SPOSI ‘OG. andTHRAILKILI J. (1979) A comparison of computerizedchemical models for equilibrium calculation in aqueoussystems. rl. C: S. Symposium Serie.s No. 93, 857-892.

PI.~ZERK. S. (1977) Electrolyte theory-improvements sinceDebye and Hiickel. Acct. Chem. Res. 10, 371-3’7

REED M. H. (1982) Calculation of multicomponent chemicalequilibria and reaction processes in systems involving min-erals, gases, and an aqueous phase. Geochim (i~smochi~~j

.4cta 46, 5 13-528.SMITH W. R. and MISSENR. W. ( 1982) ChemlL,al Rlwtiwi

Equilibn’um .4nalJ:sis:Theory and Algorithms. John Wile\and Sons.

STRANG G. (1980) Linear Algebra and r/s .4pp/1c~afi~~rr~-

ademic Press.VA~X’~ OFF J. H. ( 190.5) Zur Bildurrr: du o-_w~~ sc m .W.:

lugerstarrm (first part). Vieweg.

VAN? HOFF J. H. (1909) Zur Bil&n,q tier oxozwh~x Suir-lager.statten (second part). Vieweg.

ZOUTFNDIJK G. (1959) Methnd.s ol Feasihlc iI/rcv~itrw\. Fl-sevier,

APPENDIX

CONSTRAINT ADDITION AND DELETION

In this appendix we will discuss a method for addmg anddeleting individual species constraints without recalculatin&the entire Q matrix. This is important in terms of computationtime, since (for example) in our aqueous solution model. there

are more than 60 solution and mineral species resulting in aQ matrix of a dimension of at least 60 by 60. We will describein this appendix a method which changes a relatively small

portion ofthe Q matrix as constraints are added and dropped.

Let us assume that we have obtained a Q matrix such that:

QlyclD) -: i(rn 14.11

where R” is an upper triangular matnx of rank m as definedin Section III. All redundant constraints in the C matrix hav?

been removed using the same criteria as in the update pro-

cedure discussed below. Q ‘lrn) is an orthonormal constraint

Page 13: A Chemical Equilibrium Algorithm for Highly Non-ideal Multiphase

8/13/2019 A Chemical Equilibrium Algorithm for Highly Non-ideal Multiphase

http://slidepdf.com/reader/full/a-chemical-equilibrium-algorithm-for-highly-non-ideal-multiphase 13/13

Non-ideal multiphase systems 1057

matrix with which we can construct a null space in whichcharge, mass balance, and species constraints are not violated.

Originally this matrix was calculated by a series of Householdertransformations for a particular set of phases giving a particularD matrix. We now wish to add an additional species constraint2 Jwhich corresponds to chemical species j (constraint numberm + 1). Species constraints have the simple form nj = 0.Therefore the elements of aj are of the form:

d,=O i#j

d,=l i=j. (A.2)

The new Q matrix, operating on the new constraint matrix,must produce an upper triangular R matrix of rank m + 1:

Q’m+‘)T CIDld) = R”+‘. (A.3)

The old Q matrix, operating on the new constraint matrixwill produce an upper triangular R matrix except for the last

column due to the addition of the new constraint. The House-holder transformation may be used to produce the new Rmf’

matrix. The new Q matrix, which is formed by transformingthe old Q matrix, is given by (STRANG, 1980, p. 29 1):

(I- bu~‘)al-‘~ = ~(m+ln (~.4)

where I is the identity matrix and ir is formed from the ele-ments of QT’m’a rom the m + lth element on down. Becauseof the special form of the added constraint (Eqns. A.2) 3 hasthe form:

0

00

Q(m)J m+3

where

0 = Q m),m+, + \/,j+, Q: ?' (A.@

Since all elements with indices less then m t 1 are zero in3, only a portion of the Q matrix is changed after the trans-formation. In addition, we take advantage of the fact that, fora constrained species k, QE is equal to zero for i greater thanm (since h must be zero). These two aspects of the transfor-mation considerably decrease the number of operations thatwould be necessary if the entire Q matrix had to bc recalcu-lated.

(A.5)

All constraints represented in (CID) are linearly indepen-dent. Redundant constraints are found by examining the ele-ments of the vector formed by operating on the m + 1 hconstraint with the Q”’ matrix. If it is found that all elements

at and below the m + I h element of this vector are equal tozero, the m + Ith constraint is linearly dependent on thepreviously added constraints and is discarded.

In a manner similar to that used for adding constraints, theHouseholder transformation may be used to delete constraints.If species 1 is constrained by constraint number k (where m,< k 5 m) then m - k Householder transformations must beperformed to form an upper triangular R matrix of rank m- 1. For example, consider the following R matrix of rank 5:

0 _ ._ _ ~

oo---

0 0 0 - - (A.7)

0 0 0 0 -0 0 0 0 0

0 0 0 0 0

where “-” denotes a nonzero element. If we now removeconstraint number 3 from the D matrix, MC1D) with the newD matrix becomes:

0 _ - -

0 0 - -

0 0 - - 64.8)0 0 0 -

0 0 0 00 0 0 0

We now wish to find a new matrix which will produce anew upper triangular R. In order to find this matrix, we per-form a Householder transformation beginning in column 3.For each successive Householder transformation the D vectorcontains only two non-zero elements, since for each speciesconstraint 1 he elements of the lth column of the old R matrixare all equal to zero for each element greater then 1. After thefirst transformation, the R matrix assumes the form:

0 _ _ _

0 0 - -0 0 0 - (A.9)0 0 0 -

0 0 0 0

0 0 0 0

The last iteration transforms the final column to produce thenew R matrix.