One issue which is important to know about when dealing with the extensive properties of streams (e.g. the heat balances of a process) is what ChemApp takes into account when it calculates these properties and returns them through TQSTXP.
As a general rule with all versions of ChemApp prior to 3.2.0, the extensive properties of streams can only be retrieved after an equilibrium calculation has been performed. As of version 3.2.0 of ChemApp, TQSTXP can also be called before the equilibrium calculation.
The values of the extensive properties are always calculated based on the initial composition of the streams. ChemApp of course can not and must not alter the composition of the streams, as input by the user.
Example: For a stream "O2H2_Gas" at room temperature which consists of 50% O2 and 50% H2, the extensive properties are calculated for exactly this composition.
This means that ChemApp does not put any stream into equilibrium, not even phase-internal. If ChemApp would put the stream mentioned above into equilibrium, H2O would certainly be stable, which would change for instance the enthalpy of the stream drastically.
If a stream is to be put into equilibrium, regardless of whether it consists of one or more phases, this has to be done explicitly in a separate calculation. This might require that other phases of the system need to be set dormant, if their formation is not compatible with the type of stream (example: a liquid slag stream without any precipitated solid phases). This is equivalent to the assumption that the stream in question may only be in a metastable equilibrium.
In calculating the extensive properties of streams, the following contributions are considered:
Although ChemApp does not put the streams into equilibrium, this does not necessarily mean that it treats the streams as mechanical mixtures, since within-phase excess terms are considered.
For substances in streams to be treated as mechanical mixtures, one should define a separate stream for each part of the mixture, unless it is made sure that the various parts of the mechanical mixture are input through separate phases (e.g. CaO(solid) and SiO2/SLAG/).
Sometimes it is desirable to define a stream based on the elemental analysis of the phases it consists of. As an example, assuming one performs calculations in the Pb-Sn system, using the data-file pbsn.dat (see Appendix H.5) for this purpose, it is straightforward to define a stream which consists of a certain amount of FCC phase. Since the phase constituents of the FCC phase are Pb and Sn, i.e. they are identical to the system components, the composition of the FCC stream can immediately be set using TQSTCA based on an elemental analysis, for instance 0.2 mol Pb and 0.8 mol Sn.
If, on the other hand, the same is to be done with a phase whose constituents are not the elements, an intermediate calculation might be the best way to allow for the input of an elemental analysis. As an example, the data-file for the system Fe-C (see Appendix H.3) is considered, in particular the BCC_A2 phase. This phase is modelled using the sublattice model, in which case the phase constituents are not elements.
In order to still be able to define a stream which consists of the phase BCC_A2 at a certain elemental composition, the following calculation method is employed:
The following code example demonstrates this case.
C Using streams (advanced topics)
PROGRAM CAF201 IMPLICIT NONE
INTEGER NOERR, IBCC, IFE, IC, I, NPHASE, * numcon, nopc
DOUBLE PRECISION VAL, VALS(2), TP(2)
C Initialise ChemApp CALL TQINI(NOERR)
C Open data-file for reading CALL TQOPNA('fec.dat', 10, NOERR)
C Read data-file CALL TQRFIL(NOERR)
C Close data-file CALL TQCLOS(10, NOERR)
C Get the index number of the BCC phase. It is actually called 'BCC_A2', C but since 'BCC' is a unique abbreviation, it will do. CALL TQINP('BCC ', IBCC, NOERR)
C Get the number of phases in the data-file CALL TQNOP(NPHASE, NOERR)
C Eliminate all phases except BCC from the calculation DO I=1, NPHASE IF (I .NE. IBCC) CALL TQCSP(i, 'eliminated', noerr) ENDDO
C Enter the equilibrium temperature. It does not really matter which C temperature is entered for this intermediate equilibrium calculation C using global conditions, since BCC is the only phase which has not C been eliminated. CALL TQSETC('T ', 0, 0, 800.D0, NUMCON, NOERR)
C Get the index numbers of the system components Fe and C CALL TQINSC('Fe ', IFE, NOERR) CALL TQINSC('C ', IC, NOERR)
C Enter the incoming amounts. In our example, an alloy consisting of C 99.999 mol-% Fe, rest C. CALL TQSETC('ia ', 0, IFE, 0.99999D0, NUMCON, NOERR) CALL TQSETC('ia ', 0, IC, 0.00001D0, NUMCON, NOERR)
C Calculate the equilibrium CALL TQCEL(' ', 0, 0, VALS, NOERR)
Output:
T = 800.00 K P = 1.00000E+00 bar V = 0.00000E+00 dm3 |
C As can be seen from the above output table, the BCC phase is the C only one which is stable, since all others have been eliminated.
C Before the final calculation using streams is performed, remove all C previously set conditions. CALL TQREMC(-2, NOERR)
C Remove all streams too, in case any have been defined previously. CALL TQSTRM(' ',NOERR)
C Include all phases in the equilibrium calculation again. DO I=1, NPHASE CALL TQCSP(i, 'entered', NOERR) ENDDO
C Define a stream called 'STREAM_BCC' at 300 K and 1 bar TP(1) = 300.D0 TP(2) = 1.D0 CALL TQSTTP('STREAM_BCC ', TP, NOERR)
C Get the number of phase constituents in the BCC phase CALL TQNOPC(IBCC, NOPC, NOERR)
C Now, retrieve all equilibrium amounts of the BCC phase constituents C from the previous equilibrium calculation and input them as stream C constituents in the BCC stream DO I=1, NOPC CALL TQGETR('a ', IBCC, I, VAL, NOERR) CALL TQSTCA('STREAM_BCC ', IBCC, I, VAL, NOERR) ENDDO
C Calculate the equilibrium CALL TQCEL(' ', 0, 0, VALS, NOERR)
Output:
T = 800.00 K P = 1.00000E+00 bar V = 0.00000E+00 dm3 |
C As can be seen from the bottom of the above output table, the mole C fractions of the system components in the BCC phase are, as intended, C the same as in the first calculation.
10 CONTINUE
END
The following points should be noted with respect to this method and the above code:
When calculations are made under constant product volume by using the option 'VT' of the subroutines TQSETC or TQSTEC, ChemApp will make a global minimisation of the Gibbs energy, changing the total pressure in accordance with the given volume. This is, however, a calculation which in rare occasions might fail to converge, for instance when for the given input the volume exhibits a discontinuous change at the appearance or disappearance of phases and the entered product volume lies within the interval of the discontinuity.
If the same situation would appear during a target calculation with volume as target and pressure as target variable, then ChemApp will weigh all numbers on both sides of the discontinuity and a converged solution will be obtained.
Because of these problems related to constant volume calculations, the decision has been made to delete 'VT' as a possible option for TQSETC and TQSTEC in future versions of ChemApp. In all application programs where it is currently being used, the option 'VT' should be replaced by option 'V', such defining a target calculation. Note that this does not affect the subroutine TQGETR and its option 'VT' in any way (see below).
The following is an example of how this can be done.
C Performing volume target calculations instead of calculations at C constant volume
C Note that this program contains target calculations, C which cannot be performed with the 'light' version of ChemApp
PROGRAM CAF210 IMPLICIT NONE
INTEGER NOERR, NUMCON, ISIO2, IC, ISLITE DOUBLE PRECISION VALS(2), RESULT
C Initialise ChemApp CALL TQINI(NOERR)
C Open data-file for reading CALL TQOPNA('cosi.dat', 10, NOERR)
C Read data-file CALL TQRFIL(NOERR)
C Close data-file CALL TQCLOS(10, NOERR)
C 1) Equilibrium calculation at constant volume. While ChemApp will be C able to converge and find a solution for this particular calculation, C similar calculations with more complex data-files, especially those C containing molar volume data, might make it impossible for ChemApp to C find the equilibrium. For this reason, the use of constant volume C calculations using the option 'VT' with TQSETC is discouraged, C instead, use the calculation method outlined below in 2). Future C versions of ChemApp will have the option 'VT' disabled.
C Set conditions for an equilibrium calculation at constant volume: C temperature, incoming amounts, and volume.
C Set temperature to 1900 K CALL TQSETC('T ', 0, 0, 1900.D0, NUMCON, NOERR)
C Set incoming amounts: 1 mol SiO2(quartz) and 2 mol C C Get phase index numbers for both phases and set their amounts CALL TQINP('SiO2(quartz)', ISIO2, NOERR) CALL TQSETC('IA ', ISIO2, 1, 1.D0, NUMCON, NOERR)
CALL TQINP('C ', IC, NOERR) CALL TQSETC('IA ', IC, 0, 2.D0, NUMCON, NOERR)
C Use option 'VT' to set the volume to 100 dm^3. Setting the volume to a C constant value means ChemApp will calculate the resulting pressure. CALL TQSETC('VT ', 0, 0, 100.D0, NUMCON, NOERR)
C Calculate the equilibrium. CALL TQCEL(' ', 0, 0, VALS, NOERR)
Output:
T = 1900.00 K P = 2.14173E+00 bar V = 1.00000E+02 dm3 |
C Use TQGETR with its option 'VT' to get the calculated total C volume. CALL TQGETR('VT ', 0, 0, RESULT, NOERR)
10 FORMAT(1X,A,G12.5,A) WRITE(*,FMT=10) 'Equilibrium volume (total): ', RESULT, ' dm^3'
Output:
Equilibrium volume (total): 100.00 dm^3 |
C Check if we are working with the 'light' version. C If we do, omit the following target calculation(s). CALL TQLITE(ISLITE, NOERR) IF (ISLITE .EQ. 1) THEN WRITE(*,FMT='(3(1X,A,/))') * '*** Target calculations have been omitted here,', * '*** since they are not possible with the ', * '*** ''light'' version of ChemApp.'
ELSE
C 2) Equilibrium calculation with volume as target and pressure as C target variable. This is the recommended method, as ChemApp is able to C take discontinuities in volume properly into account and obtain a C converged solution. The only difference in defining this calculation C compared to the one above is the use of option 'V' instead of 'VT', C and the specification of the target variable (pressure) when calling C TQCEL.
C First, reset all previous conditions CALL TQREMC(-2, NOERR)
C Set temperature to 1900 K CALL TQSETC('T ', 0, 0, 1900.D0, NUMCON, NOERR)
C Set incoming amounts: 1 mol SiO2(quartz) and 2 mol C CALL TQSETC('IA ', ISIO2, 1, 1.D0, NUMCON, NOERR) CALL TQSETC('IA ', IC, 0, 2.D0, NUMCON, NOERR)
C Use option 'V' to define a volume of 100 dm^3 as the target for the C next equilibrium calculation CALL TQSETC('V ', 0, 0, 100.D0, NUMCON, NOERR)
C Calculate the equilibrium, using the pressure as target variable with C an initial estimate of 1 bar VALS(1) = 1.D0 CALL TQCEL('P ', 0, 0, VALS, NOERR)
Output:
T = 1900.00 K *P = 2.14178E+00 bar V = 1.00000E+02 dm3 |
C As you can see from the two output tables produced by the calls to C TQCEL, the only difference is the asterisk that marks the target C variable (pressure) in the second table. All calculated values are C otherwise the same.
C Use TQGETR with its option 'VT' to get the calculated total C volume. Note that TQGETR's option 'VT' is _not_ related to C TQSETC/TQSTEC's option 'VT'. The latter only specifies that the total C volume of the system should be _retrieved_, and can always be C used. The use of TQGETR's option 'VT' need not be changed in any way C or discontinued with any future version of ChemApp. CALL TQGETR('VT ', 0, 0, RESULT, NOERR)
WRITE(*,FMT=10) 'Equilibrium volume (total): ', RESULT, ' dm^3'
Output:
Equilibrium volume (total): 100.000 dm^3 |
ENDIF END
ChemApp Programmer's Manual, Edition 3.6 | © GTT-Technologies, 2003 |