## 5.1: TQCE

`TOC``Group 5``TQSTRM``TQCEL``Group 1``A-Z``Group 5`

### CALCULATE-EQUILIBRIUM

Use TQCE to calculate the equilibrium with current settings of global conditions or streams.

### Synopsis

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

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

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

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

 Name Type Value set on call or returned OPTION CHARACTER Set to a string as shown in Table 16 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 an initial estimate of the target variable, or the lower and upper limits of an incoming amount, if necessary NOERR INTEGER Returns an error number

OPTION, INDEXP, INDEX, and VALS are all input. For a calculation without any target, it is sufficient to enter OPTION as a blank character and the remainder as dummies. See Table 16 for the mnemonics of possible target variables, and for the meaning of VALS.

The constraints when two values of VALS entered are: VALS(1) and VALS(2) must not be equal, and VALS(2) must be greater or equal to zero. VALS is entered with the default unit, or a unit selected using TQCSU (see Chapter 2). The estimate of the target variable (see Table 16) need not be particularly accurate. However, unnecessarily long computing times may result if it is far from the equilibrium value. The limits of the target variable can be changed using TQCLIM. While the target variable is specified using TQCE, the target itself must have been set previously using TQSETC or TQSTEC.

### Examples

 FORTRAN: View plain source code

```
C Calculation of different phase equilibria

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

PROGRAM CAF18
IMPLICIT NONE

INTEGER NOERR, ISLITE, IO2, IC, IN2, ITEMP
DOUBLE PRECISION VALS(2), TP(2), RESULT, TEMP

C Initialise ChemApp
CALL TQINI(NOERR)

C Open data-file for reading. In this case, a data-file containing the
C thermochemical data for the system carbon-nitrogen-oxygen is selected.
CALL TQOPNA('cno.dat', 10, NOERR)

CALL TQRFIL(NOERR)

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

C Since we will perform an extensive property target calculation later,
C we will do the equilibrium calculations using streams. This way we can
C associate an initial state regarding temperature and pressure to the
C incoming substances, which will be taken into account when ChemApp
C calculates the extensive property (e.g. heat) balance.

C Since we are going to prefer degrees Celsius as temperature unit,
C we will change the unit now
CALL TQCSU('Temperature ', 'C ', NOERR)

C Define a stream at room temperature and 1 bar
TP(1) = 20.D0
TP(2) = 1.D0
CALL TQSTTP('inputs ', TP, NOERR)

C Set stream constituents: 0.5 mol of oxygen and 10 grams of carbon

C Get the index number of the phase constituent oxygen ('O2') in the gas
C phase. If a thermochemical data-file for ChemApp and ChemSage
C contains a gas phase, it is always the first one:
CALL TQINPC('O2 ', 1, IO2, NOERR)

C Get the index number of the phase carbon ('C')
CALL TQINP('C ', IC, NOERR)

C Set the incoming amount of oxygen in the stream (0.5 mol)
CALL TQSTCA('inputs ', 1, IO2, .5D0, NOERR)

C Change the amount unit to gram and set the incoming amount of carbon
C in the stream (10 gram)
CALL TQCSU('Amount ', 'gram ', NOERR)
CALL TQSTCA('inputs ', IC, 0, 10.D0, NOERR)

C Set the temperature for the equilibrium calculation (1500 C)
CALL TQSTEC('T ', 0, 1500.D0, NOERR)

C Calculate the equilibrium
CALL TQCE(' ', 0, 0, VALS, NOERR)

C Alternatively, TQCEL can be used, which does not only calculate the
C equilibrium, but also writes a ChemSage result table to standard output
CALL TQCEL(' ', 0, 0, VALS, NOERR)
```

 Output: ``` T = 1500.00 C P = 1.00000E+00 bar V = 1.22745E+02 dm3 STREAM CONSTITUENTS AMOUNT/gram TEMPERATURE/C PRESSURE/bar STREAM O2/GAS/ 1.5999E+01 20.00 1.0000E+00 1 C 1.0000E+01 20.00 1.0000E+00 1 EQUIL AMOUNT MOLE FRACTION FUGACITY PHASE: GAS mol bar CO 6.6514E-01 7.9890E-01 7.9890E-01 CO2 1.6743E-01 2.0110E-01 2.0110E-01 O 3.0441E-09 3.6562E-09 3.6562E-09 O2 1.2593E-09 1.5126E-09 1.5126E-09 C2O 1.6626E-14 1.9970E-14 1.9970E-14 C 2.8498E-17 3.4229E-17 3.4229E-17 O3 9.3779E-22 1.1264E-21 1.1264E-21 C2 2.6273E-22 3.1556E-22 3.1556E-22 C3 9.1060E-25 1.0937E-24 1.0937E-24 C4 2.7548E-33 3.3088E-33 3.3088E-33 C5 2.5090E-36 3.0135E-36 3.0135E-36 TOTAL: 8.3257E-01 1.0000E+00 1.0000E+00 gram ACTIVITY C 0.0000E+00 2.7932E-04 C_DIAMOND_A4 0.0000E+00 1.4585E-04 ******************************************************************** DELTA_Cp DELTA_H DELTA_S DELTA_G DELTA_V J.K-1 J J.K-1 J dm3 ******************************************************************** 1.22149E+01 -9.39612E+04 1.16311E+02 -4.58469E+05 1.10558E+02 Mass fraction of system components: GAS C 3.8462E-01 O 6.1538E-01```
