Numerical Solution OF' THE Chemical Equilibrium Problem: Memorandum
Numerical Solution OF' THE Chemical Equilibrium Problem: Memorandum
CtkEE49
MEMORANDUM
RM-4345-PR
JANUARY 1965
THE NUMERICAL SOLUTION OF'
THE CHEMICAL EQUILIBRIUM PROBLEM
R. J. Clasen
E
"' PREPARED FOR:
UNITED STATES AIR FORCE PROJECT RAND
I
--
S A N T A M O N I C A - CALIFORNIA
THE NUMERICAL SOLUTION OP
THE CHEMIC ROBLE
R. J. Clasen
This rcwarch is sponsored hy the United States Air F'0'orc.e under Project Rx4NL3-con-
tract No. AF 4.9 (638 1-700 monitored by the Directorat? of De\-clopmw Plan.. Dcputy
Chief of Staff. R e w a r r h and Development, Hq USAF. 1'ii.w~ o r conclnsioiis contained
in thi s M e m o r a n d u m should not be interpreted as rcprrsmtinp tht, official oi'inion or
policy of the Ilnitrd States Air Force.
DDC AVAILABILITY NOTICE
Qualified requesters n a y obtain copies of this report from the Defense Documentatiori
Center (DDC) .
PREFACE
This Memor andumi s one i n a cont i nui ng ser i es of RAND
9
publ i cat i ons deal i ng wi t h t heor et i cal comput at i onal ques-
t i ons ar i si ng f r omt he RAND pr ogr amof r esear ch i n bi ol ogy
and physi ol ogy. The Memor andumcont r i but es t o our abi l i t y
t o appl y comput er t echnol ogy t o t he anal ysi s of compl ex
chemi cal syst ems by consi der i ng t he "chemi cal equi l i br i um
pr obl em, " t he pr obl emof det er mi ni ng t he di st r i but i on of
chemi cal speci es t hat mi ni mi zes t he f r ee ener gy of a syst em
whi l e conser vi ng t he mass of each of t he chemi cal el ement s.
Sol ut i ons t o t he chemi cal equi l i br i umpr obl empub-
l i shed up t o t hi s t i me [4,53 appl y t o t hose pr obl ems f or
whi ch an est i mat e of t he sol ut i on exi st s. Thi s Memor andum
consi der s a pr obl emor whi ch no est i mat ed sol ut i on exi st s
and sol ves t hat pr obl emwi t h t he maxi mumpr eci si on now
avai l abl e.
The mat hemat i cal aspect s of t hi s Memorandurn shoul d
also be of i nt er est i n ot her f i el ds wher e comput at i onal
anal yses of compl ex chemi cal syst ems ar e under consi der a-
tion, e. g. , i n st udi es or' r ocket pr opul si on syst ems,
planetary at mospher es, r e- ent r y pr obl ems, et c.
- vi i -
FOREWORD
I n deci di ng bet ween t he l anguages of mat hemat i cs and
physi cal chemi st r y, we have chosen i n t hi s Memor andumt o
use t hat of mat hemat i cs. The di sadvant age of t hi s choi ce
i s t hat t he physi cal chemi st may exper i ence some di f f i cul t y
i n i mmedi at el y i dent i f yi ng cer t ai n concept s. The advant age
i s t hat mat hemat i cal l anguage di vor ces t he met hods f r om
t he physi cal assumpt i ons i nvol ved i n const r uct i ng a mathe-
2%
mat i cal model of a physi cal syst em. The mat hemat i cal
met hods ar e, hence, f r ee t o t r anscend t hei r speci f i c
chemi cal appl i cat i ons.
The met hods gi ven her e do not sol ve ever y pr obl emt hat
i s speci f i ed i n t he gi ven mat hemat i cal f orm. The sol ut i on of
a pr obl emi n whi ch some phase vani shes (a degener at e pr obl em)
r equi r es f ur t her work. Some work has been done on par t i cul ar
degenerate syst ems [ 133, but the accur at e numer i cal sol ut i on
of a large gener al syst emof this t ype has yet t o be accom-
pl i shed. Unt i l r ecent l y, a ski l l ed physi cal chemi st coul d
i nt ui t i vel y el i mi nat e t he degener aci es of his model and
P
- 1 .
n
The r eader i s r ef er r ed t o other wor ks for t he pr o-
cedur e of const r uct i ng t he mat hemat i cal model s of bio-
chemical sys'tms [9-121.
- vi i i -
obvi at e t he need f or sol vi ng a degener at e syst em.
as pr obl ems gr ow, el i mi nat i ng degener acy becomes i ncr easi ngl y
di f f i cul t . Fr equent l y, t he poi nt at whi ch t he pr obl embe-
comes t oo l ar ge f or t he physi cal chemi st t o deci de whet her
or not t o i ncl ude a phase coi nci des wi t h t he poi nt at whi ch
t he pr obl embecomes numer i cal l y unwi el dy. Hopef ul l y, t he
f ut ur e wi l l el i mi nat e t hese di f f i cul t i es.
But ,
St at ement s about conver gence and conver gence t est s
exi st , unl ess ot her wi se i ndi cat ed, i n t he cont ext of finite-
accur acy numer i cs.
i n t he absence of qual i f i cat i on, that no pr obl emexi st s
nor t hat no machi ne woul d ser ve as a count er exampl e.
Rat her t hey ar e si mpl y descr i pt i ons of what was f ound t o
occur i n act ual pr act i ce.
St at ement s of t hi s ki nd do not mean,
No at t empt has been made to descr i be t hose met hods
whi ch wer e t r i ed and f ound want i ng. The met hods pr esent ed
ar e t hose which ar e best for t he l ar gest number of cases.
Fi nal l y, i t shoul d be poi nt ed out t hat al t hough
comput i ng t i me was a f act or , i t was consi der ed secondar y
t o accur acy of r esul t s.
. ..
- ix-
ACKNOWLEDGMENTS
The author wishes to thank J. C. DeHaven, E. C.
DeLand, F. R. Gilmore, and M. Z. Shapiro for their many
constructive comments and suggestions.
, 1'
-xi-
CONTENTS
PREFACE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
SUMMARY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
FOXEWORD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ACKMOWLEDGMmTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
i i i
V
vi i
i x
Sect i on
1. I NTRODUCTI ON . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2. THE I NI TI AL SOLUTI ON . . . . . . . . . . . . . . . . . . . . .
The Pr oj ect i on Met hod . . . . . . . . . . . . . . . . . .
The Li near Pr ogr ammi ng Met hod . . . . . . . . . .
3. THE LI NEAR- LOGARI THMXC PROGRAMMI NG
PROBLEp/I, FI RST- ORDER METHOD . . . . . . . . .
15
4. THE FI RST- ORDER METHOD FOR SOLVI NG TJ 3E
CHEMI CAL EQUI LI BRI UMPROBLW. . . . . . . .
21
5. THE LI NEAR- LOGARI THMI C PROGRAMMI NG
PROBLEM, SECOND- ORDER METHOD . . . . . . . .
28
6, THE SECOND- ORDER CHEPl I CAL EQUI LI BRI UM
ALGORI THM . . . . . . . . . . . . . . . . . . . . . . . . . . .
33
35
7,
SUMMARY OF THE COMPUTATI ON PROCEDURE . . . . .
Appendi x
A.
A FORTRAN- I V PROGRAMFOR SOLVI NG THE
CHENICAL EQUI LI BRI UMPROBLEM . . .
37
37
41
45
. . . . .
. . . . .
. . . . .
. . . . .
General . Descr i pt i on . . . . . . . . . . . . . . .
Li st i ng . . . . . . . . . . . . . . . . . . . . . . . . . . .
Subr out i ne . . . . . . . . . . . . . . . . . . . .
Subr out i nes . . . . . . . . . . . . . . . . . . . . . . .
Cal l i ng Sequence for Si mpl ex
56
. . . . .
B. MATRI X NOTATI ON ANI ) FURTHER PROOFS . .
67
. . . . .
REFERENCES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
79
- 1-
1. IhTRODUCTION
For t he pur poses of t hi s Memor andum, the chemi cal
equi l i br i umpr obl emi s mer el y a name we use f or a par -
t i cul ar mat hemat i cal pr ogr ami ng pr obl em, i . e. , t he prob-
l Y X Y
l emof mi ni mi zi ng a par t i cul ar nonl i near f unct i on F(x
. . . xn)
st r ai nt s or const r ai nt s
def i ned bel ow, whi l e sat i sf yi ng the l i near r e-
n
i
1 ai j xj = b i =l , 2, 3, . . . , m
j =I
wi t h x 2 0 for j=lY2, . . . ,n and a b. gi ven const ant s,
j i j 1
Assumi ng t hat t he equat i ons of (1. 1) ar e l i near l y i nde-
pendent , t hen i n or der t o have a non- t r i vi al pr obl emit can
be assumed that men.
consi der ed component s of a vect or (x I, x2, . . . xn9 ,
t he chemi cal equi l i br i umpr obl emt hen i s t he pr obl emof
The var i abi es xl , x2$. . . ,x can be
n
Sol vi ng
det er mi ni ng t hi s vect or . The var i abl e x. wi l l be r ef er r ed
t o as t he rfjth component ! ; al so t he numer i cal val ue of x
may be r ef er r ed t o as the component r at her than usi ng
J
j
t he per haps l i ngui st i cal l y cor r ect but cumber some t er m
component value. I
I f
- 2-
The component s ar e par t i t i oned i nt o p non- empt y
subset s cal l ed compar t ment s,
Let us denot e t hese compar t -
ment s by (l), (2>, . . . , {p). Then i f t he j t h component i s
t h
i n t he k compar t ment , we wi l l say j c (k), wher e each
component i s i n exact l y one compar t ment . The number of
t he Compar t ment t hat t he j t h component i s i n i s denot ed
by [j].
Each compar t ment has associ at ed wi t h i t a sumdef i ned by
Hence jc(k) i mpl i es [j] = k, and conver sel y.
-
X
The component f r act i on x A i s def i ned by x h = i - whenever
[j 1
j j S
Lj l
S
is
The obj ect i ve f unct i on t o be mi ni mi zed over (1. 1)
4- log x.) r\ (1.3)
J
wher e cl,e2,. . . , c
const ant s.
are gi
n
n
= 1 x.(c
J j
j =1
en const an- s, cal l ed ob- j ect i ve
When an x i s zer o, l og x A i s undef kned; but we de-
j j
f i ne 0 log 0 t o equal 0 so t hat we may eval uat e F when
-3-
,-
some component s are zer o. A f easi bl e sol ut i on t o t he
chemi cal equi l i br i umpr obl emi s def i ned t o be any set of
non- negat i ve component s t hat sat i sf i es (1.1). The pr obl em
i s sai d to be f easi bl e i f i t has f easi bl e sol ut i ons. I f
no f easi bl e solution i s ar bi t r ar i l y ' l arge i n any component ,
t he f easi bl e pr obl emi s sai d t o be bounded f easi bl e; al l
pr act i cal pr obl ems wi t h whi ch one mi ght have occasi on t o
deal ar e bounded f easi bl e.
A sol ut i on or opt i mal sol ut i on t o a bounded f easi bl e
pr obl emI s any f easi bl e sol ut i on i n whi ch F(x 1' * YXn)
at t ai ns t he mi ni mumval ue over al l f easi bl e sol ut i ons. A
pr obl emwhi ch has opt i mal sol ut i ons i n whi ch some component
i s zer o i s cal l ed degener at e, and a bounded feasible pr ob-
l emi n whi ch t he component s i n any opt i mal sol ut i on ar e
a11 st r i ct l y posi t i ve i s cal l ed a non- degener at e pr obl em.
I t has been shown [l, Theor em12.13 t hat a non- degener at e
pr obl emhas exact l y one opt i mal sol ut i on. Hence, we may
speak of _e t he sol ut i on t o t he pr obl em. Fur t her mor e, i t has
t
al so been shown for
mi ni mi zat i on of F i s
r 1, r 2, . . . , r m, cal l ed
?i
Ref . 1, p. 18.
t he non- degener at e pr obl emt hat the
equi val ent t o t he exi st ence of number s
Lagr ange mul t i pl i er s, whi ch sat i sf y:
-4-
A
3
1 viaij = c + log x. . j=1,2,3,.,.,n (1.4)
j 3
I n t he f ol l owi ng sect i ons we der i ve condi t i ons,
anal ogous t o (l..4), whi ch ar e usef ul i n sol vi ng t he pr obl em.
I n Sec. 2 we ar e i nt er est ed i n f i ndi ng a sol ut i on t o (1. 1)
wi t h al l x 0. A set 02 x whi ch sat i sf i es t hese con-
di t i ons i s called a posi t i ve f easi bl e sol ut i on. I f (1. 1)
j j
i s sat i sf i ed wi t h x 2 0, we have cal l ed such a r esul t a
f easi bl e sol ut i on.
j
The t heor y of l i near pr ogr ami ng gi ves
us met hods of f i ndi ng f easi bl e sol ut i ons t o pr obl ems wi t h
l i near r est r ai nt s. I n Sec. 2, we use a l i near pr ogr ammi ng
t echni que to f i nd a posi t i ve f easi bl e sol ut i on. I n Sec. 4
we show how t o modi f y t he i ni t i al posi t i ve f easi bl e sol u-
t i on t o get t he sol ut i on t o t he pr obl em.
- 5-
2. THE INITIAL SOLUTION
The al gor i t hms pr esent ed i n t he f ol l owi ng sect i ons
r equi r e an i ni t i al posi t i ve f easi bl e sol ut i on i n or der t hat
t he pr ocedur e or sol vi ng t he pr obl emcan be i ni t i at ed,
Fr equent l y, an i ndi vi dual wi t h a pr obl emt o sol ve wi l l be
abl e t o gi ve a r at her accur at e est i mat e of i t s opt i mal
sol ut i on.
anot her pr obl emwhi ch di f f er s f r omt he one bei ng consi der ed
i n r el at i vel y mi nor ways.
Thi s est i mat e may be t he exact sol ut i on of
THE PROJ ECTI ON METHOD
Let us suppose t hat such i s t he case, and l et us de-
not e t he est i mat e of t he component ' s by ylJyz,, . . , yn.
val ues, subst i t ut i ng y f or x i n Eq. (l.l), wi l l not
gener al l y sat i sf y (1.11, bei ng somewhat i n er r or . Let us
denot e t hese er r or s by gl , g2, . . . , gm, * t hat i s, l et
These
j j
gi = i - 1 ai j Yj .
i =l , Z, . . . , rn
(2.1)
j =l
Then, we wi sh t o f i nd cor r ect i ons t o y such t hat , denot i ng
j
t he cor r ect i ons by 8 we have
j'
3
n
- 6-
or
n
j =1
The 8. must al so be chosen such t hat y + 8. 0, f or al l
j. We cannot guar ant ee t hi s condi t i on, but we can at t empt
J j J
t o choose smal l val ues f or 8 . One way t o do t hi s i s t o
mi ni mi ze
j
n
2
J j
1 w.0
j -1
subj ect t o (2. 2), wher e w i s t he "wei ght " or r el at i ve
i mpor t ance of mi ni mi zi ng 8 . Thi s r educes t o t he pr obl em
of f i ndi ng Lagr ange mul t i pl i er s T ~, V ~~~. . , T ~, such t hat
wi t h
j
j
n m / n
we have
- =
aL 0 .
ae
j
j=1,2,. . . ,n (2.4)
-7-
Equation (2.4) becomes
m
i=l
j=1,2,. . . ,n (2.5)
and substituting (2. 5) into (2.2) we have
The terms
can be immediately evaluated; let us denote these terms
by
Not e that q = . Then, (2.6) becomes
y,i it
i=l, 2, . . . ,m.
- 8-
Equat i on (2. 8) i s 8 set of msi mul t aneous equat i ons i n
t he m unknowns, V ~ , V ~ , ~ . . , V ~ ~
sol ved f or nl,n2,. . . ,v
st i t ut ed i n (2.5) t o get Q1,Q2,...,Q,.
These equat i ons may be
and t hen t hese values may be sub-
m
Ther e r emai ns the
quest i on of choosi ng val ues f or t he wei ght i ng f act or s
*
w .
using
I n t est s of t hi s met hod,
i t has been f ound t hat
j
yi el ds sat i sf act or y r esul t s.
f act or s depends, t o some ext ent , on t he avai l abl e com-
The choi ce of t he wei ght i ng
put er s.
t he comput at i on of 8
Usi ng t hese wei ght i ng f act or s, we can summar i ze
i n t he f ol l owi ng t hr ee equat i ons:
j
1
A
n
i=l,Z, . . . , rn
.p,-1,2,. . . , m
m
j=1,2,. . . ,m (2.11)
wher e
x = y . + Q .
j 3 j
-9-
j=1,2,. . . ,n (2.12)
The x. f r om( 2, 12) wi l l sat i sf y (1. 1). However , t he
J
x need not al l be st r i ct l y posi t i ve. I f any x i s zer o
or negat i ve, t hi s met hod of obt ai ni ng t he i ni t i al sol ut i on,
whi ch we shal l cal l t he pr oj ect i on met hod, has f ai l ed. I f
t he pr oj ect i on met hod f ai l s, or i f no i ni t i al est i mat e i s
pr ovi ded, t hen a l i near pr ogr ami ng met hod may be used.
j j
THE LINEAR PROGRAMMING METHOD
The t er mi nol ogy used i n l i near pr ogr ammi ng i s si mi l ar
to t he t er mi nol ogy used above i n descr i bi ng t he chemi cal
equi l i br i umpr obl em. The st at ement of a l i near pr ogr am-
mi ng pr obl emi ncl udes a set of l i near r est r ai nt s
n
C ai j xj = bi
i=l,2, . . . , m (2. 13)
j =1
J
t oget her wi t h a set of const ant s C 1 C 2 C 3.9Cn cal l ed
cost s. A f easi bl e sol ut i on t o a l i near pr ogr ammi ng pr obl em
i s any set of non- ner at i ve x such t hat ( 2. 13) i s sat i sf i ed.
The costs ar e used t o f or mt he f ol l owi ng expr essi on,
which ,is cal l ed t he obj ect i ve f unct i on
j
L,
-10-
n
L = 1 cjxj .
j =l
(2.14)
For ever y set of f easi bl e x we can eval uat e L. The set
of f easi bl e x f or whi ch L has t he mi ni mumval ue t hat i t
j
j
can have with any set of f easi bl e x i s cal l ed a sol ut i on
j
of t he l i near pr ogr ami ng pr obl em. A pr obl emwhi ch has
set s of f easi bl e x i s cal l ed a f easi bl e pr obl em, and a
j
pr obl emi n whi ch t her e ar e no set s of f easi bl e x i s cal l ed
an i nf easi bl e pr obl em. An i nf easi bl e pr obl emhas no sol u-
j
t i ons, whi l e a f easi bl e pr obl emhas at l east one sol ut i on.
I n t hi s di scussi on, we wi l l not be concer ned as t o whet her
a pr obl emhas mor e t han one sol ut i on: we wi l l onl y be
_I _
concer ned wi t h f i ndi ng a sol ut i on t o t he pr obl em. Si nce
-
t he means of f i ndi ng a sol ut i on t o a l i near pr ogr ammi ng
pr obl emhas been t he subj ect of many paper s and books, we
will not gi ve an act ual met hod of sol vi ng t he l i near pr o-
gr ammi ng pr obl emher e. The r eader may r ef er t o Dant zi g
[Z] f or a compl et e di scussi on of t he pr obl em.
The problem of f i ndi ng a feasible solution to a
linear programming problem is itself a linear programing
pr obl em- - t hat i s, i t i nvol ves f i ndi ng a sol ut i on t o t he
,J
c
-11-
pr obl emwi t h al l C equal to zer o. Wi t h al l C = 0, L i n
j j
(2. 14) i s zer o f or any set of f easi bl e x hence, L i s at
i t s mi ni mumval ue or any set of f easi bl e x . Si nce L i s
at i t s mi ni mumval ue f or any f easi bl e set of x any
f easi bl e set of x i s, by t he above def i ni t i on, a sol ut i on
j
j
j
j
t o t he l i near pr ogr ammi ng pr obl em.
However , we must not onl y f i nd a f easi bl e sol ut i on t o
t he l i near pr ogr ammi ng pr obl em, we must also f i nd a posi t i ve
f easi bl e sol ut i on t o t he pr obl em. I n or der t o do t hi s, we
1 et
xj = Yj + Yn*l *
j=1,2,. . . , n (2.15)
I f we can f i nd non- negat i ve val ues of y1, y2, . . . , yn+1
whi ch sat i sf y
n
j =1
i=l,2, . . . , m (2.16)
t hen x as def i ned by (2. 15), wi l l be a f easi bl e sol ut i on.
I f we can somehow assur e that y
x wi l l be poskt i ve. Rewr i t i ng (2.16), we have
j
i s posi t i ve, t hen _I _ al l
n+1
j
S
-12-
n n
i=1,2,. , . ,m (2.17)
j =l j-1
I f we now speci f y C 1' C 2' - * J,+y we have a l i near pr ogr am-
ming pr obl emi n ni-1 unknowns.
En or der t o guar ant ee t hat
i s posi t i ve, i f i t i s possi bl e f or i t t o be posi t i ve,
Y,+1
I t i s easy t o see t hat we can maxi mi ze
n+l
we can maxi mi ze y
Yn+l
by set t i ng
whi ch i s equi val ent to set t i ng C1=C2=C3=,..=G =0, Cn+l = - 1.
n
I f t he sol ut i on t o t he r esul t i ng l i near pr ogr ammi ng pr obl em
i s f easi bl e and y
f easi bl e sol ut i on t o the anal ogous chemi cal equi l i br i um
pr obl em(1.1).
n+l
but y
i s degener at e, si nce t her e i s no st r i ct l y posi t i ve sol ut i on
t o t he pr obl em.
degener acy, and i t s occur r ence usual l y i ndi cat es t hat a
mi st ake was made i n set t i ng up the pr obl em.
l i near programming met hod gi ves us a way of f i ndi ng a posi t i ve
feasible sol ut i on t o t he chemi cal equi l i br i umpr obl emFf
t he chemi cal equi l i br i umpr obl emLs non- degener at e,
9. 0, t hen we have, by (2. 15),
a posi t i ve
n+l
If t he l i near pr ogr ami ng pr obl emis f easi bl e
= 0, t hen t he anal ogous chemi cal equi l i br i umpr obl em
However, t hi s i s a r at her t r i vi al ki nd of
Hence, t hi s
-13-
The posi t i ve f easi bl e sol ut i on t hat we obt ai n by t hi s
met hod wi l l gener al l y not r esembl e t he f i nal sol ut i on of
t he chemi cal equi l i br i umpr obl em. The i ni t i al posi t i ve
f easi bl e sol ut i on can be i mpr oved by t he f ol l owi ng t ech-
ni que. Def i ne bmt. l t o be some mul t i pl e, bet ween zer o and
t hat was obt ai ned above. Then, one, of t he val ue of y
adj oi n t o t he l i near r est r ai nt s (2. 17) one mor e r est r ai nt
- . Next , solve t he l i near pr ogr am- of t he form Y,,~
mi ng pr obl emwi t h t hese r est r ai nt s and wi t h C =e C =e
1 1 2 2
=O ( r ecal l t hat t he l ower - case cs her e
. e . y cn=cn, n+l
r ef er t o t he c s i n t he chemi cal equi l i br i umpr obl em(1.3))
The sol ut i on t o t hi s l i near pr ogr ammi ng pr obl emwi l l gi ve a
set of component s mor e near l y r esembl i ng t he sol ut i on t o t he
chemi cal equi l i br i umpr obl emt han di d t he component s cal cu-
l at ed f r omEqs. (2. 17) and (2. 18). Thi s new sol ut i on, i n
t ur n, may be i mpr oved by sol vi ng anot her l i near pr ogr ammi ng
pr obl em( t he det ai l s of whi ch can be seen i n SUBROUTI NE LP i n
Appendi x A) and aver agi ng t he new sol ut i on wi t h t he ol d sol ut i on.
n+l
- brn+l
I n or der t o solve an el abor at e chemi cal equi l i br i um
pr obl emi t i s not suf f i ci ent t o si mpl y use a met hod whi ch
we can pr ove conver ges t o t he cor r ect sol ut i on. Pr oof s
of c onver genc e gen er a1 1 y as sume i nf i ni t e c ompu t: a t i onal
accur acy, but si nce we ar e usual l y l i mi t ed i n pr act i ce t o
J
-14-
about ei ght si gni f i cant di gi t s, t he numer i cal sol ut i on wi l l
not al ways conver ge. However , i t has been obser ved t hat
t he cl oser we can get t o t he sol ut i on by t he i ni t i al sol u-
t i on met hods descr i bed above, t he gr eat er wi l l be t he
pr obabi l i t y t hat t he numer i cal pr ocedur e wi l l conver ge.
Fur t her mor e not onl y wi l l t he pr obabi l i t y of conver gence
be gr eat er , but t he number of i t er at i ons t o get t o t he
sol ut i on wi l l be f ewer , and hence- - when an i mpr oved i ni t i al
sol ut i on i s used- - t he comput at i on t i me wi l l be shor t er .
Unf or t unat el y, t he mat hemat i cal met hods t hat ar e avai l abl e
f or anal yzi ng conver gence of i t er at i ve pr ocesses do not ,
i n t he case of t he chemi cal equi l i br i umpr obl em, enabl e us
t o prove conver gence when we me l i mi t ed t o f i ni t e mat he-
mat i cal accur acy. Onl y exper i ence wi t h a par t i cul ar met hod
wi l l t el l us whet her i t i s a usef ul numer i cal pr ocedur e
t o use.
I n t he next sect i on we consi der a somewhat mor e gener al
pr obl emt han t he chemi cal equi l i br i umproblem. Thi s pr ob-
l emi s consi der ed f i r st because t he numer i cal r esul t s t ake
on an especi al l y si mpl e form when t he addi t i onal gener al i t y
i s admi t t ed.
-15-
3. THE LINEAR-LOGARITHMIC PROGRAMMING PROBLEM,
FIRST-ORDER METHOD
I n t hi s sect i on we consi der %he pr obl emof mi ni mi zi ng
N
j =1
whi l e sat i sf yi ng t he l i near r est r ai nt s
N
1 ai j xj = b i .
i=1,2,3, . . . , M (3.2)
j =1
Y
The symbol s aij, bi, c and d denot e const ant s, and
j j
X 1 , X 2 , . . * , ~ ar e t he unknowns t hat we seek. We r est r i ct
t he pr obl emt o t he case t hat d 0 f or j = ly2,3,..,>N.
j
We not e t hat i f x 0, t he t er mi n (3*1), x. (c + d log x.),
j ~j j J
i s undef i ned, wher eas i f x 0 t hi s t er mi s def i ned. I f
x = 0 we def i ne x.(c + d.log x ) = 0, si nce this expr essi on
appr oaches zer o as x 0 appr oaches zer o. Fr omt hi s di s-
cussi on, we see t hat , i n or der f or a sol ut i on of Eqs. (3. 1)
j
j J j J 1
j
and (3. 2) t o be def i ned, we must assume t hat x 2 0 f or
j
j = 1,2,3, . . . , N.
We may attempt to solve this problem using Lagrange
9;
multipliers. In this method we let
and then set
for j = 1,2,3,, ~. , N. Performing the partial differentia-
tion, we get
M
c $. d. log x + d - 1 riaij = 0 ,
j 3 j j
i=l
(3.3)
j=1,2,3,. . . ,N
or , when rearranged ,
j=1,2,3,. . , N
7k
See Kaplan, Ref. 3, p. 128, or Dantzig, Ref. 2,
p * 140.
-17-
Exponent i at i ng bot h si des of (3.4), we get
M
1 n a d - d. - 1 c - ~] .
i i j J j
i =l
j =1, 2, 3, . . . , N
(3.5)
Not e t hat or (3. 5) t o be a sol ut i on t o t he pr obl em, we
F
must have al l x 3 0. We assume, i n t he r emai nder of t hi s
sect i on, t hat t he sol ut i on does have a11 x 0. Then,
t he pr obl emr educes t o t he problem of det er mi ni ng t he M T
j
j
i
so t hat t he x from (3. 5) sat i sf y (3.2) Equi val ent l y,
t he M+ N equat i ons (3. 2) and (3. 5) must be sat i sf i ed si mul -
j
t aneousl y by t he proper choi ce of t he M+ N unknowns,
971, ~2, *. . , 3qY x p 2 . . . , %.
of appr oxi mat i ng t he sol ut i on.
We now consi der t wo met hods
I n t he f i r st met hod, we suppose t hat we have an est i -
mat e of t he x. whi ch may or may not sat i sf y (3. 2). We
J
denot e t hi s est i mat e by y and, i n t hi s met hod, sol ve
Eqs. (3. 2) and (3. 4) si mul t aneousl y by maki ng a l i near
j y
appr oxi mat i on t o log x . Si nce we have t he est i mat e t hat
x i s near y
pansi on of log x about y i s
j
we not e t hat the f i r st - or der Tayl or ex-
j j 9
j j
x -Y
log x
= log yj +
+ (higher-order terms) , (3.63
yj
Dropping the higher-order terms, and substituting (3.6) into
(3.4) and solving for x j we have
M
4 -1
1 viaij - d. c
- log yj
3 j
i=l
xj j
(3.7)
L
j=1,2,3 , . . . , N
/
Now, if we substitute these x j into (3.2), we get
- -1
j =1
i=1,2,3, . . . , M
Denoting
j =1
and
(3 8)
&=1,2,3, . . . , M
i=l,2,3, . . . , M
N
/3 -1
s = bi + 1 a y.(log yj + d. c.>
i ij J 3 . 3
(3.91
j =1
i==1,2,3, . . . , M
J
we have
-19-
i=1y2,3y...yM (3.10)
Equat i on (3. 10) i s a set of si mul t aneous equat i ons whi ch
can be sol ved f or vl,mZ , . . . , vN.
Wi t h t he above r esul t s, we C ~ R now def i ne t he i t er at i ve
pr ocess f or t he f i r st met hod. At each i t er at i on we have a
. . . , x At t he begi nni ng of t he
S X 2 ~ N'
set of val ues f or x
i t er at i on t hese val ues ar e cal l ed ylyyZ,...yyNy and at t he
end of t he i t er at i on t he val ues ar e x 1?X2>..'YxN.
I f
i s smal l f or each j , t hen we say we have conver ged.
magni t ude of "small" depends on t he nat ur e of the pr obl em.
I f
The
i s not smal l f or some j, then we have not conver ged and
t he i t er at i on must be r epeat ed.
the f ol l owi ng t hr ee st eps:
One i t er at i on consi st s of
,
..
-20-
1) Eval uat e t er ms i n Eqs. (3. 8) and (3.9), t hese
t er ms dependi ng on yl,y2, ...,yN;
2) Sol ve Eq. (3. 10) f or a1,r2 , . . . , aM;
3) Subst i t ut e nl,a2, . . . , a i nt o (3. 7) t o get
M
x p y Y%*
For t hi s problem, i n t hi s gener al i t y, we can say not h-
i ng about whet her t hi s i t er at i ve pr ocess conver ges. I n
the next sect i on we wi l l show t hat t he chemi cal equi l i br i um
pr obl emi s a speci al case of t hi s pr obl em, and one for whi ch,
wi t h appr opr i at e modi f i cat i on, t hi s met hod does conver ge.
-21-
4, THE FIRST-ORDER METHOD FOR SOLVING THX
CHEMICAL EQUILIBRIUM PROBLEM
The chemical equilibrium problem is a special ease
of the linear-logarithmic programming problem.
to put Eqs. (3.1) and (3.2) into the form of Eqs. (1.1)
and (1.31, we first define
In order
N = n4.p
M = mtp
where, as stated previously, p is the number of compartments
in the problem. Then we define a bi, x and c for
ij 3 j
i > rn and j n, as follows
bi = 0
c = o
j
i=m+l,m+2, . . . ,M
(4.1)
j=n+l,n+2,. . . , N (4.2)
-22-
0 i f i r m, j >n
1 i f i m, j n, and [j] = i - m
0 i f i m, j n, and [j ] # i - m (4.4)
- 1 i f i m, j > n, and i-m = j - n
0 i f i 9 m, j n, and i - m# j - n .
i j
For al l j , we def i ne
+1 i f j s n
- 1 i f j > n .
d j = [
(4.5)
Wi t h t hese def i ni t i ons, i t has been shown c4] t hat t he two
pr obl ems are i dent i cal . Next , we l et
+ 1 . i >m
=\'; + log s i-m
Subst i t ut i ng Eqs.
(3. 10) and si mpl i f yi ng, we have
(4.1) through (4. 6) i nt o (3. 7) t hr ough
23-
(4.7)
kj I*
1
m
A
1 aijri - c - log y. + n'
j J
i=l
j=1,2,. . . ,n
,
-
r. -
12.
s! =
1
M
C atjYj
j c (i-m)
rl
z a y ij j
0
I n
bi -t- 1 aijyj(cj + log yj A - 1)
j =1
i sm
(4.9)
P
i=l,2, . . . , M (4.10)
The directional derivative of F in the direction
(0,,Q2, . . ,Qn> is given by el, Theorem 8.113 to be
- 24-
n
1 ej(cj 3- log gj) .
j =1
Q2d
Y:
But , i f we comput e 1 A wher e by (3. 7)
r 1
(4.11)
(4.12)
k=1,2, ...,p
we show, i n Appendi x B, t hat
rn n
Q?d n
IT= - 1 Q.(c f log 9.) -I - 1 r i (bi - 1 ai j yj ) . (4.13)
J j 3
j=1 j=l i =l j =1
Thus, i f we assume t hat (y,,y, , . . . , y ) is f easi bl e, we get
t he i nt er est i ng r esul t t hat t he di r ect i onal der i vat i ve of
F i n t he di r ect i on (01,02,...38n) is
m
(4 - 14)
However , i t i s also shown i n Appendi x 3 t hat t he
equal i t y on t he r i ght si de of (4.14) hol ds i f and onl y i f
t he val ues for y are opt i mal .
( yl , y, , . . . ,y ) i s feasible, t hen
We further not e that i f
j
n
- 25-
n
1 ai j Qj = 0
j =l
f or i = 1, 2, . . . , m.
t hen ( yl +XQ y y +X02y. . . , y +XQ ) wi l l be f easi bl e for any
k f or whi ch each y + he. i s posi t i ve.
Hence, i f ( y1, y2, ...,y,) i s f easi bl e,
1 2 n n
j J
We now st at e t he f i r st - or der chemi cal equi l i br i um
al gor i t hm:
1)
Cal cul at e (Q,,Q,, . . . ,en) usi ng Eqs. (4. 7) t hr ough
(4. 10).
2) Cal cul at e t he di r ect i onal der i vat i ve of F i n t he
di r ect i on ( @l , Q2y. , . y0 ) as gi ven by Eq.
i f t hi s quant i t y i s not negat i ve, we ar e done.
(4.11);
n
3) Cal cul at e
e i s a number t hat r epr esent s t he r oot - mean- squar e
er r or i n ( ~~, y~~. . . , y, ) .
gi ven number ( say, 0. 001) , we ar e done.
If F i s less t han some
-26-
4) Cal cul at e t he r a i o -y,/Q. for ever y j for whi ch
J J
0. < 0, Let X be t he mi ni mumof al l such r at i os
and l et X = mi n (l,pA1)* where j3 i s a number less
t han 1 but cl ose t o 1 {say, 0.99). We now per -
J 1
f or mt he f ol l owi ng st eps unt i l t he t est at c) be-
l ow i s sat i sf i ed:
a) Let z i= y. -t- lej;
b) Comput e t he di r ect i onal der i vat i ve of F at
J J
z i n t he di r ect i on (Q 8 ..,0 ): f(X) =
Q.(c + l og 2.);
j 1' 2'' n
A
J j J _I
c) If f(X) s 0, go di r ect l y t o st ep 5);
d) Repl ace X by yX, wher e 0 < y < 1, e, g. , y = L fi .
2
5) Fi nal l y, r epl ace y by y. 1- A@ f or j = lS2,*..,,n,
j 3 j
St eps 1-5 are r epeat ed unt i l ei t her t he test i n st ep 2 or
t he t est i n st ep 3 i s sat i sf i ed.
I f t hi s pr ocess t er mi nat es, t he sol ut i on wi l l be
opt i mal wi t hi n t he speci f i ed l i mi t s of accur acy, I t may
happen t hat t he pr ocess does not t er mi nat e. Si nce t he
obj ect i ve f unct i on F i s convex and assumi ng i nf i ni t e
*
comput at i onal accur acy, non- t emf nat i on can occur onl y be-
cause t he values chosen for A become smaller on every
*
Ref . 1, Theor em8. 13; ReE. 5.
i t er at i on. Thi s wi l l occur onl y i f some y i s appr oachi ng
zer o, and hence (y , y ...,y 1 i s appr oachi ng a poi nt at
whi ch, i f i t wer e t he opt i mal sol ut i on, t he pro' bl emwoul d
be degener at e. It i s possi bl e f or t hi s t o happen or a
non- degener at e pr obl emf or whi ch t he i ni t i al sol ut i on
chosen was t oo f ar f r omt he opt i mal sol ut i on. Conver gence
can be guar ant eed by i mposi ng t he condj t i on t hat t he val ue
j
1 2' n
of F at t he i nf t l al sol ut i on be l ess t han t he val ue of F
at any f easi bl e, degener at e poi nt . However , i t i s not
pr act i cal to i mpose t hi s condi t i on on t he i ni t i al sol ut i on
si nce i t may be ver y di f f i cul t t o f i nd such a poi nt . I n
pr act i ce, i t has been f ound t hat r ound- of f er r or s cause
mor e di f f i cul t y t han t he possi bl e sel ect i on of a poor
i ni t i al sol ut i on,
-28-
5. THE LINEAR-LOGARITHMIC P R O G W I N G PROBLEM,
SECOND-ORDER METHOD
I n t he f i r st - or der met hod, pr esent ed i n Sec. 3, t he
i t er at i ve pr ocess was i ni t i at ed wi t h an est i mat e of t he
I n t he second- or der met hod, we
N'
val ue of xl , x2, . . . , x
assume t hat t he pr obl emi s as def i ned by Eqs. (3. 1) and
(3.21, but t hat we have i ni t i al est i mat es f or t he val ues
Let us denot e t hese est i mat es by
M'
of 7T1,7T2,**.,a
xl , xz>- * ?A*'
The x. can t hen be eval uat ed by Eq. (3.5),
subst i t ut i ng Xi f or vi. These x however , pr obabl y wi l l
J
j'
not sat i sf y Eq. (3. 2). The pr obl emof the second- or der
met hod i s t o f i nd number s bAl,Ak2,...,AAM, such t hat
7T = A. +Mi
i 1
i=1,2, . . . , M
when subst i t ut ed into (3. 4) will gi ve x t hat satisfy (3.2).
j
I n or der t o accompl i sh t hi s, we f i r st use t he x
j
cal cul at ed f r omEq. (3. 5) t o get
N
gi = bi - 1 aijxj
j=1
(5. 2)
where g
Next, we evaluate
represents the amount that equation i is in error.
i
= - 1 aij & a
1,
j=1
-
N r / M \
exp (,djl 1 Ahahj d - d. -1 c - 1,)
3 . j
h-l
N
(5 3)
where r is given by Eq. (3.8). If we make a very small
change, dXly dA2, . . . , in X1,Xz,...y the change in g1,g2y.,.y
is given by dg lydg2,...3 where
t i
i=l92, . . . , M
-30-
M
We would want dg to be equal to -gi as computed by
i
Eq. (5.2). If we make the approximation that
A
I
c
ax
is constant over the domain considered, we can set
dgi - - -gi9 let dh = M and write
m_ 1-
M
(5. 5)
Equation (5.5) consists of M equations in the M unknowns
M1,CA2t.. . ,MM. We may thus solve Eq. (5.5) for
AA1,M2y...,% and compute T ~ ~ T ~ , . . . , ~ T ~ from (5.1). If
the assumption aboue
being constant over the domain considered was correct, then
-31-
t he x
sat i sf y (3.2). However , i n gener al , t hey wi l l not sat i sf y
comput ed f r om(3. 5) wi t h t hese val ues f or nf wi l l
j
(3.2), but i f we wer e cl ose enough t o t he sol ut i on so
t hat t he
di d not var y gr eat l y
val ues f or x shoul d
di d t he f i r st set of
j
i n t he domai n consi der ed,
come cl oser to sat i sf yi ng
j
X
t hen t he new
(3. 2) t han
Wi t h t hi s assumpt i on, we may now st at e t he i t er at i ve
pr ocess:
M
Usi ng t he val ues at hand f or nl,v2y*,.,n
eval uat e (3. 5) .
Usi ng t he val ues f or x
eval uat e (5. 2).
smal l , we ar e done.
Comput e r
obt ai ned i n st ep a,
j
I f t he l gi l ar e suf f i ci ent l y
usi ng (3. 8) and sol ve (5. 5) f or LAi .
i t
Denot i ng t he n i n st ep a by X we get new 7~
i i i
by (5. 1).
Steps a- d ar e r epeat ed unt i l t he / g. I J comput ed i n st ep
by ar e suf f i ci ent l y small, or unt i l t hey show no mor e
i mpr ovement .
1
-32-
Ther e i s no pr oof of conver gence f or t hi s met hod.
I n act , t he met hod pr esent ed her e i s unl i kel y t o conver ge
unl ess t he st ar t i ng val ues of T ~ , T ~ , , . . , T
and even t hen t her e may be no conver gence. Thi s met hod may
be used on t he chemi cal equi l i br i umpr obl emaf t er t he Ei r st -
or der met hod has r esul t ed i n a r easonabl y good sol ut i on.
If t he 7~ obt ai ned f r om(3. 10) i n t he f i nal i t er at i on of
t he f i r st - or der met hod ar e used t o i ni t i at e t he second- or der
met hod, t he accur acy pr oduced by t he second- or der met hod
wi l l gener al l y be bet t er t han t hat whi ch coul d be achi eved
by use of t he f i r st - or der met hod onl y.
ar e ver y good,
M
i
-33-
6. THE SECOND- ORDER cI;LEMICAL EQUI LI BRI UMALGORITHM
I n or der t hat t he second- or der l i near - l ogar i t hmi c
met hod be set i n t he f or mof a chemi cal equi l i br i umpr obl em,
t he same def i net i ons as gi ven i n Sec. 4- - i . e. , Eqs. (4. 1)
t hr ough (4. 5)- - are used her e. Si nce t he second- or der met hod
i s best used af t er t he f i r st - or der met hod has been appl i ed,
t he i ni t i al val ues of 71 f or t he second- or der met hod must
be speci f i ed. The f i r st - or der met hod gi ves a set of 71'
i
i
whi ch ar e r el at ed t o a by Eq. (4.6). The 7. comput ed by
i 1
means of (4. 6) ar e appr opr i at e i ni t i al val ues f or t he second-
or der met hod. Usi ng t hese i ni t i al val ues f or 71 t he second-
or der chemi cal equi l i br i umal gor i t hmi s an i t er at i ve pr ocess
i '
or whi ch each i t er at i on consi st s of t he f ol l owi ng st eps:
1)
Usi ng t he cur r ent val ues for ( 7r19n2, . . , , nM) Y
eval uat e x1, x2, . . ..,x
by means of (3.5).
n
2) Cal cul at e gl,g2,.,.,g by means of (5. 2) and set
m
3)
Comput e r i C f r om(4. 8) and sol ve (5. 5) for
"1"2'*'''MM.
4) Let
M
i =l
P = max l ahi l .
- 34-
I f P c 6, wher e 6 i s a smal l posi t i ve number such
as we ar e done; ot her wi se, l et Q = mi n ( + ) *
5) Repl ace 7~ by ri + Q Si f or 1 = 1,2,,..,M.
i
St eps 1- 5 ar e r epeat ed unt i l t he t est at 4) i s sat i sf i ed.
P shoul d decrease at ever y i t er at i on; however , when t he
val ues f or 7~ get cl ose t o t hei r opt i mal val ues, P may
not become zer o due t o r ound- of f er r or . I n order t o prevent :
i
an endl ess r epet i t i on of st eps 1- 5 due t o t he sel ect i on of
t oo smal l a 6, we can test P agai nst t he val ue of P at t he
pr evi ous i t er at i on. I f t hi s val ue has i ncr eased over t he
pr evi ous i t er at i on, i t can be assumed t hat t hi s met hod has
obt ai ned as accur at e a sol ut i on as possi bl e, and we can
t er mi nat e t he i t er at i on pr ocess. The r eason f or i nser t i ng
t he f act or Q above i s t o pr event t he T f r omvar yi ng t oo
much on one i t er at i on.
i
-35-
7. S - Y OF THE COMPUTATICON PROCEDURE
The best met hod f or st ar t i ng t he sol ut i on of t he
chemi cal equi l i br i umpr obl emdepends on whet her an est i mat e
f or t he sol ut i on vect or i s avai l abl e. The pr oj ect i on met hod
shoul d be used when t he pr obl embei ng sol ved i s a sl i ght
var i at i on f r oma pr obl empr evi ousl y sol ved, and i n t hi s
case, t he val ues used f or y i n (2. 9 - 2. 12) shoul d be t he
sol ut i on vect or t o t he pr evi ous pr obl em. Even when t he
est i mat e i s no bet t er t han an i nt ui t i ve guess, t he pr o-
j ect i on met hod may st i l l be used. The l i near pr ogr ammi ng
met hod, t hen, may be used as a back- up i f t he pr oj ect i on
met hod pr oduces a non- posi t i ve component . Of cour se, i f
no est i mat e i s avai l abl e, t he l i near pr ogr ammi ng met hod
woul d be used i mmedi at el y t o pr ovi de an est i mat e.
j
The r ecommended pr ocedur e I s, t hen, t o use t he f i r st -
or der met hod unt i l ei t her no f ur t her pr ogr ess can be made
with t hi s met hod or unt i l t he amount of change becomes
smal l from i t er at i on t o i t er at i on, and t hen t o use t he
second- or der met hod. I t has been f ound t hat , f or r eason-
abl y l ar ge pr obl ems (say m= 30, n = loo), t he poi nt at
whi ch pr ogr ess ceases i n t he f i r st - or der met hod usually
occur s when t he i ndi cat ed cor r ect i ons t o t he component s
-36-
of t he sol ut i on vect or aver age about one per cent of t he
component s; t hat i s, when (3. 5) i s accur at e t o about t wo
si gni f i cant di gi t s. A swi t ch t o t he second- or der met hod
at t hi s poi nt usual l y yi el ds qui t e accur at e r esul t s i n t wo
i t er at i ons of t he second- or der met hod, The second- or der
met hod usual l y sat i sf i es (1. 1) to an accur acy of about
f i ve si gni f i cant di gi t s on a machi ne t hat car r i es ei ght
si gni f i cant di gi t s. Thi s accur acy i s t ypi cal l y about t hr ee
or der s of magni t ude above what i s usual l y obt ai ned i n
exper i ment al dat a.
To summar i ze, t he t ypi cal pr ocedur e f or sol vi ng a
chemi cal equi l i br i umpr obl emi s t he f ol l owi ng:
1) I f an est i mat e i s avai l abl e, use t he pr oj ect i on
met hod t o obt ai n a f easi bl e est i mat e.
2)
I f st ep 1 yi el ds a stxictiy posi t i ve est i mat e, go
t o st ep 3, but i f t he pr oj ect i an met hod yi el ds non- posi t i ve
component s, or i f t her e was no i ni t i al est i mat e, t hen use
t he l i near pr ogr ammi ng met hod t o get an est i mat e.
3) Use t he f i r st - or der met hod unt i l one of t he t est s
descr i bed i n Sect i on 4 i s sat i sf i ed.
4) Use t he second- or der met hod as descr i bed i n Sect i on
6.
-37-
Appendix A
A FORTRAN- I V PROGRAM FOR SOLVI NG THE
CHEMI CAL EQUI LI BRI UMPROBLEM
>
GENERAL DESCRI PTI ON
The pr ogr amdescr i bed her e i s a set of FORTRAN- I V
subr out i nes f or sol vi ng chemi cal equi l i br i umproblems,
The cal l i ng sequence used i s mer el y t he st at ement :
CAZL SOLVE
Communi cat i on of dat a i nt o and out of t he subr out i nes
i s accompl i shed by a bl ock common st at ement :
The dat a t hat must be i nput bef or e CALL SOLVE i s
execut ed consi st of t he f ol l owi ng:
-38-
COMMON Locat i on Quant i t y
I W ) Pr i nt f l ag: -1 = mi ni mal amount of
messages; 0 = one message per i t er a-
t i on st ep; +l = all messages.
Maxi mumnumber of i t er at i ons t o be
allowed.
bi , i = 1,2 , . . . , m.
yj, j=1,2,...,mY wher e y i s t he
j
i ni t i al est i mat e of t he sol ut i on.
I f no est i mat e i s avai l abl e, set
X(J) = 0.
c j=l,Z,.. . , n.
a i=1,2, . . . , m; j=1,2,...,n.
j y
C(j1
W, j ) i j '
I n addi t i on, all component s i n one compar t ment must
J
have consecut i ve subscr i pt s, That i s, component s 1, 2, 3, . , , kl
must be i n Compar t ment 1; component s kl+l, k1+2, . . . , k2
must be i n compar t ment 2; . . . ; and component s k +1,
kp- l +2, . . . , k
communi cat ed t o t he subr out i nes by set t i ng
P-1
must be i n compar t ment p. These k's ar e
P
KL(2) = kl+l
KL(3) = k2+1
I n other wor ds, KL(k) i s the number of the f i r st component
i n compar t ment k, and KL(p+l) i s equal t o n+l.
The above ar e t he onl y number s t hat need be set i n
or der t hat CALL SOLVE wi l l sol ve t he chemi cal equi l i br i um
pr obl em. However , i n or der t hat t he pr ogr amcan wr i t e
messages, i n cases of i nf easi bi l i t y, et c. , names for t he
r ows component s, and compar t ment s may be i nput :
COMMON Locat i on Quant i t y
NR(I ,I> Y 1 7 2) Two- wor d r ow name for row I .
KN(J) One- wor d component name f or
component J .
compar t ment K.
In addi t i on, TOL(1) t hr ough TOL(5) ar e t ol er ances used
by t he pr ogr am. I f they ar e zer o when t he pr ogr ami s
ent er ed, t hey ar e set by t he subr out i nes t o nomi nal val ues.
These values may al so be set by t he user of: t he subr out i nes,
i n whi ch case t he nomi nal val ues wi l l not be set i n t he sub-
r out i nes. These t ol er ances ar e t he f ol l owi ng:
Nomi nal
Tol er ance Value Meani ng
0. 01 c in st ep 3 of t he f i r st -
or der met hod ( see Sec. 4).
J
-40-
e
%
Nomi nal 8.
To 1 er a m e Val ue Meani ng
TOL ( 2)
6 i n st ep 4 of t he second-
or der met hod ( see See. 6).
Mi ni mumval ue any x i s
3
TOL(3)
al l owed to have.
TOL( ~) lo-5 Mi ni mumst ar t i ng val ue t hat
any component wi l l have i s
TOL(5) lo-8
t he l esser of TOL(4) and
& ( see Sec. 2).
2Y,+1
Pr obl emi s assumed t o be
degener at e i f any S
becomes l ess t han TOL(5).
k
Wi t h t he above as i nput , t he st at ement CALL SOLVE wi l l
cause an at t empt t o sol ve t he chemi cal equi l i br i umpr obl em.
I f , upon compl et i on of t hi s at t empt , a sol ut i on i s obt ai ned,
t he cel l
IV(10)
wi l l cont ai n a 1 and t he f ol l owi ng dat a wi l l be i n st or age:
Dat a
x i =1, 2, . . . , n ( t he sol ut i on) .
-
COMMON Locat i on
i
X(i )
XBAR(k) Sk, k=f,2, ...,p.
71 i =1, 2, . . . , m.
PI E(i )
i =1, 2, . . . , n.
i J
1
x A =mi )
. -
'..
\J
..
-41-
I f IV(10) i s not 1, t he subr out i nes have f ai l ed t o sol ve
t he chemi cal equi l i br i umpr obl em. The r eason f or t hi s
f ai l ur e i s wr i t t en on out put uni t IV(6).
X(i) wi l l cont ai n t he l at est val ue of t hese quant i t i es.
I n such a case,
SUBROUTINES
Ther e ar e ni ne subr out i nes i n t he set used f or t he
sol ut i on of t he chemi cal equi l i br i umpr obl em.
descr i pt i on of t hese subr out i nes f ol l ows.
A br i ef
1. Subr out i ne SOLVE
SOLVE i s t he mast er subr out i ne, and i s di vi ded i nt o
f our f unct i onal segment s. Each segment cal l s ot her sub-
r out i nes whi ch do speci f i c t asks. The f our segment s
The pr oj ect i on and l i near pr ogr ammi ng r out i nes
f or obt ai ni ng t he i ni t i al sol ut i on (lines 18-42).
The f i r st - or der met hod ( l i nes 43-122).
The second- or der met hod ( l i nes 123- 163) .
Out put messages ( l i nes 164-203).
2. Subr out i ne BAtQ
BAR cal cul at es t he Sk.
-42-
3. Subroutine BERROR
BERROR calculates
N
= b - 1 aijxj .
j =1
i=1,2, . . . ,M
gi i
4. Subroutine DEL
DEL sets
J
m
w = 1 aijqi . j=l,2,. . . ,n
j
i=l
5. Subroutine RCALC
RCALC calculates the r. array (4.8).
1 .E
6. Subroutine CLOG
CLOG computes
A
Q = c + l o g x ,
j j j
j=1,2,. . . ,n
7. Subroutine LP
LP sets up the linear programming problems.
8. Subroutine SIMPLE
SIMPLE solves the linear programming problems.
Information is communicated to this routine via a
4
-43-
cal l i ng sequence r at her t han by COMMON as i n sub-
r out i nes 1- 7. The di mensi on of A i n SI MPLE shoul d
agr ee wi t h t he di mensi on of A i n t he f i r st seven
subr out i nes, but all ot her di mensi ons ar e dummy
st at ement s.
9, Subr out i ne mTINV
MATINV sol ves si mul t aneous equat i ons. As i n
SIMPLE, no COMMON i s used. The di mensi on of A i n
NATINV shoul d agr ee wi t h t hat of R ( not A) i n SOLVE.
All ot her di mensi ons are si ngl y subscr i pt ed and ar e
i r r el evant as to magni t ude.
* * 3;
Each of t he f i r st seven subr out i nes has a COMMON
st at ement whi ch shoul d be t he same i n al l seven. The
di mensi ons of t he var i abl es i n t hi s COMMON st at ement may
be set t o t he val ues f or t he l ar gest pr obl emt o be sol ved.
Wi t h m, M, p, and n as pr evi ousl y def i ned, t hese di men-
si ons must be at l east :
,
IV
TOL
MR
B
KN
X
C
KL
NAM
A
PIE
XMJ?
XBAR
R
v1,v2,v3,v4
x1, x2, x3
Mi ni mumDi mensi on
A l i st i ng of t hese subr out i nes follows.
not necessar i l y r epr esent an act ual pr ogr am.
used was t hat ver si on of FORTRAN descr i bed i n [63. The
machi ne used f or t he sol ut i on of chemi cal equi l i br i um
pr obl ems was t he I BM- 7044, whi ch uses a f l oat i ng- poi nt
number wi t h ei ght bi t s f or t he exponent and 28 bi t s f or
t he si gn and mant i ssa.
Thi s l i st i ng does
The language
-45-
.
LISTIKC
. .
.
5060 1
5cc02
50003
50004
5c005
50006
5ac37
50006
50039
50010
50011
50314
500 15
50015
SO0 17
50018
53019
50c20
53021 ,&
52022
53023
50024
5C025
5G026
50027
50023
50029
59030
5C031
50032
$0033
53034
5 3 6 3 5
50036
50037
50038
50039
50040
a0G41
50042
30043
50044
50045
5u046
55047
50046
SbL'49
5G250
huc 5 1'
5uu52
ag053
b C 0 5 4
5u055
53056
50057
50058
50c59
50960
.
7114 CONTI NUE
CALL RCALC
CALL M A T I ~ V ( R , K E N ~ * P I E I - I * ~ ~ * V ~ ~ ~ ~ * ~ E )
iF(KE.NE.0) GO f0 IC003
DMAX i a c + 2 C
CALL DEL( TH* PI E)
7105 GNORMzG;.
TDA 3.
F E = 0.
DO 71L4 K=l r NCOMP
MK = M + K
KTA = KL( KI
KTb = KLI K+l ) - 1
DO 7103 J = KTA, K T E
TH( J ) * TH( J ) +PI E(I . ' k)- ALPHA( J 1
GFr3RM = GhOR,'I + TH( J ) **2
TH(J1 = TH( J ) * X( J )
TDA = TDA + TH( J ) * ALPki A( J )
F E F E + X ( J ) * ALPHA( J )
IF ( X( J ) . LT. - 3~AX*Tt i ( J ) ) DMAX = - XI J ) / l H( J I
7103 CONT I NUE
7104 CONTI NUE
EPS- SQRT 4 GN3RY/ FLGAT ( NTUT) )
DFE = F E - FE2
F E 2 = F E
I TR = I TER - 1
1FtPF.SE-u) wRI TE( NOT9799) I TR* DF EI OP T L I EP ~
IF(PF.GTaO)hRITE(NOT*8241) DYAX, OPTL* TDA* ERR
I F ( I TER. EQ. 1) GO TO 712d
712d OPTL = A M I F < l ( 1.9 . 59*OMAX 1
I F LEPS. LE. TOL( 1) I GO TO 8269
826 I F ( TDA. GE. Oa) GO TO 8267
8263 DO 8265 I 1 1 1 9 5 4
00 6331 J = 1 9 N
DX( J ) = AMAXL( X( J ) + @PTL* TH( J ) t XYI N)
8301 CONTI NUE
CALL UAH( DX9XaAR)
CALL CL OG( DX* XdAH)
T 3 A = S.
DO 8266 J = l * NTOT
TDA = TDA + THt J ) * ALPkA( J )
8266 CCj hT I hUE 4-
I F( PF. GTOY) WRI TE( NOT, 8262)II*OPTL* TDA
I F ( TDAaLT. 0. ) GO TO 828
8264 OPTL = OPTL /le4142
8265 CONTI NUE
CALL BAR( X* XbARI
GO TO 8271
826 DO 8281 J Zl r NTOT
X( J I DXl J l
8281 CONTI NUE
F E =
00 8231 J S l r N
F E = FE + ALPt i At J ) *X( J I
8231 CGNTI NUE
8288 CALL SS%TCH( 5r LASELI
If ILAklEL*Nt.Z) 60 TO 10064
899 CONTINUE
SOC61
1ug62
50063
53564
50065
50066
ab867
5c06a
5C069
50070
53C71
5CG72
5cc73
5ac74
5uO 7 5
50076
50077
50078
53279
5z cu1
5j 5b2
50083
ScIG84
20085
5uC96
s v v e 7
50088
3 2 C d 9
SO1?90
5cb91
23092
50093
~1g94
t 3G95
- C G 9 6 ,
>g097
50c98
1a399
5010c
50101
33132
5G103
53104
50105
50136
b0137
so 109
23110
5,0111
so1 12
50113
SO1 14
50115
50116
50117
501 18
53119
50120
Lccaa
wi o a
I F ( LAi 3EL. NE. Z) GO TO 1UOCt4
63u2 CONTI NUE
00dN
50121
SO1 22
50123
50124
50125
501 24
50127
50128
50129
501 30
50131
5, 0133
5c134
50135
50136
50137
53138
5,0139
56140
50141
SO1 42
5a144
53145
501 46
50147
50148
b0i 44,
501 50
50151
501 52
SO1 5 3
50154
SO1 5 5
SO1 56
SO1 57
53159
56160
5q161
50162
53163
SO 154
50165
5g166
50167
50168
52169
501 70
a3171
531 72
>2173
50174
53175
501 76
5c177
5lr178
SO1 79
501 80
$0132
sol 43
501 58
-48
. 0262 FQRYAT(1dXr 4HSTEP912r 9H LA%3CA=1PE10.3t6Hr TDA=E15.61
799 FORMAT(1bM I T E R A T I O N I I ~ I ~ ~ H CHANGE IN FREE ENERGY=lPE15*Brl2H
lSTEP SIZE=E15.8ilGH A V THETArEl2.5)
AERROR*El5.8
6039 FCRMAT(13H ITERATI3NrI4rlYH M A X CHANGE IN PKE=lPE15mBrlSH*MAX ROW
END
P
501b1
50i a2
b01a3
5.31 84
531 d 5
531 b6
5c187
50188
sGlt19
50190
53191
50192
10193
50194
5g195
50196
50197
50199
502 30
50202
50203
50204
soi sra
so201 ~
, .
-49- 1
P
. . . . . . .- -. . . .. . - .. .. __
60031
i>UC)22
b0c03
b0004
01c35
bUC06
bU0Cl7
YCJCOB
b0039
bu010
BCC 1 1
b O C 12
eg013
3GC 14
E30 15
EGG16
83317
ti3019
b002g
d0021 4
d0322
50024
80025
UG026
60027
E0620
b0029
b0c30
80031
800 32
iiscia
auo23 ,
. . . ~. . . . ~ .. . . - . . _. . _
. ? . .
I , :
WI J 1 =- , W k
ZG CONTINUE
RETURN
END
.
G 3 0 O S
DrJr06
DO207
DOCS8
DGCC9
3CGlC
0i;Gll
oc012
DOC 13
000 14
DO0 14
00016
DOC17
r
-52-
ii2SOl
Rti 0' 32
h3023
kcg04
RC235
h5036
RUCG7
r 0c38
R2009
r 0010
R C O l l
r 0012
R G C 1 3
ROO 14
r 0015
r0016
iiOGl7
R G O l d
R0319
r 0020
ROO2 1
ROC22 @
r 0023
r 0024
r0025
r0026
R0327
RUG26
r0c29
RC.230
p5031
r0c32
r 0033
ROO 34
r 0035
r0036
r 0037
R003d
r 0039
r 0040
.
0
coco 1
c3002
c0003
c0004
c0c05
c0036
c0007
c0005
C C C 0 9
cc010
COCll
c0012
c0013
c0014
COQ 15
cc016
coo1 7
CC016
C3G19
c0020
I
.e
1 12H1 CONDI Ti ON , 131
ZZT =AMI Nl ( ZT/ Z. O~ XSTART)
DO 104 I =
P ( 1 ) = P ( I ) - ZZT* A( I , N+l )
194 CONTI NUE
Z Q O DO 2C1 J z I r NTOT
X( J ) = XX1J )
XMF( J ) I l e u
LUVU I
1cc22
10g03
13974
LOO83 3
10006
1gc07
LCCOE
10g59
LOG 10
LO91 1
10312
LO013 ,
LO: 14
10215
LGC 16
10g17
LCCl S
1c019
LOZ220 d
13cz1
10022
13c23
10324
10025
10n26
LO02 7
10028
10029
10330
19532
L00 32
10033
L3C 34
10g35
1c336
1a037
1e838
LC1039
13040
15c41
1a042
1cc43
1ac44
10g45
LLi046
1c047
10040
10049
10050
10051
LSCSL
10c53
1cc54
10055
LO3 5 b
10057
10058
10059
1a060
X M F ( J ) = d o
IF f XBARIK).NE.O.) XMF(J) = XtJ) / XBARtK)
310 CONTINUE
3U5 FOR:.\AT(BH S I M P L E X ~ I ~ . ~ H * I I ~ ~ Z Z H ITERATIONS r6H FR ENGxlPE15.8)
FRZ=FR
301 CONTINUE
399 DO 436 J 1rN
I F (PFmGE.0) WRITE(NOT*305) N P ~ I < O U T ( ~ ) ~ F R
IF [fRoGE*FRZ) GO TO'399
X(J) = XIJ) + ZLT
4 U U CONT I NiJE
RETURN
WRITE INOTr41)
4ci IF tKOUT(l)*bT.l) GO TO 50
41 FORMAT(72HOTHIS PROBLEM IS INFEASIdLE. THE FOLLOWING LINEAR COMB1
1NATION OF ROa.59 / 1 X J
DO 14; I = l t M
I F (PI Et I 1 *NE a 0 1 W R I TE ( NOT * 14 1 1 P 3 E ( I I r NR ( I s 1 1 r NR ( I 9 2
141 FOHMAT(lOXs3H+ (rF15a6rSH ) * s2A6J
140 CONTINUE
142 FORhAT(4dHO LEADS TO THE FOLLOKING INFEASILJLE EQUATIONr /1X)
WRITE (NOT91421
DO 1 5 ~ K =l*kCOIW
MTA = KL(L)
MTB = KL(K+l) - 1
DO 151 J X MTAs MTB
0 = 0.
DO 152 I = l r M
D = PIE(II* AtIrJ) + D
152 CONT I NUE
15i) CONTIhUE
D 00
DO 160 I ~ 1 v M
D = PIE(Il*d(Il + D
160 CONTINUE
144 FORMATIlHOtlTXI 7H+ 0.0 = 1 F 1 5 ~ 8 )
WHITE (NOTs1441 D
70 MON = 1
RETURN
JT = KOUT(71
DO 51 K = 1,NCQMP
5C: IF ( K O U T I ~ ~ O N E D ~ I GO TO 60
8-
IF ( JT.GE*KL(#)l GO TO 52
51 CONTIFU'JE
52 &RITE (NOTs9521 K N ( J T ) t N A ~ ( K r l I , N A t ~ ( K I Z )
952 FORMAT(l4H THE VARfAbLE sA6r4H IN r2A6r33H IS UNBOUNDED A
1 E REMOVED)
GO .TO 73
50 WRITE I N 0 T ~ 9 6 0 )
D MUST
960 FORMATf60H SIMPLEX ROUTINE HAS FAILED DUE TO EXCESSIVE ROUND-OFF E
1 R R O R )
GO TO 73
END
1cg61
10042
10g43
10064
10065
10066
10067
10068
10069
10370
10071
10072
10073
10074
10075
10076
10077
10078
10079
10080
LO082
1c083
10084
10085
10086
10g87
10088
10089
10090
10g91
10092
10093
19094
1cc95
10g96
10097
10099
10103
10101
10102
10103
10104
10105
10106
10107
10108
LO 109
10110
LOlll
LO1 12
10113
LO1 14
10115
LO1 16
L a o a i
~ o o 9 a
. i J
Cal l i ng Sequence f or Si mpl ex Subr out i ne
The si mpl ex subr out i ne, SI MPLE, may be used t o sol ve
a gener al l i near pr ogr ammi ng pr obl emof t he form:
n
1 c.x
J j
j -1
subj ect t o
Mi ni mi ze
(1)
n
1 ai j Xj = bi .
j=l
(2) i =122, 3, . . . ,m
The ai j i s st or ed i n a t wo- di mensi onal ar r ay, A, wi t h
i n cel l A(i ,j ); C. i s st or ed i n a one- di mensi onal ar r ay, a
C, wi t h C. i n cell C(j); and b. i s st or ed i n a one-
i j J
J 1
di mensi onal ar r ay, B, wi t h bi i n cell B(i).
The cal l i ng sequence i s
CALL SIMPLE~I~,M,N,A,B,C,KO,X~P,~H,XX,Y,PE,E)
wher e
II = 0;
M = No. of r ows, rn;
N = No. of var i abl es, n;
-57-
A, B y C Are as above;
KO = A subscr i pt ed var i abl e of
di mensi on 7;
X = A subscr i pt ed var i abl e of di men-
si on n or mor e;
P, J H, XX, Y, and PE = Subscr i pt ed var i abl es of
di mensi on mor mor e; and
E -- A subscr i pt ed var i abl e of
di mensi on m or mor e.
2
Upon exi t i ng from t he subr out i ne,
x(1), X(2)y. . . , X(n) Cont ai ns xI , x2, . . ~, x ( t he sol ut i on) ;
n
P(l),P(Z),...,P(m) Cont ai ns t he shadowpr i ces;
KO(1)
Cont ai ns an 0 i f t he pr obl emwas
f easi bl e, 1 i f t he pr obl emwas
i nf easi bl e, 2 i f t he pr obl emhad
an i nf i ni t e sol ut i on, and 3, 4, or
5 i f t he al gor i t hmdi d not t er mi nat e;
The number of i t er at i ons t aken;
The number of pi vot s per f or med si nce
t he l ast i nver si on;
KO(2)
KO(3)
KO(4)
KO(5)
The number of i nver si ons per f or med;
The number of pi vot st ep? per f or med;
-58-
KO(6)
A l ogi cal var i abl e t hat i s "t rue"
i f and onl y i f t he pr obl emwas
f easi bl e; and
KO(7) Cont ai ns, i f t he pr obl emhad an
i nf i ni t e sol ut i on, t he number of
t he var i abl e t hat was i nf i ni t e.
The di mensi on of A ( l i ne XOOO9) must agr ee (at least
i n t he f i r st subscr i pt ) wi t h t he di mensi on of A i n t he
cal l i ng pr ogr am. The ot her di mensi ons need not agr ee wi t h
t hose of t he cal l i ng pr ogr am.
I an i ni t i al basi s i s avai l abl e, t hi s basi s may be
communi cat ed t o t he subr out i ne by l et t i ng
I1 = 1 ,
(0.0 i f var i abl e i i s not i n basi s,
( ( non- zer o) i f var i abl e i i s i n basi s,
X(i > =
and t he ot her quant i t i es r emai n as above.
Thi s subr out i ne di f f er s f r omot her l i near pr ogr ammi ng
r out i nes i n sever al r espect s. I f t he r est r ai nt s (2) are
l i near l y dependent , t he pr obl emi s consi der ed t o be i n-
f easi bl e. Thi s i s t he case because t he chemi cal equi l i br i um
pr obl emcannot be sol ved i f t he r est r ai nt s ar e dependent .
I n addi t i on, t hi s subr out i ne was wr i t t en t o be as scal e- f r ee
-59-
-
as possible; this was accomplished by computing tolerances
internally in the subroutine.
xoco 1
x0302
x0003
X0004
X3C05
X0006
X0007
x0008
x0009
XOOlO
X O O l l
x0012
X0013
X0014
X0015
XOOlb
x0017
X O O 18
XOO 19
x0021
X0023
X0024
x3020+9,
x0322 ,
L *
X0025 ,"
X0026
X0027 . I . '
I .
X0020
X0330
XOO 3 1
X0032
XU034
X0035
X0036
X0037 ,
X0038 ,
XC039
X0041
X0042
XU043
X0044
X0045 - .
X0046 '
X0047
XU048
X0049
XOOSO
X0051
x0c53
X0054 '
X0055 '
. XOO56
X0057
XOOSB -
X0059 .
XOCbO
X0029 ' I .
X0033 . ' :
X0040 *
,XOO52
<
IF (JH(I1*NEo-1) GO TO 1104
IF 1 ABSIYlll)rLE*TY) GO TO 1104
IR I
T Y = ABSIYIt))
1194 CONTINUE 1
1 KBIJTI = 0
C TEST PIVOT
C P 1 VOT
IF (TYoLE*TPlV) GO TO 1102
JHIIR) - JT
KUIJTt = I R
GO TO 900
C 9bu CALL PIV
1102 CONTlPiUE
C RESET A R f f F r c l A ~ s
i DO 1109 I 8 1 t M
f IF IJH(II*EPo-1) JHtIt 0
1109 CONTINUE
' 1203 V E R = *FALSE*
' C PERFORM ON fTERAfION
DETER:.iINE FEASIBILITY
F E A S - * T R U E *
NEG * *FALSE*
. DO 1241 I e 1,M
- IF ( X ( I I * L T * O o O ) GO TO 1250
1201 'CONTINUE
'
I *
IF fJHfI)*EQ*O) FEAS * .FALSE. ,
f
GET APPLlCAdLE P R I C E S
IF I*NOT*FEASI 'GO TO SO1
, ' PRIMAL P R S C E S I 1 1
. 1
DO 503 I IrH ,
2 . *
# . - :
I .
P(It = PEtt)
ABSC * *FALSE*
' ' 503 CONTINUE
> \, ,
d '
i
.GO TO 599
t O M P O 3 1 T E PRICES
* -
I ,
,
I '. .
0 ,
r . J
I'
. 'i '
, t
ABSC * T R U E * !
DO 505 I 1 9 M ~
MM = r I
IF ( X ( l ) r G E * O o d l GO 10~307
AbSC *FALSE*
00 508 J = 1 s M I
i * I
I '
P(JI = P1Jt + E ( M M )
M M = M M +M
t
i
, <
I .
SO6 CONTINUE I
. * <
, r l
GO TO 5c5
. *
* 407 IF (JH(I).NC*Ol GO TO SO3
* * ' < I IF (XIIIoNE*O.) AUSC I, *FALSE* *
DO 510 J 1rM
I
. L * , < 1 t
P(J) 9 P(Jt - EIMM)
s .r,l ' HM - M M + M
7 r * % * >
*1
i .
I .
510 'CONTINUE I ) I
.'MIN' FINO HIlllfWM REDUCE0 COST .
6 - 4 ~ 5 CONftNUE
A' .
' * 399JT.0 _ . , I
* .
8 %
. SI.
8
. .
X0061
X006Z
X0063
X0064
X0065
X0066
X0067
X0068
XOC69
X0070
XU071
X0072
X0073
XOG74
X0075
XOC76
XO077
X0379
X0080 , ?
X3381
X O O B Z
X0083
X0084
X0085
X0086
X0087
X0088
X0090
x309 1 . .
XG092
xoo7a
x w e 9 .
I "
X0104
X0105 ,
XOl06 I
X0107
X0109 I
XO110
X O l l l
xo11z
X0113
X0114
X U 1 1 5
X O I 16
X0117
X0118
X0119 .
XOl20
xoioa '
- - .
i
\ -62-
1- , LI
. *
88 * 0.0
DO 701 J * l r N
c SKIP COLUMNS IN BASIS
1 IF tKUfJ)*NE*OI GO TO 701
Of = ( i s 0 t
00 303 I * l v f l
IF I A I I ~ J ) * N E ~ O I O ) D T OT + PI11 0 A ~ I B J I ..
I 393 CONTINUE
IF (FEASI DT DT + CtJI
1F (ABSCI DT * - kBStDf)
88 0 DT
IF (DT*CE*OBI GO TO 701
696 CONTINUE
GO T O 605
602 LL LL + M
605 CONTINUE
COMPUTE PIVOT TOLERANCE
Y M A X 0.0
, I
, ) .
RETURN TO INVERSION ROUTfNEt .if 1NVERTlNO
IF (VERI GO TO 1114
COST TOLERANCE CONTROL t
IF (TRIG.ANO*D8.GE*-TPIV) GO TO 203
IF tBD*fE*-fPtV) TRtG *TRUE*
+ a * T R I G * *FALSE*
\ I
*
< I c AMONG EdS. WlTH X I 0 9 FINO MAXIMUM Y AMONG ARTlfICtALS, OR# IF NONE,
, C* BROW; SELECT PtVOt ROW :
z C GET M A X POSITIVE Y(1i AMONG REALSL ,
a
I / ) . \
5 .
4 , 1000 IR 0
0 1
A A m 003
KO * .FALSE*
00 lU50 f = 1 r M
#
3
1 *
I.
. 1 6
* i
- 1
L .
$ .
tF ~ X ~ f l ~ ~ E o O . O r O R ~ Y ~ f ) * L E ~ f P f V ~ , ~ GO. TO 1U30at
IF (KO) GO TO 1?)50
( .
, 1
1
I >
- , - & , IF fJHltlrEQe0) GO TO 1044
, 4
2 .
1
0
b
x0121
x0122
X0123
X O 124
x0125
X0126
XOlZ?
X0128
X0129
X0130
X0131
X0132
X0133
X0134
X0135
X0136 * I
x0137
X0138
X0139
X0140 , f
X0141
X O 142
X0143
X0144
X0145 .
X0146
X9147 - ,
X0148
XC149
X0150,
xo151 ,
xo152 .
X0153
X0154
X0155
X0156
X0157
X0158
X0159
XOlbO
X O l b l
X0162 - .
X0163
X0164
x0165
XOl66 .
XOlbf
x016b
X0169
X0170
X0171
X O 172
X0173
X0174
x0175
X0176
X0177
xoi7a I
x0179
X0180
I
' 1044 IF (KQI GO TO 1045 XO181
K Q * * T R U E * XOl02
lob7 A A Y t l ) x51 B 3
i f f = I X0104
105U CONTINUE X0185
IF IIR.NE.6) GO TO 1Odb X0186
1001 A A * 1.OE+2u X O 187
C F I N O MIN. PIVOT AMONG POSITIVE EQUATIONS X0188
00 1010 I 1tM X0189
IF ~ Y ~ I ~ o L E ~ T P I V ~ O R ~ X t f ~ . L E . O . O . O R . Y o + A A ~ ~ E ~ X ~ I l 1 GO TO 1010 X0190
A A = X ( f I / Y I l t X0191
IR a I X O 192
1010 CONTINUE X0193
I F (eNOTaNEG) GO T O 1099 X0194
. C F I N D PIVOT AMONG NEGATIVE EQUATIONS, fN WHICH X/Y IS LESS THAN THE X0195
X0196 +" C MINIMUM X/Y IN THE POSlTlVE E O U A T I O N S I THAT HAS THE LARGEST ABSFlY)
'! 1016 BE3 * - TPIV X0197
DO 1030 I 8 1,M X0198
' .
IF ~ X ~ I ) ~ G E ~ O ~ ~ O R O Y ( ~ ~ ~ C E I B B . O R , V ( ~ ~ . A A . G ~ ~ X ~ ~ ) t GO TO 1030 X0199.
x0200 I .
x0202 '
X0204 '
X0205.
* X0206
X0207
X0209 . ,
XO20l ,"
BB = Y(Il
IR = I
I 1030 CONTINUE
, . XO203
TRANSFORMED COLUMN IN Y(1)
Yf -Y(IRI
YIIR) * -1.0 z .
TRANSFORM f)IVERSE , -
*
;DO 9 ~ 4 J 1 r M '
r01Ol GO TO 909 ,*
LC * LL + M '
PEIJ) = PE(J) +COST XY ' 5 2 X02lB '
j xo220
E(L1 0.0 4- 1 ,
CL - L L + 1 < I , I * . , x0221
x0222.
t a 1, ' xo217 ' ',
,.*.I.
' x0219
t , ' *
DO 906 I I t M
I,. . , ' ?'
l i -
X0223
E(Ll.1 9 E(LLJ * + XY Y(1)
906 CONTINUE
904 CONTINUE
* X0224
X0226
XY X 1 I R ) / Yf
00 9C6 I 1; 1 1 M ' X0227
C TRANSFORM' X 8 , ' XOZ25 .
X N E M = Xlfl 4 XY * Yf!) , XOZZB
iF ~ V E R . O R ~ X N E W ~ C E O O ~ ~ O R , Y ~ ~ G T . ~ P ~ V . ~ R . X ~ ~ J O ~ T O O ~ x0229
X I I ) 0.0 X0230 , ~
GO TO 908
* ' . X0231
X02 32
- D i * X U 2 33
" XO234
1 I, , X0235
X0236
, ' X0237
' 1 X Q 2 3 8
X0239
, X0240
9u7 X ( I ) 8 XNEW :
'k I
3 ,908 CONTINUE
, *
'j * ' ; c RESTORE Y f f I ? J
I . YtIRI -YI
XIlRl -XY
IF IVERl GO Tb 1102 I
tF f1AoCT.O) '&SI1
i
. I
T .
& , * > 3 .
, 221 IA 8 JHlLR)
d
213 KBIJfl , ,a fR ,
I
, .I
. .
' *. * > C .
r i
t
I ,
6
-I-4& i _ _ - - - - - -
- _.
J
I
j
-67-
Appendi x B
MATRI X NOTATI ON AND FURTHER PROOFS
,'
The der i vat i ons i n t he pr ecedi ng sect i ons woul d be
J
f aci l i t at ed by t he use of mat r i x not at i on r at her t han sub-
i scr i pt ed var i abl es. We i nt r oduce t he f ol l owi ng symbol s t o
/ /
1 r -
)
cor r espond t o t he subscr i pt ed var i abl es used i n Sec. 3.
Subscr i pt ed Var i abl e
a
i j
i
b
d
j
C
j
7T
i
r
i m,
X
j
The si ngl e- col umn mat r i ces
We use here t he convent i on
Mat r i x
A
B
Y
D
57
R
X
may al so be
Si ze of Mat r Px
-
MxN
Mxl
Nxl
Nxl
N xl
Mxl
MxM
Nxl
t hought of as vect or s.
t hat an oper at or appl i ed t o a
mat r i x means t hat t he oper at or oper at es on each el ement of
t he mat r i x. For exampl e, log Y i s t he Nxl mat r i x consi st -
i ng of
,.,-
I
The super scr i pt i ndi cat es t he t r ansposi t i on of a mat r i x.
We assume t hat t he el ement ar y r esul t s of mat r i x t heor y ar e
known. For exampl e, i t i s known t hat t he i nver se of an
i nver t abl e symmet r i c mat r i x i s symmet r i c. The squar e
di agonal mat r i x whose di agonal i s one of t he vect or s pr e-
vi ousl y def i ned wi l l be denot ed by t he pr evi ousl y def i ned
vect or i n el ongat ed t ype; t hat i s,
D = di ag (D) .
and
y = di ag (Y) .
Equat Lons (3.2) and (3. 7) i n mat r i x not at i on ar e
y = B
X = Y ( D- 1 7 Ad" -D-'C - l og Y) .
-69-
To see the ease of matrix notation, we may substitute (B.2)
into (B.l) to get
By letting
1 7
R = AYD' A
and
we see that
Rn = S
corresponds to (3, LO).
In Sec. 4, we evaluated
j =1
r
. ~ . - - - -
03- 71
- -
.
-70-
but we did not give the details of the computation.
algebra of thts evaluation is very difficult unless matrix
algebra is used.
where 0 = x- Y. From (B.2) we have
The
In mat r i x notation, (8. 7) is Q'DY-lg,
Hence,
Since
equ il ibr ium Eormu la t i on,
= B, $Q = y-$Y = B-kjY.
Also, in the chemical
n N
DTQ = 1 ej -
1 ej -
j =I j =n+l
and
-71-
Hence,
n N
j=1 j =n+l
n
Q.(c. + log y.) A .
=C . J j =1 J J
i=l \ j =I
J
in the context of the chemical equilibrium problem used in
Sec. 4.
Next we wish to show that
as stated in (4.14). First, we prove
L e m a 1: Let yl>yz,..,yy be positive numbers and let
r
QL,Q2 , . . . , 8 be any real numbers. Let
r
fJ Yj
r
j =1
Y yj
j=1
Then
i) G 2 0
if> G = 0 if and only if
Proof: Let CY = Q./y j=1,2,. . . ,r. Then,
J 3' j
-
j =1 Yj
j =1
-73-
which is result i).
G = 0 if and only if oi = Q for all i and j; this proves
ii) .
The proof is completed by noting that
j
Now we can prove
Theorem 1: In the chemical equilibrium problem
" Q'?d
ii> 11- i = 0 if and only if there exist
j =I yj
numbers Q! l,~2,...,a such that
P
S
j-n j-n '
b) 0j = LY
j>n
Proof: The proof follows by noting that for i n
j E (i-n }
Then,
by lemma 2.
then for each k there is a number ok such t hat 0 = akyj if
j E k.
Furthermore, by lemma 1, if the equality hol ds,
j
This, noting that b) follows from the fact that
-75-
compl et es t he pr oof of t he t heor em.
Our f i nal r esul t i s
Theor em2: I n t he chemi cal equi l i br i umpr obl em, wi t h
( y1, y2 , . . . , yn) f easi bl e and 01,02,, .30, cal cul at ed as i n
j =l
n
ti )
1 ej (cj + log $,) = 0 i f and onl y i f
j=l
(y,,y,, . . . , y n ) i s opt i mal .
c_c Pr oof :
t hat {yl , y2, . . . ,y n ) i s f easi bl e.
i ) f ol l ows from Theor em1, (B.lO), and t he f act
To pr ove i i ), we assume t hat
n
j =l
Then,
and 8 is as in ii} of Theorem 1. Combining b) of Theorem
j
1 and (4.12) we have
i
= s 7r' = QkSk
'k+n k m+k
CYk = 71'
m+k
Next, we combine a) of Theorem 1 with (4.7)
to get
c
m
,
This last result is the optiunallty condition for
(yI9y2 ...,y ) as given by (1.4), and this demonstrates
the forward implication of ii). The converse follows from
n
the fact that optimality implies that the objective function
cannot be decreased.
REFERENCES
1. Shapi r o, N. Z. , and L. S. Shapl ey, Mass Act i on Laws
and t he Gi bbs Fr ee Ener gy Funct i on, The RAND Cor por a-
t i on, RM- 3935- 1- PR, Sept ember 1964.
2. Dantzig, C. B., Li near Pr ogr mi np and Ext ensi ons, The
RAND Cor por at i on, R- 366- PR, August 1963. ' Al so pub-
l i shed by Pr i ncet on Uni ver si t y Pr ess , Pr i ncet on,
New J er sey, 1963.
3. Kapl an, Wi l f r ed, Advanced Cal cul us, Addi son- Wesl ey
Pr ess, Inc., Cambr i dge, Massachuset t s, 1952.
4. Cl asen, R. J . , The Li near - Logar i t hmi c Pr ogr ammi ng
. Pr obl em, The RAND Cor por at i on, W- 3707- PR, J une
1963
Chemi cal Equi l i br i umi n Compl ex Mi xt ur es, The RAND
Cor por at i on, P- 1059, Oct ober 8, 1957. Al so pub-
l i shed i n J. Chem. Phys. , (1958) 751- 755.
7040/ 7044 Oper at i ng Syst em, FORTRAN I V Language, "
IBM Syst ems Ref er ence Li br ar y, For mC28- 6329,
Poughkeepsi e, New York, 1963.
7. Dant zi g, G. B. , and J . C. DeHaven, "On t he Reduct i on
of Cer t ai n Mul t i pl i cat i ve Chemi cal Equi l i br i umSyst ems
to Mat hemat i cal l y Equi val ent Addi t i ve Syst ems
3. Chem. Phys. , _36 (1962) 2620- 2627.
Shapi r o, N. Z. , A Gener al i zed Techni que f or El i mi nat i ng
Speci es i n Compl ex Chemi cal Equi l i br i umCal cul at i ons,
The RAND Cor por at Lon, RM- 4205- PR, August 1964.
9. Dant zFg, G. B, , J. C. DeHaven, I . Cooper , S. M. J ohnson,
E. C. DeLand, H. E. Kant er , and 6. F. Sams, "A Mat he-
mat i cal Model of t he Human Ext er nal Respi r at or y
Syst em, " Per spect i ves i n Bi ol . di Med. , 3 (2961)
5. Whi t e, W. B. , S. M. J ohnson, and G. B. Dant zi g,
6. I nt er nat i onal Busi ness Machi nes Cor por at i on, "IBM
8.
324- 376.
10. Mal oney, J . V., J r. , M.D., J. C. DeHaven, E. C. DeLand,
9
and G. B. Br adham, M.D,, Anal ysi s of Chemi cal C Q ~ -
st i t uent s of Bl ood by Di gi t al Comput er , The RAND
Cor por at i on, RM- 354f - PR, Apr i l 1963.
12. BcNaven, J. C,, E, C, DeLaad, F9. S. Assali, and W. Manson,
Physfochmical Characteristics of Placental Transfer,
The MWD &+oration, P-256.5, March- 1962.
Thermo-Chemical Equilibrium Problem," J. SOC. Indust.
Appl. Math., 2 (1963) 594-606.
/
//
1
' 13. Warga, J., "A Convergent Procedure or Sol vi ng the
i .
I