Appendix B: Advanced topics



B.1: Extensive properties of streams

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/).



B.2: When phase constituents are not elements

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:

  1. Perform a calculation using global conditions, using the system components, which are the elements, to specify the incoming amounts, and eliminate all phases except BCC_A2 from the calculation.

  2. Retrieve the equilibrium composition of the phase BCC_A2 in terms of all of its phase constituents (Fe:C and Fe:Va), and use these amounts to define the constituents of the BCC_A2 stream using TQSTCA.

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

STREAM CONSTITUENTS AMOUNT/mol Fe 9.9999E-01 C 1.0000E-05
EQUIL AMOUNT MOLE FRACTION ACTIVITY PHASE: BCC_A2 mol Fe:C 3.3333E-06 3.3334E-06 3.2918E-27 Fe:Va 9.9999E-01 1.0000E+00 7.4652E-01 TOTAL: 9.9999E-01 1.0000E+00 1.0000E+00 ******************************************************************** Cp_EQUIL H_EQUIL S_EQUIL G_EQUIL V_EQUIL J.K-1 J J.K-1 J dm3 ******************************************************************** 3.92040E+01 1.55840E+04 5.68631E+01 -2.99065E+04 0.00000E+00
Mole fraction of sublattice constituents in BCC_A2: Fe 1.0000E+00 Stoichiometry = 1.0000E+00 --------------------------------------------------------------- C 3.3334E-06 Stoichiometry = 3.0000E+00 Va 1.0000E+00
Magnetic properties for BCC_A2: Curie temperature = 1043.00 K Average magnetic moment/atom = 2.2200E+00
Mole fraction of system components: BCC_A2 Fe 9.9999E-01 C 1.0000E-05

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

STREAM CONSTITUENTS AMOUNT/mol TEMPERATURE/K PRESSURE/bar STREAM Fe:C/BCC_A2/ 3.3333E-06 300.00 1.0000E+00 1 Fe:Va/BCC_A2/ 9.9999E-01 300.00 1.0000E+00 1
EQUIL AMOUNT MOLE FRACTION FUGACITY PHASE: GAS mol bar Fe 0.0000E+00 1.0000E+00 5.8156E-20 C 0.0000E+00 1.2312E-20 7.1600E-40 C3 0.0000E+00 2.7925E-31 1.6240E-50 C2 0.0000E+00 9.3191E-32 5.4196E-51 C4 0.0000E+00 8.2701E-43 4.8095E-62 C5 0.0000E+00 4.2112E-44 2.4491E-63 C6 0.0000E+00 NOT CALCD. <1.0000E-75 C7 0.0000E+00 NOT CALCD. <1.0000E-75 TOTAL: 0.0000E+00 1.0000E+00 5.8156E-20 PHASE: LIQUID mol MOLE FRACTION ACTIVITY C 0.0000E+00 1.0635E-01 1.4608E-07 Fe 0.0000E+00 8.9365E-01 2.6887E-01 TOTAL: 0.0000E+00 1.0000E+00 3.1890E-01 PHASE: BCC_A2 mol MOLE FRACTION ACTIVITY Fe:C 3.3333E-06 3.3334E-06 3.2918E-27 Fe:Va 9.9999E-01 1.0000E+00 7.4652E-01 TOTAL: 9.9999E-01 1.0000E+00 1.0000E+00 PHASE: FCC_A1 mol MOLE FRACTION ACTIVITY FeC 0.0000E+00 3.7560E-03 1.7392E-05 Fe 0.0000E+00 9.9624E-01 8.1417E-01 TOTAL: 0.0000E+00 1.0000E+00 8.1730E-01 mol ACTIVITY C_GRAPHITE 0.0000E+00 3.4778E-01 Fe3C_CEMENTITE 0.0000E+00 1.1965E-01 ******************************************************************** DELTA_Cp DELTA_H DELTA_S DELTA_G DELTA_V J.K-1 J J.K-1 J dm3 ******************************************************************** 1.43137E+01 1.55369E+04 2.94283E+01 -2.17231E+04 0.00000E+00
Mole fraction of sublattice constituents in BCC_A2: Fe 1.0000E+00 Stoichiometry = 1.0000E+00 --------------------------------------------------------------- C 3.3334E-06 Stoichiometry = 3.0000E+00 Va 1.0000E+00
Magnetic properties for BCC_A2: Curie temperature = 1043.00 K Average magnetic moment/atom = 2.2200E+00
Magnetic properties for FCC_A1: Neel temperature = 67.00 K Average magnetic moment/atom = 7.0000E-01
Mole fraction of system components: GAS BCC_A2 FCC_A1 Fe 1.0000E+00 9.9999E-01 9.9626E-01 C 1.2312E-20 1.0000E-05 3.7419E-03

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:

  1. Using an intermediate equilibrium calculation using elements to define the incoming amounts, in order to determine the constituent amounts for the input to a subsequent stream calculation might not only be necessary when the solution phase in question is modeled according to the sublattice formalism. Even for a gas phase this might be necessary, for instance if the gas phase contains constituents like O2 and O3, but no monoatomic O. This case already makes it difficult to input the constituent amounts for a gas stream if they are to be entered based on an elemental analysis.

  2. In the above code, the fact that phases might be labelled DORMANT or ELIMINATED in the data-file has been neglected for simplicity. To make the code independent of such cases, the original state of all the phases, as stated in the data-file and as present immediately after loading of the data-file, should be taken into account.

  3. Since such a calculation is normally only one of many in a larger framework, care should be taken to remove all previously set conditions before performing the intermediate calculation. If this is not done, the stream defined might contain more material than intended.



