## 5.5: TQMAP

`TOC``Group 5``TQCENL``TQMAPL``Group 1``A-Z``Group 5`

### CALCULATE-ONE-DIMENSIONAL-PHASE-MAP

Use TQMAP to perform a one-dimensional phase mapping calculation, giving all phase transitions within a defined interval.

### Synopsis

FORTRAN: `CALL TQMAP(OPTION,INDEXP,INDEXC,VALS,ICONT,NOERR)`

C: `tqmap(option,indexp,indexc,vals,&icont,&noerr)`;

Pascal: `tqmap(option,indexp,indexc,vals,icont,noerr)`;

Basic: `Call tqmap(option,indexp,indexc,vals,icont,noerr)`

 Name Type Value set on call or returned OPTION CHARACTER Set to a string as shown in Table 21 INDEXP INTEGER Set to the index number for a phase, if necessary INDEXC INTEGER Set to the index number for a constituent, if necessary VALS Array of 2 of DOUBLE PRECISION Set to the lower and upper limits of the search variable ICONT INTEGER Returns a value indicating whether more calls to TQMAP / TQMAPL are necessary NOERR INTEGER Returns an error number

OPTION, INDEXP, INDEXC, and VALS are all input, ICONT and NOERR are output. See Table 21 for the mnemonics of possible search variables. VALS is an array of two double precision values which is always used to pass the lower and upper bounds of the search interval to TQMAP.

The constraints for the two values of VALS entered are: VALS(1) and VALS(2) must not be equal, and VALS(2) must be greater than, or, for incoming amount as search variable, equal to zero. VALS is entered with the default unit, or a unit set using TQCSU (see Chapter 2).

For every one-dimensional phase map, the first two calls to TQMAP return the equilibrium state of the system at VALS(1) and VALS(2) and not results relating to any phase boundary. Beginning with the third and every subsequent call of TQMAP, the output variable ICONT has to be tested. If it does have a positive value, more calls to TQMAP need to be made.

In case incoming amount is the search variable, and incoming amounts for more than one substance need to be defined, all except the last one have to be called using 'IA0' as option to TQMAP. Once 'IAF' is passed for the last incoming amount, the first calculation is made. Subsequently 'IAN' is used as OPTION for all following calls to TQMAP. See the worked example 5 for an example of how to use TQMAP with incoming amount as search variable.

### Examples

 FORTRAN: View plain source code