```
50   FORMAT(1X,A,G12.5)

C Get the change in volume that takes place
CALL TQGETR('V ', 0, 0, RESULT, NOERR)
WRITE(*,FMT=50) 'Change in volume/dm^3 is ', RESULT
```

 Output: ` Change in volume/dm^3 is 110.56`
```
C Get the enthalpy change for the process (since its sign is negative,
C energy is released
CALL TQGETR('H ', 0, 0, RESULT, NOERR)
WRITE(*,FMT=50) 'Change in enthalpy/J is ', RESULT
```

 Output: ` Change in enthalpy/J is -93961.`
```
C Get the activity of carbon, which, at 1500 C is far from being unity
CALL TQGETR('AC ', IC, 0, RESULT, NOERR)
WRITE(*,FMT=50) 'Activity of carbon is ', RESULT
```

 Output: ` Activity of carbon is 0.27932E-03`
```
C Once an equilibrium has been calculated using TQCE/TQCEL, subsequent
C calculations can be performed using TQCEN/TQCENL, which speeds up the
C equilibrium calculation by taking results from the previous
C calculation as initial estimates

DO ITEMP=1510, 1600, 10

TEMP = ITEMP

CALL TQSTEC('T ', 0, TEMP, NOERR)
CALL TQCEN(' ', 0, 0, VALS, NOERR)
CALL TQGETR('AC ', IC, 0, RESULT, NOERR)
WRITE(*,*) 'Activity of carbon at T = ',
*        TEMP, ' C is ', RESULT

ENDDO

```

 Output: ``` Activity of carbon at T = 1510. C is 0.00026264471 Activity of carbon at T = 1520. C is 0.000247141494 Activity of carbon at T = 1530. C is 0.000232720875 Activity of carbon at T = 1540. C is 0.000219296861 Activity of carbon at T = 1550. C is 0.000206791051 Activity of carbon at T = 1560. C is 0.000195131904 Activity of carbon at T = 1570. C is 0.000184254082 Activity of carbon at T = 1580. C is 0.000174097858 Activity of carbon at T = 1590. C is 0.000164608613 Activity of carbon at T = 1600. C is 0.000155736275```
```
C Similar to TQCEL, TQCENL also provides a ChemSage output table
CALL TQCENL(' ', 0, 0, VALS, NOERR)
```

 Output: ``` T = 1600.00 C P = 1.00000E+00 bar V = 1.29667E+02 dm3 STREAM CONSTITUENTS AMOUNT/gram TEMPERATURE/C PRESSURE/bar STREAM O2/GAS/ 1.5999E+01 20.00 1.0000E+00 1 C 1.0000E+01 20.00 1.0000E+00 1 EQUIL AMOUNT MOLE FRACTION FUGACITY PHASE: GAS mol bar CO 6.6514E-01 7.9890E-01 7.9890E-01 CO2 1.6743E-01 2.0110E-01 2.0110E-01 O 2.1027E-08 2.5256E-08 2.5256E-08 O2 9.4832E-09 1.1390E-08 1.1390E-08 C2O 4.0356E-14 4.8472E-14 4.8472E-14 C 2.1347E-16 2.5639E-16 2.5639E-16 O3 3.2996E-20 3.9632E-20 3.9632E-20 C2 1.6278E-21 1.9551E-21 1.9551E-21 C3 3.1116E-24 3.7374E-24 3.7374E-24 C4 1.0919E-32 1.3115E-32 1.3115E-32 C5 5.9958E-36 7.2015E-36 7.2015E-36 TOTAL: 8.3257E-01 1.0000E+00 1.0000E+00 gram ACTIVITY C 0.0000E+00 1.5574E-04 C_DIAMOND_A4 0.0000E+00 8.1689E-05 ******************************************************************** DELTA_Cp DELTA_H DELTA_S DELTA_G DELTA_V J.K-1 J J.K-1 J dm3 ******************************************************************** 1.24040E+01 -9.05677E+04 1.18173E+02 -4.80888E+05 1.17480E+02 Mass fraction of system components: GAS C 3.8462E-01 O 6.1538E-01```