B.3: Equilibrium calculations at constant volume

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

STREAM CONSTITUENTS AMOUNT/mol SiO2(quartz) 1.0000E+00 C 2.0000E+00
EQUIL AMOUNT MOLE FRACTION FUGACITY PHASE: GAS mol bar CO 1.3387E+00 9.8746E-01 2.1149E+00 SiO 1.6841E-02 1.2422E-02 2.6604E-02 CO2 1.5690E-04 1.1573E-04 2.4786E-04 Si 3.5988E-07 2.6545E-07 5.6852E-07 SiO2 2.5279E-08 1.8646E-08 3.9935E-08 Si2C 6.1745E-09 4.5544E-09 9.7542E-09 Si2 1.5027E-10 1.1084E-10 2.3740E-10 O 1.2476E-11 9.2022E-12 1.9709E-11 SiC 3.3631E-12 2.4807E-12 5.3129E-12 Si3 1.5088E-12 1.1129E-12 2.3835E-12 C 1.4781E-12 1.0903E-12 2.3351E-12 C3 6.4685E-13 4.7712E-13 1.0219E-12 C2 5.5328E-14 4.0811E-14 8.7405E-14 O2 2.7271E-15 2.0116E-15 4.3082E-15 O3 6.0308E-30 4.4484E-30 9.5272E-30 TOTAL: 1.3557E+00 1.0000E+00 1.0000E+00 mol ACTIVITY SiC 6.6111E-01 1.0000E+00 SiO2(cristobalite) 3.2205E-01 1.0000E+00 SiO2(tridymite) 0.0000E+00 9.9918E-01 SiO2(liquid) 0.0000E+00 9.7125E-01 SiO2(quartz) T 0.0000E+00 9.0635E-01 C 0.0000E+00 7.4034E-01 Si 0.0000E+00 4.6870E-02 ******************************************************************** Cp_EQUIL H_EQUIL S_EQUIL G_EQUIL V_EQUIL J.K-1 J J.K-1 J dm3 ******************************************************************** 1.08323E+02 -3.33861E+05 4.57839E+02 -1.20376E+06 1.00000E+02
Mole fraction of system components: GAS C 4.9376E-01 O 5.0003E-01 Si 6.2106E-03
Data on 1 constituent marked with 'T' are extrapolated outside their valid temperature range

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

STREAM CONSTITUENTS AMOUNT/mol SiO2(quartz) 1.0000E+00 C 2.0000E+00
EQUIL AMOUNT MOLE FRACTION FUGACITY PHASE: GAS mol bar CO 1.3387E+00 9.8745E-01 2.1149E+00 SiO 1.6863E-02 1.2438E-02 2.6639E-02 CO2 1.5684E-04 1.1569E-04 2.4778E-04 Si 3.6047E-07 2.6588E-07 5.6946E-07 SiO2 2.5305E-08 1.8665E-08 3.9975E-08 Si2C 6.1848E-09 4.5618E-09 9.7704E-09 Si2 1.5062E-10 1.1110E-10 2.3795E-10 O 1.2484E-11 9.2081E-12 1.9722E-11 SiC 3.3665E-12 2.4831E-12 5.3182E-12 Si3 1.5133E-12 1.1162E-12 2.3907E-12 C 1.4786E-12 1.0906E-12 2.3358E-12 C3 6.4621E-13 4.7664E-13 1.0209E-12 C2 5.5310E-14 4.0796E-14 8.7377E-14 O2 2.7281E-15 2.0122E-15 4.3097E-15 O3 6.0308E-30 4.4483E-30 9.5272E-30 TOTAL: 1.3558E+00 1.0000E+00 1.0000E+00 mol ACTIVITY SiC 6.6110E-01 1.0000E+00 SiO2(cristobalite) 3.2204E-01 1.0000E+00 SiO2(tridymite) 0.0000E+00 9.9918E-01 SiO2(liquid) 0.0000E+00 9.7125E-01 SiO2(quartz) T 0.0000E+00 9.0635E-01 C 0.0000E+00 7.3985E-01 Si 0.0000E+00 4.6901E-02 ******************************************************************** Cp_EQUIL H_EQUIL S_EQUIL G_EQUIL V_EQUIL J.K-1 J J.K-1 J dm3 ******************************************************************** 1.08323E+02 -3.33851E+05 4.57845E+02 -1.20376E+06 1.00000E+02
Mole fraction of system components: GAS C 4.9375E-01 O 5.0003E-01 Si 6.2188E-03
Data on 1 constituent marked with 'T' are extrapolated outside their valid temperature range

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