UBC Theses and Dissertations

UBC Theses Logo

UBC Theses and Dissertations

The theoretical basis for the modelling of chemical reactions in rock-water systems with specific reference… Perkins, Ernest Henry 1986

Your browser doesn't seem to have a PDF viewer, please download the PDF to view this item.

Item Metadata

Download

Media
831-UBC_1986_A1 P47.pdf [ 14.14MB ]
Metadata
JSON: 831-1.0052535.json
JSON-LD: 831-1.0052535-ld.json
RDF/XML (Pretty): 831-1.0052535-rdf.xml
RDF/JSON: 831-1.0052535-rdf.json
Turtle: 831-1.0052535-turtle.txt
N-Triples: 831-1.0052535-rdf-ntriples.txt
Original Record: 831-1.0052535-source.json
Full Text
831-1.0052535-fulltext.txt
Citation
831-1.0052535.ris

Full Text

T H E THEORETICAL BASIS FOR T H E MODELLING OF CHEMICAL REACTIONS IN ROCK—WATER SYSTEMS WITH SPECIFIC R E F E R E N C E TO T H E HEAT FLOW, FLUID FLOW AND SOLUTE TRANSPORT LAWS by ERNEST HENRY PERKINS M.Sc, University of British Columbia, 1980 B.Sc, University of British Columbia, 1975  A THESIS SUBMITTED IN PARTIAL FULFILLMENT OF T H E REQUIREMENTS  FOR T H E DEGREE OF  DOCTOR OF PHILOSOPHY in THE FACULTY OF GRADUATE STUDIES Department of Geological Sciences  We accept this thesis as conforming to the required standard  THE UNIVERSITY OF BRITISH COLUMBIA September 1986 ©Ernest Henry Perkins, 1986  In p r e s e n t i n g  t h i s t h e s i s i n p a r t i a l f u l f i l m e n t of  requirements f o r an advanced degree a t the  the  University  o f B r i t i s h Columbia, I agree t h a t the L i b r a r y s h a l l make it  f r e e l y a v a i l a b l e f o r reference  and  study.  I further  agree t h a t p e r m i s s i o n f o r e x t e n s i v e copying of t h i s t h e s i s f o r s c h o l a r l y purposes may department o r by h i s or her  be granted by the head o f representatives.  my  It i s  understood t h a t copying or p u b l i c a t i o n o f t h i s t h e s i s f o r f i n a n c i a l gain  s h a l l not be  allowed without my  permission.  Department o f  Geological  Sciences  The U n i v e r s i t y of B r i t i s h Columbia 1956 Main Mall Vancouver, Canada V6T 1Y3 " Date Sept > 26  DE-6  (3/81)  !986  written  ABSTRACT In o r d e r t o understand t h e p r o c e s s e s i n v o l v e d i n water and steam f l o o d s d u r i n g secondary and enhanced o i l r e c o v e r , waste d i s p o s a l , i n - s i t u mining and l e a c h i n g , o r many d i f f e r e n t types o f g e o l o g i c a l phenomenona, the chemical i n t e r a c t i o n s between the f l u i d and the s u r r o u n d i n g m i n e r a l s must be known as a f u n c t i o n o f p r e s s u r e , temperature and c o m p o s i t i o n . These systems a r e g e n e r a l l y open systems, thus the changes i n p r e s s u r e , temperature and b u l k c o m p o s i t i o n a r e coupled t o the chemical r e a c t i o n s o c c u r r i n g throughout the e n t i r e system and cannot be i n d e p e n d e n t l y specified. Based on the equations o f mass a c t i o n and mass b a l a n c e , f u r t h e r e q u a t i o n s have been d e r i v e d which a l l o w chemical r e a c t i o n s between a f l u i d and s o l i d phases to be e v a l u a t e d . The equations are based on the d e r i v a t i v e s o f the mass a c t i o n and mass b a l a n c e equations with r e s p e c t t o time, and a r e used i n a s e r i e s expansion to p r e d i c t the composition o f the f l u i d and the s o l i d phases a t f u t u r e times. The equations a r e * c o u p l e d t o those c o n s t r a i n i n g p r e s s u r e , temperature and mass f l u x which have been m o d i f i e d t o a l l o w t h i s c o u p l i n g . Because o f v a r i o u s l i m i t a t i o n s on many o f t h e equations used, o n l y a s i n g l e f l u i d i n porous media can be modelled. A computer program has been w r i t t e n to t e s t the equations and concepts developed i n t h i s t h e s i s . The r e s u l t s a l l o w t h e f o l l o w i n g g e n e r a l i z a t i o n f o r n a t u r a l f l o w systems w i t h d e c r e a s i n g p r e s s u r e and temperature along the f l o w path t o be made. E x c l u d i n g systems w i t h s u f f i c i e n t mechanical energy t o c r e a t e new f l o w paths and e x c l u d i n g a l l phases which e x h i b i t d e c r e a s i n g s o l u b i l i t y w i t h i n c r e a s i n g temperature o r w i t h d e c r e a s i n g p r e s s u r e , every n a t u r a l f l o w system which attempts t o m a i n t a i n e q u i l i b r i u m between t h e f l u i d and s o l i d phases i n c o n t a c t w i t h the f l u i d w i l l ; . i ultimately seal i t s e l f .  Table o f Contents  Abstract Table of Contents List of Tables List of Figures List of Symbols Acknowledgements 1. Introduction 2. Description of the Problem 3. Components 4. Thermodynamic Basis of the Constraining Equations The Mass Balance Equation The Mass Action Equation Summary 5. Model-Dependent Equations Activity Coefficients of Solid Solution Species The Activity Coefficient of Aqueous Species The Ionic Strength equation The Derivative of the Activity of Water Derivative of the Number of Moles of the Reactant Minerals Summary 6. Solution of the Mass, Ionic Strength and Activity Derivatives 7. The Flow equation The Temporal Terms The Spatial Terms Conclusions 8. The Solute Transport Equation 9. The Heat Equation 10. Notes on the Solution of the Equations 11. Model Verification 12. Examples of Model Application Overview of the Graphical Technique Model One: Iso-thermal with no Chemical Reactions, Inert Transport Model Two: Thermal Effects, Fixed Pressure Gradient, Inert Transport Model Three: No Chemical Reaction, Inert Transport Model Four: Iso-thermal with no Transport Model Five: Thermal Effects, Fixed Pressure Gradient, No Transport Model Six: No Transport - Pressure and Temperature Gradient Model Seven: Iso-thermal system with flow and mass transport Model Eight: Thermal Effects, Fixed Pressure Gradient Model Nine: No Pressure, Temperature or Mass Flux Constraints Overview of the Modelling 13. Future Work 14. Summary References Appendix One: Summary of the Thermodynamic Relationships iii  ii iii v vi viii ix 1 5 8 10 10 14 17 18 18 20 24 25 26 27 29 36 36 39 41 43 49 52 57 60 61 62 69 73 79 84 88 99 104 108 114 115 117 120 128  Solid Phases Aqueous Species Water Appendix Two: Program Description Input For Fortran Unit 1—The Physical Constraints Input for Fortran Unit 2—The Thermodynamic Data Input For Fortran Unit 3—The Chemical Constraints Fortran Unit 7 Output—Plotting Pressures and Fluid Velocities Fortran Unit 8 Output—Plotting the Temperatures Fortran Unit 9 Output—-Plotting Porosity and Permeability Fortran Unit 10 Output—Plotting Fluid Compositions Fortran Unit 11 Output—Plotting the Number of Moles of Solid Phases Appendix Three: Sample Unit 1 Data Appendix Four: Sample Unit 2 Data Appendix Five: Sample Unit 3 Data Appendix Six: Sample Unit 6 Output Appendix Seven: Program Listing  iv  .  130 133 136 139 140 143 146 148 148 149 150 150 152 154 158 159 166  L i s t o f Tables  Table Table Table Table Table Table Table Table Table Table Table Table Table  I: Solvation Parameter for NaCl II: Short Range interaction Parameter for NaCl III: Expansion of Symbols in Figure 1 III: Continued, IV: Calculated values of Pressure, • • •, at time: 0.0 V: Calculated values of Pressure, • • , at time: 4000 VI: Calculated values of Pressure, , at time: 8000 VII: Calculated values of Pressure, , at time: 12000 VIII: Calculated values of Pressure, • , at time: 16000 DC: Coefficients for Equation A-15 X: Coefficients for Equation A-16 XI: Coefficients for Equation A-21 XII: Coefficients for Equations A-20 and A-21  v  21 22 31 32 94 95 96 97 98 135 135 138 138  List of Figures  Figure 1 - Tabular Forms of the Constraining Chemical Equations Figure 2 - Method of Solution Figure 3 - Iteration Scheme Used Figure 4A - Change in Pressure with respect to time and distance Figure 4B - Derivative of the Change in Pressure Figure 4C - Change in Velocity with respect to time and distance Figure 4D - Derivative of the Change in Velocity Figure 4E - Change in Porosity with respect to time and distance Figure 4F - Derivative of the Change in Porosity Figure 4G - Change in Permeability with respect to time and distance Figure 4H - Derivative of the Change in Permeability Figure 41 - Change in Concentration with respect to time and distance Figure 4J - Derivative of the Change in Concentration Figure 5A - Change in Temperature with respect to time and distance Figure 5B - Derivative of the Change in Temperature Figure 5C - Change in Porosity with respect to time and distance Figure 5D - Derivative of the Change in Porosity Figure 5E - Change in Concentration with respect to time and distance Figure 5F - Derivative of the Change in Concentration Figure 6A - Change in Pressure with respect to time and distance Figure 6B - Derivative of the Change in Pressure Figure 6C - Change in Velocity with respect to time and distance Figure 6D - Derivative of the Change in Velocity Figure 6E - Change in Temperature with respect to time and distance Figure 6F - Derivative of the Change in Temperature Figure 6G - Change in Porosity with respect to time and distance Figure 6H - Derivative of the Change in Porosity Figure 61 - Change in Concentration with respect to time and distance Figure 6J - Derivative of the Change in Concentration Figure 7A - Change in Pressure with respect to time and distance Figure 7B - Derivative of the Change in Pressure Figure 7C - Change in Velocity with respect to time and distance Figure 7D - Derivative of the Change in Velocity Figure 7E - Change in Porosity with respect to time and distance Figure 7F - Derivative of the Change in Porosity Figure 7G - Change in Concentration with respect to time and distance Figure 7H - Derivative of the Change in Concentration Figure 8A - Change in Temperature with respect to time and distance Figure 8B - Derivative of the Change in Temperature Figure 8C - Change in Porosity with respect to time and distance Figure 8D - Derivative of the Change in Porosity Figure 8E - Change in Concentration with respect to time and distance Figure 8F - Derivative of the Change in Concentration Figure 9A - Change in Pressure with respect to time and distance Figure 9B - Derivative of the Change in Pressure Figure 9C - Change in Velocity with respect to time and distance vi  30 34 56 64 64 65 65 66 66 67 67 68 68 70 70 71 71 72 72 74 74 75 75 76 76 77 77 78 78 80 80 81 81 82 82 83 83 85 85 86 86 87 87 89 89 90  Figure Figure Figure Figure Figure  9D 9E 9F 9G 9H -  Derivative of the Change in Velocity Change in Temperature with respect to time and distance Derivative of the Change in Temperature Change in Porosity with respect to time and distance Derivative of the Change in Porosity  Figure Figure Figure Figure Figure Figure Figure Figure Figure Figure Figure  91 - Change in Concentration with respect to time and distance 9J - Derivative of the Change in Concentration 10A - Change in Pressure with respect to time and distance 10B - Derivative of the Change in Pressure 10C - Change in Velocity with respect to time and distance 10D - Derivative of the Change in Velocity 10E - Change in Porosity with respect to time and distance 10F - Derivative of the Change in Porosity 10G - Change in Concentration with respect to time and distance 10H - Derivative of the Change in Concentration 11A - Change in Temperature with respect to time and distance  93 93 100 100 101 101 102 102 103 103 105  Figure Figure Figure Figure Figure Figure Figure Figure Figure Figure Figure Figure Figure Figure Figure Figure  11B - Derivative of the Change in Temperature 11C - Change in Porosity with respect to time and distance 11D - Derivative of the Change in Porosity H E - Change in Concentration with respect to time and distance 11F - Derivative of the Change in Concentration 12A - Change in Pressure with respect to time and distance 12B - Derivative of the Change in Pressure 12C - Change in Velocity with respect to time and distance 12D - Derivative of the Change in Velocity 12E - Change in Temperature with respect to time and distance 12F - Derivative of the Change in Temperature 12G - Change in Porosity with respect to time and distance 12H - Derivative of the Change in Porosity 121 - Change in Concentration with respect to time and distance 12J - Derivative of the Change in Concentration 13 - Availablity of Model Parameters  105 106 106 107 107 109 109 110 110 Ill Ill 112 112 113 113 118  vii  90 91 91 92 92  List of Symbols  A  Debye-Huckel electrostatic  a a  A c t i v i t y of a phase, species or c o m p o n e n t  coefficient  Size p a r a m e t e r f o r c a l c u l a t i n g a c t i v i t y c o e f f i c i e n t s  B  Debye-Huckel electrostatic  f>NaCl  Solvation  f>Nn+  ai-  coefficient  parameter  Short range interaction  parameter.  C Cp Cv  Concentration  A,y  Coefficient of dispersion  H e a t c a p a c i t y at c o n s t a n t  pressure  H e a t capacity at constant  volume  G  G i b b s free energy  g  Gravity  H  Enthalpy  I  Ionic  K  Equilibrium  m N n P  M o l a l i t y of an aqueous  Q ?  Source/sink  R s  Gas constant  s T V  Surface area Volume  X  M o l e f r a c t i o n of an e n d m e m b e r  z a  C h a r g e on an ion  strength constant species  T o t a l n u m b e r o f m o l e s o f a s p e c i e s , s o l i d , gas o r c o m p o n e n t N u m b e r o f m o l e s o f a s o l i d , a q u e o u s species o r gas Pressure Specific  term  discharge  Entropy Temperature  Coefficient of t h e r m a l  expansion  Coefficient of l o n g i t u d e n t a l  a P  T  dispersivity  Coefficient of i s o t h e r m a l  contraction  Activity  coefficient  e  Dielectic  constant  V  Dynamic  viscosity  6  Porosity  X  R a d i o a c t i v e decay  V  Stoichiometric  i p a  Progress variable  T  Time  U)  Born  1  dispersivity  Coefficient of transverse  constant  coefficient of c o m p o n e n t i n phase  Density R a t e of decomposition coefficient  viii  Acknowledgements  T h i s thesis c o u l d have never been w r i t t e n w i t h o u t t h e s u p p o r t , patience a n d e n c o u r a g e m e n t  of my  wife, Laurie. T h r o u g h t h e years, b o t h D r . T . H . B r o w n a n d D r . H.J. G r e e n w o o d have c o m m e n t e d on a n d discussed in detail topics t h a t  I have been i n t e r e s t e d  in.  T h e y have c r i t i c i z e d w h e n necessary,  and  helped  whenever needed. I deeply appreciate all t h a t they have done. I w o u l d like t o acknowledge  the  -  C o m p u t i n g Center at the University of British Columbia, Vancouver, B C , Canada,  -  Rechenzentrum, E T H , Zurich, Switzerland,  -  Z e n t r u m fur interaktives Rechnen, E T H , Zurich, Switerland,  -  Institut fur Mineralogie und Petrographie, E T H , Zurich, Switzerland,  f o r t h e use o f t h e i r c o m p u t i n g f a c i l i t i e s . Excluding  the figures, the p r o g r a m  and the data I / O listings,  all t e x t was processed using  w h i c h r e d u c e d t h e n i g h t m a r e o f typesetting e q u a t i o n s a n d t e x t t o a n a l m o s t p l e a s u r a b l e  ix  T^jX,  experience.  1.  Introduction  In any regional or local flow system, the fluid can react with the surrounding media. These reactions are manifested by the spatial and temporal distribution of phases and by the spatial and temporal variation in the composition of the phases and the fluid. Rock/water interactions can perturb the local temperature and flow fields and are one of the controlling factors in the rate of migration of chemical components. Geological examples are abundant: weathering, hydrothermal alteration, diagensis, metasomatism and ore deposition are familiar results of such processes. There are many examples of mathematical and numerical analysis for heat flow in solid media, fluid flow in porous/fractured media and coupled heat and fluid flow in porous media using various different boundary conditions. For example, the classic book of Bear (1972) presents and discusses the equations for both fluid flow and coupled heat-fluid flow in porous media. Numerical analysis of coupled flow processes has been applied to regional ground water flow (for example, Domenico and Palciauskas, (1973)), geothermal areas (for example, Straus and Schubert (1977), Sorey (1978)) and porphyry copper environments (for example, Norton and Knight (1977), Norton (1978)). Because of the increasing problem of chemical and nuclear waste disposal and the potential problem of contaminating existing flow systems, considerable attention has been paid to the migration of chemical species in ground water.  A few of the many papers discussing the various  aspects of the contaminant transport problem include those by Bredehoeft and Pinder (1973), Pinder (1973), Schwartz and Domenico (1973), Pickens and Lennox (1976), Konikow (1977), Pickens and Grisak (1979), Charbeneau (1981), Chu and Sposito (1981), Rao, Portier and Rao (1981), Smith and Schwartz (1981), Tang, Frind and Sudicky (1981), in addition to the numerous technical reports generated by the various atomic waste disposal groups. W i t h the exceptions of Norton (1978, 1979, 1982, 1984), Norton and Knight (1977) and Lichtner (1985), authors discussing the redistribution of mass generally limit themselves to near-surface iso-thermal conditions where the aqueous species and the solid phases are considered to be inert, or, a retardation factor is used to approximate the chemical reactions between the aqueous species and the surrounding matrix. Norton, and Norton and Knight have discussed the coupling of heat flow, fluid flow and chemical reactions for large systems in the vicinity of intrusive bodies and have assessed the critical factors constraining these 1  processes u n d e r h y d r o t h e r m a l c o n d i t i o n s . modynamic  consistent  Lichtner  model coupling advective  (1985) h a s p r e s e n t e d a m a t h e m a t i c a l a n d t h e r -  transport,  diffusion a n d chemical reactions.  His  m o d e l is i s o - t h e r m a l a n d i s o - b a r i c b u t c a n b e e a s i l y m o d i f i e d t o i n c l u d e t h e effects o f p r e s s u r e a n d temperature  (personal  communication).  E q u i l i b r i u m t h e r m o d y n a m i c s h a s been used b y p e t r o l o g i s t s f o r m a n y years t o calculate e q u i l i b r i a b e t w e e n m i n e r a l s a n d a f l u i d at elevated t e m p e r a t u r e s a n d pressures a n d t o d e l i m i t t h e c o n d i t i o n s o f f o r m a t i o n o f v a r i o u s phases a n d assemblages.  I n addition, t h equalitative estimation of t h e amounts  a n d d i s t r i b u t i o n o f phases i n a r o c k a l l o w p e t r o l o g i s t s t o suggest t h e possible r e a c t i o n s t h a t t h e phases in t h e rock have undergone. fluid,  I n o p e n systems, especially those t h a t c o n t a i n significant a m o u n t s o f a  t h e e x t e n t a n d n a t u r e o f t h e r e a c t i o n s are v e r y d i f f i c u l t t o d e l i m i t w i t h a n y degree o f confidence.  B e g i n n i n g i n t h e late sixties, a n u m b e r o f authors began t o m a t h e m a t i c a l l y m o d e l chemical reactions i n ideal closed systems  i n order  i n c l u d e ; weathering—Helgeson,  t o place constraints  Garrels a n d Mackenzie  1981); geothermal areas—Capuano  a n d Cole  on natural  analogies.  Calculated  (1969), F o u i l l a c e t a l . (1976), P f e i f e r (1977,  (1982); ore deposition—Helgeson  N o r t o n (1977); reaction of a vault fluid with different several rock types—Wolery alteration—Kwong,  Brown  and Greenwood,  examples  (1970), V i l l a s a n d (1980); supergene  (1982). T h e success o f t h e s e s i m u l a t i o n s  t h a t m a n y g e o c h e m i c a l processes c a n b e m o d e l l e d b y a m a t h e m a t i c a l  has shown  approach, leading t o a better  understanding of n a t u r a l systems. T h e r e have been three d i s t i n c t n u m e r i c a l approaches t o t h e m o d e l l i n g of chemical reactions i n g e o c h e m i c a l s y s t e m s ; t h e d i s t r i b u t i o n o f species m e t h o d , t h e d e r i v a t i v e m e t h o d , a n d t h e c o n t i n u u m m e t h o d . O f t h e three methods, only t h e c o n t i n u u m m e t h o d was initially a n d explicitly developed for an open s y s t e m , none were developed f o r systems u n d e r g o i n g changes i n t e m p e r a t u r e a n d pressure. T h e d i s t r i b u t i o n o f species m e t h o d w a s first used b y G a r r e l s a n d M a c k e n z i e lated the evaporitic concentration of spring water.  (1967), w h o s i m u -  T h e y solved t h e mass balance a n d mass  action  e q u a t i o n s f o r a series o f b u l k c o m p o s i t i o n s w h e r e e a c h b u l k c o m p o s i t i o n w a s r e l a t e d t o t h e p r e v i o u s -> o n e b y t h e r e m o v a l o f a s m a l l a m o u n t o f w a t e r .  I f t h e fluid w a s s u p e r s a t u r a t e d w i t h r e s p e c t t o a s o l i d  phase, a s m a l l a m o u n t o f this phase w o u l d b e p r e c i p i t a t e d ,  i f t h e fluid w a s u n d e r - s a t u r a t e d  with  r e s p e c t t o a s o l i d p h a s e , a s m a l l a m o u n t w o u l d b e d i s s o l v e d i n t o t h e fluid. T h e m e t h o d is n o n - l i n e a r a n d i t e r a t i v e b u t h a s t h e d i s t i n c t a d v a n t a g e t h a t i t is easy t o u n d e r s t a n d a n d p r o g r a m . r e - e x a m i n e d i n m o r e d e t a i l since t h e w o r k o f G a r r e l s a n d M a c k e n z i e .  I t has been  Karpov, Kay'min and Kashik  (1973) p r e s e n t e d i t i n t h e R u s s i a n l i t e r a t u r e , w h i l e P a r k h u r s t , P l u m m e r a n d T h o r s t e n s o n (1978, 2  1980), Wolery (1979) and Read (1982) have developed more general and efficient algorithms. The derivative method was developed by Helgeson who recognized that the changes in the amount and composition of phases during a reaction could be modelled as a expansion in the derivatives taken with respect to reaction progress.  In a series of theoretical papers, (Helgeson  (1968), Helgeson (1970a,b), Helgeson, Brown, Nigrini and Jones (1970), Helgeson (1971)), Helgeson discusses the equations and implications of this technique, and presents the results of different iso-thermal iso-baric processes that he and his co-workers modelled. Subsequent development of this approach has been limited: Fouillac, Michard and Bocquier (1976) discussed the modifications necessary to model a partially open system while Perkins (1980) corrected some conceptual errors in the equations and presented a more efficient numerical algorithm. The continuum model of Lichtner couples the first derivatives of the molalities of the aqueous species and of the number of moles of solid phases with respect to time directly to the transport equations.  This allows a rapid coupled solution of the equations but restricts the step size.  It  currently has not been extended to systems with thermal or pressure gradients. Kinetic equations for solid phases are very easily included. The distribution of species method and the derivative method are complementary. For large complex unconstrained problems when only limited information about the process is needed, the distribution of species method can be very efficient. The derivative approach analytically solves the reaction coefficients at each time step, thus knowledge of the reaction is more detailed. With the exception of this thesis, neither method has proven to be successful in modelling an open system. The extent to which a phase or assemblage has undergone a reaction is given by the progress variable, initially defined by DeDonder (1920) and formalized by Prigogine and Defay (1954). It was first related to geochemical systems by Helgeson (1968).  The progress variable relates the degree of  reaction to the forces which cause the reaction—dissolution of phases not in equilibrium with the fluid, changes in temperature and/or pressure, etc. With the exception of Lichtner, none of the authors modelling reactions involving a fluid have related the progress variable to time. This is a direct result of the rather limited kinetic information known at the time these models were developed. There has been considerable work in the last few years relating reaction progress to time. Kinetic equations describing the dissolution rates of silicates with specific reference to the progress variable have been developed by Aagaard and Helgeson (1982), Helgeson and Murphy (1983) and Murphy and Aagaard (1984). Their models are functions of surface area and reaction affinity. Other approaches 3  to the rate at which silicate reactions occur relate directly to functions of time and bypass the progress variable. Lasaga (1984) in a review paper summarizes many of the different models and discusses the effect of grain size on reaction rate. This thesis develops the equations constraining chemical reactions in an open system and couples the partial differential equations constraining heat flow, fluid flow and mass transport to them. Modification of the transport, heat and flow equations was necessary and is discussed in separate chapters.  All equations have been specifically developed for porous media, fluid flow in fractured  media or multi-phase flow is beyond the scope of this work. Using the equations, a computer program has been written to calculate chemical reactions in a flow system with thermal and compositional gradients. A description of the program, a program listing, sample input data, and a partial listing of the output are given in the appendices.  The  program has been used to model several rock-water systems and the results are briefly discussed at the end of this thesis. Fluid flow in the program is considered to occur as a direct result of fluid potential and not as a direct result of density, temperature or chemical gradients. However, the spatial and temporal changes in density, temperature and fluid composition will modify the fluid potential, thus indirectly affecting the fluid flow. The numerical method used is based on the derivative method and the driving forces will include temperature, pressure, dissolution of phases not in equilibrium with the system, radioactive decay and addition or removal of mass from the system.  4  2. D e s c r i p t i o n of the P r o b l e m  To mathematically extensive  d e s c r i b e t h e c h e m i c a l processes o c c u r r i n g i n a v o l u m e o f r o c k , t h e i n t e n s i v e  properties  over the v o l u m e  (temperature,  element.  pressure, porosity,  T h i s volume element  must  bulk composition,  ...)  must  be an  be large c o m p a r e d  to the dimension  and  average of the  i n d i v i d u a l p o r e s a n d m i n e r a l g r a i n s . I f t h e s y s t e m is n o t c l o s e d , t h e n e a c h v o l u m e e l e m e n t m u s t b e s m a l l c o m p a r e d t o t h e t o t a l d i m e n s i o n s o f t h e s y s t e m as w e l l as b e i n g s m a l l e r t h a n t h e l a r g e - s c a l e heterogeneities.  T h e v o l u m e element corresponds directly to the representative  elementary  volume  I n any given v o l u m e of rock, o n l y t w o types of phases w i l l be c o n s i d e r e d — c r y s t a l l i n e  phases  ( R E V ) as d e f i n e d b y B e a r  and  a  fluid  w i t h the  phase.  fluid  respectively.  1  (1972).  T h e crystalline  and those not. The  fluid  phases can be s e p a r a t e d  i n t o t w o sets:  those in  equilibrium  T h e s e w i l l b e r e f e r r e d t o as e q u i l i b r i u m p h a s e s a n d r e a c t a n t  p h a s e is c o m p o s e d p r e d o m i n a t e l y  phases,  of w a t e r w i t h dissolved m a t e r i a l i n  f o r m o f c h a r g e d a n d n e u t r a l a q u e o u s species a n d c o m p l e x e s .  The  fluid  the  phase can be assumed t o be  i n i n t e r n a l e q u i l i b r i u m b e c a u s e t h e r e a c t i o n t i m e s b e t w e e n m o s t a q u e o u s species a n d c o m p l e x e s s o l u t i o n are o n t h e o r d e r o f m i l l i s e c o n d s . o f s o l u t i o n as t h e c o m p o s i t i o n  of the  Equilibrium  fluid  changes.  phases w i l l dissolve i n t o or p r e c i p i t a t e  T h e r a t e s o f t h e s e r e a c t i o n s are m u c h  t h a n the reaction rates involved in the internal equilibria of a than the rate  at w h i c h  reactant  phases dissolve.  Thus,  a n d t h e e q u i l i b r i u m phases represents a stable e q u i l i b r i u m  fluid,  assemblage.  supersaturation Reactant which  w i t h respect  fluid  faster phase  reaction  I t also i m p l i e s  t o any m i n e r a l even t h o u g h  that  a s m a l l degree  of  to.  rate  at  area, the degree  of  is n e c e s s a r y as t h e d r i v i n g f o r c e f o r p r e c i p i t a t i o n .  phases  the reactant  are those w h i c h  the  phases dissolve i n t o  u n d e r s a t u r a t i o n of the  fluid  a  fluid  is u n d e r s a t u r a t e d  fluid  is a f u n c t i o n  with  respect  of t h e i r surface  The  w i t h r e s p e c t t o t h a t p h a s e , t e m p e r a t u r e , a n d t o a lesser e x t e n t , p r e s s u r e .  A r e a c t a n t phase w i l l become an e q u i l i b r i u m phase w h e n t h e  1  the  This implies that  r a t e s f o r t h e e q u i l i b r i u m p h a s e s are t h e s a m e as t h o s e f o r t h e a q u e o u s s p e c i e s . t h e f l u i d can never be s u p e r s a t u r a t e d  that  out  slower  b u t are g e n e r a l l y m u c h  it w i l l be assumed  in  fluid  saturates w i t h respect to it.  E q u i l i b r i u m p h a s e s h a v e o f t e n b e e n r e f e r r e d t o as p r o d u c t p h a s e s i n t h e l i t e r a t u r e . 5  T h e p e r t u r b a t i o n of a n e q u i l i b r i u m assemblage b y changes i n t e m p e r a t u r e , changes i n pressure, dissolution of reactant and radioactive  phases i n t o t h e  fluid,  transport  of material  into/out  of thevolume  element  d e c a y c a n b e e x p r e s s e d t h r o u g h t h e use o f a series e x p a n s i o n i n t h e n u m b e r o f m o l e s  o f each p h a s e a n d species. F o r e x a m p l e , t h e c h a n g e i n t h e n u m b e r o f m o l e s o f a phase o r species ( n ) o v e r a t i m e i n t e r v a l ( A r ) c a n b e e x p r e s s e d u s i n g a T a y l o r series as:  A  ^  = ^  d is t h e t o t a l d e r i v a t i v e .  dn  A x -  +  (AT)  2  2  L _ i - ^  +  (ArP d ' n  d n ...  +  ^  +  -  —  (1)  .  O n e such expansion i n the n u m b e r o f moles a n d the derivative w i t h respect  t o time c a n be w r i t t e n  f o r each p h a s e a n d species i n t h e s y s t e m .  Each of t h e derivatives  can be  e x p a n d e d as f u n c t i o n s o f t h e i n t e n s i v e a n d e x t e n s i v e p r o p e r t i e s w h i c h a f f e c t t h e s y s t e m . F o r e x a m p l e , an expansion of the  first  dn  derivative  dn dT  d7 ~ d~f ~d7  could yield:  dn dP +  ~9P !h  dn c=l  The  first  a n d t h e second terms  functions of temperature  (T)  on the right  dNx.c  9NTc  ^  +  9T  +  dn 9nr  ..  ^ 3 ^ ~ 3 7  '  '  ^'  r=l  h a n d s i d e a r e t h e c h a n g e i n t h e n u m b e r o f m o l e s as  and pressure ( P ) , respectively.  T h e t h i r d t e r m o n t h e r i g h t h a n d side  is t h e c h a n g e i n t h e n u m b e r o f m o l e s as a r e s u l t o f a c h a n g e i n t h e t o t a l n u m b e r o f m o l e s o f t h e c ' t h component  (NT.C)—the  result o f mass  term on the right-hand dissolution of reactant field,  flux  a n d possibly  as a r e s u l t o f r a d i o a c t i v e  s i d e is t h e c h a n g e i n t h e n u m b e r o f m o l e s as a f u n c t i o n phases i n t o t h e  fluid.  2  decay.  of the  irreversible  I f other intensive variables, for example t h e magnetic  c o u l d p o s s i b l y affect t h e s y s t e m , t h e n a n a d d i t i o n a l d e r i v a t i v e f o r each o f these n e w  variables  should be included i n equation  T h e last  (2). C o n v e r s e l y ,  i f any of t h e derivatives  intensive  i n e q u a t i o n (2)  are zero a n d w i l l r e m a i n zero t h r o u g h o u t t h e e n t i r e process, t h e n t h e e n t i r e t e r m c a n b e e x c l u d e d , simplifying  the modelling.  The derivatives  of t h e n u m b e r of moles w i t h respect t o t i m e i n equation  (1) c a n b e s o l v e d b y  t a k i n g a n d m a n i p u l a t i n g derivatives o f t h e mass balance a n d mass a c t i o n equations.  These equations  a r e d e v e l o p e d i n c h a p t e r s 4 a n d 5, a n d a m e t h o d o f s o l u t i o n d i s c u s s e d i n c h a p t e r 6. T h r e e n e w t e r m s  (dP/dr, They  dNx.c/dr  are i n t r o d u c e d  c a n be solved using t h e radioactive  equations. 2  a n d dT/dr)  as t h e r e s u l t o f e x p a n s i o n s  decay law, t h e  fluid  flow,  s i m i l a r t o e q u a t i o n (2).  mass t r a n s p o r t  a n d heat  flow  T h e s e a r e d i s c u s s e d i n c h a p t e r s 4, 7, 8 a n d 9, r e s p e c t i v e l y .  M o r e c o r r e c t l y , t h i s l a s t t e r m c o u l d b e t h o u g h t o f as t h e r e a c t i o n o f s u b s y s t e m s w h i c h m a y o r  may not be i n internal equilibrium equilibrium  a t t h e specified  a t t h e s p e c i f i e d c o n d i t i o n s w i t h a s u b s y s t e m w h i c h is i n i n t e r n a l  conditions.  Higher order terms in equation 1 can be evaluated and expanded in a similar fashion as was done to obtain equation 2. When more high order terms are evaluated, a larger time step can be taken. Although a Taylor series was used for equation (1), this does not imply that it is the only applicable expansion.  A Taylors series is an exact description of any continuous function  when sufficient derivatives are used. When only a limited number of derivatives are available, other expansions of the same order may be able to approximate the true function to a greater degree of accuracy.  7  8. C o m p o n e n t s  In a strict thermodynamic  sense, a set o f c o m p o n e n t s r e f e r s t o t h e set o f i n d e p e n d e n t b a s i s v e c t o r s  t h a t c o m p l e t e l y s p a n t h e c o m p o s i t i o n a l s p a c e o f t h e s y s t e m . E a c h c o m p o n e n t has a u n i q u e c o m p o s i t i o n w h i c h m a y be i d e n t i c a l t o t h e c o m p o s i t i o n of a phase o r species i n t h e s y s t e m . T h e c o m p o s i t i o n o f a c o m p o n e n t need n o t c o r r e s p o n d t o a r e a l phase or species, a n i m a g i n a r y or negative  composition  is p e r f e c t l y v a l i d . I n a d d i t i o n , t h e c o m p o n e n t m a y b e a s s i g n e d i d e n t i c a l t h e r m o d y n a m i c  and physi-  c a l p r o p e r t i e s as a p h a s e o r s p e c i e s . T h i s d o e s n o t i m p l y t h a t t h e p h a s e o r species is a c o m p o n e n t , r a t h e r t h a t t h e i r p r o p e r t i e s are i d e n t i c a l . a component generally  A phase or species w i l l always have t h e same a c t i v i t y  w i t h i d e n t i c a l p r o p e r t i e s ; h o w e v e r , t h e n u m b e r o f moles of t h a t phase or species  be d i f f e r e n t t h a n t h e n u m b e r o f moles o f t h e c o r r e s p o n d i n g  component.  as will  The number  m o l e s o f a n y p h a s e o r species is a l w a y s z e r o o r p o s i t i v e , t h e n u m b e r o f m o l e s o f a c o m p o n e n t  of  may  be negative, zero or positive. T h e m i n i m u m n u m b e r o f c o m p o n e n t s n e e d e d t o d e s c r i b e a n y r e a l s y s t e m is o n e . T h e number oxidation  of components  depends  o n several factors:  s t a t e s o r c h a r g e d species  the number  are p r e s e n t , i f c o m p o s i t i o n a l  m o r e t h a n one isotope exists for any element.  of elements  present,  dependencies  maximum if  multiple  are p r e s e n t  and  I n a n y f l u i d - r o c k s y s t e m c o m p o s e d of elements  if  with  a u n i q u e i s o t o p i c c o m p o s i t i o n , t h e m a x i m u m n u m b e r o f c o m p o n e n t s is t h e n u m b e r o f e l e m e n t s p l u s one.  If o n l y one o x i d a t i o n  state exists for each element, t h e m a x i m u m  equal t o the n u m b e r of elements. chemical behaviour  number  of c o m p o n e n t s  If m o r e t h a n one isotope exists for a given element,  is s i g n i f i c a n t l y d i f f e r e n t , t h e n t h e y m u s t b e t r e a t e d i n d e p e n d e n t l y .  and  is  their  Because  the  p r e s e n c e o f a r a d i o g e n i c o r r a d i o a c t i v e i s o t o p e r e s u l t s i n a n a d d i t i o n a l c o m p o n e n t w h i c h is d e p e n d e n t o n t i m e , t i m e m u s t b e i n c l u d e d as a n i n t e n s i v e T o m i n i m i z e t h e numerical  roundoff  error,  variable. simplify  the equations a n d the m e t h o d of s o l u t i o n ,  t h e c o m p o n e n t basis w i l l be c o m p r i s e d of c o m p o n e n t s w i t h c o m p o s i t i o n a l a n d t h e r m o d y n a m i c erties i d e n t i c a l t o t h e e q u i l i b r i u m phases a n d w a t e r . tional and thermodynamic  T h e r e m a i n i n g c o m p o n e n t s w i l l have c o m p o s i -  properties identical to the most abundant independent  C h a n g i n g f r o m one c o m p o n e n t basis t o a n o t h e r can be d o n e b y s i m p l e m a t r i x W h e n the activity  or t h e n u m b e r o f moles of each c o m p o n e n t 8  prop-  aqueous species.  manipulations.  is k n o w n f o r a g i v e n  tempera-  ture and pressure, then the activities of all species, complexes and phases in the system are fixed. Various authors have taken advantage of this in geochemical modelling, for example: Brown and Skinner (1974) in the prediction of equilibrium phase assemblages, Wolery and Walters (1975) in the Monotone Sequence method of distribution of species, Perkins (1980) in mass transfer theory. The number of independent solute transport equations needed to completely describe the migration of chemical species in a flow system is also equal to the number of components. This is discussed in more detail below.  9  4. T h e r m o d y n a m i c  At  any given t e m p e r a t u r e ,  pressure  a n d species i n a n e q u i l i b r i u m  Basis of the C o n s t r a i n i n g  and composition,  s y s t e m is c o m p l e t e l y  mass action a n d mass balance equations.  Equations  the distribution  determined  The temperature,  of mass a m o n g the  and can be c a l c u l a t e d  the pressure  t h e e q u i l i b r i u m s y s t e m m a y c h a n g e as a f u n c t i o n o f t i m e , p o t e n t i a l l y  phases  using  the  and the composition  of  changing the distribution  of  mass a m o n g t h e phases a n d species. T h i s change i n t h e d i s t r i b u t i o n of mass c a n be solved b y t a k i n g the derivatives  w i t h respect  to time of the constraining  equations, solving t h e m , and using  these  d e r i v a t i v e s i n a series e x p a n s i o n t o p r e d i c t t h e n u m b e r o f m o l e s at f u t u r e t i m e s . T h e derivatives  of the mass balance  discussed separately.  and mass action equations  w i t h respect  to time will  A s t h e s e e q u a t i o n s are d e r i v e d , t e r m s w i l l a p p e a r w h i c h c a n o n l y b e e v a l u a t e d  b y t h e use o f e m p i r i c a l a n d s e m i - e m p i r i c a l m o d e l s o r b y t h e a p p l i c a t i o n o f m o d e l - d e p e n d e n t conditions.  These w i l l be discussed a n d evaluated i n the following  The Mass Balance There  be  boundary  chapters.  Equation  are nc i n d e p e n d e n t  mass balance  equations,  one for each of t h e c o m p o n e n t s .  b a l a n c e e q u a t i o n expresses t h e t o t a l n u m b e r of moles of t h e c ' t h c o m p o n e n t  (NT. ) C  Each  mass  as a s u m o f t h e  n u m b e r o f m o l e s o f t h e c ' t h c o m p o n e n t i n e a c h o f t h e p h a s e s , a q u e o u s species a n d c o m p l e x e s i n t h e volume element.  I t c a n b e " w r i t t e n as:  (3)  w h e r e nr, ns, np a n d ei are t h e n u m b e r o f r e a c t a n t p h a s e s , n u m b e r o f a q u e o u s species a n d c o m p l e x e s , n u m b e r o f e q u i l i b r i u m p h a s e s a n d n u m b e r o f e n d m e m b e r s o f t h e i^th e q u i l i b r i u m p h a s e , r e s p e c t i v e l y . n„, n , n , j t a r e t h e n u m b e r o f m o l e s o f t h e s ' t h a q u e o u s s p e c i e s , o f t h e r ' t h r e a c t a n t m i n e r a l a n d o f r  t h e k'ih e n d m e m b e r o f t h e i'th. m i n e r a l , r e s p e c t i v e l y . the c'th component  v .s, v . c  0  T  a n d v .i.k are t h e n u m b e r o f m o l e s o f c  i n one m o l e of t h e s ' t h aqueous species, i n one mole of t h e r ' t h r e a c t a n t  a n d i n o n e m o l e o f t h e k'th e n d m e m b e r o f t h e i ' t h e q u i l i b r i u m p h a s e , r e s p e c t i v e l y . phase, the n u m b e r of e n d m e m b e r s  is o n e .  Thus the  first  phase  In a stoichiometric  t e r m on the r i g h t - h a n d  side of t h e mass  balance e q u a t i o n represents t h e aqueous species, t h e second a n d t h i r d represent t h e solid phases i n  10  equilibrium with the fluid (equilibrium phases) and those not in equilibrium with the fluid (reactant phases), respectively. The molality of an aqueous species ( m „ ) is related to the total number of moles of that species (n ) by: s  = 55.51— n„  m  s  (4)  is the number of moles of water and 55.51 the number of moles of water in one thousand grams  n  w  of water. 3  By substituting equation (4) for the number of moles of each aqueous species, the mass  balance equation can be written in terms of the molalities of aqueous species and number of moles of solid phases. It is:  N T  -O  =  Y  "55 51 '  9=1  +  '  Y  Y  y  o.i.kni.k + Yl <-r r  t'=l  V  fc=l  (5)  n  r=l  Equation (5) is more useful than equation (3) for several reasons. • • The reported analytical results of most waters are given in units relative to a fixed mass or volume of solvent or to a fixed mass or volume of water.  It is simple to convert these to  molalities. •  Because of the standard state conventions used, molality is easily equated to activity.  The derivative of the mass balance equation (equation 5) with respect to time is: j »r -5^  ns  „.  = 2 . - 5 5 1 1 — a T " 9=2  ns +  ~  Y - ^ i r ^ r «=1  np ei  «  + Y Y ^ - j ^ i=l  fc=l  nr  + Y ^ ^  3  (6)  r=l  The derivatives of the molalities of the aqueous species have been written as a logarithmic derivatives through the use of the relationship dx = xd ln x = 2.303 xd log x. For convenience, the convention that water is always the first aqueous species will be followed. The number of moles of water per one thousand grams of water is a constant and its derivative zero. Thus the first term in equation (6), the derivative of the molality of the aqueous species, is summed from s = 2 and not from s = 1. The second term, the derivative of the number of moles of water, is summed from s = 1 to include the change in the total number of moles of water and its effects on all aqueous species, including solvent water. The first three terms on the right-hand side contain derivatives of the molalities of the aqueous species, of the number of moles of water and of the number of moles of each of the equilibrium 3  The actual value is closer to 55.50825 but 55.51 will be used for brevity. 11  phases with respect to time. They will be solved and used to predict the change in the number of moles of each phase and species in the volume element once the remaining constraining equations have been developed. The derivative in the last term on the right-hand side is the change in the number of moles of the reactant minerals with respect to time. This term depends on the composition of the fluid in the volume element, the volume of the reactant minerals and their surface area. It can be solved using semi-empirical models and is discussed in chapter 5. The left-hand side of equation (6) is the change in the number of moles of the c'th component with respect to time. This derivative is a function of only two processes which can be assumed to be additive: • Mass flux into/out of the volume element, • Radioactive decay. Mass flux into/out of the volume element is an applied boundary condition or it can be calculated using the flow, solute transport and diffusion equations. The coupling of the flow and solute transport equations to the chemical reaction equations is discussed in chapters 7 and 8. The rate of decay of an radioactive isotope can be calculated using the decay constant (A) and the decay equation: ]Sr  = N e~  +Ar  N  T  and ^ V  T + A R  T  .  XAT  (7)  are the number of moles of the isotope at time r and r + A T , respectively. In a closed  system with radioactive components present, the left-hand side of equation (6) for a radioactive parent component would reduce to:  ^  = -XN .. UT and for a daughter component, the left-hand side reduces to: -^  T  d  or  = +XN . T  c  .  (8)  (9)  For any non-radiogenic component in a closed system, the left-hand side of equation (6) reduces to: -  ^  = 0  .  (10)  The energy released during the process of radioactive decay is easily included in the energy balance for a REV. Unfortunately, the exact amount of energy depends on the type of particles, the nature of their interaction with the surrounding matrix/fluid, and if their interaction causes any 12  chemical reactions to occur. In general, the amount of energy released during most decay processes in many different matrix materials is known, plus/minus an order of magnitude or two, and can be included. The change in mass of each of the components as a result of radioactive decay is potentially very easily included, see equation (9) for example. The problem is that there is no reasonable way to include the elementary particles released during a decay reaction—many for micro-seconds  are stable only  and their final form largely depends on the surrounding matrix. By ignoring  their presence, changing amount and interaction with the other phases in the system, the mass and energy balance equations have been violated. Except under very unusual circumstances (for example, natural reactors ), the violation is local, affecting the rock matrix and the fluid a maximum 4  of millimeters around the point of decay, and thus can be considered trivial. 5  4  Some fluid inclusions from the Okla natural reactor contain 95 percent hydrogen and 5 percent  nitrogen, others contain 80 percent hydrogen and 20 percent oxygen. Clearly the only reasonable source for the hydrogen (and oxygen) was from the breakdown of water—introduced by interaction with the decay particles. This non-equilibrium assemblage is probably the most extreme example of decay affecting the surrounding fluid and minerals. J. Dubessy, personal communication.  5  The average length of the decay path of many particles is on the order of angstroms to 10's of  microns. Those with a longer decay paths generally do not cause chemical reactions to occur. 13  The  Mass Action  Equation  The  a c t i v i t y of the s'th aqueous species  c a n be related t o the a c t i v i t y of the c o m p o n e n t s  through  the mass action equation. F o r the s'th species, the mass action equation c a n be written: nc In K = v„ ln as +  i/ ln a C9  (11)  c  0=1 where a  a n d a„ are the activities of the c'th c o m p o n e n t a n d the s'th species, respectively. i/  c  cs  i/g are the reaction coefficients of the c'th component is the e q u i l i b r i u m y  K  s  constant for the reaction between the s'th aqueous species a n d the components.  has been i n c l u d e d for completeness b u t generally  s  a n d the s'th species i n the s'th reaction.  and  is equal t o one. T h e r e l a t i o n s h i p between the  a c t i v i t y of a phase a n d the c o m p o n e n t s is expressed using a mass action equation of i d e n t i c a l f o r m to e q u a t i o n (11), the s u b s c r i p t The  s is replaced  b y the subscript i t o i n d i c a t e the i'th phase.  r e l a t i o n s h i p between the a c t i v i t y a n d the molality of a n aqueous species is:  o, = 7 „ m  where 7 , , a  s  and m  s  (12)  s  are t h e a c t i v i t y coefficient, activity a n d m o l a l i t y of the s'th species, respectively.  E q u a t i o n (11) does n o t differentiate between c o m p o n e n t s w i t h different types of properties. It can  be r e w r i t t e n  such that np c o m p o n e n t s have the same properties  as the np e q u i l i b r i u m  phases,  one has t h e same properties as water, a n d the r e m a i n i n g c o m p o n e n t s have the same properties as the most a b u n d a n t i n d e p e n d e n t aqueous species.  S u b s t i t u t i n g equation  (12), the r e l a t i o n s h i p between  m o l a l i t y a n d activity, into the r e w r i t t e n f o r m yields: lnJT,  , =  l n 7 „  , +  In  1 m  s  +  v .B In a + ^2 w  np is the n u m b e r of e q u i l i b r i u m  w  ln  7  C  +  i/ , l n m  ^  c=2  c  s  c  c=2  phases i n the system, nc  sp  + ^  ^  y,j, In a k  iA  (13)  i = l k=l  is the n u m b e r of aqueous species  repre-  senting the r e m a i n i n g c o m p o n e n t s . T h e subscript w indicates water. T h e molalities of the aqueous species are s u m m e d f r o m c = 2 t o allow water t o be treated separately. a component, then the aqueous species  terms must be s u m m e d f r o m  d r o p p e d . If the k'th e n d m e m b e r of t h e i'th e q u i l i b r i u m  c =  1 a n d the water t e r m is  m i n e r a l does not have the same  as a component, t h e n iVt.fc (the coefficient of the &'th e n d m e m b e r reaction)  is zero, a n d a mass action equation similar t o equation  activity.  T h e mass action e q u a t i o n  between a c o m p o n e n t  c h e m i c a l a n d t h e r m o d y n a m i c properties  Ji water does not represent  properties  of the i'th m i n e r a l i n the s'th  (11) c a n be used t o calculate its  a n d a phase or species  w i t h t h e same  is trivial, the phase or species has t h e same a c t i v i t y as the  component.  14  The activity of the k'th solid solution species (dk) in a ei-component solid solution mineral is given by: (14)  O-k — IkXk  (15)  Y i n  3=1 where Xk and 7 ^ are the mole fraction and the activity coefficient of the &'th solid solution endmember, respectively.  Substituting equation (15) into equation (14) and the result into equation (13)  yields a general form of the mass action equation, which can be written as: In if,  , = kii  s  , 1 + In m H  ,,, ln a + Y c.s In 7 c + X ] c-2 c=2 np ei r v  s  w  »'=1 k=l  m  m  c  ei  (16)  j=i  L  If an equilibrium phase is stoichiometric—it has only one endmember, its activity coefficient is one and the logarithmic terms involving the number of moles of solid phases drops out. Equation (16) can be rewritten to describe the activity of the I'th non-component phase by substituting the subscript i for the subscript s. Differentiating equation (16) with respect to time yields: 1 dhiK v * dr  <9hi79 dr  3 ln m9 dr  5 .ln a v . ——  1 u  w  w  s  OT  a  ^ np ei  >^sp \ ^  V)  d ln 7 , .  ,v  c=2  31n7,-,fc 1 drii.k dr ' riik dr  1=1 fc=l  d ln m,. dr  v—^  c  1 it  e i  Y  ei  9 ra».y  i-^ dr ^-^  (17)  3 = 1  J'=I  The equilibrium constant can be expanded in terms of the thermodynamic variables of each phase and species in the reaction, yielding:  , h  „ l  K  =  -AC -^f-=  APT - TAS -RT  r  , , < > 18  and taking its derivative with respect to time yields: d\nK dr  AH dT r  RT  2  dr 15  AV RT  dP dr  (19)  R is the gas constant, A C , AS , AH , r  r  and AV  enthalpy, and volume of reaction, respectively.  are the Gibbs free energy, the entropy, the  As these terms are functions of temperature and  pressure, they must be evaluated under the conditions of reaction. The thermodynamic variables and their derivatives are summarized in appendix one. Values for various phases and species can be obtained from standard compilations of thermodynamic data, for example: Robie, Hemingway and Fisher (1978), Helgeson, Delany, Nesbitt and Bird (1978) and Berman, Brown and Greenwood (1985). The derivatives of pressure and temperature with respect to time in equation (14) are either known boundary conditions or have been solved using the flow and heat equations presented in chapters 7 and 9. The derivatives of the activity coefficients of aqueous species and of solid phases and the derivative of the activity of water are model-dependent. They will be discussed in chapter 5. It is often necessary to simplify theoretical equations representing real systems, either because essential data may be missing or because the complete forms of the equations are too complex. The right-hand side of equation (17) can be simplified by several assumptions. The fluid phase in many geological systems is believed to be a concentrated brine and the removal/addition of small amounts of mass from/to the fluid will not significantly change the activity coefficients of the aqueous species. Under these conditions, the activity coefficients of aqueous species can be assumed to be constant and their derivatives zero. The activity of water varies from 1.0 in an infinitely dilute solution to approximately 0.95 in a 3 molal sodium chloride solution at 25  C—the magnitude of c hange is  similiar at higher pressures and temperatures. For this reason, the activity of water can be assumed to be constant and its derivative zero under many geological situations. If the equilibrium phases can be represented by an ideal solid solution (activity coefficients constant and equal to one), then when combined with the above assumptions, equation (17) reduces to:  (20)  16  Summary The total derivative of the mass balance equation and the mass action equation with respect to time (equations (6), (17) and (19)) introduces a large number of new terms which must be evaluated. These terms are model-dependent and will be discussed in chapters 5, 7, 8 and 9. If a variety of reasonable assumptions are made, the derivatives of both the mass balance and mass action equations can be reduced in complexity, leaving only the boundary conditions (dNx.c/dT/dr,  dP/dr) to  be specified. These assumptions allow complicated systems to be simplified to a sufficient degree such that they can easily be modelled.  17  5. M o d e l - D e p e n d e n t  Equations  T h i s c h a p t e r e v a l u a t e s t h e model-dependent d e r i v a t i v e t e r m s a n d i n t r o d u c e s  two new  constraining  e q u a t i o n s , b o t h o f w h i c h are t h e result o f t h e specific m o d e l s used. T h e t w o n e w e q u a t i o n s c o u l d b e d i r e c t l y s u b s t i t u t e d i n t o t h e d e r i v a t i v e o f t h e m a s s a c t i o n a n d t h e m a s s b a l a n c e e q u a t i o n s , b u t as s h o w n i n c h a p t e r 6, t h e i r i n t r o d u c t i o n as i n d e p e n d e n t e q u a t i o n s a l l o w s a m o r e e f f i c i e n t  mathematical  s o l u t i o n t o be used.  A c t i v i t y Coefficients of Solid Solution Species T h e d e r i v a t i v e o f t h e m a s s a c t i o n e q u a t i o n ( e q u a t i o n 17) h a s i n t r o d u c e d t h e d e r i v a t i v e o f t h e a c t i v i t y of each o f t h e solid s o l u t i o n e n d m e m b e r s .  T h e d e r i v a t i v e o f t h e n u m b e r o f moles o f each o f t h e solid  s o l u t i o n e n d m e m b e r s was i n t r o d u c e d i n the derivative of the mass balance e q u a t i o n . derivative  o f mass  and of activity,  a solid solution  m o d e l f o r every  phase w h i c h  To relate  the  potentially can  exhibit solid s o l u t i o n m u s t be assumed o r k n o w n . I f t h e a c t i v i t y o f a solid s o l u t i o n e n d m e m b e r is e q u a l t o its m o l e f r a c t i o n , t h e n t h e  derivative  o f t h e a c t i v i t y is e q u a l t o t h e d e r i v a t i v e o f t h e m o l e f r a c t i o n , w h i c h i n t u r n c a n b e e q u a t e d t o t h e t o t a l n u m b e r o f moles o f each e n d m e m b e r a n d t h e i r derivatives.  Tli  Y Hi «'=1  \  ( ani k  J2 n' Unfortunately  i=l  -Xi  k  V  f e w s o l i d s o l u t i o n phases o b e y such s i m p l e r e l a t i o n s h i p s .  solid solution models i n the literature.  There  are m a n y  different  F o r each, an e q u a t i o n c a n be w r i t t e n r e l a t i n g t h e d e r i v a t i v e o f  t h e a c t i v i t y , m o l e f r a c t i o n a n d t h e n u m b e r o f moles of each e n d m e m b e r .  For purposes of illustration,  t h e m o s t g e n e r a l m o d e l w i l l b e u s e d . B a s e d o n a p o l y n o m i a l e x p a n s i o n o f t h e excess f r e e e n e r g y o f a solid solution, B e r m a n and B r o w n  (1984) d e v e l o p e d 18  a general equation t o calculate the  activity  coefficient  o f t h e / ' t h s o l i d s o l u t i o n species i n a  fc-component  solid solution.  When a third  degree  p o l y n o m i a l is u s e d t o d e s c r i b e a b i n a r y s o l i d s o l u t i o n p h a s e , t h e i r e q u a t i o n r e d u c e s t o t h e M a r g u l e s f o r m u l a t i o n f o r a b i n a r y a s y m m e t r i c s o l i d s o l u t i o n ( T h o m p s o n , 1967). T h e g e n e r a l e q u a t i o n f o r t h e a c t i v i t y c o e f f i c i e n t o f t h e / ' t h species g i v e n b y B e r m a n a n d B r o w n i s : (k-1  l n 7y =  k  E  aRT  E  k  -  .  ^i'l = l l2=>i  E *p = *fp — 1  (21)  i) I I X *  i j > (=1  1=1  J)  where: •3)  k=l  a n d f o r n = 0, 0 r t = 1, f o r n > 0, 0"  p is t h e d e g r e e o f p o l y n o m i a l parameter  used i n t h e f u n c t i o n  between the subscripted  0.  t o fit t h e d a t a .  M^,.i  T is t h e t e m p e r a t u r e ,  endmembers.  a n d a t h e ^ u m b e r o f p o s s i l {<%-mixing s i t e s . T h e d e r i v a t i v e <.{ e q u a t i o n  tRT 2  E  E  I «i = l i 3 = ii v /k-l  aRT  E  k  k  E  ' " '  E  ii = l is = ii  ip =  (  (  t V  is t h e i n t e r a c t i o n  R t h e i d e a l gas c o n s t a n t  (21)  w i t h jrespec t^ ;o t i m e i s :  q]l xi-(p--)I[ x^  «P  E  x'p=:'p_1  ip  3  1=1  ;=1  JJ  ••••«> ip-i  \  <?E  n  h=l  k=i k^h  V  dr  (22)  ( p - i ) E  k=l \k^h  h=l  i  J  J  J  B y s u b s t i t u t i n g t h e d e f i n i t i o n o f m o l e f r a c t i o n ( e q u a t i o n 15) i n t h e a b o v e e q u a t i o n , t h e d e r i v a t i v e o f t h e a c t i v i t y coefficient w i t h respect t o t i m e c a n be w r i t t e n i n t e r m s o f t h e n u m b e r o f moles o f each solid solution  endmember.  D a t a exists f o r m a n y  solid solution minerals,  b u t generally  only for binary or pseudo-binary  s e c t i o n s . F o r t h e p u r p o s e s o f c l a r i t y , s i m p l i c i t y a n d b e c a u s e o f t h e r e s t r i c t e d d a t a , e q u a t i o n (22) be w r i t t e n i n t e r m s o f a t h i r d degree p o l y n o m i a l , b i n a r y solid s o l u t i o n ( a s y m m e t r i c b i n a r y using the terminology  of Thompson).  S u b s t i t u t i n g e q u a t i o n (15)  i n t o e q u a t i o n (22)  will  solution  and restricting  t h e result t o a t h i r d degree b i n a r y s o l u t i o n , yields:  d ln7i dr  1  aRT 2 XjX2 + aRT XjX2 aRT  W1122XLxl  + Wl22X2(X2  - Xx)  W1122X2(l  - 3X X ) -  W1122X2{1  - 3Xi) - Wi222X2{l 19  W1222X2{1  - 3Xi.) - 3X X )  d l n ni dr d l n n2  (23)  The equation for the second endmember in a binary solid solution is identical in form, all subscripts "1" are replaced by "2" and all subscripts "2" are replaced by "1". The derivative of temperature with respect to time in equation (23) is known either as a boundary condition or calculated using the heat equation. The interaction parameters in equation (23) are independent of temperature, pressure and composition. Interaction parameters which vary as a function of temperature and pressure could be included in the above development; the resulting equation is more complex. If the strings " i " and "3 — i" are substituted for the subscripts "1" and "2", and the string  k" is appended  to all subscripts, then the notation used in equation (23) would be consistent with the notation used throughout the rest this thesis. Equation (23) can be substituted for the derivative of the activity coefficient of solid solution phases in the derivative of the mass action equation, equation (17), thus restricting all solids to be either stoichiometric or binary solid solution phases. This restriction could, of course, be removed by the substitution of equation (22) rather than equation (23) into equation (17) but insufficient data exists to make this a useful substitution. T h e A c t i v i t y Coefficient o f Aqueous  Species  The derivative of the mass action equation (equation 17) has introduced the derivative of the activity coefficient of each aqueous species as another set of unknown variables.  By taking the derivative  of an equation which relates the activity coefficient to molality of the species, the derivative of the activity coefficient can be removed from equation (17), thus decreasing the number of unknowns. Helgeson et al. (1981) proposed that for a given temperature and pressure, the activity coefficient of the s'th neutral aqueous species could be approximated by: 7* = 1-0  (24)  and the activity coefficient of the s'th charged aqueous species could be approximated by the following modification of the Debye-Huckel equation. -AZ yA 2  log79 =  '—-= + 1 +  r + (uj  b i  ab9  N<lC  +b  N  a  +  c  l  -  -  0.19(abs(Zs) - 1)) I  (25)  a Bvl 9  I is the true ionic strength of the solution and is defined later below. A and B are Debye-Huckel equation electrostatic parameters and are defined below.  ui  abs  is the absolute Born coefficient for the  s'th aqueous species and is defined by equation (A-15) in appendix one. Z is the charge on the s'th s  aqueous species. <zis the effectiv e electrostatic radius of the ith aqueous species. 6jv«C(and  b +ciNa  are the solvation parameter and the short range interaction parameter for NaCl, respectively. They 20  Table I: Solvation Parameter for NaCl  N a G l  " 2.30ZRT  where E is an entry in the table below, R is the gas constant, and T is the temperature in degrees kelvins. The values in the table have been taken from Helgeson et al., (1981). Pressure is in kilobars, the temperature is in degrees C. Sat refers to the pressure at that temperature along the critical curve of water. Parentheses indicate high uncertainty. Values have been multiplied by 103. Units are Kg/mole. Pressure T 25 50 75 100 125 150 175 200 225 250 275 300 325 350 375 400 425 450 475 500  Sat 2.47 2.15 1.79 1.39 0.93 0.41 -0.18 -0.85 -1.64 -2.57 -3.71 -5.21 -7.32  1 (2.58) (2.28) (1.95) 1.58 1.18 0.73 0.25 -0.28 -0.86 -1.50 -2.20 -2.99 -3.88 -4.91 -6.11 -7.56 -9.31 -11.43 -14.01 -17.12  2 (2.66) (2.37) (2.06) 1.72 1.35 0.95 0.51 0.04 -0.46 -1.00 -1.57 -2.19 -2.85 -3.58 -4.38 -5.26 -6.24 -7.34 -8.56 -9.88  3 (2.72) (2.45) (2.15) 1.83 1.48 1.11 0.72 0.29 -0.15 -0.63 -1.13 -1.67 -2.24 -2.86 -3.52 -4.24 -5.03 -5.87 -6.78 -7.73  4 (2.77) (2.51) (2.22) 1.91 1.58 1.23 0.86 0.47 0.05 -0.38 -0.84 -1.33 -1.85 -2.40 -2.99 -3.63 -4.32 -5.06 -5.84 -6.63  5 (2.82) (2.56) (2.28) (1.99) (1.67) (1.33) (0.98) (0.60) (0.21) (-0.20) (-0.63) (-1.09) (-1.58) (-2.10) (-2.65) (-3.25) (-3.85) (-4.57) (-5.28) (-6.00)  are used as approximations for the solvation and interaction parameters of the s'th aqueous species and are both functions of pressure and temperature. Data for both have been taken from Helgeson et al. (1981) and are given in tables I and II, respectively. T represents the mole fraction to molality conversion factor and is defined by:  T = - log ( 1 + 0.0180153 ] T m 8=2  log (l + 0.01801531)  g  (26)  As suggested by Helgeson et al. (1981), the ionic strength has been substituted for the sum of the molalities of all the aqueous species to yield equation (26). A, the Debye-Huckel electrostatic 21  T a b l e EE: S h o r t R a n g e i n t e r a c t i o n P a r a m e t e r f o r N a C l  Taken from Helgeson et al., (1981). Pressure is given in kilobars, temperature is given in degrees C. Parentheses indicate high uncertainty. All values have been multiplied by 103. Units are Kg/mole 2 . Pressure T 25 50 75 100 125 150 175 200 225 250 275 300 325 350 375 400 425 450 475 500  '  Sat -9.77 -5.59 -2.43 0.23 2.44 4.51 6.38 8.11 9.73 11.29 12.71 14.15 15.49  1 -9.19 (-5.07) (-2.63) -0.07 1.71 4.13 5.91 7.48 9.27 10.80 .12.24 13.68 15.16 16.48 17.80 19.12 20.33 21.55 22.86 24.03  2  3  4  5  -9.12 (-5.52) (-2.65) -0.10 1.85 4.12 5.88 7.66 9.20 10.73 12.19 13.66 15.10 16.42 17.79 19.11 20.35 21.61 22.84 23.95  9.51 (-5.60) (-2.46) 0.13 2.14 4.28 6.16 8.18 9.59 11.15 12.62 13.99 15.41 16.76 18.10 19.40 20.66 21.85 23.09 24.32  -10.44 (-5.66) (-2.15) 0.71 3.05 5.13 7.05 9.05 10.40 11.92 13.39 14.83 16.23 17.52 18.81 20.13 21.38 22.56 23.74 24.94  (-11.76) (-5.87) (-1.68) (1.39) (4.21) (6.26) (8.13) (10.30) (11.58) (13.15) (14.54) (16.01) (17.36) (18.68) (19.88) (21.23) (22.38) (23.64) (24.78) (25.95)  parameter, is defined by:  A = 1.824829238 x 10  6  V  ^ -  pw and ew represent the density and dielectric constant of pure water.  (27)  B is the Debye-Huckel  electrostatic parameter and is defined by:  B = 50.29158649 x 10 ^ZJL 8  (28)  The development of the above equations have been discussed in detail by Helgeson and Kirkham (1974b), Helgeson and Kirkham (1976) and Helgeson et al. (1981).  22  The derivative of equation (25) with respect to time can be written as:  -0.5Z?A  d log 7.^ dr  (l + «  0 . 1 9 ( | Z , | - 1) ~ n  -Z^AVl  (dAdP  (l + a,flvf) \ + K  0.0180153 o w >  ' „^  a n i g o f l  2.303(1 +0.01801531]  Bvf) vf 2  8 J  .  .-.  „ ~o .  d  ab» (dbttaCidP ( - ^ r - —  Pd  W< +  +<  dl  bciNa+c  dAdT' T  +  d  T  d  T  , dbNaCidT\ + ^ Y ~ a 7 j  -fdbNa+Ci-dP s/>  a 7  i +  dbNa+Ci-8T sr a7'  ( 2 9 )  The derivatives of pressure and temperature with respect to time are boundary conditions or are known from the flow and heat laws.  The derivative of ionic strength is discussed below. The  derivatives of the solvation parameter and the short range interaction parameter of NaCl with respect to time can be evaluated numerically using tables I and II, respectively. The derivative of the Debye-Huckel electrostatic parameter with respect to time is:  dA _ (1.824829238 x 10° \ 8pw dr~ ~ \  2Pw(ewT)^  dT  / 3 x 1.824829238 x 10 6 \ /  ) ~dr~ + {  2(ewT)™  ) \ £w^r~  +  dew\ ~d7)  T  ™]  [  and the derivative of the Debye-Huckel electrostatic radius parameter with respect to time is:  dB dr  (50.29158649 dpw V 2 V ^ ^ x T 10 J s \ dr '  *  ^  „ 2{e / wT) 15 \ (' \J + 50.29158649 x 10 ./ P  8  w  J \ \ /W drdT e  +  , , drdew\ j — ^ ) (31)  The derivative of the density of pure water with respect to time can be expanded to yield:  dr Vw, aw and  V° dr  +  Vw dr  (  '  are the molar volume, thermal expansion at constant pressure and isothermal  contraction at constant temperature for pure water evaluated at the temperature and pressure of interest. The derivative of the dielectric constant of water with respect to time can be obtained by taking the derivative of equation (A-15), appendix one and is: 4  ^  =E i=Q  ei.j  4 >  E  4  - /I-*-) "I  +  E «=o  j=o  are fit coefficients given in table LX in the appendix.  4  t  E  <^f>J£  3=0  An alternative representation can be  obtained by taking the derivative of equation (A-16), appendix one, yielding: 23  All fit parameters for the preceeding equations are given in tables IX and X, appendix one. For reasons given in this appendix, equation (33) is preferred over the preceding one. Equations (30), (31), (32) and (33) can be substituted into equation (29) to obtain the total derivative of the activity coefficient with respect to time. The Ionic Strength equation The derivative with respect to time of the activity coefficient of an aqueous species has introduced a new term, the derivative of the true ionic strength. The true ionic strength of an aqueous solution was defined by Helgeson (1969) as: nn I = ; E ^ 1  1=1  m  «  ( ) 3 4  where Z and m„ are the charge and the molality of the s'th aqueous species, respectively. The s  derivative of the ionic strength equation with respect to time is obtained by taking the derivative of this equation. It is: 31 1 -^-y „ 9 ^-=-> £am,  d ln m „  s  , „ (35)  s= l  The derivative of ionic strength with respect to time can be replaced in all equations containing it by the right-hand side of equation (35). Although this replacement decreases the number of unknown variables by one, a more efficient numerical algorithm can be used if it is not made. This is discussed in detail below.  24  The Derivative of the Activity of Water In addition to temperature and pressure, the activity of pure water is dependent upon the number of moles of dissolved material. Many different models have been suggested to directly calculate the activity of water as a function of solute concentration (for example: Harvie and Weare, 1980) or indirectly as a function of the osmotic coefficient (for example: Helgeson et al., 1981). An alternative method of calculating the activity of water is through the use of the Gibbs-Duhem equation which relates the derivatives of the intensive variables for a given phase.  Writing these derivatives as  temporal derivatives yields: T 8T ndP din a, 0 = -Vt— + Sf— + RT Ly VJ - r - OT dr — or  36  8=1  The volume (V) and entropy (S) have been subscripted / to indicate that they apply only to the fluid. The last term on the right-hand side can be separated into the activity of water and the activity of all other species in solution, yielding:  + R T Y ^ a - ^ + RTnw a-^ ^ 55.51 dr dr 8=2 Rearranging equation (37) with this in mind yields: d ln a,„ Vt dT - = 3r RTnw 3r  Si dP RTnw 3r  + R T Y ^ a - ^ ± ^ 55.51 dr  1 v-* 3 ln m, > ms 55.51 ^ dr 8=2  (37) '  y  8=2  1 > 55.51 ^  9=2  ms  Sin 7 , — dr  y  (38) '  The derivative of the activity coefficient of the aqueous species has been left in this equation only for reasons of clarity as it can "be replaced using equation (29). The derivative of the parameters which are introduced by this replacement are then replaced by equations (30), (31), (32) and (33). The derivative of temperature and pressure with respect to time are known or have been solved using the flow and heat equations. Equation (38) could be substituted into all equations containing the derivative of the activity of water but has not been done in order to allow a more efficient numerical algorithm.  25  Derivative of the Number of Moles of the Reactant Minerals The derivative of the number of moles of reactant minerals taken with respect to time was introduced in equation (6), the derivative of the mass balance equation with respect to time. Because reactant minerals are those with which the solution is undersaturated, they will dissolve into the solution, potentially changing the molality of the aqueous species and/or potentially causing the precipation/dissolution of equilibrium phases. This driving force continues until the solution is saturated with respect to all of the reactant phases or until all reactant phases have totally dissolved into the solution. Helgeson proposed monitoring the progress of the system towards equilibrium through the use of the progress variable (£), a convention generally followed in the literature. When the derivative of the number of moles of all solid phases and the molality of all aqueous species with respect to the progress variable is zero, then the system is at equilibrium for an isothermal isobaric process. Under these conditions, the derivative of the Helmholtz and Gibbs free energy with respect to the progress variable must be zero. If the derivative of the number of moles of a reactant taken with respect to time is expanded to include the progress variable, then the following expression is obtained. dn  r  d n d£  .  r  lh l>J[~dT~ =  '  y39  where n is the number of moles of the r'th reactant phase. The derivative of the progress variable r  taken with respect to time is the reaction kinetic term and controls the rate of the dissolution of each of the reaction minerals. With the exception of Aagaard and Helgeson (1982), Helgeson and Murphy (1983) and Helgeson, Murphy and Aagaard (1984), previous papers discussing the derivative approach have considered the derivative of the progress variable with respect to time to be a constant or have ignored it. Aagaard and Helgeson have derived a rate equation which is dependent on the effective surface area and the chemical affinity between the reactant phase and the fluid. This equation allows the derivative of the progress variable with respect to time to be evaluated, it is:  dr k is the rate constant, s is the effective surface area, a is the activity of the s'th aqueous species, s  is the stoichiometric reaction coefficient of the s'th aqueous species corresponding to the formation of the critical activated complex, a is the rate of decomposition of the activated complex and A is 26  the chemical affinity of the mineral reaction. This equation was initially applicable under isothermal isobaric conditions and in the temperature range 25—200  C along the critical curve of water. The  parameters in this equation have been re-evaluated by Helgeson and Murphy (1983) and Helgeson, Murphy and Aagaard (1984) and extended to temperatures in the range of 650 C. Equation (40) has been explicitly derived for iso-thermal, iso-baric conditions and is only one term of a more complete expansion, which could have the form:  dti_dP_  d£_5T +  dT d 7  +  dP ~d7  +  d£ 57  Although the derivatives of the progress variable with respect to temperature and pressure can be assumed to be zero, the possibility that they exist and are not zero precludes the rigorous use of equation (40) in open systems. If the changes in temperature and pressures are small with respect to time, then it can be used.  Summary Substituting equations (8) and (40) into the derivative of the general mass balance equation (equation (6)) yields an equation consistent with assumptions that the component is a radioactive parent, mass flux potentially occurs from/to the neighboring volume elements and the modified model of Aagaard and Helgeson is used to constrain the reaction rate. The left-hand side of this equation includes equation (9) instead of equation (8) if the component is a radiogenic daughter product. This equation is simplified if no mass flux occurs or if the component is not radiogenic or radioactive. Substituting equations (19), (23) and (29) into the derivative of the general mass action equation with respect to time (equation (17)) yields an equation consistent with the model of Helgeson et al. (1981) for activity coefficients of aqueous species, of Berman and Brown (1984) for a third degree binary solid solution phase and the Gibbs-Duhem equation for the activity of water. Two additional equations have been developed in this chapter, the derivative of the activity of water with respect to time (equation (38)) and the derivative of the ionic strength (equation (35)). These equations can be solved using matrix algebra, yielding the first derivatives of molalities of aqueous species, of the activity and number of moles of water and of the number of moles of all solid phases in the system. Equations similar to these allow higher order derivatives to be solved in an analogous fashion. Once all of the derivatives are known, an expansion in molality for aqueous species, in number of moles for water and for solid phases and in activity for water can be used to 27  calculate the distribution of mass among the species and solids at future times. The next chapter discusses in more detail the techniques used to solve these equations.  28  6. S o l u t i o n of the M a s s , Ionic S t r e n g t h  and Activity  Derivatives  The derivative of each of the mass balance equations (one for each component), the derivative of each of the mass action equations (one for each non-component phase and species), the derivative of the ionic strength equation and the derivative of the activity of water equation form a set of equations which contain the following derivatives: drip dr  dn '  da  w  dr  '  dm  w  dr  '  dr  dP  31  s  '  dr  '  9T  dT '  dr  Subscripted variables indicate that there is one derivative for each possible value of the subscript—s has been used for aqueous species, p for solid phases and c for components. The derivative of pressure, the derivative of temperature and the derivative of the total number of moles of a component with respect to time for each volume element cannot be solved using the equations presented in the previous chapters, they must be solved using the flow, solute transport and heat equations which are discussed in the following chapters. The flow, heat and solute transport equations are not independent of the variables listed above, as explained in chapter 10, a coupled solution procedure is necessary. Once the pressure, temperature and total number of moles of component derivatives are known, the derivatives of the mass action equation, of the mass balance equation, of the ionic strength equation and of the activity of water equation form a set of equations which are linear with respect to the last six derivatives listed above. These derivatives can be solved using standard matrix techniques. At this point, it is worth rewriting the derivatives of the mass action, mass balance, ionic strength and activity of water equations in order to illustrate a method of solution. All substitutions discussed in chapters 4 and 5 will be made, but rather than write the equations in full, the symbols A, B, C, D, ... will be used to represent various terms. These symbols are expanded in table III. The equations are listed in figure 1, in order they are: • the derivative of the mass balance equations, • the derivative of the ionic strength equation, • derivative of the activity of water equation, • the derivative of the mass action equations.  29  Figure 1 - Tabular Forms of the Constraining  Chemical  Equations  N II  s  K  £ to  £  a to  to  II  'to|<o  %  'to I to ''to|to  en*  to |co °*  J5 ^ to o  +  + = 1A|«  —  Note 1: Although it was not done in the text, the first three equations have had the sums of the log molalities of the species separated into component and non-component terms. Note 2: The above equations are the general forms of the equations constraining the first derivatives when the symbols A, B, . . . are expanded as given in table III. The expansions given are not totally complete, some substitution from the text is necessary. Note 3: Although it was not done in the text, all logarithm and logarithmic derivatives to the base 10 have been converted to base e. 30  Table HI: Expansion of Symbols in Figure 1  55.51 ^  A  8=1  ar  ^  ar  r=l  Zfm, 2 1 55.51 J = 2.303m,  -°- ^1 5  (l + a.vf)  Vf  0.19(abs(X)-l)-  °-°  1 8  °  1 5 3  2.303(1 + 0.0180153)  + w"''" fc^aCI + #JVa+ Cl-  K = M - 2.303 ^ > / m  8  8=2  M =  V  ar  RTnw  dr  Z aVI 2  =  (i + . f l v f | a  s'  ap  R.Tn,,, dr fdAdP  dAdT\  37 +  Z;AVl  a7j - (  (dBdP  dB dT  f ) l a p a7 a r a7 +  1 + f l s j B v  •" V 3 P ar dT r(dha+ct3P dbNa+clV ap ar ar ^8  31  dr) dT\ ar y  Table D3: Continued, . . .  <2 R  ?_J_ m„ J_  S •T fc-i fc  » - a f E E i =l 1  -  £  . £ ( ( 1 1  h> *v-i  h=l  =  * ) / £ * . .  V fc = l  u  y =  w  h—H  -X aRT E  E  •  E  '1 = 1 «2 = »'l  *p  —  ^ w „ - ( »,i —  P  - i ) E  ( n )  ;,.=i \ fc=i k=h.  1  X W  y--  E t=i  AH d T  AV  r  z =  ^ k-1  +  „ NGej< ^  8P  r  *RT  2  E  k  E  ^i'i = l t2=*i  (  k  ••• E  >.<*.-<,  g  n  P  Xi, - (  P  -1) n  Xi,  1=1  i =i —± v  ,  w  v  32  dT ~d7  These equations can be directly solved using matrix algebra techniques such as direct inversion or gaussian elimination. The computational time needed to solve a set of linear equations by matrix inversion is approximately proportional to the cube of the number of unknowns while the time needed for gaussian elimination increases as a function of the square of the number of unknowns. The time needed these techniques and more many others are well documented in a wide variety of texts. In most aqueous systems, the number of aqueous species is large relative to the number of components, thus there are a large number of derivatives of the mass balance equations. Examination of the equations in figure 1 reveals that if the derivative of number of moles and the derivative of the molalities of the components, the derivative of ionic strength and the derivative of the activity of water are positioned in the first nc + 2 columns, the lower right corner of the matrix bounded by the nc + 2 column and row, is an identity matrix. In iso-thermal iso-baric mass tranfer and Perkins (1980) recognized the presence of this identity matrix and solved the set of equations by a partitioning method. This particular method is outlined in figure 2 and is very efficient when the rank of the identity matrix is a significant portion of the rank of the entire matrix. The identity matrix will exist only when the ionic strength and the activity of water are treated as separate variables. If they are not, the equations containing derivatives of the ionic strength and the activity of water must be substituted into the derivative of the mass action equation. Each mass action equation will contain the derivative of the logarithmic molalities of each of the aqueous species, and no identity matrix would exist in the lower right hand corner of the matrix. The solution of this set of equations would take considerable computer time as the coefficient matrix is not sparse. If computer storage is limited, it may  be necessary to reduce the number of equations and  unknowns. Because the derivative of each of the non-component species is written only in terms of the derivatives of the components, ionic strength and activity of water, it can be substituted for each occurrence of the derivative of that species in the derivative of ionic strength, the derivative of the activity of water and the derivative of the mass balance equations. This reduces the number of equations to the number of components plus two. The derivatives of the non-component species can be calculated directly from the derivative of the mass action equations once the derivative of the component phases and species, ionic strength and water are known. Alternatively, the molalities of the non-component species can be directly calculated once the molality of the component species, the ionic strength, the activity of water and the number of moles of the component phases are known. If both methods are used, comparison allows a direct assessment of the numerical roundoff error. 33  F i g u r e 2 - M e t h o d of S o l u t i o n  For any linear system of equations which can be written in the form  the solution can be obtained by: [B] = [C][A]-  1  .  [A] is a square non-singular matrix of known coefficients, [B] is the unknown column vector and [C] is a vector containing the constant terms. Direct inversion of matrix [A] is slow but the procedure can be speeded up considerably if [A] is divided into partitions such that the lower right partition is an identity matrix. If [A] is partitioned and contains an identity matrix, the following method can be used to calculate the inverse.  If partition d is an identity matrix, then: q — (a — be)  1  w = — bq x = qc y  = I — cw  and I = the identity matrix This proceedure is correct only when partition d is an identity matrix. The advantage is that the only matrix which must be inverted has the dimensions of partition a. When its rank is small compared to the rank of matrix [A], this method is extremely fast. If only one set of equations is to be solved, elimination is generally much faster. However, if the equations can be written such that matrix [A] is independent of the number of derivatives which will be solved for, only one inversion is needed. This makes this method a very practical alternative to elimination.  34  The solution by partitioning method has one major advantage over a solution by a direct inversion or elimination—speed.  All methods have similar numerical roundoff error. The speed  of solution for the collapsed set of equations is similiar to the speed of solution of the partitioned matrix but requires slightly more time to set up. The solution of the collapsed equations has the advantage of decreased storage space but the disadvantage of slightly greater numerical roundoff error, ff the matrix is collapsed, the non-component species must be calculated from the component species. With the partitioned matrix method, the derivatives of the non-component species are part of the solution vector and can be directly compared with those calculated from the components, allowing a direct assessment of the numerical error.  35  7. The Flow equation  Following Cooper's (1966) development (equation 15, page 4787), the generalized transient flow equation of a compressible fluid in a hetrogeneous porous medium can be written in fixed Cartesian coordinates as: n / >. „ dPf -V(pf9)=04 L+Pf~or  dB or  „ d v r, + Pf01T az  . (41)  P/ is the fluid density, q is the specific discharge vector with components in each of the Cartesian coordinates. 9 is the porosity of the medium, vg is the grain velocity. V is the del operator. Equation (41) assumes that any deformation must be in a vertical direction, thus is restricted in applicability. The Temporal Terms Assuming that the grain velocity is negligible, the last term on the right-hand side of equation (41) can be ignored. The remaining terms on the right-hand side of equation (41) can be expanded in terms of the properties of the media and the fluid. Consider first the porosity, which is defined as: ym  V el is the volume of the element, V m is the volume of the solids ( V m = ^  n  +  r  > ^»')- Inherent  n  in the use of equation (42) to define the porosity are the assumptions that only one fluid is present, that all of the grain surfaces are completely wetted, and that all pores are connected. This is most closely approximated in sandstones and other unsolidated sediments. The derivative of the porosity with respect to time is:  dd _  v  dv  37 ~ (V 'f  ~dr  m  e  el  i dv  m  'V 71  dr  _ e dv  el  V el  dr  _ I Y 71  dv dr  m  ^  The volume of an element is constant in fixed coordinates, therefore the first term of the right-hand side of equation (43) is zero. The total volume of the matrix is a function of temperature-, pressure and the number of moles of each of the solid phases. The number of moles of each solid phase can change as a result of dissolution, precipitation or by the physical movement of solid material into the volume element. Rewriting equation (43) with these processes in mind, assuming as before that 36  the grain velocity is negligible, yields: d dr  yd  \ i g V  1=1  T  + i gp n  g  v  T  VidT\  jT"dr~) + n  dV dT r  T  (44)  Vj and V are the molar volume of the i'th equilibrium phase and of the r'th reaction phase, r  respectively, ra, and n are the number of moles of the i'th equilibrium phase and of the r'th reactant r  phase, respectively. In order to simplify the notation, the equilibrium phases have been treated as stoichiometric phases. To include solid solution phases, each summation of the number of phases must be expanded to include an inner summation over the number of endmembers of each phase. The derivative of the number of moles of reactant minerals taken with respect to time is known, is an applied boundary condition or can be calculated. The derivatives of the number of moles of each of the equilibrium phases are solved using the equations presented in the previous chapters. The assumption of constant volume for each element coupled with a grain velocity of zero implies an incompressible media, not incompressible phases. Experimental evidence and field observation indicate that porous media is compressible and that porosity is hysteretic with respect to pressure. The available data describing the compressibility of porous media are for shallow  environments,  little or no data are available for deep basins or any other geological environment. Undoubtedly, porous media display a similar hysteretic effect with respect to temperature but no evidence or observations exist. The assumption of a constant volume element does not imply the porosity is constant. As is obvious from equation (44), the porosity will change as a function of temperature and pressure through the changes in the molar volume and the number of moles of each of the solid phases. If the assumption of a constant volume and/or a grain velocity of zero is removed, then the shape and/or size of the volume element may change in response to a stress field. The thermodynamic properties of the phases in the volume element will also change in response to the stress field. If new phases form by diffusion of material into existing phases or by a direct solid-solid transformation, it is not clear what the effects of the stress field would be, or indeed, the effects of the stress field on the reaction. In any natural medium, the use of a non-hydrostatic model for the solid phases would necessitate knowledge or assumptions on the average  grain orientation and size of each solid  phase, on the nature of the porosity and permeability and how a stress field will modify them. As new phases precipitate, they would form in a hydrostatic environment and as the supporting matrix 37  dissolves or the stress field changes, they could be rotated and their thermodynamic properties changed. Although the effects of non-hydrostatic stress on phases could potentially be very important, it is very difficult to evaluate the effects of a changing stress field. Bruton and Helgeson (1983) examined the thermodynamic implications of a static stress field and the consequences when fluid pressure was not equal to rock pressure. They concluded • that the effect of a stress field was small when compared to the absolute magnitude of thermodynamic energies under hydrostatic conditions, • that the difference between fluid and rock pressure could significantly affect the interpretation of the pressure temperature depth history of solid assemblages and fluids, • that this effect could be safely ignored when the pressure difference between rock and fluid pressure was less than fifty bars. Contrary to the first conclusion of Bruton and Helgeson, it is clear from a great variety of geological observations that stress related phenomenon do exist and that stress can be a significant modifier of phase relationships under many different geological conditions. The inclusion of the effects of a non-hydrostatic pressure field in a general sense is currently impossible. For very limited and specific cases, it is possible to calculate the order of the effect by setting a rock pressure different than the fluid pressure or by using very specific phenomenological relationships. Density is a function of the molar volume and the number of moles of each species in the fluid. It can be defined as: n3  PI = ^  (45) £ !<=i  MW  S  v  >> n  is the molecular weight of the s'th species, n» is the number of moles of the s'th species and  V„ is the partial molar volume of the s'th species (including solvent water). Equations defining the molar volume of water and the molar volume of aqueous species are given in appendix one. Equation (45) assumes that the volume of a solution can be represented by a weighted combination of the partial molal volumes of the species present in the fluid. In dilute solutions, this assumption is quite good; in concentrated solutions, it is not very accurate. Rewriting equation (45) in terms of molalities through the use of equation (4), and taking its 38  derivative with respect to time yields:  a 9 and /3„ are the coefficients of thermal expansion and isothermal compressibility for the s'th aqueous species, respectively. They can be evaluated through taking the derivative of the volume equations given in appendix one.  The Spatial Terms The spatial derivative of the density and of the specific discharge vector are present in the right-hand side of equation (41). In a similar fashion to the expansion of the derivative of equation (45), the derivative of the density can be expanded, including the effects of each aqueous species on density as a function of position. However, the spatial variation in density is often small compared to its temporal variation, thus in general, it can be ignored. Specific examples when the spatial variation cannot be ignored include the interface between two immiscible fluids such as oil and water or between fluids with vastly different densities like fresh and salt water. The specific discharge is evaluated as a function of the hydraulic head, which can be written as a function of pressure. It is:  rj is the dynamic viscosity of the fluid and k the permeability of the medium. The interial term is generally small except in systems with high fluid velocities. For the remainder of this thesis, it will be assumed to be zero. If the gravity term is moved out of the integral on the right hand side, the integral describes the amount of work involved in moving the fluid from one pressure to another. In principle, this integral can only be evaluated if the complete chemical history, pressure and temperature history over the path of integration is known. In practise, this degree of information is never available. The integral can be simplified by two assumptions: 39  • For the purposes of integration, the fluid can be approximated by pure water with no chemical reactions occurring between the fluid and the matrix. • The integral can be evaluated isothermally at the reference temperature. Other more elaborate integration paths could be conceived and evaluated but there is no advantage to this. Evaluating the integral with these assumptions yields: f  /  AG  W  P  dP  7~  =  1 MW~ (  A G  -^  - AGw.Tr.Fr)  (48)  is the Gibbs free energy of pure water, evaluated at the subscripted pressure and temperature.  In most hydrology texts and papers, a constant, the ideal gas law or simple exponential/polynomial equations are used to represent the density of water. When integrated, these often provide a poor approximation to the right hand side of equation (48). The free energy of water has been measured and tabulated in detail over a wide range of pressure temperature space (for example: Burnham, Holloway and Davis (1969), Keenan, Kyes, Hill and Moore (1978), Haar, Gallagher and Kell(1984)) and many complex fit equations allow easy computer evaluation of the free energy of water (for example, equations A-19, A-20, A-21 in appendix one). Equation (47) introduced a new variable, the dynamic viscosity.  Equations describing the  dynamic visosity of pure water and steam are given by Watson, Basu and Sengers (1980). If the solute concentration is low (less than 1 molar), the extended Jones-Dole equation (Jones and Talley, 1933) can be used to calculate the viscosity ratio between the solution and pure water. Data for some of the common univalent species are given by Out and Los (1980) for a pressure of one atmosphere and temperatures less than 100 C. Formore concen trated solutions which are predominately sodium or potassium chloride brines, the equations given by Kestin, Khalifa and Correia (1981a, 1981b, 1981c, 1981d) can be used in the temperature and pressure range of 20-150  C and 0.1-35 M P a . Systems  which exceed these limits must model the dynamic viscosity of the fluid by using the dynamic viscosity of pure water. In systems where the composition of the fluid and the temperature does not significantly vary, the dynamic viscosity is approximately a constant and its derivative zero.  40  Conclusions Combining equations (44), (46), (47) and (48) with equation (41), and assuming that the kinetic is negigible, allows the flow equation to be written in terms of spatial, temporal, molar, pressure and temperature derivatives.  E  l  ,,orii dm  dVidP  dVidT  dP dr  dT dr  - / „ dn dV dP dV 8T EL V £ [V — + n — — + n yd dT dr dP dr r=l r  r  T  ( I  r)  :»=2  +8  V (  r  \ J  E  r  r  "  n  s=2  E  KMS  ,=2  sr^  I  d  m  »  9=2  \s=2  ns  Y MW> m<> s=2  (49)  where: AG  W  = A G w.Tr.P  AG w.Tr.Pr  In the above equation, the permeability is assumed to vary spatially but not temporally, and canbe considered to be a scalar quantity in each element. Given a model for the relationship between the permeability and the number of moles of solid phases or the porosity, this restriction could be removed. Although various general models for permeability exist, they are, at best, approximations and are not satisfactory for a wide range of conditions or for systems which have significant amounts of precipatation or dissolution of solid phases. Wood and Hewitt (1982) have made a simple observation which allows the precipation and dissolution of solid phases to modify the permeability. Arguing that changes in the permeability will occur relative to changes in the porosity, they proposed the following phenomenological relationship between porosity and permeability in sandstones: LT + A T  flr + A r  This observation is very useful, as most modelling processes assume an initial porosity and an initial permeability. The change in porosity as a function of time can be easily calculated as the changes in 41  temperature, pressure and number of moles of solid phases is known, thus the change in permeability can be approximated. Their relationship can be easily extended to include any model which relates permeability to the volume of solid phases. We could write: k T+AT kT  =  f(T,P,n„nT,... }(T,P,ni:nr,...  ,T+ AT) ,T)  where / is some function which relates temperature, pressure, moles of equilibrium phases, moles of reactant phases,  and time to the permeability. Examples of possible functions would include  any emperical relationship relating permeability to grain size and packing, any relationship based on dimensional considerations or any theoretical relationship which has the general form: k = /i( )f2(n)d', s  where s is dimensionaless parameters that express the effect of grain shapes, n is  a parameter that expresses the effect of porosity and d is the effect diameter of the grains (Bear, 1972). This function will not be used to calculate the permeability, rather it will be used to calculate the change in permeability as a function of various system parmeters. For this reason, it does not need to be very accurate. Equation (49) contains the spatial derivative of the Gibbs free energy. Rather than solve this as a new derivative, the spatial derivative of the Gibbs free energy of water can be expanded in terms of the derivatives of pressure and temperature, yielding: d oxi  VwTrP  V  . n > dAGw,Tr.pdP , Tr.P ~ &<^w.Tr.Pr) = ^ ~ ~~ 1 dP dx{ = Vw.Tr.P(l7a) ^  dAGw,Tr.pdT ^ "= dT dxi (50)  is the volume of water evaluated at the reference temperature and at the pressure. The free  energy of water at the reference temperature and reference pressure is fixed thus its derivative with respect to position is zero. Because of the assumption used in the integration of equation (48), the derivative of temperature with respect to position must be zero, even if the process being modelled is not isothermal in time or space. Equation (50) is substituted into equation (49) to complete the flow equation. If a more elaborate path was used in the integration of equation (47), then the left hand side of the flow equation could potentially include the derivatives of temperature and fluid composition in addition to the derivative of pressure.  42  8. T h e Solute T r a n s p o r t  Equation  The solute transport equation has been developed and used as a predictive tool by many different authors (for example: Reddell and Sunada (1970), Bear (1972), Bredehoeft and Pinder (1973), Konikow and Grove (1977)). In general, it has the form: (51) when written in Cartesian tensor notation. V{ is the component of the average interstitial velocity of the fluid in the I'th direction, Z?,-.y is the coefficient of mechanical dispersion (a second order tensor) C is the concentration of the chemical species in the fluid and 6 is the porosity. R is the reaction term. Each of the authors previously mentioned imply or explicitly state that this equation describes the behavior of only a single species in the fluid and that there must be an additional equation for each new species considered. In modelling the movement of one or two aqueous species, this is not restrictive. Many geochemical problems involve tens of aqueous species, clearly the computational time needed if a transport equation is used for each species is excessive. In fairness, it should be pointed out that the concentration of one aqueous species for a given element may dominate the concentration of all other aqueous species containing that element by orders of magnitude. Thus in modelling the movement of an element in a flow field, the concentration of the dominant ion will be the effective concentration. Unfortunately, in determining the reactions between the species and complexes in the fluid and the reactions between the fluid and the surrounding media, the effects of all aqueous species and complexes must be considered. As discussed in the chapter on components, the number of independent variables needed to constrain all of the chemical species and phases in the system is the number of components and not the number of species and phases,ffthe number of moles of each component, the temperature and the pressure are known, then the number of moles of all species, complexes and phases can be calculated. Knowing this, the solute transport equation can be written in terms of components, thus simplifying the analysis of a chemical system and reducing the number of mass transport equations to the number of components from the number of aqueous species. 43  The change in the number of moles of any component with respect to time is a function of only three processes: • Mass flux of the component into/out of the R E V due to advection, diffusion or dispersion, • Radioactive and radiogenic decay creating or destroyiny the component, • Physical removal or addition of the component by a source or sink. Expressing this list as an equation, yields: net flux of component C  =  rate of accumulation of component C  —  rate of change due to source/sink terms  —  change due to radioactive decay  (52)  The radioactive decay term is negative for a daughter component and positive for the parent. The source term is positive for material being removed (sink) and negative for material being added (source). Equation (52) has no reaction term because chemical reactions do not destroy components, they redistribute them among the phases and species in the system. Consider the mole flux term of the above equation. The flux of the c'th component parallel to the x axis through the center plane of an R E V can be defined as: Nf,cv*JAyAz  .  (53)  Nf-C is the number of moles of the c'th component in a unit volume of the fluid, v* is the instantaneous mass velocity of the fluid parallel to the x axis. 6 is the porosity and Ay Az represents the effective cross-sectional area through which flow occurs. The mole flux of the c'th component into the R E V parallel to the x axis from the left can then be written: Nf.cv*xe  Ay Ax-  Q AX — (Nf,cv*xe Ay Az) —  OX  L  (54)  and the mole flux out of the R E V to the right is: 3 Nj.cvie Ay Ax + — (Nf.cv*xe ox  Ax Ay Az) — I  (54)  4 r is the distance along the x axis from the edge to the center of the REV. Expressions similar to equations (54) and (55) can be written for flow parallel to the y and z axis. Summing them for flow parallel to all axis yields: 3 -^-(Nf.cv*xAyAz) dx  3 Ax - — (Nf.cv* AxAz) y ay  44  3 Ay - — (Nf.cv*z Ax Ay) Az dz  or using an implicit summation and assuming that the volume of the R E V is constant, ~—(Nf.cv*d)  AxAy  Az  (56)  Equation (56) does not take into account the increase of a component by the movement of solid material into the REV. In developing the flow equation, it was assumed that the grain velocity was small (zero) and this process could be ignored. The mole flux term, equation (56), is written in terms of the number of moles of component in the fluid and not the total number of moles of component. Thus, the first term on the right-hand side of equation (52) must also be expressed in terms of the number of moles of the c'th component in a unit volume of the fluid. Considering that an REV contains only a single fluid and solid phases, the total number of moles of the c'th component can be expressed in terms of the number of moles of the fluid species and in the solid phases in the matrix as: NT.C  Nf.c and Nm,c  AxAyAz  = ~Nf.e AxAyAzd  + Nm,c  AxAyAz{l  - 6)  (57)  are the number of moles of the c'th component in a unit volume of the fluid (/) and  of the matrix (m), respectively. Ax Ay Az represents the volume of the R E V . Assuming as before that the volume of the REV is constant, the derivative of equation (57) with respect to time is: A x A  2  / A  Z  dr  AxAyAz  ^ =  ((Nj.^Nm.c) d/ \  or  +  or  + (l - 9 ) 3 - ^ ) ar j  (58)  The change in the total number of moles of the c'th component is a function not only of the change in the number of moles of the c'th component in the fluid but includes the changes in the number of moles of the c'th component in the solid phases and the change in the porosity. The total number of moles of the c'th component in a unit volume is related to the total number of moles of the c'th component and to the total number of moles of the c'th component in the phases and species comprising the R E V by:  AxAyAz ^ =  / ns  AxAyAz *  nr + £  V=l  r= i  np ei ^  + £  E  i=l Jc=l  \ ^  ^  J  (  5 9  )  /  The last expression on the right-hand side of equation (59) is effectively the mass balance equation for the c'th component divided by the volume of the REV. This equation was defined in chapter 4. 45  The total number of moles of the c'th component in a unit volume of fluid is related to the total number of moles of the c'th component in the REV and the total number of moles of the c'th component in the aqueous species present in the fluid in the REV by: Nj.c AxAyAz £^c. «i ^ 3  55.519AxAyAz  (60)  8  The total number of moles of the c'th component in a unit volume of the matrix is related to the total number of moles of the c'th component in the matrix of the REV and the total number of moles of the c'th component in all solid phases comprising the REV by: N3.c  =  N..S.C AxAyAz ^  f nr  np et  (E"-»'+ E E  (l-9)AxAyAz  () 61  Equations (60) and (61) could be substituted into equations (57) and (58) but will not be done in order to simplify the notation. The radioactive term in equation (52) can be written as: AxAyAz  ^  (62)  which represents the total change of the c'th component in the REV as a function of radioactive decay. This term is discussed in more detail in chapter 4. The source/sink term can be written as: AxAyAz  Q{f,NT.c)  (63)  which represents the change of the c'th component in the REV as a function of time and number of moles of the c'th component in the fluid. Equation (63) is positive when representing a source term and negative when representing a sink term. Through the use of equations (56), (58), (62) and (63), equation (52) can be written in a more rigorous sense, yielding: *  x,'  = (Nf, v  - Nm,)  d  or  ±  +  +  9  d  J ^ or  +  (  l-9)  (d~NT.c [rod)  d N  dr  m. c  +Q(t,Nt.°)  ( 64)  As the volume of the element is constant, it can be moved out of the derivatives, and cancels out. The instantaneous mole flux in equation (64) must be expanded in terms of variables currently used to describe the system. As shown by Bear (1972), it can be written in the form: Nf.cv*  = Nf.cv  46  + Nj.cV  (65)  v is the average interstitial velocity of the fluid and v is the average deviation of the velocity from the average interstitial velocity. The average interstitial velocity is defined by: ^ = £  (66)  where q is the specific discharge vector for the fluid. The specific discharge is calculated using equations (47) and (48) in chapter 7. As show by Bear (1972), the average deviation of the velocity from the interstitial velocity can be approximated by:  viN . f  = -D,/-^axj  e  where Dij is the coefficient of mechanical dispersion.  (67)  This term is defined as a function of the  properties of the media and of the fluid velocity by:  Di.j = a v&ij + (a t  a )^-  L  (68)  t  a is the dispersivity of the porous medium, subscripted Y to indicate the transversal dispersivity and subscripted 'L' to indicate the longitudinal dispersivity. 6i. - is the Kronecker delta and v is the }  velocity of the fluid (with components v  v , v ). In cartesian coordinates, equation (68) reduces  xt  y  z  to:  D  = (a {vl  vy  = { t{v  D  = (a (v  xx  D  + v )  a  t  x  2  z  2  2  zz  +a v )' /v  2  t  L  + v) +  a v ) /v  2  x  x  2  L  y  + v ) + av) 2  jv  2  y  L  z  and  D  xy  = D  yx  = (a  L  -  a )v v /v  L  -  a )v v /v  D  xz  = D  = (a  D  yz  = D  = (a  zx  zy  L  t  x  t  x  - a )v v /v t  y  z  y  z  (69)  These equations are limited as they specifically refer to isotropic medium. The coefficients of longitudinal and transversal dispersivity are calculated from field observations or from experimental simulations. In both cases, the composition of the fluid is generally analyzed for the total concentration of an element in solution parallel and perpendicular to the direction of flow. If elemental 47  components are used, the coefficients of longitudinal and transversal dispersivity for the component has been measured and not the coefficient for the s'th species in the fluid. Values for these coefficients are tabulated in the literature and can be used directly in equation (69). Unfortunately, there is often considerable discrepancy for dispersion coefficients determined from experimental and from field values. This is partly a result of large and small scale hetrogeneities in the medium and the intrinsically anisotropic nature of all geological units. In addition, the field values are generally derived by fitting the flow and solute equations to a given set of field data, using boundary and initial conditions which are presumed to apply. Substituting equations (65), (67) and (69) into (64) yields a general form for the solute transport equation written in terms of components. It is:  axi  axi \  axi  J  or + ( l - e ) ^ ^ + or  or d  - ^ or  + Q(t,Nf.c)  (70)  The temporal derivative of porosity should be replaced using equation (44) from the previous chapter. It has not been done in order to simplify the notation. Equation (70), including equations (60) and (61) can be compared directly with equation (51) as they have an identical form. The primary difference between them is that concentration of a species is used in equation (51) and number of moles of a component is used in equation (70). Equation (70) is directly coupled to the flow equation (chapter 7) through the specific discharge vector of the fluid. It is also coupled to the chemical reaction equations developed in chapter 4 through the derivative of the number of moles of the c'th component. As shown in equations (60), (61) and (62), this derivative can be directly related to the derivative of the number of moles of each solid phase and each aqueous species in the REV. Theflowequation is directly coupled to the chemical reaction equations through the derivative of the porosity. Because all of these equations are coupled, they should be solved simultaneously, either directly or by an iterative technique.  48  9. T h e H e a t E q u a t i o n  The energy equation, which describes temperature spatially and temporally can be written for porous media in the form: (6Pf  Cvf+(1-  d)PmCvm)  ^  = A - ( ^ K * ^ ) -  P  f  Cvf q  f  ~ +  Q(R) + Q(f)  (71)  p and Cv are the density and the specific heat at constant volume, respectively, subscripted / to indicate fluid or m to indicate matrix. 6 is the porosity, T the temperature, and r the time. K* is the total thermal dispersion tensor. Q(f) is a heat source/sink term which can be considered to be the result of a point source of fluid of a different temperature than the temperature of the matrix.  Q(R)  is the heat source/sink term which is a result of the chemical reactions and the radioactive  decay occurring in the volume element. Equation (71) assumes that the temperature of the fluid and the temperature of the matrix in a volume element are identical at all times. This implies that the volume element is in total thermal equilibrium and that heat transfer within an R E V is instantaneous. Only fluid systems with low fluid velocities and high porosities approach these criteria, yet Mercer and Pinder (1974) and Sorey (1978), among others, successfully modelled geothermal systems using equations essentially identical to equation (71). Q(f) can be defined by: Q(f) = (pfCvf(T-  Tf))rate  (72)  T is the temperature of the volume element, Ty is the temperature of the incoming fluid. Cvj is the heat capacity at constant volume for the incoming fluid and  rate  is the rate at which the fluid  is entering the volume element. An injection well is a typical example of such a source. Q(R) can be defined by:  oim - V ° s7+ VZ.-^r+ V 2^i^r^7 + V o ^dNe ~ d 7 Q y ) - l ^ - v * + a 7 + 9= 1 i=l r=l c=l AH  9ns  A H i dni  R  AH  A H r d n r  +  Q  c  is the enthalpy of the phase or species, n is the number of moles. Both are subscripted i for the  i'th phase, s for the s'th aqueous species and r for the r'th reactant phase. Qc is the heat produced during the radioactive decay of the c'th component. It is beyond the scope of this presentation to 49  (  7  3  )  rigorously evaluate this term as it depends on parameters such as the nature of the matrix in which the decay occurs. Fortunately, the energy associated with the radioactive decay of most isotopes can be approximated by a temperature independent constant which is in the order of 10 cal/gram/year 3  (plus or minus one order of magnitude). The thermal dispersion tensor can be expanded in terms of the thermal conductivity tensor of the matrix and the fluid, and of the coefficient of thermal dispersion (superscripted m, / and d, respectively). K* = K (l-6)  + K 6 + Kl  m  f  (74)  where yei The total thermal conductivity of the matrix can be approximated by: np K  m  nr  = J 2 i i + Y'' K  n  i=l  K  n  r=l  () 75  K is the thermal conductivity, subscripted i to indicate of the i'th phase and subscripted r to indicate the r'th reactant. The thermal conductivity of most phases is a tensor, but equation (75) tacitly assumes random grain orientation. Thus the thermal conductivity is the bulk thermal conductivity. Equation (75) is only an approximation as it does not consider the physical properties of each grain. For example, Vandersande and Pohl (1982) found that the effects of exsolution and twinning lamellae, inclusions and density gradients within each phase are more significant modifiers of the thermal conductivity of a rock than grain boundary effects between each phase. Because their measurements were at low temperatures, it is reasonable to assume that the same properties will probably not be significant modifiers of the thermal conductivity of the media at geological temperatures. Without direct experimental data, there is no way to predict or evaluate terms arising from these interactions or other effects such as the grain boundaries produce. Because of the absence of experimental data and theoretical models for a wide range of pressure temperature conditions, the thermal conductivity of a water rich fluid must be approximated by the thermal conductivity of pure water. The thermal conductivity of pure water is represented over a large range of pressure-temperature space using the equations discussed by Kestin (1979). By analogy to the dispersion term for solute transport, the coefficient of thermal dispersion has been suggested by many authors (Bear (1972), Mercer and Pinder (1979), Pickens and Grisak 50  (1979), among others) to have the following form: Ki^pjCvjDa  (76)  Dij is the coefficient of mechanical dispersion for the fluid. It was defined in equation (69) as part of the solute transport equation, an identical form is used for heat transport. When used with the heat flow equation, the coefficients of transverse and longitudinal dispersion (OIL and ax) describe the heat dispersion in the fluid. Many authors consider the dispersion coefficient for heat transport as a scalar which can enhance heat transport. Both the scalar and the tensor dispersion term (76) have been successfully used in modelling heat transport in geothermal systems.  51  10. Notes on the Solution of the Equations  All of the partial differential equations which constrain fluid flow, heat transport, and solute transport implicitly assume that the parameters in these equations are a statistical average over a representative  elementary  volume  described is not affected by  (REV). The R E V must be large enough such that parameter being  local  fluctuations in the parameter, but small enough that large scale  features are in different REV's. The size of a REV for porosity (or for example, permeability) is clearly controlled by the size and homogenetity of the geological unit for which it is being determined. For identical reasons, an R E V representing the total number of moles of each of the components is controlled by the homogenetity (grain size, number of moles of minerals, and amount of each component in each mineral) and scale of the geological unit. In general, the volume of the REV for each parameter is different. For a static system, the dimensions of the parameter  chemical  REV's may be different than the  REV's, but in adynamic system where they are coupled, the  physical  and  chemical  physical  REV's  must be the same size. This leads to a philosophical problem. Consider an R E V for porosity which has superimposed a number of  chemical  REV's. The chemical REV's are too small to define the  porosity in a meaningful sense while the chemical heterogeneity on the scale of the R E V for porosity does not allow large chemical REV's. If a reaction occurs in one of the chemical REV's, reducing local void space to zero, the entireflowprocess would be be affected, but due to the necessarily larger size of the porosity REV, it would be averaged out and never seen. This is one of the limitations when mapping real systems to a numerical model, and then mapping the results back to the real system. For numerical models, the R E V for each parameter are often tactly assumed to be the same for reasons of expediency. The initial volume of the R E V is based on the scale of the process being modelled and the degree of information that the modeller thinks necessary.  The  correct  volume  of R E V will depend on the process occuring—often sufficient detail will not be known until the modelling has been completed. The flow, heat and solute transport equations contain and solve for the following temporal and 52  spatial derivatives:  dP_ 9T_ dNf.e dP_ dT_ dNf.c dr ' dr ' dr ' dx/dxi' dxi Subscripted variables indicate that there is one derivative for each possible value of the subscript. These equations are coupled through the derivatives of pressure and temperature, either directly or indirectly through terms such as fluid velocity. In addition, all three of these equations contain the derivative of the number of moles of each of the solid phases and of water, and the derivative of the molality of all aqueous species:  drii dn drrig dn dr ' dr ' dr ' dr T  w  Ideally, the flow, heat and solute transport equations should be solved simultaneously with the derivatives of the mass balance, mass action, ionic strength and activity of water.  This is clearly  impractical for many systems because of the large number of equations involved. For every volume element, the initial temperature, the initial (fluid) pressure, the initial number of moles of each of the components and the initial distribution of these components among the phases and species must be known before the temporal effects can be calculated. The initial values for the temperature, fluid pressure and number of moles of each component in each volume element can be based on a natural system, on the results of other calculations, or they can be arbitrarily chosen. The initial value of the number of moles of each component in a volume element cannot be based on a steady state calculation as most chemical systems never reach total equilibrium. The problem of obtaining good initial values for the number of moles of each of the phases and species in each volume element can be partially overcome by considering each volume element to be initally closed with respect to the mass of components. The number of moles of each phase and the molality of each aqueous species consistent with the chosen mass of each component is then calculated at the initial pressure and the initial temperature of the volume element. of species calculation or by a EQULAS  This is easily done by a distribution  type of calculation (Brown and Skinner, 1974). The total  volume of solids will not generally be equal to the volume available to solids (total volume of the R E V minus the porosity), nor will the volume of the calculated fluid equal the volume available in the pores. The number of moles of each of the solid phases and the aqueous species must be scaled such that the sum of their volumes total the volume of the R E V . The total number of moles of each component are subsequently calculated. Once the initial conditions and boundary conditions are define, the solution of the equations can preceed. The partial differential equations can be solved using finite difference or finite element 53  techniques. T h e s o l u t i o n of these equations is well d o c u m e n t e d i n a wide range of texbooks  (Remson,  H o r n b e r g e r a n d M o l z , 1972, P i n d e r and Gray, 1977, Desai a n d A b e l , 72 are three of many available). F i n i t e element techniques were used for a l l of the m o d e l l i n g w i t h the parameters evaluated discussed  below.  as  T h e s o l u t i o n of the t e m p o r a l derivatives of the n u m b e r of moles of each of the  phases a n d of the m o l a l i t y of a l l of the aqueous species are discussed i n chapter 6. T h e t e m p o r a l p o r t i o n of the flow, heat a n d solute transport equations can b e solved using a m u l t i t u d e of methods, for a one d i m e n s i o n a l stream tube analysis,  a finite difference a p p r o x i m a t i o n is generally  used.  P i n d e r and G r a y (1977) c o n c l u d e d t h a t the centered finite difference procedure is generally the most efficient a n d stable m e t h o d of solution for one d i m e n s i o n a l analysis.  In contrast, the present s t u d y  f o u n d the centered finite difference procedure t o be very unstable a n d only y i e l d i n g an acceptable answer for large t i m e steps. A n finite difference procedure w i t h a weighting factor of a p p r o x i m a t e l y 0. 9 w i t h a l l parameters evaluated at r + ^AT (described below) was found t o give the most stable results except for very s m a l l time steps. Before each time step, the values for all system variables (such as pressure) are guessed for t i m e T + AT using one of two different techniques. E i t h e r an e x t r a p o l a t i o n from the values at r a n d T — AT is used (for t h e parameters w h i c h v a r y smoothly, i.e. pressure) a n d an up-stream weighting based on t h e values at r for t h e two preceeding nodes (for the parameters w h i c h e x h i b i t e d sharp changes, 1. e.  temperature  at T + ^AT.  and composition).  U s i n g these values, a l l system parameters are t h e n evaluated  Because t h e system parameters depend o n t h e system variables at T + AT, t h e y are  be u p d a t e d whenever the system variables are solved.  T h e s o l u t i o n technique for each variable is  iterative a n d c a n take considerable c o m p u t e r t i m e . T h e amount of time used is a direct f u n c t i o n of t h e test(s) used to t e r m i n a t e the iterations.  T h e test presently used compares  the difference  between the value c a l c u l a t e d for the present iteration a n d t h e previous i t e r a t i o n , if this is greater t h e n a specified tolerance, t h e iterations continue. T o prevent an excessive n u m b e r of iterations, a counter specifying t h e m a x i m u m n u m b e r of iterations must be used. T h e o p t i m a l size of the time step is of c r i t i c a l i m p o r t a n c e t o the accurate solution of any finite difference procedure.  A l t h o u g h it is the most convenient t o have a l l t i m e steps the same size, this  results i n a very slow a n d inaccurate code.  W h e n time steps are t o o s m a l l , often n u m e r i c a l drift  is greater t h e n the true change i n the values b e i n g solved for. T h e correct t i m e step is u l t i m a t e l y d e t e r m i n e d b y the process b e i n g modelled, its size a n d rate of response to t e m p o r a l p h e n o m e n o n . T h i s is not always obvious f r o m the b o u n d a r y conditions, thus modeller must expect t o t r y different  54  time steps, based on preceeding results. As will be discussed in the modelling chapter, the pressure at each element quickly reaches a value from which it varies only slowly. The change in temperature is dominated by convection thus very little happens until the front reaches the given element. The maximum step size for the solute transport equation is constrained by convection and by the chemical reactions occurring in each volume element. The size of the time step that can be taken in the chemical reactions equations is dependent totally on the process being modelled and to a lesser extent, on the amount of output desired by the modeller. The size of this time step is generally small, but the absolute size is variable. In most processes, the size of the chemical reaction time step and the solute transport time step should be similar. In the development of the partial differential equations describing the flow, heat transport and solute transport equations, all spatial derivatives of an order greater than two and all temporal derivatives of an order greater than one were discarded. This truncation has resulted in the use of only one derivative to approximate the total change in the number of moles of a phase or the molality of an aqueous species and will introduce significant errors when large time steps are taken. This can be overcome by replacing the derivative of the number of moles or molality in the flow, heat and solute transport equations by a finite difference derivative. The derivative of the number of moles of the i'th phase (for example) would be replaced by: a_ ani  „T + AT  n-  T  — n-  7 7 = -""AT-"  , ( 7 7 )  The number of moles of the i'th phase at time r + A r would be calculated using as many derivatives as is needed in a series expansion such as equation (1). This effectively reintroduces higher-order derivatives into the temporal portion of the flow, heat and solute transport equation, and improves the accuracy and stability of these equations. Figure 3 illustrates the iteration scheme used, the order of solution and potential relative sizes of the time steps. Each horizontal line indicates the relative size of time step, and the relative position of the time of solution. The predicted values for all parameters (for example, porosity) are updated at the end of each iteration for the solution of flow, heat and solute transport equations. One practical limitation on the step size is the difference in velocity of one R E V compared to the next. If this difference, multiplied by the time step, is significantly greater then the length of the REV, the calculated results for the solute transport and for the heat transport will be grossly in error. 55  Figure 3 - I t e r a t i o n Scheme Used  Flow equation Heat  equation  S o l u t e transport and c h e m i c a l reaction  equations solved alternatively  Heat  equation  S o l u t e transport and c h e m i c a l reaction  equations solved alternatively  Heat  equation  S o l u t e transport and c h e m i c a l reaction  equations solved alternatively  T I M E  The length of the dashed lines indicates the relative size of time steps—their vertical position indicates the relative order in which they occur. For purposes of illustration, all time steps are fixed, the flow equation step size is three times greater than the heat equation step size and nine times greater than the solute transport equation and chemical reaction equation step size. In general, each step can vary and is iterative.  56  11. Model Verification  The equations developed and discussed in the previous chapters have been used as the basis for a computer program which is described in the appendices. Before the program can be used as a predictive tool, the results must be confirmed as correct. The theoretical bases of the program can be verified by independently rederiving all equations, but the verification of a large computer code is much more difficult. Programs are verified by comparing their calculated results with existing analytical solutions or with the results of other programs. The program can also be examined by other programmers, but the absence of visible errors does not ensure that there are none. For a given problem, an analytical solution is exact but the range of problems for which an analytical solution exists and can be applied to is extremely limited. Comparison with other programs is often the only method of verification, but this depends on the availability of programs which make similar calculations. To the best of the author's knowledge, there are no computer codes (and certainly no analytical solutions) that can be used to calculate geochemical processes in the detail and with the degree of coupling presented here. The code has been verified by checking the results against existing analytical solutions and other computer codes, generally by modelling very simple and restricted cases. For many of these test, the code developed for this thesis had to be modified (simplified) to match the other program. The following comparisons/verifications have been made: 1 Iso-thermal flow processes with no mass transport and no chemical reactions. Constant porosity and permeability as a function of time and space, all nodes equal. All matrix phases considered inert. Fluid is inert and the volumetric properties of the REV  are independent of pressure  and temperature. Results were directly compared to analytical solutions and simple numerical models which calculated the pressure head and fluid velocity. 2 As per (l), except the volumetric properties of the fluid were modelled using the ideal gas law. Results compared to simple numerical models which calculated the pressure head and fluid velocity. 3 As per (l), except the volumetric properties of the fluid were modelled using the Keenan and Keyes equations of state for water. The initial pressure gradient was kept small, all other 57  properties were scaled accordingly. Results compared to simple numerical models which used the ideal gas law to calculate the pressure head and fluid velocity. 4 As per (2) except porosity varied as a function of node position. Results compared against simple numerical models which calculated the pressure head and fluid velocity. 5 No flow, no chemical reactions, constant porosity and permeability as a function of space and time, heat capacity of matrix and fluid set to a constant, all nodes equal. Results compared to analytical solution which calculated the conductive heat transport. 6 No flow, no chemical reactions, constant porosity and permeability as a function of space and time, all nodes equal, heat capacity of matrix and fluid allowed to vary, results compared to numerical models which calculated conductive heat transport. 7 Flow constant as a function of time and equal in all nodes. No chemical reactions, constant and equal porosity and permeability as a function of space and time, pressure constant and equal at all nodes, heat capacity of matrix and fluid constant. No conductive heat transport.-Results compared to numerical models for advective heat transport. 8 As per 7 except dispersive heat conduction considered as well. Results compared to numerical models. 9 Constant pressure (same at all nodes), constant porosity and permeability (same at all nodes) as a function of space and time, constant temperature (at all nodes), no chemical reactions. Constant ionic strength, activity coefficents, volumetric properties of fluid. No flow, only diffusional transport of species allowed. All parameters not specified here were held constant. Species and matrix phases considered inert. Results compared to analytical solution for diffusional mass transport. 10 As per 9, except advection included. Compared to numerical results for advective and diffusional mass transport. 11 Thermodynamic properties of aqueous species compared to results calculated using PATH69 (Perkins, 1980), PATH81 (Perkins, 1980), SUPCRT (Kirkham, et al., 1978) and EQ3D (Wolery, 1979). 12 Thermodynamic properties of solids and water compared to values calculated using a modification of PT-SYSTEM (Perkins, Brown and Berman, 1985). 13 Mass transfer calculations for isothermal isobaric closed systems compared to results calculated using PATH69 (Perkins, 1980), PATH81 (Perkins, 1980), and EQ3D (Wolery, 1979). 58  14 All routines which calculate the physical properties of phases, aqueous species and water verified against existing tabulations of experimental data. The above comparisons verify most of the subroutines in the program, they do not verify the coupling and subsequent interactions. These can only be verified by detailed examination of the individual run results, plotting them, and examining their implications. The chemical data for any given run can be plotted on activity diagrams; if the calculations are inconsistant with the thermodynamic data, then the calculated equilibrium would disagree with the diagrams. Until such time that equivalent programs are available, complete verification of the program written for this thesis is not possible. The program does contain some internal checks against errors. At any point in time, the total mass in an REV  is fixed and the distribution of mass among the phases and species has been  calculated. Using the total mass, the distribution of mass among the phases and species can be recalculated using different routines, thus independently verifying the number of moles of the solid phases and the molality of the aqueous species. The final verification that any model can undergo is to sucessfully predict and interpret natural and industrial processes. The most applicable process to which this model can be applied is a steam or hot water flood during secondary oil recovery. Within the limitations of the code (a one dimensional analysis), the agreement is good.  59  12. Examples of Model Application  This chapter presents the results of various  model calculations  which were made with the program de-  scribed and listed in the appendices. All of the calculations have the same basic physical geometry—a one dimensional "stream tube" consisting of a quartz matrix with an initial porosity of 20%. At time zero, a pressure and/or thermal event occurs at one end. This event modifies the existing flow field (if one existed), the pressure and temperature.  Dependent on the boundary conditions, material  may dissolve/precipitate during this process. The results are presented infiguresand must be considered preliminary. The models have been kept as simple as possible in order to illustrate the processes—results from complicated runs often hide the underlying process in details. The models are divided into three sets, each set into three subsets. The subsets are the same in each set. The sets were chosen to represent the three most extreme cases possible—they and thenrespective subsets are: • Inert component, with transport - Pressure gradient in an isothermal system. - Temperature gradient in a system with fixed pressures at each node. - Pressure and temperature gradients. • Reactive component, with no tranport - Pressure gradient in an isothermal system. - Temperature gradient in a system with fixed pressures at each node. - Pressure and temperature gradients. • Reactive component, with transport - Pressure gradient in an isothermal system. - Temperature gradient in a system with fixed pressures at each node. - Pressure and temperature gradients. Because of the interactions in the system, each of the subsystems will have different ranges for each of the variables. The closest  real system  to these models would be a wet steam flood—which is used  as an enhanced oil recovery technique. The position z, = 0 on the followingfigureswould correspond 60  to a position close to the gravel pack. Steam/hot water injected through it quickly dissolves the 6  quartz, often reaching a near saturated silica value before the formation is reached. The producing formation in most oil fields usually contains upwards of 50% quartz.  Overview of the Graphical Technique The results have been plotted in a series of three dimensional figures. On each figure, the x axis is the distance along the flow path, and increases from left to right. The y axis is time, and increases with depth into the figure. The variable being plotted (pressure, temperature, porosity, ...) always increases vertically (the z axis). The surface has been generated by a series of lines, one set parallel to the time axis (iso-distance) and the other set parallel to the distance axis (iso-time). The set of surfaces for any given run all have the same x and y dimensions. Regardless of the number of time steps and of volume elements, the results have been displayed such that there is always between 31 and 61 divisions in the x (distance) and y (time) directions. No calculations were made with less then 31 divisions in either direction. If there were more than 40 REV's or more than 61 time steps, then some of the intermediate results were not plotted. This was done to maintain the density of information on thefigureat a useable level. On occasion, not plotting the intermediate results yields a  bumpy  surface. The  bumpiness  may also be a result of numerical roundoff during plotting, or due  to numerical error/roundoff/instability during the calculations. For each variable considered (pressure, temperature, porosity, ...), two surfaces have been plotted. The first is the variable versus distance and time, the second is the derivative of the variable with respect to time versus distance and time. The second plot gives a better sense of the spatial and temporal changes that particular variable undergoes. Although each variable is coupled to all others, one of the variables may change a factor of two or much more than the others. When this occurs, the time scale for that variable on thefigureswill be different than for the other figures. Because the change in permeability is totally proportional to porosity (see the equation of Wood and Hewitt (1982), at the end of flow chapter),figurescontaining permeability and the deriviative of permeability have only been plotted for the first model. Figures of the spacial and temporal change in the molality of the aqueous species and the temporal derivatives have not been included. 6  A gravel pack is a cylinderical shell of sieved quartz sand (approximately  1.70 to 0.85 mm  in  diameter) surrounding the well. It typically has an inter radius of 20-30 centimeters and an outer of 50-70 centimeters. 61  The aqueous species data base used is that of Helgeson et al. (1974a, 1974b, 1976, 1981), and it, unfortunately, is limited as it generally includes only one aqueous species for each element—typically the bare ion. As an aid in interpreting the graphs, several tables are associated with model 6. These list the pressure, temperature, porosity and molality of silica as a functions of distance and time. The units for allfiguresare: pressure is in MPa, temperature is in degrees kelvins, concentration of aqueous species are in molality.  M o d e l One:  Iso-thermal w i t h no Chemical Reactions, I n e r t  Transport  This model calculates the changes in pressure, fluid velocity, porosity, permeability and concentration of aqueous silica when a quartz sandstone is subjected to a pressure event. The process was calculated under the following conditions— Initial conditions (time = 0.0, for all z ) 8  pressure = 20.0 MPa, porosity = 20.0 percent, log permeability = —8.00, initial velocity = 0.0 m/sec, "fluid composition in equilibrium with quartz,  for times greater than 0.0  pressure o = 20.5 MPa, solution is inert, x=  and for all times and positions  temperature = 500 degrees kelvins.  This model is illustrated by figures 4A, 4B, 4C, 4D, 4E, 4F, 4G, 4H, 41 and 4J. Examination of the figures reveals the following: • Each node reacts quickly to the pressure front, reaching a pressure value near the  steady  state  value. • The change in pressure rapidly decays and disperses over a a longer length of the stream tube. • The magnitude of the velocity decays as quickly as the pressure does, in exact proportion to the pressure decay. 62  The permeability and porosity at x = 0 was held constant, giving the graphs the appearance of a ridge. Both the porosity and permeability increase as the pressure increases. Their maximum rate of change correlates to the maximum rate of change of pressure. Because of the model used, the change in permeability is exactly the same as the change in porosity. The silica in solution cannot react with the matrix, and because there is only one aqueous silica species, its concentration is independent of the pressure. As would be expected for any inert component, speed of the silica concentration front is a function of the velocity. This isothermal process illustrates the effects that occur when the rate of reaction between aqueous species and solids is infinitely slow—the effects on the matrix are totally a function of the pressure work term.  63  Figure 4A - Chang, » p  r e  „„,« „ „ , „ , „ „ ,  t  o  t l m (  ,  a  n  d  CO  \  Figure  - Derivative of the Change in Pressure  Figure 4B is the derivative of pressure with  respect to time plotted as a function of time and distance  in an isothermal system. 64  F i g u r e 4C - C h a n g e i n V e l o c i t y w i t h r e s p e c t t o t i m e a n d d i s t a n c e  Figure 4C illustrates the change in velocity as a function of time and distance in an isothermal system.  F i g u r e 4D  - Derivative of the Change in Velocity  Figure 4D is the derivative of velocity with respect to time plotted as a function of time and distance in an isothermal system.  65  Figure 4 E - Change in Porosity w i t h respect to t i m e a n d  distance  Figure 4E illustrates the change in porosity as a function of time and distance in an isothermal system.  F i g u r e 4F  - Derivative of the Change in Porosity  Figure 4F is the derivative of porosity respect to time plotted as a function of time and distance in an isothermal system. 66  Figur. iG - C h « m V^bmiy M g  system.  <^,._  with re,p«, ,„ tta, « „ , , „ „ di  ^  > i a  Figure 4H - Derivative of the Change b, Permeability Fi »re 4H is the derivative 8  o t p  „  m e i b i l i t y  w i t h  r  „  p e c t  distance in an isothermal system. 67  ^  ^  ^ ^^  ^ ^  ^  F i g u r e 41 - C h a n g e i n C o n c e n t r a t i o n w i t h r e s p e c t t o t i m e a n d d i s t a n c e  Figure 41 illustrates the change in the concentration of an inert component as a function of time and distance in an isothermal system.  F i g u r e 4J - D e r i v a t i v e o f t h e C h a n g e i n  Concentration  Figure 4J is the derivative of the concentration of an inert component with respect to time plotted as a function of time and distance in an isothermal system. 68  Model  Two:  Thermal  Effects, F i x e d Pressure  Gradient,  Inert  Transport  This model calculates the changes in temperature, fluid velocity, porosity, permeability and concentration of aqueous silica when a quartz sandstone is subjected to a thermal event. The process was calculated under the following conditions— Initial conditions (time = 0.0, for all z,-)  temperature = 500.0 degrees kelvins, porosity = 20.0 percent, log permeability = —8.00, initial velocity = 0.0 m/sec, fluid composition in equilibrium with quartz, for times greater than 0.0  temperature x= o = 550.0 degrees kelvins, solution is inert, and for all times and positions  Pressure MPa= 20.5 - (.00125i,). The model is illustrated by figures 5A, 5B, 5C, 5D, 5E and 5F. Examination of thesefiguresreveals the following: • The thermal event is a sharp front moving from left to right across the diagram. • Plotting error (too few points for a true  3D view), numerical error (both roundoff and insta-  bility) are clearly visible in the derivative of temperature with respect to time and the porosity. • The porosity decreases as a function of temperature. The maximum rate of change correlates to the maximum rate of change of temperature. • As would be expected for any inert component, speed of the silica concentration front is a function of the velocity. • Because the silica front is not reactive, it quickly moves ahead of the temperature front. The rate of change of temperature is constrained by the velocity of the fluid and by the heat capacity of the matrix. This process illustrates the effects that occur when the rate of reaction between aqueous species and solids is infinitely slow—the effects on the matrix are totally a function of the temperature. It also illustrates that under these conditions, the temperature field migrates considerably slower than the solute front. 69  Figure 5 A - Change in Temperature with respect to time and distance Figure 5A illustrates the change in temperature as a function of time and distance in a system with fixed pressures.  Figure 5B - Derivative of the Change in Temperature Figure 5B is the derivative of temperature with respect to time plotted as a function of time and distance in a system with fixed pressures. 70  F i g u r e 5C - C h a n g e i n P o r o s i t y w i t h r e s p e c t t o t i m e a n d d i s t a n c e  Figure 5C illustrates the change in porosity as a function of time and distance in a system with fixed  Figure 5 D - Derivative of the Change in Porosity  Figure 5D is the derivative of porosity respect to time plotted as a function of time and distance in a system with fixed pressures. 71  Figure 5E - Change in Concentration with respect to time and distance Figure 5E illustrates the change in the concentration of  an inert component as a function of time  and distance in a system with fixed pressures.  F '"o,  F- °°„  °S  0  • 0-  F i g u r e 5F - D e r i v a t i v e o f t h e C h a n g e i n C o n c e n t r a t i o n  Figure 5F is the derivative of the concentration of an inert component respect to time plotted function of time and distance in a system with fixed pressures. 72  as a  M o d e l Three: N o  Chemical Reaction, Inert  Transport  This model calculates the changes in temperature, fluid velocity, porosity, permeability and concentration of aqueous silica when a quartz sandstone at equilibrium with a fluid, is subjected to a thermal and pressure event. The process was calculated under the following conditions— Initial conditions (time = 0.0, for all x ) t  temperature = 500.0 degrees kelvins, pressure = 20.0  MPa,  porosity = 20.0 percent, log permeability = —8.00, initial velocity = 0.0 m/sec, fluid composition in equilibrium with quartz, for times greater than 0.0  pressure o = 20.50 MPa, temperature I=  x = 0  — 550.0 degrees kelvins.  solution is inert, This process is illustrated by figures 6A, 6B, 6C, 6D, 6E, 6F, 6G, 6H, 61 and 6J. Note that the pressure and velocity figures have a different time scale than the other figures. The most significant points shown on thesefiguresare: • The pressure quickly rises to a near steady state case. • The velocity instantaneously reaches a maximum value from which it decays rapidly to near the steady state value. • The maximum change in porosity correlates directly with the maximum change in temperature. • The thermal effect on porosity (and permeability) is far greater than that of the mechanical (pressure) effect. The pressure effect can be seen—although only for the initial nodes after a longer time when the porosity surface curves upward. • Because the velocity changes significantly—from zero to a positive, approximately constant value—the inert component ture  shock front  shock front  only travels about 15 percent faster then the tempera-  does. This process illustrates the effects when the reaction rates between the  aqueous species and the solids are infinitely slow—the effects on the matrix are totally a function of the pressure and temperature. It also illustrates that in a evolving system, the solute shock front  does not outdistance the temperature  an established flow system. 73  shock front  to the same degree as it would in  F i g u r e 6A  - Change i n Pressure w i t h respect to t i m e a n d distance  Figure 6A illustrates the cha lange m pressure as a function of time and dist thermal and pressure gradients.  ance m a system with  Figure 6 B - Derivative of the Change in Pressure  Figure 6B is the d e r i v e of pressure with respect to time plotted as a function of tune and distance in a system with thermal and pressure gradients. . 74  Figure 6C - Change in Velocity with respect to time and distance Figure 6C illustrates the change in fluid velocity as a fun, ction of time and distance in a system with thermal and pressure gradients.  Figure 6D - Derivative of the Change in Velocity Figure 6D is the derivative of velocity with respect to time plotted as a function of time and distance in a system with thermal and pressure gradients. 75  F i g u r e 6E - C h a n g e i n T e m p e r a t u r e w i t h r e s p e c t t o t i m e a n d d i s t a n c e  Figure 6E illustrates the change in temperature as a function of time and distance in a system with thermal and pressure gradients.  F i g u r e 6F - D e r i v a t i v e o f t h e C h a n g e i n  Temperature  Figure 6F is the derivative of temperature with respect to time plotted as a function of time and distance in a system with thermal and pressure gradients. 76  F i g u r e 6 G - Change i n P o r o s i t y w i t h respect t o t i m e a n d distance  Figure 6G illustrates the change in porosity as a function of time and distance in a system with thermal and pressure gradients.  Figure 6 H - Derivative of the Change in Porosity  Figure 6H is the derivative of porosity with respect to time plotted as a function of time and distance in a system with thermal and pressure gradients. 77  F i g u r e 61 - C h a n g e i n C o n c e n t r a t i o n w i t h r e s p e c t t o t i m e a n d d i s t a n c e  Figure 61 illustrates the concentraion of an inert component as a function of time and distance in a system with thermal and pressure gradients.  F i g u r e 6J - D e r i v a t i v e o f t h e C h a n g e i n  Concentration  Figure 6J is the derivative of the concentration of an inert component with respect to time plotted as a function of time and distance in a system with thermal and pressure gradients. 78  M o d e l Four: Iso-thermal w i t h no Transport.  This model calculates the changes in pressure, fluid velocity, porosity, permeability and concentration of aqueous silica when a quartz sandstone at constant temperature remains in equilibrium with the fluid during a pressure event. The process was calculated under the following conditions— Initial conditions (time = 0.0, for all z,)  pressure = 20.0 MPa, porosity = 20.0 percent, log permeability = —8.00, initial velocity = 0.0 m/sec, fluid composition in equilibrium with quartz,  for times greater than 0.0  pressure  x=0  = 20.50 MPa, solution is inert,  and for all times and positions temperature = 500.0 degrees kelvins, there is no solute transport, the fluid remains at all times in equilibrium with quartz.  This process is illustrated by figures 7A, 7B, 7C, 7D, 7E, 7F, 7G and 7H which can be compared with those of model one. • As in model one, the pressure and velocity quickly reach a near steady state values. • The porosity increases with respect to time and distance as it does in model one, but the increase is a  factor of 1.5  • There is no  more due to the dissolution of quartz.  solute  front as no transport has occurred. Thus the molality and the derivative of  the molality of silica in solution is a direct function of the pressure and the derivative of fluid pressure. This model illustrate the effects on a system in which the rates of reaction between the solution and the solid phases are infinitely fast but no solute transport occurs. Under these conditions, the general effect is to increase the porosity and permeability.  79  F i g u r e 7A  - Change i n Pressure w i t h respect to t i m e a n d distance  Figure 7A illustrates the change in pressure as a function of time and distance in an isothermal  Figure 7B - Derivative  of the Change in Pressure  Figure 7B is the derivative of pressure with respect to time plotted as a function of time and distance in an isothermal system. 80  F i g u r e 7C - C h a n g e i n V e l o c i t y w i t h r e s p e c t t o t i m e a n d d i s t a n c e  Figure 7C illustrates the change in velocity as a function of time and distance in an isothermal  F i g u r e 7D  - Derivative of the Change in Velocity  Figure 7D is the derivative of velocity with respect to time plotted as a function of time and distance in an isothermal system. 81  Figure 7E - Change in Porosity with respect to time and distance Figure 7E illustrates the change in porosity as a function of time and distance in an isothermal system.  Figure 7F - Derivative of the Change in Porosity Figure 7F is the derivative of porosity respect to time plotted as a function of time and distance in an isothermal system. 82  F i g u r e 7 6 - Change i n C o n c e n t r a t i o n w i t h respect to t i m e and distance  Figure 7G illustrates the change in the concentration of a component as a function of time and distance in an isothermal system with no transport of that component.  Figure 7 H - Derivative of the Change in Concentration  Figure 7H is the derivative of the concentration of a component with respect to time plotted as a function of time and distance in an isothermal system with no transport of that component. 83  Model Five: Thermal Effects, Fixed Pressure Gradient, No Transport This model calculates the changes in temperature, fluid velocity, porosity, permeability and concentration of aqueous silica when a quartz sandstone is subjected to a thermal event. The process was calculated under the following conditions— Initial conditions (time = 0.0, for all x,)  temperature = 500.0 degrees kelvins, porosity = 20.0 percent, log permeability = —8.00, fluid composition in equilibrium with quartz,  for times greater than 0.0  temperature o = 550.0 degrees kelvins, solution is inert, I =  and for all times and positions  Pressure MPa= 20.5 — (.00125X;), velocity determined by pressure gradient, there is no solute transport, the fluid remains at all times in equilibrium with quartz.  This process is illustrated by figures 8A, 8B, 8C, 8D, 8E and 8F. The most important points illustrated by these set of figures are: • The position of the temperature front is exactly mirrored by the changes in porosity and by the molality of silica in solution. • The fronts broaden and slow with respect to time and distance due to the heat capacity of the solid phases and due to dispersion. • In contrast to model 3, the porosity has increased by approximately 20 percent (and although not shown, the permeability as well). This model illustrates the effects on a steady state flow field when a thermal event occurs, the rate of reaction between aqueous species and solid phases is infinitely fast, but no solute tranport occurs. The general effect is to increase the porosity and permeability significantly. 84  Figure 8A - Change in Temperature with respect to time and distance Figure 8A illustrates the change in temperature as a function of time and distance in a system with fixed pressures.  Figure 8B - Derivative of the Change in Temperature Figure 8B is the derivative of temperature with respect to time plotted as a function of time and distance in a system with fixed pressures. 85  F i g u r e 8C - C h a n g e i n P o r o s i t y w i t h r e s p e c t t o t i m e a n d d i s t a n c e  Figure 8C illustrates the change in porosity as a function of time and distance in a system with fixed pressures.  • '  /x  F i g u r e 8D  - Derivative of the Change in Porosity  Figure 8 D is the derivative of porosity respect to time plotted as a function of time and distance in a system with fixed pressures. 86  F i g u r e 8E - C h a n g e i n C o n c e n t r a t i o n w i t h r e s p e c t t o t i m e a n d d i s t a n c e  Figure 8E illustrates the change in the concentration of a component as a function of time and distance in a system with a fixed pressure head and fixed fluid velocity, but in a system with no tranport of that component.  Figure 8F - Derivative of the Change in  Concentration  Figure 8F is the derivative of the concentration of a component respect to time plotted as a function of time and distance in a system with a fixed pressure head and fixed fluid velocity, but in a system with no transport of that component. 87.  Model Six: No Transport - Pressure and Temperature Gradient This model can be considered the "no solute transport" analogy to model 2 or the sum of models 4 , and 5. The process was calculated under the following conditions— Initial conditions (time = 0.0, for all x,)  temperature = 500.0 degrees kelvins, pressure = 20.5 MPa, porosity = 20.0 percent, log permeability = —8.00, initial velocity = 0.0 m/sec, fluid composition in equilibrium with quartz,  for times greater than 0.0  temperature x= $ '= 550.0 degrees kelvins, pressure o = 20.5 MPa, I=  and for all times and positions  there is no solute transport, the fluid remains at all times in equilibrium with quartz.  Figures 9A through 9J illustrate this model. All points mentioned for models 4 and 5 apply to this one as well, but a few more need to be mentioned. • The effects of numerical instability can be clearly seen in figures 9E, 9G and 91—and are, of course, present in the figures showing the derivatives of these properties. • The effects of pressure on the porosity or on the molality of silica in solution is small compared to the effects of temperature and is difficult to see in these diagrams. It can be most easily seen in the derivative of porosity by comparing the height of the surface in front of and behind the "ridge" indicating the effects of the temperature  shock  front.  • Because the thermal front broadens with respect to time and distance, all of the  shock  fronts  appear to be curved in time. Because the front broadens, the time taken by the front to tranverse a given point inceases. This model indicates what could happen in a static system when it is disturbed by an injection of hot fluid, but no solute transport occurs. The general conclusion is that the porosity, permeability and amount of dissolved material in solution would increase. The position of maximum change in any of these variables would be at the  thermal  shock front.  F i g u r e 9 A - Change i n Pressure w i t h respect to t i m e a n d distance  Figure 9A illustrates the change in pressure as a function of time and distance in a system with thermal and pressure gradients.  Figure 9 B - Derivative of the Change i n Pressure  Figure 9B is the derivative of pressure with respect to time plotted as a function of time and distance in a system with thermal and pressure gradients. 89  Figure 9C - Change in Velocity with respect to time and distance Figure 9C illustrates the change in fluid velocity as a function of time and distance in a system with thermal and pressure gradients.  Figure 9D - Derivative of the Change in Velocity Figure 9D is the derivative of velocity with respect to time plotted as a function of time and distance in a system with thermal and pressure gradients. 90  F i g u r e 9 E - Change in T e m p e r a t u r e w i t h respect to t i m e a n d distance  Figure 9E illustrates the change in temperature as a function of time and distance in a system with thermal and pressure gradients.  F i g u r e 9F - D e r i v a t i v e  of the Change in  Temperature  Figure 9F is the derivative of temperature with respect to time plotted as a function of time and distance in a system with thermal and pressure gradients. 91  F i g u r e 9G  - Change i n Porosity w i t h respect to t i m e and distance  Figure 9G illustrates the change in porosity as a function of time and distance in a system with thermal and pressure gradients.  i—i  cn o ex  o  Figure 9 H - Derivative of the Change in Porosity  Figure 9H is the derivative of porosity with respect to time plotted as a function of time and distance in a system with thermal and pressure gradients. 92  F i g u r e 91 - C h a n g e i n C o n c e n t r a t i o n w i t h r e s p e c t t o t i m e a n d d i s t a n c e  Figure 91 illustrates the concentration of a component as a function of time and distance in a system with thermal and pressure gradients, but with no transport of that component.  F i g u r e 9J - D e r i v a t i v e  of the Change in  Concentration  Figure 9J is the derivative of the concentration of a component with respect to time plotted as a function of time and distance in a system with thermal and pressure gradients, but with no transport of that component. 93  Table TV: C a l c u l a t e d values o f P r e s s u r e ,  , at time: 0.0  The following values for pressure, temperature, molality of silica in solution and porosity were calculated for time: 0.0 Position  Pressure  Temperature  Molality  Porosity  .00000E+00 .10000E+02 .20000E+02 .30000E+02 .40000E+02 .50000E+02 .60000E+02 .70000E+02 .80000E+02 .90000E+02 .10000E+03 .11000E+03 .12000E+03 .13000E+03 .14000E+03 .15000E+03 .16000E+03 .17000E+03 .18000E+03 .19000E+03 .20000E+03 .21000E+03 .22000E+03 .23000E+03 .24000E+03 .25000E+03 .26000E+03 .27000E+03 .28000E+03 .29000E+03 .30000E+03 .31000E+03 .32000E+03 .33000E+03 .34000E+03 .35000E+03 .36000E+03 .37000E+03 .38000E+03 .39000E+03  .21000E+02 .20O0OE+02 .2OO00E+02 .20O00E+02 .20O00E+02 .20O0OE+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20O0OE+O2 .2OO00E+02 .20O0OE+02 .20000E+02 .20000E+02 .20O00E+02 .20O00E+02 .20000E+02 .20O0OE+02 .20000E+02 .20O0OE+02 .20O0OE+02 .20000E+02 .20000E+02 .20000E+02 .20O0OE+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20O0OE+O2 .20000E+02  .55000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .5000OE+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 '.50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03  .85929E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02  .20000000 .20000000 .20000000 .20000000 .20000000 .20000000 .20000000 .20000000 .20000000 .20000000 .20000000 .20000000 .20000000 .20000000 .20000000 .20000000 .20000000 .20000000 .20000000 .20000000 .20000000 .20000000 .20000000 .20000000 .20000000 .20000000 .20000000 .20000000 .20000000 .20000000 .20000000 ^20000000 .20000000 .20000000 .20000000 .20000000 .20000000 .20000000 .20000000 .20000000  94  Table V: Calculated values of Pressure, • • •, at time: 4000 The following values for pressure, temperature, molality of silica in solution and porosity were calculated for time: 4000. Position  Pressure  Temperature  Molality  Porosity  .OO000E+0O .10000E+02 .20000E+02 .30000E+02 .40000E+02 .50000E+02 .60000E+02 .70000E+02 .80000E+02 .90000E+02 .10000E+03 .11000E+03 .12000E+03 .13000E+03 .14000E+03 .15000E+03 .16000E+03 .17000E+03 .18000E+03 .19000E+03 .20000E+03 .21000E+03 .22000E+03 .23000E+03 .24000E+03 .25000E+03 .26000E+03 .27000E+03 .28000E+03 .29000E+03 .30000E+03 .31000E+03 .32000E+03 .33000E+03 .34000E+03 .35000E+03 .36000E+03 .37000E+03 .38000E+03 .39000E+03  .21000E+02 .20784E+02 .20598E+02 .20436E+02 .20305E+02 .20203E+02 .20130E+02 .20080E+02 .20048E+02 .20027E+02 .20015E+02 .20008E+02 .20005E+02 .20002E+02 .20001E+02 .20001E+02 .200O0E+O2 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02  .55000E+03 .54994E+03 .55000E+03 .54993E+03 .55000E+03 .54990E+03 .55000E+03 .54982E+03 .55000E+03 .54950E+03 .55000E+03 .54795E+03 .55000E+03 .53387E+03 .50280E+03 .50000E+03 .50016E+03 .50000E+03 .50001E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03  .85929E-02 .85798E-02 .85763E-02 .85646E-02 .85642E-02 .85529E-02 .85570E-02 .85419E-02 .85536E-02 .85168E-02 .85524E-02 .84068E-02 .85519E-02 .74313E-02 .54934E-02 .53343E-02 .53434E-02 .53343E-02 .53349E-02 .53343E-02 .53343E-02 .53343E-02 .53343E-02 .53343E-02 .53343E-02 .53343E-02 .53343E-02 .53343E-02 .53343E-02 .53343E-02 .53343E-02 .53343E-02 .53343E-02 .53343E-02 .53343E-02 .53343E-02 .53343E-02 .53343E-02 .53343E-02 .53343E-02  .20000000 .23733399 .23724984 .23708875 .23704466 .23690701 .23692623 .23675795 .23687128 .23647653 .23685253 .23512364 .23684497 .21841017 .20045878 .20014559 .20003666 .20000148 .19999859 .19999596 .19999582 .19999563 .19999562 .19999560 .19999560 .19999560 .19999560 .19999560 .19999560 .19999560 .19999560 .19999560 .19999560 .19999560 .19999560 .19999560 .19999560 .19999560 .19999560 .20000000  95  Table VI: Calculated values of Pressure,  at time: 8000  The following values for pressure, temperature, molality of silica in solution and porosity were calculated for time: 8000.0 Position  Pressure  .00000E+00 .10000E+02 .20000E+02 .30000E+02 .40000E+02 .50000E+02 .60000E+02 .70000E+02 .80000E+02 .90000E+02 .10000E+03 .11000E+03 .120O0E+O3 .13000E+03 .14000E+03 .15000E+03 .16000E+03 .17000E+03 .18000E+03 .19000E+03 .20000E+03 .21000E+03 .22000E+03 .23000E+03 .24000E+03 .25000E+03 .26000E+03 .27000E+03 .28000E+03 .29000E+03 .30000E+03 .31000E+03 .32000E+03 .33000E+03 .34000E+03 .35000E+03 .36000E+03 .37000E+03 .38000E+03 .39000E+03  .21000E+02 .20847E+02 .20711E+02 .20584E+02 .20468E+02 .20367E+02 .20281E+02 .20210E+02 .20154E+02 .20110E+02 .20077E+02 .20053E+02 .20035E+02 .20023E+02 .20015E+02 .20009E+02 .20006E+02 .20004E+02 .20002E+02 .20001E+02 .20001E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02  Temperature .55000E+03 .55000E+03 .55000E+03 .55000E+03 .54999E+03 .55000E+03 .54998E+03 .55000E+03 .54996E+03 .55O0OE+O3 .54991E+03 .55000E+03 .54977E+03 .55000E+03 .54933E+03 .55000E+03 .54746E+03 .55000E+03 .53547E+03 .50453E+03 .50000E+03 .50022E+03 .50000E+03 .50001E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 \50000E+03 .50000E+03 .50000E+03  96  Molality  Porosity  .85929E-02 .85866E-02 .85807E-02 .85756E-02 .85704E-02 .85668E-02 .85619E-02 .85604E-02 .85549E-02 .85562E-02 .85482E-02 .85539E-02 .85365E-02 .85527E-02 .85039E-02 .85521E-02 .83714E-02 .85519E-02 .75391E-02 .55925E-02 .53346E-02 .53471E-02 .53346E-02 .53354E-02 .53346E-02 .53347E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02  .20000000 .23742872 .23732949 .23724384 .23715473 .23709310 .23701555 .23698534 .23690921 .23691782 .23681413 .23687643 .23669783 .23685708 .23633432 .23684830 .23466565 .23684528 .22142581 .20153386 .19999858 .20009008 .19999835 .20000469 .19999828 .19999871 .19999826 .19999828 .19999825 .19999825 .19999825 .19999825 .19999825 .19999825 .19999825 .19999825 .19999825 .19999825 .19999825 .20000000  Table V U : C a l c u l a t e d values o f P r e s s u r e ,  at time: 12000  The following values for pressure, temperature, molality of silica in solution and porosity were calculated for time: 12000. Position  Pressure  .OOO00E+0O .10000E+02 .20000E+02 .30000E+02 .40000E+02 .50000E+02 .60000E+02 .70000E+02 .80000E+02 .90000E+02 .10000E+03 .11000E+03 .12000E+03 .13000E+03 .14000E+03 .15000E+03 .16000E+03 .17000E+03 .18000E+03 .19000E+03 .20000E+03 .21000E+03 .22000E+03 .23000E+03 .24000E+03 .25000E+03 .26000E+03 .27000E+03 .28000E+03 .29000E+03 .30000E+03 .31000E+03 .32000E+03 .33000E+03 .34000E+03 .35000E+03 .36000E+03 .37000E+03 .38000E+03 .39000E+03  .21000E+02 .20875E+02 .20763E+02 .20655E+02 .20554E+02 .20462E+02 .20379E+02 .20306E+02 .20243E+02 .20190E+02 .20146E+02 .20111E+02 .20083E+02 .20061E+02 .20044E+02 .20031E+02 .20022E+02 .20015E+02 .20010E+02 .20007E+02 .20005E+02 .20003E+02 .20002E+02 .20001E+02 .20001E+02 .20001E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .2O0O0E+O2 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02  Temperature .55000E+03 .55000E+03 ' .55000E+03 .55000E+03 .55000E+03 .55000E+03 .54999E+03 .55000E+03 .54999E+03 .55000E+03 .54998E+03 .55000E+03 .54996E+03 .55000E+03 .54990E+03 .55000E+03 .54976E+03 .55000E+03 .54925E+03 .55000E+03 .54697E+03 .55000E+03 .53321E+03 .50396E+03 .50000E+03 .50019E+03 .50000E+03 .50001E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03  97  Molality  Porosity  .85929E-02 .85877E-02 .85830E-02 .85786E-02 .85742E-02 .85707E-02 .85667E-02 .85642E-02 .85607E-02 .85595E-02 .85560E-02 .85562E-02 .85519E-02 .85542E-02 .85467E-02 .85539E-02 .85354E-02 .85523E-02 .84987E-02 .85520E-02 .83363E-02 .85519E-02 .73870E-02 .55596E-02 .53343E-02 .53455E-02 .53343E-02 .53350E-02 .53343E-02 .53343E-02 .53343E-02 .53343E-02 .53343E-02 .53343E-02 .53343E-02 .53343E-02 .53343E-02 .53343E-02 .53343E-02 .53343E-02  .20000000 .23744910 .23736843 .23729545 .23722170 .23716094 .23709776 .23705295 .23700059 .23697346 .23692811 .23691991 .23687184 .23688731 .23681214 .23687317 .23671157 .23685659 .23632221 .23684650 .23437098 .23684442 .22041296 .20150192 .19999772 .20009339 .19999748 .20000343 .19999739 .19999778 .19999736 .19999738 .19999735 .19999735 .19999734 .19999734 .19999734 .19999734 .19999734 .20000000  Table VIII: Calculated values of Pressure,  , at time: 16000  The following values for pressure, temperature, molality of silica in solution and porosity were calculated for time: 16000. Position  Pressure  Temperature  Molality  Porosity  .0O00OE+OO .10000E+02 .20000E+02 .30000E+02 .40000E+02 .50000E+02 .60000E+02 .70000E+02 .80000E+02 .90000E+02 .10000E+03 .11000E+03 .12000E+03 .13000E+03 .14000E+03 .15000E+03 .16000E+03 .17000E+03 .18000E+03 .19000E+03 .20000E+03 .21000E+03 .22000E+03 .23000E+03 .24000E+03 .25000E+03 .26000E+03 .27000E+03 .28000E+03 .29000E+03 .30000E+03 .31000E+03 .32000E+03 .33000E+03 .34000E+03 .35000E+03 .36000E+03 .37000E+03 .38000E+03 .39000E+03  .21000E+02 .20892E+02 .20794E+02 .20699E+02 .20609E+02 .20524E+02 .20446E+02 .20375E+02 .20312E+02 .20256E+02 .20208E+02 .20166E+02 .20132E+02 .20103E+02 .20080E+02 .20061E+02 .20046E+02 .20034E+02 .20025E+02 .20018E+02 .20013E+02 .20010E+02 .20007E+02 .20005E+02 .20003E+02 .20002E+02 .20002E+02 .20001E+02 .20001E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02 .20000E+02  .55000E+03 .54999E+03 .55000E+03 .54998E+03 .55000E+03 .54998E+03 .55000E+03 .54998E+03 .55000E+03 .54998E+03 .55000E+03 .54997E+03 .55000E+03 .54995E+03 .55000E+03 .54992E+03 .55000E+03 .54985E+03 .55000E+03 .54966E+03 .55000E+03 .54911E+03 .55000E+03 .54741E+03 .54946E+03 .54322E+03 .51135E+03 .50000E+03 .50030E+03 .50O0OE+O3 .50001E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03 .50000E+03  .85929E-02 .85873E-02 .85844E-02 .85794E-02 .85767E-02 .85721E-02 .85700E-02 .85658E-02 .85645E-02 .85606E-02 .85602E-02 .85564E-02 .85571E-02 .85527E-02 .85553E-02 .85482E-02 .85536E-02 .85423E-02 .85527E-02 .85280E-02 .85523E-02 .84883E-02 .85521E-02 .83680E-02 .85123E-02 .80725E-02 .59947E-02 .53346E-02 .53512E-02 .53348E-02 .53354E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02 .53346E-02  .20000000 .23744944 .23739144 .23731471 .23726241 .23719208 .23714918 .23708694 .23705596 .23700140 .23698394 .23693395 .23693166 .23687922 .23689888 .23682624 .23687302 .23675067 .23685910 .23658484 .23685113 .23610066 .23684755 .23446726 .23671410 .22907370 .20578904 .20000013 .20018104 .19999976 .20000917 .19999973 .20000025 .19999968 .19999970 .19999965 .19999965 .19999965 .19999964 .20000000  98  Model Seven: Iso-thermal system with flow and mass transport This model is the open system analog to model four and the  reactive  analog to model one.  It  evaluates what could happen to an isothermal system when the fluid remains in equilibrium with the minerals. The process was calculated under the following conditions— Initial conditions (time = 0.0, for all x;)  pressure = 20.0 MPa, porosity = 20.0 percent, log permeability = —8.00, initial velocity = 0.0 m/sec, fluid composition in equilibrium with quartz,  for times greater than 0.0  pressure I  =  0  = 20.5 MPa,  and for all times and positions  temperature = 500.0 degrees kelvins, at all times, the fluid remains in equilibrium with quartz.  The results of this model are illustrated by figures 10A through 10H. In, addition to the points made by thesefigures,there are several significant differences between these results and the previous ones. • The amount of silica in solution is totally a function of the fluid pressure. • There is no  shock front  as the solution is always in equilibrium with quartz.  • Considerable numerical error has occurred and can be easily seen in figures 10E, 10F and 10J. • In contrast to models one and two, the porosity has decreased by approximately 10 percent— due to the precipation of silica. This model illustrates what could happen in an isothermal open system. Although the amount of silica in solution at a given point increase as the pressure increases, quartz is precipitated out of solution because of the material transported from the preceeding REV's. This model also leads to the inference that the the steeper the pressure gradient, the more flow, the more quartz precipitated, the faster the system seals itself.  99  Figure 1 0 A - Change in Pressure w i t h respect to t i m e a n d distance  Figure 10A illustrates the change in pressure as a function of time and distance in an isothermal  Figure 10B - Derivative of the Change in Pressure  Figure 10B is the derivative of pressure with respect to time plotted as a function of time and distance in an isothermal system. 100  Figure IOC - Change in Velocity with respect to time and distance Figure IOC illustrates the change in velocity as a function of time and distance in an isothermal  Figure 10D - Derivative of the Change in Velocity Figure 10D is the derivative of velocity with respect to time plotted as a function of time and distance in an isothermal system. 101  Figure 10E - Change in Porosity with respect to time and distance Figure 10E illustrates the change in porosity as a function of time and distance in an isothermal  Figure 10F - Derivative of the Change in Porosity Figure 10F is the derivative of porosity respect to time plotted as a function of time and distance in an isothermal system. 102  Figure 1 0 G - Change i n C o n c e n t r a t i o n w i t h respect to t i m e a n d distance  Figure 10G illustrates the change in the concentration of a component as a function of time and distance in an isothermal system with transport of that component.  Figure 10H - Derivative of the Change in  Concentration  Figure 10H is the derivative of the concentration of a component with respect to time plotted as a function of time and distance in an isothermal system with transport of that component. 103  Model Eight: Thermal Effects, Fixed Pressure Gradient. This model is the open system analog to model five or the  reactive  analog to model two. It was  calculated under the following conditions— Initial conditions (time = 0.0, for all z,-)  temperature = 500.0 degrees kelvins, porosity = 20.0 percent, log permeability = —8.00, fluid composition in equilibrium with quartz,  for times greater than 0.0  temperature  x  =  0  = 550.0 degrees kelvins,  and for all times and positions  Pressure MPa= 20.5 - (.00125a;,-u), Velocity defined by the pressures, the fluid remains in equilibrium with quartz.  This process is illustrated in figures 11A through 11F. The most obvious thing about these figures is that everything occurs in a very short distance—and extremely quickly. It is clear that the composition of the solution follows the temperature front, and that the maximum change in porosity and permeability occur at this front as well. Because the  solute  shock front  attempts to outdistance  the thermal front and because the solution is constrained to be in equilibrium with quartz, the system very quickly clogs itself with precipitated quartz. Flow is reduced to a minimum, porosity to near zero. These figures clearly illustrate that equilibrium phases cannot exist in aflowfieldwith a significant temperature gradient—the system just shuts itself down.  104  Figure 1 1 A - Change i n T e m p e r a t u r e w i t h respect to t i m e and distance  Figure 11A illustrates the change in temperature as a function of time and distance in a system with fixed pressure head and fluid velocity.  Figure 11B - Derivative  of the Change in  Temperature  Figure 11B is the derivative of temperature with respect to time plotted as a function of time and distance in a system with a fixed pressure gradient. 105  F i g u r e 11C  - Change i n Porosity w i t h respect t o t i m e a n d distance  Figure 11C illustrates the change in porosity as a function of time and distance in a system with a  Figure 11D - Derivative of the Change in Porosity  Figure 11D is the derivative of porosity respect to time plotted as a function of time and distance in a system with a fixed pressure gradient. 106  F i g u r e 1 1 E - Change i n C o n c e n t r a t i o n w i t h respect to t i m e a n d distance  Figure H E illustrates the change in the concentration of a component as a function of time and distance in a system with a fixed pressure gradient. Mass transport of the component  occurs.  Sr,  Figure 11F - Derivative of the Change in Concentration Figure H F is the derivative of the concentration of a component respect to time plotted as a function of time and distance in a system with a fixed pressure gradient. 107  Model Nine: No Pressure, Temperature or Mass Flux Constraints This model is analogous to the previous one, the primary difference being that the pressure is not invarient as a function of time. It was calculated under the following conditions— Initial conditions (time = 0.0, for all x,)  temperature = 500.0 degrees kelvins, porosity = 20.0 percent, pressure = 20.0 MPa log permeability = —8.00, initial velocity = 0.0 m/sec, fluid composition in equilibrium with quartz,  for times greater than 0.0  temperature o = 550.0 degrees kelvins, I =  pressure o = 20.5 MPa, I=  and for all times and positions  the fluid remains in equilibrium with quartz.  This model, illustrated by figures 12A to 12J yields identical information to the previous one. Equilibrium phases cannot exist in aflowfield with a temperature gradient. Thesefiguresshow that everything happens in the first nodes, and that the only change would be due to heat conduction. The extremely small space and short time in which this model occurs contributes significantly to the numerical error, which can be easily seen on most of the figures. If the REVs are made smaller in an attempt to correct this, the process will still occur only in the first REVs.  108  Figure 12A - Change in Pressure with respect to time and distance Figure 12A illustrates the change in pressure as a function of time and distance in a system with thermal and pressure gradients.  Figure 12B - Derivative of the Change in Pressure Figure 12B is the derivative of pressure with respect to time plotted as a function of time and distance in a system with thermal and pressure gradients. 109  Figure 12C - Change in Velocity with respect to time and distance Figure 12C illustrates the change in fluid velocity as a function of time and distance in a system with thermal and pressure gradients.  Figure 12D - Derivative of the Change in Velocity Figure 12D is the derivative of velocity with respect to time plotted as a function of time and distance in a system with thermal and pressure gradients. 110  Figure 12E - Change in Temperature with Figure 12E illustrates the cha  respect to time and distance  ige in temperature as a function of time and dist  thermal and pressure gradients.  ance in a system with  CO \  f"0  Figure 12F - Derivative of the Change in Temperature Figure 12F is the derivative of temperature with respect to time plotted a, a function of time and distance in a system with thermal and pressure gradients. Ill  Figure 12G - Change in Porosity with respect to time and distance Figure 12G illustrates the change in porosity as a function of time and distance in a system with thermal and pressure gradients.  Figure 12H - Derivative of the Change in Porosity Figure 12H is the derivative of porosity with respect to time plotted as a function of time and distance in a system with thermal and pressure gradients. 112  Figure 121 - Change in Concentration with respect to time and distance Figure 121 illustrates the concentration of a component as a function of time and distance in a system with thermal and pressure gradients, with transport of that component.  Figure 12J - Derivative of the Change in Concentration Figure 12J is the derivative of the concentration of a component with respect to time plotted as a function of time and distance in a system with thermal and pressure gradients, with transport of that component. 113  Overview of the Modelling The three different sets of models presented in this thesis: • Non-reactive aqueous species, which can be transported (models one, two and three), • Reactive aqueous species, which cannot be transported (models four, five and six), • Reactive aqueous species, which can be tranported (models seven, eight and nine), correspond to three of the four combinations of the following pairs of limiting conditions: • infinitely slow kinetics of reaction or infinitely fast kinetics of reaction, • no mass transport of the aqueous species or mass transport of the aqueous species. The fourth model, infinitely slow kinetics and no mass transport, is not of interest.  All systems  modelled are open to heat energy and work, but only the first and third sets of models are open to mass. Because of intermediate reaction kinetics, most natural systems fall between the first and third sets. Although there are a number of general conclusions which have been observed/inferred from the figures, the most important is a result of the third set of models.  This conclusion can  be stated as: In open systems where the temperature and pressure gradient coincide, the shock front  will attempt to outdistance the  temperature  shock front.  solute  If the reaction rates of the  solid phases with the aqueous species are rapid when compared to the rate of solute transport, the material which attempts to outdistance the  temperature  shock front  will precipitate. This will reduce  the porosity and permeability. Under extreme conditions, the effective porosity and permeability will be reduced to a point where conduction becomes the effective means of heat transport. This leads to the observation that equilibrium phases, although useful as limiting constraints in modelling and useful to clarify the numerical algorithm, probably do not exist in open systems with coincident pressure and temperature gradients.  114  13. F u t u r e  Work  The most obvious place for future work is the evaluation of more complicated models—the possibilities are endless. However, based on experience gained in the development of this thesis, there are three areas in which further work should be done before detailed modelling is attempted. These are: • Removal of the  equilibrium  constraint.  mineral  "Real systems" are often supersaturated or  undersaturated with respect to phases. If a general kinetic equation was available for precipatation and dissolution of phases, all phases would be treated in the same fashion as the 7  reactant phases are currently treated. This would more closely approximate real systems. It would ensure that small changes in fluid composition, temperature or pressure would not cause massive or instantaneous changes in the matrix. • Use of more powerful finite element techniques. One of the problems is that a significant amount of time is spent calculating chemical reactions in the REVs where very little happens—or the change is totally a result of numerical instability. A finer mesh improves the numerical error (at the expense of increased computational time) but results in many more REVs where nothing is happening. A better solution would be to use a moving mesh technique. With this method, the mesh will be very fine at the front and coarser away from it. As the front evolves, the mesh expands and contracts proportionally to the distance from the front. • Improvement of the numerical algorithm for the calculation of the properties of water and the aqueous species. In the current program, the Keenan and Keys equation of state for water has been used because of its high precision in calculating the thermodynamic and physical properties of water. Unfortunately, it is very slow. If this routine could be speeded up or a faster algorithm used, the CPU  time used to run the program would decrease significantly. After the computer  program was written, the Haar (Haar, et al., 1984) equation of state was available. It is faster and more accurate than the Keenan and Keys equation. It should be used in preference. • Better definition of the characteristic volume for R E V s of the various system parameters and improve the numerical methods which uses these definitions. 7  See equation (40) for an example of an equation for the kinetic rate of dissolution of a solid  phase. 115  The primary reasons for these improvements are: improved representation of natural systems, speed and numerical accuracy. It is critical that the equilibrium mineral constraint be removed, otherwise any system with a decreasing thermal gradient in the direction offlowwill try and seal itself as fast as the reaction kinetics will allow.  116  14.  Summary  The preceding chapters have presented an internally consistent set of equations which describe the chemical reactions occurring within a given volume element and the interaction of these reactions between each of the surrounding volume elements. The chemical reactions equations are primarily based on expansions in the derivatives of the mass action and mass balance equations. Additional functions used include the derivatives of equations constraining the activity of water and the activity coefficients of solid solution endmembers and of aqueous species. The coupling of the equations for each volume element is through modified forms of the flow, heat transport and solute transport equations. These yield changes in temperature, pressure and composition in each volume element with respect to time and distance. A wide range of situations can be modelled using these equations, for example: • geological processes in porous media, • industrial processes such as nuclear waste disposal, secondary oil recovery and in-situ leaching and mining. A list of all processes which could be modelled is limited only by the user's imagination and by the available data. The necessary model parameters and their availability are listed in figure 13. Given all of parameters for the appropriate conditions and suitable kinetic relationships for the phases and species in the system, any process could be modelled. The models presented in this thesis illustrate the limiting conditions when heat transport/solute transport/fluid flow are all in the same direction in porous media. The most important conclusion is that the speed of the solute front is controlled by the rate at which a solid containing the solute can react with the solution. If the reaction rate is infinitely fast (an equilibrium phase) and if the solubility of the solid decreases with respect to temperature, then the system will always attempt to seal itself. However, most systems with a thermal gradient have enough work energy to hydrologically re-fracture the matrix and create new porosity and permeability. The model presented in this thesis can not model this type of process. It must be emphasized that the equations and parameters used in these models cannot begin to represent the complexity and detail which occurs in natural and industrial processes. The principal 117  Figure IS - Availablity of Model Parameters  Parameter  Boundary/Initial conditions  Availability  Model-dependent, can be easily changed or modified.  (temperature, pressure, compositon) Thermodynamic data  Good—stoichiometric  phases  Poor—solid solution phases Limited—aqueous species Excellent—water Kinetic data for solid phases  Needs to be better  Physical Properties  Limited but adequate for stoichiometric phases and solid solution phases. Most fluid properties must be modelled using properties of pure water. Water properties are very well known.  Physical properties of the medium  Adequate at near surface conditions for moderate to high porosity medium. Poor to non-existent for most other conditions  External processes (eg: injection wells)  Model-dependent, can be easily changed or modified.  118  goal of this modelling is not to simulate an existing situation, but to allow a clearer understanding of how processes evolve and to help evaluate which parameters are significant and potentially the controlling factors.  119  References  Aagaard, P. and Helgeson, H . C . 1982. Thermodynamic and Kinetic Constraints on Reaction Rates among Minerals and Aqueous Solutions.  I. Theoretical Considerations.  American Journal of  Science, 282, pp. 237-285. Bear, J. 1972. Dynamics of fluids in porous media. 764 pages. Berman, R . G . and Brown, T . H . (1983) A revised equation for representation and high temperature extrapolation of the heat capacity of minerals. Trans. Amer. Geophys. Union 64, 875. Berman, R . G . and Brown, T . H . (1984) A thermodynamic model for multicomponent melts, with application to the system CaO — A I 2 O 3 — Si02.  Geochimica et Cosmochimica Acta, 48, pp.  661-678 Berman, R . G . and Brown, T . H . (1985) Heat capacity of minerals in the system Na20 CaO - MgO - FeO-  Fe203  - Al203-  and high temperature extrapolation.  Si0 2  Ti02-  H20-  C02:  —  K20—  representation, estimation,  Contributions to Mineralogy and Petrologie, 89, pages  168-183. Berman, R . G . , Brown, T . H . and Greenwood, H.J. (1985) A n internally-consistent thermodynamic data base for minerals in the system Na O 2  Si02  — Ti02  — H20  — G02.  — K20  — CaO — MgO — FeO — Fe 03 2  — A^ 03 —  Atomic Energy of Canada Technical Report (in press).  Bredehoeft, J.D and Pinder, G . F . 1973. Mass Transport in Flowing Groundwater. Water Resources Research, 9, pp. 194-210. Brown, T . H . and Skinner, B.J. 1974.  Theoretical Prediction of equilibrium Phase Assemblages in  Multicomponent Systems. American Journal of Science, 274, pp. 961-986. Burnham, C . W . , Holloway, J.R. and Davis, N . F . 1969. 1,000  Thermodynamic properties of water to  C and 10,000 bars: Geol. Soc. America Spec. P aper 132, 72p.  Bruton, C.J.  and Helgeson, H . C . 1983.  Calculation of the chemical and thermodynamic conse-  quences of differences between fluid and geostatic pressure in hydrothermal systems. American Journal of Science, 283-A, pp. 540-588. Capuano, R . M . and Cole, D.R. 1982. Fluid-mineral Equilibria in a Hydrothermal System, Roosevelt Hot Springs, Utah. Geochimica et Cosmochimica Acta, 46, pp. 1353-1364. 120  Charbeneau, R.J. 1981. Groundwater Contaminant Transport With Adsorption and Ion Exchange Chemistry: Method of Characteristics for the Case without Dispersion. Water Resources Research, 17, pp. 705-713. Chu, S. and Sposito, G. 1981.  A Derivation of the Macroscopic Solute Transport Equation for  Homogeneous, Saturated, Porous Media 2. Reactive Solutes at Low Concentration. Water Resources Research, 17, pp. 333-336. Cooper, H.H. 1966.  The Equation of Groundwater Flow in Fixed and Deforming Coordinates.  Journal of Geophysical Research, 71, pp. 4785-4790. DeDonder, Th. 1920. Lecons de Thermodynamique et de Chimie-Physique.  Gauthier-Villars.  Desai, CS. and Abel, J.F. 1972. Introduction^ the finite element Method. Van Nostrand Reinhold Company. .477 pages. Domenico, P.A. and Palciauskas, V.V. 1973. Theoretical Analysis of Forced Convective Heat Transfer in Regional Ground-Water Flow. Geological Society of America Bulletin, 84. pp. 3803-3814. Flowers, G.C. 1979.  Correction of Holloway's (1977) adaptation of the modified Redlich-Kwong  equation of state for calculation of the fugacities of molecular species in supercritical fluids of geologic interest. Contributions to Mineralogy and Petrology, 69, pp. 315-318. Fouillac, C, Michard, G. and Bocquier, G. 1977. Une methodee simulation de revolution des profiles d'alteration. Geochimica et Cosmochimica Acta, 41, pp. 207-213. Garrels, R.M. and Mackenzie, F.T. 1967. Origin of the Chemical Compositions of Some Springs and Lakes. In Advances in Chemistry Series, 67, pp. 222-242. Haar, C, Gallagher, J.S., and Kell, G.S. 1984.  NBS/NRC Steam Tables. Thermodynamic and  Transport Properties and Computer Programs for Vapour and Liquid States of Water in SI units. Hemisphere Publishing Co. Haas, J.L. Jr. and Fisher, J.R. 1976. Simultaneous evaluation and correlation of thermodynamic data. American Journal of Science, 276, pages 525-545. Harvie, C.E. and Weare, J.H. 1980. The prediction of mineral solubilities in natural waters: the  Na — K — Mg — Ca — Gl — S O4 — H2 O system from zero to high concentration at 25 C. Geochimica et Cosmochimica Acta, 44, pp. 981-998. Hazen, R.M. and Finger, L.W. 1981.  Crystal Structure of Diopside at High Temperature and  Pressure. Annual Report of the Director, Geophysical Laboratory, 1980-1981, pp. 373-375. Helgeson, H.C. 1968. Evaluation of irreversible reactions in geochemical processes involving minerals 121  and aqueous solutions-I. Thermodynamic relations. Geochimica et Cosmochimica  Acta, 32,  pp. 853-877. Helgeson, H.C. 1969.  Thermodynamics of hydrothermal systems at elevated temperatures and  pressures. American Journal of Science, 267, pp. 729-804. Helgeson, H.C. 1970a. Descriptions and interpretation of phase relations in geochemical processes involving aqueous solutions. American Journal of Science, 268, pp. 415-438. Helgeson, H.C. 1970b. A Chemical and Thermodynamic Model of Ore Deposition in Hydrothermal Systems. Mineralogical Society of America Special Paper 3, pp. 155-186. Helgeson, H.C. 1971. Kinetics of mass transfer among silicates and aqueous solutions. Geochimica et Cosmochimica Acta, 35, pp. 421-469. Helgeson, H.C, Brown, T.H., Nigrini, A. and Jones, T.A. 1970. Calculation of Mass transfer in Geochemical Processes involving Aqueous Solutions. Geochimica et Cosmochimica  Acta, 34,  pp. 569-592. Helgeson, H.C, Delany, J.M., Nesbitt, H.W.  and Bird, D.K. 1978. Summary and Critique of the  Thermodynamic properties of Rock-forming Minerals. American Journal of Science, 278-A, pp. 1-220. Helgeson, H.C,  Garrels, R.M.  and Mackenzie, F. 1969.  Evaluation of irreversible reactions in  geochemical processes involving minerals and aqueous solutions-II. Applications. Geochimica et Cosmochimica Acta, 33, pp. 455-481. Helgeson, H.C. and Kirkham, D.H. 1974a. Theoretical Prediction of the Thermodynamic Behavior of Aqueous Electrolytes at High Pressures and Temperatures: I. Summary of the Thermodynamics/Electrostatic Properties of the Solvent. American Journal of Science, 274, pp. 1089-1198. Helgeson, H.C. and Kirkham, D.H. 1974b. Theoretical Prediction of the Thermodynamic Behavior of Aqueous Electrolytes at High Pressures and Temperatures: II. Debye-Huckel parameters for activity coefficients and relative partial molal properties. American Journal of Science, 274, pp. 1199-1261. Helgeson, H.C. and Kirkham, D.H. 1976. Theoretical Prediction of the Thermodynamic Behavior of Aqueous Electrolytes at High Pressures and Temperatures: III. Equation of state for aqueous species at infinite dilution. American Journal of Science, 276, pp. 97-240. Helgeson, H.C, Kirkham, D.H. and Flowers, G.C  1981. Theoretical prediction of the thermody-  namic behavior of aqueous electrolytes at high pressures and temperatures: IV. Calculation of 122  activity coefficients, osmotic coefficients, and apparent molal and standard and relative partial molal properties to 600  C and 5 kb. American Journal of Science, 281, pp. 1249-1516.  Helgeson, H.C. and Murphy, W.M. 1983. Calculation of Mass Transfer Among Minerals and Aqueous Solutions as a Function of Time and Surface Area in Geochemical Processes. I. Computational Approach. Mathematical Geology, 15, pp. 109-130. Helgeson, H.C, Murphy, W.M. and Aagaard, P. 1984. Thermodynamic and kinetic constraints on reaction rates among minerals and aqueous solutions. II. Rate constants, effective surface area, and the hydrolysis of feldspar. Geochimica et Cosmochimica Acta, 48, pp. 2405-2432. Hill, P.G. 1982. Personal communication. Holloway, J.R. 1977. Fugacity and activity of molecular species in supercritical fluids, in Thermodynamics in geology, Fraser, D.G., editor. D. Reidel Publishing Co., pp. 161-181. Jones, G. and Talley, S.K. 1933. The Viscosity of Aqueous Solutions of Strong Electrolytes with Special Reference to Barium Chloride. Journal of the American Chemical Society, 55, pp. 4124. Karpov, I.K., Kaz'min, L.A. and Kashik, S.A. 1973. Optimal Programming for Computer Calculations of Irreversible Evolution in Geochemical Systems. Geochemistry International, 10, pp. 464-470. Keenan, J.H., Keys, F.G., Hill, P.G. and Moore, J.G. 1978. Steam Tables, Thermodynamic Properties of Water Including Vapor, Liquid, and Solid Phases (International System of Units-S.L). 156 pages. Kerrick, D.M. and Jacobs, G.K. 1981. A modified Redlich-Kwong equation for H20,  C02  C02  and H20-  mixtures at elevated pressures and temperatures. American Journal of Science, 281, pp.  735-767. Kestin, J. 1979. The Transport Properties of Water Substance in Water and Steam, Their Properties and Current Industrial Applications, edited by J. Straub and K. Schemer, pp. 283-302. Kestin, J., Khalifa, H.E. and Correia, R.J. 1981a. Tables of the Dynamic and Kinematic Viscosity of Aqueous KC1 Solutions in the Temperature Range 25-150 C and the Pressure Range 0.1-35 MPa. Journal of Physical and Chemical Reference Data, 10, pp. 57-70. Kestin, J., Khalifa, H.E. and Correia, R.J. 1981b. Erratum: Tables of the Dynamic and Kinematic Viscosity of Aqueous KC1 Solutions in the Temperature Range 25-150  C and the Pressure  Range 0.1-35 MPa. Journal of Physical and Chemical Reference Data, 10, pp. 1203. Kestin, J., Khalifa, H.E. and Correia, R.J. 1981c. Tables of the Dynamic and Kinematic Viscosity of 123  Aqueous NaCl Solutions in the Temperature Range 20-150 C and the Pressure Range 0.1-35 MPa. Journal of Physical and Chemical Reference Data, 10, pp. 71-88. Kestin, J., Khalifa, H.E. and Correia, R.J. 1981c. Erratum: Tables of the Dynamic and Kinematic Viscosity of Aqueous NaCl Solutions in the Temperature Range 20-150  C and the Pressure  Range 0.1-35 MPa. Journal of Physical and Chemical Reference Data, 10, pp. 1203. Kirkham, D.H., Walther, J., Delany, J., and Flowers, G. 1978. SUPCRT (Internal Memo), Computer Program Library, Prediction Central, Department of Geology and Geophysics, University of California, Berkeley. 20 pages. Konikow, L.F. 1977. Chloride Movement in the Alluvial Aquifer at the Rocky Mountain Arsenal, Colorado. U.S. Geological Survey Water Supply Paper, 2044. 43 pages. Konikow, L.F. and Grove, D.B. 1977. Derivation of Equations describing Solute Transport in Ground Water. U.S. Geological Survey Water-Resources Investigations 77-19. 30 pages. Kwong, Y.T.J., Brown, T.H. and Greenwood, J.H. 1982. A thermodynamic approach to the understanding of the supergene alteration at the Afton copper mine, south-central British Columbia. Canadian Journal of Earth Sciences, 19, pp. 2378-2386. Lasaga, A.C. 1984. Chemical Kinetics of Water-Rock Interactions. Journal of Geophysical Research, -  89, B6, pp. 4009-4025.  Lichtner, P.C. 1985. Continuum model for simultaneous chemical reactions and mass transport in hydrothermal systems. Geochimica et Cosmochimica Acta, 49, pp. 779-800. Mercer, J.W. and Pinder, G.F. 1979. Finite Element Analysis of Hydrothermal Systems in Finite Element Methods in Flow Problems, pp. 401-414. Norton, D. 1978. Sourcelines, Sourceregions, and Pathlines for Fluids in Hydrothermal Systems Related to Cooling Fluids. Economic Geology, 73, pp. 21-28. Norton, D. 1979. Transport phenomena in hydrothermal systems: the redistribution of chemical components around cooling magmas. Bulletin Mineralogy, 102, pp. 471-486. Norton, D. 1982.  Fluids and heat transport phenomena typical of copper-bearing pluton envi-  ronments, southeastern Arizona. In Advances in Geology of the Phorphyry Copper deposits, Southwestern North America, ed: S.R. Titley, pp. 59-72. Norton, D. 1984. Theory of Hydrothermal Systems. Ann. Rev. Earth Planet. Science, 12, pp. 155-177. Norton, D. and Knight, J. 1977. Transport phenomena in hydrothermal systems: Cooling plutons. 124  American Journal of Science, 277, pp. 937-981. Out, D.J.P. and Los, J.M. 1980. Viscosity of Aqueous Solutions of Univalent Electrolytes from 5 to 95  C. Journal of Solution Chemistry, 9, pp. 19-35.  Parkhurst, D.L., Plummer, L.N., and Thorstenson, D.C. 1978. Chemical Models in Ground-Water Systems. Geological Society of America Abstracts, 7, pp. 468. Parkhurst, D.L., Plummer, L.N. and Thorstenson, D.C. 1980. P H R E E Q E — A computer program for geochemical calculations. U.S. Geological Survey, Water-Resources Investigations 80-96. 216 pages. Perkins, E.H. 1980. A Reinvestigation of the Theoretical Basis for the Calculation of Mass Transfer in Geochemical Processes involving Aqueous Solutions. MSc Thesis, Department of Geological Sciences, University of British Columbia, Vancouver, B.C., Canada. 149 pages. Perkins, E.H., Brown, T.H. and Berman, R. 1985. PT-SYSTEM, TX-SYSTEM, PX-SYSTEM— Three programs which calculate Pressure-Temperature-Composition Phase Diagrams.  Cur-  rently submitted to Computers and Geology. Pfeifer, H.R. 1977.  A Model for Fluids in Metamorphosed Ultramafic Rocks.  Observations at  Surface and Subsurface Conditions (High pH Spring Waters). Schweizerische Mineralogische und Petrographische Mitteilungen 57, pp. 361-396. Pfeifer, H.R. 1981. A Model for Fluids in Metamorphosed Ultramafic Rocks. III. Mass transfer under amphibolite facies conditions in olivine-enstatite rocks of the Central Alps, Switzerland. Bulletin Mineralogy, 104, pp. 834-847. Pickens, J.F. and Grisak, G.E. 1979. Finite-Element Analysis of Liquid Flow, Heat Transport and Solute Transport in a Ground-Water System: 1. Governing Equations and Model Formulation. Report by Contaminant Hydrogeology Section, Hydrology Research Division, Inland Waters Directorate, Environment Canada. 39 pages. Pickens, J.F. and Lennox, W.C. 1976. Numerical Simulation of Waste Movement in Steady Groundwater Flow Systems. Water Resources Research, 12, pp. 171-180. Pinder, G.F. 1973. A Galerkin-Finite Element Simulation of Groundwater Contamination on Long Island, New York. Water Resources Research, 9, pp. 1657-1669. Pinder, G.F. and Gray, W.G. 1977. Finite Element Simulation in Surface and Subsurface Hydrology. 295 pages. Prigogine, I. and Defay, R. 1954. Chemical Thermodynamics, 125  translated  by  D.H. Everett. Longmans  Green. 543 pages. Ralph, R.L. , Hazen, R.M. and Finger, L.W.  1981.  Cell parameters of Orthoenstatite at High  Temperature and Pressure. Annual Report of the Director, Geophysical Laboratory, 19801981, pp. 376-379. Rao, P.V., Fortier, K.M. and Rao, P.S.C. 1981. A Stochastic Approach for Describing ConvectiveDispersive Solute Transport in Saturated Porous Media. Water Resources Research, 17, pp. 963-968. Raz, U. 1983. Thermal and Volumetric measurements on quartz and other substances at pressures up to 6 kbars and temperatures up to 700  C. PhD Thesis Diss. nr. 7386, Swiss Federal  Institute of Technology (ETH), Zurich. 91 pages plus tables. Read, M.H. 1982. Calculation of Multicomponent Chemical Equilibria and Reaction processes in systems involving Minerals, Gases and an Aqueous phase. Geochimica et Cosmochimica Acta, 46, pp. 513-528. Reddell, D.L. and Sunada, D.K. 1970. Numerical Simulation of Dispersion in Groundwater Aquifers. Hydrology Papers, Colorado State University, Number 41. 79 pages. Redlich, O. and Kwong, J.N.S. 1949. An equation of state. Fugacitites of gaseous solutions. Chemical Review, 44, pp. 233-244. Remson, I., Hornberger, G.M., and Molz. 1971. Numerical Methods in Subsurface Hydrology with an introduction to the finite element method. Wiley-Interscience. 389 pages. Robie, R.A., Hemingway, B.S. and Fisher, J.R. 1978. Thermodynamic Properties of Minerals and Related Substances at 298.15 K and 1 Bar (10 Pascals) Pressure and at Higher Temperatures. 5  Geological Survey Bulletin 1452. 456 pages. Schwartz, F.W.  and Domenico, P.A. 1973.  Simulation of Hydrochemical Patterns in Regional  Groundwater Flow. Water Resources Research, 9, pp. 707-720. Smith, L. and Schwartz. F.W.  1981. Mass Transport 3. Role of Hydraulic Conductivity Data in  Prediction. Water Resources Research, 17, pp. 1463-1479. Sorey, M.L. 1978. Geohydrology of Geothermal Systems. United States Geological Survey Professional Paper 1044-D. 25 pages. Straus, J.M. and Schubert, G. 1977. Thermal Convection of Water in a Porous Medium: Effects of Temperature and Pressure Dependent Thermodynamic and Transport Properties. Journal of Geophysical Research, 82, pp. 325-333. 126  Tang, D.H., Frind, E.O. and Sudicky, E.A. 1981.  Contaminant  Transport in Fractured Porous  Media: Analytical Solution for a Single Fracture. Water Resources Research, 17, pp. 555-564. Thompson, J.B. 1967. Thermodynamic Properties of Simple Solutions. In Researches in Geochemistry, edited by P.H. Abelson, volume II, pp. 340-361. Uematsu and Franck. 1980. Static Dielectric Constant of Water and Steam, Jour. Physical. Chemical Reference Data, 9, pp. 1291. Vandersande, J.W. and Pohl, R.O. 1982. Negligible Effect of Grain Boundaries on the Thermal Conductivity of Rocks. EOS, 63, pp. 814. Villas, R.N. and Norton, D. 1977. Irreversible Mass Transfer Between Circulating Hydrothermal Fluids and the Mayflower Stock. Economic Geology, 72, pp. 1471-1504. Watson, J.T.R., Basu, R.S. and Sengers, J.V. 1980. An Improved Representative Equation for the Dynamic Viscosity of Water Substance. Journal of Physical Chemical Reference Data, 9, pp. 1254-1290. Wolery, T.J. 1979. Calculation of chemical equilibrium between aqueous solutions and minerals: the EQ3/EQ6 software package, UCRL-52658, University of California, Lawrence Livermore Laboratory, Livermore, California. 44 pages. Wolery, T.J. 1980.  Chemical modelling of geological disposal of nuclear waste: progress report  and a perspective. UCRL-52748, University of California, Lawrence Livermore Laboratory, Livermore, California. 66 pages. Wolery, T.J. and Walters, L.J. 1975. Calculation of Equilibrium Distribution of Chemical Species in Aqueous Solutions by Means of Monotone Sequences. Journal of Mathematical Geology, 7, pp. 99-115. Wood, J.R. and Hewett, T.A. (1982) Fluid convection and mass transfer in porous sandstones: a theoretical model. Geochimica et Cosmochimica Acta 46, pp. 1707-1713.  127  Appendix One: Summary of the Thermodynamic Relationships  The equilibrium constant is related to the thermodynamic properties of each phase, species and component in an equilibria by:  -RTki  K = AG' = AG prod  ln K is the logarithm of the equilibrium constant.  — AG  O - l )  r e a c i  T is the temperature in kelvins, R is the gas  constant. A G is the Gibbs free energy, superscripted "r" to indicate of reaction, "prod" to indicate the sum of the free energy of the products and "read? to indicate the sum of the free energy of the reactants. The Gibbs free energy of formation of any phase or species can be related to its enthalpy and entropy of formation by: AG;.T.P  AGf.T.p,  AH/.T.P  =  AH/.T.P  - TASf.T.p  {A - 2a)  and ASf.j.p are the standard molal Gibbs free energy of formation, the standard  molal enthalpy of formation and the standard molal entropy of formation at the subscripted temperature and pressure from a reference set of components at the same temperature and pressure. 8  Equation (A-2a) is awkward to evaluate as the properties of the components must also be evaluated at the temperature and pressure interest. In any balanced reaction, the properties of the components must cancel. Taking advantage of this, the free energy of a phases or species can be defined in a variety of other ways. For example, it is often denned as a function of the enthalpy of formation and the third law entropy, yielding:  AGT.P  =  AH/.Tr.Pr + (H  TP  - HTr Pr) - TSTr  Pr  - T(STP  - STr  )  Pr  (A - 2b)  H° is the standard molal enthalpy at the subscripted conditions and S° is the third law entropy at the subscripted conditions. Another very common definition used to define the apparent molal 8  Generally the reference set of components are the the stable form of the elements or the stable  form of the oxides. 128  Gibbs free energy  AG  T.P  (AGT.P),  =  which has been used extensively by Helgeson is:  G% Tr.Pr  AG' 'f.T.P  =  AGf.Tr.Pr  -  AHfTP  + (H°T,P  + (E°r  T(ST  P  P  - H°Tr!Pr)  ~ S°T,P(T-  - H^r.pr)  S^  R P R  -  Sj.T  Pr  (T  Tr) -  -  Tr) -  T(S^P  -  5° . ) r  Pr  TrSfTTpT  [A-2c)  )  Equation (A-2b) will be used throughout this thesis. The enthalpy and the third law entropy of any phase or species at any temperature and pressure can be related to the enthalpy and third law entropy of that phase or species at the reference temperature and pressure by:  and (A-4)  In equations (A-3) and (A-4), V° is the molar volume and Cp is the molar heat capacity at constant pressure. Evaluation of the integrals in equations (A-3) and (A-4) depends on the equations used to represent the molar volume and the heat capacity. The equations used for solid phases are different than those for aqueous species, both of which are different than those for gases. The equations used for solid phases, aqueous species and water will be discussed in separate sections.  129  S o l i d Phases  The coefficient of thermal expansion (a) is defined as:  (A-5) and the coefficient of compressibility (fi) as: fdV°\  -1  With the notable exceptions of quartz (Raz, 1983), diopside (Hazen and Finger, 1981), enstatite (Ralph, Hazen and Finger, 1981) and a limited number of other phases which have measured at low temperatures in the diamond anvil cell, the isothermal compressibility is known only at room temperature and the coefficient of thermal expansion is only known at one atmosphere. The data generally indicate that in the absence of phase transitions, the isothermal compressibility of most silicates can be assumed to be independent of pressure. Integrating equation (A-6) with this assumption, the volume as function of pressure at constant temperature is: yo  _  yo  c  VlPr(l-0(P-Pr))  -0[P-Pr)  (A -7)  Equation (A-7) is only an approximation and does not represent the volume of most phases accurately. However, within the limits of the low pressure experimental data, the linear approximation of equation (A-7) is equally valid to an exponential approximation. The heat capacity of most solid phases can be accurately represented within the range of the experimental data using the Maier-Kelly expression, which is:  Cp=  a+bT+  cT~ 2  This equation does not yield a constant heat capacity at high temperatures and it cannot represent the heat capacity of a phase undergoing a phase transition.  However, a wealth of data in this  form exists. Other heat capacity equations are used (for example, Haas and Fisher (1976)) but the most satisfactory form is that of Berman and Brown (1983, 1985). Although it does not fit the experimental data as well as some of the other forms, it doesfitthe data within the experimental 130  error, extrapolates well and agrees with the limiting values for heat capacity at high temperatures. Their equation is: Cp =  k0 + h T~ 0- 5  +  k2 T~ 2  + k3 T~ 3  (A  - 8)  wherefciand k2 are less then or equal to zero. Equations (A-5), (A-7) and (A-8) can be substituted into equations (A-3) and (A-4), and the result into equation (A-2b) to obtain the apparent molal Gibbs free energy of a solid phase as a function of temperature and pressure. It is:  AG$,, = Aflfry.p, -  TAS°Tr.r,  /  +  H  +  VT.pr  +fc( T  (T - Tr)  f-2  _ -2 Tr  -2-0 ((P  T  +  -3_  -  TrTh  -3\  Tr  3.0  - P r ) ( l + pPr)  -  J  -{P 2  P  - Pr )) 2  (A -  9)  This equation does not make any provision for the possibility of any phase transitions. If a lambda, second or higher order phase transition exist in the temperature range of interest, then the above equation must be modified to include a term expressing the additional energy. Equations for lambda type transitions and for disorder transformations are given by Berman and Brown (1985). An alternative method used by Helgeson et al. (1978), is to use coefficients for the heat capacity and, if necessary for volume, which are only applicable to a given temperature range. 'Different coefficients must be used for the other temperature ranges. Typically, these temperature ranges correspond to the temperature space between transitions for the given phase but may also correspond to the range between transitions in the reference material. As noted in Helgeson et al. (1978), this method will not yield correct results at pressure unless the temperature of transition is independent of pressure. The change in volume of most solid phases is relatively small at low to moderate pressures and temperatures. If the region of pressure-temperature space is limited to region where the data for aqueous species from Helgeson, Kirkham and Flowers (1981) is defined (less then 5 kilobars and 600  C), it is reasonable to assume that the isothermal con traction term in equation (A-9) is  negligible and that the volume of a solid phase is a constant. The Gibbs free energy of a solid solution mineral can be calculated from the properties of the endmembers and from an equation which describes the excess free energy of mixing. For a given 131  composition, the Gibbs free energy of a ^-component solid solution can be written:  AG  isol  fc Y  k  X{AG°  +  «'=!  TX,RT  ln X; +  AG'  (A  -10)  »'=1  A G is the Gibbs free energy, superscripted "soP to indicate solution, "°" to indicate the apparent molar Gibbs free energy and "ex" to indicate the excess Gibbs free energy, a is the number of equivalent sites and X, is the mole fraction of the i'th endmember. The Gibbs free energy of the endmembers is calculated using the equations presented previously in this appendix. The excess Gibbs free energy is dependent on composition, temperature and pressure. Berman and Brown (1984) have developed a general equation describing the excess free energy of a solid solution using an p'th degree polynomial. It is:  (A.- 11)  where k is the number of components.  .,3  ,• is the interaction term between the subscripted  endmembers and is obtained by fitting to experimental data sets. Under the appropriate conditions, this model reduces to the Margules model presented by Thompson (1967). There are various sources of thermodynamic data which can be used to evaluate these expressions, for example: Robie, Hemingway and Fisher (1978), Helgeson, Delany, Nesbitt and Bird (1978), Berman, Brown and Greenwood (1985).  132  Aqueous Species The various thermodynamic and physical properties of aqueous species vary significantly throughout pressure and temperature space. The experimental data is limited. In fact, the properties of most aqueous species are only known at one bar and temperatures below 100  C. Data not on the boiling  curve is almost non-existant. However, as these thesis is concerned with developing the equations to "model geological process", most of which do not occur on the boiling curve, only the equations applicable under high temperature and pressures conditions will be discussed. In a series of four papers, Helgeson and co-workers (Helgeson and Kirkham (1974a, 1974b, 1976), and Helgeson, Kirkham and Flowers (1981)) analyzed the existing high pressure and temperature data pertaining to aqueous species. Fitting the available (limited) data and extrapolating it under various practical and theoretical constraints, they developed equations which describe the partial molal properties of aqueous species at pressures up to 5 kilobars and temperatures to 600  C. They  proposed that the partial molal volume of an aqueous species can be accurately represented as a function of pressure and temperature using the following expression:  V„ is the volume of the s'th aqueous species. a , a , , a l 8  2  9  a^^ and d„ represent temperature and  3  pressure independent coefficients for the s'th aqueous species, given by Helgeson et al. (1981). They also proposed that the heat capacity at constant pressure for the s'th aqueous species could be represented by:  Op,  =  CL,  2a3.s (P  c.« T 2  +  T-ds  - Pr)  + a ,2 {P 2  (T-8,)  a  4  -  Pr 2)  3  (A - 13) Ci.„ and C2. are temperature and pressure independent constants for the s'th. aqueous species, also s  given by Helgeson et al. (1981). w  s  is defined by: abs  and abs  =  V Z>  (A-14)  rj is a constant (6.94657 * 10 A Joules/mole). Zs and rs are the charge and the effective electrostatic 5  radius of the s'th ion, respectively. The subscript "H +" 133  indicates hydrogen ion.  ew is the dielectric constant of pure water and wasfitto a fourth degree power function of temperature and density by Helgeson and Kirkham (1974a). It is defined by:  i-i  4  ^ =£ X ^ M 7 V  .  (A-15)  ,'=0 J=0  €jj arefitcoefficients and are given in table LX. Uematsu and Franck (1980) have reviewed all existing experimental data and numerical representations of the dielectric constant of water. They concluded that equation (A-15) represented the data within experimental error but suffered from two flaws. • It can only be used for temperatures below 550 C and for densities greater than 0.4 g /cm . 3  It could not be used for extrapolation. • It exhibits a undulatory pattern through the experimental data, thus derivatives calculated with this equation should not be used. They proposed instead that the dielectric constant of water be represented by:  ew = 1 + -£p* + (|L +  ffl3  + a4 ) ( *) + (|L ^ T* + a7 (T*) 2) 2  r  p  +  (p*)  3  where pw is the density of pure water and T the temperature. The constants used in equation (A-16) are defined in table X. The enthalpy and entropy of the s'th aqueous species at any given temperature and pressure can then be expressed using equations (A-3), (A-4), (A-12) and (A-16). This leads to the following expression for the apparent molal Gibbs free energy of the s'th aqueous species: AG,,T.P = AH3,f.Tr.Pr +  +  C  a  - TS^Pr  + cUs (j-Tr-  (jr^)  Tin  . . ( r - T r - ( T - ^ ) l n ( ^  7  ) )  2 ( ., (T - 8.) q ., T) (P - Pr) + (a2.8 (T - 6,) + a4.s T) (P 2 - Pr 2) fll  3  2{T-6.) T-Tr\(dUem.T.P\  1 ^W.TT.PT  £W.T.P  ZW.TT.PT  J  \  { A  _  i 7 )  dT  This equation is consistent with equation (A-2b). The Gibbs free energy of any aqueous solution can be calculated at any given temperature and pressure by: ns  AG"  0, R  = v-"» ( AG° n  F  + RTlna9)  134  .  (A - 18)  Table TX: Coefficients for Equation A-15 Coefficients for equation (A-15) as taken from Helgeson and Kirkham (1974). ti.i =&ylO*-'' fi.J  i  j 0 1 2 3 4  0  i  2  5  4.39109592 -2.18995148 1.82898246 1.54886800 -6.13542375  -2.33277456 1.00498361 -2.08896146 -6.13941874  4.61662109 -1.35650709 1.60491325  -4.03643333 5.94046919  4 1.31604037  ki.j  > i  k  0  1  2  5  0 1 2 3 4  2 2 1 2 1  0 0 -1 -2  -3 -3 -4  -6 -7  Table X : Coefficients for Equation A-16 Coefficients for equation (A-16) as taken from Uematsu and Franck (1980). p T  *  = p/Po = T/T 0  Po  1000.0Kg/M  T0  298.15degK  3  A(5)  = 7.62571 = 244.003 = -140.569 = 27.7841 = -96.2805  A(6)  41.7909  A(7)  = -10.2099  A(8)  -45.2059  A(l)  A{2) A{3) A{4)  A{9)  A(10)  = 84.6395 = -35.8644  135  -9  A G is the Gibbs free energy and is subscripted "soP  to indicate of solution or "°" to indicate the  apparent molar Gibbs free energy. a„ and ra are the activity and number of moles of the s'th aqueous 8  species (including water), respectively. Helgeson and Kirkham (1974b, 1976) and Helgeson et al. (1981) discuss in detail the derivation of these equations, their limitations and the calculation of the various constants. The above section is only a brief summary.  Water Some phases, especially gases, have properties that vary widely throughout pressure and temperature space. Certainly, the best known is water. Many different equations with various functional forms have been proposed to be used in describing its physical and thermodynamic properties, thus allowing the integrations in equations (A-3) and (A-4). Most equations which can accurately calculate the properties of water, are high-order polynomials (often with logarithmic and exponential terms) representing the Gibbs free energy (for example, Burnham, Holloway and Davis, 1969), or the Helmholtz free energy (for example, Keenan, Keys, Hill and Moore, 1978, Haar, Gallagher and Kell, 1984). These equations are typically functions of temperature and density or of temperature and pressure. A variety of corresponding state equations have also been suggested, the most accurate of which generally use adjustablefitparameters. The most common are variations on the RedlichKwong equation (Redlich and Kwong (1949), Holloway (1977), Flowers (1979), Kerrick and Jacobs (1981), among many others). By taking derivatives or integrating these equations and combining them with various thermodynamic equations of state, all thermodynamic properties can be calculated.  Although the  corresponding state equations are often accurate over a restricted pressure-temperature range in describing the primary fit property (either the Gibbs free energy or the volume), thermodynamic properties obtained from the derivatives of these equations are typically highly inaccurate. One of the most accurate equations of state is the Keenan and Keys equation, which is limited to pressures below one kilobar. P.G. Hill (1982) has proposed a modification of the fit parameters for the Keenan and Keys equation of state for water which allows the calculation of the properties of water to temperatures greater than 1300  C and pressures greater than 10 kilobars, including  the low pressure region. The fundamental form of the Keenan and Keys equation expresses the Helmholtz free energy (F) as a continuous function of the temperature and of the density of water in both the liquid and 136  gas regions. It is of the form:  T  (A- 19)  (In p + pQ(p, T))  = F°( T) + RT  F .P  where: 6  C  T  F ° { T ) ^ Y . j ^ l  +  G  ^  h  i  T  +  ^ Y  G  (A-20)  and: 7 Q(p, T) =  (T-  T e)  / 8  £ (T - T. ) J  2  y  i=l  \  10  £ A,-,;  (p - p*)''" + <T - p £  Vi=l  1  4  8  ^P*'~  1=9  9  M - 21)  /  T, T, p, i2 and T are the temperature in kelvins, 1000 / T, density in g/cm , the gas constant 3  c  (4.6151 bar cm /g 3  K) and a constant, 1.544912. The remaining coefficien ts are givenin tables XI  and XII. As these equations apply only to water, the parameters have not been subscripted 'w'. Values for the Gibbs free energy of water can be directly calculated from: G=F  + PV  (A-22)  Expressions relating each of the different thermodynamic variables to the Helmholtz free energy are given in Keenan et al. (1978), Helgeson and Kirkham (1974) or in most thermodynamic texts. An alternative to the Keenan and Keyes equation of state for is the Haar equation of state for water. It is more accurate and faster. It is similiar to the Keenan and Keys equations in that it calculates the Helmholz free energy as a function of density and temperature and that all other parameters are derived from the Helmholz free energy. It should be used in preference to the Keenan and Keys equation. Throughout this thesis, the activity of all pure substances has been assumed to be one at all temperatures and pressures. In addition, the third law entropy of all substances is assumed to be zero at absolute zero. The Keenan and Keys equation, along with most compilations of steam properties, assumes that the third law entropy of water is zero at the triple point of water. This must be taken into account when using this equation.  137  Table X I : Coefficients for E q u a t i o n A - 2 1  Coefficients for equation (A-21) as given by Hill (1982).  Ai.j  j i  1  2  8  4  1 2 3 4 5 6 7 8 9 10  15.08935547 -72.10865784 152.4410858 -200.0392914 193.2660826 -142.1213989 78.26339722 -.2260081482 -229.34576423 -224.9741058  -1.126399040 -8.325212479 17.59562683 -16.59400940 5.603165627 -127.4073334 93.21633911 76.98554993 49.11743464 -408.3481445  6.248408318 -25.87362671 50.28768921 -64.65473938 0.0 0.0 0.0 0.0 -155.2604218 -653.3615723  -0.7511532307 -2.641253471 4.8491477997 3.395516396 0.0 0.0 0.0 0.0 -4.012123108 -80.93405151  i  5  6  7  1 2 3 4 5 6 7 8 9 10  -2.360856056 9.403068542 -18.87019348 -22.99574280 0.0 0.0 0.0 0.0 55.59095764 229.297058  -1.041758537 -4.143721581 -7.860260963 5.793392181 0.0 0.0 0.0 0.0 18.63822937 108.8137970  -.108-222130 7.4030921459 -.4694258571 0.01748328283 0.0 0.0 0.0 0.0 0.6496112347 122.8528786  T a b l e X I I : Coefficients for E q u a t i o n s A - 2 0 a n d A - 2 1  Coefficients for Equations (A-20) and (A-21) as given by from Hill (1982). i  Ci  1 2 3 4 5 6 7 8  1857.065 3229.12 -419.465 36.6649 -20.5516 4.85233 46.0 -1011.249  Paj .634 1.0 1.0 1.0 1.0 1.0 1.0  —  1~aj 1.545 2.5 2.5 2.5 2.5 2.5 0.0  —  138  Appendix Two: Program Description  A computer program has been written to apply the theory developed in this thesis. The program is written in F T N 5, a Control Data Corporation (CDC) implementation of ANSI standard FORTRAN 77 and has been run on a Cyber 825 computer under the NOS 4.1 operating system. No FTN5 extensions of ANSI standard FORTRAN 77 have been used, thus conversion to other operating systems is relatively easy. The program models the chemical, thermal and mechanical effects as the result of one dimensional flow through porous media. The flow is the result of a pressure gradient and will redistribute thermal energy by convection and by conduction. Mass is redistributed by the flow process and by dispersion. These processes cause the spatial and temporal dissolution/precipitation of solid phases and a spatial and temporal change in the composition of the fluid. This version of the program uses the pressure, temperature and composition at nodes 1 and n (in a system of n nodes) as the boundary conditions—these values can be invariant or functions of time. The program is listed in appendix seven. The input for the program has been divided into three files. The first contains information about the physical problem, the second contains the thermodynamic properties of all phases, species and gases, the last contains the initial chemical composition of the nodes. These files are read by fortran units 1, 2 and 3, respectively. The output is written on six different units, fortran units 6, 7, 8, 9, 10 and 11. Fortran unit 6 output is a complete record of the run data, including input verification and error messages. A partial listing of typical output is given in appendix six. Fortran unit 7 output is a condensed listing of the pressures and fluid velocities at the nodes for each time step. Fortran unit 8 output is a condensed listing of the temperatures at the nodes for each time step. The information written to fortran unit 9 is a condensed listing of the composition at each node (both fluid and matrix), porosity and permeability for each time step. Fortran unit 10 output is a condensed listing of the log molalities and log activities of the aqueous species for each time step. Fortran unit 11 output is a condensed listing of the number of moles and the change in the number of moles of the solid phases for each time step. The output written to units 7 to 11 are intended as input for plot programs. They are described in more detail below. 139  It must be emphasized that this program needs relatively large amounts of central memory (CM) and takes a minimum of thousands of seconds of central processor time (CPU seconds) for all but the most trivial of runs. The accuracy of the program is totally dependent on the quality of the thermodynamic data, the medium data (porosity, permeability, etc), the user specified error limits and, most important, the size of the time step and the number of nodes. The speed of the program is directly proportional to a power of the number of nodes and to the size of the time step.  I n p u t For F o r t r a n U n i t 1 — T h e Physical  Constraints  This file contains the temperature, pressure, porosity, permeability, and all other parameters for each node at the initial time. These define the initial state of the media, the initial chemical conditions, several switches and error limits. The initial lines in this file are the: TITLE  cards, which can be up to 100 characters long. There can be as many title cards as need be,  including blank lines. The last title line contains the word  START,  beginning in column one.  If the S T A R T title line is omitted, then the entire file will be read as a title. The next card contains a character string which defines the type of following data. The possible strings are: A L P H a ,  CHEMical,  POROsity, PRESsure,  COMPosition, DISTance, E N D , ERROr, N O D E ,  STEP, STOP, TEMPerature,  THICkness,  TIME, WEIGht.  PERMeability,  Only the first  four characters are necessary. Each string can be specified more than once, although for some, there is no advantage in doing so. ff the string reads: A 1 P H — t h e n a minimum of 2 lines follows. The first following line contains an integer value which indicates how many lines follow (format: 15). These lines contain the names of the components used for flow calculations and their associated longitudinal dispersivity (format: 2A4,8X,Fl0.5). Only these components will be transported and they must correspond to an aqueous chemical species in the data base attached to fortran unit 2 (see the description of unit 2 below). If the  system is described by nc chemical components, then only nc — 1 components can be  specified. These components, water and if necessary, other components chosen automatically by the program will be the reference compositional basis. All dispersivities are positive, non-zero, real numbers (units: meters/sec). Water will always have a dispersivity of zero and can never be specified by the user. The transport equation will be solved only if component-dispersivity pairs are present. 140  CHEM—then chemical reactions will be calculated during this run. The default is that NO reactions will be calculated. COMP—then the next line contains a formula which indicates which chemical elements will be considered during this run. The formula is a character string and has the form: CA(1)MG(1)AL(1)SI(1)0(1)H(1). No chemical elements can be referenced which are not defined in the thermodynamic data base (see description of fortran unit 2 below).  The coefficients assigned to each of the chemical  elements must be non-zero but their value is not important. DIST—then a minimum of 2 lines follows. The first line contains the number of distances which will be assigned (NUM) and the index of the first node to which they will be applied (ISTART) (format: 215). The next line(s) contains the distance between nodes ISTART and ISTART + 1, nodes ISTART + 1 and ISTART + 2, up to and including the distance between nodes ISTART + NUM - 1 and ISTART + NUM (units: meters, format: 8F10.5). END—then no more data is read from this file. If this string is not present, the program reads to the end of file (EOF) or to the string STOP. ERRO—then two lines follows. The line contains three error limit/test values (format: 3E12.5). The first value is used in the pressure, the second in the temperature, and the last in the flow calculations. Their values must be between zero and one. If out of this range, a default of one is used. They are applied to the test: ABS(( where x„ +  i  •Sn.+i  %n)/%n) ^  error limit value  and x„, are the values of the parameters at iteration n+1 and iteration n, respectively.  The iterations continue until the test is pasted. The second Une contains three counters which indicates the maximum number of iterations for each time step (format: 315). The default value is five. MAXP—then one line follows containing the maximum pressure for node 1, the length of time used to raise to this pressure, and the time at which the increase begins (format: 3F10.3). MAXT—then one line follows containing the maximum temperature for node 1, the length of time used to raise to this temperature, and the time at which the increase begins (format: 3F10.3). NODE—then one line follows containing the number of nodes in the system (format: 15). PERM—then a minimum of 2 lines describing the initial permeabilities follows. The first contains the number of nodes which will be assigned and the index of the first node (NUM, ISTART, 141  format: 215). The next line(s) contains the logarithm (base 10) of the permeability (units: square meters, format: 8F10.5). The first value corresponds to node with the index ISTART, the next to the node with the index ISTART + 1. The last corresponds to the node with the index ISTART + NUM - 1. PORO—then a minimum of 2 lines describing the initial porosities follows. The first contains the number of nodes which will be assigned and the index of the first node (NUM, ISTART, format: 215). The next line(s) contains the porosities (format: 8F10.5). The first value corresponds to the node with the index, ISTART, the next to the node with the index ISTART + 1. The last corresponds to the node with the index ISTART + NUM  - 1.  PRES—then a minimum of 2 lines describing the initial pressures follows. The first contains the number of nodes and the index of thefirst,node (NUM, ISTART, format: 215). The next line(s) contains ABS(NUM) initial pressures in MPa (format: 8F10.5). The first value corresponds to the node with the index, ISTART, the next to the node with the index ISTART + 1. The last corresponds to the node with the index ISTART + NUM  - 1. If NUM  is negative, then the  pressures will be held constant through all of the calculations. STEP—then the next line contains four integers (NSTEP, ITERT,- ITERC, ITERM, format: 415). NSTEPS is the maximum number of steps to be taken this run. For the first attempt, a step size of zero (the default) should be used to verify the initial conditions and the data. ITERT is the number of temperature steps for each pressure step and ITERC is the number of transport steps taken for each temperature step. STOP—then no more data is read from this file. If this string is not present, the program reads to the end of file (EOF) or to the string END. TEMP—then a minimum of 2 lines defining the initial temperatures follows. The first contains the number of nodes (NUM) and the index of the first node (NUM, ISTART, format: 215). The next line(s) contains ABS(NUM) initial temperatures in degrees kelvins (format: 8F10.5). The first value corresponds to the node with the index, ISTART, the next to the node with the index ISTART + 1. The last corresponds to the node with the index ISTART + NUM  - 1. If NUM  is negative, then these temperatures will be held constant through all of the calculations. THIC—then the next line contains the Y dimension in meters. By default, this value is equal to one meter (format: F10.4). The Z dimension is equal to the Y dimension. The X direction is the direction along which flow occurs and is set by the DIST command. 142  TIME—then the next line contains the size of the initial time step and the initial time in seconds (default is zero seconds) (format: 2F10.5). WEIG—then the next line contains the value of the weighting parameter for the finite-difference time step used in solving the pressure, temperature and transport equations (format: F10.5). If an input value is less than zero or greater than one, a one is used. Zero corresponds to an explicit temporal approximation, one-half to a Crank-Nicolson implicit scheme and one to a fully implicit method. If the initial values for any variable is not specified for a given node, then the value from the preceeding node is used. If the first node does not have a value, then the program prints out an error message and stops. If a value for a node is specified more than once, then the last value is used. Appendix three contains a simple example of the input for fortran unit 1.  Input for Fortran Unit 2—The Thermodynamic Data The initial portion of this file defines the atomic symbols and the atomic weights. The second portion identifies the phases, species and gases, with their accompanying thermodynamic, compositional, and physical data. An example of an input file for fortran unit 2 is listed in appendix four. The first line in the file is the number of elements (format: 15). This is followed by the atomic symbols of the elements, left justified in their field (format: 7(A4,4X)). In general, only two characters are needed to define the atomic symbols, but four positions are provided so that unique strings can be given for each of the isotopes. These lines are followed by the atomic weights of each of the elements/isotopes (format: 7(F10.5)). Immediately after these fines of input, is a character string identifying the following information. The only valid character strings are: AQUEOUS DATA, DECAY, GAS REFERENCES, SOLID SOLUTION DATA, END  DATA, MINERAL DATA,  and STOP. Each of these character strings must  be followed by at least three asterisks and (starting in column one) preceeded by at least three asterisks. There are no spaces between the asterisks and the character string. If the character string is: ****AQUEOUS DATA****—then the following lines contain the names, compositions and thermodynamic data of aqueous species. The data for each species occurring as a set of three lines. The first line contains the name of the species (only the first 8 characters are used, but it can be of any length), 4 blanks (or more), the formula (in the form: AL(1)0(2)H(2)—decimal 143  numbers  can be used as coefficients). This is followed by at least 4 blanks and then any information can be included. The next line contains: the apparent Gibbs free energy of formation from the elements at 298.15  C and 0.1 MP a (J/mole), the enthalpy of formation from the elements  (J/mole), the third law entropy (J/mole/deg), two terms (Cl and C2) of the of the heat capacity equation (J/mol/deg, J/mol/deg), and the first two terms of the volume expansion, A l and A2 (J/mol/bar, J/mol/bar , respectively). The next line contains the remaining two terms 2  of the volume expansion, A3 and A4 (J/mol/bar, J/mol/bar , respectively), theta (deg), the 2  conventional Born parameter and the charge of the species. The last two lines are read with the format: (5X,6F12.3). In the data base, A2 and A4 have been multiplied by 10 , A3 has been 5  multiplied by 10 and the conventional Born parameter by 10 . Values for these parameters 2  -5  are given in calories by Helgeson et al (1981). Water must be the first aqueous species in the data base and only its enthalpy and entropy are needed. If an aqueous species has a charge of zero or a charge greater than nine, then an activity coefficient of one is used. The activity of water is calculated using equations given previously in the text. *DECAY****—then information about the natural radioactive decay of isotopes follows. Each decay reaction has two lines. The first line contains one space, then the name of the decay reaction (for example: Ra226 => Rn222 + He4), at least four spaces and an equation giving the decay reaction. The name of the decay reaction can be of any length, but only the first 20 characters are used. The decay reaction is written in the form: RA26(-l)RN22(l)HE(l) which would imply that one atom of Radium, mass 226, decays to one atom of Radon gas, mass 222 and one atom of Helium, mass 4. Note that these symbols and their masses must have been identified in the first section of this file. The next line contains the half life constant of the reaction (units: seconds) and the energy released as heat per second of decay for one mole of the substance (units: J/sec mole) (format: 5X, 2E12.5). *END****—then the program stops reading this data base immediately. If this string is not present, the program reads until the end of the file or to the character string  ***SJOP***.  This string is not necessary on most systems.  *GAS DATA****—then the following lines contains the names, compositions and thermodynamic data of various gases. The data for each gas occurs in a set of two lines. The first line contains one space, the name of the gas (only the first twenty characters are used, but the name can be of any length), four spaces (at least), the formula, (in the form: H(2)S(1)—decimal 144  numbers can be used). At least four blanks follows and then any information. The next line contains: the Gibbs free energy of formation from the elements (J/mole), the enthalpy of formation from the elements (J/mole) and the third law entropy (J/mole deg), all at at the reference temperature and pressure. The next line contains the terms of the capacity equations: a, b, c, d, e, f and g (J/mole/deg, J/mole/deg , J deg/mole, J/deg , J/m/deg , J/m, J deg /mol, 2  5  3  2  respectively). No two gases should have identical thermodynamic and compositional properties. As the above terms only allow the gas properties to be calculated at one bar, a Redlich-Kwong routine is used to calculate the pressure integral in the programs.  *MTNERAL DATA****—then the following lines contain the names, compositions and thermodynamic data of stoichiometric minerals. The data for each phase occurs in a set of three lines. The first line contains one space, the name of the phase (only the first 20 characters are used, but it can be of any length), 4 spaces (or more), the formula (in the form: CA(3)AL(2)SI(3)0(12)— decimal numbers can be used). At least 4 blanks follows and then any information. The next line contains: the Gibbs free energy of formation from the elements (J/mole), the enthalpy of formation from the elements (J/mole), the third law entropy (J/mole deg), and the molar volume (cubic cm.), all evaluated at the reference conditions. The next line contains the terms of the heat capacity equation: a, b, c, d, e, f and g ((J/mole/deg, J/mole/deg , J deg/mole, 2  J/deg , J/m/deg , J/m, J deg /mol, respectively). The next line contains the coefficient of 5  3  2  iso-baric expansion (l/deg), the coefficient of iso-thermal contraction (l/MPa) and the thermal conductivity (watt/m deg). These lines are read using the format: (5X,6F12.3). No two phases should have an identical composition and thermodynamic properties. •REFERENCES****—then the following information is ignored by the program unless the first non-blank  characters  are another key word character string.  *SOIID SOLUTION DATA***—Then the next lines contain the properties of various solid solution minerals. These occur in sets, in which the first line contains one space, the number of endmembers, four spaces, the name of the solid solution, four spaces and a representative formula for the phase (format: 1X,I2,2X,20A4). The name of the solid solution can be of any length, but only the first twenty characters are used. The formula must contain all of the elements in the solid solution. Any analysis can be used as the formula is used to determine if the solid solution phase is in the compositional space of the system being modelled. Thus it is only used when the data base is being read. For a pyrope-grossular garnet, the formula could 145  be any of the following: CA(0.1)MG(2.9)AL(2)SI(3)O(8),  CA(1)MG(2)AL(2)SI(3)0(8),  CA(l.l)MG(1.0)AL(2)SI(3)O(8),  CA(2)MG(l)AL(2)SI(3)0(8),  CA(2.9)MG(0.l)AL(2)SI(3)O(8).  All of the elements must be included in the formula using  real or integer coefficients. The next line(s) contains 10 blanks and the name of one of the solid solution endmembers. (format: 10X,30A4). This is repeated until all of the endmembers have been defined. The name of the endmember can be of any length, but must be identical to the name of a stoichiometric phase in the mineral data section. The next lines contain the interaction parameters for this solid solution. All parameters must be included, even if they are zero, (format: 5X,6E12.5). At present, only binary solid solution phases are allowed. ****gjQp****—then  the program stops reading this data base immediately. If this string is not  present, the program reads until the end of the file (EOF) or to the character string ***END***. This string is not necessary on most systems. Input F o r F o r t r a n U n i t S — T h e Chemical Constraints  This file contains the chemical constrains for each of the nodes, an example is given in appendix five. The first lines in the file are title cards. As many as desired, including blank lines, can be used. They are terminated by a line with the word S T A R T in the first five columns. The next line in the file is one of five character strings which describes the nature of the data following it. Thefivepossible strings are C O M P o s i t i o n , E N D , I N E R t , R E A C t a n t s and S T O P . Only the first four characters of the string are used to identify the string. Each string (and its associated data) can be repeated as many times as needed. If the string is: C O M P — t h e n the following lines define the composition at the specified nodes. The first line which follows contains the number of compositional constraints, the number of nodes (NUM) and the index of the first node to which these constraints apply (ISTART, format: 315). The next lines contain the compositional constraints. The first three characters (AQU=aqueous species, MTN=stoichiometric mineral, SSS=solid solution mineral, GAS=gas) specifies the physical state of the constraint and the portion of the data base in which it will be found. This is followed by one blank and then one character specifying molality ( M ) , number of moles ( M ) , log activity ( A ) , balancing ion (B) or grams ( G ) . Balancing ion indicates molality and that initial molality can be modified by the program for charge balance. For an aqueous species, only 146  the molality, balancing ion and log activity options can be used. For a solid solution or stoichiometric mineral, only the moles and grams options can be used. For a gas, only the log activity option can be used. This is followed by one blank and then a.field(F10.5) for the molality/log activity/number of moles/number of grams of the mineral/aqueous species/gas. This is followed by a field for the name of the phase/species/gas exactly as it appears in the data base (format: A1,1X,A1,1X,F10.5,10A4). Water is automatically added as a constraint, thus the user specified constraints must be independent of water. In a five component system, only four constraints are needed, if one of the constraints was brucite, periclase could not be another. If the composition of a node is not specified, then the value of the previous node is used. These constraints are applied to nodes whose indexes are  IS TART,  IS TART  + 1,...  , IS TART  +  NUM-  1.  END—signals the end of this file. If not present, the program reads until the end of file (EOF) or until the character string STOP. TNER—then a minimum of two lines follows. The first contains the number of nodes (NUM)  and  a pointer to the first node (ISTART) to which the values on the following line(s) apply. The next line(s) contain the fraction of the solid portion which will be inert (format: 8F10.5). The first value applies the node with index ISTART, the next to the node ISTART + 1. The last applies to the node with the index ISTART + NUM  - 1. The default value for any unspecified  node is zero. If no solid phases are present at a node, the inert portion defaults to 1.0 minus the porosity. REAC—then the following lines defines the reactant minerals at each node. The first line specifies the number of reactants (K), the number of nodes (NUM), and a. pointer to the first node to which these reactants will apply (ISTART). The next K lines contain the reactant(s). Each line contains one character which indicates if the amount is in grams (G) or moles (M), followed by one space, the amount (F10.5), 3 spaces and the reactant mineral name. The reactants apply to all nodes with indexes  IST  ART,  +1,... , ISTART  IS TART  +  NUM  -  1. default value is  that there are no reactants at a given node. STOP—signals the end of this file. If not present, the program reads until the end of file (EOF) or to the character string  END.  When the composition of the fluid has been calculated, the volume of the fluid is determined based on one thousand grams of water. The total number of moles of water in the system is then calculated based on this value, the porosity and the total volume of the element. The total volume available 147  for solid phases is (the total volume of the element) minus (the total volume times the porosity) minus (the total volume times the inert fraction of the volume). The sum of the volumes of solid constraints and reactant minerals is normalized to this amount. Thus the values given for the number of grams (or moles) of minerals and reactants only provide a ratio for the final calculated amount. For example, if the user would like solid phases A, B, and C to be present in a weight ratio of 1:2:4, then their amounts could be specified as 1, 2 and 4 grams, or 1000, 2000 and 4000 grams, respectively. Both would result in the same number of moles of each phase as an initial condition.  F o r t r a n U n i t 7 O u t p u t — P l o t t i n g Pressures a n d F l u i d Velocities  The output directed to fortran unit 7 is pressure and velocity information and is designed to be read by a plot program. The first line is the number of nodes (format: 15). The second line contains two integers in a 215 format. They are the maximum number of pressure steps and a switch. The following line(s) contain the position of each of the nodes, 10 per line in 10(1X,E12.5) format (units: meters). The next set of lines are printed for each time step unless the switch is negative when they are only printed at the initial time. The first line of the set contains the time and the time step, (format: 2(lX,El2.5). The next line(s) of the set contains the pressures (units: MPa) for nodes 1 to n (format: 10(1X,E12.5)). These are followed by the velocities between each node (format: 10(1X,E12.5)). F o r t r a n U n i t 8 O u t p u t — P l o t t i n g the T e m p e r a t u r e s  The output directed to fortran unit 8 contains the temperatures at each node point and is designed to be read by a plot program. The first line contains two integer in a 215 format.  They are the number of nodes and a  switch. The next line also contains two integers—the number of pressure steps and the number of temperature steps per pressure step (format: 215). The following line(s) contain the position of each of the nodes (format: 10(1X,E12.5); units: meters). The next set of lines is printed for each time step. The first line contains the time and the time step (format: 2(lX,E12.5). The next line(s) contains the temperatures (units: deg K) for nodes 1 to TI (format: 10(lX,E12.5)). If the switch is negative, then the temperatures are only printed for the initial conditions.  148  F o r t r a n U n i t 9 O u t p u t — P l o t t i n g Porosity a n d Permeability  The output directed to fortran unit 9 is bulk composition of the fluid and matrix, porosity and permeability data and is designed to be read by a plot program. The first line contains three integers in 315 format. These are the number of nodes, the number of components and a switch. The second line contains 3 integers (format: 315)-—the number of pressure steps which will be attempted, the number of temperature steps per pressure step and the number of flow steps per temperature step. The following line(s) contain the position of each of the nodes (format: 10(1X,E12.5); units: meters). This is followed by the names of the components, using a 15A8 format. The lines described in this paragraph are printed only at the beginning of the file. The next set of lines is printed for each time step. The molality of the first component in the fluid for each node, followed by the second,  , until the molality of all components are printed (format:  10(1X,E12.5)). If the switch is negative, then they are printed only for the initial conditions. The next set of lines contains the total number of moles of each of the components in the solid phases for the each node, printed for the first component, followed by the second, ... (format: 10(1X,E12.5)). If the switch is negative, then they are only printed for the initial conditions. The next set of lines contain the porosity for each node (format: 10(1X,E12.5)) followed by the permeability for each node (format: 10(lX,El2.5)). The permeability and porosity are printed for all time steps, regardless of the switch setting.  149  Fortran Unit 10 Output—Plotting Fluid Compositions The output directed to fortran unit 10 contains the molalities and activity coefficient of each species in the fluid at each node and is designed to be used by a plot program. The first line contains the number of nodes (format: 15). The next line(s) contains the positions of each of the nodes (format: 10(lX,El2.5), units: meters). The next line contains the number of aqueous species, written as an integer in 15 format. The next line(s) contains the names of all the aqueous species in the system (format: 10(5X,A8)). These lines are printed only at the beginning of the file. The next set of lines are printed for each time step. The first line contains the time and the time step (format: 2(1X,E12.5)). The next line(s) contains the log molality of the first, second, third,  aqueous species, followed by the log activity for these species, in the same order as they  were listed at the start of the file. The next line(s) contains the log molalities and log activities for the second node, followed by the third, etc. For water, the total number of moles is written instead of molality (format: 10(lX,El2.5)).  Fortran Unit 11 Output—Plotting the Number of Moles of Solid Phases The output directed to fortran unit 11 contains the total number of moles of each of the solid phases at each node and is designed to be read by a plot program. The first line contains the number of nodes (format: 15). The next line(s) contains the positions of each of the nodes (format: 10(lX,El2.5), units: meters). The next line contains the number of possible solid phases in the system (format: 15). The next line(s) contains the names of all of the solid'phases with twenty spaces for each phase name, six names per line (format: 6A20). These lines are only at the start of the file. The next set of lines is printed for each time step. The first line contains the time and the time step (format: 2(1X,E12.5)). The next line contains three integers, the first is the number of the node, the second the number of product (equilibrium) phases present at that node, the third the number of reactant phases present at that node (format: 315). If the number of product phases is greater than zero, then the next line(s) contains the index number of a product phase at that node, the number of moles and the change in the number of moles of that phase since the last time step. This is repeated for each product phase. If the number of reactant phases at that node is non-zero, then the identical information is written for each reactant phase on a separate line (format: 150  I5,2(1X,E12.5)).  151  Appendix Three: Sample Unit 1 Data  The following is a listing of typical data for unit 1. TEST: THIS RUN MORE OR LESS MODELS WHAT WILL HAPPEN WHEN A FLUID GOES THROUGH A PURE QUARTZ ROCK UNDER A PRESSURE AND TEMPERATURE GRADIENT START NODES 40 COMPOSITION H(1.0)O(1.0)SI(l)CL(l)NA(l) PERM 1 1 -8.0 POROUSITY 1 1 0.2 PRESSURE 2 1 21.00000 20.0 TEMPERATURE 2 1 650.00 600. TIME 1500.0 STEPS 60 4 1 THICK 1.0 DIST 1 1 10. WEIGHT 0.9 ALPHA 3  NA+ 0.10 CL.001 SI02(AQ) 0.01 CHEMICAL REACTIONS ERROR 0.05 5 5 5 5 152  S T O P  153  A p p e n d i x Four: Sample U n i t 2 D a t a  The following pages are portion of a typical data set which would normally be assigned to fortran unit 2. The data for the aqueous species was taken from Helgeson et al., 1981. The data for the solid phases was taken from a prerelease copy of the Berman et al. data base (1985). This database has now been formally released—some of the data shown here is not current. Please contact R. Berman for a current version.  154  NA H CA MG FE MN PB ZN AU CU HG SI AL K F S C CL P N NI W CO BA V I U SR N BR LI TI 1.00797 22 . 9 8 9 8 1 24 3 1 2 0 0 15 . 9 9 9 4 0 40 . 0 8 0 0 0 55 8 4 7 0 0 54.938 107 . 8 7 0 0 0 1 9 6 . 9 6 7 0 0 2 0 7 . 1 9 0 0 0 65 .3 7 0 0 0 63 5 3 9 9 9 200 59 28.086 74 . 9 2 1 6 0 32.06400 12.01115 35. 4 5 3 0 0 26 9 8 1 5 1 18.9984 39 1 0 2 0 1 14.0067 58 . 71 58 9 3 3 2 9 5 .94 30.9738 183 8 5 208.980 87 . 62 238.03 50.942 14 0 0 6 7 118 . 6 9 126 9 0 4 4 79.909 47 .90 132 .905 6.939 * * * * AQUEOUS S P E C I E S * * * REF . - S E E BELOW WATER H(2)0(l) H20 -285830. 0.0000 69.915 0.0000 0 0000 0.0000 0.0000 0.0000 0.0000 0 0000 ••••REFERENCES*** WATER MUST B E T H E F I R S T S P E C I E S I N T H E AQUEOUS S P E C I E S S E C T I O N ! ! ! ! ! ! ****AQUEOUS S P E C I E S * * * H+ H( 1) REF . 1 0.0000 0.0000 0 0000 0 0000 0 . 0 0 0 0 0.0000 0.0000 0.0000 0 0000 0 0000 1.0000 4.0000 NA + NA( 1) REF. 1 - 240299.6719 149 4 3 2 8 -26 2 9 9 0 -2002.13 58.5760 0 8 . 0 0 8 1529.67 I 383 2 1.0000 -235.484 215 1700 4.0000 REF . 1 K( 1) - 252169.6875 -12 2 4 4 5 77 2 7 1 0 311.79 101.2528 13.000 234 1900 -81.421 0 8063 1.0000 4.0000 606.85 REF . 1 MG ( 1) MG+ + - 466779.5937 - 17.447 5894.29 138.0720 - 11 1 5 6 6 163 2 8 3 5 4.0000 029.46 270 5600 6 4316 2.0000 -00.264 CA( 1) REF . 1 CA+ + -543099.9375 - 14.949 4771.18 150 1 2 1 9 - 13 8 4 9 0 -56.4840 2.0000 4.0000 073.97 266 1400 5 1739 -05.238 1 AL(1) REF AL+ + + -531401.5000 -29.414 -307.9424 273 0897 -376.56 -33 0 1 1 8 12 0 1 2 7 4.0000 229 6000 3.0000 907.93 -133.888 1 CL(1) REF CL- 167079.6719 24.104 -2911.65 56.9024 -8 5 3 9 5 -20 2 4 3 9 4.0000 6 0919 - 1.0000 246 0200 -44.760 433.67 REF . 0(1)H(1) 1 OH- 230023.7656 -041.59 02.155 - 2 5 9 7 18 - 10.8784 103 4 3 1 8 4.0000 7 2157 -1.0000 453.21 253 5 2 0 0 -83.031 REF . 1 H( 1 ) C ( 1 ) 0 ( 3 ) HC03-3733.17 64 4 3 3 6 32.999 -689933.2500 - 12 5 5 2 0 98.3240 4.0000 -1 .0000 236 8700 5 5618 -112.077 600.40  0 AG AS MO SN CS  NACL(AQ) NA(l)CL(l) REF. 1 -417868.6250 62.7600 266.2317 -4.1840 195.723 111837.35 -1970.777 -101880.77 265.2500 4.9413 0.OOOO 4.OOOO SI02(AQ) SI(1)0(2) REF. 1 -881677.5625 61.9232 202.9947 -66.0616 2064.43 OO.895 285.596 124.64 233.0000 0.5402 0.OOOO 4.OOOO •••REFERENCES*** REF. 1 - DATA I S FROM H E L G E S O N E T A L ( 1 9 8 1 ) , A J S 2 8 1 , PP 1 2 4 9 1 5 1 6 DATA IS IN ORDER H, S, C l , C 2 , A l , A2 , A3, A4, THETA, W, Z, A Z E R O A2 HAS B E E N M U L T I P L I E D BY 1 0 * * 5 , A3 HAS B E E N M U L T I P L I E D BY 10**2 A4 HAS B E E N M U L T I P L I E D BY 1 0 * * 5 , W HAS B E E N M U L T I P L I E D BY 10**-5 U N I T S ARE I N ORDER: J/M, J / ( M K ) , J / ( M K ) , J / ( M K ) , J / ( M B A R ) , J / ( M BAR BAR) J / ( M B A R ) , J / ( M BAR B A R ) , K, J/M, E - , ANGSTOMS WHERE J I S J O U L E S , M I S MOLES, K I S DEG K E L V I N , AND B I S B A R S O R I G I N A L R E F E R E N C E I S I N C A L O R I E S , THEY WERE M U L T I P L I E D BY 4 . 1 8 4 TO C O N V E R T N O T E THAT WATER MUST BE THE F I R S T AQUEOUS S P E C I E S AND DOES NOT HAVE A N Y T H I N G OTHER THAN AN D E L T A H OF FORMATION AND A S Z E R O . • * * *REF ERENCES* * * * * * S O L I D P H A S E S - F I T U S I N G HAAR E Q U A T I O N OF S T A T E PRELIMINARY R E L E A S E OF BERMAN E T FORMAT: H, S, V A, B, C, D, E , F, G DV/DT, DV/DP, K (THERMAL COND) DV/DT K  AND  (THERMAL  DV/DP  FROM  COND.)  MEMOIR  FROM  97  MEMOIR  AL  - WHEN NO DATA D E F A U L T V A L U E S OF 0 . 0 0 1 AND -0.002 USED. 97 - D E F A U L T V A L U E OF 100 U S E D WHEN NO D A T A . A L P H A - Q U A R T Z USED FOR BETA-QUARTZ C A L C I T E V A L U E U S E D FOR A L L C A R B O N A T E S  •••••MINERAL DATA***** ALBITE NA( 1 ) A L ( 1 ) S I ( 3 ) 0 ( 8 ) ALB I -3934963.50 208.09999 99.9800 393.63568 0.000000 -7892826. -2415.4976 0.00100000 -0.00200000 100. ANDALUSITE AL(2)SI(1)0(5) ANDA -2590415.75 91.53000 51.5877 236.47818 0.000000 -7526810. -1102.9413 0.00082000 -0.00200000 110. ANORTHITE AL(2)CA(1)SI(2)0(8) ANOR -4230350.50 199.59999 100.7500 439.36926 0.000000 0. -3734.1487 0.00120000 -0.00200000 100. CALC CA(1)C(1)0(3) CALC -1207438.00 91.72376 36.9190 193.23828 0.000000 0. -2040.8756 0.00100000 -0.00050000 38. CORUNDUM AL(2)0(3) CORU -1675700.00 51.02000 25.5680 155.01888 0.000000 -3861363. -828.3870 0.00100000 -0.00008000 250.  0.OOOO  0.0  1070635968  0.OOOO  0.0  936442432  0.OOOO  0.0  -317023264  0.OOOO  0.0  199455888  0.OOOO  0.0  409083520  DIOPSIDE MG(1)CA(1)SI(2)0(6) DI -3200898.50 142.50000 66.1527 305.41321 0.000000 -7165973. 1604 0.00057600 -0.00070000 100 . FORSTERIT E MG(2)SI(1)0(4) FO 94.20061 -2176500.00 43.8030 238.64136 0.000000 0 . 2001 0.00105000 -0.00043000 100 . GROSSULAR CA(3)AL(2)SI(3)0(12) GROS -6634023.50 255.00000 125.3920 573.43042 0.000000 - 18887174. 2039 0.00225000 -0.00075000 100. PYRO M G ( 3 ) A L ( 2 ) S I ( 3 ) 0 ( 12) PYRO -6283743.50 272.79999 113.1100 -9039100. 2790 581.51300 0.000000 100 . 0.00100000 -0.00200000 SI(1)0(2) ALPHA-QUARTZ A-QTZ 41.45252 -910700.00 22.6880 -3546684. 80.01199 0.000000 -240 8 . 4 0.00077100 -0.006100 SI(1)0(2) BETA-QUARTZ B-QTZ -908624.06 23.7180 44.20796 -3546684. 80.01199 -240 0.000000 8 . 4 0.00075000 -0.00200000 SILL SILLIMANITE AL(2)SI(1)O(5) 95.64000 49.8481 -2586855.50 1052 233.15654 -7726210. 0.000000 100 . 0.00049800 -0.00042000 SPINEL MG(1)AL(2)0(4) SP 83.66499 39.7400 -2304398.50 235.89992 -1710415. 1766 0.000000 0.00100000 -0.00016000 138 .  9314  0.0000  0.0  2606  0.0000  0.0 - 1 1 6 2 4 3 2 8 0  4049  0.0000  0.0 2 3 1 9 3 1 1 8 7 2  7576  0.0000  0.0  143163008  2755  0.0000  0.0  491568416  2755  0.0000  0.0  491568416  7800  0.0000  0.0  997865792  5780  0.0000  0.0  40616924  921837504  A p p e n d i x Five: Sample Unit S D a t a  The following is a typical set of data assigned to unit 3. The example is perhaps the simplest possible, with all REV having the same composition. THIS FILE DESCRIBES T H E CHEMICAL COMPOSITION OF EACH NODE HERE IT IS A QUARTZ ROCK, CONTAINING A SODIUM CHLORIDE BRINE BALANCING ION IS SODIUM  START COMPOSITION 4 1 MIN M 1.0 AQU A -6.0 AQU B 1.0 AQU M 1.0  ALPHA-QUARTZ H+ NA+ CL-  STOP  158  Appendix  Six: S a m p l e U n i t 6 O u t p u t  The following listing is an edited version of the output written to the file attached to fortran unit 6. Typically this output file is very large—100000 lines is not unusual. On most computer systems, only files on magnetic tape can be big enough to contain the entire output. For hardcopy, micro-fiche is recommended. This output was generated using the data given earlier. Only the inital conditions and portions of the first step are shown for brevity. When material has been removed, it has been flagged using the following construction: *************************************************************** **************************************************************** ************* REMOVED HERE************ **************************************************************** M A T E R I A L  H  A  g B  E  E  N  In addition to removing material, the length of the output lines was truncated to 90 characters in order tofitthe thesis format. The following material was extracted from a output listing about 3 inches thick.  159  1 TITLE INFORMATION READ FROM DATA ATTACHED TO UNIT 1 TEST NUMBER OF NODES -  40  SIZE OF ELEMENTS (METERS) ie.eee 10.eee 10.000 10.000  10.000 10.000 10.000 ie.eee  10.000 10.000 10.000 10.000  10.eee 10.000 10.eee 10.000  10.000 10.000 10.000 10.000  10.000 10.000 10.000 10.000  10.ee 10.00 1e.ee 10.00  30.000 130.000 230.000 330.000  40.000 140.000 240.000 340.000  50.000 150.000 250.000 350.000  60.00 160.00 260.00 360.00  POSITION OF EACH OF THE NODES (METERS) .eee 100.000 200.eee 300.000  10.000 ne.eee 210.eee 3ie.eee  20.000 120.000 220.000 320.000  THICKNESS OF GRID IN METERS -  .10000E+01  SYSTEM IS COMPOSED OF THE FOLLOWING ELEMENTS:  H  SI  CL  NA  INITIAL PERMEABILITY IN EACH NODE (METERS»»2) .100O0E-O7 .10000E-07 .ieeeeE-07 .ieoeoE-e7  .10000E-07 .ieO00E-07 .1O000E-07 .i0oeeE-e7  .ioeeeE-e7 .1OO00E-07 .ieoeoE-07 .10000E-07  . 10000E-0 .10000E-O .10000E-0 .10000E-0  .ieeoeE-07 .ieeeeE-07 .ieeeeE-07 .ioeeeE-07  10000E-07 1O000E-O7 10O0OE-07 1O000E-07  .100OOE-O7 .10000E-O7 . 10000E-O7 . 1O00OE-07  .200 .200 .200 .200  .200 .200 .200 .200  .200 .200 .200 .200  .20 .20 .20 .20  20.0 20.e 20.0 20.0  20.0 20.0 20.0 20.0  20.0 20.0 20.0 20.0  20. 20. 20. 20.  500.0 500.0 500.0  500.0 500.0 500.0  500.0 500.0 500.0  500. 500. 500.  INITIAL POROUSITY IN EACH NODE .200 .200 .200 .200  .200 .200 .200 .200  .200 .200 .200 .200  INITIAL PRESSURES IN EACH NODE (MPA) 21.0 20.0 20.e 20.0  20.0 20.0 20.e 20.0  20.B 20.0 20.0 20.e  INITIAL TEMPERATURES IN EACH NODE (DEG K) 550.0 500.e 500.0  500.0 500.0 500.0  500.0 500.0 500.0  500.0  500.0  500.0  500.0  500.0  500.0  500.  THE FOLLOWING AQUEOUS S P E C I E S HAVE BEEN CHOSEN AS MOBILE COMPONENTS NAME  LONG.  DISPERSIVITY  SI02(AQ)  .01000  WEIGHTING FACTOR FOR THE F I N I T E DIFFERENCE TIME STEP I S : MAX. NUMBER OF TIME (PRESSURE) STEPS IS  4 TEMPERATURE STEPS 1 SOLUTE TRANSPORT STEPS 1 CHEMICAL REACTION S T E P S .  FOR EACH PRESSURE S T E P . THERE IS FOR EACH TEMPERATURE S T E P , THERE IS FOR EACH SOLUTE TRANSPORT S T E P . THERE IS THE INITAL TIME I S :  .00000E+00 SECONDS  THE INITAL PRESSURE THE INITAL TEMPERATURE THE INITAL COMPONENT TRANSPORT THE INITAL CHEMICAL REACTION  PRESSURE TEMPERATURE TRANSPORT 1  .90000  TIME TIME TIME TIME  STEP STEP STEP STEP  IS IS IS IS  PERCENT MAXIMUM ERROR .50000E+01 .10000E+03 .10000E+03  THE FOLLOWING PHASE/THERMODYNAMIC  INFORMATION  .20000E+01 .50000E+00 .50000E+00 .50000E+00  SECONDS SECONDS SECONDS SECONDS.  MAX. NUMBER  ITERATIONS 5 5 5  WAS READ FROM THE F I L E ASSIGNED TO UNIT  THE FOLLOWING AQUEOUS SPECIES WERE USED AS THE COMPOSITIONAL B A S I S FOR A L L PHASES AND SP WATER SI02(AQ) H+ CLNA+ THE FOLLOWING AQUEOUS SPECIES WILL BE CONSIDERED IN THE CALCULATIONS NAME WATER  (G/MOLE) 18.01534 1.00797  H (F) (J/MOLE) -285830.0 .0  S (ZERO) (J/MOLE/DEG) 69.92 .00  •••••••••••••MATERIAL HAS BEEN REMOVED HERE*»»»»»»**»*»«»«»»»»*«  •••••••••••••••••••••••••••••••••••••••••••••••••••a************ TITLE  INFORMATON READ FROM DATA ON UNIT 3  THIS F I L E DESCRIBES THE CHEMICAL COMPOSITION OF EACH NODE  Cl J/MOL/DEG .0000 .0000  0 CHEMICAL CONSTRAINTS FOR NODE: ALPHA-QUARTZ (MINERAL) (AQ S P E C I E S ) H+ (AQ S P E C I E S ) NA+ (AQ S P E C I E S ) CL(AQ S P E C I E S ) WATER  1 (MOLES) (LOG A C T . ) (MOLALITY) (MOLALITY) (LOG A C T . )  .100O0E+01 -.600O0E+01 .10000E+01 .10000E+31 .00000E+00  CHEMICAL CONSTRAINTS ALPHA-QUARTZ H+ NA+ CLWATER  FO (M (AQ (AQ (AQ (AO  .MATERIAL HAS BEEN REMOVED HERE*  NODE:  0  TOTAL VOLUME INERT (M*«3) FRACTION  POROSITY  AVAILABLE VOLUME (M**3)  PHASES  AMOUN (MOLE  PRESENT  .10000E+02  .000000  .200000  .80000E+01  ALPHA-QUARTZ  .35158  .10000E+02  .000000  .200000  .B0000E+01  ALPHA-QUARTZ  .35208  .MATERIAL HAS BEEN REMOVED HERE*  DISTRIBUTION OF SPECIES CALLED AT TIME 0 FOR NODE: 1 WITH A TEMPERATURE OF 5 5 0 . 0 0 0 ( O E G . K ) AND A PRESSURE OF 2 1 . 0 0 0 (MPA) 0 SPECIES MOLALITY LOG MOL. ACTIVITY LOG ACT. A C T I V I T Y COEF LOG ACT COEF WATER .55508E+02 1.74436 .96461E+00 -.01565 .01738 -1 .76000 H+ .99863E-05 .10014 -.99940 -5.00060 .10000E-05 -6.00000 NA+ .99103E+00 .09018 -1.04488 -.00391 .89374E-01 -1.04879 CL.99091E+00 .08882 - 1 .05148 -.00397 .88015E-01 -1.05545 OH.13U1E-03 .08158 -1.08842 -3.88136 .10721E-04 -4.96978 .90916E-02 .00000 .00000 NACL(AQ -2.04136 .90916E-02 -2.04136 .85929E-02 .00000 SI02(AQ 1.00000 -2.06586 .85929E-02 -2.06586 0 IONIC STRENGTH: .99104 ELECTRICAL BALANCE: .49687E-10 ION/COMPONENT  0  PHASE ALPHA-QUARTZ BETA-OUARTZ  USED FOR ELECTRICAL BALANCE:  NA+  LOG A C T I V I T Y .00000E+00 -.55346E-01  LOG K .0000 -.0553  LOG Q .0000 .0000  .MATERIAL HAS BEEN REMOVED HERE*  1  COMPOSITION.  POROSITY AND PERIMIABILTY  AT:  PRESSURE STEP NUMBER:  0  0  TEMPERATURE STEP NUMBER: COMPONENT FLOW STEP NUMBER: TIME OF OUTPUT ( S E C ) : TEMPERATURE TIME STEP ( S E C ) : MAX. ERROR (PERCENT): MAX. NUMBER OF ITERATIONS I S :  .0O0OOE+OO .50000E+0O 100.00000000 5  PERCENT ERROR .00000000  FLOW COMP SI02(AQ)  ITERATIONS  NUMBER OF MOLES OF EACH OF THE FLUID COMPONENTS PER LITER NODE: 1 2  SI02(AQ) .85929E-02 .53346E-02  WATER .55508E+02 .55508E+02  o  FOR THE AQUEOUS S P E C I E S NA+ .10001E+01 .10001E+01  CL. 10000E+01 . 10000E+01  -.12143E-03 -.63112E-04  ARE:  •MATERIAL HAS BEEN REMOVED HERE*  NUMBER OF MOLES OF EACH OF THE FLUID COMPONENTS NODE: 1 2  SI02(AQ) .35158E+06 .35208E+06  WATER .00000E+00 .00000E+00  POROUSITIES AT THE NODES FOR .20000 .20000 .20000 .20000  TIME  .20000 .20000 .20000 .20000  H+ . 00000E+00 .00000E+00 .00000E+00 S E C .  .20000 .20000 .20000 .20000  P E R M I A B I L I T I E S AT THE NODES FOR TIME .10000E-07 .10000E-O7 .10000E-07 .10000E-07 1  .10000E-07 .10000E-07 .10000E-07 .10000E-07  .10000E-07 .10000E-07 .10000E-07 •10000E-07  TEMPERATURE OUTPUT A T :  TIME OF OUTPUT TEMPERATURE TIME STEP  IN THE SOLID PHASES ARE  .00000E+00 S E C . .10000E-07 . 10000E-07 . 10000E-07 . 1000OE-07  .00000E+00 .50000E+00  NA+ .O0000E+OO .00000E+00  ARE:  .20000 .20000 .20000 .20000  PRESSURE STEP NUMBER: TEMPERATURE STEP NUMBER:  (SEC): (SEC):  CL.00000E+OO .00000E+00  .20000 .20000 .20000 .20000  .20000 .20000 .20000 .20000  .2000 .2000 .2000 .2000  .10000E-07 .10000E-07 . 10000E-07 10000E-07  .10000E-0 . 10000E-0 10000E-O 10000E-0  ARE: . 10000E-07 10000E-07 10000E-07 10000E-07 0  PERCENT PERCENT  TEMPERATURES  ERROR L I M I T : ERROR USED :  100.00060000 .00000000  MAX. NUMBER TOTAL NUMBER  500.00 500.00 500.00 500.00  500.00 500.00 500.00 500.00  500.00 500.00 500.00 500.00  1 PRESSURE OUTPUT AT PRESSURE STEP NUMBER: TIME OF CALCULATION ( S E C ) : PRESSURE TIME STEP ( S E C ) :  500.00 500.00 500.00 500.00  500.0 500.0 500.0 500.0  0  5.00000000 .00000000  MAX. NUMBER TOTAL NUMBER  ITERATIONS: ITERATIONS:  (MPA) AT THE NODES ARE :  21.00 20.00 20.00 20.00  VELOCITIES  20.00 20.00 20.00 20.00  .00000E+00 .00000E+00 .00000E+00 .00000E+00  1 AT TIME PRESSURE TEMPERATURE FLOW REACTION  20.00 20.00 20.00 20.00  20.00 20.00 20.00 20.00  20.00 20.00 20.00 20.00  20.00 20.00 20.00 20.00  20.0 20.0 20.0 20.0  .00000E+00 .00000E+00 .00000E+00 .00000E+00  .000O0E+O0 .00000E+00 .00000E+00 .00000E+00  .00000E+00 .00000E+00 .00000E+00 .00000E+00  .00000E+0 .00000E+0 .00000E+0 .00000E+0  (M/SEC) BETWEEN EACH NODE ARE:  .91162E+01 .00000E+00 .0000OE+00 .00000E+00  .00000E+00 .00000E+00 .00000E+00 .00000E+00  . 5 FOR NODE: ITERATION ITERATION ITERATION ITERATION  PRESSURE TEMPERATURE SPECIES WATER H+  500.00 500.00 500.00 500.00  .00000E+00 .20000E+01  PERCENT ERROR L I M I T : PERCENT ERROR USED :  0  5 0  ( K ) AT THE NODES ARE  550.00 500.00 500.00 500.00  PRESSURES  ITERATIONS: ITERATIONS:  -  1  1 1 1 1  2 1 . 0 0 MPA 5 5 0 . 0 0 DEG K  MOLALITY .55508E+02 .99862E-05  LOG MOL. 1.74436 -5.00060  ACTIVITY .96461E+00 .10000E-05  LOG A C T . -.01565 -6.00000  A C T I V I T Y COEF LOG ACT COEF .01738 -1.76000 .10014 -.99940  NA+ CLOH— NACL(AQ) SI02(AQ)  .99103E+0O .99091E+00 . 12676E-03 .90916E-02 .85929E-02  -.00392 -.00397 -3.89701 -2.04136 -2.06586  .89374E-01 .88015E-01 .10341E-04 .90916E-02 .85929E-02  IONIC STRENGTH: .99104 ELECTRICAL BALANCE: -.31934E-09 ION/COMPONENT USED FOR ELECTRICAL BALANCE: PHASE ALPHA-QUARTZ BETA-QUARTZ  LOG ACTIVITY .00000E+00 -.55346E-01 D M/ DT  PHASE ALPHA-QUARTZ  -1.04879 -1.05544 -4.98543 -2.04136 -2.06586  NA+ LOG K .0000 -.0553  TOTAL NUMBER OF MOLES  .00000000E+00  'MATERIAL HAS BEEN REMOVED HERE  .09018 .08882 .08158 1.00000 1.00000  .35157593E+06  LOG Q .0000 .0000  -1.04487 -1.05148 -1.08842 .00000 .00000  Appendix Seven: Program listing  The following program has been written in F T N 5, a Control Data Corporation (CDC) implementation of ANSI standard FORTRAN 77 and has been run on Cyber 825 and Cyber 855 computers under NOS 4.1 and NOS 4.2 operating systems. It has also been compiled under the DEC (Digital Equipment Corporation) implementation of ANSI standard FORTRAN 77. The only non-ANSI standard statement used is a CDC extension to the PROGRAM statement. This statement is the first in the program, and in addition is giving a name to the main program blocks, identifies the various I/O units.  166  PROGRAM C C  c  C C C C C C C C C  PHD(TAPE1, TAPE2, TAPE3, TAPE6, TAPE7, TAPE 10, TAPE 11)  TAPE8,  TAPE9,  ***************************************************************** THIS PROGRAM IS DESIGNED TO CALCULATE MASS TRANSPORT AND TRANSFER IN A 1 DIM SECTION OF ROCK RANGING FROM THIN SECTION TO CRUSTAL DIMENSIONS. THE AREA IS DIVIDED INTO A LINEAR GRID AND THE I N I T I A L TEMPERATURE AND PRESSURE VALUES ARE USED TO CALCULATE THE MASS DISTRIBUTION IN EACH C E L L .  WRITTEN BY E.H. PERKINS, STARTING JAN 17, 1983 **************************************************  c  H-* ^  C C C C C C C C C C C C C C C C C C C C C C C C C C C C  UNIT 1 - READS UNIT 2 - READS  THE RUN S P E C I F I C DATA SUCH AS POROUSITY THE THERMODYNAMIC DATA F I L E  UNIT 3 - READS THE COMPOSITION OF EACH NODE UNIT 6 - WRITES A USER VERSION OF ALL OF THE THE DATA, CALCULATIONS AND ERROR MESSAGES UNIT 7 - WRITES A SUMMARY TO BE USED PLOTTING THE PRESSURES AND V E L O C I T I E S UNIT 8 - WRITES A SUMMARY TO BE USED PLOTTING THE TEMPERATURES UNIT 9 - WRITES  UNIT  UNIT  A SUMMARY TO BE USED PLOTTING THE TOTAL COMPOSTION OF THE FLUID AND SOLID PHASES, POROUSITY AND PERMIMIABILITY 10 - WRITES A SUMMARY TO BE USED PLOTTING THE MOLALITY AND A C T I V I T Y OF ALL AQUEOUS S P E C I E S  11 - WRITES  A SUMMARY TO BE USED PLOTTING THE NUMBER OF MOLES OF EACH PHASE AND THE POROSITY. IPSWIT, ITSWIT, ICSWIT, IMSWIT ARE SWITCHES FOR PRESSURE, TEMPERATURE, COMPONENT TRANSPORT AND MASS TRANSFER RESPECTIVELY. IF 0, SOLVE, IF - 1 , THESE TERMS ARE CONSTANT AND ARE NOT SOLVED FOR, IF 1, THEY HAVE CONVERGED FOR THIS ITERATION.  NSTEPS IS THE TOTAL NUMBER OF STEPS TO BE MADE ITSTEP CONTAINS THE NUMBER OF LOOPS-FOP? TEMPERATURE ( 1 ) , THE NUMBER OF LOOPS FOR COMPONENTS FLOW ( 2 ) AND THE NUMBER OF LOOPS FOR MASS TRANSFER ( 3 ) COMMON /SWIT/ I T S T E P ( 3 ) , IPSWIT, ITSWIT, ICSWIT, IMSWIT, NSTEPS  C C  IF IUPDT NOT IUPDT  EQUAL EQUAL  TO ZERO, TO ZERO,  READ IN S I Z E , POROSITY OF THE ENTIRE SYSTEM  C  CALL SETUP 1 READ IN PHASE DATA CALL SETUP2  C C C  C C C C C  COMPOSITION  2  EACH NODE FROM UNIT 3  - CALCULATE FREE ENERGY AND VELOCITY CALCULATIONS  DENSITY  FOR  SETUP4  CALCULATE AND  CALL C C  OF  THE  SETUP3  SETUP WATER ROUTINE  CALL C C C C  AND PERMEABILITY OF EACH NODE AND FROM UNIT 1  FROM UNIT  READ IN COMPOSITION CALL  C C C C  PREDICTIONS,  = 1  C C C C  C C C  THEN PRINT OUT THEN DO NOT  OUTPUT I N I T I A L DISTRIBUTION OF S P E C I E S AT EACH NODE.  SETUP5  CALCULATE I N I T I A L VELOCITY CALL VEL CALL SETUP6 OUTPUT  I N I T I A L PRESSURE, VELOCITY, TEMPERATURE, AND PERMIABILTY CALL 0UTC(O,O,O,ICSWIT,IMSWIT, IUPDT) CALL 0UTT(O.O,ITSWIT, IUPDT) CALL OUTP(0,IPSWIT, IUPDT) THIS IS THE TIME  COMPOSITION,  POROSITY  STEP LOOP  SOLVE PRESSURE, TEMPERATURE, COMPONENT FLOW AND NOTE THAT ROUTINES ARE ONLY CALLED AS NEEDED IF (NSTEPS .GT. 0 ) THEN DO 100 ITERP = 1, NSTEPS IF (IPSWIT.NE.-1) THEN CALL SOLVEP(IMSWIT) CALL VEL END IF DO 90 ITERT = 1, I T S T E P ( 1 )  MASS  TRANSFER  IF  (ITSWIT.NE.-1)  CALL  SOLVET(IMSWIT)  DO  80 ITERC = 1, I T S T E P ( 2 ) IF (ICSWIT.NE.-1) CALL  SOLVEC(IMSWIT)  C IF  (IMSWIT.NE.-1 ) THEN DO 70 ITERM = 1, I T S T E P ( 3 ) CALL S O L V E M ( I T E R P , I T E R T , ITERC,ITERM) CONTINUE END I F CALL O U T C ( I T E R P , I T E R T , I T E R C , I C S W I T , IMSWIT, IUPDT)  70  80  90 ^ CTN  100 •  CONTINUE IF (ITSWIT.NE.-1) CALL O U T T ( I T E R P , ITERT, ITSWIT, IUPDT) CONTINUE CALL OUTP(ITERP, CONTINUE END IF  IPSWIT,  IUPDT)  C  C C C  C C C C  STOP END SUBROUTINE SOLVEC(IMSWIT) THIS ROUTINE SETS UP THE F I N I T E ELEMENT MATRIX'S FOR THE SOLUTION OF THE NEW COMPOSITIONS COMMON BLOCKS PREVIOUSLY DEFINED COMMON / C E L L S / C E L L P O ( 5 1 , 2 ) , C E L L P E ( 5 1 , 2 ) , C E L L P ( 5 1 , 2 ) , CELLT(51,2), DENSF(51,2), SIZEX(51), XINERT(51), THICK, NUMX, INOWP, IFUTP, INOWT, IFUTT COMMON /TIME/ DTAUP, DTAUT, DTAUC, DTAUM, TAUP, TAUT, TAUC, TAUM, W1 COMMON /CHEMPH/ COMPPH(10,25), T H E R P H ( 1 4 , 2 5 ) , NUMPH COMMON /CHEMAQ/ COMPAQ(10,25), THERAQ(13,25), NUMAQ COMMON /CHEMSS/ COMPSS(10,20), T H E R S S ( 8 , 2 0 ) , NUMSS COMMON /CHEMG / COMPG(10,10), THERG(6,10), NUMG COMMON / C E L L C H / CHEM(10,51), TOTALM(10,51), STRNGH(51), WATER(51), I N D E X 1 ( 1 0 , 5 1 ) , I N D E X 2 ( 1 0 , 5 1 ) , I N D E X 3 ( 1 0 , 5 1 ) , I B A L ( 5 1 ) , NUMCHM, NCONST COMMON / D I V I N E / E R R 0 R ( 5 5 ) , ERRMAX(3), L 0 P T 0 T ( 5 5 ) , L I M L 0 P ( 3 ) COMMON /TRANS/ V E L 0 C ( 5 1 , 2 ) , A 0 C O ( 1 0 . 5 1 , 2 ) , S O C O ( 1 0 , 5 1 , 2 ) , A L P H A ( 1 0 ) , INOWC, IFUTC LOCAL VARIABLES A CONTAINS A BANDED REPRESENTATION OF THE F I N I T E ELEMENT C O E F F I C I E N T ARRAY. INITIALLY CONTAINS THE [ A ] TERMS FOR THE EQUATIONS  C C C C C C C C C C C C C C C C  B  -  [A] P + [ B ] DP/DT = F CONTAINS A BANDED REPRESENTATION OF THE IN THE ABOVE EQUATION.  C  -  CONTAINS THE COMPOSITIONS  D F  -  WORKING ARRAY ON C A L L I N G IMSL ROUTINE, CONTAINS THE RIGHT HAND SIDE OF THE EQUATIONS, ON EXIT, IT CONTAINS THE SOLUTION VECTOR. SEE ABOVE EQUATION.  PORE VOLUMEX -  [ B ] AREA  AT TIME INOW  POROUSITY FOR AN ELEMENT - WEIGHTED WITH W1 IN TIME VOLUME OF ELEMENT S I Z E OF ELEMENT, ALSO USED FOR TEMPERARY STORAGE  XL WORK ARRAY FOR THE IMSL ROUTINE LEQT1B DIMENSION A ( 1 0 2 , 3 ) , B ( 1 0 2 , 3 ) , C ( 1 0 2 ) , D ( 1 0 2 ) , F ( 1 0 2 ) ,  XL(204)  C ^ O  ZERO = 1.OE-06 THIS LOOP IS DONE ONCE FOR EACH MOBILE COMPONENT. IT ENDS AT THE LABEL 900 -- A COMMENT CARD WITH *** FOLLOWS THIS LINE DO 900 IK = 1, NCONST IF ( A B S ( A L P H A ( I K ) ) . L T . Z E R O ) GO TO 900  C C C  C DO 800 LOOP = 1, L I M L 0 P ( 3 ) I = 2 + IK L O P T O T ( I ) = LOOP C  50 C C C  C C  CALL M I N I T ( C , 102, 1, O.OEOO) CALL M I N I T ( D , 102, 1, O.OEOO) CALL M I N I T ( F , 102, 1, O.OEOO) DO 50 I = 1, NUMX C ( I ) = AQCO(IK,I,INOWC) CONTINUE SET UP ELEMENT S T I F F N E S S MATRIX EVALUATED AT TIME T + DELTA ( T / 2 ) EACH TERM IS EVALUATED FOR THE ELEMENT CALL M I N I T ( A , 102, 3, O.OEOO) CALL M I N I T ( B , 102, 3, O.OEOO) CALL M I N I T ( X L , 204, 1, O.OEOO) K = NUMX - 1 DO 100 I = 1, K J = I + 1  THE VELOCITY CALCULATION DOES NOT  ASSUME  THAT THE  C C  TIME AT INOWP IS THE SAME S V V  C C C  THE PORE  AS THE TIME AT INOWC  = ( V E L O C ( I , I F U T P ) - VELOC(I,INOWP)) / DTAUP = VELOC(I,INOWP) + (W1 * S * DTAUC) = V + (S * ((TAUC - DTAUC) - (TAUC - D T A U C ) ) )  CALCULATION PORE S PORE S PORE DISP X  = (CELLPO(I,INOWC) + CELLPO(0,INOWC)) = ( C E L L P O ( I , I F U T C ) + C E L L P O ( J , I F U T C ) ) - PORE = PORE / 2.0 = S / ( 2 . 0 * DTAUC) = PORE + (W1 * S * DTAUC) = A L P H A ( I K ) * ABS(PORE) SIZEXO )  C  c 100 C C  160 C C  A(I,2) A(I,3) A(d,1) A(J,2)  = ( 1 . 0 * DISP = (-1.0 * DISP = (-1.0 * DISP = ( 1 . 0 * DISP  B(I,2) B(I,3) B(J,1) B(J,2)  =((X = (X = (X = (X  / / / /  ( 3 ..0 (6 .0 (6..0 ( 3 ..0  * * * *  / / / /  X) X) X) X)  + +  DTAUC)) DTAUC)) DTAUC)) DTAUC))  (V (V (V (V  / / / /  2. 0 ) 2. 0) 2. 0) 2. 0 )  * PORE) + * PORE * PORE * PORE  + A(I,2)  B(I,2)  CONTINUE F I N I S H SETTING UP RIGHT HAND SIDE CALL BMMULT(B,102,NUMX,C,F) CALL BMMULT(A,102,NUMX,C,D) DO 160 1 = 1 , NUMX F ( I ) = F ( I ) + ((W1 - 1.0) * D ( I ) ) CONTINUE F I N I S H SETTING UP ELEMENT S T I F F N E S S MATRIX DO  170 180 C C C  180 J = 1,3 DO 170 I = 1, NUMX A ( I , J ) = (W1 * A ( I , J ) ) + CONTINUE CONTINUE SET UP BOUNDARY CONDITIONS F(1) = AQCO(IK,1,INOWC) F(NUMX) = AQCO(IK,NUMX,INOWC)  B(I,J)  200  C C C C C C  DO 200 1 = 1 , 3 A( 1 , I ) =0.0 A(NUMX,I) = 0 . 0 CONTINUE A(1,2) =1.0 A(NUMX,2) = 1.0 SOLVE THE SYSTEM OF EQUATIONS USING IMSL ROUTINE LEQT1B THIS ROUTINE USES IMSL ROUTINES UERTST AND UGETIO FOR ERROR OUTPUT. CALL LEQT1B(A,NUMX,1,1,102,F,1,102,0,XL,204,IER) CHECK  FOR LARGEST ERROR, COPY NEW VALUES TO COMPOSITION  800  <J = 2 + IK ERROR(J) = 0.0 DO 500 1 = 1 , NUMX X = ABS((AQCO(IK,I,IFUTC) - F ( I ) ) / F ( I ) ) IF ( X . G T . E R R O R ( J ) ) ERROR(J) = X AQCO(IK,I,IFUTC) = F ( I ) CONTINUE IF ( E R R O R ( J ) . L E . E R R M A X ( 3 ) ) GO TO 900 CONTINUE  900  CONTINUE  500  ARRAY  C C C C C  *************************************  RETURN END SUBROUTINE C C C C C  END OF LOOP FOR EACH MOBILE COMPONENT  SETUP 1  THIS ROUTINE READS IN S I Z E , COMPOSITION, OF EACH NODE, AND A FEW OTHER THINGS.  POROSITY, PERMEABILITY  NEW COMMON BLOCKS COMMON /UPPER / PMIN, PMAX, PTIME, PSTART, TMIN, TMAX, TTIME, TSTART COMMON / D I V I N E / E R R 0 R ( 5 5 ) , ERRMAX(3), L 0 P T 0 T ( 5 5 ) , L I M L 0 P ( 3 ) COMMON /TIME/ DTAUP, DTAUT, DTAUC, DTAUM, TAUP, TAUT, TAUC, TAUM, W1 COMMON / C E L L S / C E L L P O ( 5 1 , 2 ) , C E L L P E ( 5 1 , 2 ) , C E L L P ( 5 1 , 2 ) , C E L L T ( 5 1 , 2 ) , DENSF(51,2), S I Z E X ( 5 1 ) , XINERT(51), THICK, NUMX, INOWP, IFUTP, INOWT, IFUTT COMMON /CHEMEL/ WGHT(10), NUMEL CHARACTER*20 PHNAME(25), SSNAME(20), GNAME(10), DNAME(3)  CHARACTER*8 F LNAME(10), AQNAME(25) CHARACTER*4 ELNAME(10) COMMON /CHNAME/ PHNAME, SSNAME, GNAME, DNAME, AQNAME, FLNAME, ELNAME COMMON /TRANS/ V E L 0 C ( 5 1 , 2 ) , AQCO(10,51,2), S O C O ( 1 0 , 5 1 , 2 ) , A L P H A ( 1 0 ) , INOWC, IFUTC PHNAME CONTAINS THE NAME OF A L L OF THE SOLID PHASES CONSIDERED AQNAME  CONTAINS THE NAME OF ALL OF THE AQUEOUS S P E C I E S  SSNAME GNAME  CONTAINS THE NAME OF ALL OF THE SOLID SOLUTION ENDMEMBERS CONSIDERED. CONTAINS THE NAME OF A L L OF THE GASES CONSIDERED  DNAME  CONTAINS THE DECAY  FLNAME  CONTAINS THE NAMES OF THE SPECIES/COMPONENTS FLOW CALCULATIONS  CELLPO  CONTAINS THE POROUSITY AT EACH OF THE NODES CELLPO(I.INOWC) AND C E L L P O ( I , I F U T C ) CONTAINS THE POROUSITY AT TIMES TAUC-DTAUC AND TAUC  CELLPE  CONTAINS THE PERMIABILITY AT EACH OF THE NODES UNITS ARE METERS**2 CELLPE(I,INOWC) AND C E L L P E ( I , I F U T C ) CONTAINS THE PERMEABILITY AT TIMES TAUC-DTAUC AND TAUC  CELLP  CONTAINS THE PRESSURE AT EACH OF THE NODES UNITS ARE MPA (1 BAR = 0.1 MPA) CELLP(I,INOWP) AND C E L L P ( I , I F U T P ) CONTAINS THE PRESSURE AT TIMES TAUP-DTAUP AND TAUP  CELLT  CONTAINS THE TEMPERATURE AT EACH OF THE NODE UNITS ARE DEG K C E L L T ( I , I N O W T ) AND C E L L T ( I , I F U T T ) CONTAINS THE TEMPERATURES AT TIMES TAUT-DTAUT AND TAUT  DENSF  CONTAINS THE DENSITY OF THE FLUID AT TIMES AT EACH OF THE NODES AT TIMES TAUC-DTAUC AND TAUC S I Z E ( I N METERS) OF EACH OF THE ELEMENTS  SIZEX THICK NUMX INOW?  CONSIDERED  REACTIONS USED  Y AND Z DIMENSIONS (EQUAL) FOR THE STREAM TUBE NUMBER OF NODES INDEX POINTING TO THE PRESENT TIME LEVEL FOR? = P - PRESSURE  FOR THE  C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C  ? = T - TEMPERATURE ? = C - COMPONENTS IFUT?  INDEX  POINTING TO THE NEXT TIME ? = P - PRESSURE ? = T - TEMPERATURE ? = C - COMPONENTS  LEVEL  FOR-  ELNAME  NAME OF THE ELEMENTS THAT DEFINE THE SPACE OF THE SYSTEM.  WGHT  ATOMIC  NUMEL  NUMBER OF ELEMENTS THAT OF THE SYSTEM.  DTAUP DTAUT  CONTAINS CONTAINS  THE DELTA TIME STEP FOR THE DELTA TIME STEP FOR  DTAUM DTAUC  CONTAINS CONTAINS  THE DELTA TIME STEP FOR THE CHEMICAL REACTIONS THE DELTA TIME STEP FOR MASS TRANSPORT  TAUP  CONTAINS  THE TIME AT IFUTP (THE TIME AT THE COMPLETION OF THE TIME STEP (DTAUP) (PRESSURE S T E P )  TAUT  CONTAINS  THE TIME AT IFUTT (THE TIME AT THE COMPLETION OF THE TIME STEP (DTAUT) (TEMPERATURE S T E P )  TAUC  CONTAINS  THE TIME AT IFUTC (THE TIME AT THE COMPLETION OF THE TIME STEP (DTAUC) (COMPONENT TRANSPORT S T E P )  TAUM  CONTAINS  THE TIME AT THE TIME OF COMPLETION FOR THE CHEMICAL REACTION STEPS  W1  -  WEIGHT OF THE SPACE OF THE  ELEMENTS SYSTEM.  COMPOSITIONAL  THAT DEFINE THE  COMPOSITIONAL  DEFINE THE COMPOSITIONAL  SPACE  PRESSURE TEMPERATURE  OF THE TIME STEP  WEIGHTING FACTOR FOR F I N I T E DIFFERENCE TIME APPROX. 0 <= W1 <= 1 W1 = 1 I M P L I C I T , W1 = .5 CRANK-NICOLSON I M P L I C I T , W1 = 0 EXPLICIT ERRMAXMAXIMUM ERROR ALLOWED IN PRESSURE (POSN 1 ) , TEMPERATURE (POSN 2 ) . COMPONENT MOVEMENT (POSN 3) (POSN 4 NOT USED) ERROR CALCULATED ERROR - SAME ORDER AS ABOVE FORMULA USED IS ABS((NEW VALUE - OLD VALUE) / NEW VALUE) LIMLOP - MAXIMUM NUMBER OF LOOPS TO BE USED IN CALCULATING THE ERROR ( 1 ) - PRESSURE, ( 2 ) - TEMPERATURE, ( 3 ) - COMPONENT MOVEMENT PMIN, PMAX, PTIME - PRESSURES - I N I T I A L P AT NODE 1, P AT NODE 1  c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c  PSTART TMIN,  TMAX, TTIME TSTART  AT TIMES PTIME AND GREATER. PSTART - TIME TO START INCREASING P - TEMPERATURES- I N I T I A L T AT NODE 1, T AT NODE 1 AT TIMES TTIME AND GREATER. TSTART - TIME TO START INCREASING T  COMMON BLOCK VARIABLES PREVIOUSLY DEFINED COMMON /SWIT/ I T S T E P ( 3 ) , IPSWIT, ITSWIT, ICSWIT, IMSWIT, NSTEPS LOCAL VARIABLES COMP TEMPERARY STORAGE FOR THE COMPOSITION OF A NODE LDUMMY - TEMPERARY LOGICAL ARRAY USED TO READ THE SYSTEM COMPOSITION ID  USED TO READ CHARACTERS FROM THE DATA F I L E AND TO DECIDE WHAT TYPE OF DATA IS BEING READ. ALPH - READ IN THE ALPHA FACTORS FOR FLOW AND THE SPECIES/COMPONENTS FOR FLOW COMP - COMPOSITION OF EACH NODE CHEM - MASS TRANSFER CALCULATIONS WILL BE MADE DIST - DISTANCE FROM ONE NODE TO ANOTHER END - END OF DATA ERRO - VALUES FOR ERROR SWITCHES - BETWEEN 0 AND MAXP - VALUE OF MAX P AS A FUNCTION OF TIME MAXT - VALUE OF MAX T AS A FUNCTION OF TIME NODE - NUMBER OF NODES DURING THIS RUN PERM - PERMEABILITY OF EACH NODE PORO - POROUSITY OF EACH NODE PRES - I N I T I A L PRESSURES FOR EACH NODE STEP - NUMBER OF STEPS STOP - END OF DATA TEMP - I N I T I A L TEMPERATURES FOR EACH NODE THIC - THICKNESS OF THE CELL ( I N Y AND Z DIM) TIME - S I Z E ( I N TIME) OF THE STEPS WEIG - WEIGHTING FACTOR FOR FD TIME STEP  POSN  HOLDS THE CALCULATED POSITION OF THE NODES  TITLE READS THE T I T L E CARDS FOR PRINTING REAL COMP(10), P 0 S N O 0 2 ) CHARACTER*1 LDUMMY(IOO) CHARACTER*4 I D ( 4 ) CHARACTER*100 T I T L E ZERO OUT SOME OF THE ARRAYS (-1.0E-50 INDICATES NO NUMX = 40 NXDIM = 51 CALL M I N I T ( X I N E R T , 51,  1, O.OEOO)  DATA)  1  CALL CALL CALL CALL CALL CALL CALL CALL CALL CALL CALL CALL DO 1  MINIT(CELLPE, MINIT(CELLPO. MINIT(CELLP, MlNIT(CELLT, MINIT(SIZEX, MINIT(COMP, MINIT(ALPHA, MINIT(ERRMAX, MINIT(ERROR,  51, 51 , 51. 51 , 51 , 10, 10, 4, 55,  I M I N I T ( I T S T E P , 3, I M I N I T ( L I M L O P , 5, IMINIT(L0PT0T,55, I = 1 , 25 PHNAME(I ) AQNAME(I ) CONTINUE DO 2 I = 1 , 20 SSNAME(I ) CONTINUE DO 3 I = 1 , 10 GNAME(I) FLNAME(I ) ELNAME(I ) CONTINUE DO 4 I = 1 , 3 DNAME(I) CONTINUE NCHEM = 10 TTIME = 0.000001 PTIME = 0.000001 PMIN 0.0 TMIN 0.0 PMAX -1 .0 TMAX -1 .0 PSTART = 0.0 TSTART = 0.0 TAUP 0.OEOO TAUT 0.OEOO TAUC O.OEOO TAUM O.OEOO DTAUP = 1.OEOO DTAUT = O.OEOO DTAUC = 0.OEOO DTAUM = O.OEOO ICSWIT = -2  2, -1.OE-50) 2, -1.OE-50) 2, -1 OE-50) 2, -1.OE-50) 1 , - 1.OE-50) 1 , O.OEOO) 1 , O.OEOO) 1 , 1.OEOO) O.OEOO) 1  i , 1) 1 , 5) 1 , 0)  C C  d  C C C C C C  C C  IPSWIT = - 2 ITSWIT = - 2 IMSWIT = - 2 INOWP = 1 INOWT = 1 = 1 INOWC IFUTP = 2 IFUTT = 2 = 2 IFUTC NUMEL = 0 THICK = 1.OEOO W1 = 1.OEOO NSTEPS = 0 WRITE(6,1930) READ AND P R I N T I N THE T I T L E C A R D ( S ) - STOP WHEN THE F I R S T FOUR CHARACTERS ARE STAR (SHORT FOR S T A R T ) I = O WRITE(6, 2140) 10 READ( 1 , 1 1 2 0 ) T I T L E I D ( 1 ) = TITLE I F ( I D ( 1 ) . E O . ' S T A R ' ) GO TO 4 0 WRITE(6,1940) TITLE GO TO 10 ************************************************** THE FOLLOWING LOOP I S THE MASTER LOOP WHICH CONTROLS THE READING I N OF THE D A T A . I T ENDS AT THE COMMENT L I N E WITH THE ROW OF * * * * * * READ I N S P E C I F I C COMAND I N D I C A T I N G WHAT K I N D OF DATA FOLLOWS AND GO TO THE SECTION OF THAT PROGRAM WHICH READS I T I N . 40 READ(1,1125,END=650) ( I D ( I ) , I = 1,4) I F ( I D ( 1 ) . E O . ' A L P H ' ) THEN READ I N THE NAMES OF THE FLOW COMPONENTS AND T H E I R A L P H A ' I F NONE ARE READ I N , THEN THERE I S NO MASS TRANSPORT READ ( 1 , 1 1 0 0 ) I C S W I T ICSWIT = ICSWIT + 1 DO 1 0 0 J = 2 , I C S W I T READ(1, 1150) FLNAME(J), ALPHA(U) 100 CONTINUE F L N A M E ( 1 ) = 'WATER ALPHA(1) = -1.0E00  C ELSE C C  IF  (ID(1)  .EO-  MASS TRANSFER IMSWIT = 1  'CHEM') -  YES  !!  THEN  ELSE  IF ( I D ( 1 )  .EO.  'COMP') THEN  READ IN COMPOSITIONAL DATA FOR  ELSE  ELSE  ENTIRE  GRID.  LDUMMY(1) = 'H' LDUMMY(2) = ' ( ' LDUMMY(3) = ' 1 ' LDUMMY(4) = ' ) ' LDUMMY(5) = '0' LDUMMY(6) = ' ( ' LDUMMY(7) = '2' LDUMMY(8) = ' ) ' READ(1,1140) (LDUMMY(I),I=9,100) CALL ELSORT(COMP,LDUMMY,ELNAME,NCHEM,NUMEL,100,6,1) IF ( I D ( 1 ) .EQ. 'DIST') THEN READ IN THE DIMENSION OF EACH ELEMENT IN X DIRECTION. READ(1.1100) NUM, ISTART I F I N = ISTART - 1 + NUM READ( 1 ,1110) ( S I Z E X ( I ) , 1 = 1 S T A R T , I F I N ) IF ( I D ( 1 ) .EO. 'END ') THEN END  ELSE  THE  OF DATA  GO TO 650 IF ( I D ( 1 ) .EQ. 'ERRO') THEN READ IN ERROR LIMIT AND LIMIT SWITCHS READ(1,1110) (ERRMAX(I), 1=1,3) READ(1,1100) ( L I M L O P ( I ) , 1 = 1 , 3 ) DO 120 I = 1, 3 IF(ERRMAX(I).GT.1.OEOO.OR.ERRMAX(I).LE.O.OEOO) ERRMAX(I) = 1.0E00 IF(LIMLOP(I).GT.100.OR.LIMLOP(I).LE.0) LIMLOP(I) = 1 CONTINUE  READ IN VALUES ELSE  NODE  1 PRESSURE  AS A FUNCTION  OF  TIME  IF ( I D ( 1 ) .EO. 'MAXP') THEN READ(1,1110) PMAX, PTIME, PSTART  READ IN VALUES ELSE  FOR  FOR  NODE  1 TEMPERATURE AS A FUNCTION  IF ( I D ( 1 ) .EO. 'MAXT') THEN READ(1,1110) TMAX, TTIME, TSTART  OF  TIME  ELSE  IF ( I D ( 1 ) .EQ. 'NODE') THEN READ IN THE NUMBER OF NODES IN X DIRECTION READ(1,1100) NUMX IF(NUMX.GT.NXDIM) THEN WRITE(6,1900) 1, NUMX.NXDIM STOP END IF ELSE IF ( I D ( 1 ) .EO. 'PERM') THEN READ IN PERMEABILITY DATA FOR EACH GRID POINT. FIRST READ PERMEABILITY, THEN THE NUMBER OF NODES AND THE NODE NUMBERS. READ IN AS L0G(1O) PERMEABILITY BUT STORED IN NORMALLY UNITS (METERS **2) READ(1,1100) NUM, ISTART I F I N = ISTART - 1 + NUM READ(1, 1110) ( C E L L P E ( I , 1 ) ,I = I S T A R T , I F I N ) DO 140 I = ISTART, I F I N CELLPE(I,1) = (10.OEOO)**CELLPE(I,1) CONTINUE  ELSE  IF ( I D ( 1 )  .EO.  'PORO') THEN  READ IN POROSITY DATA FOR EACH GRID POINT. FIRST READ THE POROSITY THEN THE NUMBER OF NODES AND THEN THE NODE NUMBERS. READ(1,1100) NUM, ISTART I F I N = ISTART - 1 + NUM READ( 1 , 1110) ( C E L L P O ( I , 1 ) ,I = I S T A R T , I F I N ) ELSE I F ( I D ( 1 ) .EO. 'PRES') THEN READ IN I N I T I A L PRESSURE DATA FOR EACH GRID POINT. FIRST READ IN THE PRESSURE, THEN THE NUMBER OF NODES AND THEN THEN THE NODE NUMBER. IF NUM IS NEGATIVE, THEN THESE I N I T I A L PRESSURE WILL BE HELD CONSTANT FOR THE REST OF THE RUN READ(1,1100) NUM, ISTART IF (IPSWIT.EQ.-2.OR.IPSWIT.GT.O) IPSWIT = ISIGN(1,NUM) NUM = IABS(NUM) I F I N = ISTART - 1 + NUM READ( 1 , 1110) ( C E L L P ( 1 , 1 ) , I = I S T A R T , I F I N ) ELSE I F ( I D ( 1 ) .EQ. 'STEP') THEN READ  IN THE MAX. NUMBER OF STEPS - AND NUMBER OF LOOPS TEMPERATURE, COMPONENTS AND MASS TRANSFER  FOR  READ ( 1 , 1100) NSTEPS, ( I T S T E P ( I ) ,I = 1,3) IF ( N S T E P S . L T . 0 ) NSTEPS = 0 DO 160 I = 1, 3 IF ( I T S T E P ( I ) . L T . 1 ) I T S T E P ( I ) = 1 CONTINUE ELSE I F ( I D ( 1 ) .EO. 'STOP') THEN END OF DATA GO TO 650 ELSE  IF (ID(1)  .EO.  'TEMP') THEN  READ IN I N I T I A L TEMPERATURE FOR EACH GRID POINT. FIRST READ TEMPERATURE, THEN NUMBER OF NODES THEN THE NODE NUMBERS. IF NUM IS NEGATIVE, THEN THE TEMPERATURE IN EACH CELL WILL BE HELD CONSTAINT THROUGH OUT THE RUN  ELSE  READ(1,1100) NUM, ISTART IF(ITSWIT.EO.-2.OR.ITSWIT.GT.0) ITSWIT = ISIGN(1,NUM) NUM = IABS(NUM) I F I N = ISTART - 1 + NUM READ(1,1110) ( C E L L T ( 1 , 1 ) , 1 = 1 S T A R T , I F I N ) IF ( I D ( 1 ) .EO. 'THIC') THEN  ELSE  READ IN THICKNESS OF GRID (METERS) READ(1,1110) THICK I F ( T H I C K . L T . 1 . O E - 0 5 ) THICK = 1.0E-05 IF(THICK.GT.1.OE+04) THICK = 1.0E+04 IF ( I D ( 1 ) .EO. 'TIME') THEN READ THE SIZE  OF THE TIME (PRESSURE) STEP AND  ELSE  READ ( 1 , 1110) DTAUP, TAUP I F ( I D ( 1 ) .EO. 'WEIG') THEN  ELSE  READ IN THE WEIGHTING PARAMETER READ ( 1 , 1110) W1 IF ( I D ( 1 ) .NE. ' ') THEN IGNORE BLANK L I N E S . WHAT IS I T ? WRITE OUTPUT WRITE(6,1920) STOP  END IF READ MORE DATA  1,  ERROR  INITIAL  FOR THE FD TIME  STEP  MESSAGE  (ID(I),I=1,4)  - ONLY WAY  OUT  IS VIA STOP OR  END  COMMANDS  TIME  IN DATA  OR BY AN END OF F I L E IN DATA  GO TO 4 0 *****************************************************  650  CHECK FOR DATA AT THE FIRST ELEMENT AND THE FIRST NODE IF (IPSWIT.EO " 2) IPSWIT = -1 IF (ITSWIT. EQ. -2) ITSWIT = -1 IF (ICSWIT.EQ.- 2) ICSWIT = -1 IF (IMSWIT.EQ.- 2) IMSWIT = -1 IF (IPSWIT.EQ.- 1) I T S T E P ( 1 ) = 1 IF ( I T S W I T . E Q . - 1) I T S T E P ( 2 ) = 1 IF (ICSWIT.EQ.- 1) I T S T E P ( 3 ) = 1 IF ( C E L L P E ( 1,1) . EQ. -1.OE-50) WRITE(6,1910) IF ( C E L L P O ( 1,1) .EQ . -1.OE-50) WRITE(6,1911) IF ( C E L L T ( 1,1) . EQ. -1.OE-50) WRITE(6,1912) IF ( C E L L P ( 1 , 1 ) .EQ . -1.OE-50) WRITE(6, 1913) IF ( S I Z E X ( 1 ) .EQ . -1.OE-50) WRITE(6,1914) IF ( C E L L P E ( 1,1) .EQ . -1.OE-50) STOP IF ( C E L L P O ( 1 , 1 ) . EQ. -1.OE-50) STOP IF ( C E L L T ( 1 , 1 ) . EQ. -1.OE-50) STOP IF ( C E L L P ( 1 , 1 ) • EQ. -1.OE-50) STOP IF ( S I Z E X ( 1 ) . EQ. -1.OE-50) STOP SET  700  UP SOME DEFAULTS  TAUT = TAUP TAUC = TAUP TAUM = TAUP PTIME = TAUP + PTIME TTIME = TAUP + TTIME DTAUT = DTAUP / F L O A T ( I T S T E P ( 1 ) ) DTAUC = DTAUP / F L O A T ( ( I T S T E P ( 1 ) * I T S T E P ( 2 ) ) ) DTAUM = DTAUP / F L O A T ( ( I T S T E P ( 1 ) * I T S T E P ( 2 ) * I T S T E P ( 3 ) ) ) IF ANY DATA IS MISSING, USE DATA FROM PRECEEDING NODE/ELEMENT CALCULATE THE POSITION OF EACH NODE P 0 S N ( 1 ) = O.OEOO DO 700 1 = 2 , NUMX IF ( S I Z E X ( I ) EQ. = SIZEX(I-I) .OE-50) S I Z E X ( I ) IF ( C E L L P E ( I , 1 ) . EQ. .OE-50) C E L L P E ( I , 1 ) = C E L L P E ( 1-1 , 1 ) . OE-50) C E L L P O ( I , 1) = C E L L P O ( 1 - 1 , 1 ) IF (CELLPO( I , 1 )EQ. OE-50) C E L L P ( I , 1) IF ( C E L L P ( 1 , 1 ) . EQ. = CELLP(1-1 , 1 ) OE-50) C E L L T ( I , 1) IF ( C E L L T ( I , 1 ) . EQ. = C E L L T ( I - 1 , 1) S I Z E X ( I -1) P O S N ( I ) = POSN(I -1) CONTINUE PMIN = C E L L P ( 1 ,1)  TMIN = C E L L T ( 1 , 1 ) IF (PMAX . L E . 0.0) PMAX = C E L L P ( 1 , 1 ) IF (TMAX . L E . 0.0) TMAX = C E L L T ( 1 , 1 ) MUST BE SAME AS PRESENT SET UP I N I T I A L GUESSES FOR THE FUTURE DO 750 1 = 1 , NUMX CELLPE(I,INOWC) CELLPE(I,IFUTC) CELLP(I,INOWP) CELLP(I,IFUTP) CELLPO(I,INOWC) CELLPO(I,IFUTC) CELLT(I,INOWT) CELLT(I,IFUTT) CONTINUE OUTPUT - V A R I F I C I A T I O N OF INPUT 6,1950) NUMX 7,1100) NUMX, IPSWIT 8,1100) NUMX, ITSWIT 9,1100) NUMX, NUMEL, ICSWIT 10,1100) NUMX 11,1100) NUMX 7,1100) NSTEPS 8,1100) NSTEPS, I T S T E P ( 1 ) 9,1100) NSTEPS, ( I T S T E P ( I ) , 1=1,2) 6,1960) 6,1970) ( S I Z E X ( I ) , I = 1 , ( N U M X - 1 ) ) 6,1975) =1,NUMX) 6,1970) ( P O S N ( I ) =1.NUMX) 7,1130) ( P O S N ( I ) =1,NUMX) 8,1130) ( P O S N ( I ) =1,NUMX) 9,1130) ( P O S N ( I ) =1,NUMX) 10,1130) ( P O S N ( I ) =1,NUMX) 11,1130) ( P O S N ( I ) 6,1980) THICK 6,1990) (ELNAME(I ) , 1=1, NUMEL) 6,2000) 6, 1971) ( C E L L P E ( 1 , 1 ) , 1=1,NUMX) 6,2010) 6,1970) ( C E L L P 0 ( I , 1 ) , 1=1,NUMX) 6,2020) 6,1972) ( C E L L P d . O , 1 = 1,NUMX) 6,2030) 6,1972) ( C E L L T ( I , 1 ) , I=1,NUMX) I F ( I P S W I T . E O . - I ) WRITE( 6,2040) I F ( I T S W I T . E Q . - I ) WRITE( 6,2050) I F ( I M S W I T . E Q . - I ) WRITE( 6,2070) IF (ICSWIT.GT.O) THEN WRITE(6, 2 1 1 0 )  DO  770  780  790  CO CO  1100 1 1 10 1 120 1 125 1 130 1 140 1 150 1900  1910 191 1 1912 19 13 1914 1920  1930  770 1 = 1 , ICSWIT IF ( A L P H A ( I ) . L T . O . O E O O ) GO TO 770 WRITE(6,2120) F L N A M E ( I ) , ALPHA(I )  ELSE  CONTINUE  ENDIF WRITE( WRITE( WRITE( DO 780  WRITE(  6,2060)  6,2090) W1 6,2080) NSTEPS, ( I T S T E P ( I ) , I = 1 , 3 ) 6,2100) TAUP, DTAUP, DTAUT, DTAUC, DTAUM 1 = 1,3 ERRMAX(I ) = ERRMAX(I) * 100.0 CONTINUE WRITE( 6,2130) ( E R R M A X ( I ) , L I M L O P ( I ) , I = 1 , 3 ) DO 790 1 = 1 , 3 ERRMAX(I) = ERRMAX(I) / 100.0CONTINUE IF (PMAX .NE. PMIN) WRITE(6, 2160) PMIN, PMAX, PTIME, PSTART IF (TMAX .NE. TMIN) WRITE(6, 2180) TMIN, TMAX, TTIME, TSTART RETURN FORMATS F0RMAT(2615) FORMAT(8F10.3) FORMAT(A 100) FORMAT(30A4) FORMAT(10(1X.E12.5)) FORMAT(100A1) F0RMAT(A8,8X,F8.5) FORMAT(' FROM DATA READ FROM FORTRAN UNIT ',12, ', THE NUMBER OF ',/, ' NODES IN THE X DIRECTIONS IS ',15,/, ' IT MUST BE LESS THAN ',14,'.') FORMAT(' FROM DATA READ FROM FORTRAN UNIT ',12, '. THE PERMEABILITY OF THE FIRST NODE IS MISSING.') FORMATC FROM DATA READ FROM FORTRAN UNIT ',12, ', THE POROUSITY OF THE FIRST NODE IS MISSING.') FORMATC FROM DATA READ FROM FORTRAN UNIT ',12, ', THE TEMPERATURE OF THE FIRST NODE IS MISSING.') FORMAT(' FROM DATA READ FROM FORTRAN UNIT ',12, ', THE PRESSURE OF THE FIRST NODE IS MISSING.') FORMAT(' FROM DATA READ FROM FORTRAN UNIT '.12, '. THE S I Z E OF THE FIRST ELEMENT IS MISSING.') FORMAT(' FROM DATA READ FROM FORTRAN UNIT ',12, '. THE DATA COMMAND',/, 'GIVEN :" ',4A4,' " IS INVALID. CORRECT AND RERUN.') FORMAT(':',/,' 1 ' )  1940 1950 1960 1970 1971 1972 1975 1980 1990 2000 2010 2020 2030 2040 2050 2060 CO  2070 2080  2090 2100  21 10  2120 2130  F0RMAT( F0RMAT( FORMAT( FORMAT( FORMAT( FORMAT( FORMAT( FORMAT( FORMAT(  ' ',A100) 'O','NUMBER OF NODES = ',15) ' 0 ' , ' S I Z E OF ELEMENTS (METERS)',/) 10(3X,F10.3)) 10(1X,E12.5)) 10(3X,F10.1)) '0','POSITION OF EACH OF THE NODES (METERS) ',/) 'O','THICKNESS OF GRID IN METERS = '.E12.5,/) ' SYSTEM IS COMPOSED OF THE FOLLOWING ELEMENTS:', 10(' ',10(A4.1X),/)) FORMAT( 'OINITIAL PERMEABILITY IN EACH NODE (METERS**2 ) ',/) FORMAT( 'OINITIAL POROUSITY IN EACH NODE ',/) FORMAT( 'OINITIAL PRESSURES IN EACH NODE (MPA)',/) FORMAT( ' O I N I T I A L TEMPERATURES IN EACH NODE (DEG K ) ' , / ) FORMAT( 'OALL NODE PRESSURES ARE FIXED THROUGH THE ENTIRE', ' RUN.') FORMAT( 'OALL NODE TEMPERATURES ARE FIXED THROUGH THE ', 'ENTIRE RUN. ') FORMAT( 'ONO MASS FLUX BETWEEN THE NODES WILL BE ALLOWED ', 'THIS RUN.') FORMAT( 'ONO CHEMICAL REACTIONS WILL BE CALCULATED THIS RUN.') FORMAT( '0 MAX. NUMBER OF TIME (PRESSURE) STEPS IS ',18,//, FOR EACH PRESSURE STEP, THERE IS ',15, ' TEMPERATURE S T E P S ' , / , FOR EACH TEMPERATURE STEP, THERE IS ',15, ' SOLUTE TRANSPORT S T E P S ' , / , ' FOR EACH SOLUTE TRANSPORT STEP, THERE IS ',15, ' CHEMICAL REACTION S T E P S . ' ) FORMAT( 'OWEIGHTING FACTOR FOR THE F I N I T E DIFFERENCE TIME STEP' ' I S : '.F10.5) FORMAT( 'OTHE I N I T A L TIME I S : '.E12.5,' SECONDS',//, THE INITAL PRESSURE TIME STEP I S : '.E12.5, ' SECONDS',/, THE I N I T A L TEMPERATURE TIME STEP I S : '.E12.5, ' SECONDS',/, ' THE I N I T A L COMPONENT TRANSPORT TIME STEP I S : '.E12.5, ' SECONDS',/, THE INITAL CHEMICAL REACTION TIME STEP I S : '.E12.5, ' SECONDS.') FORMAT( 'OTHE FOLLOWING AQUEOUS SPECIES HAVE BEEN CHOSEN ', 'AS MOBILE COMPONENTS',//, 14X,'NAME',15X,'LONG. D I S P E R S I V I T Y ' , / ) FORMAT( ' ',11X,A8,20X,F8.5) FORMAT( / / ,24X,'PERCENT MAXIMUM ERROR',5X, 'MAX. NUMBER ITERATIONS', /,6X, ' PRESSURE',14X,E12.5,16X,15,/,  2140 2160  2180  oo  6X ' TEMPERATURE',11X,E12.5,16X,I5,/, 6X ' TRANSPORT',13X,E12.5,16X,15,/) FORMAT(' T I T L E INFORMATION READ FROM DATA ATTACHED TO UNIT 1 ///) ,F10.4, FORMAT(///.' THE PRESSURE AT NODE 1 WILL I N I T I A L L Y BE: ',F10.4, / ,27X, ' AND RAISED TO: ' OVER '.F10.4,' SECONDS', / ,36X, ' STARTING AT '.F10.4,' SECONDS') / ,30X, FORMAT(/// , ' THE TEMPERATURE AT NODE 1 WILL I N I T I A L L Y BE: F10.4 /,30X,' AND RAISED TO: , F 10. /,36X , ' OVER ,F10. SECONDS', /,30X, STARTING AT ,F10. SECONDS' ) END SUBROUTINE SETUP2 NEW COMMON BLOCKS COMMON /CHEMPH/ COMPPH(10,25), COMMON /CHEMAQ/ COMPAQ(10,25), COMMON /CHEMSS/ COMPSS(10,20), COMMON /CHEMG / COMPG(10,10),  T H E R P H ( 1 4 , 2 5 ) , NUMPH THERAQ(13,25), NUMAQ THERSS(8,20), NUMSS THERG(6,10), NUMG  COMPPH, COMPAQ, COMPSS, COMPG - CONTAINS THE COMPOSITION OF THE MINERALS, AQUEOUS S P E C I E S , SOLID SOLUTION ENDMEMBERS AND GASSES IN THE ORDER OF THE ELEMENTS IN ELNAME. THERPH,  THERAQ, THERSS, THERG - CONTAINS THE THERMODYNAMIC PROPERTIES OF THE MINERALS, AQUEOUS S P E C I E S , SOLID SOLUTION ENDMEMBERS AND GASSES. ORDER IS GIVEN IN THE APPROPRIATE SECTION BELOW. NUMPH, NUMAQ, NUMSS, NUMG - NUMBER OF MINERALS, AQUEOUS S P E C I E S SOLID SOLUTION ENDMEMBERS AND GASSES PREVIOUSLY DEFINED COMMON BLOCKS COMMON /SWIT/ I T S T E P ( 3 ) , IPSWIT, ITSWIT, ICSWIT IMSWIT, NSTEPS COMMON /CHEMEL/ WGHT(10), NUMEL COMMON /TRANS/ V E L 0 C ( 5 1 , 2 ) , A Q C O ( 1 0 , 5 1 , 2 ) , SOCO(10,51,2) A L P H A ( 1 0 ) , INOWC, IFUTC CHARACTER*20 PHNAME(25), SSNAME(20), GNAME(10), DNAME(3) CHARACTER*8 FLNAME(10), AQNAME(25) CHARACTER*4 ELNAME(10) SSNAME, GNAME, DNAME, AQNAME, FLNAME, COMMON /CHNAME/ PHNAME ELNAME REAL DATA(14 ) , WEIGHT(40), PHCMP(40) C0MP(1O,25), A ( 1 0 . 1 0 ) INTEGER N S Y C 0 ( 4 O ) , I P O I N T ( 1 0 ) CHARACTER*20 DUM  CHARACTER*8 ABV CHARACTERM CONAME (40) , LTYPE (8 ) CHARACTER*1 LDUMMY(101)  12  00  DATA  LTYPE/  'MINE' 'REFE'  CALL CALL CALL CALL CALL  MINIT(COMPG, MINIT(COMPSS, MINIT(COMPPH, MINIT(COMPAO, MINIT(WEIGHT,  ' AQUE', 'SOLI ' 'DECA' , 'STOP' 10, 10, 10, 10, 40,  10, 20, 25, 25, 1,  'GASE', 'END '/  O.OEOO) O.OEOO) O.OEOO) O.OEOO) O.OEOO)  CALL I M I N I T ( I P O I N T , 10, 1, 0 ) CALL IMINIT(NSYCO, 40, 1, O) DO 12 I = 1, 40 CONAME(I) = ' CONTINUE NUMPH = O NUMG = 0 NUMAO = 0 NUMSS = 0 NUMD = 0 READ NUMBER OF ELEMENTS IN DATA F I L E READ(2,1001) NCTZ READ IN THE ELEMENTAL SYMBOLS READ(2,1002) (CONAME(I),I=1,NCTZ) READ THE WEIGHT'S OF EACH OF THE ELEMENTS READ(2, 1003) (WE I G H T ( I ) , 1 = 1,NCTZ)  CORRELATE SYSTEM ELEMENTS WITH ELEMENTS IN DATA F I L E DO 30 J = 1, NUMEL DO 20 I = 1,NCTZ IF (ELNAME(J).EQ.CONAME(I)) THEN WGHT(J) = WEIGHT(I) NSYCO(I) = d GO TO 30 ENDIF 20 CONTINUE WRITE(6,1004) ELNAME(d), 1, 2, 1 STOP 30 CONTINUE READ IN NEXT LINE .  THIS SHOULD BE A COMMAND  LINE AND  C C C C  C C C C C C C C C C C C C C  WILL T E L L WHICH SECTION OF THE DATA F I L E IS BEING READ. ALL LINES WITH A BLANK FIRST CHARACTER ARE IGNORED. THE ONLY ACCEPTABLE FIRST CHARACTER IS A * TO INDICATE A COMMAND 40 READ(2,1021,ERR=700,END=700) (LDUMMY(I),1=1,101) IF (LDUMMY(1) .EQ. ' ') GO TO 40 45 IF (LDUMMY(1) .NE. '*') THEN WRITE(6,1007) 2, LDUMMY STOP ENDIF K = 1 I F I N = 101 CALL IGNORE(LDUMMY, 101, '*', 1, K, I F I N , IFOUND) IF (IFOUND.EQ.O) GO TO 40 IFOUND = IFOUND - 1 DO 70 K =1,8 DO GO J = 1,4 I = I FOUND + J IF ( L D U M M Y ( I ) . N E . L T Y P E ( K ) ( d : d ) ) GO TO 70 60 CONTINUE GO TO ( 1 0 0 , 200, 300, 400, 500, 600, 700. 7 0 0 ) , K 70 CONTINUE WRITE(6,1005) LDUMMY, 2 STOP THIS SECTION IS FOR SOLID PHASES. READ IN: NAME, FORMULA, ABREVIATION H, S. V, A, B, C, D, E, F, G DV/DT, DV/DP, CONDUCTIVITY VALUES ARE AT TR AND PR ( 2 9 8 . 1 5 DEG. K. AND 0.1 MPA) IF H > 999999, IGNORE PHASE, IF PHASE CONTAINS ELEMENTS NOT IN ELNAME, IGNORE. STORE PROPERTIES IN ARRAY THERPH IN ORDER: MW (GRAMS/MOLE), H (d/MOLE), S (d/MOLE/DEG), V (CM**3/M0LE), A (d/MOLE/DEG), B(d/MOLE/DEG**2), C ( d DEG/MOLE), D(d/MOLE/DEG**.5) E (d/MDLE/DEG**3), F ( J / M O L E ) , G(dDEG**3/M0LE), DV/DT (CM**3/DEG/M0LE ) DV/DP (CM**3/MPA/M0LE), CONDUCTIVITY ( d / ( M SEC DEG MOLE) 100  READ(2,1021,ERR=700,END=700) (LDUMMY(I),I=1,101) IF (LDUMMY(1) .EQ. '*') GO TO 45 READ(2,1006) ( D A T A ( I ) , 1= 1, 3) READ(2,1006) ( D A T A ( I ) , 1= 4, 10) R E A D ( 2 , 1 0 0 6 ) ( D A T A ( I ) . 1= 11, 13) IF (DATA(1).GT.999999.EOO) GO TO 100 CALL DECODE(PHCMP,DUM,NCTZ,CONAME,LDUMMY,ABV,101,40,0) DO 110 K = 1,NCTZ  110  130  140  £ Oo  C C C C C C C C C C  IF (NSYCO(K).EQ.O.AND.PHCMP(K).NE.O.OEOO) GO TO CONTINUE NUMPH = NUMPH + 1 PHNAME(NUMPH) = DUM GMW = O.OEOO DO 130 I = 1,NCTZ K = NSYCO(I) I F ( K . E Q . O ) GO TO 130 COMPPH(K,NUMPH) = PHCMP(I) GMW = GMW + (PHCMP(I) * W E I G H T ( I ) ) CONTINUE THERPH(1,NUMPH) = GMW DO 140 I = 1, 13 II = I + 1 THERPH(II,NUMPH) = D A T A ( I ) CONTINUE GO TO 100 THIS SECTION IS FOR AQUEOUS S P E C I E S READ IN NAME, FORMULA, ABREVIATION H, S, C1, C2, A1, A2, A3, A4, THETA, W, Z ALL VALUES ARE AT TR AND PR (298.15 DEG. K AND  200  210  230  0.1  100  MPA)  IF H > 999999, IGNORE S P E C I E S . IF S P E C I E S CONTAINS ELEMENTS NOT ELNAME, IGNORE. STORE PROPERTIES IN ARRAY THERAQ IN ORDER: MW, H, S, C1, C2, A1, A2, A3, A4, THETA, W, Z, AZERO READ(2,1021,ERR=700,END=700) (LDUMMY(I),1=1,101) IF (LDUMMY(1 ) .EQ. '*') GO TO 45 READ(2,1006) ( D A T A ( I ) , I = 1 , 6 ) READ(2,1006) ( D A T A ( I ) , I = 7 , 1 1 ) IF ( D A T A ( 1 ) . G T . 9 9 9 9 9 9 . E O O ) GO TO 200 CALL DECODE(PHCMP,DUM,NCTZ.CONAME,LDUMMY,ABV,101,4O,0) DO 210 K = 1,NCTZ IF (NSYCO(K).EQ.O.AND.PHCMP(K).NE.O.OEOO) GO TO 200 CONTINUE NUMAQ = NUMAQ + 1 AQNAME(NUMAQ) = DUM GMW = O.OEOO DO 230 I = 1,NCTZ K = NSYCO(I) I F ( K . E Q . O ) GO TO 230 COMPAQ(K,NUMAQ) = PHCMP(I) GMW = GMW + (PHCMP(I) * W E I G H T ( I ) ) CONTINUE THERAQ(1,NUMAQ) = GMW  IN  240  C 300  C C C C C C C C  DATA(6 ) = DATA(6 ) * 1.0E-05 DATA(7) = DATA(7 ) * 1.0E-02 DATA(8 ) = DATA(8 ) * 1.0E-05 D A T A ( 1 0 ) = D A T A ( 1 0 ) * 1.0E+05 DO 240 1=1, 11 II = I + 1 THERAQ(11,NUMAQ) = D A T A ( I ) CONTINUE IF (AQNAME(NUMAQ) .EQ. 'WATER ') THEN THERAQ(13,NUMAQ) = 0.0 ELSE WABS = D A T A ( 1 0 ) + ( O . 5 3 8 7 E 0 5 * 4 . 1 8 4 E 0 0 * D A T A ( 1 1 ) ) IF (DATA( 1 1 ) .GE. 0.0) THEN AZERO = 1.81E00 ELSE AZERO = 1 .91E00 ENDIF AZERO = ( 1 . 6 6 0 2 7 E 0 5 * 4 . 1 8 4 E 0 0 * ( D A T A ( 1 1 ) * * 2 ) / WABS) + (ABS(DATA( 1 1 ) ) * AZERO) AZERO = AZERO * 2.0E-08 / ( A B S ( D A T A ( 1 1 ) ) + 1.0E00) THERAQ(13,NUMAQ) = AZERO ENDIF GO TO 200 THIS SECTION IS FOR SOLID SOLUTION PHASE DATA READ(2,1021,ERR=700,END=700) (LDUMMY(I),I=1,101) IF (LDUMMY(1) .EQ. '*') GO TO 45 GO TO 300  THIS SECTION IS FOR GASES. READ IN NAME, FORMULA, ABREVIATION H, S, V A, B, C, D, E, F, G IF H > 999999, IGNORE PHASE, IF PHASE CONTAINS ELEMENTS NOT IN ELNAME, IGNORE. STORE PROPERTIES IN ARRAY THERG IN ORDER: MW,H,S,V,A,B,C,D,E,F,G 400 READ(2,1021,ERR=700,END=700) (LDUMMY(I),I=1,101) IF (LDUMMY(1) .EQ. '*') GO TO 45 READ(2,1006) ( D A T A ( I ) . I = 1, 3) READ(2,1006) ( D A T A ( I ) . I = 4, 10) IF (DATA(1).GT.999999.EOO) GO TO 400 CALL DECODE(PHCMP.DUM,NCTZ,CONAME,LDUMMY,ABV,101,40,0) DO 410 K = 1.NCTZ IF (NSYCO(K).EQ.O.AND.PHCMP(K).NE.O.OEOO) GO TO 400 410 CONTINUE NUMG = NUMG + 1 GNAME(NUMG) = DUM  430  440 C C C C  GMW = O.OEOO DO 430 I = 1 ,NCTZ K = NSYCO(I) I F ( K . E Q . O ) GO TO 430 COMPG(K.NUMG) = PHCMP(I) GMW = GMW + (PHCMP(I) * W E I G H T ( I ) ) CONTINUE THERG(1,NUMG) = GMW DO 4 4 0 1=1,5 II = I + 1 THERG(II,NUMG) = D A T A ( I ) CONTINUE GO TO 400 END OF GAS DATA REFERENCE DATA  500  - THIS  IS IGNORED  BY THE PROGRAM  READ(2,1021,ERR=700,END=700) (LDUMMY(I),1=1,101) IF (LDUMMY(1) .EO. '*') GO TO 45 GO TO 500 C????????????????????????????7???????????? C C DECAY DATA - THIS IS USED TO CALCULATE THE DECAY FROM C ONE ELEMENT TO ANOTHER. C C FORMAT - NAME, DECAY REACTION C 1/2 L I F E , ENERGY C C NAME I S USED FOR REFERENCE PURPOSES C DECAY REACTION IS THE REACTION WRITTEN IN A FORMULA CODE. C SUPPOSE CALCIUM DECAYED TO TWO OXYGENS AND ONE HYDROGEN, C THE DECAY REACTION WOULD READ: C A ( 1 ) 0 ( - 1 . 0 ) H ( - 1.0) 600 READ(2,1021,ERR=700,END=700) (LDUMMY(I),I=1,101) IF (LDUMMY(1) .EO. '*') GO TO 45 NUMD = NUMD + 1 GO TO 6 0 0 C CHANGE THE COMPONENT BASIS TO ONE COMPOSED OF AQUEOUS S P E C I E S C NOTE THAT THE AQUEOUS S P E C I E S FIRST CHOSEN WILL BE THE C S P E C I E S USED FOR TRANSPORT. C FIRST MAKE A COPY OF THE ARRAY, AND THEN USE THE FIRST C S P E C I E S FOUND IN EACH ROW AS THE NEW COMPONENT C 700 K = NUMEL + 1 DO 710 I = 1, NUMAQ COMPAQ(K.I) = THERAQ(12,1) * (-1.0) 710 CONTINUE  CALL C C C C C  FIND  712  715  7 16 717  718  719  720 C C C C  MCOPY(COMP,COMPAQ,1,1,K,NUMAQ,10,25,10,25) A AQ. S P E C I E S , IF ONE NOT FOUND, PUT IN I D E N T I F I E R FOR AN IDENTITY COLUMN AND DON'T PROCESS ANY MORE  ISTART = 0 DO 715 I = 1 , K I F . ( A L P H A ( I ) . N E . 0 . 0 ) THEN DO 712 J = 1, NUMAQ IF (FLNAME(I).NE.AQNAME(d ) ) GO TO 712 IF ( A L P H A ( I ) . L T . 0 . 0 ) A L P H A ( I ) = 0.0 IPOINT(I) = d ISTART = I GO TO 715 CONTINUE WRITE(6,1019) FLNAME(I) STOP ENDIF CONTINUE ISTART = ISTART + 1 DO 716 I = ISTART, K, 1 I P O I N T ( I ) = ( I - ISTART + 1) * (-1) CONTINUE DO 720 I = 1, K IF ( I P O I N T ( I ) .GT. 0 ) THEN DO 718 d = 1, K A ( d , I ) = COMPAQCd, I P O I N T ( I ) ) CONTINUE ELSE DO 719 d = 1, K A ( d , I ) = 0.0 CONTINUE d = IABS(IPOINT(I)) A ( d , I ) = 1.0 ENDIF CONTINUE INVERT TEMP. BASIS MULTIPLY THROUGH IF NOT SINGULAR ELSE TRY FOR A NEW ONE CALL INVRT(A,K, 10, I ER) IF ( I E R .EQ. 0 ) THEN CALL MMULT(C0MP, A, COMPAQ, K, K, NUMAQ, 10, 10, 25) ELSE  10, 25, 10,  721  730  M  IPOINT(K) = IPOINT(K) - 1 IF ( I P O I N T ( K ) .GE. ( ( - 1 ) * K ) ) THEN GO TO 717 ELSE 11 = K - 1 IPOINT(H) = IPOINT(H) - 1 DO 730 I = (11 + 1 ) , K IPOINT(I) = IPOINT(I-I) - 1 CONTINUE IF ( I P O I N T ( K ) .GE. ( ( - 1 ) * K ) ) THEN GO TO 717 ELSE 11 = 11 - 1 IF (11 .LT. ISTART) THEN WRITE(6 , 1015) STOP ENDIF GO TO 721 ENDIF ENDIF NOW BUILD THE REMAINING COMPONENTS USING AQUEOUS S P E C I E S  C C C  735 740  741  742  745  REMAINING  DO 750 I = ISTART, K DO 735 J = 1, NUMAQ IF ( A B S ( C O M P ( I , J ) ) .GT.0.01) THEN IPOINT(I) = J ALPHA(I ) = 0.0 FLNAME(I) = AQNAME(J) GO TO 740 ENDIF CONTINUE DO 745 J<J = 1 , K IF ( I P O I N T ( J U ) .GT. 0 ) THEN DO 741 d = 1 , K A ( d , J J ) = COMPAQ(d, I P O I N T ( J J ) ) CONTINUE ELSE DO 742 J = 1, K A ( J , U O ) = 0.0 CONTINUE J = IABS(IPOINT(JJ)) A ( d , J J ) = 1.0 ENDIF CONTINUE  INVERT NEW  750  BASIS AND MULTIPLY  THROUGH  CALL I N V R T ( A , K , 1 0 , I E R ) IF ( I E R .NE. 0 ) THEN WRITE(6,1015) STOP ENDIF CALL MMULT( COMP, A, COMPAQ, K, K, NUMAQ, 10, 25, 10, 10, 10, 2 5 ) CONTINUE CALCULATE NEW COMPOSITION ARRAYS BASED DN LAST COMPONENT AQUEOUS  ARRAY  SPECIES  CALL MC0PY(COMPAQ,C0MP,1,1,K,NUMAQ,10,25, 10,25) SOLID PHASES IF  (NUMPH.GT.O) THEN CALL MMULT(COMP,A,COMPPH,K,K,NUMPH,10,25,10,10,10,25) CALL MCOPY(COMPPH,COMP,1,1,K,NUMPH,10,25,10,25) ENDIF GASSES  IF  (NUMG.GT.O) THEN CALL MMULT(COMP,A,COMPG,K,K NUMG,10,25,10,10,10,10) CALL MCOPY(COMPG,COMP,1,1,K NUMG,10,10,10,25) ENDIF SOLID SOLUTION PHASES IF (NUMSS.LE.O) THEN CALL MMULT(COMP,A,COMPSS,K,K, NUMSS,10,25,10,10,10,20) CALL MCOPY(COMPSS,COMP,1,1,K, NUMSS,10,25,10,20) ENDIF COLLAPSE MATRIX'S AND LOOK FOR THE NUMBER OF COMPONENTS TAKE OUT PHASES ( E T C ) WITH WRONG COMPONENTS NUMEL = O DO 800 I = 1 , K IP = I P O I N T ( I ) UJ = NUMEL + 1 IF ( I P .GT. 0 ) THEN NUMEL = NUMEL + 1 ELSE IF ( J J . N E . K ) THEN COLLAPSE AQUEOUS SPECIES CALL MROW(COMPAQ,JJ,K,NUMAQ,10,25) COLLAPSE SOLID PHASES - FIRST CHECK IF ANY PHASES  MUST BE THROWN OUT IF  775 776  4>  785 786  795 796  800  (NUMPH.GT.0) THEN 12 = NUMPH DO 775 J = 1, 12 IF (J.GT.NUMPH) GO TO 776 IF ( A B S ( C O M P P H ( I , d ) ) . L E . 0 . 0 0 1 ) CALL MCOL(COMPPH, J , K, NUMPH, CALL MCOL(THERPH, d,14, NUMPH, CALL MCOL(PHNAME, J , 1, NUMPH, NUMPH = NUMPH - 1 CONTINUE CALL MROW(COMPPH,dd,K,NUMPH,10,25) ENDIF  GO TO 775 10, 25) 14, 2 5 ) 1 , 25)  COLLAPSE GASSES - FIRST CHECK IF ANY MUST BE THROWN OUT IF (NUMG.GT.O) THEN 12 = NUMG DO 785 d = 1, 12 IF (d.GT.NUMG) GO TO 786 IF ( A B S ( C O M P G ( I , d ) ) . L E . 0 . 0 0 1 ) GO TO 785 CALL MCOL(COMPG,d,K,NUMG,10,10) CALL MCOL(THERG,d,6,NUMG,6,10) CALL MCOL(GNAME,d,1,NUMPH,1,10) NUMG = NUMG - 1 CONTINUE CALL MROW(COMPG,dd,K,NUMG,10,10) ENDIF COLLAPSE SOLID SOLUTION S P E C I E S - FIRST CHECK IF ANY MUST BE THROWN OUT IF (NUMSS.GT.O) THEN 12 = NUMSS DO 795 d = 1, 12 IF (d.GT.NUMSS) GO TO 796 IF ( A B S ( C O M P S S ( I , d ) ) . L E . 0 . 0 0 1 ) GO TO 795 CALL MCOL(COMPSS,d,K,NUMSS,10,20) CALL MC0L(THERSS.d,8,NUMSS,8,2O) CALL MCOL(SSNAME,d,1,NUMSS,1,10) NUMSS = NUMSS - 1 CONTINUE CALL MROW(COMPSS,dd,K,NUMSS,10.20) ENDIF ENDIF CONTINUE  FINISHED  810  815  vo Ln  820  830  840  850  - ECHO ONLY NAMES OF PHASES, AQUEOUS S P E C I E S , SOLID SOLUTION ENDMEMBERS AND GASSES CONSIDERED.  WRITE ( 6 , 1027) WRITE ( 6 , 1016) WRITE ( 6 , 1011) (FLNAME(I),1=1.NUMEL) WRITE ( 9 , 1018) (FLNAME(I),1=1,NUMEL) WRITE ( 1 0 , 1017) NUMAQ IF (NUMAQ.GT.O) THEN WRITE ( 6 , 1010) DO 8 1 0 I = 1, NUMAQ (THERAQ(d,I),d=1,5) WRITE ( 6 , 1028) AQNAME(I) CONTINUE WRITE ( 6 , 1029) DO 815 I = 1, NUMAQ (THERAQ(J,I),J=6,9) WRITE ( 6 , 1031) AQNAME(I) CONTINUE WRITE ( 6 , 1030) DO 820 1 = 1 , NUMAQ (THERAQ(d,I),d=10,13) WRITE ( 6 , 1032) AQNAME(I ) CONTINUE WRITE ( 1 0 , 1011) (AQNAME(I),I=1,NUMAQ) ENDIF WRITE ( 1 1 , 1017) NUMPH IF (NUMPH.GT.O) THEN WRITE ( 6 , 1008) DO 830 1 = 1 , NUMPH WRITE ( 6 , 1022) PHNAME(I), ( T H E R P H ( d . I ) d=1,4) CONTINUE WRITE ( 6 , 1023) DO 840 1 = 1 , NUMPH WRITE ( 6 , 1024) PHNAME(I), ( T H E R P H ( d , I ) , d = 5 , 1 1 ) CONTINUE WRITE ( 6 , 1025) DO 850 1 = 1 , NUMPH WRITE ( 6 , 1026) PHNAME(I), ( T H E R P H ( J , I ) , d = 1 2 , 1 4 ) CONTINUE WRITE (11 1020) (PHNAME(I),I=1,NUMPH) ENDIF IF (NUMSS.GT.O) THEN WRITE ( 6 , 1012) WRITE ( 6 , 1009) ( S S N A M E ( I ) , I =1,NUMSS) ENDIF IF (NUMG .GT.O) THEN WRITE ( 6 , 1013) WRITE ( 6 , 1009) (GNAME(I),I=1,NUMG) :  ENDIF IF (NUMD  .GT.O) THEN WRITE ( 6 , 1014) WRITE ( 6 , 1009)  (DNAME(I),I=1,NUMD)  ENDIF RETURN 1001 1002 1003 1004  1005  1006 1007 vo 1008  1009 1010  1011 1012 1013 1014 1015 1016 1017 1018  FORMAT*1X,2613) F0RMAT(7(A4,4X)) FORMAT(7F10.5) FORMATC ELEMENT SYMBOL ' ,A4. ' READ IN AS A FORMULA ',/, ' ON UNIT ',12,' DOES NOT MATCH WITH ANY ELEMENT',/, ' SYMBOL READ IN OFF OF UNIT ',12,'. CORRECT UNIT',/, 12,' DATA AND RERUN. ') FORMAT(1X.101A1,//,' THE PRECEDING LINE WAS READ OFF OF ',/, ' FORTRAN UNIT ',12,' AND DOES NOT MATCH INPUT',/, ' FORMATS. CORRECT AND RERUN.') FORMAT( 5X, 7 F 1 2 . 3 ) FORMATC I L L E G A L CHARACTER IN COLUMN ONE OF THE ',/, ' DATA F I L E READ OFF OF UNIT ',12,' CORRECT', ' AND RERUN. ',/,' LINE IN QUESTION I S : ' , / , 110A1) FORMAT(//,' THE FOLLOWING PHASES WILL BE CONSIDERED IN THE ', 'CALCULATIONS - - ' , / / , 4X,'NAME ' ,23X, 'MW',15X, 'H ( F ) ' , 9 X , ' S ( Z E R O ) ' , 10X,'VOLUME',/,30X,'(G/MOLE)',9X,'(J/MOLE)',6X, '(J/MOLE/DEG) ',8X, '(CM**3)') F0RMAT(5(5X,A2O)) FORMAT(//,' THE FOLLOWING AQUEOUS S P E C I E S WILL BE CONSIDERED ' 'IN THE CALCULATIONS - - ' , / / . 4X,'NAME ' , 2 1X, 'MW', 13X, 'H ( F ) ' , 9 X , ' S ( Z E R O ) ' , 10X,'C1 ',10X.'C2',/, 28X,'(G/MOLE)',7X,'(J/MOLE)',6X,'(J/MOLE/DEG)', 6X,'J/MOL/DEG',6X,'J/MOL/DEG') FORMAT(10(5X,A8)) FORMAT(//,' THE FOLLOWING SOLID SOLUTION ENDMEMBERS WILL BE ', ' CONSIDERED IN THE CALCULATIONS --') FORMAT(//,' THE FOLLOWING GASES WILL BE CONSIDERED IN THE ', 'CALCULATIONS --') FORMAT(//,' THE FOLLOWING DECAY REACTIONS WILL BE CONSIDERED ' ' IN THE CALCULATIONS --') F0RMAT('O ERROR IN BASIS CHANGE IN ROUTINE SETUP2' ) F0RMAT('O THE FOLLOWING AQUEOUS S P E C I E S WERE USED AS THE', ' COMPOSITIONAL BASIS FOR ALL PHASES AND S P E C I E S --') FORMAT(15) FORMAT(15A8)  1019  £  F0RMAT('0',A8,' WAS USED AS A MOBILE COMPONENT BUT COULD',/, ' NOT BE FOUND IN THE AQUEOUS S P E C I E S ' , / , ' PORTION OF THE DATA BASE. CORRECT AND RERUN. ') 1020 F0RMAT(6A2O) 1021 FORMAT(101A 1 ) 1022 FORMAT( 1X , A 2 0 , 5 X , F 1 2 . 4 , 5 X , F 1 2 . 2 , 5 X , F 1 2 . 5 , 5 X , F 1 2 . 4 ) 1023 FORMAT(//, 3X,'NAME ' , 4 0 X , ' ( C P ) ' , / , 29X,'A',6X,'+',6X, 'B T,5X, '+ C / T**2 + D / T**1.5 + E T**2', + F / T + G / T**3') 1024 FORMAT(1X,A20,3X,F12.5,3X,F12.1,3X,F12.0,3X,F12.4,3X,F12.1, 3X.F12.1.3X.F12.0) 1025 FORMAT(//, 3X,'NAME',20X,'DV/DT',11X,'DV/DP',11X,'K',/,2GX, '(CM**3/T)',6X,'(CM**3/MPA) ( J / M / S E C / D E G ) ' ) 1026 FORMAT(1X,A20,3X,F12.8,3X,F12.8,3X,F12.3) 1027 FORMAT('1 THE FOLLOWING PHASE/THERMODYNAMIC INFORMATION ', ' WAS READ FROM THE F I L E ASSIGNED TO UNIT 2',///) 1028 F O R M A T ( 1 X , A 8 , 1 5 X , F 1 2 . 5 , 3 X , F 1 2 . 1 , 3 X , F 1 2 . 2 , 3 X , F 1 2 . 4 , 3 X , F 1 2 . 4 ) 1029 FORMAT(//,1X, ' NAME',26X, 'A 1' , 11X, 'A2' , 12X, 'A3',13X, 'A4',/, 29X, 'J/M/MPA',5X, 'd/M/MPA**2' ,6X, 'd/M/MPA' ,9X , • 'd/M/MPA') 1030 F0RMAT(//,3X,'NAME',24X,'THETA',11X,'W',12X,'CHARGE',9X, 'AZERO' ,/,31X, 'DEG K',9X, 'd/MOLE' , 10X, ' ( - E ) ' , 1 1X , 'CM') 1031 FORMAT(1X,A8,15X,F12.3,3X,F12.7,3X,F12.5,3X,F12.7) 1032 FORMAT(1X , A8 , 15X , F 12 . 2 , 3X , F 12 . 1 , 3X , F 12 . 1 , 3X , F 12 . 9 ) END SUBROUTINE SETUP3 C THIS ROUTINE READS IN THE COMPOSITIONAL AND A C T I V I T Y C CONSTRAINS FOR EACH OF THE ELEMENTS C C NEW COMMON BLOCKS C COMMON / C E L L C H / C H E M ( 1 0 , 5 1 ) , T O T A L M ( 1 0 , 5 1 ) , STRNGH(51 ) , WATER(51), I N D E X 1 ( 1 0 , 5 1 ) , I N D E X 2 ( 1 0 , 5 1 ) , I N D E X 3 ( 1 0 , 5 1 ) , I B A L ( 5 1 ) , NUMCHM, NCONST C COMMON /REACT/ R E A C T A ( 5 , 5 1 ) , I R E A C T ( 5 , 5 1 ) , NUMREA(51) C COMMON / C E L L C O / CHEMO(10,51) C C CHEM CONTAINS THE NUMBER OF MOLES/MOLALITY/GRAMS/ACTIVITY C OF EACH OF THE COMPONENTS AT EACH NODE. C WATER IS ALWAYS STORED AS AN A C T I V I T Y . C CHEMO CONTAINS THE NUMBER OF MOLES/MOLALITY/GRAMS/ACTIVITY C OF EACH OF THE COMPONENTS AT EACH NODE AT  S CO  C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C  A TIME DTAUM LESS THAN THE TIME THAT THESE VALUES WERE STORED IN CHEM IBAL  CONTAINS THE  TOTALM WATER  CONTAINS THE TOTAL NUMBER OF MOLES OF EACH COMPONENT CONTAINS THE NUMBER OF MOLES OF WATER AT EACH NODE  AQCO  CONTAINS  INDEX 1  INDEX2  INDEX3  INDEX OF THE  ION TO BALANCE  ON  THE TOTAL NUMBER OF MOLES OF EACH COMPONENT IN THE FLUID. THE COMPONENT HERE IS THE COMPONENT USED TO DESCRIBE THE AQUEOUS S P E C I E S IN THE ARRAY COMPAQ CONTAINS A POINTER TO WHICH PHASE/AQUEOUS S P E C I E S / SOLID SOLUTION ENDMEMBER/GAS CORRESPONDS TO THE DATA IN CHEM. CONTAINS A SWITCH WHICH INDICATES WHETHER THE POINTER IN INDEX 1 IS A SOLID PHASE ( 1 ) , AQUEOUS S P E C I E S ( 2 ) , SOLID SOLUTION ENDMEMBER ( 3 ) , OR A GAS ( 4 ) . CONTAINS  A SWITCH WHICH INDICATES WHETHER DATA IN CHEM IS MOLALITY ( 1 ) , LOG A C T I V I T Y ( 2 ) , GRAMS ( 3 ) OR MOLES ( 4 ) . NUMCHM A COUNTER WHICH IS EQUAL TO THE NUMBER OF NODES. THIS NUMBER MUST BE EQUAL TO NUMX WHICH IS IN THE COMMON BLOCK C E L L S NCONST NUMBER OF CHEMICAL CONSTRAINS ON EACH C E L L . THIS MUST BE THE SAME FOR EACH C E L L . REACTA CONTAINS THE NUMBER OF MOLES OF EACH OF THE REACTANTS IREACT CONTAINS A POINTER TO THE POSITION OF THE REACTANT IN THE MINERAL ARRAYS NUMREA CONTAINS THE NUMBER OF REACTANTS AT EACH NODE (NOTE THAT THE MAXIMUM IS DETERMINED BY THE I DIMENSION OF THE ARRAYS IREACT AND REACTA PREVIOUSLY DEFINED COMMON BLOCKS COMMON / C E L L S / CELLPO(51,2). CELLPE(51,2), CELLP(51,2), C E L L T ( 5 1 , 2 ) , DENSF(51,2), S I Z E X ( 5 1 ) , X I N E R T ( 5 1 ) , THICK, NUMX, INOWP, IFUTP, INOWT, IFUTT COMMON /CHEMAQ/ COMPAQ(10,25), THERAQ(13,25), NUMAQ COMMON /CHEMEL/ WGHT(10), NUMEL COMMON /CHEMG / COMPG(10,10), T H E R G ( 6 , 1 0 ) , NUMG COMMON /CHEMPH/ COMPPH(10,25), T H E R P H ( 1 4 , 2 5 ) , NUMPH COMMON /CHEMSS/ COMPSS(10,20), T H E R S S ( 8 , 2 0 ) , NUMSS COMMON /TIME / DTAUP, DTAUT, DTAUC, DTAUM, TAUP, TAUT, TAUC, TAUM, W1 COMMON /TRANS / V E L 0 C ( 5 1 , 2 ) , A Q C O ( 1 0 , 5 1 , 2 ) , S O C O ( 1 0 . 5 1 , 2 ) ,  A L P H A ( 1 0 ) ,  INOWC,  IFUTC  CHARACTER*20  PHNAME(25),  SSNAME(20),  CHARACTER*8  F L N A M E ( 1 0 ) ,  AQNAME(25)  CHARACTER*4  ELNAME(10)  COMMON  /CHNAME/  PHNAME,  SSNAME,  GNAME(10),  GNAME,  DNAME,  DNAME(3)  AQNAME,  FLNAME,  ELNAME LOCAL  VARIABLES  REAL  A ( 1 0 , 1 0 )  INTEGER  I P 0 I N T ( 1 O )  CHARACTER*100 CHARACTER*20 CHARACTER*12 CHARACTER*4  T I T L E CONST P R 1 ( 4 ) .  PR2(4)  STRIN  CHARACTER*3  WHAT1(4),  ANSI  CHARACTER*1  WHAT2(4),  ANS2  DATA  W H A T 1 / ' M I N ' , ' A Q U ' , ' S S S ' , ' G A S ' /  DATA DATA  W H A T 2 / ' M ' , ' A ' , ' G ' , ' B ' / P R 1/ '  (MINERAL)  ' , ' ( A Q  V  (GAS) DATA  PR2/'  (MOLALITY)  '  ' , '  (MOLES)  NUMCHM  =  NUMX  NCONST  =  0  I ER  =  0  (LOG  OUT  CALL  MINIT(CHEM,  CALL  I M I N I T ( I N D E X 1 ,  10,  51,  0)  CALL  I M I N I T ( I N D E X 2 ,  10,  51,  0)  CALL  I M I N I T ( I N D E X 3 ,  10,  51,  0)  CALL  I M I N I T ( I B A L ,  51,  1,  0)  READ  AND  I  =  READ  WRITE  10,  T I T L E  51,  STRIN  INFORMATION  IF  1035) 1036) =  T I T L E  T I T L E  (STRIN  .EQ. GO  ELSE  (GRAMS)  O.OEOO)  0 (3,  ' , '  M E M ) ' ,  ARRAYS  FOUND  WRITE(6,  A C T . )  END  '/  ZERO  IS  NEW  SPEC I ES ) ' , ' ( S S  ' S T A R ' ) TO  10  THEN  UNTIL  STAR  (SHORT  FOR  START)  WRITE(6, 1037) T I T L E ENDIF GO TO 1 THE PROGRAM LOOPS BACK TO THIS POINT AND KEEPS ON READING UNTIL AN END OF F I L E ( E O F ) OR EITHER OF THE CHARACTER STRINGS "END " OR "STOP" IS FOUND. READ ( 3 , 1026, END=700) STRIN IF  (STRIN  .EQ.  '  ') THEN SKIP. BLANK  GO TO 10 ELSE IF ( S T R I N GO TO 700 ELSE IF ( S T R I N GO TO 700 ELSE IF ( S T R I N  .EO.  .EQ.  .EO.  LINES  'STOP') THEN  'END  GO CHECK  DATA  GO CHECK  DATA  ') THEN  'INER') THEN  READ INERT PORTION OF NODE(S) READ ( 3 , 1001) NUM, ISTART I F I N = ISTART - 1 + NUM READ ( 3 , 1022) ( X I N E R T ( d ) , d = I START, I F I N ) ELSE IF ( S T R I N .EO. 'REAC' ) THEN READ REACTANTS FOR EACH NODE READ(3,1001) K, NUM, ISTART NUMREA(ISTART) = K DO 60 I = 1, K READ(3,1031) ANS2, AMOUNT, CONST IF (ANS2.NE.'G'.AND.ANS2.NE.'M') THEN WRITE(6,1032) ANS2, AMOUNT, CONST STOP ENDIF DO 50 d1 = 1, NUMPH IF (CONST.NE.PHNAME(d 1 ) ) GO TO 50 I R E A C T ( I , I S T A R T ) = d1 GO TO 55 CONTINUE WRITE(6,1033) ANS2, AMOUNT, CONST STOP IF (ANS2.E0.'G') THEN AMOUNT = AMOUNT / THERPH(1,d1) ENDIF IF (NUM.NE.1) THEN DO 57 d1 = 2, NUM d2 = d1 - 1 REACTA(I,d1 ) = REACTA(I,d2)  IREACT(I.dl) = IREACT(I,d2) CONTINUE ENDIF CONTINUE DO 65 J1 = 2, NUM d2 = d1 - 1 NUMREA(J1) = NUMREA(J2) CONTINUE SE IF ( S T R I N .EO. 'COMP') THEN READ CHEMICAL CONSTRAINTS ON EACH NODE READ ( 3 , 1001) NUMCOM, ISTART IF (NCONST.EQ.O) NCONST = NUMCOM IF (NCONST.NE.NUMCOM) THEN WRITE(6,1014) NCONST, NUMCOM I ER = IER + 1 ENDIF I = NUMEL - 1 J = I - NUMCOM IF (NUMCOM.NE.I) THEN WRITE(6,1020) NUMEL, 2, NUMCOM, 3, J IER = IER + 1 ENDIF IB  = 0  DO  560 1 = 1 , NUMCOM READ ( 3 , 1003) ANSI, ANS2, AMOUNT, CONST DO 80 J = 1, 4 K3 = d IF(ANS2.EQ.WHAT2(J) ) GO TO 100 CONTINUE WRITE(6, 1004) ANSI, ANS2, AMOUNT, CONST STOP (ANSI .EQ. 'MIN') THEN READ A MINERAL CONSTRAINT K2 = 1 IF (K3.EQ.1) K3 = 4 IF (NUMPH.LE.0) THEN WRITE(6, 1005) STOP ENDIF DO 150 d1 = 1, NUMPH IF (PHNAME(d1) .EO. CONST) THEN K1 = d1 ENDIF GO TO 500  IF  150  C C  READ AN AQUEOUS S P E C I E S CONSTRAINT  250 K> g C  330  C  CONTINUE WRITE(6, 1006) CONST STOP ELSE IF (ANSI .EO. 'AOU') THEN  K2 = 2 IF (NUMAQ.LE.O) THEN WRITE(6, 1007) STOP ENDIF DO 250 0 1 = 1 . NUMAQ IF (AQNAME(J1) .EQ. CONST) THEN K1 = J1 IF (K3.EQ.4) THEN IB = I K3 = 1 ENDIF GO TO 500 ENDIF CONTINUE WRITE(6, 1006) CONST STOP ELSE IF (ANSI .EQ. 'SSS') THEN READ SOLID SOLUTION ENDMEMBER K2 = 3 IF (K3.EQ.1) K3 = 4 IF (NUMSS.LE.O) THEN WRITE(6, 1008) STOP ENDIF DO 330 01 = 1, NUMSS IF (SSNAME(U1) .EQ. CONST) THEN K1 = J1 GO TO 500 ENDIF CONTINUE WRITE(6, 1006) CONST STOP ELSE IF (ANSI .EQ. 'GAS') THEN READ GASS CONSTRAINT K2 = 4 IF (NUMG.LE.O) THEN WRITE(6. 1009) STOP ENDIF  DO 440 J1 = 1, NUMG IF ( GNAME ( d 1 ) .EO. CONST) THEN K1 = d1 GO TO 500 ENDIF CONTINUE WRITE(6, 100G) CONST STOP  440  ELSE WRITE(6, STOP  1010) ANSI,  WHAT IS I T ? ANS2, AMOUNT, CONST  ENDIF NOW 500  NJ O LO  560  ADD  STORE THE INFO IN THE APPROPRIATE ARRAYS . CHEM(I,ISTART) = AMOUNT I N D E X 1 ( I , I S T A R T ) = K1 I N D E X 2 ( I , I S T A R T ) = K2 I N D E X 3 ( I , I S T A R T ) = K3 CONTINUE I B A L ( I S T A R T ) = IB WATER TO B A S I S . REMEMBER THAT WATER ONE IN THE AQUEOUS PORTION. L = NCONST + 1 CHEM(L,ISTART) =0.0 INDEX1(L,ISTART) = 1 INDEX2(L,ISTART) = 2 INDEX3(L,ISTART) = 2  IS ALWAY POSITION  CHECK THAT THE CONSTRAINS ARE LEGAL BY INVERTING BASIS WAS TO BE FORMED IF (IER.NE.O) THEN WRITE(6,1013) IER STOP ENDIF DO 650 I = 1 , L K1 = I N D E X 1 ( I , I S T A R T ) K2 = I N D E X 2 ( I , I S T A R T ) DO 640 d = 1, NUMEL IF (K2.EQ.1) THEN  AS  IF A  NUMBER  NEW  SOLIDS A ( d , I ) = C0MPPH(d,K1) ELSE IF (K2.EQ.2) THEN AQUEOUS S P E C I E S A ( d , I ) = C0MPAQ(d,K1)  ELSE  IF (K2.EQ.3) THEN A(d,I) =  ELSE  SOLID SOLUTION COMPSS(J,K1)  IF ( K 2 . E 0 . 4 )  SPECIES  THEN GASSES  A ( d , I ) = COMPG(d,K1) ENDIF CONTINUE INVERT  CONTINUE AND SEE IF IT IS A VALID BASIS - GO BACK AND READ MORE NODES EITHER WAY CALL INVRT(A,NUMEL,10,J) IF ( J . N E . O ) THEN WRITE(6,1021) ISTART DO 675 d = 1 , L K1 = I N D E X 1 ( d , I S T A R T ) K2 = I N D E X 2 ( d , I S T A R T ) K3 = I N D E X 3 ( d , I S T A R T ) IF (K2.EQ.1) THEN WRITE(6, 1016) PHNAME(K1), P R 1 ( K 2 ) , P R 2 ( K 3 ) , CHEM(d,ISTART) ELSE IF (K2.EQ.2) THEN ANS2 = ' ' IF ( I B . E Q . d ) ANS2 = '*' WRITE(6, 1017) AQNAME(K1), ANS2, P R 1 ( K 2 ) , P R 2 ( K 3 ) . CHEM(d,I START) ELSE IF (K2.EQ.3) THEN WRITE(6, 1016) SSNAME(K1), PR1(K2), PR2(K3), ELSE IF (K2.EQ.4) THEN WRITE(6, 1016) GNAME(K1), PR1(K2), PR2(K3), ENDIF  CONTINUE ENDIF ELSE WRITE(6,1027) 3, STRIN STOP ENDIF  CHEM(d,I START)  CHEM(d,I START)  GO TO 10 WHEN A L L HAS BEEN READ, COME HERE AND CHECK THAT A L L NODES HAVE CONSTRAINTS. I F THE NODE IS EMPTY, COPY THE DATA FROM THE PRECEEDING NODE. NCONST = NCONST + 1 DO 740 J = 1. NUMCHM J2 =0 DO 710 I = 1, NCONST IF (INDEX 1 ( I , d ) .NE. 0 ) d2 = d2 + 1 CONTINUE COPY DATA FROM PRECEEDING CELL IF ( J 2 . E Q . 0 ) THEN IF ( d . E Q . 1 ) WRITE(6,1012) IF ( d . E Q . 1 ) STOP K = d - 1 DO 730 1 = 1 , NCONST CHEM(I.d) = CHEM(I,K) INDEX 1 ( I , d ) = I N D E X 1 ( I , K ) INDEX2(I,d) = INDEX2(I,K) INDEX3(I,d) = INDEX3(I,K) CONTINUE IBAL(J) = IBAL(K) ELSE IF (d2.NE.NCONST.AND.d2.NE.O) THEN WRITE(6, 1011) d IER = IER + 1 ENDIF CONTINUE IF (IER.NE.O) THEN WRITE(6,1013) IER STOP ENDIF DO 780 1 = 1 , NUMCHM, 2 K = I + 1 WRITE(6, 1015) I , K DO 770 d = 1, NCONST DO 760 d1 = I , K IF (d1.LE.NUMCHM) THEN IB = I B A L ( d 1 ) K1 = I N D E X 1 ( d , d l ) K2 = I N D E X 2 ( d . d l ) K3 = I N D E X 3 ( d , J l ) ASSIGN 1016 TO I I IF (M0D(d1,2).EQ.O) ASSIGN 1018 TO I I  IF  (K2.EQ.1) THEN WRITE(6, I I ) PHNAME(K1), PR1(K2), PR2(K3),  CHEM(d,J1)  C ELSE  760 770 780 ° C C C  C C  IF (K2.EQ.2) THEN ANS2 = ' ' IF ( I B . E Q . d ) ANS2 = '*' ASSIGN 1017 TO I I IF (M0D(d1,2).EQ.O) ASSIGN 1019 TO I I WRITE(6, I I ) AQNAME(K1), ANS2. P R 1 ( K 2 ) , P R 2 ( K 3 ) , CHEM(d,J1) ELSE IF (K2.EQ.3) THEN WRITE(6, I I ) SSNAME(K1), P R 1 ( K 2 ) , P R 2 ( K 3 ) , CHEM(d , d 1 ) ELSE IF (K2.EQ.4) THEN WRITE(6, I I ) GNAME(K1), P R 1 ( K 2 ) . P R 2 ( K 3 ) , CHEM(d,d1) ENDIF ENDIF CONTINUE CONTINUE CONTINUE WRITE( 6.1025) WRITE(11,1038) TAUM, DTAUM NOW ALTER ALL INPUT OF SOLID PHASES IN GRAMS TO MOLES, AND NORMALIZE ALL AMOUNTS WITH THE POROUSITY TO THE APPROPIATE AMOUNT IN THE NODE. WRITE(6,1023) DO 890 1 = 1 , NUMCHM AMOUNT =0.0 L =0 DO 800 d = 1, NCONST IF ( I N D E X 2 ( d , I ) . E Q . 1 ) THEN K1 = INDEX 1 ( d , I ) K3 = I N D E X 3 ( d , I ) L = L + 1 IPOINT(L) = d IF (K3.EQ.3) THEN CONVERT GRAMS TO MOLES  SUM  CHEM(d.I) = CHEM(d.I) / THERPH(1,K1 ) INDEX3(d,I) = 4 ENDIF VOLUMES  CALL VMIN  AMOUNT ENDIF CONTINUE  (X, THERPH(4,K1), THERPH(12,K1 ) , THERPH(13 , K1 ) , CELLT(I,INOWT ) , CELLP(I,INOWP) ) = AMOUNT + ( C H E M ( d . I ) * X)  SUM IN VOLUMES OF REACTANTS (NUMREA(I).GT.0) THEN DO 810 J = 1, NUMREA(I) K1 = I R E A C T ( d . I ) CALL VMIN (X, THERPH(4,K1), T H E R P H ( 1 2 , K 1 ) , THERPH(13,K1), C E L L T ( I , I N O W T ) , CELLP(I,INOWP) ) AMOUNT = AMOUNT + ( R E A C T A ( J , I ) * X) CONTINUE ENDIF CONVERT TO METERS AND FIND FACTOR - NORMALIZE IF  J = I K = J - 1 IF ( K . L T . 1 ) K = d IF (J.GE.NUMCHM) d = K AMOUNT = AMOUNT * 1.0E-06 IF (AMOUNT.EO.0.0) THEN X I N E R T ( I ) = 1.0 - CELLPO(I,INOWC) ENDIF VOLUME = THICK * THICK * ( ( S I Z E X ( d ) + S I Z E X ( K ) ) / 2 . 0 ) X = VOLUME * ( 1 . 0 - CELLPO(I,INOWC) - X I N E R T ( I ) ) WRITE(6,1024) I , VOLUME, X I N E R T ( I ) , CELLPO(I,INOWC), X ANS2 = ' ' ASSIGN 1028 TO I I DO 830 d = 1, NCONST IF ( I N D E X 2 ( d , I ) . E O . 1 ) THEN K1 = I N D E X 1 ( d , I ) CALL VMIN (VOLUME, THERPH(4,K1), THERPH(12,K1), THERPH(13,K1), CELLT(I,INOWT), CELLP(I,INOWP)) CHEM(d.I) = CHEM(d.I) * X / AMOUNT CHEMO(d.I) = CHEM(d.I) VOLUME = CHEM(d.I) * VOLUME * 1.0E-06 WRITE(6, I I ) ANS2, PHNAME(K1), C H E M ( d . I ) , VOLUME ASSIGN 1034 TO I I ENDIF  830  840  O  00  860  870 890  1001 1003 1004  1005  1006 1007  T0TALM(d,I) = CHEM(d,I) CONTINUE IF (NUMREA(I).GT.O) THEN ANS2 = '*' DO 840 d = 1, NUMREA(I) K1 = I R E A C T ( d . I ) R E A C T A ( d . I ) = R E A C T A ( d . I ) * X / AMOUNT CALL VMIN (VOLUME, THERPH(4,K1), THERPH(12,K1), T H E R P H ( 1 3 , K 1 ) , CELLT(I,INOWT), CELLP(I,INOWP)) VOLUME = REACTA(d, I ) * VOLUME * 1.OE-06 WRITE(6, I I ) ANS2, PHNAME(K1), R E A C T A ( d . I ) , VOLUME ASSIGN 1034 TO I I CONTINUE ENDIF WRITE( 6,1029) WRITE(11,1001) I , L, NUMREA(I) IF (L.GT.O) THEN DO 860 d = 1, L K1 = I N D E X 1 ( I P O I N T ( d ) , I ) WRITE(11,1039) K1, C H E M ( I P O I N T ( d ) , I ) , 0.0 CONTINUE ENDIF IF (NUMREA(I) .GT. 0 ) THEN DO 870 d = 1, NUMREA(I) K1 = I R E A C T ( d . I ) WRITE(11,1039) K1, R E A C T A ( d , I ) , 0.0 CONTINUE ENDIF CONTINUE WRITE(6, 1030) RETURN FORMAT(: [2015) FORMAT( A3,1X.A1,4X,E12.5,3X,A20) FORMAT( ' THE SECOND PARAMETER READ A LINE IN THE F I L E ' , ' ASSIGNED TO UNIT 3 COULD NOT BE RECOGNIZED ',/, ' THIS PARAMETER SHOULD BE A C T I V I T Y , MOLALITY,', ' MOLES, OR GRAMS. THE LINE IN QUESTION I S : ' , / , A3,1X.A1,4X,E12.5,3X,A20) F0RMAT('O YOU CAN NOT HAVE SOLID PHASE CONSTRAINTS WHEN ' ./, ' NO SOLID PHASES HAVE BEEN READ (OR KEPT BECAUSE /, OF COMPOSITION) FROM THE THERMODYNAMIC DATA BANK') FORMAT( '0 PHASE ',A20,' WAS NOT FOUND IN THE THERMODYNAMIC, DATA BANK. ',/,' CORRECT AND RERUN. ') FORMAT( 'O YOU CAN NOT HAVE AQUEOUS S P E C I E S CONSTRAINTS WHEN  1008  1009  1010  1011 1012 1013 1014  1015 1016 1017 1018 1019 1020  1021 1022 1023  1024 1025 1026  ' NO AQUEOUS S P E C I E S HAVE BEEN READ (OR KEPT BECAUSE',/, ' OF COMPOSITION) FROM THE THERMODYNAMIC DATA BANK') FORMATCO YOU CAN NOT HAVE SOLID SOLUTIONS CONSTRAINTS WHEN ',/, ' NO SOLID SOLUTIONS HAVE BEEN READ (OR KEPT BECAUSE',/, ' OF COMPOSITION) FROM THE THERMODYNAMIC DATA BANK') F0RMAT('O YOU CAN NOT HAVE GAS CONSTRAINTS WHEN ',/, ' NO GASES HAVE BEEN READ (OR KEPT BECAUSE',/, ' OF COMPOSITION) FROM THE THERMODYNAMIC DATA BANK') FORMATC THE FIRST PARAMETER (MINERAL, AQUEOUS S P E C I E S , ',/, ' SOLID SOLUTION S P E C I E S OR GAS COULD NOT BE RECOGNIZED' ,/,' LINE IN QUESTION I S : ' , / , A3,1X.A1,4X,E12.5,3X,A20) FORMATCO NODE ',13,' DOES NOT HAVE ENOUGH OR HAS TOO MANY ', 'CONSTRAINTS.') FORMATCO NODE 1 MUST HAVE THE COMPOSITION DEFINED.') FORMATCO THERE WERE ',13,' ERRORS FOUND IN THE DATA BASE', ' ASSIGNED TO UNIT 3.',/,' END OF RUN.') FORMATC THE PREVIOUS NODE HAD ',13,' CHEMICAL CONSTRAINS', / , ' YET THE ONE JUST READ IN HAD ',13,'. CORRECT ',/, ' AND RERUN. ') FORMATCO CHEMICAL CONSTRAINTS FOR NODE: ',I5,28X, ' CHEMICAL CONSTRAINTS FOR NODE: ',15) FORMATC ',A20,1X.2A12,1X.E12.5) FORMATC ' ,A8, 1 1X , A 1 , 1X,2A12, ' ',E12.5) FORMAT('+',65X,A20,1X,2A12,1X,E12.5) FORMAT('+',65X,A8,11X,A1,1X,2A12,1X,E12.5) FORMATCO THERE ARE ',15,' COMPONENTS (INCLUDING', ' ISOTOPES AND DIFFERENT OXIDATION S T A T E S ) ' , ' USED TO DESCRIBE THE PHASES TAKEN FROM THE',/, ' DATA F I L E ASSIGNED TO UNIT',12, ' YET YOU HAVE ENTERED ',15,' CONSTRAINTS', ' IN THE DATA F I L E ASSIGNED TO UNIT' , 12 , ' . ' ,/, ' YOU MUST ENTER ',12,' MORE COMPONENTS TO', ' COMPLETELY DETERMINE THE SYSTEM (REMEMBER THAT', ' WATER IS AUTOMATICALLY A COMPONENT).',/) FORMATCO THE CONSTRAINS L I S T E D BELOW, DO NOT FORM A', ' INDEPENDENT BASIS FOR THE NODE: ',15) F0RMAT(8X,F12.3) FORMATCO NODE: TOTAL VOLUME INERT POROSITY ', ' AVAILABLE VOLUME PHASES PRESENT',10X,'AMOUNT', 8X,'VOLUME',/,12X,'(M**3)',4X,'FRACTION',17X, '(M**3)',32X,'(MOLES)',7X,'(M**3)',/) FORMATC ',13,4X,E 12 . 5,2X,F8.6,2X,F8.6,4X,E12.5) FORMATCO', 18X, ' * = ION/COMPONENT CHOSEN BY USER AS', ' E L E C T R I C A L BALANCING COMPONENT.',/) F0RMAT(A4)  1027  1028 1029 1030 1031 1032  1033  1034 1035 1036 1037 1038 1039  FORMATC ON FORTRAN UNIT NUMBER ',12,', THE COMMAND ',A4, ' WAS READ. IT DOES NOT MATCH ANY OF THE P O S S I B L E ' , / , ' KEYWORD STRINGS. CORRECT AND RERUN.') FORMAT(' +',59X,A1,A20,1X,E12.5,2X,E12.5) FORMAT(' ' ) FORMAT(!58X,'* = REACTANTS') FORMAT(tA1,3X,F10.5,1X.A20) FORMAT( '0 LINE IN ERROR IN DATA BANK ASSIGNED TO UNIT 3.', LINE FOR REACTANTS READS: ' , / , ' ',A 1,3X,F10.5,1X,A20, ERROR IS IN THE SYMBOL FOR GRAMS (G) OR MOLES (M) ') /, LINE IN ERROR IN DATA BANK ASSIGNED TO UNIT 3.', FORMAT(' ',A1,3X,F10.5,1X,A20, ' LINE FOR REACTANTS READS: ,/, /,' ERROR IS THAT THE REACTANT CAN NOT BE FOUND') FORMAT(' ',59X,A1,A20,1X,E12.5,2X,E12.5) FORMATC1',//,' T I T L E INFORMATON READ FROM DATA ON UNIT 3' , / / ) FORMAT(A 100) FORMATC '.A100) F0RMAT(2(1X.E12.5)) F0RMAT(I5,2(1X,E12.5)) END SUBROUTINE SETUP4 ROUTINE TO SETUP THE WATER ROUTINE.  o  LOCAL DOUBLE CPD CVD FD HD DPTVD DPRTD DPVTD PD SD TD TJD UD VD  -  PRECISION VARIABLES - LAST CHARACTER  IS ALWAYS D  HEAT CAPACITY AT CONSTANT PRESSURE OF WATER HEAT CAPACITY AT CONSTANT VOLUME OF WATER HELMHOLZ FREE ENERGY OF WATER ENTHALPHY OF WATER DERIVATIVE OF P WRT. T AT CONSTANT V AT CONSTANT DERIVATIVE OF P WRT. RHO DERIVATIVE OF P WRT. V AT CONSTANT T PRESSURE (MPA) OF WATER ENTROPY OF WATER TEMPERATURE (DEG K) OF WATER JOULE THOMPSON COEF. OF WATER INTERNAL ENERGY OF WATER VOLUME (KG/M**3) OF WATER  COMMON / C E L L S / C E L L P O ( 5 1 , 2 ) , C E L L P E ( 5 1 , 2 ) , C E L L P ( 5 1 , 2 ) , CELLT(51,2), DENSF(51,2), SIZEX(51), XINERT(51). THICK, NUMX, INOWP, IFUTP, INOWT, IFUTT COMMON /TRANS/ VELOC( 51 ,2) , A Q C O ( 1 0 , 5 1 , 2 ) , S O C O ( 1 0 , 5 1 , 2 ) , A L P H A ( 1 0 ) , INOWC, IFUTC DOUBLE PRECISION PD, TD, VD, HD, UD, SD, CPD, CVD, TJD, FD  DOUBLE  PRECISION DPTVD,  INITIALIZE CALL  THE WATER  DPRTD,  DPVTD  ROUTINE  STEAM(PD, TD, VD, HD,  UD,  SD, CPD, CVD, TdD, FD, 1,  NE, DPTVD, DPRTD, DPVTD) NOW CALL H20 WITH THE REFERENCE VALUES - THEY WILL BE STORED IN POSITION 1 OF EACH OF THE ARRAYS IN THE COMMON BLOCK PREF = 0 . 1 TREF = 298 . 15 CALL H20(PREF, TREF, VOL, GIBBS, HTP, STP, EOCON, CV, DVDT, DVDP, D2VDT2, 1) GET I N I T I A L D E N S I T I E S AT EACH OF THE NODES DO 100 1 = 1 , NUMX PRES = C E L L P ( I , I N O W P ) TK = CELLT(I,INOWT) CALL H20(PRES, TK, VOL, GIBBS, HTP, STP, EOCON, CV, DVDT, DVDP, D2VDT2, 0 ) DENSF(I,INOWC) = 1.0E00 / VOL D E N S F ( I , I F U T C ) = 1.0E00 / VOL CONTINUE RETURN END SUBROUTINE SETUP6 THIS ROUTINE COPIES THE VELOCITY ARRAY FROM IFUTP TO INOWP POSITIONS IN THE ARRAY. IT IS USED ONLY IN THE SETUP COMMON / C E L L S / C E L L P O ( 5 1 , 2 ) , C E L L P E ( 5 1 , 2 ) , C E L L P ( 5 1 , 2 ) , . C E L L T ( 5 1 , 2 ) , DENSF(51,2), S I Z E X ( 5 1 ) , XINERT(51), THICK, NUMX, INOWP, IFUTP, INOWT, IFUTT COMMON /TRANS/ V E L 0 C ( 5 1 , 2 ) , A O C O ( 1 0 , 5 1 , 2 ) , S O C O ( 1 0 , 5 1 , 2 ) , A L P H A ( 1 0 ) , INOWC, IFUTC II = NUMX - 1 DO 10 I = 1, I I VELOC(I,INOWP) = V E L O C ( I , I F U T P ) CONTINUE RETURN END SUBROUTINE SOLVET(IMSWIT) THIS ROUTINE SETS UP THE F I N I T E ELEMENT MATRIX'S THE SOLUTION OF THE NEW TEMPERATURES COMMON BLOCKS PREVIOUSLY DEFINED COMMON /CELLCO/ CHEM0(10,51)  FOR  COMMON / C E L L S / C E L L P O ( 5 1 , 2 ) , C E L L P E ( 5 1 , 2 ) , C E L L P ( 5 1 , 2 ) , CELLT(51,2), DENSF(51,2), SIZEX(51), XINERT(51), THICK, NUMX, INOWP, IFUTP, INOWT, IFUTT COMMON /TIME/ DTAUP, DTAUT, DTAUC, DTAUM, TAUP, TAUT, TAUC, TAUM, W1 COMMON /CHEMPH/ COMPPH(10,25), T H E R P H ( 1 4 , 2 5 ) , NUMPH COMMON /CHEMAO/ COMPAQ(10,25), THERAQ(13,25), NUMAQ COMMON /CHEMSS/ COMPSS(10,20), T H E R S S ( 8 , 2 0 ) , NUMSS COMMON /CHEMG / COMPG(10,10), T H E R G ( 6 , 1 0 ) , NUMG COMMON / C E L L C H / CHEM(10,51), T O T A L M ( 1 0 , 5 1 ) , STRNGH(51), WATER(51), I N D E X 1 ( 1 0 , 5 1 ) , I N D E X 2 ( 1 0 , 5 1 ) , I N D E X 3 ( 1 0 , 5 1 ) , I B A L ( 5 1 ) , NUMCHM, NCONST COMMON / D I V I N E / E R R 0 R ( 5 5 ) , ERRMAX(3), L 0 P T 0 T ( 5 5 ) , L I M L 0 P ( 3 ) COMMON /REACT/ R E A C T A ( 5 , 5 1 ) , I R E A C T ( 5 , 5 1 ) , NUMREA(51) COMMON /TRANS/ V E L 0 C ( 5 1 , 2 ) , AQCO(10,51,2), SOCO(10,5 1 , 2 ) , A L P H A ( 1 0 ) , INOWC, IFUTC LOCAL VARIABLES A  -  CONTAINS A BANDED REPRESENTATION OF THE F I N I T E ELEMENT C O E F F I C I E N T ARRAY. INITIALLY CONTAINS THE [ A ] TERMS FOR THE EQUATIONS [A] P + [ B ] DP/DT = F  B  -  CONTAINS A BANDED REPRESENTATION OF THE IN THE ABOVE EQUATION.  C D DENS  -  CONTAINS THE TEMPERATURES AT TIME INOW WORKING ARRAY DENSITY OF WATER, KG/M**3  F  PERM  [ B ] AREA  ON CALLING IMSL ROUTINE, CONTAINS THE RIGHT HAND SIDE OF THE EQUATIONS, ON E X I T , IT CONTAINS THE SOLUTION VECTOR. SEE ABOVE EQUATION. -  PERMIABILITY  FOR AN ELEMENT  - WEIGHTED WITH W1  IN TIME  PORE PRES TK VOLUME-  POROUSITY FOR AN ELEMENT - WEIGHTED WITH W1 IN TIME PRESSURE FOR AN ELEMENT - WEIGHTED WITH W1 IN TIME TEMPERATURE FOR AN ELEMENT - WEIGHTED WITH W1 IN TIME VOLUME OF ELEMENT  X  -  S I Z E OF ELEMENT, ALSO USED FOR TEMPERARY  XL  -  WORK ARRAY  REAL A ( 1 0 2 , 3 ) ,  STORAGE  FOR THE IMSL ROUTINE LEQT1B  B(102,3),  C(102),  D(102),  F(102),  XL(204)  CALL M I N I T ( C , CALL MINIT(D, CALL M I N I T ( F , DO 50  1, O.OEOO) 1, O.OEOO) 1, O.OEOO)  I = 1, NUMX C ( I ) = CELLT(I,INOWT) CONTINUE SET UP ELEMENT S T I F F N E S S MATRIX EVALUATED AT TIME EACH TERM IS EVALUATED FOR THE ELEMENT DO  ro i—1 Co  102, 102, 102,  50  T + DELTA  900 LOOP = 1, L I M L 0 P ( 2 ) L 0 P T 0 T ( 2 ) = LOOP CALL M I N I T ( A , 102, O.OEOO) CALL M I N I T ( B , 102, O.OEOO) CALL M I N I T ( X L , 204, O.OEOO) DO 100 1 = 1 , (NUMX 1) II = I + 1  THE PRESSURE AND VELOCITY CALCULATION DOES NOT ASSUME THAT THE TIME AT INOWP IS THE SAME AS THE TIME AT INOWT PRES = ( C E L L P ( I , I N O W P ) + C E L L P ( I I , I N O W P ) ) S ( C E L L P ( I , I F U T P ) + C E L L P ( I I , I F U T P ) ) - PRES PRES PRES / 2.0 S S / ( 2 . 0 * DTAUP) PRES + (S * ((TAUT - DTAUT) - (TAUP DTAUP))) PRES PRES + (W1 * S * DTAUT) PRES S ( V E L 0 C ( I , I F U T P ) - VELOC(I,INOWP)) / DTAUP V VELOC(I,INOWP) V V + (S * ((TAUT - DTAUT) - (TAUP - D T A U P ) ) ) V V + (W1 * S * DTAUT) XINT ( X I N E R T ( I ) + X I N E R T ( I I ) ) / 2.0 THE PORE CALCULATION ASSUMES THAT THE CELLPO AT INOWC IS AT THE SAME TIME AS C E L L T IS WHEN IT IS AT INOWT PORE = (CELLPO(I,INOWC) + CELLPO(11,INOWC)) S = (CELLPO(I,IFUTC) + CELLPO(11,IFUTC)) PORE = PORE / 2.0 S = S / ( 2 . 0 * DTAUC) PORE = PORE + (W1 * S * DTAUT) TK  PORE  ((CELLT(I,INOWT) + CELLT(11,INOWT)) (CELLT(I,IFUTT) + CELLT(II,IFUTT))) / 4.0 X = SIZEX(I) VOLUME = THICK * THICK * X CALL H20(PRES, TK, DENS, GIBBS, HTP, STP, EOCON,  (T/2)  DENS CALL  CV, DVDT, DVDP, D2VDT2, = 1 . 0 / DENS C0ND(XK,TK,DENS)  0)  CALCULATE CHEMICAL BASED TERMS FOR A, B AND F MATRIX'S TOTCV = 0.0 TOTK = 0.0 TOTW =0.0 TOTM =0.0 TOTV =0.0 DO 8 0 d = 1 , NCONST K1 = I N D E X 1 ( d , I ) K2 = I N D E X 2 ( d , I ) IF ( K 2 . E 0 . 1 ) THEN SOLID PHASES TOTM = TOTM + CHEM(d,I) TOTW = TOTW + ( C H E M ( d . I ) * THERPH(1,K 1 ) ) CALL VMIN(VTP, THERPH(4, K 1 ) , THERPH(12,K 1 ), THERPH(13,K1), TK, PRES) TOTV = TOTV + ( C H E M ( J . I ) * VTP) CALL CVMIN(CVM, TK, T H E R P H ( 5 , K 1 ) , THERPH(6,K1 ) , THERPH( 7 , K 1 ) , THERPH( 8 . K 1 ) , THERPH( 9,K1) THERPH(10,K1), T H E R P H ( 1 1 , K 1 ) , THERPH(12,K1 ) THERPH(13,K1 ) ) TOTCV = TOTCV + ( C H E M ( d . I ) * CVM) TOTK = TOTK + ( C H E M ( d . I ) * THERPH(14,K1) ) ELSE IF (K2.EQ.2) THEN AQUEOUS S P E C I E S ELSE IF (K2.EQ.3) THEN SOLID SOLUTION ELSE IF (K2.EQ.4) THEN GASES ENDIF CONTINUE IF  (NUMREA(I) .GT. 0) THEN DO 90 d = 1, NUMREA(I) K1 = I R E A C T ( d . I ) TOTM = TOTM + C H E M ( J , I ) TOTW = TOTW + ( C H E M ( J . I ) * THERPH(1,K1 ) ) CALL VMIN(VTP, THERPH(4, K 1 ) , THERPH(12,K 1 ) , THERPH(13,K1), TK, PRES) TOTV = TOTV + ( C H E M ( d . I ) * VTP) CALL CVMIN(CVM, TK, T H E R P H ( 5 , K 1 ) , THERPH(6,K 1 ) , THERPH( 7,K1), THERPH( 8,K1), THERPH( 9,K1)  THERPH(10,K1), THERPH(11,K1), THERPH(12,K1 ) , THERPH(13,K1) ) TOTCV = TOTCV + ( C H E M ( d , I ) * CVM) TOTK = TOTK + (CHEM(d.I) * THERPH(14,K1)) CONTINUE ENDIF A K i d OF 5 TIMES S T A T I C VALUE OF K IS USED TOTK ATEMP ATEMP NOTE  = TOTK * 6.0 = ( 1 . 0 - PORE - XINT) * TOTK / TOTM = (ATEMP + (PORE * X K ) ) / X - E-03 TERM  I S TO CONVERT  CV FROM d/G TO d/KG  A( 1,2) A( 1,3) A(II,1) A(II,2) BTEMP = BTEMP = BTEMP =  = ( ATEMP) - (DENS * CV * V = (-ATEMP) + (DENS * CV * V = (-ATEMP) - (DENS * CV * V = ( ATEMP) + (DENS * CV * V ( 1 . 0 - PORE - X I N T ) * TOTCV BTEMP + (PORE * DENS * CV * BTEMP * X / ( 6 . 0 * DTAUT)  B( 1,2) B( 1,3) B(II,1) B(II,2)  = (BTEMP * 2.0) + = BTEMP = BTEMP = BTEMP * 2.0  / 2.0E-03) + A ( I , 2 ) / 2.0E-03) / 2.0E-03) / 2.0E-03) * 1.0E06 / TOTV 1.0E03)  B(I,2)  CONTINUE F I N I S H SETTING UP RIGHT HAND SIDE CALL BMMULT(B,102,NUMX,C,D) DO 150 I = 1, NUMX F(I) = F(I) + D(I) CONTINUE CALL BMMULT(A,102,NUMX,C,D) DO 160 I = 1, NUMX F ( I ) = F ( I ) + ((W1 - 1.0) * D ( I ) ) CONTINUE F I N I S H SETTING UP ELEMENT S T I F F N E S S DO  MATRIX  180 J = 1,3 DO 170 I = 1, NUMX A ( I , d ) = (W1 * A ( I . d ) ) + B ( I , J ) CONTINUE  CONTINUE SET UP BOUNDARY  CONDITIONS  F(1) = CELLT( 1.IFUTT) F(NUMX) = C E L L T ( N U M X , I F U T T ) DO 200 1 = 1 , 3 A(1,I ) = 0.0 A(NUMX,I) = 0 . 0 CONTINUE A( 1 ,2) =1.0 A(NUMX,2) = 1.0 SOLVE THE SYSTEM OF EQUATIONS USING IMSL ROUTINE LEQT1B THIS ROUTINE USES IMSL ROUTINES UERTST AND UGETIO FOR ERROR OUTPUT. CALL LEQT1B(A,NUMX,1,1,102,F,1,102,O,XL,204,IER) CHECK FOR LARGEST ERROR, COPY NEW VALUES TO TEMPERATURE ARRAY ERROR(2 ) = 0.0 DO 5 0 0 1 = 1 , NUMX X = ABS((CELLT(I,IFUTT) - F ( I ) ) / F ( I ) ) IF (X.GT.ERR0R(2) ) ERR0R(2) = X IF ( F ( I ) .LT. C E L L T ( N U M X , I F U T T ) ) F ( I ) = C E L L T ( N U M X , I F U T T ) IF ( F ( I ) GT. C E L L T ( 1,IFUTT)) F(I)=CELLT( 1,IFUTT) CELLT(I,IFUTT) = F ( I ) F ( I ) = 0.0 CONTINUE UPDATE PARAMETERS CALL UPDATE(IMSWIT) RETURN IF  I F ERROR TEST PASTED  (ERR0R(2).LE.ERRMAX(2))  RETURN  CONTINUE RETURN END SUBROUTINE SOLVEP(IMSWIT) THIS ROUTINE SETS UP THE F I N I T E ELEMENT MATRIXaS FOR THE SOLUTION OF THE NEW PRESSURES COMMON BLOCKS PREVIOUSLY DEFINED COMMON /CELLCO/ CHEMO(10,51) COMMON / C E L L S / C E L L P O ( 5 1 , 2 ) , C E L L P E ( 5 1 , 2 ) , C E L L P ( 5 1 , 2 ) , CELLT(51,2), DENSF(51,2), SIZEX(51), XINERT(51), THICK, NUMX, INOWP, IFUTP, INOWT, I F U T T COMMON /TIME/ DTAUP, DTAUT, DTAUC, DTAUM, TAUP, TAUT, TAUC,  TAUM, W1 /CHEMPH/ COMPPH(10,25) , THERPH(14,25), NUMPH /CHEMAQ/ COMPAQ(10,25) , THERAQ(13,25), NUMAQ /CHEMSS/ COMPSS(10,20) , T H E R S S ( 8 , 2 0 ) , NUMSS /CHEMG / COMPG(10,10), THERG(6,10), NUMG / C E L L C H / CHEM(10,51), T 0 T A L M ( 1 O , 5 1 ) , STRNGH(51), WATER(51), I N D E X 1 ( 1 0 , 5 1 ) , I N D E X 2 ( 1 0 , 5 1 ) , INDEX3(10,51 ) , I B A L ( 5 1 ) , NUMCHM, NCONST COMMON / D I V I N E / E R R 0 R ( 5 5 ) , ERRMAX(3), L 0 P T 0 T ( 5 5 ) , L I M L 0 P ( 3 ) COMMON /TRANS/ V E L 0 C ( 5 1 , 2 ) , A Q C O ( 1 0 , 5 1 , 2 ) , S O C O ( 1 0 , 5 1 , 2 ) , A L P H A ( 1 0 ) , INOWC, IFUTC COMMON /REACT/ REACTA(5,51 ) , I REACT(5,5 1 ) , NUMREA(5 1 ) COMMON COMMON COMMON COMMON COMMON  LOCAL VARIABLES CONTAINS A BANDED REPRESENTATION OF THE F I N I T E ELEMENT C O E F F I C I E N T ARRAY. INITIALLY CONTAINS THE [ A ] TERMS FOR THE EQUATIONS [A] P + [ B ] DP/DT = F CONTAINS A BANDED REPRESENTATION OF THE IN THE ABOVE EQUATION.  [ B ] AREA  C CV  CONTAINS THE PRESSURES AT TIME INOWP HEAT CAPACITY AT CONSTANT VOLUME FOR WATER  D  WORKING ARRAY DENSITY OF WATER, KG/M**3  DENS  DV/DP  DVDP DVDT F  AT CONSTANT  T FOR WATER  -  DV/DT AT CONSTANT P FOR WATER ON CALLING IMSL ROUTINE, CONTAINS THE RIGHT HAND SIDE OF THE EQUATIONS, ON E X I T , IT CONTAINS THE SOLUTION VECTOR. SEE ABOVE EQUATION.  GIBBS GDREF -  GIBBS FREE ENERGY AT T AND P FOR WATER DERIVATIVE OF GIBBS FREE ENERGY WITH RESPECT TO P AT REFERENCE TEMPERATURE (USED FOR VELOCITY TERM)  PERM PORE PRES  PERMIABILITY FOR AN ELEMENT - WEIGHTED WITH W1 IN TIME POROUSITY FOR AN ELEMENT - WEIGHTED WITH W1 IN TIME PRESSURE FOR AN ELEMENT - WEIGHTED WITH W1 IN TIME  -  TK  TEMPERATURE  VISCOS-  DYNAMIC  FOR AN ELEMENT  VISCOSITY OF WATER  - WEIGHTED WITH W1  IN TIME  VOLUME-  VOLUME  OF ELEMENT  X S I Z E OF ELEMENT, ALSO USED FOR TEMPERARY STORAGE XL WORK ARRAY FOR THE IMSL ROUTINE LEQT1B DIMENSION A ( 1 0 2 , 3 ) , B ( 1 0 2 , 3 ) , C ( 1 0 2 ) , D ( 1 0 2 ) , F ( 1 0 2 ) , X L ( 2 0 4 ) CALL MINIT(D, 102, 1, O.OEOO) CALL M I N I T ( F , 102, 1, O.OEOO) DO 50 I = 1, NUMX C ( I ) = CELLP(I,INOWP) * 1.0E06 CONTINUE SET UP ELEMENT S T I F F N E S S MATRIX EVALUATED AT TIME T + DELTA ( T / 2 ) EACH TERM IS EVALUATED FOR THE ELEMENT DO 9 0 0 LOOP = 1, L I M L O P ( 1 ) LOPTOT(1 ) = LOOP CALL M I N I T ( A , 102, 3, O.OEOO) CALL M I N I T ( B , 102, 3, O.OEOO) CALL M I N I T ( X L , 204, 1, O.OEOO) DO 100 1 = 1 , (NUMX - 1) II = I + 1 PRES = ( ( ( C E L L P ( I , I N O W P ) + CELLP(11,INOWP) ) * (1 - W1)) + ( ( C E L L P ( I , I F U T P ) + C E L L P ( I I , I F U T P ) ) * W1)) / 2.0 THE CALCULATIONS IMMEDIATELY BELOW (FOR T, PORE AND PERM) ASSUMES (CORRECTLY) THAT IN THIS ROUTINE, A L L ARRAYS ARE AT THE SAME TIME FOR THEIR INOW? TIME. TK = (CELLT(I,INOWT) + CELLT(11,INOWT)) S = ( C E L L T ( I . I F U T T ) + C E L L T ( I I , I F U T T ) ) - TK TK = TK / 2.0 S = S / ( 2 . 0 * DTAUT) TK = TK + (W1 * S * DTAUP) CALL NEW( TAUP, VALUE, 2) IF (TK .GT. VALUE) TK = VALUE PORE = ( C E L L P 0 ( I , I N O W C ) + CELLP0(11,INOWC) ) S = ( C E L L P O ( I , I F U T C ) + C E L L P O ( 1 1 , I F U T C ) ) - PORE PORE = PORE / 2.0 S = S / ( 2 . 0 * DTAUC) PORE = PORE + (W1 * S * DTAUP) PERM = ( C E L L P E ( I , I N O W C ) + C E L L P E ( I I , I N O W C ) ) S = ( C E L L P E ( I , I F U T C ) + C E L L P E ( 1 1 , I F U T C ) ) - PERM PERM = PERM / 2.0 S = S / ( 2 . 0 * DTAUC) PERM = PERM + (W1 * S * DTAUP) X = SIZEX(I)  VOLUME  = THICK * THICK * X  GET DENSITY AND CONVERT TO VOLUME IN THE RIGHT CALL H20(PRES, TK, DENS, GTP, HTP, STP, EOCON, DVDT, DVDP, D2VDT2, 0 ) DENS = 1.0 / DENS CALL V I S C ( V I S C O S , T K , D E N S ) CALCULATE CHEMICAL BASED TERMS S STORES TERMS WITH 51 STORES TERMS WITH 52 STORES TERMS WITH  UNITS CV,  FOR B AND F MATRIXaS RESPECT TO DP RESPECT TO DT RESPECT TO DN  S = O.OEOO 51 = O.OEOO 52 = O.OEOO DO 70 J = 1, NCONST K1 = I N D E X 1 ( d , I ) K2 = I N D E X 2 ( d , I ) IF ( K 2 . E 0 . 1 ) THEN SOLID PHASES CALL VMIN(VTP, THERPH( 4 , K 1 ) , T H E R P H ( 1 2 , K 1 ) , THERPH(13.K1), TK, PRES) S = S + ( C H E M ( d . I ) * 1.0E-06 * T H E R P H ( 1 3 , K 1 ) ) 51 = S1 + ( C H E M ( d . I ) * 1.0E-06 * THERPH(12,K1) ) 52 = S2 + (1.OE-06 * VTP * ( C H E M ( d . I ) - C H E M O ( d . I ) ) / DTAUM) ELSE IF ( K 2 . E 0 . 2 ) AQUEOUS S P E C I E S ELSE IF (K2.EQ.3) SOLID SOLUTION ELSE IF (K2.EQ.4) GASES ENDIF CONTINUE IF (NUMREA(I) .GT. 0) THEN DO 9 0 d = 1, NUMREA(I) K1 = I R E A C T ( d . I ) S = S + ( R E A C T A ( d , I ) * 1.OE-06 S 1 = S 1 + ( R E A C T A ( d . I ) * 1.OE-06 S2 = S2 + ? ? ? ? ? ? ? ? ? ? ? CONTINUE ENDIF S = S * (-1.0) * DENS / VOLUME S1 = S1 * (-1.0) * DENS / VOLUME  * THERPH(13,K1) ) * THERPH(12,K1 ) )  S2 = S2 * (-1.0) * DENS / VOLUME INCLUDE WATER TERMS (NO S2 WATER TERM  C C  AS WATER  IS PURE  S = S - (PORE * (DENS**2) * DVDP) S1 = S1 - (PORE * (DENS**2) * DVDT) S1 = S1 * ( C E L L T ( I , I F U T T ) - C E L L T ( I , I N O W T ) ) / DTAUT PERM = PERM * DENS / (VISCOS * X) A( 1,2) = PERM + A ( I , 2 ) A( 1,3) = PERM * (-1.0) A ( I I , 1) = PERM * (-1.0) A ( I I , 2 ) = PERM S = S * X / (DTAUP * 6.0) B( 1,2) B( I , 3 ) B(II,1) B(II,2)  = (S * 2.0) + B ( I , 2 ) = S = S = S * 2.0  C 100 C O 150  160 C C  F ( I ) = S1 + S2 CONTINUE F I N I S H SETTING UP RIGHT HAND SIDE CALL BMMULT(B,102,NUMX,C,D) DO 150 I = 1, NUMX F(I) = F(I) + D(I) CONTINUE IF (W1 .NE. 1.0) THEN CALL BMMULT(A,102,NUMX,C,D) DO 160 I = 1, NUMX F ( I ) = F ( I ) + ((W1 - 1.0) * D ( I ) ) CONTINUE ENDIF F I N I S H SETTING UP ELEMENT S T I F F N E S S MATRIX DO  170 180 C C C  180 J = 1,3 DO 170 I = 1, NUMX A ( I , J ) = (W1 CONTINUE CONTINUE  * A(I,d))  SET UP BOUNDARY CONDITIONS F(1) = CELLP( 1,IFUTP) * 1.0E06 F(NUMX) = CELLP(NUMX,IFUTP) * 1.0E06 DO 200 I = 1, 3, 2 A( 1 , I ) =0.0 A(NUMX,I) = 0.0  +'B(I.J)  HERE)  CONTINUE A(1,2) = 1.0 A(NUMX,2) = 1.0 SOLVE THE SYSTEM OF EQUATIONS USING IMSL ROUTINE LEQT1B THIS ROUTINE USES IMSL ROUTINES UERTST AND UGETIO FOR ERROR OUTPUT. I ER = 0 CALL LEQT1B(A,NUMX,1,1,102,F,1,102,0,XL,204,IER) IF ( I E R .NE. 0 ) THEN WRITE(6, 1001) STOP ENDIF CHECK FOR LARGEST ERROR, COPY NEW VALUES TO PRESSURE  ARRAY  ERROR(1) = 0.0 DO 500 1 = 2 , NUMX X = ABS ( ( ( 1 . 0 E 0 6 * C E L L P ( I , I F U T P ) ) - F ( I ) ) / F ( I ) ) IF ( X . G T . E R R O R ( 1 ) ) ERROR(1) = X IF ( F ( I ) .GT. ( 1 . 0 E 0 6 * C E L L P ( 1 ,IFUTP )) ) F ( I ) = C E L L P ( 1 , I F U T P ) * 1.0E06 C E L L P ( I , I F U T P ) = F ( I ) / 1.0E06 CONTINUE UPDATE PARAMETERS CALL  UPDATE(IMSWIT)  RETURN IF  I F ERROR TEST PASTED  ( E R R O R ( 1 ) . L E . E R R M A X ( 1 ) ) RETURN  CONTINUE RETURN FORMATC1 ERROR IN CALL TO ROUTINE LEQT1B IN ROUTINE', ' PSOLVE ' ) END SUBROUTINE O U T C ( I S T E P P , ISTEPT, I S T E P C , ICSWIT, IMSWIT, IUPDT) THIS ROUTINE PRINTS THE COMPOSITION OF EACH OF THE NODES COMMON BLOCKS PREVIOUSLY DEFINED CHARACTER*20 PHNAME(25), SSNAME(20), GNAME(10), DNAME(3 ) CHARACTER*8 FLNAME(10), AQNAME(25) CHARACTER*4 ELNAME(10) COMMON /CHNAME/ PHNAME, SSNAME, GNAME, DNAME, AQNAME, FLNAME, ELNAME COMMON / D I V I N E / E R R 0 R ( 5 5 ) , ERRMAX(3), L 0 P T 0 T ( 5 5 ) , L I M L 0 P ( 3 )  COMMON / C E L L C H / CHEM(10,51), T O T A L M ( 1 0 , 5 1 ) , STRNGH(51), WATER(51), I N D E X 1 ( 1 0 , 5 1 ) , I N D E X 2 ( 1 0 , 5 1 ) , I N D E X 3 ( 1 0 , 5 1 ) , I B A L ( 5 1 ) , NUMCHM, NCONST COMMON / C E L L S / C E L L P O ( 5 1 , 2 ) , C E L L P E ( 5 1 , 2 ) , C E L L P ( 5 1 , 2 ) , CELLT(51,2), DENSF(51,2), SIZEX(51), XINERT(51), THICK, NUMX, INOWP, IFUTP, INOWT, IFUTT COMMON /TIME/ DTAUP, DTAUT, DTAUC, DTAUM, TAUP, TAUT, TAUC, TAUM, W1 COMMON /TRANS/ V E L 0 C ( 5 1 , 2 ) , A O C O ( 1 0 , 5 1 , 2 ) . S O C O ( 1 0 , 5 1 , 2 ) , A L P H A ( 1 0 ) , INOWC, IFUTC COMMON /REACT/ R E A C T A ( 5 , 5 1 ) , I R E A C T ( 5 , 5 1 ) , NUMREA(51) COMMON /CHEMPH/ COMPPH(10,25), T H E R P H ( 1 4 , 2 5 ) , NUMPH COMMON /CHEMAO/ COMPAO(10,25), THERAQ(13,25), NUMAO WRITE(6,1000) I S T E P P , I S T E P T , I S T E P C , TAUC, WRITE(9,1001) TAUC, DTAUC DON'T PRINT COMPOSITIONS UNLESS NECESSARY  DTAUC  IF (ICSWIT.EQ.-1 .AND. IMSWIT.EQ.-1 .AND. ISTEPC.NE.O) GO TO 6 0 X = ERRMAX(3) * 100.0 WRITE(6, 1013) X, L I M L 0 P ( 3 ) WRITE(G, 1014) DO 5 I = 1, NCONST IF ( A B S ( A L P H A ( I ) ) .GT. 0.0) THEN X = ERR0R(I+2) * 100.0 WRITE(6, 1015) F L N A M E ( I ) , X, L 0 P T 0 T ( I + 2 ) ENDIF CONTINUE ISTART = 1 IFIN = ISTART + 7 IF (IFIN.GT.NCONST) I F I N = NCONST WRITE(6,1002) WRITE(6,1003) ( F L N A M E ( I ) , I = I S T A R T , I F I N ) DO 20 U = 1, NUMX WRITE(6,1004) J , ( A Q C 0 ( I , J , I F U T C ) , 1 = 1 S T A R T , I F I N ) CONTINUE ISTART = I F I N + 1 IF (ISTART.LE.NCONST) GO TO 10 DO 30 I = 1, NCONST W R I T E O , 1001 ) (AQCO( I , J , I F U T C ) , J=1 ,NUMX) CONTINUE ISTART = 1 IFIN = ISTART + 7 IF ( I FIN.GT.NCONST) I F I N = NCONST WRITE(6,1006)  50  55 60  WRITE(6,1003) ( F L N A M E ( I ) , I = I S T A R T , I F I N ) DO 50 d = 1, NUMX WRITE(6,1004) J , ( S O C O ( I , J , I F U T C ) , I = I S T A R T , I F I N ) CONTINUE ISTART = I F I N + 1 IF (ISTART.LE.NCONST) GO TO 40 DO 55 I = 1, NCONST WRITE(9,1001) ( SOCO( I , d,IFUTC),d=1,NUMX ) CONTINUE WRITE(6,1009) WRITE(6,1008) WRITE(9,1016) WRITE(6,1010) WRITE(6,1001) WRITE(9,1016)  TAUC ( C E L L P 0 ( I , I F U T C ) , 1 = 1, NUMX) ( C E L L P 0 ( I , I F U T C ) , I = 1, NUMX) TAUC ( C E L L P E ( I , I F U T C ) , I = 1, NUMX) ( ( A L O G 1 0 ( C E L L P E ( I . I F U T C ) ) ) , I = 1, NUMX)  UPDATE TIME AND ro ro  POINTERS  I = IFUTC IFUTC = INOWC INOWC = I TAUC = TAUC + DTAUC NOW PREDICT THE NEW COMPOSITIONS, BUT ONLY  80  90  IF NECESSARY  IF (ICSWIT.E0.-1 .AND IMSWIT.E0.-1) GO TO 120 DO 80 I = 1, NCONST IF ( A L P H A ( I ) .GT. 0.0) THEN AQCO(I 1,IFUTC) = AQCO(I INOWC) SOCO(I 1 ,IFUTC) = SOCO(I INOWC) AQCO(I,NUMX,IFUTC) AQCO(I,NUMX,INOWC) SOCO(I,NUMX,IFUTC) SOCO(I,NUMX,INOWC) ENDIF CONTINUE DO 100 1 = 2 , (NUMX - 1) DO 90 J = 1, NCONST IF ( A L P H A ( J ) .GT 0.0) THEN II = I - 1 A Q C O ( J , I , I F U T C ) = AOCO(J,I,INOWC) + ((AOCO(d,II,INOWC) AQCO(d,I, INOWC)) (SIZEX(I-I) / ((SIZEX(I-I) + SIZEX(I))* 2.0))) S O C O ( d , I , I F U T C ) = SOCO(d,I,INOWC) + ((SOCO(d,II,INOWC) SOCO(d,I,INOWC) ) * (SIZEX(I-I) / ((SIZEX(I-I) + SIZEX(I) * 2.0)))) ENDIF CONTINUE  100  CONTINUE  120  CALL NOW IF  UPDATE(IMSWIT) PRINT  ((ICSWIT  .NE.-1  - PRINT COMPOSITIONAL DATA ONLY I F  .OR.  IMSWIT.NE.-1) .AND.  IUPDT  .EO, 0 )  220  240  ENDIF IF (IUPDT .EQ. 0 ) THEN WRITE(6,1011) TAUC WRITE(6,1008) ( C E L L P O ( I , I F U T C ) , WRITE(6,1012) TAUC WRITE(6,1001) ( C E L L P E ( I , I F U T C ) , ENDIF  1=1,  NUMX)  I = 1, NUMX)  RETURN 1000  THEN  ISTART = 1 IFIN = ISTART + 7 IF (IFIN.GT.NCONST) I F I N = NCONST WRITE(6,1007) TAUC WRITE(6,1003) ( F L N A M E ( I ) , I = I S T A R T , I F I N ) DO 240 J = 1, NUMX WRITE(6,1004) J , ( S O C O ( I , d , I F U T C ) , I = I S T A R T , I F I N ) CONTINUE ISTART = I F I N + 1 IF (ISTART.LE.NCONST) GO TO 230  230  300  NECESSARY  ISTART = 1 IFIN = ISTART + 7 IF (IFIN.GT.NCONST) I F I N = NCONST WRITE(6,1005) TAUC WRITE(6,1003) ( F L N A M E ( I ) , 1 = 1 S T A R T , I F I N ) DO 220 J = 1, NUMX WRITE(6, 1004) J , ( A Q C O d . d , I F U T C ) , I = I S T A R T , I F I N ) CONTINUE ISTART = I F I N + 1 IF (ISTART.LE.NCONST) GO TO 210  210  ho  PREDICTIONS  FORMATC1 COMPOSITION, POROSITY AND PERIMIABILTY AT: 8X,'PRESSURE STEP NUMBER: ',18,/, 52X,'TEMPERATURE STEP NUMBER: ',18,/, 49X,'COMPONENT FLOW STEP NUMBER: ',18,//. TIME OF OUTPUT ( S E C ) : '.E12.5,/, ' TEMPERATURE TIME STEP ( S E C ) : '.E12.5)  1001 1002 1003 1004 1005  1006 1007  1008 1009 1010 101 1 N3 1012 1013 1014 1015 1016  FORMAT(10(1X.E12.5)) FORMATC//,' NUMBER OF MOLES OF EACH OF THE FLUID COMPONENTS' ' PER LITER FOR THE AQUEOUS S P E C I E S ARE: ',/) F0RMAT(3X, 'NODE: ' , 2 X , 8 ( 3 X , A 8 , 4 X ) ) FORMATC1X,I5,1X,8(3X,E12.5)) FORMATC//,' PREDICTED NUMBER OF MOLES OF EACH OF THE F L U I D ' , ' COMPONENTS PER LITER OF F L U I D ' , ' FOR TIME: '.E12.5,' SEC. ARE: ',/) FORMATC//,' NUMBER OF MOLES OF EACH OF THE FLUID COMPONENTS' ' IN THE SOLID PHASES ARE : ',/) FORMATC//,' PREDICTED NUMBER OF MOLES OF EACH OF THE F L U I D ' , ' COMPONENTS IN THE SOLID PHASES', ' FOR TIME: ' . E 1 2 . 5 , ' SEC. ARE: ',/) FORMATC10(3X,F10.5)) F O R M A T C O POROUSITIES AT THE NODES FOR TIME ',E12.5, ' SEC. ARE:',/) F O R M A T C O PERM I A B I L I T I E S AT THE NODES FOR TIME ',E12.5, ' SEC. ARE:',/) FORMATC'O PREDICTED POROUSITIES AT THE NODES FOR TIME ', E 1 2 . 5 , ' S E C . ARE:',/) FORMATC'0 PREDICTED P E R M I A B I L I T I E S AT THE NODES FOR TIME ', E12.5, ' SEC. ARE: ',/) FORMATC' MAX. ERROR ( P E R C E N T ) : .F12.8,/, ,15) ' MAX. NUMBER OF ITERATIONS I S : FORMAT (I/, 1 FLOW COMP',6X,'PERCENT ERROR' ,7X,'ITERATIONS') FORMATC ',A8,8X,F12.8,5X.14) FORMATC10(1X,F12.8)) END SUBROUTINE O U T P ( I S T E P P , I P S W I T , IUPDT) THIS ROUTINE PRINTS THE PRESSURES AT EACH NODE AND THE V E L O C I T I E S IN EACH C E L L . IT PREDICTS THE VALUES FOR THE NEXT TIME STEP COMMON / D I V I N E / E R R 0 R ( 5 5 ) , ERRMAX(3), L 0 P T 0 T ( 5 5 ) , L I M L 0 P ( 3 ) COMMON / C E L L S / C E L L P O ( 5 1 , 2 ) , C E L L P E ( 5 1 , 2 ) , C E L L P ( 5 1 , 2 ) , CELLT(51,2), DENSF(51,2), SIZEX(51), XINERT(51), THICK, NUMX, INOWP, IFUTP, INOWT, IFUTT COMMON /TRANS/ V E L 0 C ( 5 1 , 2 ) , AQCOC10,51,2), SOCO(10,51,2 ) , ALPHAC10), INOWC, IFUTC COMMON /TIME/ DTAUP, DTAUT, DTAUC, DTAUM, TAUP, TAUT, TAUC, TAUM, W1 K = NUMX - 1 IF ( I S T E P P . E Q . O .OR. IPSWIT.NE. •1) THEN X = ERRMAX(1) * 100.0 Y = ERROR( 1 ) * 100.0  WRITE(6,1000)  ISTEPP, TAUP, Y, L 0 P T 0 T ( 1 ) W R I T E ( 7 , 1 0 0 3 ) TAUP, DTAUP  DTAUP, X, L I M L 0 P ( 1 ) ,  WRITE(6,1001) WRITE(6,1002) ( C E L L P ( I , I F U T P ) , 1=1,NUMX) WRITE(7,1003) ( C E L L P ( I , I F U T P ) , 1=1,NUMX) WRITE(6,1004) WRITE(6,1003) ( V E L O C ( I , I F U T P ) , 1 = 1 , K ) WRITE(7,1003) ( V E L O C ( I , I F U T P ) , 1 = 1 , K ) ENDIF PREDICTION  to ro  100  1 10  FOR THE NEXT TIME  STEP.  I = IFUTP IFUTP = INOWP INOWP = I TAUP = TAUP + DTAUP IF (IPSWIT.NE.-1) THEN CALL NEW(TAUP, VALUE, 1) C E L L P ( 1 . I F U T P ) = VALUE CELLP(NUMX, I F U T P ) = CELLP(NUMX, INOWP) DO 100 I = 2, K C E L L P ( I , I F U T P ) = C E L L P ( I , INOWP) C E L L P ( I , I F U T P ) = C E L L P ( I , INOWP) + ( ( C E L L P ( I - 1, I F U T P ) C E L L P ( I + 1 , INOWP)) * ( S I Z E X ( I - I ) / (SIZEX(I-I) + SIZEX(I)))) CONTINUE ELSE I F ( I S T E P P .EQ. 0 ) THEN DO 110 I = 2, NUMX C E L L P ( I , I F U T P ) = C E L L P ( I , INOWP) CONTINUE ENDIF OUTPUT  PREDICTIONS  IF  (IUPDT .EQ. 0 ) THEN WRITE(6,1005) TAUP WRITE(6,1002) ( C E L L P ( I , I F U T P ) , 1=1,NUMX) ENDIF  1000  RETURN FORMATC1  PRESSURE OUTPUT AT PRESSURE STEP NUMBER: TIME OF CALCULATION ( S E C ) : ',E12.5,/, PRESSURE TIME STEP ( S E C ) : '.E12.5,//, 12X,' PERCENT ERROR LIMIT: '.F12.8, 4X,'MAX. NUMBER ITERATIONS: ',15,/,  18,//,  1001 1002 1003 1004 1005  : :  N> —I  12X,' PERCENT ERROR USED : '.F12.8, 3X,'TOTAL NUMBER ITERATIONS: ',15) FORMAT(//,' PRESSURES (MPA) AT THE NODES ARE : ',/) FORMAT(10(3X,F10.2)) FORMAT(10(1X,E12.5)) FORMAT(//' V E L O C I T I E S (M/SEC) BETWEEN EACH NODE ARE: FORMAT(//,' PREDICTED PRESSURES (MPA) AT THE NODES', ' FOR TIME: '.E12.5,' SEC. ARE:',/) END SUBROUTINE O U T T ( I S T E P P , I S T E P T , I T S W I T , IUPDT)  ',/)  THIS ROUTINE PRINTS THE TEMPERATURES AT EACH NODE AND PREDICTS THE TEMPERATURE FOR THE NEXT STEPS COMMON / D I V I N E / E R R 0 R ( 5 5 ) , ERRMAX(3) , L 0 P T 0 T ( 5 5 ) , L I M L 0 P ( 3 ) COMMON / C E L L S / C E L L P 0 ( 5 1 , 2 ) C E L L P E ( 5 1 , 2 ) , C E L L P ( 5 1 , 2 ) , CELLT(51,2), DENSF(51,2), SIZEX(51), XINERT(51), THICK, NUMX, INOWP, IFUTP, INOWT, IFUTT COMMON /TIME/ DTAUP, DTAUT, DTAUC, DTAUM, TAUP, TAUT, TAUC, TAUM, W1 IF (ITSWIT.NE.-1 .OR. ISTEPT.EQ.O) THEN X = ERRMAX(2) * 100.0 Y = ERROR(2) * 1O0.0 TAUT, DTAUT, X, WRITE( 6,1000) I S T E P P , ISTEPT L I M L 0 P ( 2 ) , Y, L 0 P T 0 T ( 2 ) WRITE( 8.1003) TAUT, DTAUT WRITE( WRITE( WRITE(  6,1001) 6,1002) ( C E L L T ( I , I F U T T ) , I = 1,NUMX) 8,1003) ( C E L L T ( I , I F U T T ) , 1=1,NUMX)  ENDIF NOW PREDICT THE NEW TEMPERATURES I = IFUTT IFUTT = INOWT INOWT = I TAUT = TAUT + DTAUT CALL NEW( TAUT, C E L L T ( 1 , I F U T T ) , 2) CELLT(NUMX, I F U T T ) = CELLT(NUMX, INOWT) IF (ITSWIT .NE. -1) THEN DO 100 1 = 2 , (NUMX - 1) C E L L T ( I , IFUTT) = C E L L T ( I INOWT) C E L L T O , IFUTT) = CELLT( I INOWT) + ( ( C E L L T ( I - 1, INOWT) - CELLT(I INOWT)) / 1.5) IF ( C EE LLLLTT((II,, I F U T T ) .GT CELLT(1.IFUTT) ) C E L L T ( I , IFUTT) = CELLT(1,IFUTT) IF ( C E L L T ( I , I F U T T ) . LT . C E L L T ( N U M X , I F U T T ) ) CELLT(NUMX,IFUTT) C E L L T ( I ,I F U T T )  100  1 10  CONTINUE ELSE DO 110 I = 2, (NUMX - D C E L L T ( I , IFUTT) = CELLT(I, CONTINUE ENDIF NOW  INOWT)  PRINT PREDICTIONS  IF  1000  ho CO  1001 1002 1003 1004  (IUPDT .EQ. 0 ) THEN WRITE( 6.1004) TAUT WRITE( 6.1002) ( C E L L T ( I , I F U T T ) . 1=1,NUMX) ENDIF RETURN FORMAT('1 TEMPERATURE OUTPUT AT: ' PRESSURE STEP NUMBER: ',18,/, 26x! TEMPERATURE STEP NUMBER: ',18,//, TIME OF OUTPUT ( S E C ) : '.E12.5,/, TEMPERATURE TIME STEP ( S E C ) : '.E12.5,//, PERCENT ERROR L I M I T : '.F12.8, 12X MAX. NUMBER ITERATIONS: ',15,/, 4X 12X PERCENT ERROR USED : '.F12.8, 3X TOTAL NUMBER ITERATIONS: ',15) FORMAT(//, ' TEMPERATURES (K) AT THE NODES ARE : ',/) FORMAT(10( 3 X . F 1 0 . 2 ) ) FORMAT(10( 1 X . E 1 2 . 5 ) ) FORMAT(//, ' PREDICTED TEMPERATURES ( K ) AT THE NODES FOR' ' TIME ' .E12.5,' SEC. ARE : ',/) END SUBROUTINE P A T C A L ( I T E R P , ITERT, ITERC, ITERM, INODE) THIS ROUTINE IS RESPONSIBLE FOR THE MASS TRANSFER CALCULATIONS IT LOADS THE ARRAYS AND CALLS THE STEPING AND PRINTING ROUTINES COMMON BLOCKS PREVIOUSLY DEFINED COMMON /PATH/ C ( 2 5 ) , CMOLE(IO), XMNOW(10), X M F U T ( 1 0 ) , R E A M T ( 5 ) , TKNOW, TKFUT, TAUNOW, TAUFUT, PNOW, PFUT, EMAX, STRONG, AMWAT, DTAU, DTK, DPRES, I P 0 I N T ( 2 5 ) , I N D R E A ( 5 ) , NUM, IPRINT, NUMREC COMMON /NEWCOM/ CNEWAO(10,25), CNEWPH(10,25), CNEWSS(10,20), CNEWG(10,10), I N D X 1 ( 1 0 ) , I N D X 2 ( 1 0 ) , I N D X 3 ( 1 0 ) , NUMELE LOCAL ARRAYS DERIV  CONTAINS THE FIRST FOUR D E R I V A T I V E S OF THE LOG MOLALITY OF THE COMPONENTS AND AQUEOUS S P E C I E S , OF THE IONIC STRENGTH,  OF THE A C T I V I T Y OF WATER, AND OF THE NUMBER OF MOLES OF THE SOLID PHASES WHICH ARE PART OF THE COMPONENT B A S I S . GRAND  - CONTAINS THE INVERSE OF THE GRAND MATRIX. THE SAME FOR A L L LEVELS OF DERIVATIVES  THIS MATRIX I S  DIMENSION GRAND(40,40), D E R I V ( 4 0 , 4 ) , DXM(10) CALL M I N I T ( D E R I V , 40, 4, O.OEOO) CALL MINIT(DXM, 10, 1, O.OEOO) DTAU = TAUFUT - TAUNOW DTK = TKFUT - TKNOW DPRES = PFUT - PNOW DO 10 I = 1, NUMELE DXM(I) = X M F U T ( I ) - XMNOW(I) CONTINUE THIS ROUTINE LOOPS BACK TO THIS STATEMENT UNTIL THE COMPLETE STEP IS TAKEN LOOP = 0 SET UP GRAND MATRIX IN T H E S I S  AND INVERT (USE PARTIONING METHOD DESCRIBED  CALL LEFT(GRAND, 4 0 ) IF THE STEP I S TOO LARGE, COME BACK TO HERE SET UP RIGHT HAND SIDE FOR DERIVATIVES AND SOLVE CALL DER(GRAND, DERIV, NDIR, 40, 4) TAKE STEP - IF NOT OK, REDUCE S I Z E AND TRY AGAIN LOOP = LOOP + 1 CALL S T E P ( D E R I V , 40, 4, NDIR, IOK) IF (IOK .NE. 0 .AND. LOOP .LT. 100) THEN DTAU = DTAU / 2.0E00 DTK = DTK / 2.0E00 DPRES = DPRES / 2.0E00 DO 180 1 = 1 , NUMELE DXM(I) = DXM(I) / 2.0E00 CONTINUE GO TO 150 ELSE I F (IOK .NE. 0 .AND. LOOP .GE. 100) THEN WRITE ( 6 , 1001) LOOP STOP ENDIF CHECK  FOR SUPERSATURATION - IF NOT SUPERSATURATED, PRINT - IF SUPERSATURATED, FIND PHASE BOUNDARY ADD PHASE TO MATRIX, PRINT  CALL S A T C H K ( I S A T ) IF ( I S A T . N E . O ) CALL SETSAT CALL P A T O U T ( I T E R P ,  ITERT,  ITERC,  ITERM)  TAUNOW TKNOW PNOW DO 210  = TAUNOW + DTAU = TKNOW + DTK = PNOW + DPRES J = 1, NUMELE XMNOW(d) = XMNOW(J) + DXM(d) CONTINUE IF ((TAUNOW+DTAU) .LT. TAUFUT .AND. TAUNOW+(2.0*DTAU) .LT. TAUFUT) THEN DTAU = TAUFUT - TAUNOW DTK = TKFUT - TKNOW DPRES = PFUT - PNOW DO 220 d = 1, NUMELE DXM(d) = XMFUT(d) - XMNOW(d) CONTINUE ENDIF IF (TAUNOW RETURN  .LT. TAUFUT) GO TO  100  FORMAT(' * * * * * * * * * * * * * * * ',//, ' ',15,' ITERATIONS MADE REDUCING THE STEP S I Z E ',/, ' RUN TERMINATED AS STEP S I Z E IS NOW TOO SMALL ',//) END SUBROUTINE SAQU( STP, SZERO, C1, C2, THETA, A3, A4, W, YPT, YPRTR, TK, P) THIS ROUTINE CALCULATES THE THIRD LAW ENTROPY OF AN AQUEOUS S P E C I E S USING EQUATION 274 FROM HELGESON, KIRKHAM AND FLOWERS, AdS 281, P. 1412 ( 1 9 8 1 ) . RETURNED:  STP - CALCULATED ENTROPY  AT T AND P  PASSED:  C1, C2, A3, A4, THETA, W, YPT, YPRTR - PARAMETERS IN EQUATION. SEE TEXT FOR D E T A I L S . SZERO - THIRD LAW ENTROPY AT TR, PR  P - PRESSURE IN MEGA-PASCALS TK - TEMPERATURE IN DEG K. NOTE: UNITS USED ARE dOULES AND MEGA-PASCALS, NOT CALORIES AND BARS AS IN HELG. ET. AL. REAL STP, SZERO, C1, C2, THETA, A3, A4, W, YPT, YPRTR  REAL TR, TK, P, PR PR = 0.1E00 TR = 2 9 8 . 1 5 E 0 0 STP = SZERO + ( C l * A L O G ( ( T K / T R ) ) ) + (C2 * ALOG(( (TK - T H E T A ) / ( T R - T H E T A ) ) ) ) + (THETA * ( ( 2 . 0 * A3 * (P - P R ) ) + (A4 * (p** - PR**2))) / (2.0E00 * ((TK - THETA)**2)) ) + (W * (YPT - YPRTR)) RETURN END SUBROUTINE SATEMP(P,TM) INTERVAL HALF TO CALCULATE SATURATION TEMPERATURE FOR A GIVEN PRESSURE. DOUBLE PRECISION TA, TB, TM, PC, PSATD 2  ro to  200  PC= 21.66D0 IF ( P .GT. PC) TM= 0.0 IF (P .GT. PC) RETURN TA= 0.0 TB= 370.74 DO 200 d=1,25 TM= (TA + TB ) / 2.0 PM= PSATD(TM) IF (PM .LE.P) TA TM IF (PM .GT. P ) TB= TM CONTINUE RETURN END SUBROUTINE UPDATE(IMSWIT) THIS ROUTINE UPDATES THE POROSITY COMMON BLOCKS PREVIOUSLY DEFINED  AND PERMIABILITY  COMMON / D I V I N E / E R R 0 R ( 5 5 ) , ERRMAX(3), L 0 P T 0 T ( 5 5 ) , L I M L 0 P ( 3 ) COMMON / C E L L C H / C H E M ( 1 0 , 5 1 ) , T 0 T A L M ( 1 0 , 5 1 ) , STRNGH(51 ) , WATER(51), I N D E X 1 ( 1 0 , 5 1 ) , INDEX2(10,51 ) , I N D E X 3 ( 1 0 , 5 1 ) , I B A L ( 5 1 ) , NUMCHM, NCONST COMMON / C E L L S / C E L L P O ( 5 1 ,2 ) , C E L L P E ( 5 1 ,2 ) , C E L L P ( 5 1 , 2 ) , CELLT(51,2) DENSF(51,2), SIZEX(51), XINERT(51), THICK, NUMX INOWP, IFUTP, INOWT, I F U T T COMMON /TIME/ DTAUP, DTAUT DTAUC, DTAUM, TAUP, TAUT, TAUC, TAUM, W1 COMMON /TRANS/ V E L 0 C ( 5 1 , 2 ) , AQCO(10,51,2) S O C O ( 1 0 , 5 1 , 2 ) , A L P H A ( 1 0 ) , INOWC. IFUTC COMMON /REACT/ R E A C T A ( 5 , 5 1 ) , I R E A C T ( 5 , 5 1 ) NUMREA(51)  COMMON /CHEMPH/ COMPPH(10,25), COMMON /CHEMAQ/ COMPAQ(10,25),  THERPH(14,25), THERAQ(13,25),  NUMPH NUMAQ  IFUTC) = CELLPE( 1 , IFUTC) = C E L L P E ( NUMX IFUTC) = CELLPO( 1 , IFUTC) = CELLPO( NUMX IFUTC) = DENSE ( 1 , IFUTC) = DENSF ( NUMX DO 200 I = !, (NUMX ((CELLT(I, TK  ho  170  CELLPE( 1 , INOWC) CELLPE(NUMX, INOWC) INOWC) CELLPO(1, CELLPO(NUMX, INOWC) INOWC) DENSF(1, INOWC) DENSF(NUMX, 1) I F U T T ) - C E L L T ( I , INOWT)) * DTAUC / DTAUT) + C E L L T ( I , INOWT) PRES = ( ( C E L L P ( I , I F U T P ) - C E L L P ( I , INOWP)) * DTAUC / DTAUP) + C E L L P ( I , INOWP) CALL H20(PRES, TK, VOL, GIBBS, HTP, STP, EQCON, CV, DVDT, DVDP, D2VDT2, O) DENS F ( I . I F U T C ) = 1.OEOO / VOL AMOUNT = O.OEOO DO 170 J = 1, NCONST K2 = I N D E X 2 ( J , I ) IF (K2.EQ.1) THEN K1 = I N D E X 1 ( J , I ) SUM VOLUMES CALL VMIN (X, THERPH(4,K1), THERPH(12,K1 ) , THERPH(13,K1), TK, PRES) AMOUNT = AMOUNT + ( C H E M ( d . I ) * X) ENDIF CONTINUE SUM  IN VOLUMES OF REACTANTS  IF  180  (NUMREA(I).GT.0) THEN DO 180 d = 1, NUMREA(I) K1 = I R E A C T ( d . I ) CALL VMIN (X, THERPH(4,K1), THERPH(12,K1), THERPH(13,K1), TK, PRES) AMOUNT = AMOUNT + ( R E A C T A ( J , I ) * X) CONTINUE ENDIF CONVERT TO METERS AND FIND FACTOR - NORMALIZE AMOUNT = AMOUNT d = I KK = d - 1  *  1.0E-06  IF ( K K . L T . 1) KK = d IF (d.GE.NUMCHM) d = KK VOLUME = ( T H I C K * * 2 ) * ( S I Z E X ( d ) + S I Z E X ( K K ) )/2 . 0 C E L L P O ( I , I F U T C ) = ((VOLUME * ( 1 . 0 - X I N E R T ( I ) ) ) - AMOUNT) / VOLUME C E L L P E ( I , I F U T C ) = C E L L P E ( I , INOWC) * C E L L P O ( I , I F U T C ) / C E L L P O ( I , INOWC) CONTINUE RETURN END SUBROUTINE  VAQU(VTP, A1, A2, A3, A4, THETA, 0, W,  TK, P)  THIS ROUTINE CALCULATES THE VOLUME OF AN AQUEOUS S P E C I E S USING EQUATION 253 FROM HELGESON, KIRKHAM AND FLOWERS, AdS 281, P. 1409 ( 1 9 8 1 ) . RETURNED:  VTP - CALCULATED VOLUME AT T AND P  PASSED:  A1, A2, A3, A4, THETA, W, Q - PARAMETERS IN EQUATION. SEE TEXT FOR D E T A I L S . P TK  - PRESSURE IN MEGA-PASCALS - TEMPERATURE IN DEG K.  NOTE: UNITS USED ARE dOULES AND MEGA-PASCALS, NOT CALORIES AND BARS AS IN HELG. ET. AL. REAL VTP, A1, A2, A3, A4, THETA, Q, W, TK, P VTP  A1 + (A2 * P) (W * Q) + ( ( ( A 3 * TK) + (A4 * TK * P ) ) / (TK - T H E T A ) )  RETURN END SUBROUTINE VEL THIS ROUTINE CALCULATES THE DARCY VELOCITY OF THE FLUID IN EACH OF THE ELEMENTS. COMMON / C E L L S / C E L L P O ( 5 1 , 2 ) , C E L L P E ( 5 1 , 2 ) , C E L L P ( 5 1 , 2 ) , CELLT(51,2), DENSF(51,2), SIZEX(51), XINERT(51), THICK, NUMX, INOWP, IFUTP, INOWT, IFUTT COMMON /TIME/ DTAUP, DTAUT, DTAUC, DTAUM, TAUP, TAUT, TAUC, TAUM, W1 COMMON /TRANS/ V E L 0 C ( 5 1 , 2 ) , AQCO(10,51,2), S O C O ( 1 0 , 5 1 , 2 ) , A L P H A ( 1 0 ) , INOWC, IFUTC COMMON /CHEMAQ/ COMPAQ(10,25), THERAQ(13,25), NUMAQ  DO  100 I II = PRES PERM X PERM X PERM TEMP X TEMP X TEMP X CALL  = 2, NUMX I - 1 = ( C E L L P ( I , I F U T P ) + C E L L P ( I I , I F U T P ) ) / 2.0 = ( C E L L P E ( I ,INOWC) + C E L L P E ( I I , I N O W C ) ) ( C E L L P E ( I ,IFUTC) + C E L L P E ( I I , I F U T C ) ) - PERM = PERM / 2 .0 X / ( 2 . 0 * DTAUC) = PERM + (X * DTAUP) = ( C E L L T ( I , INOWT) + C E L L T ( 1 1 , I N O W T ) ) ( C E L L T ( I , I F U T T ) + C E L L T ( I I , I F U T T ) ) - TEMP = TEMP / 2 .0 X / ( 2 . 0 * DTAUT) = TEMP + (X * DTAUP) SIZEX(II ) H20(PRES, TEMP, D2, G2, HTP, STP, EOCON, CV, DVDT, DVDP, D2VD2T, 0 ) D2 = 1.OEOO / D2 CALL V I S C ( V I S 2 , TEMP, D2)  ro  LO -P-  VELOC(II,IFUTP) VELOC(II,IFUTP)  100  c c c c c c c c c c c c c c c  PERM / VIS2 (-1.0E06) * V E L O C ( I I , I F U T P ) (CELLP(I,IFUTP) CELLP(II,IFUTP)) VELOC(II,IFUTP) / X  VELOC(II,IFUTP) CONTINUE RETURN END SUBROUTINE VMIN(VTP, VZERO, DVDT, DVDP, P) THIS ROUTINE CALCULATES THE VOLUME OF A SOLID PHASE AT T AND P USING: V ( T , P ) = V(TR.PR) + (DV/DT) (T - TR) + (DV/DP) (P - PR) RETURNED PASSED  LOCAL  VARIABLE:  VARIABLES:  VARIABLES  VTP VZERO DVDT DVDP T P TR PR  VOLUME  AT T AND P  - VOLUME AT TR AND PR (DV/DT) AT CONSTANT P (DV/DP) AT CONSTANT T - TEMPERATURE IN K - PRESSURE IN MPA 298.15 DEG. K 0.1 MPA  TR = 298 . 15 PR =0.1 VTP = VZERO + (DVDT * ( T - T R ) ) + (DVDP * (P - P R ) )  RETURN END SUBROUTINE V I S C ( V , T K , D E N S )  £ Ln  C C C C C C C C C C C C C C C C C C C C C  ROUTINE  TO CALCULATE THE VISCOSITY OF WATER AND STEAM. FORMULA AND CONSTANTS FROM WATSON, BASU AND SENGERS, AN IMPOROVED REPRESENTATIVE EQUATIONS FOR THE DYNAMIC V I S C O S I T Y OF WATER SUBSTANCE. <J. PHYS. CHEM. REF. DATA VOL 9, NO.4, 1980. P 1255. THIS ROUTINE IS ONLY ACCURATE OUTSIDE OF A REGION BOUNDED BY 645.30K < T < 652.55K AND .240 < DENSITY < .410 G/CM3 AS FEW  GEOLOGICAL SOLUTIONS ARE IN THIS REGION, IT WAS NOT THOUGHT NECESSARY TO ADD THIS CORRECTION TERM. THE CORRECTION TERM WOULD INVOLVE CONSIDERABLE CPU TIME AND ADD CONSIDERABLE LENGTH TO THE ROUTINE.  PROGRAMMED 9/2/83 E.H. PERKINS INPUT:  TK DENS  TEMPERATURES IN DEG. KELVINS DENSITY IN KG/M3  OUTPUT:  V  VISCOSITY  DIMENSION  A(4),  PA SEC  C0EF(6,7)  TR DENR  = =  647.27 317.763  A(1) A(2) A(3) A(4)  = 0.0181583 = 0.0177624 = 0.0105287 = -0.0036744  CALL M I N I T ( C 0 E F , 6, 7, O.OEOO) COEF( 1,1) = 0,.5132047 C0EF(2,1) = 0..3205656 C 0 E F ( 5 , 1 ) = - o ., 7782567 C0EF(6,1 ) = 0,. 1885447 COEF(1,2) = 0..2151778 C0EF(2,2) = 0..7317883 = 1 ,241044 . C0EF(3,2) = 1 .476783 . C0EF(4,2) C0EF(1,3) = - o . 2818107 C0EF(2,3) = -1 .070786 = -1 .263184 C0EF(3,3)  C0EF(1,4) C0EF(2,4) C0EF(3,4) C0EF(4,4) C0EF(1,5) C0EF(4,5) C0EF(2,6) C0EF(4,7)  30 N>  ON  0..1778064 0..4605040 0..2340379 4924179 = -o. = -o. 04176610 = 0. 1600435 = -0..01578386 = -0..003629481 = = =  T = TK / TR X = ( T * * -1 ( ) ) - 1 .0 D = DENS / DENR Y = D - 1 .0 THE LOW DENSITY LIMIT OF VISCOSITY (AS P SUM1 = 0. 0 DO 30 I I = 1 , 4 I = I I -- i SUM1 = SUM1 + ( A ( I I ) / ( T * * I ) ) CONTINUE SUM1 = 1 . 0 / SUM1 SUM1 = SUM 1 i ( S Q R T ( T ) )  > O )  VISCOSITY OUTSIDE OF THE C R I T I C A L REGION SUM2 = O.OEOO DO 50 I I = 1, 6 I = II - 1 DO 40 JO = 1, 7 IF ( C O E F ( I I ,,JO).EO.O.OEOO) GO TO 40 J = JJ - 1 (COEF(II,J0) (X**I) * (Y**J)) SUM2 = SUM2 40 CONTINUE 50 CONTINUE SUM2 = EXP((SUM2 * D ) ) V = SUM2 * SUM1 * ( 1 . 0 E - 6 ) RETURN END SUBROUTINE WFNS (RHO,TAU,W,M) DOUBLE PRECISION RH0M1(10), RH0M2(10), RH0M3, TAUM(10), E DOUBLE PRECISION C ( 1 0 , 1 0 ) , RHO, TAU, W(5,5), GRST, DEXP, 1 AA, AB, AC, RONE, EXPE, RMC, TMC , T 2 5 , T M ( 5 ) , RM(5) DO 1 0=1,5 DO 1 1=1,5 W(I,0)=0. GO TO ( 1 5 , 2 0 . 3 0 , 3 0 ) , M READ EQUATION DATA 15 OMAX = 7  C C C  15  C C  C C  £ C C  9876 C C  C  IMAX = 10 READ(17,13) JMAX,IMAX PRINT 13,JMAX,IMAX PRINT 160 JMAX = 7 11 = 8 12 = 2 READ(17,111) JMAX,11,12 PRINT111,JMAX,11 , 12 E = 4.8 RH0M3= 0.0 READ(17,10) E.RH0M3 PRINT1O,E,RH0M3 RH0M1(1) = 634 RH0M1(2) = 1.0 RH0M1(3) = 1.0 RH0M1(4) = 1.0 RH0M1(5) = 1.0 RH0M1(6) = 1.0 RH0M1(7) = 1.0 READ(17,10) (RH0M1 ( I ) , 1 = 1 ,7) PRINT 10,(RH0M1(I),1 = 1,7) DO 9876 1 = 1 , 7 RH0M2(I) = 0.0 CONTINUE READ(17,10) ( R H 0 M 2 ( I ) , 1 = 1 , 7 ) PRINT 1 0 , ( R H Q M 2 ( I ) , I = 1,7) TAUM(1) = 1.545 TAUM(2) = 2.5 TAUM(3) = 2.5 TAUM(4) = 2.5 TAUM(5) = 2.5 TAUM(6) = 2.5 TAUM(7) = 0.0 READ(17,10) ( T A U M ( I ) , I = 1 , 7 ) C ( 1 , 1 ) = 0.1508935547E+02 C ( 2 , 1 ) = -.7210865784E+02 C ( 3 , 1 ) = O.1524410858E+03 C ( 4 , 1 ) = -.2000392914E+03 C ( 5 , 1 ) = 0.1932660828E+03 C ( 6 , 1 ) = -.1421213989E+03 C ( 7 , 1 ) = 0.7826339722E+02 C ( 8 , 1 ) = -.2260081482E+02 C ( 9 , 1 ) = -.2293457642E+03 C ( 1 0 , 1 ) = -.2249741058E+03 C ( 1 , 2 ) = -.1126399040E+01  c ( 2 , 2 )  =  -  8325212479E+01  c  3 , 2 )  =  0  1759562683E+02  c  4 , 2 )  =  -  1659400940E+02  c  5 , 2 )  =  0  5603165627E+01  c  6 , 2 )  =  0  1274073334E+03  c ( 7 , 2 )  =  0  9321633911E+02  c ( 8 , 2 )  =  0  7698554993E+02  c ( 9 , 2 )  =  0  4911743164E+02  =  c ( 1 0 , 2 )  -.4083481445E+03  c ( 1 . 3 )  =  0  6248408318E+01  c ( 2 , 3 )  =  -  2587362671E+02  c  3 . 3 )  =  0  5028768921E+02  c  4 , 3 )  =  -  6465473938E+02  c  5 , 3 )  =  0  0  c  6 , 3 )  =  0  0  c  7,3)  =  0  0  c  8 , 3 )  =  0  0  c  9 , 3 )  =  -  c  10,3)  =  1552604218E+03  -- . 6 5 3 3 6 1 5 7 2 3 E + 0 3  c  1,4)  =  0  7511532307E+00  c  2,4)  =  -  2641253471E+01  c  3 , 4 )  =  0  4849147797E+01  c  4 , 4 )  =  0  3395516396E+01  c  5,4)  =  0  0  c  6 , 4 )  =  0  0  c  7,4)  =  0  0  c  8 , 4 )  =  0  0  c  9 , 4 )  =  -  c  10,4)  c  =  4012123108E+01  -- . 8 0 9 3 4 0 5 1 5 1 E + 0 2  1,5)  =  -  2360856056E+01  C( 2 , 5 )  =  0  9403068542E+01  c  3 , 5 )  =  -  1887019348E+02  C( 4 , 5 )  =  0  2299574280E+02  C( 5 , 5 )  =  0  0  C( 6 , 5 )  =  0  0  Cl 7 , 5 )  =  0  0  C( 8 , 5 )  =  0  0  c  9 , 5 )  =  0  c  10,5)  c  =  1,6)  =  C( 2 , 6 )  =  C( 3 , 6 ) C( 4 , 6 ) C( 5 , 6 )  5559095764E+02 0 . 2 2 9 7 2 9 7 0 5 8 E + 0 3  -  1041758537E+01  0  4143721581E+01  =  -  7860260963E+01  =  0  5793392181E+01  =  0  0  C( 6 , 6 )  =  0  0  C( 7 , 6 )  =  0  0  C ( 8 , 6 ) = 0.0 C ( 9 , 6 ) = 0.1863822937E+02 C ( 1 0 , 6 ) = 0.1088137970E+03 C ( 1 , 7 ) = -.1080222130E+00 C ( 2 , 7 ) = 0.4030921459E+00 C ( 3 , 7 ) = -.4694258571E+00 C ( 4 , 7 ) = 0.1748328283E-01 C ( 5 , 7 ) = 0.0 C ( 6 , 7 ) = 0.0 C ( 7 , 7 ) = 0.0 C ( 8 , 7 ) = 0.0 C ( 9 , 7 ) = 0.6496112347E+00 C ( 1 0 , 7 ) = 0.1228528786E+02 DO 2 d=1,dMAX READ(17,3) ( C ( I , d ) , I = 1 , I M A X ) 2 CONTINUE RETURN SHORT VERSION W11.W12.W21 ONLY CONTINUE RMC = RHO-RHOM 1 ( 1 ) TMC=TAU-TAUM(1 ) T25=TAU-TAUM(2) EXPE=DEXP(-E *RHO) RONE=RHO-RH0M1(2) DO 44 d = 2,7 AB=0. AC=0. DO 41 1=2,4 AA=C(I,J)*RONE**(1-2) AB=AB+AA*RONE AC=AC+AA*(1-1) AA=EXPE*(C(9,d)+RH0*C(10,J)) AB=AB+AA+C(1,d) AC=AC+EXPE*C(10,J)- E *AA AA=T25**(d-2) W( 1 , 1 )=W(1,1)+AB*AA W(2,1)=W(2,1)+AC*AA W(1,2)=W(1,2)+AB*AA*(1.+TMC*(d-2)/T25) DO 42 1=5,8 AA=C(I,2)*R0NE**(I-2) W( 1 ,1)=W(1, 1)+AA*RONE W(1,2)=W(1,2)+AA*R0NE W(2,1)=W(2.1)+AA*(I-1) W( 1 , 1 )=W(1,1)*TMC W(2,1)=W(2,1)*TMC DO 43 1=2,8  43  C 30  23  22 11 C 35 12 C 40 13 3 150 101 4 160  AA=C(I, 1 )*RMC**(1-2) W(1,1)=W(1, 1)+AA*RMC W(2, 1)=W(2,1 )+AA*(I-1 ) AA=EXPE*(C(9,1)+RHO*C(10,1 ) ) W(1, 1)=W(1, 1 )+C( 1 , 1)+AA W ( 2 , 1 ) = W ( 2 , 1 ) + E X P E * C ( 1 0 , 1 ) - E *AA W( 1 , 1)=W(1,1)*RH0 W(2,1)=W(2,1)*RH0**2 W(1,2)=W(1,2)*RH0*TAU RETURN LONG VERSION USING GRST ALL W OR OS KE=4 LE = 3 DO 11 d=1,dMAX TM(1)= G R S T ( I , d ,RHO,TAU,3, * UMAX,I 1,12,E,RH0M3, RH0M1,RH0M2,TAUM) TM(2)=GRST(I,d,RHO,TAU,6. * UMAX,I 1,12,E.RH0M3, RHOM1,RH0M2,TAUM) TM(3)=GRST(I,d,RHO,TAU,9, * dMAX,I1,I2,E,RH0M3, RHOM1,RH0M2,TAUM) DO 11 1=1,IMAX RM(1)=GRST(I,d,RHO,TAU,4, * UMAX,11,I2,E,RH0M3, RHOM1,RH0M2,TAUM) RM(2)=GRST(I,d,RHO,TAU,5, * UMAX,I 1,12,E,RH0M3, RHOM1,RH0M2,TAUM) GO TO ( 2 2 , 2 2 , 2 3 , 2 3 ) , M RM(3)=GRST(I,d,RH0,TAU,7, * UMAX,11,I2.E.RH0M3, RHOM1,RH0M2,TAUM) RM(4)=GRST(I,d,RHO,TAU,8, * JMAX,I1,I2,E,RH0M3, RHOM1,RH0M2,TAUM) DO 11 K=1,KE DO 11 L=1,LE W(K,L)=W(K,L) +C ( I , d ) *RM( K ) *TM( I.) GO TO ( 4 0 , 4 0 , 3 5 , 4 0 ) , M FOR W DO 12 K=1,KE DO 12 L=1,LE W(K,L)=W(K,L)*RH0**K*TAU**(L-1) FOR 0 RETURN FORMAT ( 1 0 1 3 ) FORMAT(5D16.10) FORMATC '.6F15.6) F0RMAT(8F1O.O) FORMAT (//) FORMAT (//)  111 10  FORMAT ( 1 0 1 3 ) FORMAT ( 7 D 1 0 . 3 ) END . DOUBLE P R E C I S I O N FUNCTION GRST (I,d,RHO,TAU,L, * dMAX,I 1,12,E,RH0M3, RHOM1,RH0M2,TAUM) C L=1 I N I T , 2 GRST=ZERO , 3 TAU FN, 4 RHO FN, 5 DERIV RHO FN C 6 DERIV TAU FN, 7 2ND DERIV RHO FN, 8 3RD DERIV RHO FN C 9 2ND DERIV TAU FN DOUBLE PRECISION RHOM1(10), RH0M2(1O), RH0M3, TAUM(10), RHO DOUBLE PRECISION EXPE, EXPEM, E, DRHO, EXPK, DEXP, TAU GRST= 1 . GO TO ( 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ) , L 1 CONTINUE 2 GRST=0 RETURN 3 IF ( d - 2 ) 30,31,32 32 GRST=EXPK(TAU-TAUM(2),d-2) 31 GRST=GRST*(TAU-TAUM(1)) 30 RETURN 6 IF ( d - 2 ) 2,30,62 62 GRST= ((TAU-TAUM(1))*EXPK(TAU-TAUM(2),d-3)*(d-2) 1 +EXPK(TAU-TAUM(2),J-2)) RETURN 9 IF ( d - 3 ) 2,92,91 91 GRST= ((TAU-TAUM(1))*(d-2)*(d-3)*EXPK(TAU-TAUM(2),d-4) 1 +2.*(d-2)*EXPK(TAU-TAUM(2),d-3)) RETURN 92 GRST=2. RETURN 4 LD=0 GO TO 100 5 LD=1 GO TO 100 7 LD = 2 GO TO 100 8 LD = 3 100 LDA=LD+1 IF ( I - 1 1 - 1 ) 20,21,21 20 GRST=EXPK(RH0-RH0M1(d),I-1-LD) GO TO ( 3 0 , 2 7 , 2 8 , 2 9 ) , L D A 29 GRST=GRST*(1-3) 28 GRST=GRST*(1-2) 27 GRST = G R S T * ( I - 1 ) RETURN 21 IA = I-11 DRHO=RHO-RH0M2(d)  22 23 24  25  1 2 ho  3  EXPE=DEXP(-E*RHO) EXPEM=EXPE-RH0M3 GO TO ( 2 2 , 2 3 , 2 4 , 2 5 ) , L D A GRST=EXPEM*EXPK(DRHO,IA-1) RETURN GRST=EXPEM*(IA-1)*EXPK(DRHO,IA-2) -E*EXPE*EXPK(DRHO,IA-1 ) RETURN GRST=EXPEM*(IA-1)*(IA-2)*EXPK(DRHO,IA-3) 1 -2.*E*EXPE*(IA-1)*EXPK(DRHO,IA-2) 2 +E**2*EXPE*EXPK(DRHO,IA-1) RETURN GRST=EXPEM*(IA-3)*(IA-2)*(IA-1)*EXPK(DRHO,IA-4) 1 -3.*E*EXPE*(IA-1 )*(IA-2)*EXPK(DRHO,IA-3) 2 +E**2*EXPE*EXPK(DRH0,IA-2) +E**3*EXPE*EXPK(DRHO,IA-1 ) RETURN END DOUBLE PRECISION FUNCTION EXPK ( A , L ) DOUBLE PRECISION A IF ( L ) 1,2,3 EXPK=0. RETURN EXPK=1. RETURN EXPK=A**L RETURN END DOUBLE PRECISION FUNCTION PWAG(T68) DOUBLE PRECISION DEXP DOUBLE PRECISION TAU,TEMP,TCRIT,T68,W TEMP= T68 + 273.15 TCRIT= 647.25 TAU= 1.0TEMP/TCRIT -7.863889 * TAU W + 1 .898527 * TAU**1.5 W + (-2.364891 * TAU**2.5) W + (-9.911414 * TAU**6.5) W + ( 9 . 9 8 2 9 5 2 * TAU**7.5) DEXP(TCRIT/TEMP * W) PWAG= 220.93 * W PWAG= PWAG/10. RETURN END SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS S S S THE FUNCTION BELOW THIS COMMENT CALCULATES VAPOUR PRESSURE S  c c c c c c c c  N3  S FROM T68 USING POLLACK'S EQUATION OF STATE: S TC = C R I T I C A L TEMPERATURE (DEG K) S PC = C R I T I C A L PRESSURE (BARS) S PPOL = POLLACK'S PRESSURE (MPA) S U = T (DEG K) / TC S SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS DOUBLE PRECISION FUNCTION P P 0 L ( T 6 8 ) DOUBLE PRECISION A ( 8 ) , TC, T68, U, PC, LNPIE, DEXP, XXXX TC = 647.25 PC = 220.93 A(1) = -7.8889166 A(2) = 2.5514255 A(3) = -6.7161690 A(4) = 33.239495 A ( 5 ) = -105.38479 A(6) = 174.35319 A ( 7 ) = -148.39348 A(8) = 48.631602 U = ( T 6 8 + 2 7 3 . 1 5 ) / TC LNPIE = 0.0 DO 1 U=1,8 LNPIE = L N P I E + A ( J ) * ( ( 1 0 - U ) * * ( ( D F L O A T ( J ) + 1 . 0 ) / 2 . 0 ) ) XXXX= D B L E ( ( F L O A T ( J ) + 1 0 ) / 2 . 0 ) LNPIE = L N P I E + A ( U ) * ( ( 1 0-U)**XXXX) CONTINUE LNPIE = LNPIE / U PPOL = DEXP ( L N P I E ) * PC/10.0 RETURN END DOUBLE PRECISION FUNCTION P S A T D ( T 6 8 ) DOUBLE PRECISION T68, TC, PC, TAU, DEXP, W, T, A ( 3 0 ) DO 200 J=1,30 A ( J ) = O.C CONTINUE 200 PC = 21 .66 DO TC = 643.89 DO T = T68 + 273 15 DO TAU = 1 .ODO T/TC I F ( T A U .LT. -0.00001) PSATD= 0.0 I F ( T A U .LT. -0.00001) RETURN IF (TAU .LT. 0.0) TAU 0.0 A(1) = -7.8158255 A(3)= 17.601192  300  A(4)= -18.174658 A(11)= -3.9248806 A ( 2 0 ) = 4.1917387 W = 0.0 W = W + TAU * * ( 1 ) * A ( 1 ) W + TAU * * ( 1 .5) * A ( 2 ) W = W + TAU * * ( 1 . 9 ) * A ( 3 ) W = DO 300 d 4,20 EXPON= d EXPON= d/2.0 W= W + TAU **EXPON * A ( d ) CONTINUE W= DEXP(TC/T * W) PSATD= W * PC RETURN END DOUBLE PRECISION FUNCTION T F I X ( T I P T S , T D I F F ) CONVERTS T (C 1948) TO T (C 1968) REFERENCES BEDFORD, RE / KIRBY GM/ METROLOGIA, 5, 83 ( 1 9 6 9 ) KELL, GS / d CHEM ENG DATA, VOL 20, 1 ( 1 9 7 5 ) DOUGLAS TB / d RES NAT BUR STAND, A VOL 73, 468, DOUBLE PRECISION T I P T S , TDIFFW, T D I F F Z , T D I F F , W  (1969)  RETURN I F ( ( T I P T S . LT . 0.0) .OR.(TIPTS .GT. 1 0 6 4 . ) ) GO TO IF ( ( T I P T S .GE . 0 . 0 ) . A N D . ( T I P T S .LT. 6 3 0 . 7 4 ) ) IF ( ( T I P T S .GE 630.74).AND.(TIPTS .LE. 1 0 6 4 . 4 3 ) ) GO 200  300  CONTINUE TDIFFW= 0.00045 * T I P T S * ( T I P T S / 1 0 0 . 0 - 1.0) TDIFFW= TDIFFW * ( T I P T S / 4 1 9 . 5 8 - 1.0) TDIFFW= TDIFFW * ( T I P T S / 6 3 0 . 7 4 - 1.0) TDIFFZ= 4.9035 / 100000.0 * T I P T S (TIPTS/100.0 TDIFFZ= T D I F F Z / ( 1 . 0 - 2.94855 * T I P T S / 1 0 0 0 0 . 0 ) TFIX = T I P T S + TDIFFW + T D I F F Z TDIFF= TDIFFW + T D I F F Z RETURN CONTINUE W= -1.3145 + W= W + 1.5625 W= W / (1.0 + TDIFF= W TFIX= TIPTS + RETURN END  .5016 * 10. * * ( - 3 ) * T I P T S 10.**(-6) * TIPTS**2 .101 * 1 0 . * * ( - 4 ) * T I P T S )  200 TO 300  1 .0)  500  500  to  -e0  1  C C C  c  C C C  DOUBLE P R E C I S I O N FUNCTION H Z F U N C ( T , H Z C , R ) DOUBLE P R E C I S I O N T , DLOG, H Z C ( 8 ) HZFUNC= 0 . 0 DO 5 0 0 d = 1 , 6 HZFUNC= HZFUNC + H Z C ( J ) * (1.0-(d-1))*T**(d-1)/(1000.0**(d-1)) CONTINUE HZFUNC= HZFUNC + H Z C ( 7 ) * ( D L O G ( T ) - 1 . 0 ) + (R - H Z C ( 8 ) / 1 0 0 0 . ) * T RETURN END DOUBLE P R E C I S I O N FUNCTION C P F U N C ( T , H Z C , R ) DOUBLE P R E C I S I O N H Z C ( 8 ) , T CPFUNC= 0 . 0 DO 5 0 0 d = 3 , 6 CPFUNC= CPFUNC + HZC(d)*((2-d)*(d-1))*T**(d-2)/(1000.0**(d-1)) CONTINUE CPFUNC= CPFUNC + H Z C ( 7 ) / T + (R - H Z C ( 8 ) / 1 0 0 0 . ) RETURN END SUBROUTINE B A S I S ( V E C T O R , L ) T H I S ROUTINE CHANGES THE B A S I S OF A L L COMPOSITIONAL ARRAYS AND RETURNS THE RESULT I N M A T R I X ' S CNEWAO, CNEWPH, CNEWG AND CNEWSS THE VALUES PASSED I N VECTOR ALSO HAVE T H E I R B A S I S L I S THE INDEX OF THE NODE COMMON COMMON COMMON COMMON COMMON  CHANGED.  C O M P P H ( 1 0 , 2 5 ) , T H E R P H ( 1 4 . 2 5 ) , NUMPH C O M P A Q ( 1 0 , 2 5 ) , T H E R A Q ( 1 3 , 2 5 ) , NUMAQ COMPSS(10,20), THERSS(8,20), NUMSS COMPG(10,10), THERG(6,10), NUMG CNEWAQ(10,25), CNEWPH(10,25), CNEWSS(10,20), CNEWG(10,10), I N D X 1 ( 1 0 ) , I N D X 2 ( 1 0 ) , INDX3(10), NUMELE REAL A ( 1 0 , 1 0 ) , V E C T O R ( 1 0 ) , S A V E ( 1 0 ) CALL M I N I T ( A , 1 0 , 1 0 , O.OEOO) CALL MCOPY(SAVE, VECTOR, 1 , 1 , NUMELE, 1 , 1 0 , 1 , 1 0 , 1)  C C  /CHEMPH/ /CHEMAO/ /CHEMSS/ /CHEMG / /NEWCOM/  B U I L D THE CHANGE OF B A S I S ARRAY DO 1 0 0 1 = 1 , NUMELE K1 = I N D X 1 ( I ) K2 = I N D X 2 ( I ) DO 9 0 d = 1 , NUMELE I F ( K 2 . E Q . 1 ) THEN  C A(d,I) C  =  SOLID C0MPPH(d,K1)  PHASE  COMPONENTS  ELSE  IF (K2.EQ.2) THEN  C A(J,I)  AQUEOUS S P E C I E S COMPONENTS = COMPAQ(d,K1)  C ELSE  IF (K2.EQ.3) THEN  ELSE  SOLID SOLUTION COMPONENTS A ( d , I ) = COMPSS(U,K1) IF (K2.EQ.4) THEN GAS COMPONENTS A ( J , I ) = COMPG(J,K1)  C  C C ELSE C  ERROR WRITE(6,1000) K2 STOP  C 90 100 C C  ENDIF CONTINUE CONTINUE FORM NEW BASIS AND MULTIPLY THROUGH CALL INVRT( A, NUMELE, 10, J ) IF (d.NE.O) THEN WRITE(6,1001) IF (L.NE.O) WRITE(6,1002) L STOP ENDIF IF (NUMAQ.GT.O) CALL MMULT(CNEWAQ,A,COMPAQ,NUMELE,NUMELE, NUMAQ,10,25,10,10,10,25) IF (NUMPH.GT.O) CALL MMULT(CNEWPH,A,COMPPH,NUMELE,NUMELE, NUMPH,10,25,10,10,10,25) IF (NUMSS.GT.O) CALL MMULT(CNEWSS,A,COMPSS,NUMELE,NUMELE, NUMSS,10,20,10,10,10,20) IF (NUMG .GT.O) CALL MMULT(CNEWG, A,COMPG, NUMELE,NUMELE, NUMG, 1 0 , 2 5 , 1 0 , 1 0 , 1 0 , 2 5 ) CALL MMULT(VECTOR, A, SAVE, NUMELE, NUMELE, 1, 10, 1, 10, 10, 10, 1)  ro  i~ ^  C 1000 1001 1002  RETURN FORMAT('0 *** ERROR IN INDEX 1 IN ROUTINE BASIS ',/, ' K2 HAS A VALUE OF ',15) FORMAT('0 *** BASIS PASSED TO ROUTINE INVRT FROM ROUTINE', ' BASIS WHICH WAS NOT INDEPENDENT.') FORMAT('0 PASSED FOR NODE ',15) END SUBROUTINE COND(THERMK,TK,DENS)  THIS ROUTINE CALCULATES THE THERMAL CONDUCTIVITY OF WATER AND STEAM USING THE RECOMMENDED INTERPOLATING EQUATION FOR INDUSTRIAL USE. ( d . KESTIN, MECHANICAL ENGINEERING, dULY 1978, VOL 100, ISSUE 8, PAGE 4 6 ) . THIS EQUATION IS THE EQUATION CONTAINED IN THE IAPS (INTERNATIONAL ASSOCIATION FOR THE PROPERTIES OF STEAM) RELEASE RTC 77. THIS EQUATION DOES NOT GIVE A GOOD REPRESENTATION AT/NEAR THE C R I T I C A L POINT AS IT PREDICTS A F I N I T E VALUE AT THE C R I T I C A L POINT. HOWEVER, IF IT IS EXCLUDED USE IN THE REGION BOUNDED BY T=T(CR) +/- 1.5C AND DEN = DEN(CR) +/- 100KG/M**3 IT IS IDENTICAL TO THE RECOMMENDED INTERPOLATING EQUATION FOR S C I E N T I F I C USE (SAME P U B L I C A T I O N ) . THE S C I E N T I F I C EQUATION HAS NOT BEEN USED DUE TO THE EXTRA INFO NEEDED AND INCREASED CPU TIME PROGRAMMED: 8/2/83 E.H. PERKINS INPUT: TK TEMPERATURE IN DEG. K DENS DENSITY IN KG/M**3 ro  OUTPUT: THERMK THERMAL CONDUCTIVITY DIMENSION A ( 4 ) , B ( 3 ) , C ( 6 ) , D ( 4 ) 647 . 3 TR 1.02811E-02 A(1) 2 99621E-02 A(2) = 1.56146E-02 A(3) -4.22464E-03 A(4) -3.97070E-01 B( 1) 4.00302E-01 B(2) 1.06000 B(3) -1.71587E-01 BB1 2.39219 BB2 6.42857E-01 C(1) -4.11717 C(2) -6. 17937 C(3) 3.08976E-03 C(4) 8.22994E-02 C(5) 1.00932E01 C(6) 317.7 DENR 7.01309E-02 D(1) 1.18520E-02 D(2) 1.69937E-03 D(3) -1.02000 D(4) TK / TR T DENS / DENR DRAT A B S ( ( T - 1.0)) + C ( 4 ) DELT  W/K  M  10  DUM = DELT**(-0.6) 0 = 2.0 + ( C ( 5 ) * DUM) R = 0+1.0 IF ( T . G E . 1 . 0 ) S = 1 / DELT IF ( T . L E . 1 . 0 ) S = C ( 6 ) * (DUM) THERM 1 = O.OEOO DO 10 I = 1, 4 d = I - 1 THERM 1 = ( A ( I ) * ( T * * J ) ) + THERM 1 CONTINUE THERM 1 = THERM 1 * ( S Q R T ( T ) ) THERM2 = B( 1 ) + ( B ( 2 ) * DRAT) THERM2 = THERM2 + ( B ( 3 ) * E X P ( ( ( D R A T + B B 2 ) * * 2 ) * BB1) )  C  N> *~  THERM3 THERM3 DUM THERM3 DUM THERM3  = = = = = =  ( ( D ( 1 ) * ( ( 1 . 0 / T ) * * 1 0 ) ) + D ( 2 ) ) * (DRAT**1.8) THERM3 * E X P ( ( C ( 1 ) * ( 1 . 0 - ( D R A T * * 2 . 8 ) ) ) ) D ( 3 ) * S * (DRAT**Q) THERM3 + (DUM * E X P ( ( Q / R ) * ( 1 . 0 - ( D R A T * * R ) ) ) ) ( C ( 2 ) * (T**1.5)) + ( C ( 3 ) * ((1.0/DRAT)**5) ) THERM3 + ( D ( 4 ) * EXP(DUM))  C THERMK = THERM1 + THERM2 + THERM3  0 0  C RETURN END SUBROUTINE CPAQU( CP, C1, C2, THETA, A3, A4, W, C C C C C C C C C C C C  X,  THIS ROUTINE CALCULATES THE HEAT CAPACITY OF AN AQUEOUS USING EQUATION 273 FROM HELGESON, KIRKHAM AND FLOWERS, AJS 281, P. 1412 ( 1 9 8 1 ) . RETURNED: CP - CALCULATED HEAT CAPACITY AT T AND P PASSED: C1, C2, A3, A4, THETA, W, X - PARAMETERS IN EQUATION. SEE TEXT FOR D E T A I L S . P - PRESSURE IN MEGA-PASCALS TK  - TEMPERATURE  SPECIES  IN DEG K.  NOTE: UNITS USED ARE JOULES AND MEGA-PASCALS, NOT CALORIES AND BARS AS IN HELG. ET. AL. REAL CP, C1, C2, THETA, A3, A4, W, PR = 0.1E00 CP  = C1 -  X, TK, P, PR  + ( ( C 2 * TK) / (TK - T H E T A ) ) + (W * TK * X) ( ( ( 2 . 0 * A3 * (P - P R ) ) + (A4 * ( P * * 2 - P R * * 2 ) ) ) * THETA * TK / ( ( T K - T H E T A ) * * 3 ) )  RETURN END SUBROUTINE CPMIN(CP,  TK,  A, B, C, D,  E, F,  G)  THIS ROUTINE CALCULATES THE CP OF A PHASE USING THE HEAT CAPACITY FUNCTION: CP = A + BT + C / ( T * * 2 ) + D / ( T * * . 5 ) + E ( T * * 2 ) + F/T + G / ( T * * 3 ) TK - TEMPERATURE IN DEG K CP - RETURNED HEAT CAPACITY ALL OTHER TERMS ARE DEFINED  IN THE ABOVE  CP  = A + (B * TK) + (C / ( T K * * 2 ) ) + (D / + (E * ( T K * * 2 ) ) + (F / TK) + (G / RETURN END SUBROUTINE D I E ( E , T K , D ) ROUTINE  IS THE  (SQRT(TK))) (TK**3))  TO CALCULATE THE D I E L E C T R I C CONSTANT OF WATER AND STEAM. FORMULA AND CONSTANTS FROM UEMATSU AND FRANCK, S T A T I C D I E L E C T R I C CONSTANT OF WATER AND STEAM, J . PHYSICAL CHEMICAL REFERENCE DATA, VOL. 9, NO. 4, 1980. PP 1291.  PROGRAMED 4/2/83 E  EQUATION  CALCULATED  EHP D I E L E C T R I C CONSTANT OF WATER  TK IS THE TEMPERATURE IN DEG. K D IS THE DENSITY OF WATER IN KG/M**3 TO A1 A2 A3 A4 A5 A6 A7 A8 A9 A10  = = = = = = = = = = =  298.15 7.62571E00 2.44003E02 -1.40569E02 2.77841E01 -9.62805E01 4.17909E01 -1.02099E01 -4.52059E01 8.46395E01 -3.58644E01  DENS T  = D / 1000.OEOO = TK / TO  E1  =  A1  * DENS / '  - OUTPUT  VARIABLE  E2 = ( ( A 2 / T ) + A3 + (A4 * T ) ) * (DENS**2) E3 = ( ( A 5 / T ) + ( A 6 * T ) + ( A 7 * ( T * * 2 ) ) ) * (DENS**3) E4 = ( ( A 8 / ( T * * 2 ) ) + ( A 9 / T ) + A10) * (DENS**4) E = 1.0 + E1 + E2 + E3 + E4 RETURN END SUBROUTINE DIE1(TK,D,D1,D2,D3,ETRPR,YTRPR,ZTRPR,E, YTP, ZTP, XTP, OTP) ROUTINE  TO CALCULATE THE VARIOUS DERIVATIVES OF THE D I E L E C T R I C CONSTANT OF WATER AND STEAM AS NEEDED BY THE AQUEOUS S P E C I E S ROUTINES. FORMULA AND CONSTANTS DERIVED THOSE GIVEN BY UEMATSU AND FRANCK IN S T A T I C D I E L E C T R I C CONSTANT OF WATER AND STEAM, J . PHYSICAL CHEMICAL REFERENCE DATA, VOL. 9, NO. 4, 1980. PP 1291. PROGRAMED 4/2/83 EHP DEDT - DERIVATIVE OF THE D I E L E C T R I C CONSTANT WITH RESPECT TO TEMPERATURE AT CONSTANT PRESSURE DEDP - DERIVATIVE OF THE D I E L E C T R I C CONSTANT WITH RESPECT TO PRESSURE AT CONSTANT TEMPERATURE D2EDT - SECOND DERIVATIVE OF THE D I E L E C T R I C CONSTANT WITH RESPECT TO TEMPERATURE AT CONSTANT PRESSURE TK IS THE TEMPERATURE IN DEG. K D IS THE DENSITY OF WATER IN KG/M**3 D1 - D E R I V A T I V E OF THE VOLUME OF WATER WITH RESPECT TO PRESSURE UNITS: M'**3/ MEGA-PASCALS D2 - D E R I V A T I V E OF THE VOLUME OF WATER WITH RESPECT TO TEMPERATURE UNITS: M**3/ DEG K D3 - SECOND DERIVATIVE OF THE VOLUME OF WATER WITH RESPECT TO TEMPERATURE. UNITS: (M**3)**2 / (DEG K ) * * 2 " Q, X, Y, Z - VARIOUS PARAMETERS NEEDED IN THE AQUEOUS S P E C I E S ROUTINE. WHEN TRPR IS APPENDED, REFERS TO 298.15 AND 1 BAR, WHEN TP IS APPENDED, REFERS TO CURRENT CONDITIONS. Q = - D ( 1 / E ) / D P = ( 1 / E ) (DLN E / DP) = ( 1 / E * * 2 ) (DE/DP) Y = - D ( 1 / E ) / D T = ( 1 / E ) (DLN E / DT) = ( 1 / E * * 2 ) (DE/DT) X = ( 1 / E ) ( (D2LN E/DT2) - (DLN E / D T ) * * 2 ) = ( 1 / E ) ( ( - 1 / E ) ( D E / D T ) * * 2 + ( 1/E ) (D2E/DT) - ( ( 1 / E ) ( D E / D T ) ) * * 2 ) TO A1 A2 A3  = 298.15 = 7.62571E00 = 2.44003E02 = -1.40569E02  A4 A5 A6 A7 A8 A9 A10  = = = = = = =  2.77841E01 -9.62805E01 4.17909E01 -1.02099E01 -4.52059E01 8.46395E01 -3.58G44E01  CALL D I E ( E, TK, D) DENS = D / 1000.0 T = TK / TO DDDP = D1 * 1.OE-03 DDDT = D2 * 1.OE-03 DD2DT = D3 * 1.OE-06 E1P = A1 * DDDP / T E1T = (A1 * DDDT / T ) - (A1 * DENS * TO / ( T K * * 2 ) ) E1T2 = ( ( - 1 . 0 ) * DDDT * TO / ( T K * * 2 ) ) + (A1 * DD2DT / T ) - (A1 * DDDT * TO / ( T K * * 2 ) ) + (A1 * DENS * TO * 2.0 / (TK**3)) E2 E2P E2T  = = =  E2T2  =  E3 E3P E3T  = = =  E3T2  ( A 2 / T ) + A3 + (A4 * T ) E2 * 2.0 * DENS * DDDP ( E 2 * 2.0 * DENS * DDDT) + ( ( D E N S * * 2 ) * (A4 (A2 * TO / ( T K * * 2 ) ) ) ) ( E 2 * 2.0 * ((DDDT**2) + (DENS * D D 2 D T ) ) ) + ( 4 . 0 * DENS * DDDT * (A4 - (A2 * TO / ( T K * * 2 ) ) ) ) + ( ( D E N S * * 2 ) * A2 * TO * 2.0 / ( T K * * 3 ) ) + ( 2 . 0 * DENS * DDDT * (A4 - (A2 * TO / ( T K * * 2 ) ) ) )  (A5/T) + (A6*T) + ( A 7 * ( T * * 2 ) ) E3 * 3.0 * (DENS**2) * DDDP E3 * 3.0 * (DENS**2) * DDDT + ( ( D E N S * * 3 ) * (A6 - (A5 * TO / ( T K * * 2 ) ) + (A7 * 2.0 * TK / T O ) ) ) = ( E 3 * 3.0 * ( ( ( D E N S * * 2 ) * DD2DT) + ((DDDT**2) * 2.0 * D E N S ) ) ) + ( 6 . 0 * (DENS**2) * DDDT * (A6 (A5 * TO / ( T K * * 2 ) ) + (A7 * 2.0 * TK / T O ) ) ) + ( ( D E N S * * 3 ) * ( ( A 7 * 2.0 / TO) + (A5 * TO / T K * * 3 ) ) )  E4 E4P E4T  = = =  E4T2  =  ( A 8 / ( T * * 2 ) ) + ( A 9 / T ) + A10 E4 * 4.0 * (DENS**3) * DDDP E4 * 4.0 * (DENS**3) * DDDT + ( ( D E N S * * 4 ) * ( ( A 8 * (-2.0) * ( T 0 * * 2 ) / ( T K * * 3 ) ) - A9 * TO / ( T K * * 2 ) ) ) (E4 * 4.0 * ((DD2DT * ( D E N S * * 3 ) ) + ( 3 . 0 * (DENS**2) * ( D D D T * * 2 ) ) ) )  +  ( ( 8 . 0 * (DENS**3) * DDDT) * ( ( A 8 * (-2.0) * ( T 0 * * 2 ) / ( T K * * 3 ) ) - (A9 * TO / ( T K * * 2 ) ) ) ) + ( ( D E N S * * 4 ) * ( ( A 8 * 6.0 * ( T 0 * * 2 ) / ( T K * * 4 ) ) + (A9 * TO * 2.0 / ( T K * * 3 ) ) ) ) DEDP = E1P + E2P + E3P + E4P DEDT = E1T + E2T + E3T + E4T DE2DT2 = E1T2 + E2T2 + E3T2 + E4T2 ETRPR ZTRPR YTRPR  = 78.97765 = (-1.0) / ETRPR = -5.8017E-05  OTP YTP ZTP XTP  DEDP / ( E * * 2 ) DEDT / ( E * * 2 ) (-1.OEOO) / E ( ( ( - 1 . 0 / E * * 2 ) * (DEDT**2) ) + ( ( 1 . 0 / E ) * DE2DT2) ( ( ( 1 . 0 / E ) * (DEDT))**2) ) * (1.0/E)  = = = =  RETURN END SUBROUTINE D I S T ( T , P, STRENG, IBAL, I S A T ) THIS ROUTINE  TOTAL, C, ACT, XHOLD,  -  VOL,  CALCULATES THE DISTRIBUTION OF S P E C I E S ACCORDING TO THE ALGORTHIUM OF WOOLERY AND WALTERS  COMMON COMMON COMMON COMMON COMMON  /CHEMPH/ /CHEMAQ/ /CHEMSS/ /CHEMG / /NEWCOM/  COMPPH(10,25), T H E R P H ( 1 4 , 2 5 ) , NUMPH COMPAQ(10,25), THERAQ(13,25), NUMAQ COMPSS(10,20). T H E R S S ( 8 , 2 0 ) , NUMSS COMPG(10,10), THERG(6,10), NUMG CNEWAQ(10,25), CNEWPH(10,25), CNEWSS(10,20), CNEWG(10,10), I N D X 1 ( 1 0 ) , I N D X 2 ( 1 0 ) , I N D X 3 ( 1 0 ) , NUMELE CHARACTER*20 PHNAME(25), SSNAME(20), GNAME(10), DNAME(3) CHARACTER *8 FLNAME(10), AQNAME(25) C H A R A C T E R S ELNAME( 10) COMMON /CHNAME/ PHNAME, SSNAME, GNAME, DNAME, AQNAME, FLNAME, ELNAME TOTAL G ACT CONCAQ COLDAQ C  -  TOTAL NUMBER OF MOLES/MOLALITY OF COMPONENTS LOG K OF THE S P E C I E S LOG A C T I V I T Y OF THE COMPONENTS LOG MOLALITY OF THE AQUEOUS S P E C I E S LOG MOLALITY OF THE AQUEOUS S P E C I E S OF THE LAST ITERATION CONCENTRATION OF THE COMPONENTS. IF WATER IS A COMPONENT, THEN STORE THE A C T I V I T Y OF WATER  CSAV GAMMAQ GAMMC REAL REAL REAL  - CONCENTRATION OF THE COMPONENTS FROM THE LAST - A C T I V I T Y COEF FOR THE AQUEOUS SPECIES - A C T I V I T Y COEF. FOR THE COMPONENTS  ITERATION  C0NCAQ(25), C 0 L D A Q ( 2 5 ) , GAMMAQ(25), GCOMP(10) A C T ( 1 0 ) , GAMMC(10), C S A V ( 1 0 ) , XHOLD(10), C ( 1 0 ) G(25) , TOTAL(10)  ZERO = 1.0E-09 ZERO = 1.OE-07 A10 = ALOG(10.O) CALL MINIT(CSAV, .OEOO) 10, CALL MINIT(GAMMC, .OEOO) 10, CALL MINIT(GAMMAQ, 25, .OEOO) CALL MINIT(CONCAQ, 25, OEOO) CALL MINIT(COLDAQ, 25, OEOO) CALCULATE/SETUP ACTIVITY COEFFIECIENTS CALL H20(P, T, VOL, X1, HTP, STP, G ( 1 ) , X2, X3, X4, X5, 0 ) DENS = 1 . 0 / VOL GAMMAQ(1) = A L 0 G 1 0 ( 0 . 0 1 8 0 1 5 3 4 ) C0NCAQ(1) = ALOG10(1.0 / 0.01801534) C0LDAQ(1) = C0NCAQ(1) CALL D I E 1 ( T , DENS, X4, X3, X5, ETRPR, YTRPR, ZTRPR , E, YTP , ZTP, X, Q) IF (STRENG.GT.O.O) THEN DO 20 I = 2, NUMAQ CALL GAMMA(COEF, T.P,DENS,STRENG,THERAQ(12,1), THERAQ(13,1),THERAQ( 1 1 , 1 ) ) GAMMAQ(I) = COEF CONTINUE ENDIF GET A C T I V I T Y / A C T I V I T Y COEF. DO 80 I = 1, NUMELE K2 = I N D X 2 ( I ) IF (K2.EQ.1) THEN  OF THE COMPONENTS  SOLID  PHASES  ACT(I) = O.OEOO GAMMC(I) = O.OEOO ELSE  AQ SPECIES IF (K2.EQ.2) THEN K1 = I N D X K I ) K3 = I N D X 3 ( I ) GAMMC(I ) = GAMMAQ(K1) IF (K3.EQ.1) A C T ( I ) = A L 0 G 1 O ( C ( I ) ) + GAMMC(I)  IF  (K3.EQ.2)  ACT(I) = C(I) SOLID  ELSE  GASSES IF (K2.EQ.4) THEN ACT(I) = C(I) GAMMC(I) = O.OEOO ENDIF CONTINUE FIND ION AMONG COMPONENTS FOR CHARGE BALANCE IF ( I B A L . L E . O ) THEN COEF = O.OEOO = 0 DO 90 I = 1, NUMELE K2 = I N D X 2 ( I ) IF (K2.NE.2) GO TO 90 K1 = I N D X K I ) IF (THERAQ(12,K1).NE.0.0) THEN K3 = I N D X 3 ( I ) IF (d.EQ.1.AND.K3.EQ.2) GO TO 90 IF ( C O E F . G E . A B S ( C ( I ) ) . A N D . J . E Q . 1 ) GO TO 90 IF (K3.EQ.1) J = 1 IBAL = I COEF = A B S ( C ( I ) ) ENDIF CONTINUE ENDIF GET LOG K'S FOR EACH OF THE S P E C I E S . FIRST WATER, WHICH IS ALWAYS SPECIES NUMBER 1. DO 100 1 = 2 , NUMAO CALL GAQU(XLOGK,GM,THERA0(2,I),THERA0(3 I ) , T H E R A 0 ( 4 , I ) , T H E R A Q ( 5 , I ) , T H E R A O ( 1 0 , I ) , T H E R A Q ( 6 , I ) THERAQ(7, I ) , ZTP, THERAQ(8,I),THERAQ(9,I),THERAQ(11,1) ZTRPR, YTRPR, T) G ( I ) = XLOGK CONTINUE GET LOG K'S FOR EACH OF THE COMPONENTS AND PREPARE TO CHANGE B A S I S DO 150 1 = 1 , NUMELE K1 = I N D X 1 ( I ) K2 = I N D X 2 ( I ) IF (K2.EQ.1) THEN SOLID PHASE COMPONENTS CALL GMIN(XLOGK, GM, THERPH(2,K1), THERPH(3,K 1 ) , THERPH(5,K1), THERPH(6,K1), T H E R P H ( 7 , K 1 ) , ELSE  80  4N  90  95  100  SOLUTION  IF ( K 2 . EO .3) THEN ACT(I) O.OEOO GAMMC(I ) O.OEOO  THERPH(8,K1), THERPH(9,K1), THERPH(10,K1), THERPH(11,K1), THERPH(4 , K1 ) , THERPH(12, K 1 ) , THERPH(13,K 1 ) , T. P) GCOMP(I) = XLOGK ELSE I F (K2.EQ.2) THEN AQUEOUS SPECIES COMPONENTS GCOMP(I ) = G ( K 1 ) ELSE I F (K2.EQ.3) THEN SOLID SOLUTION COMPONENTS ELSE IF (K2.EQ.4) THEN GAS COMPONENTS ENDIF CONTINUE NOTE THAT XHOLD IS USED ONLY AS A DUMMY CALL BASIS(XHOLD.O)  ARGUEMENT  SUBTRACT OUT LOG K OF COMPONENTS FROM EACH S P E C I E S DO 220 1 = 1 . NUMAQ DO 2 1 0 d = 1, NUMELE IF (ABS(CNEWAQ(U,I)).GE.ZERO) G ( I ) = G ( I ) - (CNEWAQ(u,I) * GCOMP(d)) CONTINUE CONTINUE MONOTONE SEQUENCE CONVERGENCE OF W AND W L00P2 = 1 L00P1 = 1 DO 330 1 = 1 , NUMELE K2 = I N D X 2 ( I ) IF (K2.NE.2) GO TO 330 K3 = I N D X 3 ( I ) IF (K3.NE.1) GO TO 330 ATEMP = 1.0 K1 = I N D X 1 ( I ) DO 320 J = 1, NUMAQ I F ( K 1 . E Q . d ) GO TO 320 IF(ABS(CNEWAQ(I ,<J)) .LT.ZERO) GO TO 320 BTEMP = (CNEWAQ(I.J) - 1.0) * A C T ( I ) BTEMP = BTEMP + GAMMC(I) BTEMP = BTEMP + G ( U ) - GAMMAQ(d) DO 310 K = 1, NUMELE I F ( K . E Q . I ) GO TO 310 IF(ABS(CNEWAQ(K, J ) ).LT.ZERO) GO TO 310 BTEMP = BTEMP + (CNEWAQ(K.J) * A C T ( K ) )  310 320  330  CONTINUE ATEMP = ATEMP + (CNEWAQ(I.d) * ( 1 0 . 0 * * B T E M P ) ) CONTINUE C ( I ) = T O T A L ( I ) / ATEMP IF ( C ( I ) . L E . 0 . 0 ) THEN WRITE(6,1008) AQNAME(K1) STOP ENDIF CONTINUE CHECK  ro  Ln  340  390  I F CONVERGENCE HAS BEEN OBTAINED  K = 0 d = 0 DO 340 1 = 1 , NUMELE K2 = I N D X 2 ( I ) IF (K2.NE.2) GO TO 340 K3 = I N D X 3 ( I ) IF. (K3.NE.1 ) GO TO 340 K = K + 1 ATEMP = A B S ( ( C S A V ( I ) - C ( I ) ) / C ( I ) ) IF (ATEMP.LT.ZERO) d = d + 1 CSAV(I) = C ( I ) A C T ( I ) = GAMMC(I) + A L 0 G 1 0 ( C ( I ) ) CONTINUE L00P1 = L00P1 + 1 IF (K.NE.d .AND. L00P1.LT.5O) GO TO 300 L00P1 = 1 CONCENTRATIONS OF SPECIES/NEW IONIC STRENGTH AND  ELECTRICAL BALANCE  STRENG =0.0 ELECT = 0.0 BTEMP = 0.0 CONCAQ(I) = AL0G1O( 1.0 / 0.01801534 ) DO 4 0 0 1 = 2 , NUMAQ ATEMP = G ( I ) NUMELE DO 390 d = 1 (CNEWAQ(d,I) A C T ( d ) ) + ATEMP ATEMP CONTINUE CONCAQ(I) = ATEMP - GAMMAQ(I) IF ( C O N C A Q ( I ) . L T . - 6 5 . 0 ) X1 = 0.0 IF ( C O N C A Q ( I ) . G E . - 6 5 . 0 ) X1 = 10**C0NCAQ(I) STRENG = STRENG + ( ( T H E R A Q ( 1 2 , I ) * * 2 ) * X1 * 0.5) ELECT = ELECT + (THERAQ(12,1) * X1 ) BTEMP = BTEMP + X1  CONTINUE IF (BTEMP .GT. IF (STRENG .GT.  10.0) BTEMP 10.0) STRENG  UPDATE A C T I V I T Y  COEFFI ECIENTS  = 10.0 = 10.0 - WATER ALWAYS IS POSITION 1  GAMMAQO) = ( ( - 1 . 0 ) * BTEMP * 0.01801534 / A10) - CONCAQC 1 ) DO 510 I = 2, NUMAO CALL GAMMA(COEF,T,P,DENS,STRENG,THERAO(12.1), THERAO(13,I),THERAQ(11,1)) GAMMAQ(I ) = COEF CONTINUE DO 520 1 = 1 , NUMELE K2 = I N D X 2 ( I ) IF (K2.EQ.2) THEN K1 = INDX1(1) GAMMC(I) = GAMMAQ(K1) ENDIF CONTINUE CHARGE BALANCE K1 = INDX1(IBAL ) T O T A L ( I B A L ) = T O T A L ( I B A L ) - ( E L E C T / THERAQ(12,K1 ) ) CHECK FOR CONVERGENCE K = 0 J = 0 DD 600 1 = 2 , NUMAO IF ( C O N C A Q ( I ) . L T . - 6 5 . 0 ) GO TO 600 X1 = 1O**C0NCAQ(I) X2 = 10**COLDAQ(I) ATEMP = A B S ( ( X 1 - X2) / X1) J = J + 1 IF (ATEMP.LT.ZERO) K = K + 1 C O L D A Q ( I ) = CONCAQ(I) CONTINUE L00P2 = L00P2 + 1 IF ( K . N E . J .AND. LOOP2.LT.50) GO TO 300 IF WATER IS A COMPONENT, SENT BACK A C T I V I T Y DO 610 K1 K2 IF  I = 1, NUMELE = INDXKI) = INDX2(I) (K1.EQ.1 .AND. K2 .EQ. 2) THEN INDX3(I) = 2 C ( I ) = C O N C A Q O ) + GAMMAQO) ENDIF  IN C  ARRAY  610 C C  CONTINUE OUTPUT WRITE(6,1001) DO 700 1 = 1 , NUMAO X1 = 0.0 IF ( C O N C A 0 ( I ) . G T . - 6 5 . 0 . A N D . C 0 N C A 0 ( I ) . L T . 2 . 0 ) X1 = 10**CONCAQ(I) X4 = 10.0**(GAMMAQ(I)) X3 = CONCAO(I) + GAMMAQ(I) X2 = 0.0 IF (X3.GT.-65.0.AND.X3.LT.2.0) X2 = 10 ** X3 X5 = X1 * THERAO(1,1)  C WRITE(6,1002) AQNAME(I), X1, CONCAQ(I), X2, X3, X4, GAMMAQ(I),  700  N> c£  C c C C C C C  810  X5 CONTINUE WRITE(6,1003) STRENG, ELECT I = INDX1(IBAL) WRITE( 6,1004) AQNAME(I) WRITE(10,1009) ( C O N C A Q ( I ) , 1 = 1 . NUMAQ), (GAMMAQ(K), K = 1, NUMAQ) CALCULATE VOLUME OF SYSTEM BASED ON 1000 GRAMS OF WATER VOL CONTAINS VOLUME OF FLUID (WATER) IN (M**3/KG) * 1KG(H20) VOL = VOL CALCULATE FREE ENERGY OF GASES AND OUTPUT FUGACITY IF (NUMG. GT. 0 ) THEN ENDIF CHECK/OUTPUT SUPERSATURATION OF SOLIDS ISAT = 0 IF (NUMPH .GE. 1) THEN WRITE(6,1005) DO 820 1 = 1 , NUMPH CALL GMIN(XLOGK, GM, T H E R P H ( 2 , I ) , T H E R P H ( 3 , I ) , THERPH(5,I), THERPH(6,I), THERPH(7,I), THERPH(8,I), THERPH(9,I), THERPH(10,1), THERPH(11,1), T H E R P H ( 4 , I ) , THERPH(12,1), T H E R P H ( 1 3 , I ) , T, P) X1 = O.OEOO X2 = O.OEOO DO 810 J = 1, NUMELE XLOGK = XLOGK - (CNEWPH(J.I) * G C O M P ( J ) ) X2 = X2 - (CNEWPH(d.I) * A C T ( d ) ) CONTINUE X1 = XLOGK - X2  IF  (X1 .GT. 1.0) THEN WRITE(6,1006) PHNAME(I), ISAT = ISAT + 1 ELSE WRITE(6,1007) PHNAME(I), ENDIF  X1, XLOGK, X2  X1, XLOGK, X2  CONTINUE ENDIF CHECK FOR SOLID SOLUTION PHASES MUST GO HERE ? ? ? ? ? RETURN IN ACT - SUM OF EACH OF THE GLOBAL COMPONENTS IN THE F L U I D RETURN IN XHOLD - SUM OF EACH OF THE GLOBAL COMPONENTS IN THE SOLIDS RETURN IN TOTAL - SUM OF EACH OF THE LOCAL COMPONENTS IN THE F L U I D NOTE THAT ALL VALUES HERE ARE FOR 1000 GRAMS OF WATER THEY WILL BE CORRECTED BY THE NUMBER OF MOLES OF WATER IN THE CALLING ROUTINE DO 940 1 = 1 , NUMELE T O T A L ( I ) = O.OEOO ACT(I) = O.OEOO X H O L D ( I ) = O.OEOO DO 910 J = 1, NUMAQ IF ( C O N C A Q ( J ) . G T . - 6 5 . 0 ) THEN X1 = 10**CONCAQ(d) A C T ( I ) = A C T ( I ) + (X1 * C O M P A Q ( I , d ) ) T O T A L ( I ) = T O T A L ( I ) + (X1 * CNEWAQ(I,d)) ENDIF CONTINUE CONTINUE IF (NUMPH.GT.O) THEN DO 980 1 = 1 , NUMELE K2 = I N D X 2 ( I ) IF (K2.EQ.1) THEN K1 = INDX1(1) DO 970 d = 1, NUMELE IF ( A B S ( C 0 M P P H ( d , K 1 ) ) . G T . Z E R O ) XHOLD(d) = X H O L D ( I ) + (C0MPPH(d,K1) * C ( I ) ) CONTINUE ENDIF CONTINUE ENDIF RETURN FORMAT('0 SPECIES MOLALITY LOG MOL. ACTIVITY ,'LOG ACT. A C T I V I T Y COEF LOG ACT COEF GRAMS/LITER') FORMAT(1X,A8,2X,E12.5,2X,F10.5,2X,E12.5,2X,F10.5,2X,F10.5,4X, F10.5,2X,E12.5) FORMAT('O IONIC STRENGTH: '.F10.5,/, ELECTRICAL BALANCE: '.E12.5)  1004 1005 1006 1007 1008 1009  FORMAT('0 ION/COMPONENT USED FOR E L E C T R I C A L BALANCE: ',A8) FORMAT(//,5X,'PHASE',21X,'LOG A C T I V I T Y ' , 9 X , ' L O G K',10X,'L0G 0') FORMAT(1X.A20,10X,E12.5,5X,F10.4,5X,F10.4, / * * * * * * * * * * * SUPERSATURATED ') FORMAT(1X.A20,10X,E12.5,5X,F10.4,5X,F10.4) FORMATC//,' ION DRIVEN NEGATIVE DURING D I S T I B U T I O N OF S P E C I E S ' , / , ' EXAMINE INPUT DATA - ION/COMPONENT WAS: ',A8) FORMAT(10(1X,E12.5)) END SUBROUTINE SMIN(STP, SZERO, A, B, C, D, E, F, G, DVDT, T, P) THIS ROUTINE CALCULATES THE ENTROPY OF A PHASE PASSED VARIABLES:  RETURNED  SZERO - ENTROPY AT TR, PR A, B, C, D, E, F, G - HEAT CAPACITY TERMS DVDT - DV/DT AT CONSTANT P T - TEMPERATURE IN DEG K P - PRESSURE IN MEGA-PASCALS VARIABLE: STP - ENTROPY AT T AND P  INTERNAL VARIABLES: TR - 298.15 DEG K (REFERENCE PR - 0.1 MEGA-PASCALS O  CP AND  VOLUME EQUATION USED  ( I N INTEGRATED  TEMPERATURE)  FORMS)  CP = A + BT + C / ( T * * 2 ) + D / ( T * * . 5 ) + E ( T * * 2 ) + F/T + G / ( T * * 3 ) VTP TR PR STP  STP  = VO + ( ( D V / D T ) * (T - T O ) ) + ( ( D V / D P ) * (P - P O ) ) 298.15E00 0.1E00 = SZERO + + + + + + + = STP -  RETURN END SUBROUTINE  (A * ( A L O G ( ( T / T R ) ) ) ) (B * (T - T R ) ) (C * ( ( 1 . 0 / ( T R * * 2 ) ) - ( 1 . 0 / ( T * * 2 ) ) ) / 2.0) (D * ( ( 1 . 0 / ( S Q R T ( T R ) ) ) - ( 1 . 0 / ( S Q R T ( T ) )) ) * 2.0) (E * ( T * * 2 - TR**2) / 2.OEOO) (F * ( ( 1 . O / T R ) - ( 1 . 0 / T ) ) ) (G * ( ( 1 . 0 / ( T R * * 3 ) ) - ( 1 . 0 / ( T * * 3 ) ) ) / 3.0) (DVDT * (P - P R ) )  STEAM (P,THETA,V,H,U,S,CP,CV,Td,F,L,NEQ,DPTV,DPRT, DPVT) L=1 I N I T , L=2 GIVEN P VAP SIDE, L=3 GIVEN P LIQ SIDE L=4 GIVEN V NECESSARY SUBROUTINES WFNS,GRST,PDSUM  C UNITS P IN MPA, THETA IN DEGC IPTS68 C UNITS V IN CC/GM H,U,F IN d/G, C S.CP.CV IN J/G/DEG K, T J IN MPA/DEG K DOUBLE PRECISION W(5,5),RHO,TAU,P,THETA,V,H,U,S,CP,CV,TJ,F DOUBLE PRECISION DHVT, DPTV, DPVT, FZERO, HZERO, CPZERO, DPRT DOUBLE PRECISION SZERO.TEMP, TA, PCALC, H Z C ( 8 ) , THETA1 DOUBLE PRECISION DLOG, RH1, DRHO, DABS, CPFUNC, HZFUNC V = 1.0 DPVT = 1.0 GO TO ( 1 , 1 2 , 1 2 , 1 2 , 1 2 ) , L 12 CONTINUE NE0=O TEMP=273.15+THETA RT=R*TEMP TAU=1000./TEMP TA=DLOG(TEMP) SZERO= . 0 0 1 * ( H Z C ( 2 ) + 2 . * H Z C ( 3 ) / T A U + 3 . * H Z C ( 4 ) / T A U * * 2 + 4 . * H Z C ( 5 ) * /TAU**3 + 5. *HZC(6)/TAU**4 + H Z C ( 8 ) * T A + H Z C ( 8 ) ) + H Z C ( 7 ) / T E M P FZERO= HZC(1)+HZC(2)/TAU+HZC(3)/TAU**2+HZC(4)/TAU**3+HZC(5) * /TAU**4 + H Z C ( 7 ) * T A + H Z C ( 8 ) * T A / T A U + H Z C ( 6 ) / TAU**5 HZERO= HZFUNC(TEMP,HZC,RCONV) CPZERO= CPFUNC(TEMP,HZC,RCONV) GO TO ( 1 , 2 , 3 , 4 ) ,L 1 CONTINUE R = 0.46151 H Z C C D = 1857.065 H Z C ( 2 ) = 3229.12 H Z C ( 3 ) = -419.465 H Z C ( 4 ) = 36.6649 H Z C ( 5 ) = -20.5516 • H Z C ( 6 ) = 4.85233 H Z C ( 7 ) = 46. H Z C ( 8 ) = -1011.249 C READ(17,101) R RCONV= R C READ(17,101) ( H Z C ( I ) , 1 = 1 , 8 ) CALL WFNS (RHO,TAU,W,1) RETURN 2 RHO=P/RT DRHO=RHO*.1 25 JUMP=0 RMAX=.1 CALL WFNS (RHO,TAU,W,2) PCALC=RHO*RT*(1.+W(1,1)+W(2,1)) 20 PC1=PCALC JUMP=JUMP+1  32 31  27 26 22 33 3  60 4 C  C  IF (UUMP-10) 31,31,32 RMAX=RMAX*.5 CONTINUE RH1=RHO RHO=RH1+DRHO CALL WFNS (RHO,TAU,W,2) PCALC = RHO*RT*(1.+W(1,1)+W(2,1 ) ) DRHO=(P-PCALC)/(PC1-PCALC)*(RH1-RHO) IF (DABS(DRHO)-RMAX) 26,26,27 DRHO=RMAX*DRHO/DABS(DRHO) IF ( J U M P - 2 0 ) 2 2 , 4 2 , 4 2 IF (DABS(DRHO)-.1E-6*RH0) 60,60,33 I F ( D A B S ( P - P C A L C ) - 1 .E-5*P) 60,60.20 V=.97+.032*(.01*THETA)**2 RH0=1./V DRH0=1./(V+.01+.005*(.01*THETA)**2) -RHO GO TO 25 V=1./RH0 RH0=1./V CALL WFNS (RHO,TAU,W,3) IF (RHO .LT. 0.0) WRITE(6,43) P,THETA,RHO,DRHO,L IF (RHO .LT. 0.0) RETURN F=FZERO+ RT*(DLOG(RHO)+W(1,1) ) P=RHO*RT*(1.+W(1,1)+W(2,1)) H=HZERO+ RT*( W(1,1)+W(2,1)+W(1,2)) U=H-P*V S=SZERO+ R*(W(1,1)-W(1,2)+DLOG(RHO)) S = -S DHVT = DH/DV AT CONSTANT T, SIMILARLY FOR DPTV AND DPVT DHTV = CPZERO+ R*(W(1, 1)+W(2,1)-W(1,2)-W(2,2)-W(1,3 ) ) DHVT = RHO*RT*(W(1,1) + 3.*W(2, 1)+W(3, 1)+W(1,2)+W(2,2) ) DPTV=RHO*R*( 1 .+W(1,1)+W(2, 1 ) - W ( 1 , 2 ) - W ( 2 , 2 ) ) DPVT = -RH0**2*RT*( 1.+2.*W(1,1)+4.*W(2,1)+W(3,1)) CV=DHTVDPTV/RHO CP=DHTV-DHVT*DPTV/DPVT Td=1./(DPTV-DPVT*DHTV/DHVT) DPRT= 1 , O / ( - ( R H 0 * * 2 ) ) * DPVT  C I F ( ( C P / C V * D P R T ) .LT. 0.0) RETURN 42 CONTINUE NE0=1 GO TO 60 101 F0RMAT(8F1O.0) 50 FORMAT (2D20.6 ) 155 FORMAT('0', 'B,C: ',2F15.4)  RETURN  SUBROUTINE CVMIN(CV, TK, A, B, C, D, E, F, G, DVDT, DVDP) THIS ROUTINE CALCULATES THE CV OF A PHASE USING THE HEAT CAPACITY (AT CONSTANT P) FUNCTION AND THE FOLLOWING THERMODYNAMIC RELATIONSHIP CP = A + BT + C / ( T * * 2 ) + D / ( T * * . 5 ) + E ( T * * 2 ) CV = CP + ( ( D V / D T ) * * 2 * TK / (DV/DP) TK - TEMPERATURE IN DEG K CV - RETURNED HEAT CAPACITY DV/DT - DERIVATIVE DF VOLUME WRT TEMPERATURE DV/DP - DERIVATIVE OF VOLUME WRT PRESSURE AT ALL OTHER CP TERMS ARE DEFINED IN THE ABOVE  + F/T + G / ( T * * 3 )  AT CONSTANT P CONSTANT T EQUATION  CALL CPMIN(CP, TK, A, B, C, D, E, F, G) CV = CP + ( ( D V D T * * 2 ) * TK / DVDP) RETURN END SUBROUTINE DER(GRAND, DERIV, NDIR, IDIM, JDIM) THIS ROUTINE SETS UP THE RIGHT HAND SIDE FOR THE DERIVATIVE AND SOLVES IT COMMON BLOCKS PREVIOUSLY DEFINED COMMON COMMON COMMON COMMON COMMON  1'ST  /CHEMPH/ /CHEMAQ/ /CHEMSS/ /CHEMG / /NEWCOM/  COMPPH(10,25), T H E R P H ( 1 4 , 2 5 ) , NUMPH COMPAQ(10,25), T H E R A Q ( 1 3 , 2 5 ) , NUMAQ COMPSS(10,20), T H E R S S ( 8 , 2 0 ) , NUMSS COMPG(10,10), THERG(6,10), NUMG CNEWAQ(10,25), CNEWPH(10,25), CNEWSS(10,20), CNEWG(10,10), I N D X 1 ( 1 0 ) , I N D X 2 ( 1 0 ) , I N D X 3 ( 1 0 ) , NUMELE COMMON /PATH/ C ( 2 5 ) , C M 0 L E ( 1 0 ) , XMN0W(1O), XMFUT(10), REAMT(5) , TKNOW, TKFUT, TAUNOW, TAUFUT, PNOW, PFUT, EMAX, STRONG, AMWAT, DTAU, DTK, DPRES, I P 0 I N T ( 2 5 ) , INDREA(5) , NUM, IPRINT, NUMREC REAL GRAND(IDIM, IDIM), D E R I V ( I D I M , J D I M ) , RHS(40) R = 8.3143 A10 = AL0G(10.OEOO) ZERO = 1.OE-05 NDIR = 0 CALL M I N I T ( D E R I V , I D I M , JDIM, O.OEOO) GET WATER PROPERTIES CALL H20 (PNOW, TKNOW, VOLWAT, GWAT, HWAT, SWAT, XKWAT, CVWAT, DVDTW, DVDPW, DV2DT2, 0 )  C C C C C C C  ADD  IN CHANGE IN THE NUMBER OF MOLES OF EACH COMPONENT (NOTE THAT THIS WILL INCLUDE RADIO-ACTIVE DECAY) AND INCLUDE THE CHANGE IN THE NUMBER OF MOLES OF EACH REACTANT  SPEED IS THE RATE OF EACH REACTION  40 50 C C ,o O  SPEED = 1.OEOO DO 50 I = 1, NUMELE R H S ( I ) = DXM(I) IF (NUMREC .GT. O) THEN DO 4 0 J = 1, NUMREC K = INDREA(J) IF (ABS(CNEWPH(I,K)) .GT. ZERO) R H S ( I ) = R H S ( I ) - (CNEWPH(I.K) * SPEED) CONTINUE ENDIF CONTINUE ACTIVITY OF WATER AND IONIC STRENGTH -- S AND V OF FLUID HAVE BEEN APPROXIMATED BY THE S AND THE V OF PURE WATER. IONIC = NUMELE + 1 IAWAT = NUMELE + 2  C  C C  RHS(IONIC) = O.OEOO RHS(IAWAT) = VOLWAT * DTK / (R * TKNOW * AMWAT) RHS(IAWAT) = RHS(IAWAT) - (SWAT * DPRES / (R * TKNOW * AMWAT)) DO 150 J = 1, NUMAQ IF ( I P O I N T ( J ) .GT. 0 ) THEN K = I P O I N T ( J ) + IAWAT DH = 0.0 DV = 0.0 DO 140 1 = 1 , NUMELE GET V AND SUM > DELTA V GET H AND SUM > DELTA H 140 CONTINUE RHS(K) = DH * DTK / (R * TKNOW * TKNOW) RHS(K) = RHS(K) - (DV * DPRES / (R * TKNOW))  C C 150 C C  DON'T FORGET A C T I V I T Y ENDIF CONTINUE  TERMS  NOW SOLVE FOR THE FIRST DERIVATIVE CALL MMULT(DERIV, GRAND, RHS, K, K, 1, IDIM, JDIM, IDIM, IDIM, 40, 1) NDIR = 1  C C C C C C C C C C C C C C C C C C C C C C C C C C C C  RETURN END SUBROUTINE GAMDI1( DGDI1, TK, P, D, STRENG, Z, AZERO, W) THIS ROUTINE CALCULATES THE DERIVATIVE OF THE A C T I V I T Y C O E F I C I E N T S OF AQUEOUS S P E C I E S TAKEN WITH RESPECT TO THE IONIC STRENGTH. HELGESON ET AL'S MODEL IS USED FOR A C T I V I T Y COEF. DGDI1  IS RETURNED  AND CONTAINS THE THE FIRST DERIVATIVE OF THE LOG OF THE A C T I V I T Y C O E F I C I E N T OF THE S P E C I E S TAKEN WITH RESPECT TO THE IONIC STRENGTH  THE FOLLOWING VARIABLES ARE PASSED AZERO - ELECTROSTATIC RADIUS ( I N ANGSTROMS) D - DENSITY OF PURE WATER (M**3/KG) STRENG- IONIC STRENGTH OF THE SOLUTION P TK W  - PRESSURE IN MPA - TEMPERATURE IN DEG K - CONVENTIONAL BORN PARAMETER  Z  -  CHARGE  ON THE ION - IF 0 OR GREATER THEN 10, AN A C T I V I T Y COEF. OF 1 IS USED.  LOCAL VARIABLES DENS - DENSITY OF PURE WATER (CM**3/G) W1 - ABSOLUTE BORN PARAMETER ( 0 . 5 3 8 7 E 0 5 IS THE ABSOLUTE BORN PARAMETER FOR HYDROGEN ION (HAL, PAGE 1304) DIELE - D I E L E C T R I C CONSTANT OF WATER SHORT - SHORT RANGE INTERACTION PARAMETER FOR NACL (KG/MOLE) SOLVE - SOLVATION PARAMETER FOR NACL (KG/MOLE) DGDI1 = 0 . 0 IF ( A B S ( Z ) . G T . 1 0 . 0 . 0 R . A B S ( Z ) . L T . 1 ) RETURN  C CALL NACL(SOLVE,SHORT,P,TK,DSOLDP,DSOLDT,DSHODP,DSHODT) CALL D I E ( D I E L E , T K , D ) W1 = W + (Z * 0.5387E05 * 4.184) DENS = D / 1000.0 A = 1.824829238E06 * SQRT(DENS) / ( ( D I E L E * T K ) * * 1 . 5 ) A = (-1.0) * A * ( Z * * 2 ) B = 50.29158649E08 * SQRT(DENS) / ( S Q R T ( D I E L E * T K ) ) B = AZERO * 1.OE-08 * B C DGDI1 DGDI1 C  = A / (2.OEOO * SQRT(STRENG) ) = DGDI1 / ( 1 . 0 E 0 0 + (B * S Q R T ( S T R E N G ) ) )  DGDI1  =  DGDI1  +  (  (A  *  B)  /  (2.OEOO (B  T  =  (-0.0180153EOO)  /  C  =  ((W1  +  SHORT  +  C  *  SOLVE)  ( 1 . 0  + -  *  *  SORT(STRENG)  *  (O.OEOO  +  SORT(STRENG)))**2) ) )  (0.0180153EOO ( 0 . 1 9  *  *  ( A B S ( Z )  STRENG)) -  1 . 0 ) ) )  C DGDI1  =  DGDI1  +  T  RETURN END SUBROUTINE  GAQU(XLOGK, A3,  C  THIS  ROUTINE  G.  A4,  CALCULATES  C  OF  C  HELGESON,  H. W,  THE  FORMATION  S,  C1.  ZPT,  C2.  THETA,  A1,  ZPRTR,  YPRTR,  P,  GIBBS  FOR  AN  KIRKHAM  FREE  ENERGY  AQUEOUS  AND  AND  SPECIES  FLOWERS  A2, T) THE  LOG  K  USING  (1981)  EQUATIONS  C C  RETURNED  C  XLOGK  -  V A R I A B L E S ^  C  G  GIBBS  C  PASSED  LOG  K  OF  FORMATION  C £J ON  -  C  A1,  A2,  C  C1,  C2  FREE  ENERGY  OF  FORMATION  VARIABLES A3,  A4  -  -  TERMS  -  TERM  TERMS  VOLUME  EXPANSION  THE  HEAT  CAPACITY  EXPANSION  BOTH  HEAT  AND  IN  IN  THE  C C  THETA  C  H  IN  VOLUME  EXPANSION  ENTHALPHY  C  S  -  C  DENS  -  C  W  C  YTRPR  ENTROPY DENSITY  OF  WATER  CONVENTIONAL -  DERIVATIVE  C  BORN OF  PARAMETER  THE  TEMPERATURE  AT  TEMPERATURE  (DEG  LN  OF  CONSTANT  THE  DIELECTRIC  PRESSURE  -  CONSTANT  EVALUATED  AT  C C C C  T P  -  PRESSURE  TR,  PR  -  K)  (MPA)  REFERENCE  TEMPERATURE  (DEG  K)  AND  PRESSURE  C C  R  -  A10  =  ALOG(IO.O)  TR  =  298.  PR  GAS  CONSTANT  (J  K**-1  M0LE**-1)  15  = 0 . 1 E 0 0  R  =  8.3143  C TH1  =  T  -  THETA  THO  =  TR  -  THETA  *  G  =  H  -  (T  G  =  G  +  (C1  *  S) (T  -  TR  -  (T  G  =  G  +  (C2  *  (T  -  TR  -  (TH1  *  A L O G ( T / T R ) ) ) ) *  A L O G ( ( T H 1 / T H O ) ) ) ) )  (MPA)  WRT TR,  PR  G  G  = G + ( ( 2 . 0 * (A1 * TH1 + T * A3) * (P - PR) + (A2 * TH1 + A4 * T) * ( P * * 2 - P R * * 2 ) ) / (2.0 * TH1)) = G - (W * ( Z P T - ZPRTR - ( ( T - TR) * Y P R T R ) ) )  C XLOGK = G / ( ( - A 1 0 ) * R * T ) RETURN END SUBROUTINE GMIN(XLOGK, GTP, H, S, A, B, C, D, E, F, G, V, DVDT, DVDP, T, P) C C C C C C C C  ho  c  5  C C C C C C C C C C C C C C C C C C C C C C C C C C C  THIS ROUTINE CALCULATES THE LOG K AND  G FOR FOR A SOLID PHASE  RETURNED VARIABLES GTP  -  XLOGK  -  GIBBS FREE LOG  ENERGY  OF FORMATION  ( 1 0 ) K OF FORMATION  OF THE PHASE  OF THE PHASE  PASSED VARIABLES A, B, C, D,  E, F, G, -  TERMS OF THE CP EQUATION  H  -  ENTHALPHY  AT PR AND  S  -  ENTROPY  V  -  VOLUME AT PR AND  DVDT  =  AT PR AND  TR  TR TR  ( I N CM**3 (=  J/MPA)  D(V) EVALUATED AT CONSTANT  P  EVALUATED AT CONSTANT  T  D(T) D(V) DVDP  = D(P)  T - TEMPERATURE IN DEG K P PRESSURE IN MPA TR, PR REFERENCE TEMPERATURE R  -  CP AND  GAS CONSTANT  ( J K**-1  VOLUME EQUATION USED  ( 2 9 8 . 1 5 DEG K) AND  PRESSURE  (0.1 MPA)  M0LE**-1)  ( I N INTEGRATED FORMS)  CP = A + BT + C / ( T * * 2 ) + D / ( T * * . 5 ) + E ( T * * 2 ) + F/T + G / ( T * * 3 )  VTP  = VO + ( ( D V / D T ) * (T - T O ) ) + ((DV/DP) * (P - P O ) )  TR PR R A10 GTP  to  ON CO  298.15 0. 1 8.3143 ALOG(10.0) = H (T * S) < (T - T R ) ) " T * (ALOG((T / T R ) ) ) ) < ( T * * 2 - TR**2) / 2.0) ' T * (T - T R ) ) ' ((1.0E00/TR) - (1.OEOO/T))) T * ( ( 1 . 0 / ( T R * * 2 ) ) - ( 1 . 0 / ( T * * 2 ) ) ) / 2.0) 2.0 * ( S Q R T ( T ) - S O R T ( T R ) ) ) T * ( ( 1 . 0 / ( S Q R T ( T R ) ) ) - ( 1 . 0 / ( S O R T ( T ) ) ) ) > 2.0) ( T * * 3 - TR**3) / 3.0) T * ( T * * 2 - TR**2) / 2.OEOO) ALOG((T / T R ) ) ) T *((1.0/TR) - (1.0/T))) ( ( 1 . 0 / ( T R * * 2 ) ) - ( 1 . 0 / ( T * * 2 ) ) ) / 2.0) T * ( ( 1 . 0 / ( T R * * 3 ) ) - ( 1 . 0 / ( T * * 3 ) ) ) / 3.0)  CALL VMIN(VTP0, V, DVDT, DVDP, T,  PR)  GTP = GTP + ( ( V T P O - (PR * DVDP)) * (P - P R ) ) + (DVDP * ( P * * 2 - PR**2) / 2.0) XLOGK = GTP / ( ( - A 1 0 ) * R * T ) RETURN END SUBROUTINE H20(PRES, TEMP, VOLUM, GTP, HTP, STP, EOCON, CV, DVDT, DVDP, D2VDT2, I SWT) THIS ROUTINE CALLS THE WATER ROUTINES AND PROPERTIES OF WATER PRES TEMP GTP EOCON HTP STP CV VOLUM DVDT DVDP  -  CALCULATES THE  PRESSURE OF CALCULATION (MPA) (PASSED) TEMPERATURE OF CALCULATION ( T K ) ( P A S S E D ) GIBBS FREE ENERGY (J/MOL) (RETURNED) EQUILIBRIUM CONSTANT (RETURNED) H AT T AND P (RETURNED) S AT T AND P (RETURNED) HEAT CAPACITY AT CONSTANT VOLUME (RETURNED) VOLUME AT T AND P (KG/M**3) (RETURNED) DV/DT (P=CONST) (KG/M**3/DEG) (RETURNED) DV/DP (T=CONST) (KG/M**3/MPA) (RETURNED)  C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C  D2VDT2 ISWT  - D2V/DT2 AT CONTANT PRESSURE (RETURNED) - A SWITCH USED IN THE PROGRAM SHOULD BE EQUAL TO ONE ON THE FIRST CALL AND ZERO ON THE REST (PASSED) THE FOLLOWING VECTORS SAVE ALL WATER WATER DATA CALCULATED THE FIRST DATA IS ALWAYS SAVED ON THE ASSUMPTION THAT IT IS THE REFERENCE CONDITIONS (POSN 1 OF ARRAYS) OTHER POINTS ARE STORED IN POSITIONS 2 THROUGH 42 AS CALCULATED, WITH THE OLDEST POINT BEING THROWN AWAY. ALL POINTS ARE CHECKED BEFORE THE WATER CALCULATION ROUTINE IS CALLED - IF THE T AND P IS WITHIN .1 DEG AND 0.01 MPA, THEN THOSE PROPERTIES ARE USED PHLD - SAVED P, THLD - SAVED T, VOLHLD - SAVED VOLUME GIBHLD - SAVED GIBBS FREE ENERGY, EQHLD - SAVED EQUILIBRIUM CONSTANT, HHLD - SAVED ETHALPHY AT T AND P, SHLD - SAVED ENTROPY AT T AND P, CVHLD - SAVED CV, DVTHLD - SAVED DVDT AT P, DVPHLD - SAVED DVDP AT T , D2VPHLD - SAVED D2V/DT2 IPOWAT - POSITION IN ARRRAY TO MAKE NEXT SAVE LOCAL DOUBLE PRECISION VARIABLES - LAST CHARACTER IS ALWAYS D CPD - HEAT CAPACITY AT CONSTANT PRESSURE OF WATER CVD - HEAT CAPACITY AT CONSTANT VOLUME OF WATER FD - HELMHOLZ FREE ENERGY OF WATER HD ENTHALPHY OF WATER DPTVD - DERIVATIVE OF P WRT. T AT CONSTANT V DPRTD - DERIVATIVE OF P WRT. RHO AT CONSTANT T DPVTD - DERIVATIVE OF P WRT. V AT CONSTANT T PD PRESSURE (MPA) OF WATER SD ENTROPY OF WATER TD - TEMPERATURE (DEG K) OF WATER TJD JOULE THOMPSON COEF. OF WATER. UD INTERNAL ENERGY OF WATER VD VOLUME (KG/M**3) OF WATER DOUBLE PRECISION PD, TD, VD, HD, UD, SD, CPD, CVD, TJD, FD DOUBLE PRECISION DPTVD, DPRTD, DPVTD REAL P H L D ( 4 2 ) , T H L D ( 4 2 ) , V 0 L H L D ( 4 2 ) , G I B H L D ( 4 2 ) , E Q H L D ( 4 2 ) , HHLD(42), SHLD(42), CVHLD(42), DVTHLD(42), DVPHLD(42), D2VHLD(42) INTEGER IPOWAT, IMAX SAVE PHLD, THLD, VOLHLD, GIBHLD, EQHLD, HHLD, SHLD, CVHLD, DVTHLD, DVPHLD, D2VHLD, IPOWAT, IMAX  C IF C  (ISWT .EQ. 0 ) THEN FIRST CHECKED SAVED VALUES  PLIM = 0.01 TLIM =0.1 DO 10 I = 1, IMAX IF ( A B S ( ( P H L D ( I ) ABS((THLD(I) VOLUM = GTP = EQCON = HTP = STP = CV = DVDT = DVDP = D2VDT2= RETURN ENDIF CONTINUE  10  ro  - P R E S ) ) .LT. PLIM .AND THEN - TEMP)) .LT. T L I M ) VOLHLD(I) GIBHLD(I) EQHLD(I) HHLD(I) SHLD(I) CVHLD(I) DVTHLD(I) DVPHLD(I) D2VHLD(I)  ELSE IMAX = 0 IPOWAT = 1 ENDIF A10 = ALOG(10.OEOO) R = 8.3143  O  PD TD  = DBLE(PRES) = DBLE(TEMP) -  CALL THE WATER CALL  ROUTINE  STEAM(PD, TD, VD, HD, UD, SD, CPD, NE, DPTVD, DPRTD, DPVTD)  T R I P L E POINT  TTRIP STRIP PTRIP VTRIP HTRIP WH20  273.15D00  CVD, TJD,  FD,  3,  REFERENCE DATA FOR WATERED T - DEG K; S - J / (G K) P - MPA; V - 0 / ( G ) ; H - J/G; W - G  == == == == == ==  273.16E00 3.5144E00 0.0006113E00 0.10002E00 -1597 1 .OEOO 18.01534E00  VOLUM == SNGL(VD) / 1.0E03 CV = SNGL(CVD) DVDP == ( 1 . 0 E 0 0 / SNGL(DPVTD)) /  1.0E03  DVDT STP HTP  = DVDP * SNGL(DPTVD) * (-1.0) SNGL(SD) STRIP (TEMP - T T R I P ) ) SNGL(FD) (STRIP + ((TEMP STP) - ( S T R I P * T T R I P ) ) + HTRIP + ( ( P R E S * 1.0E03 * VOLUM) - ( P T R I P GTP HTP (TEMP STP) GTP / ( ( - A 1 0 ) * R * TEMP) E0C0N  C C C C C C C C C C  c c  * VTRIP))  STP STP WH20 HTP HTP WH20 GTP WH20 GTP EQCON WH20 EOCON ******** D2V/DT2 IS NOT CALCULATED ? ? ? ? ? ? ? ? D2VDT2 = O.OEOO PHLD(IPOWAT) = PRES THLD(IPOWAT) = TEMP VOLHLD(IPOWAT) = VOLUM GIBHLD(IPOWAT) = GTP EOHLD(IPOWAT) = EQCON HHLD(IPOWAT) = HTP SHLD(IPOWAT) = STP CVHLD(IPOWAT) = CV DVPHLD(IPOWAT) = DVDP DVTHLD(IPOWAT) = DVDT D2VHLD(IP0WAT) = D2VDT2 IMAX = IMAX + 1 IPOWAT = IPOWAT + 1 IF (IMAX .GT. 4 2 ) IMAX = 42 IF (IPOWAT .GT. 4 2 ) IPOWAT = 2 RETURN END SUBROUTINE HAQU( HTP, HF, C1, C2, THETA, A1, A2, A3, A4, W, YPT, YPRTR, ZPT, ZPRTR, TK, P) THIS ROUTINE CALCULATES THE ENTHALPY OF AN AQUEOUS S P E C I E S USING EQUATION 275 FROM HELGESON, KIRKHAM AND FLOWERS, A J S 281, P. 1413 ( 1 9 8 1 ) . RETURNED@D HTP - CALCULATED ENTHALPY AT T AND P PASSED@D  A1 ZPRTR -  A2, A3, A4, THETA, C l , C2, W, YPT, YPRTR. ZPT, PARAMETERS IN EQUATION. SEE TEXT FOR D E T A I L S .  HF  - DELTA H OF FORMATION  P TK  - PRESSURE IN MEGA-PASCALS - TEMPERATURE IN DEG K.  AT TR AND PR  NOTE@D UNITS USED ARE JOULES AND MEGA-PASCALS, NOT CALORIES AND BARS AS IN HELG. ET. AL. REAL HTP, HF, C1, C2, THETA, A1, A2, A3, A4, W, YPT REAL YPRTR, ZPT, ZPRTR, TK, P, PR, TR PR = 0.1E00 TR = 298. 15 HTP = HF + ( ( C 1 + C2) * (TK - TR) ) + (C2 * THETA * A L 0 G ( ( ( T K - T H E T A ) / ( T R - T H E T A ) ) ) ) + (A1 * (P - P R ) ) + (A2 * ( P * * 2 - PR**2) / 2.OEOO) + ( ( ( 2 . 0 * A3 * TK * (P - P R ) ) + (A4 * TK * ( P * * 2 P R * * 2 ) ) ) / ( 2 . 0 * (TK - T H E T A ) ) ) + ( ( ( 2 . 0 * THETA * A3 * TK * (P - P R ) ) + (THETA * A4 * TK * (P**2 - P R * * 2 ) ) ) / ( 2 . 0 * ( ( T K - T H E T A ) * * 2 ) ) ) + (W * ( ( T K * YPT) - (TR * YPRTR) - ZPT + Z P R T R ) ) RETURN END SUBROUTINE HMIN(HTP, HZERO, A, B, C, D, E, F, G, V, DVDT, DVDP, T, P) C C  THIS ROUTINE CALCULATES H AT T AND  P FOR A GIVEN PHASE  c c  RETURNED  VARIABLES  HTP  = ENTHALPHY  AT T AND P  c  to to  c c c c c c c c c c c  PASSED VARIABLES@D  T - TEMPERATURE IN DEG K P PRESSURE IN MPA HZERO ENTHALPHY AT 298 AND . 1 MPA A, B, C, D, E, F, G - CP TERMS V - VOLUME AT TR, PR DVDT (DV/DT) AT CONSTANT P DVDP (DV/DP) AT CONSTANT T INTERNAL VARIABLES@D R - GAS CONSTANT ( J K**-1 M O L E * * - i ) TR - 298.15 DEG. K PR - 0 . 1 MPA VTPO - VOLUME AT T AND PO  c c  CP  AND  VOLUME EQUATION USED  ( I N INTEGRATED FORMS)  CP  = A + BT + C / ( T * * 2 ) + D / ( T * * . 5 ) + E ( T * * 2 ) + F/T + G / ( T * * 3 )  c c c c  VTP = VO + ( ( D V / D T ) * (T - T O ) ) + ( ( D V / D P ) * (P - P O ) ) TR = 2 9 8 . 1 5 E 0 0 PR = 0.1E00 HTP = HZERO + (A * (T - T R ) ) + (B * ( T * * 2 - TR**2) / 2.0)  + + + + +  (C (D (E (F (G  * * * * *  ((1.0E00/TR) - (1.0E00/T))) 2.0 * ( S Q R T ( T ) - S O R T ( T R ) ) ) ( T * * 3 - TR**3) / 3.0) ALOG((T / T R ) ) ) ((1.0/(TR**2) ) - (1.0/(T**2))) /  2.0)  CALL VMIN(VTP0, V, DVDT, DVDP, T, PR) HTP = HTP + ( ( V T P O - (PR * DVDP)) * (P - P R ) ) + (DVDP * ( P * * 2 - PR**2) / 2.0) + ( ( - 1 . 0 ) * DVDT * (P - PR) * T ) RETURN END SUBROUTINE IN ARRAY  ro  LEFT(GRAND,  IDIM)  AARRAY,  COMPONENTS ARE STORED IN THE F I R S T NUMELE ROWS/COLUMNS. THE NUMBER OF MOLES OF WATER IS STORED IN THIS AREA, I T ' S COLUMN IS DETERMINED BY I T ' S COMPONENT NUMBER. THE IONIC STRENGTH IS COLUMN/ROW NUMELE + 1. THE A C T I V I T Y OF WATER IS STORED IN COLUMN NUMBER NUMELE + 2, THE A C T I V I T Y OF WATER EQUATION IS ROW NUMBER NUMELE + 2 COMMON /CHEMPH/ COMPPH(10,25), THERPH(14,25), NUMPH COMMON /CHEMAQ/ COMPAQ(10,25), THERAQ(13,25) , NUMAQ COMMON /CHEMSS/ COMPSS(10,20), T H E R S S ( 8 , 2 0 ) . NUMSS COMMON /CHEMG / COMPG(10,10), THERG(6,10), NUMG COMMON /NEWCOM/ CNEWAQ(10,25), CNEWPH(10,25), CNEWSS(10,20) , CNEWG(10,10), I N D X 1 ( 1 0 ) , I N D X 2 ( 1 0 ) , I N D X 3 O 0 ) , NUMELE COMMON /PATH/ C ( 2 5 ) , CM0LE(1O), XMNOW(10), X M F U T ( 1 0 ) , REAMT(5), TKNOW, TKFUT, TAUNOW, TAUFUT, PNOW, PFUT, EMAX, STRONG, AMWAT, DTAU, DTK, DPRES, I P 0 I N T ( 2 5 ) , INDREA(5) , NUM, IPRINT, NUMREC REAL GRAND(IDIM, IDIM) REAL AARRAY(10, 10), BARRAY(10.25), CARRAY(25, 10) , R E S U L T ( 2 5 , 2 5 ) X = 1000.00E00 / THERAQ(1,1) ZERO = 1.0E-05 IONIC = NUMELE + 1 IAWAT = NUMELE + 2 CALL CALL CALL CALL CALL LOAD  MINIT(AARRAY, 10, 10, MINIT(BARRAY, 10, 25, MINIT(CARRAY, 25, 10, MINIT(RESULT, 25, 25, MINIT(GRAND, IDIM, IDIM, AARRAY  O.OEOO) O.OEOO) O.OEOO) O.OEOO) O.OEOO)  AARRAY(IONIC, IONIC) = 1.0 AARRAY(IAWAT, IAWAT) = 1.0 DO 100 1 = 1 , NUMELE K1 = I N D X 1 ( I ) K2 = I N D X 2 ( I ) IF (K2 .EQ. 1) THEN MINERAL COMPONENTS DO 20 d = 1, NUMELE AARRAY(d,I) = CNEWPH(I.KI) CONTINUE ELSE IF ( K 2 . EQ. 2) THEN AQUEOUS S P E C I E S IF (K 1 .EQ. 1) THEN DO 40 d = 1, NUMELE AARRAY(d,I ) = CNEWAQ(d,K1) DO 30 J I = 2, NUMAQ A A R R A Y ( J . I ) = AARRAY(d , I ) + (CNEWAQ(I,d1 ) * C ( d ) ) CONTINUE AARRAY(d,I) = AARRAY(d,I) / X CONTINUE ELSE DO 50 d = 1, NUMELE AARRAY(d,I) = CNEWAQ(d,K1) * AMWAT * C ( K 1 ) / X CONTINUE AARRAYCIONIC,I) = (-0.5) * ( T H E R A Q ( 1 2 , K 1 ) * * 2 ) AARRAY(IONIC,I) = AARRAY(I O N I C , I ) * C ( K 1 ) AARRAY(IAWAT,I) = C ( K 1 ) / X ENDIF ELSE IF (K2. EQ. 3) THEN SOLID SOLUTION COMPONENTS DO 70 d = 1, NUMELE AARRAY(d,I) = CNEWSS(I,K1) CONTINUE ELSE  IF (K2. EQ. 4 ) THEN GAS COMPONENTS DO 90 d = 1, NUMELE AARRAY(d,I) = CNEWG(I,K1) CONTINUE  ENDIF CONTINUE AARRAY(IAWAT , IONIC) = O.OEOO DO 110 I = 2, NUMAQ CALL GAMDI1(GDI)  AARRAY(IAWAT, 110 C  210  220 C C  300 310  320 C C C  IONIC) + ( C ( I )  CONTINUE LOAD BARRAY LOOP = 0 DO 220 1 = 1, NUMAO K = IPOINT(I) IF (K .GT. 0 ) THEN LOOP = LOOP + 1 DO 210 J = 1, NUMELE BARRAY(J,K) = CNEWAQ(J,I) * AMWAT * C ( I ) / X CONTINUE BARRAY(IONIC,K) = (-0.5E00) * ( T H E R A Q ( 1 2 , I ) * * 2 ) * C ( I ) BARRAY(IAWAT.K) = C ( I ) / X ENDIF CONTINUE LOAD CARRAY DO  <-n  IONIC) = AARRAY(IAWAT, * GDI)  310 I = 1, NUMELE K2 = I N D X 2 ( I ) I F (K2 .EO. 2) THEN DO 300 J = 1, NUMAO K = IPOINT(U) K1 = I N D X K I ) IF (K .GT. 0 .AND. CNEW(K1,I) .GT. ZERO) THEN IF (K1 .NE. 1) THEN CALL GAMDI1(GDI) CARRAY(K.I) = CNEWAQ(K1,I) * (-1.0) CARRAY(K,IONIC) = CARRAY(K,I ) * GDI ELSE CARRAY(K,IAWAT) = CNEWAQ(K1,I) * (-1.0) ENDIF ENDIF CONTINUE ENDIF CONTINUE DO 320 1 = 2 , NUMAO K = IPOINT(I) IF (K.GT.O) THEN CALL GAMDI1(GDI) C A R R A Y ( I , I O N I C ) = CARRAY(K,IONIC) + ( G D I ) ENDIF CONTINUE CALCULATE THE INVERSE OF THE GRAND MATIX FROM THE A, B, C ARRAYS USING THE PARTITIONING TECHNQUE - STORE IN GRAND MATRIX  A GRAND  B  -1  =  J  K  L  M  GRAND C  D  BUILD J PORTION CALL MMULT(RESULT, BARRAY, CARRAY,  IAWAT, LOOP, IAWAT, 25, 25, 10, 25, 25, 10)  DO 410 d = 1, IAWAT DO 400 1 = 1 , IAWAT R E S U L T ( I . d ) = AARRAY(I,d) - R E S U L T ( I . d ) CONTINUE CONTINUE I = 0 CALL INVRT(RESULT, IAWAT, 25, I ) IF ( I . N E . 0 ) THEN WRITE(6,1001) STOP ENDIF CALL MCOPY(GRAND, RESULT, 1, 1, IAWAT, IAWAT, IDIM, IDIM, 25, 25) BUILD L PORTION CALL MMULT(RESULT, CARRAY, GRAND, LOOP, IAWAT, IAWAT, 25, 25, 25,10, IDIM, IDIM) CALL MMULTC(RESULT, -1.0, LOOP, IAWAT, 25, 25) I = IAWAT + 1 CALL MCOPY(GRAND, RESULT, I, 1, LOOP, IAWAT, IDIM, IDIM, 25, 25) BUILD K PORTION CALL MMULT(RESULT, GRAND, BARRAY, IAWAT, IAWAT, LOOP, 25, 25, IDIM, IDIM, 10, 25) CALL MMULTC(RESULT, -1.0, IAWAT, LOOP, 25, 25) CALL MCOPY(GRAND, RESULT, 1, I , IAWAT, LOOP, IDIM, IDIM, 25, 25) BUILD M PORTION (NOTE AS BARRAY IS NOT USED ANY MORE, IT IS USED FOR TEMPERARY STORAGE OF K PORTION CALL MCOPY(BARRAY,  RESULT,  1, 1, IAWAT,  LOOP,  10, 25, 25, 2 5 ) CALL MMULT(RESULT, CARRAY, BARRAY, LOOP, IAWAT, LOOP, 25, 25, 25, 10, 10, 25) CALL MMULTC( RESULT, -1.0, LOOP, LOOP, 25, 25) DO 450 d = 1, LOOP  450  1001  R E S U L T ( J . U ) = R E S U L T ( d . j ) + 1.0 CONTINUE CALL MCOPY(GRAND, RESULT, I, I , LOOP, LOOP, IDIM,  RETURN FORMAT('O  ERROR  IN ROUTINE LEFT - SINGULAR MATRIX RETURNED ',/, FROM INVERT ROUTINE. BAD SETUP !!')  END SUBROUTINE NEW( TIME, THIS ROUTINE GETS THE AT FUTURE TIMES COMMON /UPPER IF  S3  IDIM, 25, 25)  VALUE, ISWIT) VALUES FOR PRESSURE AND  / PMIN, PMAX, TMIN, TMAX, (ISWIT .EO. 1) THEN IF (TIME .LT. PTIME .AND. VALUE = PMIN + ((PMAX  PTIME, TTIME,  TEMPERATURE  PSTART, TSTART  TIME .GT PSTART) THEN - PMIN) * (TIME - PSTART) / (PTIME - P S T A R T ) ) (TIME .GE. PTIME) THEN = PMAX (TIME .LE. PSTART) THEN = PMIN  ELSE IF VALUE ELSE IF VALUE ENDIF ELSE IF (ISWIT .EO. 2) THEN IF (TIME .LT. TTIME .AND. TIME .GT. TSTART) THEN VALUE = TMIN + ((TMAX - TMIN) (TIME - TSTART) / TSTART) ) (TTIME ELSE IF (TIME .GE. TTIME) THEN VALUE = TMAX ELSE IF (TIME .LE. TSTART) THEN VALUE = TMIN ENDIF ENDIF RETURN END SUBROUTINE NACL(SOLVE,SHORT,PMA,TK,DSOLDP,DSOLDT,DSHODP,DSHODT) THIS ROUTINE CALCULATES THE SHORT RANGE INTERACTION PARAMETER (SHORT) AND THE SOLVATION PARAMETER ( S O L V E ) FOR THE GIVEN T (DEG K) AND P (MPA) IT ALSO CALCULATES THEIR DERIVATIVES WITH RESPECT TO T AND P SHORT CONTAINS THE SHORT RANGE INTERACTION PARAMETER SOLVE CONTAINS THE SOLVATION PARAMETER DSHODP CONTAINS THE DERIVATIVE OF THE SHORT RANGE PARAMETER WITH RESPECT TO PRESSURE  c c c c c c c c c c c c c c c c c c  CO  DSHODT CONTAINS THE DERIVATIVE OF THE SHORT RANGE PARAMETER WITH RESPECT TO TEMPERATURE DSOLDP CONTAINS THE DERIVATIVE OF THE SOLVATION PARAMETER WITH RESPECT TO PRESSURE DSOLDT CONTAINS THE DERIVATIVE OF THE SOLVATION PARAMETER WITH RESPECT TO TEMPERATURE NOTE@D VALUES ARE FROM TABLES 29 AND 30, HELG. ET AL, THE VALUE FOR THE SOLVATION PARAMETER IS THEN MODIFIED WITH EQUATION 149. I DIRECTION IN MATRIX IS PRESSURE J IS TEMPERATURE TEMPERATURES ARE FROM 25 TO 500 DEG C PRESSURES ARE FROM .1 ( S E E NOTE) TO 500 MPA NOTE@>D THE LOWER PRESSURES ARE ALONG THE BOILING CURVE, BUT NO CORRECTIONS HAS BEEN MADE. I N I T I A L I Z E SHORT RANGE INTERACTION PARAMETER AND SOLVATION PARAMETER FOR NACL FOR SUBROUTINE. SH0(6,20) S0L(6,20) 2 77, 2 82, 2.47, 2 58, 2 .66, 2 72, 2 51 , 2 56, 2.15, 2 .37 , 2 45, 2 28, 1 95. 2. 06, 2 15, 2 22, 2 28, 1 .79, 1 91 , 1 99, 1 .72, 1 83, 1 .39, 1 58, 1 58, 1 .35, 1 48, 1 67, 0.93, 1 18, 1 33, 0.41 , 1 1 1 , 1 23, 0 73, 0. 95, -0.18, 0 86, 0 98, 0. 51 , 0 72, 0 25, -0.85, 0 60, - o 28, 0. 04, 0 29, 0 47, -1.64, 0 05, 0 21 , -0 86, -0. 46, -0 15, -2.57, -1 50, -1. 00, -0 63, -0 38, -0 20, -0 63, -3.71 , -2 20, -1. 57, -1 13, -0 84, -1 09, -5.21 , -2 99, -2 .19, -1 67, - 1 33, -1 58, -7.32, -3 88, -2 .85, -2 24, - 1 85, -4 91 • -3 .58, -2 86, - 2 40, -2 10, -7.32, -2 65, -7.32, -6 1 1 , -4. 38, -3 52, - 2 99, -3 25, -7 56, -5. 26, -4 24, - 3 63, -7.32, -3 85, -7.32, -9 31 , -6. 24, -5 03, - 4 32, -4 57, -7.32, -11 43, -7. 34, -5 87, - 5 06, -5 28, -7.32, -14 01 , -8 .56, -6 78, - 5 84, -6 00 -7.32, -17 12, -9 .88, -7 73, -6 63, / -1 1 76, -9.77, -9 • 12, 9.51 , -10.44, -9 19, -5.59, -5 • 52, -5.60, -5.66, -5 87, -5 07, -2.43, -2 .65, -2.46, -2.15, -1 68, -2 63, 0.23, 0.71, 1 39, - o 07, -0 . 10, 0.13, 2.44, 1 • 85, 2.14, 3.05, 4 21 , 1 71 , 4.51 , 4 • 12, 5.13, 6 26, 4 13, 4.28, 6.38, 7 .05, 8 13, 5 91 , 5 88, 6.16,  8.11, 9.73, 11.29, 12.71 , 14.15, 15.49, 15.49, 15.49, 15.49, 15.49, 15.49, 15.49, 15.49,  7 .48, 9.27, 10.80, 12.24, 13.68, 15. 16, 16.48, 17.80, 19.12, 20.33, 21.55, 22.86, 24.03,  7.66, 9.20, 10.73, 12.19, 13.66, 15.10, 16.42, 17.79, 19.11, 20.35, 21.61, 22.84, 23.95,  8.18, 9.59, 11.15, 12.62, 13.99, 15.41 , 16.76, 18.10, 19.40, 20.66. 21.85, 23.09, 24.32,  9.05, 10.40, 11.92, 13.39, 14.83, 16.23, 17.52. 18.81 . 20.13, 21.38, 22.56, 23.74, 24.94,  10.30, 11.58, 13.15, 14.54, 16.01, 17.36, 18.68, 19.88, 21.23, 22.38, 23.64, 24.78, 25.95  SAVE SHO, SOL T = TK - 273.15E00 P = PMA R = ALOG(10.OEOO) * 8.3143EOO * TK d1 = I F I X ( T / 2 5 . O O E O O ) IF ( J 1 . L T . 1 ) d 1 = 1 IF ( J 1 . G T . 1 9 ) d1 = 19 d2 = 01 + 1 1 1 = 1 + I F I X ( P / 100.OEOO) IF ( 1 1 . L T . 1 ) 11 = 1 IF ( 1 1 . G T . 5 ) 11 = 5 1 2 = 1 1 + 1 TEMPI TEMP2 PRES1 PRES2 DELTAT DELTAP X1 X2  = = = = = =  25.OEOO * F L O A T ( d 1 ) 25.OEOO * F L 0 A T ( d 2 ) ( F L O A T ( 1 1 ) - 1.0) * ( F L 0 A T ( I 2 ) - 1.0) * (T - TEMP 1)/(TEMP2 (P - P R E S 1 ) / ( P R E S 2 -  (DELTAT (DELTAT  ( S O L ( I 1,d2) (S0L(I2,d2)  100.0 100.0 TEMPI) PRES 1 ) S O L ( I 1 ,d 1 ) ) ) S0L(I2, d1)))  S O L ( I 1,d 1 ) SOL(12,d1)  DSOLDP = (X2 - X1) * 1.0E-05 / R SOLVE = DELTAP * (X2 - X1) + X1 SOLVE = SOLVE * 1.0E-03 / R X1 = (DELTAP * ( S 0 L ( I 2 , d 1 ) - S 0 L ( I 1 , d 1 ) ) ) + X2 = (DELTAP * ( S 0 L ( I 2 , d 2 ) - S 0 L ( I 1 , d 2 ) ) ) + DSOLDT = ( ( X 2 - X1) * 1.0E-03) / (25.OEOO * DSOLDT = DSOLDT - (SOLVE / (TK * R ) )  S0L(I1,d1) S0L(I1,d2) R)  X1 = (DELTAT * ( S H 0 ( I 1 . J 2 ) - S H 0 ( I 1 , J 1 ) ) ) + S H 0 ( I 1 , J 1 ) X2 = (DELTAT * ( S H 0 ( I 2 , J 2 ) - S H 0 ( I 2 , d 1 ) ) ) + S H 0 ( I 2 , J 1 ) DSHODP = (X2 - X1) * 1.0E-04 SHORT = ( ( D E L T A P * (X2 - X 1 ) ) + X1) * 1.0E-02 X1 = (DELTAP * ( S H 0 ( I 2 , J 1 ) - S H O ( I 1 , d 1 ) ) ) + S H O ( I 1 , d 1 ) X2 = (DELTAP * ( S H 0 ( I 2 , d 2 ) - S H O ( I 1 , d 2 ) ) ) + S H 0 ( I 1 , d 2 ) DSHODT = (X2 - X1) * 1.0E-02 / 25.OEOO C  C C C C C C C C C C C O  RETURN END SUBROUTINE GAMMA(COEF,TK,P,D,STRENG,Z,AZERO,W) THIS ROUTINE CALCULATES A C T I V I T Y C O E F I C I E N T S ACCORDING TO HELGESON ET AL'S MODEL COEF IS RETURNED AND CONTAINS THE LOG OF THE A C T I V I T Y C O E F I C I E N T OF THE S P E C I E S THE FOLLOWING  VARIABLES ARE PASSED  AZERO - ELECTROSTATIC RADIUS ( I N ANGSTROMS) DENS - DENSITY OF PURE WATER (CM**3/G) D  -  DENSITY OF PURE WATER  (M**3/KG)  c C C C C C C C C C C C C C C C  STRENG- IONIC STRENGTH OF THE SOLUTION P TK W W1  - PRESSURE IN MPA - TEMPERATURE IN DEG K - CONVENTIONAL BORN PARAMETER ABSOLUTE BORN PARAMETER ( 0 . 5 3 8 7 E 0 5 IS THE ABSOLUTE BORN PARAMETER FOR HYDROGEN ION (HAL, PAGE 1304)  Z  -  CHARGE  ON THE ION - IF 0 OR GREATER THEN 10, AN A C T I V I T Y COEF. OF 1 IS USED.  LOCAL VARIABLES DIELE - D I E L E C T R I C CONSTANT  OF WATER  SHORT - SHORT RANGE INTERACTION PARAMETER FOR NACL SOLVE - SOLVATION PARAMETER FOR NACL (KG/MOLE) COEF = 0.0 IF ( A B S ( Z ) .GT. 10.0 .OR. A B S ( Z ) .LT. 1.0) RETURN  (KG/MOLE)  C CALL CALL  NACL(SOLVE,SHORT,P,TK,DSOLDP,DSOLDT,DSHODP,DSHODT) DIE(01ELE,TK,D)  W1 DENS  = W + (Z * 0.5387E05 * 4.184) = D / 1000.0  A A B B  = = = =  1.824829238E06 * SORT(DENS) / ( ( D I E L E * T K ) * * 1 . 5 ) (-1.0) * A * ( Z * * 2 ) * SORT(STRENG) 5 0 . 2 9 1 5 8 6 4 9 E 0 8 * SQRT(DENS) / ( S O R T ( D I E L E * T K ) ) 1.0 + (AZERO * 1.0E-08 * B * SORT (STRENG))  T = (-1.0) * A L O G ( ( 1 . 0 + (0.0180153 * S T R E N G ) ) ) C = ((W1 * SOLVE) + SHORT - ( 0 . 1 9 * ( A B S ( Z ) - 1 . 0 ) ) ) * STRENG COEF = ( A / B ) + T + C RETURN END SUBROUTINE SETUP5 THIS ROUTINE SETS UP THE I N I T I A L DISTRIBUTION OF S P E C I E S FOR EACH NODE. COMMON / C E L L C H / CHEM(10,51), TOTALM(10,51), STRNGH(5 1 ) , WATER(51), I N D E X K 1 0 , 5 1 ) , I N D E X 2 ( 1 0 , 5 1 ) , I N D E X 3 ( 1 0 , 5 1 ) , I B A L ( 5 1 ) , NUMCHM, NCONST COMMON /TIME/ DTAUP, DTAUT, DTAUC, DTAUM, TAUP, TAUT, TAUC, TAUM, W1 COMMON / C E L L S / C E L L P O ( 5 1 , 2 ) , C E L L P E ( 5 1 , 2 ) , C E L L P ( 5 1 , 2 ) , CELLT(51,2), DENSF(51,2), SIZEX(51), XINERT(51), THICK, NUMX, INOWP, IFUTP, INOWT, IFUTT COMMON /TRANS/ V E L 0 C ( 5 1 , 2 ) , AQCO(10,51,2), S O C O ( 1 0 , 5 1 , 2 ) , A L P H A ( 1 0 ) , INOWC, IFUTC COMMON /CHEMAQ/ COMPAQ(10,25), THERAQ(13,25), NUMAO COMMON /NEWCOM/ CNEWAOv10.25), CNEWPH(10,25), CNEWSS(10,20), CNEWG(10,10), I N D X 1 ( 1 0 ) , I N D X 2 ( 1 0 ) , I N D X 3 ( 1 0 ) , NUMELE REAL C ( 1 0 ) , T O T A L ( 1 0 ) , A C T 1 ( 1 0 ) , A C T 2 ( 1 0 ) NOTE THAT ON THE I N I T I A L CALL, THE IONIC STRENGTH IS ZERO, BUT FOR LATER CALLS, THE IONIC STRENGTH OF THE LAST NODE IS USED 10 = 0 STRENG = O.OEOO NUMELE = NCONST CALL M I N I T ( A C T 1 , 10, 1, O.OEOO) CALL M I N I T ( A C T 2 , 10, 1, O.OEOO) DO 40 I = 1, NUMCHM DO 10 d = 1, NCONST INDX1(d) = INDEX 1 ( d , I ) INDX2(J) = INDEX2(d,I) INDX3(d) = I N D E X 3 ( d , I ) C(d) = CHEM(d,I) TOTAL(d) = TOTALM(d.I) CONTINUE  T = CELLT(I,INOWT) P = CELLP(I,INOWP) IB = IBAL(I) WRITE( 6,1001) I , T, P W R I T E ( 1 0 , 1 0 0 4 ) TAUM, DTAUM CALL D I S T ( T , P, STRENG, TOTAL, C, ACT 1, ACT2, VOL, IB, I S A T ) FROM D I S T , IF ISAT IS NOT ZERO, THEN THE FLUID IS SUPERSATURATED. ACT 1 CONTAINS THE TOTAL MOLALITY OF GLOBAL COMPONENTS IN THE FLUID ACT2 CONTAINS THE NUMBER OF MOLES OF GLOBAL COMPONENTS IN THE SOLID PHASES TOTAL CONTAINS THE TOTAL MOLALITY OF LOCAL COMPONENTS IN THE FLUID IF DO  ( I S A T . N E . O ) 10 = 1 20 J = 1, NCONST AQCO(J,I,INOWC) = A C T 1 ( d ) AQCO(J,I,IFUTC) = ACT1(d) SOCO(d,I,INOWC) = A C T 2 ( d ) SOCO(J,I,IFUTC ) = ACT2(d) CHEM(J.I) = C(J) TOTALM(J.I) = TOTAL(J) CONTINUE I B A L ( I ) = IB STRNGH(I) = STRENG USING VOLUME OF FLUID PER 1000 GRAMS H20, CALCULATE NUMBER OF MOLES OF WATER. d = I K = d - 1 IF ( K . L T . 1 ) K = d IF (d.GE.NUMCHM) d = K VOLUME = THICK * THICK * ( ( S I Z E X ( d ) + S I Z E X ( K ) ) / 2 . 0 ) VOLUME = VOLUME * CELLPO(I,INOWP) WATER(I) = (VOLUME / VOL) * (1000.OEOO / T H E R A Q ( 1 , 1 ) ) WRITE(6,1002) I , WATER(I) NOW CONVERT TOTAL MOLALITES TO TOTAL NUMBER OF MOLES ADD SOLID PHASES TO TOTALM ARRAY DO 30 d = 1, NCONST T O T A L M ( d . I ) = T O T A L M ( d . I ) * WATER(I) * THERAQ(1,1) T O T A L M ( d . I ) = T O T A L M ( d . I ) / 1000.00E00 K = INDEX2(d,I) IF ( K . E 0 . 1 ) T O T A L M ( d . I ) = T O T A L M ( d . I ) + C H E M ( d . I ) CONTINUE CONTINUE  IF  ( I Q . N E . O ) THEN WRITE(6,1003) STOP ENDIF C 1001  1002 1003  1004  C C  00  L  U>  C C C C C C C C C C C C C C C C C C C C  RETURN F O R M A T C 1 D I S T R I B U T I O N OF S P E C I E S CALLED AT TIME 0 FOR ', ' NODE: ' , 1 5 , / , ' WITH A TEMPERATURE OF '.F10.3, ' ( D E C K ) AND A PRESSURE OF ' . F 1 0 . 3 , ' ( M P A ) ' ) FORMAT(//,' TOTAL NUMBER OF MOLES OF WATER AT NODE: ',15, ' = '.E12.5) FORMAT('0',' * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ' / / / , ' D I S T R I B U T I O N OF S P E C I E S AT TIME 0 FOUND NODES',/. ' THAT ARE SUPERSATURATED. TRY AGAIN WITH NEW ',/, ' I N I T I A L CONDITIONS. ',//, i  j  F0RMAT(2(1X,E12.5)) END SUBROUTINE S 0 L V E M ( I T E R P , I T E R T , I T E R C , ITERM) NEW COMMON BLOCK. T H I S BLOCK IS ONLY USED IN THE REACTION SUBROUTINES COMMON /PATH/ C ( 2 5 ) , C M 0 L E ( 1 0 ) , XMN0W(10), X M F U T ( 1 0 ) , R E A M T ( 5 ) , TKNOW, TKFUT, TAUNOW, TAUFUT, PNOW, PFUT, EMAX, STRONG, AMWAT, DTAU, DTK, DPRES, I P 0 I N T ( 2 5 ) , I N D R E A ( 5 ) , NUM, I P R I N T , NUMREC XMNOW, XMFUT ARE THE TOTAL NUMBER OF MOLES OF AT PRESENT AND FUTURE TIMES  EACH OF THE  COMPONENTS  TKNOW, TKFUT IS THE TEMPERATURES AT PRESENT AND FUTURE TIMES. PNOW, PFUT IS THE PRESSURES AT PRESENT AND FUTURE TIMES. TAUNOW, TAUFUT IS THE TIMES AT PRESENT AND FOR THE FUTURE. AMWAT IS THE NUMBER OF MOLES OF WATER NUM IS THE NUMBER OF COMPONENTS (EQUAL TO  NUMEL)  I P R I N T IS A SWITCH  OUTPUT  EMAX  IS AN  ERROR  I F THERE  SHOULD BE ANY  L I M I T TEST  STRONG IS THE IONIC STRENGTH OF THE SOLUTION C IS THE LOG MOLALITY OF EACH OF THE AQUEOUS S P E C I E S IPOINT I N D I C A T E S WHERE AN AQUEOUS S P E C I E S WILL BE IN THE GRAND MATRIX PREVIOUSLY DEFINED COMMON BLOCKS  COMMON / C E L L C O / COMMON / C E L L C H /  CHEMO(10,51) C H E M ( 1 0 , 5 1 ) , T O T A L M ( 1 0 , 5 1 ) , STRNGH(51), WATER(51), I N D E X 1 ( 1 0 , 5 1 ) , I N D E X 2 ( 1 0 , 5 1 ) , I N D E X 3 ( 1 0 , 5 1 ) , I B A L ( 5 1 ) , NUMCHM, NCONST COMMON / T I M E / DTAUP, DTAUT, DTAUC, DTAUM, TAUP, TAUT, TAUC, TAUM, W1 COMMON / C E L L S / C E L L P O ( 5 1 , 2 ) , C E L L P E ( 5 1 ,2 ) , C E L L P ( 5 1 , 2 ) , CELLT(51,2), DENSF(51,2), SIZEX(51), XINERT(51), THICK, NUMX, INOWP, I F U T P , INOWT, I F U T T COMMON /TRANS/ V E L 0 C ( 5 1 , 2 ) , A Q C O ( 1 0 , 5 1 , 2 ) , S O C O ( 1 0 , 5 1 , 2 ) , A L P H A ( 1 0 ) , INOWC, I F U T C COMMON /REACT/ R E A C T A ( 5 , 5 1 ) , I R E A C T ( 5 , 5 1 ) , NUMREA(51 ) COMMON /CHEMPH/ COMPPH(10,25), T H E R P H ( 1 4 , 2 5 ) , NUMPH COMMON /CHEMAO/ COMPAO(10,25), T H E R A Q ( 1 3 , 2 5 ) , NUMAQ COMMON /CHEMSS/ C O M P S S ( 1 0 , 2 0 ) , T H E R S S ( 8 , 2 0 ) , NUMSS COMMON /CHEMG / COMPG(10,10), THERG(6,10), NUMG COMMON /NEWCOM/ CNEWAQ(10,25), CNEWPH(10,25), CNEWSS(10,20), CNEWG(10,10), I N D X 1 ( 1 0 ) , I N D X 2 ( 1 0 ) , I N D X 3 ( 1 0 ) , NUMELE REAL GCOMP(IO), A C T ( 1 0 ) , G ( 2 5 ) A10 ZERO IPRINT EMAX  = ALOG(10.0E00) = 1.0E-05 = 1 = 1.0E-05  NODES 1 AND NUMX ARE CONSTANT AT A L L TIMES, SO NO CHEMICAL REACTIONS ARE CALCULATED DO 9 0 0 L = 2, (NUMX - 1) CALL I M I N I T ( I P O I N T , 25, 1, O) CALL M I N I T ( A C T , 10, 1, O.OEOO) S = ( C E L L T ( L , I F U T T ) - C E L L T ( L , I N O W T ) ) / DTAUT TKNOW = ( S * ((TAUM - DTAUM) - (TAUT - D T A U T ) ) ) + CELLT(L,INOWT) TKFUT = ( S * (TAUM - (TAUT - D T A U T ) ) ) + CELLT(L,INOWT) S = ( C E L L P ( L , I F U T P ) - CELLP(L,INOWP) ) / DTAUP PNOW = ( S * ((TAUM - DTAUM) - (TAUP - D T A U P ) ) ) + CELLP(L,INOWP) PFUT = ( S * (TAUM - (TAUP - D T A U P ) ) ) + CELLP(L,INOWP) TAUNOW = TAUM - DTAUM TAUFUT = TAUM DO 100 J = 1, NUMELE INDX1(d) = INDEX 1 ( d , L ) INDX2(d) = INDEX2(d,L)  INDX3(d) = INDEX3(d,L) CHEMO(d,L) = C H E M ( d . L ) CMOLE(d) = CHEM(d.L) XMNOW(d) = TOTALM(d.L) S = ( S O C O ( d , L , I F U T C ) - SOCO(d,L,INOWC)) + ( A Q C O ( d , L , I F U T C ) - AQCO(d,L,INOWC)) S = S / DTAUC X M F U T ( d ) = S * (TAUM - (TAUC - D T A U C ) ) + XMNOW(d) CONTINUE STRONG = STRNGH(L) AMWAT = WATER(L)  100  CALCULATE A C T I V I T Y C O E F F I C I E N T S C A L L H20(PN0W, TKNOW, DENS, GIBBS, HTP, STP, G ( 1 ) , CV, DVDT, DVDP, D2VDT2, O) DENS = 1.OEOO / DENS C ( 1 ) = O.OEOO C A L L D I E 1 ( T , DENS, DVDP, DVDT, D2VDT2, ETRPR, YTRPR, E, TRP, ZTP, X, 0 ) DO 110 I = 2, NUMAO CALL GAMMA(COEF,TKNOW,PNOW,DENS, STRONG, T H E R A Q ( 1 2 , 1 ) , T H E R A O ( 1 3 , 1 ) , THERAO(11. I ) ) C ( I ) = COEF CONTINUE  00  1 10 GET  LOG  K'S  FOR  EACH OF THE S P E C I E S . F I R S T WATER, WHICH IS ALWAYS S P E C I E S NUMBER 1. DO 120 I = 2, NUMAO CALL GAOU(XLOGK,GM,THERAO(2,I),THERAO(3,I), THERAQ(4,I),THERAQ(5,I),THERAQ(10,1), THERAQ(6,I),THERAQ(7,I),THERAQ(8,I), T H E R A O O , I ) , THERAQ( 1 1 , 1 ) , ZTP, ZTRPR, YTRPR, PNOW, TNOW) G ( I ) = XLOGK CONTINUE  GET  LOG  K'S DO  FOR 190 K1 K2 IF  120  EACH OF THE COMPONENTS 1=1, NUMELE = INDEX1(I,L) = INDEX2(I,L) ( K 2 . E O . 1 ) THEN SOLID PHASE COMPONENTS CALL GMIN(XLOGK, GM, T H E R P H ( 2 , K 1 ) , T H E R P H ( 3 , K 1 ) , T H E R P H ( 5 , K 1 ) , THERPH(6,K1 ) , T H E R P H ( 7 , K 1 ) , THERPH(8,K1), THERPH(9,K1), THERPH(10,K1),  C C C C  C C C C 190 C  200  M  CO ^  C C  210  220 C C C  390  THERPH(11,K1), THERPH(4,K1), T H E R P H ( 1 2 , K 1 ) , T H E R P H ( 1 3 , K 1 ) , TKNOW, PNOW) GCOMP(I) = XLOGK E L S E IF ( K 2 . E 0 . 2 ) THEN AQUEOUS S P E C I E S COMPONENTS I F WATER IS A COMPONENT, THEN THE A C T I V I T Y IS STORED RATHER THAN THE MOLALITY. GCOMP(I) = G(K1) A C T ( I ) = C(K1) * CMOLE(I) E L S E IF (K2.EQ.3) THEN SOLID SOLUTION COMPONENTS E L S E IF ( K 2 . E Q . 4 ) THEN GAS COMPONENTS END I F CONTINUE FORM NEW B A S I S FOR MINERALS AND S P E C I E S CALL BASIS(XMFUT.L) DO 200 1 = 1, NUMELE X M F U T ( I ) = X M F U T ( I ) + XMNOW(I) IF ( I N D X 2 ( I ) .EQ. 2) I P O I N T ( I N D X 1 ( I ) ) = I * (-D CONTINUE SUBTRACT OUT LOG K OF COMPONENTS FROM EACH S P E C I E S K = 0 DO 220 1 = 1 , NUMAQ DO 210 J = 1, NUMELE IF ( A B S ( C N E W A Q ( J , I ) ) . G E . Z E R O ) G ( I ) = G ( I ) - (CNEWAQ(d,I) * G C O M P ( J ) ) CONTINUE IF ( I P O I N T ( I ) . E Q . O ) THEN K = K + 1 IPOINT(I) = K END IF CONTINUE CALCULATE M O L A L I T I E S OF ALL S P E C I E S - NOTE A C T I V I T Y OF WATER IS STORED RATHER THAN MOLALITY BTEMP = 0.0 DO 4 0 0 1 = 2 , NUMAQ ATEMP = G ( I ) DO 390 d = 1, NUMELE IF (ABS(CNEWAQ(d,I)).GE.ZERO) ATEMP = (CNEWAQ(J.I) * A C T ( d ) ) + ATEMP CONTINUE  C ( I ) = ATEMP - C ( I ) IF ( C ( I ) . G E . - 6 5 . 0 ) BTEMP = BTEMP + ( 1 0 CONTINUE C ( 1 ) = ( ( - 1 . 0 ) * BTEMP * 0 . 0 1 8 0 1 5 3 4 / A 1 0 )  400  GET  450  NOW  REACTANTS NUMREC = NUMREA(L) IF (NUMREC .NE. 0 ) THEN DO 4 5 0 1 = 1 . NUMREC INDREA(I) = IREACT(I.L) REAMT(I) = REACTA(I,L) CONTINUE END IF C A L L P A T C A L ( I T E R P . I T E R T , ITERC, ITERM. L ) SAVE VALUES AT TIME TAUFUT FOR NODE L STRNGH(L) = STRONG WATER(L ) = AMWAT DO 5 0 0 1 = 1 , NUMELE K1 = INDX1(J) K2 = INDX2(J) I N D E X 1 ( J , L ) = K1 I N D E X 2 ( J , L ) = K2 INDEX3(J,L) = INDX3(J) T O T A L M ( d . L ) = XMNOW(J) CHEM(J.L) = CM0LE(K1) CONTINUE NUMREA(L) = NUMREC IF (NUMREC .NE. O) THEN DO 5 5 0 1 = 1 , NUMREC I R E A C T ( I . L ) = INDREA(I ) R E A C T A ( I , L ) = REAMT(I ) CONTINUE END IF  00  500  550  900  CONTINUE RETURN END  *C(I))  

Cite

Citation Scheme:

        

Citations by CSL (citeproc-js)

Usage Statistics

Share

Embed

Customize your widget with the following options, then copy and paste the code below into the HTML of your page to embed this item in your website.
                        
                            <div id="ubcOpenCollectionsWidgetDisplay">
                            <script id="ubcOpenCollectionsWidget"
                            src="{[{embed.src}]}"
                            data-item="{[{embed.item}]}"
                            data-collection="{[{embed.collection}]}"
                            data-metadata="{[{embed.showMetadata}]}"
                            data-width="{[{embed.width}]}"
                            async >
                            </script>
                            </div>
                        
                    
IIIF logo Our image viewer uses the IIIF 2.0 standard. To load this item in other compatible viewers, use this url:
http://iiif.library.ubc.ca/presentation/dsp.831.1-0052535/manifest

Comment

Related Items