```

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 PERFORMING target calculations
C
C Note that target calculations are not possible with ChemApp "light",
C you need the regular version of ChemApp to run the examples below.
C
C Performing target calculations requires that ChemApp needs to be told
C 2 things:
C - the target itself,
C - the target variable, i.e. which variable ChemApp is allowed to vary
C   to achieve the target.
C
C First we will perform a formation phase target calculation, which is
C used to determine the conditions under which a phase becomes stable,
C using carbon as an example. As a target variable we will use the
C temperature. The result will be the temperature under which solid
C carbon will just become stable (smoke point).

C Define the target: phase C, amount of C = 0
CALL TQSTEC('A ', IC, 0.D0, NOERR)

C Define the target variable, which is done during the call to TQCE.
C The value passed as VALS(1) will be taken as an initial estimate.
VALS(1) = 500.D0
CALL TQCE('T ', 0, 0, VALS, NOERR)

C Get the temperature, which ChemApp determined
CALL TQGETR('T ', 0, 0, RESULT, NOERR)
WRITE(*,FMT=50) 'Calculated formation temperature of ' //
*     'carbon in degrees Celsius: ', RESULT
```

 Output: ` Calculated formation temperature of carbon in degrees Celsius: 756.35`
```
C Check whether ChemApp calculated correctly by verifying that the
C activity of carbon is unity.
CALL TQGETR('AC ', IC, 0, RESULT, NOERR)
WRITE(*,FMT=50) 'Activity of carbon is ', RESULT
```

 Output: ` Activity of carbon is 1.0000`
```
C The equilibrium amount of carbon should still be zero though, as we
C had ChemApp find the temperature where carbon _just_ gets stable
CALL TQGETR('A ', IC, 0, RESULT, NOERR)
WRITE(*,FMT=50) 'Amount of carbon is ', RESULT
```

 Output: ` Amount of carbon is 0.0000`
```
C It is also possible to specify a different amount than zero for the
C phase formation target calculation. To to this, pass a different value
C to TQSTEC when defining the target. As an example, calculate the
C temperature where 1 gram of carbon is stable
CALL TQSTEC('A ', IC, 1.D0, NOERR)
CALL TQCE('T ', 0, 0, VALS, NOERR)
CALL TQGETR('T ', 0, 0, RESULT, NOERR)
WRITE(*,FMT=50) 'Calculated formation temperature for ' //
*     '1 gram of carbon in deg. Celsius:',
*     RESULT
```

 Output: ` Calculated formation temperature for 1 gram of carbon in deg. Celsius: 713.05`
```
ENDIF

C Before performing extensive property target calculations, TQREMC is
C used to remove all conditions and targets set previously.
CALL TQREMC(-2, NOERR)

C Remove also the stream 'inputs'
CALL TQSTRM('inputs ', NOERR)

C It is also useful to reset VALS, which now still contains a starting
C value for a temperature in VALS(1)
VALS(1) = 0

C If it is also desired to reset all units to default units, which would
C in this case reset the amount to mol and the temperature unit to
C Kelvin, call TQREMC with a value of -1
CALL TQREMC(-1, NOERR)

C Set up a new stream which contains 1 mol of pure oxygen, preheated to
C 400 K at 1 bar
TP(1) = 400.0
TP(2) = 1.0
CALL TQSTTP('oxygen ', TP, NOERR)
CALL TQSTCA('oxygen ', 1, IO2, 1.D0, NOERR)

C Another stream that contains 1 mol of solid carbon at room
C temperature and 1 bar
TP(1) = 298.15
TP(2) = 1.0
CALL TQSTTP('carbon ', TP, NOERR)
CALL TQSTCA('carbon ', IC, 0, 1.D0, NOERR)

C Calculate the equilibrium and retrieve the enthalpy released for this
C process
CALL TQCE(' ', 0, 0, VALS, NOERR)
CALL TQGETR('H ', 0, 0, RESULT, NOERR)
WRITE(*,FMT=50) 'Change in enthalpy/J is ', RESULT
```

 Output: ` Change in enthalpy/J is -0.36313E+06`
