Sunteți pe pagina 1din 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 in revised form 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 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 dealing with them are discussed. It will be shown that the necessary and sufficient conditions for solution phase selection may be derived from the values of the Lagrange multipliers corresponding to constraints on phases that are not present in the system. The method for evaluating the solution phase Iagrangian multipliers and choosing the optimum composition with which to bring 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 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 students ( 1905, 1909) to study marine evaporite systems such as the Zechstein salt deposits and by BOWEN (1928) to describe differentiation in silicate melts. Because phase diagrams were used, these models could treat only a limited number of components. More recently, a number of workers (GARRELS and THOMPSON, 1962; HELGESON, 1978; and NORDSTROM ef al., 1979) have developed mathematical models based on equilibrium mass action expressions which were general 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 consistent 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 parameterization of an aqueous solution model using the equations 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 equilibria between solutions and coexisting pure mineral phases in which the solution species activity coefficients 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 including a 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 potential. 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 GREENBERG (1986). The approach is equivalent to, but somewhat more general than, the more common approach of solving the mass action equations. In Section II we will derive the convergence criteria for the minimization procedure. The method utilizes Lagrange multipliers 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 generalization 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 directions are the result of projection methods that have been previously applied to chemical equilibrium problems (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 programming literature (i.e. GILL and MURRAY, 1974) they 1045

* This research was sponsored in part by the American Chemical Society PRF grant 14550-AC2,5-C, DOE grant DEACO3-85SF 15522, and the National Science Foundation OCE grants 85-07902 and 82-08482.

I046

C. E. Harvie. J. P. Greenberg and .I, H. Weare the phase addition step described in Section \, I to adJust the concentration of the species. In Section VI we will describe the calculation ofspecial directions that are modifications of the standard Newton direction. These directions are used for precipitating and removing phases and for altering mass balance. This last procedure is extremely useful Lbr performing a large number of equilibrium camputations 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 AND CONDITIONS FOR A LOCAL MINIMI.lM The chemical equilibrium problem for a system al constant temperature, pressure, and a specified bulk composition, may be expressed in terms of the following constrained minimization problem:
./1

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 equilibrium problem. Phase selection presents difficulties for minimization algorithms, particularly for solid solution phases. We will present criteria in Section IV to decide when, during the course of the algorithm, pure and solution phases should be precipitated. These phase selection methods are based on evaluating the Lagrange multipliers 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 addition we 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 nonideal phases. The method described in this paper assumes 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 GREENBERC;( 1986). Several difficulties may arise from the Newton direction 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 does not 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 optimal step length. Section VII describes an additional problem that may result from the Newton direction. Solution species which are present in very small concentrations may undergo order of magnitude variations in directions away from the equilibrium concentrations. Our procedure fixes the concentrations of such species and, after the problem has converged to the correct equilibrium assemblage, uses a step similar to

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 species j, n is the total number of species in the system. 111,is 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 component i. The n species include species in phases that are 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 corresponding 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 inactive (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

____

__~_~__

- ~~

Our algorithm discards all redundant components in order to obtain a linearly independent set (see the Appendix). While certain mass balance constraints may he redundant and are eliminated in the process of generating reaction directions, it is always important to retain all charge balance constraints in order to insure that all phases containing charged species remain neutral.

Non-ideal multiphase systems variables in the free energy expression. This approach yields the familiar mass action equations. The numerical stability of this method is in many cases poor. Usually this occurs because of a poor choice of independent 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 reaction directions. The Lagrangian may be written as (LUENBERGER, 1973):

1047

L=L(ii,i,7i,;l,3)= $pjFZj-~Ki$(Ajinj-b,f
,=I
i-l j-l 5~i C Zjnj$~j(t~j-tf) j=i

i=l j ini

(6)

where Kiis a Lagrangian multipIier for a mass balance constraint, ni is a multiplier for a charge balance constraint, 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 Lagrangian 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: an = 0 = pi - &&w; - wi
1 i-l f3L

Equations (8), (9) and (11) are the mass balance, charge balance, and non-negativity constraints on the chemical equilibrium problem. When these constraints are satisfied, the Lagrangian reduces to the free energy function. Therefore the stationary points of the Lagrangian 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 important 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 are calculated. 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 multipliers.* 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 removed. into the system or added as phases are

(7) phase

species 1in a non-electrolyte

dL z = 0 = /Js] - i A]iKi - VsZ] - W] I i=l