```
C One-dimensional phase mapping calculation

C Note that this program contains target calculations,
C which cannot be performed with the 'light' version of ChemApp

PROGRAM CAF24
IMPLICIT NONE

INTEGER NOERR, NUMCON, ISLITE, ISIO2, RESNO, ICONT
DOUBLE PRECISION VALS(2), RESULT

RESNO = 0

C Initialise ChemApp
CALL TQINI(NOERR)

CALL TQOPNA('cosi.dat', 10, NOERR)

CALL TQRFIL(NOERR)

C Close data-file
CALL TQCLOS(10, NOERR)

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 Determine the index number for the phase SiO2(quartz)
CALL TQINP('SiO2(quartz) ', ISIO2, NOERR)

C Enter one mol of SiO2
CALL TQSETC('IA ', ISIO2, 0, 1.0D0, NUMCON, NOERR)

C The temperature search interval is supposed to range from 300 to
C 3000 K:
VALS(1) = 300.D0
VALS(2) = 3000.D0

C First call to TQMAP, note the 'F' ('First') in the option parameter
CALL TQMAP('TF ',0,0,VALS,ICONT,NOERR)

C The variable RESNO keeps track of the number of times we called TQMAP:
RESNO = RESNO + 1

C Retrieve and print the temperature, which we know is VALS(1)
CALL TQGETR('T ',0,0,RESULT,NOERR)

100  FORMAT(A,F8.2,A)

WRITE(*,100) '*** Lower interval boundary:', RESULT, ' K'

30 CONTINUE

C TQMAP is called again. Note the 'N' ('Next') in the option
C parameter. If we are at the first phase boundary (RESNO is still 2),
C we call TQMAPL for a change to produce a ChemSage output table...

IF (RESNO .EQ. 2) THEN
WRITE(*,FMT='(A)')
*   '*** ChemSage result table for the first phase boundary found:'
CALL TQMAPL('TN ',0,0,VALS,ICONT,NOERR)
WRITE(*,*)
C ...otherwise we just call TQMAP:
ELSE
CALL TQMAP('TN ',0,0,VALS,ICONT,NOERR)
ENDIF
RESNO = RESNO +1

C Get the temperature...
CALL TQGETR('T ',0,0,RESULT,NOERR)

C ... and print the entry for the result table. If we have called TQMAP
C twice already, we know that we have found a phase boundary. If not, we
C have retrieved the temperature value of the upper interval boundary
C VALS(2):
IF (RESNO .GT. 2) THEN
WRITE(*,100) '*** Phase boundary found at ', RESULT, ' K'
ELSE
WRITE(*,100) '*** Upper interval boundary: ', RESULT, ' K'
ENDIF

C For as long as ICONT is positive, we need to make further calls of
C TQMAP
IF (ICONT .GT. 0) GOTO 30
```

 Output: ```*** Lower interval boundary: 300.00 K *** Upper interval boundary: 3000.00 K *** ChemSage result table for the first phase boundary found: *T = 1140.10 K P = 1.00000E+00 bar V = 0.00000E+00 dm3 STREAM CONSTITUENTS AMOUNT/mol SiO2(quartz) 1.0000E+00 EQUIL AMOUNT MOLE FRACTION FUGACITY PHASE: GAS mol bar SiO 0.0000E+00 6.2502E-01 4.4829E-16 O2 0.0000E+00 2.5088E-01 1.7994E-16 O 0.0000E+00 1.2327E-01 8.8415E-17 SiO2 0.0000E+00 8.3208E-04 5.9681E-19 Si 0.0000E+00 4.4651E-15 3.2026E-30 O3 0.0000E+00 2.4636E-19 1.7670E-34 Si2 0.0000E+00 5.5659E-36 3.9921E-51 Si3 0.0000E+00 NOT CALCD. 6.4667E-69 TOTAL: 0.0000E+00 1.0000E+00 7.1725E-16 mol ACTIVITY SiO2(quartz) 1.0000E+00 1.0000E+00 SiO2(tridymite) 0.0000E+00 1.0000E+00 SiO2(cristobalite) 0.0000E+00 9.9398E-01 SiO2(liquid) 0.0000E+00 6.4439E-01 Si 0.0000E+00 2.5802E-17 ******************************************************************** Cp_EQUIL H_EQUIL S_EQUIL G_EQUIL V_EQUIL J.K-1 J J.K-1 J dm3 ******************************************************************** 7.04991E+01 -8.55398E+05 1.25413E+02 -9.98382E+05 0.00000E+00 Mole fraction of system components: GAS O 6.6667E-01 Si 3.3333E-01 *** Phase boundary found at 1140.10 K *** Phase boundary found at 1738.28 K *** Phase boundary found at 1995.99 K```
```
C With the above example the temperatures of all phase boundaries in a
C system which contains 1 mol of SiO2 have been calculated. Thus the
C phase boundaries determined reflect the stability ranges of the
C various modifications of SiO2. Also note again that the first two
C temperatures determined are _no_ phase boundaries, but the lower and
C upper limit of the search interval (VALS(1) and VALS(2)).
C
C For the first phase boundary found, TQMAPL is called instead of TQMAP,
C thus producing a ChemSage output table. From this ChemSage output
C table it can be seen that at the temperature calculated SiO2
C transforms from the quartz into the tridymite modification.
C
C Refer to the worked example 5 (One-dimensional phase mapping) for a
C further example. This also demonstrates how to obtain information on
C which phases are stable at each of the phase boundaries determined.

ENDIF
END

```

