APPENDIX A


EQUILIBRIUM PROGRAM DESCRIPTION


The program consists of a main program and twelve subroutines (Appendix K). The program requires approximately 65 K of core without the use of DOUBLE PRECISION statements and can consider 100 species for each problem. This number can be increased in order to consider more species or decreased in order to reduce the core size and to allow the program to be used on a smaller machine by changing the size of the variables in labeled common SPECES, the variables VOL and GAMMA in labeled common MISC, DIMENSION statements in subroutines SEARCH, EQLBRM, and CPHS, and the do loop limit for zeroing A(I,J) in subroutine SEARCH. A description of the output (Appendix L) can be found in Gordon and McBride (1971). The variable names referred to below (listed in capital letters) are described in the following appendices.



Main Program


The routine performs the following functions:
1. Initializes NEWMOL, NOCONV, TEM, ALTER, SYSTM, PLUS, NOMIT, R, NSERT, NMIN, and NPT to zero or FALSE.
2. Read the coefficient cards and stores them on tape 4 if the coefficients are not already on tape.
3. Calls subroutine REACT which reads the reactant cards.
4. Reads and stores species on OMIT cards
5. Reads and stores species on INSER cards.
6. Reads case number, RSIZE value, TRI value, TEM declaration, and the T-P values to be considered.
7. Counts the number of P-T values and stores the number in NP and NT.
8. Calls subroutine SEARCH to select and store species being considered in SUB and COEF arrays.
9. Calls subroutine THERMP to set the P-T values being considered.



Subroutine REACT


This subroutine is called from MAIN and MOLEWT. When it is called from MAIN, it reads the reactant cards and stores the element symbols in the LLMT array. This subroutine also stores the number of elements in NLM and the number of reactant cards in NREAC. It then computes the mole





44




Click Here for Figure 13 - Flow diagram for main routine.




45




fraction of each element by the use of the following formula:



Formula 21


It also determines what type of mixture problem Is being considered (see MOLEWT). REACT will store the number of elements to be stored for later use in NMIN if a PLUS or SYSTM problem is being considered. It is called from MOLEWT everytime a new base value is computed and only computes the new mole fractions. REACT will reset NMIN if necessary.

Subroutine SEARCH

SEARCH is called from MAIN and MOLEWT. When called from MAIN, it searches all the thermodynamic data stored on tape 4 to select the species which are to be considered in the present system and stores them in core. If more than 100 species are selected, an error message is printed and the program goes on to a new program. SEARCH also stores the total number of species being considered in NS and the number of condensed species in NC. The IUSE array is initialized as zero for gases or -I (I = 1,....,NC) for condensed species. Different condensed phases of the same species have equal I values. For example, if IUSEj for alpha-quartz equals -4, then lUSEj+1 for beta-quartz would equal -4. In PLUS and SYSTM problems, species which are to be considered at a later time are put into temporary storage on tape 3.

If SEARCH is called from MOLEWT, it searches tape 3 for species to be considered, stores species to be removed from the present system on tape 3, and resets the NS and NC values.

Subroutine EQLBRM

This computes the equilibrium compositions for the current T-P point and is called from THERMP. EQLBRM has been modified to select a phase of a condensed species that fits in the current T range by use of the JUSE array. If JUSEj is negative, the current T is within the T range of the species. By use of the JUSE array, EQLBRM decides if a species should be removed from the current system. EQLBRM calls FCOEFF to calculate the fugacity coefficients (ln γ) of certain gases. It then calls CPHS to calculate the thermodynamic properties of the species and MATRIX and GAUSS to set up and solve the matrix. After calling GAUSS it checks for the existence of a singular matrix and attempts to correct it, if this is the case. After the matrix has been solved, the control factor λ is calculated, corrections are applied to estimates, and tests for convergence are made. After convergence has been achieved the routine begins to add or remove one condensed species at a time. When no more condensed species can be added or removed, and convergence has been achieved, EQLBKM returns control to THERMP to set up a new P, T or composition point.





46