species 1 in electrolyte phase s d,10


dL Il,h=O= dL
~Ajlnj-1? I= l,C

j=]

(8)

C ZjTZj 1= 1,e jin I

(9) (10)

dL t=O=2w,t, 1

I= l,n

1= l,n,.

(11)

*The notation C = (Z/A) means that the columns of the A matrix are appended to the 2 matrix to form the C matrix where 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
X (a + b)

matrix). The notation 7 = = srgmfies that the 7 K

ii..

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 conditions 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 equilibrium 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 sections, 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 composition that satisfies all mass, charge balance and spe-

vector is constructed by appending the elements of the ii vector to those of the ij vector. The matrix I) has elements 1 or 0 depending on the phases present (see Table I). The vector 3 in 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).

104x

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


Table 1. Example: The Formation of the Mass Balmce and Species Constraint Matrices (System w-MgO-CaO).

Q*(CID)=

E
SiO,(liq) &NW CaO(kq) 4&O&) CdgSizO,(s)

Species

.%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) represent a feasible point for all species in the system on the kth minimization iteration and nck+) the composition on the k + lth step. We may then define the step direction vector 3 as follows:
(k+lI _ (k, iz - nj + <?JIF _ nj (0 5 (Y 5 I ). 1.n (1.3)

where Q is an (n X n) orthonormal matrix that has been partitioned into the Q, . Q2 and Q1 matrices and where the upper part of R is an (II? X n7) upper trrangular 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 w,) a> urll as the (177, X rn,) and Rz2 (m - IJI, F ill 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 Q matrix have properties which are important to the turther 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: + I P=V,T-

;:I
Q:

0:

/R,,

R,?,
RZ2 /
!1

(CID) = R =

10
;o

(16)

\u:

! I iI

where x3 is a vector of coefficients. Any chorcc tar the projected 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 convergence 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 equation: V : 12, Cp,V,i=() I i.I

Operating

on Eqn. (13) with C yields:

1
We also wish to impose the condition that the active species constraints (Eqn. 4) are not violated by the step direction. This gives:
DTjTk = 0. (IS)

where rjl 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 orthonormal stoichiometric coefhcients. An example ot the reaction directions generated by this method using a simple aqueous system is given in Table 3

We can combine the C and D matrices to form the n X m matrix (CID) where m is the number of independent 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) corresponding 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:

Non-ideal multiphase systems

1049

We will now use Newtons method to find a feasible descent direction. Newtons 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):

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; - iinp).

At present the program calls a routine that evaluates the Hessian analytically. If this is not possible, numerical approximation procedures external to the main program that return Hessian element values must be supplied. The second order approximation to the local minimum at the k + I th iteration is obtained by substituting Eqn. (20) into Eqn. (12): #k?(k) + ji (k)= C;(k) + DG (k)_ (22)

(27)

We may solve for iijck) by operating on Eqn. (22) with Q: to yield: QJHk)$tk) + Q:$(k =: 0 (23) Using Eqn. (17) we obtain:
Q~H(kQ,$~ = -Q;i;(.

We may thus solve for zj - cnp by back substitution.3 Since i; is known for a particular composition of the phase to be added. ?Zcan be calculated. Another relationship that will be useful in the following section may be derived from Eqn. (27). From Eqn. (27) ij - pnp 1s function only of the chemical potentials that are present. From Eqn. (12) this term is equal to: 5 Cjiti= -(Wj - &).
i-l

Q:D is upper triangular.

(28)

(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 projected 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 approached 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-Kki~-C~.

Therefore the sum f: Cjiti is not a function of the i=l chemical potentials of the phases that are not present. IV. PHASE SELECTION AND THE CONDITIONS FOR 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 assemblage such that Eqns. (7-I 1) are satisfied (a local minimum). We must now decide whether or not other phases should be brought into the system by determining whether the free energy of the system will decrease 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 solution phases, all the species in the phase must be added simultaneously in order to avoid infinite chemical potentials of solution species at zero concentration. We will first consider single species (mineral) addition. In this treatment we will assume that mass balance constraints do not prevent any single phase from precipitating 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 infinitesimal change in the mole numbers is given by the differential of the free energy:
dG = 5 pjdnj ,=I (29)

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 to estimate the value of the multipliers before a local minimum is 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 multipliers.

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)

(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 protoenstatite will lower the free energy. In this example

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 species 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 example of mineral addition is given in Table 4. Equation (3 1) may be written as: (32) is useful for understanding the physJ ical significance of a pure mineral species multiplier and emphasizes the importance of the result in Eqns. This form for g

Non-ideal multiphase systems 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):

1051

fiMg&O6(1) =

c CMg&O~(l)i~i~
i=l

(33)

Since this liquid species has the same combination of components as the solid species, Eqn. (33) may be used mc to substitute for C Cjiti in Eqn. (32). Eqn. (32) may
i=l

then be written as: dG = (~Mg,SizO&) dn M8zsi20&) or in terms of the solubility dG = RT(ln dnM82si206(s) Kp - In
&lg$4~0&)) HMg$i206(1))