```
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 adiabatic temperature for this process. This would be
C the temperature at which the above mentioned enthalpy is zero

C Define the target: enthalpy, value = 0
CALL TQSTEC('H ', 0, 0.D0, NOERR)

C Define the target variable, which is done during the call to TQCE.
C The value passed as VALS(1) will be taken as an initial estimate.
VALS(1) = 1000.D0
CALL TQCE('T ', 0, 0, VALS, NOERR)

C Get the temperature ChemApp calculated (which is the adiabatic
C temperature in this example)
CALL TQGETR('T ', 0, 0, RESULT, NOERR)
WRITE(*,FMT=50) 'Calculated adiabatic temperature/K for ' //
*     'this process: ', RESULT
```

 Output: ` Calculated adiabatic temperature/K for this process: 3290.4`
```
C One can investigate how this temperature changes if one assumes a
C mixture that resembles air, instead of pure O2. Air has an N2/O2 ratio
C of about 4:1. Keeping 1 mol of oxygen, we thus have to add 4 mol of
C N2.
CALL TQINPC('N2 ', 1, IN2, NOERR)
CALL TQSTCA('oxygen ', 1, IN2, 4.D0, NOERR)

CALL TQCE('T ', 0, 0, VALS, NOERR)

CALL TQGETR('T ', 0, 0, RESULT, NOERR)
WRITE(*,FMT=50) 'Adiabatic temperature/K for this process ' //
*     'with an N2/O2 mixture: ', RESULT
```

 Output: ` Adiabatic temperature/K for this process with an N2/O2 mixture: 2295.3`
```
ENDIF
END

```

```

/* Program cac18 */
/* Calculation of different phase equilibria */

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

#include "cacint.h"

int main()
{
LI noerr, islite, iO2, iC, iN2;
DB vals[2], TP[2], result, temp;

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

/* Open data-file for reading. In this case, a data-file containing
the thermochemical data for the system carbon-nitrogen-oxygen is
selected. */
tqopna("cno.dat",10,&noerr);

tqrfil(&noerr);

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

/* Since we will perform an extensive property target calculation
later, we will do the equilibrium calculations using
streams. This way we can associate an initial state regarding
temperature and pressure to the incoming substances, which will
be taken into account when ChemApp calculates the extensive
property (e.g. heat) balance. */

/* Since we are going to prefer degrees Celsius as temperature unit,
we will change the unit now */
tqcsu("Temperature", "C", &noerr);

/* Define a stream at room temperature and 1 bar */
TP[0] = 20.0;
TP[1] = 1.0;
tqsttp("inputs", TP, &noerr);

/* Set stream constituents: 0.5 mol of oxygen and 10 grams of carbon */

/* Get the index number of the phase constituent oxygen ("O2") in
the gas phase. If a thermochemical data-file for ChemApp and
ChemSage contains a gas phase, it is always the first one: */
tqinpc("O2", 1, &iO2, &noerr);

/* Get the index number of the phase carbon ("C") */
tqinp("C", &iC, &noerr);

/* Set the incoming amount of oxygen in the stream (0.5 mol) */
tqstca("inputs", 1, iO2, .5, &noerr);

/* Change the amount unit to gram and set the incoming amount of
carbon in the stream (10 gram) */
tqcsu("Amount", "gram", &noerr);
tqstca("inputs", iC, 0, 10.0, &noerr);

/* Set the temperature for the equilibrium calculation (1500 C) */
tqstec("T", 0, 1500.0, &noerr);

/* Calculate the equilibrium */
tqce(" ", 0, 0, vals, &noerr);

/* Get the change in volume that takes place */
tqgetr("V", 0, 0, &result, &noerr);
printf("Change in volume/dm^3 is %g\n", result);
```

 Output: `Change in volume/dm^3 is 110.558`