```

/* Program cac24 */
/* One-dimensional phase mapping calculation */

/* Note that this program contains target calculations,
which cannot be performed with the 'light' version of ChemApp */

#include "cacint.h"

int main()
{
LI noerr, numcon, islite, iSiO2, resno=0, icont;
DB vals[2], result;

/* Initialise ChemApp */
tqini(&noerr);

/* Open data-file for reading. */
tqopna("cosi.dat",10,&noerr);

tqrfil(&noerr);

/* Close data-file */
tqclos(10,&noerr);

/* Check if we are working with the 'light' version.
If we do, omit the following target calculation(s). */
tqlite(&islite, &noerr);
if (islite)
{
printf("*** Target calculations have been omitted here,\n"
"*** since they are not possible with the\n"
"*** 'light' version of ChemApp.\n\n");
}
else
{

/* Determine the index number for the phase SiO2(quartz) */
tqinp("SiO2(quartz)", &iSiO2, &noerr);

/* Enter one mol of SiO2 */
tqsetc("IA", iSiO2, 0, 1.0, &numcon, &noerr);

/* The temperature search interval is supposed to range from 300 to
3000 K: */
vals[0] = 300.0;
vals[1] = 3000.0;

/* First call to tqmap, note the "f" ("first") in the option
parameter */
tqmap("tf", 0, 0, vals, &icont, &noerr);

/* The variable resno keeps track of the number of times we call
tqmap: */
resno++;

/* Retrieve and print the temperature, which we know is vals[0]: */
tqgetr("t", 0, 0, &result, &noerr);
printf("*** Lower interval boundary: %g K\n", result);

/* For as long as icont is positive, we need to make further calls
of tqmap */
while (icont) {

/* tqmap is called again. Note the "n" ("next") in the option
parameter. If we are at the first phase boundary (resno is
still 2), we call tqmapl for a change to produce a ChemSage
output table... */
if (resno == 2) {
printf("*** ChemSage result table "
"for the first phase boundary found:\n");
tqmapl("tn", 0, 0, vals, &icont, &noerr);
printf("\n");

/* ...otherwise we just call tqmap: */
} else {
tqmap("tn", 0, 0, vals, &icont, &noerr);
}
resno++;

/* Get the temperature... */
tqgetr("t", 0, 0, &result, &noerr);

/* ...and print the entry for the result table. If we have called
tqmap twice already, we know that we have found a phase
boundary. If not, we have retrieved the temperature value of
the upper interval boundary (vals[1]): */

if (resno > 2) {
printf("*** Phase boundary found at %g K\n", result);
} else {
printf("*** Upper interval boundary: %g K\n", result);
}

}

```

 Output: ```*** Lower interval boundary: 300 K *** Upper interval boundary: 3000 K *** ChemSage result table for the first phase boundary found: *T = 1140.10 K P = 1.00000E+00 bar V = 0.00000E+00 dm3 STREAM CONSTITUENTS AMOUNT/mol SiO2(quartz) 1.0000E+00 EQUIL AMOUNT MOLE FRACTION FUGACITY PHASE: GAS mol bar SiO 0.0000E+00 6.2502E-01 4.4829E-16 O2 0.0000E+00 2.5088E-01 1.7994E-16 O 0.0000E+00 1.2327E-01 8.8415E-17 SiO2 0.0000E+00 8.3208E-04 5.9681E-19 Si 0.0000E+00 4.4651E-15 3.2026E-30 O3 0.0000E+00 2.4636E-19 1.7670E-34 Si2 0.0000E+00 5.5659E-36 3.9921E-51 Si3 0.0000E+00 NOT CALCD. 6.4667E-69 TOTAL: 0.0000E+00 1.0000E+00 7.1725E-16 mol ACTIVITY SiO2(quartz) 1.0000E+00 1.0000E+00 SiO2(tridymite) 0.0000E+00 1.0000E+00 SiO2(cristobalite) 0.0000E+00 9.9398E-01 SiO2(liquid) 0.0000E+00 6.4439E-01 Si 0.0000E+00 2.5802E-17 ******************************************************************** Cp_EQUIL H_EQUIL S_EQUIL G_EQUIL V_EQUIL J.K-1 J J.K-1 J dm3 ******************************************************************** 7.04991E+01 -8.55398E+05 1.25413E+02 -9.98382E+05 0.00000E+00 Mole fraction of system components: GAS O 6.6667E-01 Si 3.3333E-01 *** Phase boundary found at 1140.1 K *** Phase boundary found at 1738.28 K *** Phase boundary found at 1995.99 K```
```
/* With the above example the temperatures of all phase boundaries in a
system which contains 1 mol of SiO2 have been calculated. Thus the
phase boundaries determined reflect the stability ranges of the
various modifications of SiO2. Also note that the first two
temperatures determined are _no_ phase boundaries, but the lower and
upper limit of the search interval (vals[0] and vals[1]).

For the first phase boundary found, tqmapl is called instead of
tqmap, thus producing a ChemSage output table. From this ChemSage
output table it can be seen that at the temperature calculated
SiO2 transforms from the quartz into the tridymite modification.

Refer to the worked example 5 (One-dimensional phase mapping) for
a further example. This also demonstrates how to obtain
information on which phases are stable at each of the phase
boundaries determined. */

}

return 0;

}

```

 ChemApp Programmer's Manual, Edition 3.6 © GTT-Technologies, 2003