4.1: TQSETC

TOCGroup 4TQCSPCTQREMCGroup 5A-ZGroup 4

SET-EQUILIBRIUM-CONDITION

Use TQSETC to set a condition for the equilibrium calculation.

Synopsis

FORTRAN: CALL TQSETC(OPTION,INDEXP,INDEX,VAL,NUMCON,NOERR)

C: tqsetc(option,indexp,index,val,&numcon,&noerr);

Pascal: tqsetc(option,indexp,index,val,numcon,noerr);

Basic: Call tqsetc(option,indexp,index,val,numcon,noerr)


Name Type Value set on call or returned
OPTION CHARACTER Set to a string as shown in Table 13
INDEXP INTEGER Set to the index number for a phase, if necessary
INDEX INTEGER Set to the index number for a constituent or component, if necessary
VAL DOUBLE PRECISION Set to the value of the condition
NUMCON INTEGER Returns a number for the condition
NOERR INTEGER Returns an error number

OPTION, INDEXP, INDEX, and VAL are all input. NUMCON is output. The possible state variables are shown in Table 13, and possible values of INDEXP and INDEX in Table 14. VAL is entered with the default unit, or a unit set using TQCSU (see Chapter 2). Each condition with respect to incoming amount, chemical potential, or relative activity is given a unique number (NUMCON). This number can later be used to remove any of these conditions (see TQREMC).

Normally two state variables, such as temperature and pressure, as well as one condition for the amount of each component of the actual system are necessary to define a calculation. The latter condition can also be fulfilled by defining incoming amounts of any number of constituents. Note that the input amounts entered do not have to include all the elements contained in the data-file. A previous value is replaced if incoming amounts for the same constituent are entered twice.

ChemApp defines a constituent for which chemical potential or relative activity is entered as incoming. The incoming amount (negative or positive) that corresponds to the condition set is calculated and the results can be retrieved using TQGETR. When any other variable than pressure (volume), temperature, or input composition is defined as an equilibrium condition, for example, enthalpy or the amount of a phase, a target variable has to be entered upon calling TQCE, see Chapter 5. Note that TQSETC and TQSTCA/TQSTEC cannot be used interchangeably for setting conditions.

Note that some solution phase models might not permit the usage of their phase constituents as incoming species. TQPCIS can be used to check for these cases.

See also

TQREMC, TQSTEC

Examples

FORTRAN:View plain source code



C Set and remove equilibrium conditions
PROGRAM CAF16 IMPLICIT NONE
INTEGER NOERR, NUMCON, ISIO2, IC, ISIC, ISI 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 Set conditions for a simple equilibrium calculation: temperature and C some incoming amounts.
C Set temperature to 1900 K CALL TQSETC('T ', 0, 0, 1900.D0, NUMCON, NOERR)
C Set incoming amounts: 1 mol SiO2(quartz), 2 mol C, and 3 mol SiC
C Get phase index numbers for all 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)
CALL TQINP('SiC ', ISIC, NOERR) CALL TQSETC('IA ', ISIC, 0, 3.D0, NUMCON, NOERR)
C Use TQSHOW to check which conditions have been set so far, or are C active by default CALL TQSHOW(NOERR)

Output:
 
 T = 1900.00 K
 P = 1.00000E+00 bar 

STREAM CONSTITUENT SiO2(quartz) AMOUNT/mol = 1.00000E+00 C AMOUNT/mol = 2.00000E+00 SiC AMOUNT/mol = 3.00000E+00

C TQSETC returns a variable (called NUMCON in this example) which can be C used to remove a previously set condition. To do this, pass it to C TQREMC. Here we remove the last condition set, which are the 3 mol of C SiC CALL TQREMC(NUMCON, NOERR)
C Call TQSHOW again to demonstrate that it has been deleted from the C list of active conditions CALL TQSHOW(NOERR)

Output:
 
 T = 1900.00 K
 P = 1.00000E+00 bar 

STREAM CONSTITUENT SiO2(quartz) AMOUNT/mol = 1.00000E+00 C AMOUNT/mol = 2.00000E+00

C Calculate the equilibrium CALL TQCE(' ', 0, 0, VALS, NOERR)
C Get the activity of Si CALL TQINP('Si ', ISI, NOERR) CALL TQGETR('AC ', ISI, 0, RESULT, NOERR)
WRITE(*,FMT='(1X,A,G12.5)') 'Activity of pure Si is ', RESULT

Output:
 Activity of pure Si is  0.79115E-01

END




C:View plain source code




/* Program cac16 */ /* Set equilibrium conditions */
#include "cacint.h"
int main() { LI noerr, numcon, iSiO2, iC, iSiC, iSi; DB vals[2], result;
/* Initialise ChemApp */ tqini(&noerr);
/* Open data-file for reading */ tqopna("cosi.dat",10,&noerr);
/* Read data-file */ tqrfil(&noerr);
/* Close data-file */ tqclos(10,&noerr);
/* Set conditions for a simple equilibrium calculation: temperature and some incoming amounts. */
/* Set temperature to 1900 K */ tqsetc("T", 0, 0, 1900.0, &numcon, &noerr);
/* Set incoming amounts: 1 mol SiO2(quartz), 2 mol C, and 3 mol SiC */
/* Get phase index number for both phases and set their amounts */ tqinp("SiO2(quartz)", &iSiO2, &noerr); tqsetc("ia", iSiO2, 0, 1.0, &numcon, &noerr);
tqinp("C", &iC, &noerr); tqsetc("ia", iC, 0, 2.0, &numcon, &noerr);
tqinp("SiC", &iSiC, &noerr); tqsetc("ia", iSiC, 0, 3.0, &numcon, &noerr);
/* Use tqshow to check which conditions have been set so far, or are active by default */ tqshow(&noerr);

Output:
 
 T = 1900.00 K
 P = 1.00000E+00 bar 

STREAM CONSTITUENT SiO2(quartz) AMOUNT/mol = 1.00000E+00 C AMOUNT/mol = 2.00000E+00 SiC AMOUNT/mol = 3.00000E+00

/* tqsetc returns a variable (called numcon in this example) which can be used to remove a previously set condition. To do this, pass it to tqremc. Here we remove the last condition set, which are the 3 mol of SiC */ tqremc(numcon, &noerr);
/* Call tqshow again to demonstrate that it has been deleted from the list of active conditions */ tqshow(&noerr);

Output:
 
 T = 1900.00 K
 P = 1.00000E+00 bar 

STREAM CONSTITUENT SiO2(quartz) AMOUNT/mol = 1.00000E+00 C AMOUNT/mol = 2.00000E+00

/* Calculate the equilibrium */ tqce(" ", 0, 0, vals, &noerr);
/* Get the activity of Si */ tqinp("Si", &iSi, &noerr); tqgetr("ac", iSi, 0, &result, &noerr);
printf("Activity of pure Si is %g\n", result);

Output:
Activity of pure Si is 0.0791154

return 0;
}


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