```
/* Get the enthalpy change for the process (since its sign is
negative, energy is released */
tqgetr("H", 0, 0, &result, &noerr);
printf("Change in enthalpy/J is %g\n", result);
```

 Output: `Change in enthalpy/J is -93961.2`
```
/* Get the activity of carbon, which, at 1500 C is far from being
unity */
tqgetr("ac", iC, 0, &result, &noerr);
printf("Activity of carbon is %g\n", result);
```

 Output: `Activity of carbon is 0.000279325`
```
/* Once an equilibrium has been calculated using tqce/tqcel,
subsequent calculations can be performed using tqcen/tqcenl,
which speeds up the equilibrium calculation by taking results
from the previous calculation as initial estimates */
for (temp = 1510; temp <= 1600; temp +=10) {

tqstec("T", 0, temp, &noerr);
tqcen(" ", 0, 0, vals, &noerr);
tqgetr("ac", iC, 0, &result, &noerr);
printf("Activity of carbon at T = %g C is %g\n", temp, result);

}

```

 Output: ```Activity of carbon at T = 1510 C is 0.000262645 Activity of carbon at T = 1520 C is 0.000247141 Activity of carbon at T = 1530 C is 0.000232721 Activity of carbon at T = 1540 C is 0.000219297 Activity of carbon at T = 1550 C is 0.000206791 Activity of carbon at T = 1560 C is 0.000195132 Activity of carbon at T = 1570 C is 0.000184254 Activity of carbon at T = 1580 C is 0.000174098 Activity of carbon at T = 1590 C is 0.000164609 Activity of carbon at T = 1600 C is 0.000155736```
```
/* Similar to tqcel, tqcenl also provides a ChemSage output table */
tqcenl(" ", 0, 0, vals, &noerr);
```

 Output: ``` T = 1600.00 C P = 1.00000E+00 bar V = 1.29667E+02 dm3 STREAM CONSTITUENTS AMOUNT/gram TEMPERATURE/C PRESSURE/bar STREAM O2/GAS/ 1.5999E+01 20.00 1.0000E+00 1 C 1.0000E+01 20.00 1.0000E+00 1 EQUIL AMOUNT MOLE FRACTION FUGACITY PHASE: GAS mol bar CO 6.6514E-01 7.9890E-01 7.9890E-01 CO2 1.6743E-01 2.0110E-01 2.0110E-01 O 2.1027E-08 2.5256E-08 2.5256E-08 O2 9.4832E-09 1.1390E-08 1.1390E-08 C2O 4.0356E-14 4.8472E-14 4.8472E-14 C 2.1347E-16 2.5639E-16 2.5639E-16 O3 3.2996E-20 3.9632E-20 3.9632E-20 C2 1.6278E-21 1.9551E-21 1.9551E-21 C3 3.1116E-24 3.7374E-24 3.7374E-24 C4 1.0919E-32 1.3115E-32 1.3115E-32 C5 5.9958E-36 7.2015E-36 7.2015E-36 TOTAL: 8.3257E-01 1.0000E+00 1.0000E+00 gram ACTIVITY C 0.0000E+00 1.5574E-04 C_DIAMOND_A4 0.0000E+00 8.1689E-05 ******************************************************************** DELTA_Cp DELTA_H DELTA_S DELTA_G DELTA_V J.K-1 J J.K-1 J dm3 ******************************************************************** 1.24040E+01 -9.05677E+04 1.18173E+02 -4.80888E+05 1.17480E+02 Mass fraction of system components: GAS C 3.8462E-01 O 6.1538E-01```
```
/* 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
{

/* Performing target calculations */

/* Note that target calculations are not possible with ChemApp
"light", you need the regular version of ChemApp to run the
examples below. */

/* Performing target calculations requires that ChemApp needs to be
told 2 things:
- the target itself,
- the target variable, i.e. which variable ChemApp is allowed to
vary to achieve the target.

First we will perform a formation phase target calculation, which
is used to determine the conditions under which a phase becomes
stable, using carbon as an example. As a target variable we will
use the temperature. The result will be the temperature under
which solid carbon will just become stable (smoke point). */

/* Define the target: phase C, amount of C = 0 */
tqstec("a", iC, 0.0, &noerr);

/* Define the target variable, which is done during the call to
tqce.  The value passed as vals[0] will be taken as an initial
estimate. */
vals[0] = 500.0;
tqce("T", 0, 0, vals, &noerr);

/* Get the temperature, which ChemApp determined */
tqgetr("T", 0, 0, &result, &noerr);
printf("Calculated formation temperature of "
"carbon in degrees Celsius: %g\n", result);
```

 Output: `Calculated formation temperature of carbon in degrees Celsius: 756.345`