Click Here for Figure 14 - Subroutine EQLBRM flow diagram.


Click Here for Figure 14 - Continued.




47




Click Here for Figure 14 - Continued.




48




Click Here for Figure 14 - Continued.




49




Subroutine CPHS

This routine is called from EQLBKM and is used to calculate the thermodynamic properties of the species; dimensionless enthalpy and entropy, which are stored in the HO and S arrays. A modification was made so that the routine could consider different phases with the same composition over one T range. The program selects the species with the minimum Gj value. The other phases will then be given a positive JUSEj value to prevent them from being considered in the present system.

Subroutine MATRIX

This routine computes the elements of a symmetrical matrix (Table 2) and stores them in their proper location. Only the upper diagonal matrix is set up in this routine and reflected to the lower part in GAUSS. The only alterations made to this routine were the inclusion of fugacity coefficient (ln γ) in the gas equations and molar volume (V) in the condensed species equations.

Subroutine FCOEFF

FCOEFF is called from EQLBRM and was written by Dr. J. R. Holloway. The routine calculates ln γ (GAMMAj) using data and equations from Holloway et al. (1971) for H2O, Shaw and Wones (1964) for H2, and Edminster (1968) for O2, N2, CO, CO2, CH4, and NH3. At P < 100 bars, ln γ is set to zero for all species. At pressures > 100 bars. ln γ is set to zero for all gaseous species other than the ones listed.

Subroutine GAUSS

This routine is called from EQLBKM to solve a set of simultaneous linear iteration equations constructed by MATRIX. The answers are stored in Xjj). There have been no modifications to this routine. A more detailed description can be found in Gordon and McBride (1971).

Subroutine OUT1

OUT1 is called from THERMP and is used to print out the results of up to nine P-T points. Output format is stored in the FMT array and altered to fit the data being printed. This routine was modified so it would print out the mole fractions of species with values less than 5 x 10-6. OUT1 computes the values and then prints out the ln nj values

Subroutine VARFMT

VARFMT is called from OUT1 to make adjustments to the FMT array for controlling the number of decimal points printed out in the P values





50




Click Here for Table 2 - Iteration equations to determine equilibrium compositions.




51




Subroutine THEKMP

THERMP is called from MAIN to select the P-T pair from the Pj and Tj arrays to be considered in the current point (NPT). NPT is increased each time the program considers a new T-P point. THERMP calls EQLBKM to compute the equilibrium composition after selecting the P-T pair. OUT1 is called when nine points have been computed or when all the P-T pairs have been computed for the present mole fraction point of the reactants. The routine has had the following modifications made to it: Instead of going on to a new problem when there is no solution to the last point, it now goes on to the next P-T pair. THERMP will decide if a new mole fraction ratio should be computed or if the program should go on to a new problem. Instead of calling SAVE to save or use previous compositions, the routine uses the composition of the previous point when only T has been changed. THERMP will call INIT to reset the initial estimates if a new P is being considered.

Subroutine MOLEWT

MOLEWT was added to the original program to compute new BASE values for the reactants. This routine will handle four types of problems. It will alter the values between the reactants without adding or removing any reactants. It will consider a ternary system by considering first two, then all three components simultaneously. This modification involved making changes to REACT to re-compute the mole fractions every time a new BASE value was set, and to SEARCH to either store species to be considered later or remove species from storage. MOLEWT will also consider a ternary system where all three reactants are in the system at the same time at the start. The fourth type of problem involves starting out with n reactants and adding one reactant at a time until all the reactants have been added. MOLEWT calls REACT and INIT every time a new BASE value is computed. SEARCH is called only when a reactant is added or removed from the system.

Subroutine INIT

This routine is called from MAIN, EQLBRM, and MOLEWT. It sets the initial estimates when called from MAIN, and resets the initial estimates when called from EQLBRM and MOLEWT. A more detailed explanation of the function of this routine can be found in Gordon and McBride (1971) under Initial Estimates.





52



This site built and hosted for free by FreeWebs.com. Click here to get your own free website.