GET-RESULT
Use TQGETR to get calculation results obtained by the last call to
TQCE, TQCEL, TQMAP, or TQMAPL.
Synopsis
FORTRAN: CALL TQGETR(OPTION,INDEXP,INDEX,VAL,NOERR)
C: tqgetr(option,indexp,index,&val,&noerr)
;
Pascal: tqgetr(option,indexp,index,val,noerr)
;
Basic: Call tqgetr(option,indexp,index,val,noerr)
Name |
Type |
Value set on call or returned
|
OPTION |
CHARACTER |
Set to a string as shown in Table 19
|
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 or array of DOUBLE PRECISION |
Returns the value(s) for the state variable
|
NOERR |
INTEGER |
Returns an error number
|
OPTION is character input identifying the variable for which the
calculated results are to be returned (see Table
19). The integers INDEXP and INDEX are used to
denote if a single value is expected on return or multiple values (see
Table 18). In the first case, VAL need only be a
variable of type DOUBLE. In the latter case, VAL has to be an array of
appropriate size of DOUBLE PRECISION values. VAL is returned with the
default unit, or a unit set using TQCSU.
Data for any phase that might de-mix (see also Chapter
E.2) is entered twice in a ChemSage thermodynamic
data-file and ChemApp automatically adds '#1' and '#2' to its
name. If results are wanted for a specific composition of the two
mixtures, '#1' indicates the duplicated phase with the higher
activity. Also note that within a miscibility gap, '#1' denotes the
duplicated phase with the higher amount.
See also
TQGDPC
Examples
C Retrieving results from equilibrium calculations
PROGRAM CAF19
IMPLICIT NONE
INTEGER NOERR, ISIO2, ICO2, INDEXP, NSC
DOUBLE PRECISION TP(2), VALS(2), VALUE, VALUES(3)
CHARACTER SCNAME*24
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 Define a sample input stream ('INPUTS')
C Use the array called TP to pass the information on temperature and
C pressure (298.15 K and 1 bar) of the stream to TQSTTP
TP(1) = 298.15D0
TP(2) = 1.D0
CALL TQSTTP('INPUTS ', TP, NOERR)
C Define the amounts of constituents of this stream (1 mol quartz and
C 0.5 mol CO2)
CALL TQINP('SiO2(quartz)', ISIO2, NOERR)
CALL TQSTCA('INPUTS ', ISIO2, 0, 1.D0, NOERR)
CALL TQINPC('CO2 ', 1, ICO2, NOERR)
CALL TQSTCA('INPUTS ', 1, ICO2, 0.5D0, NOERR)
C Set the temperature at which the two streams should react
CALL TQSTEC('T ', 0, 2500.D0, NOERR)
C Calculate the equilibrium
CALL TQCEL(' ', 0, 0, VALS, NOERR)
Output:
T = 2500.00 K
P = 1.00000E+00 bar
V = 1.11190E+02 dm3
STREAM CONSTITUENTS AMOUNT/mol TEMPERATURE/K PRESSURE/bar STREAM
SiO2(quartz) 1.0000E+00 298.15 1.0000E+00 1
CO2/GAS/ 5.0000E-01 298.15 1.0000E+00 1
EQUIL AMOUNT MOLE FRACTION FUGACITY
PHASE: GAS mol bar
CO2 4.3364E-01 8.1066E-01 8.1066E-01
CO 6.6363E-02 1.2406E-01 1.2406E-01
O2 3.2435E-02 6.0635E-02 6.0635E-02
O 1.9270E-03 3.6023E-03 3.6023E-03
SiO 4.3397E-04 8.1128E-04 8.1128E-04
SiO2 1.2540E-04 2.3442E-04 2.3442E-04
O3 T 2.4872E-09 4.6497E-09 4.6497E-09
Si 1.1737E-11 2.1942E-11 2.1942E-11
C 6.4393E-15 1.2038E-14 1.2038E-14
Si2 1.6425E-21 3.0705E-21 3.0705E-21
SiC 6.2162E-22 1.1621E-21 1.1621E-21
C2 1.1943E-22 2.2326E-22 2.2326E-22
Si2C 2.4986E-27 4.6711E-27 4.6711E-27
C3 6.7723E-29 1.2660E-28 1.2660E-28
Si3 1.2802E-30 2.3933E-30 2.3933E-30
TOTAL: 5.3492E-01 1.0000E+00 1.0000E+00
mol ACTIVITY
SiO2(liquid) 9.9944E-01 1.0000E+00
SiO2(cristobalite) 0.0000E+00 8.9012E-01
SiO2(tridymite) T 0.0000E+00 8.5795E-01
SiO2(quartz) T 0.0000E+00 7.4840E-01
C 0.0000E+00 7.1792E-08
Si 0.0000E+00 4.7391E-09
SiC 0.0000E+00 1.5332E-15
********************************************************************
DELTA_Cp DELTA_H DELTA_S DELTA_G DELTA_V
J.K-1 J J.K-1 J dm3
********************************************************************
1.18625E+02 2.53297E+05 2.13883E+02 -6.08043E+05 9.87954E+01
Mole fraction of system components:
GAS
C 3.3296E-01
O 6.6667E-01
Si 3.7249E-04
Data on 3 constituents marked with 'T' are extrapolated outside their valid
temperature range |
50 FORMAT(1X,A,G12.5,A)
C A number of the results retrieved below can also be found in the
C ChemSage result table output above by TQCEL. If you do not want a
C ChemSage result table, for instance because your application program
C has a graphical user interface and cannot make use of the table, call
C TQCE instead to calculate the equilibrium.
C Get the pressure, which is 1 bar, since this is the default.
CALL TQGETR('P ', 0, 0, VALUE, NOERR)
WRITE(*,FMT=50) 'Equilibrium pressure: ', VALUE, ' bar'
Output:
Equilibrium pressure: 1.0000 bar |
C Get the calculated _total_ equilibrium volume
CALL TQGETR('VT ', 0, 0, VALUE, NOERR)
WRITE(*,FMT=50) 'Equilibrium volume (total): ', VALUE, ' dm^3'
Output:
Equilibrium volume (total): 111.19 dm^3 |
C Get the calculated _change_ in volume. Note that options 'V' and 'VT'
C _only_ give different values if streams are used _and_ the whole
C system is selected, in which case 'V' retrieves the _change_ in volume
C between the reaction products and the stream constituents. In all
C other cases, both 'VT' and 'V' give the _total_ volume.
CALL TQGETR('V ', 0, 0, VALUE, NOERR)
WRITE(*,FMT=50) 'Change in volume: ', VALUE, ' dm^3'
Output:
Change in volume: 98.795 dm^3 |
C Get the temperature, which is 2500 K since we set this particular
C condition for the equilibrium calculation
CALL TQGETR('T ', 0, 0, VALUE, NOERR)
WRITE(*,FMT=50) 'Equilibrium temperature: ', VALUE, ' K'
Output:
Equilibrium temperature: 2500.0 K |
C Get the equilibrium amount of liquid SiO2
CALL TQINP('SiO2(liquid)', INDEXP, NOERR)
CALL TQGETR('A ', INDEXP, 0, VALUE, NOERR)
WRITE(*,FMT=50) 'Equilibrium amount of SiO2(liquid): ',
* VALUE, ' mol'
Output:
Equilibrium amount of SiO2(liquid): 0.99944 mol |
C Get the incoming amount of CO2/GAS/ that was input for the last
C equilibrium calculation
CALL TQGETR('IA ', 1, ICO2, VALUE, NOERR)
WRITE(*,FMT=50) 'Incoming amount of CO2/GAS/: ',
* VALUE, ' mol'
Output:
Incoming amount of CO2/GAS/: 0.50000 mol |
C Get the chemical potential of SiO2(quartz)
CALL TQGETR('MU ', 1, ISIO2, VALUE, NOERR)
WRITE(*,FMT=50) 'Chemical potential of SiO2(quartz): ',
* VALUE, ' J/mol'
Output:
Chemical potential of SiO2(quartz): -4363.3 J/mol |
C Get the activity of SiO2(quartz)
CALL TQGETR('AC ', 1, ISIO2, VALUE, NOERR)
WRITE(*,FMT=50) 'Activity of SiO2(quartz): ',
* VALUE, ' '
Output:
Activity of SiO2(quartz): 0.81066 |
C Get the activity of the first system component (carbon). Note that the
C activities of system components are given in absolute values, whereas
C relative values are obtained for phases and constituents.
CALL TQGETR('AC ', 0, 1, VALUE, NOERR)
WRITE(*,FMT=50) 'Activity of system component C: ',
* VALUE, ' '
Output:
Activity of system component C: 0.27651E-08 |
C Get the changes in the extensive property values between the reaction
C products and the reactants given as the stream constituents in the
C current units for the whole system (note that these are relative
C values)
WRITE(*,'(A)') ' Changes in extensive properties:'
CALL TQGETR('CP ', 0, 0, VALUE, NOERR)
WRITE(*,FMT=50) 'Delta CP: ', VALUE, ' J/K'
CALL TQGETR('H ', 0, 0, VALUE, NOERR)
WRITE(*,FMT=50) 'Delta H: ', VALUE, ' J'
CALL TQGETR('S ', 0, 0, VALUE, NOERR)
WRITE(*,FMT=50) 'Delta S: ', VALUE, ' J/K'
CALL TQGETR('G ', 0, 0, VALUE, NOERR)
WRITE(*,FMT=50) 'Delta G: ', VALUE, ' J'
CALL TQGETR('V ', 0, 0, VALUE, NOERR)
WRITE(*,FMT=50) 'Delta V: ', VALUE, ' dm^3'
Output:
Changes in extensive properties:
Delta CP: 118.62 J/K
Delta H: 0.25330E+06 J
Delta S: 213.88 J/K
Delta G: -0.60804E+06 J
Delta V: 98.795 dm^3 |
C Get the Gibbs energy value for CO2/GAS/
CALL TQGETR('G ', 1, ICO2, VALUE, NOERR)
WRITE(*,FMT=50) 'G(CO2/GAS/): ', VALUE, ' J'
Output:
G(CO2/GAS/): -0.46935E+06 J |
C Get the Gibbs energy value for CO2/GAS/ per amount unit
CALL TQGETR('GM ', 1, ICO2, VALUE, NOERR)
WRITE(*,FMT=50) 'G_M(CO2/GAS/): ', VALUE, ' J/mol'
Output:
G_M(CO2/GAS/): -0.10824E+07 J/mol |
C Get the mole fraction of system component C in the system
CALL TQGETR('X ', 0, 1, VALUE, NOERR)
WRITE(*,FMT=50) 'Mole fraction of C in the system: ',
* VALUE, ' '
Output:
Mole fraction of C in the system: 0.11111 |
C Get the mole fraction of system component C in the gas phase
CALL TQGETR('XP ', 1, 1, VALUE, NOERR)
WRITE(*,FMT=50) 'Mole fraction of C in the gas phase: ',
* VALUE, ' '
Output:
Mole fraction of C in the gas phase: 0.33296 |
C Now get the total amount of system component C in the gas phase
CALL TQGETR('AP ', 1, 1, VALUE, NOERR)
WRITE(*,FMT=50) 'Amount of system component C' //
* ' in the GAS phase: ', VALUE, ' mol'
Output:
Amount of system component C in the GAS phase: 0.50000 mol |
C Now get the total amount of all system components in the gas phase,
C having TQGETR return all three values in one array
CALL TQGETR('AP ', 1, -1, VALUES, NOERR)
WRITE(*,'(A)') ' Amounts of all system components' //
* ' in the GAS phase:'
DO NSC = 1, 3
CALL TQGNSC(NSC, SCNAME, NOERR)
WRITE(*,FMT=50) 'Amount of ' // SCNAME //
* ' in the GAS phase: ', VALUES(NSC), ' mol'
ENDDO
Output:
Amounts of all system components in the GAS phase:
Amount of C in the GAS phase: 0.50000 mol
Amount of O in the GAS phase: 1.0011 mol
Amount of Si in the GAS phase: 0.55936E-03 mol |
END
/* Program cac19 */
/* Retrieving results from equilibrium calculations */
#include "cacint.h"
int main()
{
LI noerr, iSiO2, iCO2, indexp, nsc;
DB TP[2], vals[2], value, values[3];
char scname[TQSTRLEN];
/* 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);
/* Define a sample input stream ("INPUTS") */
/* Use the array called TP to pass the information on temperature and
pressure (298.15 K and 1 bar) of the stream to tqsttp */
TP[0] = 298.15 ;
TP[1] = 1.0;
tqsttp("INPUTS", TP, &noerr);
/* Define the amounts of constituents of this stream (1 mol quartz and
0.5 mol CO2) */
tqinp("SiO2(quartz)", &iSiO2, &noerr);
tqstca("INPUTS", iSiO2, 0, 1.0, &noerr);
tqinpc("CO2", 1, &iCO2, &noerr);
tqstca("INPUTS", 1, iCO2, 0.5, &noerr);
/* Set the temperature at which the two streams should react */
tqstec("T", 0, 2500.0, &noerr);
/* Calculate the equilibrium */
tqcel(" ", 0, 0, vals, &noerr);
Output:
T = 2500.00 K
P = 1.00000E+00 bar
V = 1.11190E+02 dm3
STREAM CONSTITUENTS AMOUNT/mol TEMPERATURE/K PRESSURE/bar STREAM
SiO2(quartz) 1.0000E+00 298.15 1.0000E+00 1
CO2/GAS/ 5.0000E-01 298.15 1.0000E+00 1
EQUIL AMOUNT MOLE FRACTION FUGACITY
PHASE: GAS mol bar
CO2 4.3364E-01 8.1066E-01 8.1066E-01
CO 6.6363E-02 1.2406E-01 1.2406E-01
O2 3.2435E-02 6.0635E-02 6.0635E-02
O 1.9270E-03 3.6023E-03 3.6023E-03
SiO 4.3397E-04 8.1128E-04 8.1128E-04
SiO2 1.2540E-04 2.3442E-04 2.3442E-04
O3 T 2.4872E-09 4.6497E-09 4.6497E-09
Si 1.1737E-11 2.1942E-11 2.1942E-11
C 6.4393E-15 1.2038E-14 1.2038E-14
Si2 1.6425E-21 3.0705E-21 3.0705E-21
SiC 6.2162E-22 1.1621E-21 1.1621E-21
C2 1.1943E-22 2.2326E-22 2.2326E-22
Si2C 2.4986E-27 4.6711E-27 4.6711E-27
C3 6.7723E-29 1.2660E-28 1.2660E-28
Si3 1.2802E-30 2.3933E-30 2.3933E-30
TOTAL: 5.3492E-01 1.0000E+00 1.0000E+00
mol ACTIVITY
SiO2(liquid) 9.9944E-01 1.0000E+00
SiO2(cristobalite) 0.0000E+00 8.9012E-01
SiO2(tridymite) T 0.0000E+00 8.5795E-01
SiO2(quartz) T 0.0000E+00 7.4840E-01
C 0.0000E+00 7.1792E-08
Si 0.0000E+00 4.7391E-09
SiC 0.0000E+00 1.5332E-15
********************************************************************
DELTA_Cp DELTA_H DELTA_S DELTA_G DELTA_V
J.K-1 J J.K-1 J dm3
********************************************************************
1.18625E+02 2.53297E+05 2.13883E+02 -6.08043E+05 9.87954E+01
Mole fraction of system components:
GAS
C 3.3296E-01
O 6.6667E-01
Si 3.7249E-04
Data on 3 constituents marked with 'T' are extrapolated outside their valid
temperature range |
/* A number of the results retrieved below can also be found in the
ChemSage result table output above by tqcel. If you do not want a
ChemSage result table, for instance because your application
program has a graphical user interface and cannot make use of the
table, call tqce instead to calculate the equilibrium. */
/* Get the pressure, which is 1 bar, since this is the default. */
tqgetr("P", 0, 0, &value, &noerr);
printf("Equilibrium pressure: %g bar\n", value);
Output:
Equilibrium pressure: 1 bar |
/* Get the calculated equilibrium volume */
tqgetr("VT", 0, 0, &value, &noerr);
printf("Equilibrium volume (total): %g dm^3\n", value);
Output:
Equilibrium volume (total): 111.19 dm^3 |
/* Get the calculated _change_ in volume. Note that options "V" and
"VT" _only_ give different values if streams are used _and_ the
whole system is selected, in which case "V" retrieves the
_change_ in volume between the reaction products and the stream
constituents. In all other cases, both "VT" and "V" give the
_total_ volume. */
tqgetr("V", 0, 0, &value, &noerr);
printf("Change in volume: %g dm^3\n", value);
Output:
Change in volume: 98.7954 dm^3 |
/* Get the temperature, which is 2500 K, since we set this particular
condition for the equilibrium calculation */
tqgetr("T", 0, 0, &value, &noerr);
printf("Equilibrium temperature: %g K\n", value);
Output:
Equilibrium temperature: 2500 K |
/* Get the equilibrium amount of liquid SiO2 */
tqinp("SiO2(liquid)", &indexp, &noerr);
tqgetr("a", indexp, 0, &value, &noerr);
printf("Equilibrium amount of SiO2(liquid): %g mol\n", value);
Output:
Equilibrium amount of SiO2(liquid): 0.999441 mol |
/* Get the incoming amount of CO2/GAS/ that was input for the last
equilibrium calculation */
tqgetr("ia", 1, iCO2, &value, &noerr);
printf("Incoming amount of CO2/GAS/: %g mol\n", value);
Output:
Incoming amount of CO2/GAS/: 0.5 mol |
/* Get the chemical potential of SiO2(quartz) */
tqgetr("mu", 1, iSiO2, &value, &noerr);
printf("Chemical potential of SiO2(quartz): %g J/mol\n", value);
Output:
Chemical potential of SiO2(quartz): -4363.26 J/mol |
/* Get the activity of SiO2(quartz) */
tqgetr("ac", 1, iSiO2, &value, &noerr);
printf("Activity of SiO2(quartz): %g\n", value);
Output:
Activity of SiO2(quartz): 0.810657 |
/* Get the activity of the first system component (carbon). Note that the
activities of system components are given in absolute values, whereas
relative values are obtained for phases and constituents. */
tqgetr("ac", 0, 1, &value, &noerr);
printf("Activity of system component C: %g\n", value);
Output:
Activity of system component C: 2.76514e-09 |
/* Get the changes in the extensive property values between the
reaction products and the reactants given as the stream
constituents in the current units for the whole system (note that
these are relative values) */
printf("Changes in extensive properties:\n");
tqgetr("CP", 0, 0, &value, &noerr);
printf("Delta CP: %g J/K\n", value);
tqgetr("H", 0, 0, &value, &noerr);
printf("Delta H: %g J\n", value);
tqgetr("S", 0, 0, &value, &noerr);
printf("Delta S: %g J/K\n", value);
tqgetr("G", 0, 0, &value, &noerr);
printf("Delta G: %g J\n", value);
tqgetr("V", 0, 0, &value, &noerr);
printf("Delta V: %g dm^3\n", value);
Output:
Changes in extensive properties:
Delta CP: 118.625 J/K
Delta H: 253297 J
Delta S: 213.883 J/K
Delta G: -608043 J
Delta V: 98.7954 dm^3 |
/* Get the Gibbs energy value for CO2/GAS/ */
tqgetr("G", 1, iCO2, &value, &noerr);
printf("G(CO2/GAS/): %g J\n", value);
Output:
G(CO2/GAS/): -469351 J |
/* Get the Gibbs energy value for CO2/GAS/ per amount unit */
tqgetr("GM", 1, iCO2, &value, &noerr);
printf("G_M(CO2/GAS/): %g J/mol\n", value);
Output:
G_M(CO2/GAS/): -1.08236e+06 J/mol |
/* Get the mole fraction of system component C in the system */
tqgetr("X", 0, 1, &value, &noerr);
printf("Mole fraction of C in the system: %g\n", value);
Output:
Mole fraction of C in the system: 0.111111 |
/* Get the mole fraction of system component C in the gas phase */
tqgetr("XP", 1, 1, &value, &noerr);
printf("Mole fraction of C in the gas phase: %g\n", value);
Output:
Mole fraction of C in the gas phase: 0.332961 |
/* Now get the total amount of all system components in the gas
phase, having tqgetr return all three values in one array */
tqgetr("ap", 1, -1, values, &noerr);
printf("Amounts of all system components in the GAS phase:\n");
for (nsc = 0; nsc < 3; nsc++) {
tqgnsc(nsc+1, scname, &noerr);
printf("Amount of %s in the GAS phase: %g mol\n",
scname, values[nsc]);
}
Output:
Amounts of all system components in the GAS phase:
Amount of C in the GAS phase: 0.5 mol
Amount of O in the GAS phase: 1.00112 mol
Amount of Si in the GAS phase: 0.000559364 mol |
return 0;
}