(34)

product

for protoenstatite: (35)

is the activity of the Mg2Si206 species whereaMg&06(1) in the liquid. Therefore w for a pure mineral corresponds to the negative of the natural log of the saturation ratio (see Table 4 for another example). This expression is identical to GHIORSOS( 1985) expression for the chemical affinity of precipitation. In many instances there may not be one single corresponding 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 defined our components as MgO, CaO, and SiOz. For this model, Eqn. (32) becomes: dG = (~Mg&O&) dn Mssi2osW
zcMgO k02)

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: dG

.
J

dG = 7 dn, 4 = F o&j

m phase s.

(41)

If we bring a phase into the system at constant composition, Eqn. (41) becomes in terms of mole fractions: dG = d( N) 2 WjXj

(36)
=

j in s

where the factors of 2 come from the constraint manic C since there are two molecules each of component 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

d(N)[ C .Wj(pj(X)- 5 Cjiti)]


1 I s i=l

(42)

(37) (38) into Eqn. (36)

and
PSiOz(l) = fSi02.

If these two equations we obtain: dG dn MSzSi206W = (w Me&O&)

are substituted

2C(MgO(l)-

2PSiO,(lj).

(39)

As in the first example Eqn. (39) may be written terms of the solubility product: dG = fWln dn MmShO&) f& - In (~hgWl,a&l)))*

in

(40)

The second type of constraint removal corresponds to the addition of a solution phase. In such a situation

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 solution phases 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 parenthesis in Eqn. (42) is minimized over the mole fractions 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 determines the optimal composition of the solution phase to be added. However if the minimum value is positive

1052

c. E. Harvie. J. P. Greenberg and J. H. Weare where KMpsi206 and KCaMei206 are the equilibrium constants 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 solution 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 multipliers have been calculated, they are compared. If the one with the lowest value is less than zero, the species corresponding to that multiplier are brought into the system (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

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 elsewhere (GREENBERG, 1986). The criteria for phase addition may now be summarized in terms of the following optimization problem: X= minimum 2
Xj(Pj(X)
1.

--

2
87

C;,t,)
!

(43) (44) is: (45)

, in

subject to c .i;= I.

1tn.3
The Lagrangian L(X.X)= 2 corresponding to this problem

Xj(/dj(X)-

Cj,ti)--A"(

.Vl_

I)

j in E

/-

I I <

where X is defined as the phase multiplier. Differentiating 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! ,=I j in phase s. (46)

i.e. all the wjs in the phase are equal to the phase multiplier 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:

Many of the numerical problems of the chemical equilibrium algorithm are solved by the choice of reaction directions given by the columns of Qj. Nonetheless, significant numerical problems may arise in certain situations. In this section we will discuss some common difficulties associated with the implementation of the above procedure. I. Poorl_vconditioned projected Hessian matri iThe 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 depends 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 generating reaction directions (i.e. the procedure for generating 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 complication. However, numerical problems can still occur. Large positive projected Hessian eigenvalues exist when solution species approach zero (note that the eigenvalues 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

= c x,X J111 5

= AS =

o?J

j ins.

(47)

Thus if Xis 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 discussed previously except now we will introduce a protoenstatite 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~ Since we now have a solid solution of two species Eqn. (46) becomes: AS= &;s,$& and hS =
&%gSi206 EMgO CCaO &hO2~

(48) phase consisting

- 2&&o - 2ESio2

(49)

(50)

Substituting Eqns. (37), (38) and (48) into Eqns. (49) and (50) we obtain expressions similar to Eqn. (40): x = RT In KMglsilog- In
a&OOP&O_dl,

A =

aMg*Si206(SSY
kaO(l b&Odl)

(51) 11
(52) II

RT In KCaMei206 - In

aMgO(l

Qk&gSi&.(~~)mi

Non-ideal multiphase systems (1985). In effect, this requires the program to find new reaction directions via Eqns. (17) and (24) which emphasize 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 equilibrium 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). During the calculations, the estimate of the solution is given by the first order approximation of the chemical potentials (Eqn. 20). The first order equivalent of Eqn. (18) is: Q:T;(k)(first order) = 0. (53)

1053

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 component had been added to the system thereby increasing the number of degrees of freedom while not affecting the thermodynamic behavior of the system (thus satisfying 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 equilibrium 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 magnitude of the multipliers may undergo large fluctuations when the composition is far from a local minimum, multiplier estimates when the solution is close to equilibrium (as determined from the magnitude of the elements 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. Consequently precautions are taken so that each phase may only precipitate once before a local minimum is attained (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 CY in 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 a change in a solution species of many orders of magnitude; (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 species, so small that an enormous chemical potential results. 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

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 in more 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 evaporation 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 forsterite above the peritectic point and in the next problem the temperature is taken to be below the peritectic, the algorithm will first precipitate the protoenstatite phase. (Note that in each individual problem the temperature 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 factorization 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 matrix 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 determinant) 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 species mole number corresponding to a pure phase be-

1054

C. E. Hake,

J. P. Greenberg and J. H. Weare direction that takes the system from the initial composition 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 CQ, 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 constraints are violated. Therefore, operating on both sides of Eqn. (54) with 0 gives: 03 = DQ,$, + DQ2~, = 0.

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) no longer apply, p may no longer be expanded on the null space of (C/D) alone. However, since the n orthonormal vectors of Q forms a linearly independent basis set, 13 may be expanded as

(S!

P = Q,;i, + Qzf, + Q,xs

(54)

In this section we shall discuss cases where it is necessary 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 constraint. 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 respect 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 solution 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 calculated with mole numbers 7i, and let -h(9 represent the bulk composition of the system whose equilibrium assemblage we wish to calculate with mole numbers nf. We then have:
cT$~ = XII,

Since DQ2 is lower triangular, and 2, is known, Eqn. (59) is easily solved. The method for solving the zi using a modified Newton direction is described in subsection 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 deleting 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 approach 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 corresponding 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 program 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:

(55) (56) (57) the

DTj5=DTQ2&

(611

and: CT+ = 5 or: CT@_ 3i) = Ax. We define j? as Zi - #I. The vector p is therefore

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

Non-ideal multiphase systems 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. 3. Phase removal When a pure mineral hits the boundary as the result of a Newton step, a constraint is added, effectively removing 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 boundary (consider for example the situation of the COj 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 correspond to the phase being removed are set equal to the negative of the mole number of the species in the current 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 species 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. 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 the boundary 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 calculated 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. As with a phase addition step we expand p in terms . -.+ of 6 2 and b 3. 62 is calculated using Eqn. (6 1) where in the case of a solution phase removal, the non-zero elements of DTp correspond to the negative of the mole numbers of the species in the phase that is being removed. The method for solving for Js is described in the following section. 4. Mod$ed

1055

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 yields the solution for $, : matrix in Eqn. (62)

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 relatively 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 LOW CONCENTRATIONS AT VERY

In Section V we described a numerical problem encountered 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 solution phase species to go below a designated boundary value. For example, in an acidic solution, the concentration 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 species 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 concentration species. In this example the chemical potential of the CO; ion at equilibrium is given in terms of HCOj and H+:
b+ZO;2, = &HCO; )&H+, .

(64)

Newton direction

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 estimated from the activity calculated from Eqn. (64). From Eqn. ( 12) the chemical potential of a species at a minimum is m, /.Lj = 2 Cjiti + W 1 j=. , (65)

In the special directions described in subsections 1, 2 and 3,x, and x2 in Eqn. (54) have been determined

1056

C. E. Harvie. J. P. Greenberg and J. H. Weare GREENBERG J. P., WEAREJ. H. and HARVIEC. E. (1985) An equilibrium computation algorithm for complex highly nonideal systems. Application to silicate phase equilibria. High Temp. Sri. 20, 141-162. HARVIEC. E. (I 98 I) Theoretical investigations in geochemistry and atom surface scattering. Ph.D. dissertation. LJni\!. Microfilm. Int.. Ann Arbor. MI #AAD82-03026. HARVIEC. E. and WEARE J. H. (1980) The prediction of mineral solubilities in natural waters: The Na-K-Mg-CaCl-S04-HZ0 systems from zero to high concentration at 25C. GeoLhim. C(xmochim. .Acta 44, 98 l-997 HARVIEC. E.. WEAREJ. H.. HARDIE I.. A. and F.llc;s~t~ H. P. (1980) Evaporation of seaw-ater: Calculated mineral sequences. Science 208, 498-500. HARVIEC. E., EUGSTER H. P. and WEAREJ. H. ( I U&2) Minera1 equilibria in the six-component systems, Na-K-MgCa-Cl-SO,,-HZ0 at 25C. II. Compositions of the saturated solutions. Geochim. Cosmochim. Acta 46, 1603-l 6 18. HARVIEC. E.. MILLER N. and WEARE J. H. (1984) The prediction of mineral solubilities in natural waters: The NaK-Mg-Ca-H-Cl-SO,-OH-HCOI-Co3-CO1-H,O system to high ionic strengths at 25C. Geochim. (osmoc~him. l~ia 48,723-75 I. HELGESON H. C. (1978) Summary and critique ot ihe thrrmodynamic properties of rock-forming minerals. ,lf?,t~ J. Sci. 27gA, 1-229. LUENBERGER D. G. (1973) Introduc?wn fo Lirreur I& /Vcw lineur Programming. Addison-Wesley. NORDSTROM P. K.. PLUMMER L. N., WIGL.L:L1. ill. 1 WOLERYT. J.. BALLJ. W.. JENNE E. A.. BASSli I R. 1 CRERARD. A., FLORENCE T. M., FRITZB., HOFFMANM.. HOLDRENG. R. JR.,LAFON G. M.. MA~TIC;OD S. V.. MCDUFF R. E.. MORELF., REDDYM. M.. SPOSI IOG. and THRAILKILI J. (1979) A comparison of computerized chemical models for equilibrium calculation in aqueous systems. rl. C: S. Symposium Serie.s No. 93, 857-892. PI.~ZERK. S. (1977) Electrolyte theory-improvements since Debye and Hiickel. Acct. Chem. Res. 10, 371-37 REED M. H. (1982) Calculation of multicomponent chemical equilibria and reaction processes in systems involving minerals, gases, and an aqueous phase. Geochim (i~smochi~~j .4cta 46, 5 13-528. SMITH W. R. and MISSENR. W. ( 1982) ChemlL,al Rlwtiwi Equilibnum .4nalJ:sis:Theory and Algorithms. John Wile\ and Sons. STRANG G. (1980) Linear Algebra and r/s .4pp/1c~afi~~rr~ Lademic Press. VA~X~ HOFF J. H. ( 190.5) Zur Bildurrr: du o-_w~~ scim .W.:
lugerstarrm

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 concentration. The activity coefficient will be approximately constant with a small change in _\;. since it is determined by the concentrations of the species in SOlution that are present in larger amounts. Similarly. since species j is held fixed C C;,t, is a function of the 1--i chemical potentials of the species in large concentrations (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)~

(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 03 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 repeated until the species multipliers are sufficiently small. Editoriul handling: G. R. Holdren. Jr. REFERENCES BEIGHTLER C. and PHILLIPSD. T. (I 976) .@plied (;cometr~c Programming. John Wiley and Sons. BOWEN N. L. (1928) The Evolution oflgneous Rocks Princeton University Press. BRANTLEY S., CRERAR D., MLLER N. and WEARE J. H. (1984) Geochemistry of a marine evaporite: Bocana de Virills, Peru. J. Sediment. Petrol. 54, 447-462. FELMY A. R. and WEAREJ. H. (1986) The prediction of borate mineral equilibria in natural waters: Application to Searles Lake, California. Geochim Cosmochim .4cta 50, 277 I 2784. GARRELSR. M. and THOMPSONM. E. (1962) A chemical model for seawater at 25C and one atmosphere total pressure. Amer. J. Sci. 260, 57-66. GILL P. E. and MURRAY W. (1974) Newton-tvpe methods for unconstrained and lineally c&strained c$timization. Math. Prog. 7, 31 l-350. GHIORSO M. S. (1985) Chemical mass transfer in magnetic processes. I. Thermodynamic relations and numerical algorithms. Contrib. Mineral. Petrol. 90. 107-120. GREENBERG J. P. (1986) The design of chemical equilibtium computation algorithms and investigations into the modeling of silicate phase equilibria. Ph.D. dissertation IJniversity of California, San Diego.

(first part). Vieweg.

VAN? HOFF J. H. ( 1909) Zur Bil&n,q tier oxozwh~x Suirlager.statten (second part). Vieweg. ZOUTFNDIJK G. (1959) Methnd.s ol Feasihlc iI/rcv~itrw\. Flsevier, APPENDIX CONSTRAINT ADDITION AND DELETION

In this appendix we will discuss a method for addmg and deleting individual species constraints without recalculatin& the entire Q matrix. This is important in terms of computation time, since (for example) in our aqueous solution model. there are more than 60 solution and mineral species resulting in a Q matrix of a dimension of at least 60 by 60. We will describe in 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 defined in Section III. All redundant constraints in the C matrix hav? been removed using the same criteria as in the update proconstraint cedure discussed below. Q lrn) is an orthonormal

Non-ideal multiphase systems matrix with which we can construct a null space in which charge, mass balance, and species constraints are not violated. Originally this matrix was calculated by a series of Householder transformations for a particular set of phases giving a particular D matrix. We now wish to add an additional species constraint 2 Jwhich corresponds to chemical species j (constraint number m + 1). Species constraints have the simple form nj = 0. Therefore the elements of aj are of the form: d,=O d,=l i#j i=j. (A.2)

1057

The new Q matrix, operating on the new constraint matrix, must produce an upper triangular R matrix of rank m + 1:
Qm+)T(CIDld) = R+.

All constraints represented in (CID) are linearly independent. Redundant constraints are found by examining the elements of the vector formed by operating on the m + 1th constraint with the Q matrix. If it is found that all elements at and below the m + I th element of this vector are equal to zero, the m + Ith constraint is linearly dependent on the previously added constraints and is discarded. In a manner similar to that used for adding constraints, the Householder 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 be performed to form an upper triangular R matrix of rank m - 1. For example, consider the following R matrix of rank 5: 0 _ ._ 0 0 0 0 _ 0 0 0 ~ 0 0 (A.7)

(A.3)

The old Q matrix, operating on the new constraint matrix will produce an upper triangular R matrix except for the last column due to the addition of the new constraint. The Householder transformation may be used to produce the new Rmf matrix. The new Q matrix, which is formed by transforming the old Q matrix, is given by (STRANG, 1980, p. 29 1): (I- bu~)al-~ = ~(m+ln (~.4)

oo--0 0 0 0 0 0 0 0

where - denotes a nonzero element. If we now remove constraint number 3 from the D matrix, MC1D) with the new D matrix becomes: 0 0 0 0 0 0 _ 0 0 0 0 0 0 0 0 0 0

where I is the identity matrix and ir is formed from the elements of Q Tmafrom the m + lth element on down. Because of the special form of the added constraint (Eqns. A.2) 3 has the form:
0 0 0

64.8)

(A.5)
Q(m)
J

m+3

where

We now wish to find a new matrix which will produce a new upper triangular R. In order to find this matrix, we perform a Householder transformation beginning in column 3. For each successive Householder transformation the D vector contains only two non-zero elements, since for each species constraint 1the elements of the lth column of the old R matrix are all equal to zero for each element greater then 1. After the first transformation, the R matrix assumes the form: 0 0 0 0 0 0 _ 0 0 0 0 0 _ 0 0 0 0 _ 0 0 (A.9)

Q!m)

,m+, +

\/,j+,

Q:?'

(A.@

Since all elements with indices less then m t 1 are zero in 3, only a portion of the Q matrix is changed after the transformation. In addition, we take advantage of the fact that, for a constrained species k, QE is equal to zero for i greater than m (since h must be zero). These two aspects of the transformation considerably decrease the number of operations that would be necessary if the entire Q matrix had to bc recalculated.

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

S-ar putea să vă placă și