```
/* Check whether ChemApp calculated correctly by verifying that the
activity of carbon is unity. */
tqgetr("ac", iC, 0, &result, &noerr);
printf("Activity of carbon is %g\n", result);
```

 Output: `Activity of carbon is 1`
```
/* The equilibrium amount of carbon should still be zero though, as
we had ChemApp find the temperature where carbon _just_ gets
stable */
tqgetr("a", iC, 0, &result, &noerr);
printf("Amount of carbon is %g\n", result);
```

 Output: `Amount of carbon is 0`
```
/* It is also possible to specify a different amount than zero for
the phase formation target calculation. To to this, pass a
different value to tqstec when defining the target. As an
example, calculate the temperature where 1 gram of carbon is
stable */
tqstec("a", iC, 1.0, &noerr);
tqce("T", 0, 0, vals, &noerr);
tqgetr("T", 0, 0, &result, &noerr);
printf("Calculated formation temperature for "
"1 gram of carbon in deg. Celsius: %g\n", result);
```

 Output: `Calculated formation temperature for 1 gram of carbon in deg. Celsius: 713.054`
```
}

/* Before performing extensive property target calculations, tqremc
is used to remove all conditions and targets set previously */
tqremc(-2, &noerr);

/* Remove also the stream "inputs" */
tqstrm("inputs", &noerr);

/* It is also useful to reset vals, which now still contains a
starting value for a temperature in vals[0] */
vals[0] = 0;

/* If it is also desired to reset all units to default units, which
would in this case reset the amount to mol and the temperature
unit to Kelvin, call tqremc with a value of -1 */
tqremc(-1, &noerr);

/* Set up a new stream which contains 1 mol of pure oxygen,
preheated to 400 K at 1 bar */
TP[0] = 400.0;
TP[1] = 1.0;
tqsttp("oxygen", TP, &noerr);
tqstca("oxygen", 1, iO2, 1.0, &noerr);

/* Another stream that contains 1 mol of solid carbon at room
temperature and 1 bar */
TP[0] = 298.15;
TP[1] = 1.0;
tqsttp("carbon", TP, &noerr);
tqstca("carbon", iC, 0, 1.0, &noerr);

/* Calculate the equilibrium and retrieve the enthalpy released for
this process */
tqce(" ", 0, 0, vals, &noerr);
tqgetr("H", 0, 0, &result, &noerr);
printf("Change in enthalpy/J is %g\n", result);
```

 Output: `Change in enthalpy/J is -363127`
```
/* 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 adiabatic temperature for this process. This would
be the temperature at which the above mentioned enthalpy is
zero */

/* Define the target: enthalpy, value = 0 */
tqstec("H", 0, 0.0, &noerr);

/* Define the target variable, which is done during the call to
tqce. The value passed as vals[0] will be taken as an initial
estimate. */
vals[0] = 1000.0;
tqce("T", 0, 0, vals, &noerr);

/* Get the temperature ChemApp calculated (which is the adiabatic
temperature in this example) */
tqgetr("T", 0, 0, &result, &noerr);
"this process: %g\n", result);
```

 Output: `Calculated adiabatic temperature/K for this process: 3290.38`
```
/* One can investigate how this temperature changes if one assumes a
mixture that resembles air, instead of pure O2. Air has an N2/O2
ratio of about 4:1. Keeping 1 mol of oxygen, we thus have to add
4 mol of N2. */
tqinpc("N2", 1, &iN2, &noerr);
tqstca("oxygen", 1, iN2, 4.0, &noerr);

tqce("T", 0, 0, vals, &noerr);

tqgetr("T", 0, 0, &result, &noerr);
printf("Adiabatic temperature/K for this process "
"with a N2/O2 mixture: %g\n", result);
```

 Output: `Adiabatic temperature/K for this process with a N2/O2 mixture: 2295.3`
```
}

return 0;

}

```

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