CHANGE-LIMIT-OF-TARGET-VARIABLE
Use TQCLIM to modify the upper and lower limits of the target variables
pressure, volume, or temperature.
Synopsis
FORTRAN: CALL TQCLIM(OPTION,VAL,NOERR)
C: tqclim(option,val,&noerr)
;
Pascal: tqclim(option,val,noerr)
;
Basic: Call tqclim(option,val,noerr)
Name |
Type |
Value set on call or returned
|
OPTION |
CHARACTER |
Set to a string as shown in Table 17
|
VAL |
DOUBLE PRECISION |
Set to a limit in the default unit
|
NOERR |
INTEGER |
Returns an error number
|
OPTION is a character variable identifying the limit to be
changed. VAL is entered with a default unit. In a target calculation,
the lower and upper limits of a target variable are never
exceeded. One specific solution of several possible ones can be found
by changing the default numbers in Table 17,
such that the interval is reduced. By reducing TLOW, a calculated
temperature can have a value below room temperature. When composition
is the target variable, the range can only be changed by modifying
VALS(1) and VALS(2) using TQCE/TQCEL, see Table
16.
Examples
C Change the limits of target variables
C Note that this program contains target calculations,
C which cannot be performed with the 'light' version of ChemApp
PROGRAM CAF22
IMPLICIT NONE
INTEGER NOERR, ISLITE, NUMCON, IPB, ISN, ILIQ, IFCC
DOUBLE PRECISION TEMP, ACT, VALS(2)
C Initialise ChemApp
CALL TQINI(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 Open data-file for reading
CALL TQOPNA('pbsn.dat', 10, NOERR)
C Read data-file
CALL TQRFIL(NOERR)
C Close data-file
CALL TQCLOS(10, NOERR)
50 FORMAT(1X,A,G12.5,A)
51 FORMAT(1X,2(A,G12.5))
C For this example, let us assume one intends to find the solidus point
C for an Pb-Sn alloy consisting of 20 mol-% Sn and 80 mol-% Pb by
C performing a precipitation target calculation from the FCC
C phase. Figure 7 shows the Pb-Sn phase diagram as
C calculated by ChemSage. The line marked "1" indicates the
C concentration that will be used for the precipitation target
C calculations below, using the temperature as the target variable.
C Get index numbers of system components
CALL TQINSC('Pb ', IPB, NOERR)
CALL TQINSC('Sn ', ISN, NOERR)
C Get index number of the FCC and liquid phases
CALL TQINP('FCC ', IFCC, NOERR)
CALL TQINP('LIQ ', ILIQ, NOERR)
C Input 0.2 mol Sn and 0.8 mol Pb
CALL TQSETC('IA ', 0, ISN, 0.2D0, NUMCON, NOERR)
CALL TQSETC('IA ', 0, IPB, 0.8D0, NUMCON, NOERR)
C Define the precipitation phase target
CALL TQSETC('A ', IFCC, 0, -1.D0, NUMCON, NOERR)
C Define the target variable (temperature) and perform the
C equilibrium calculation. The estimate for the target variable, passed
C via VALS(1), is set to 1000 K.
VALS(1) = 1000.D0
CALL TQCE('T ', 0, 0, VALS, NOERR)
C Retrieve the calculated temperature
CALL TQGETR('T ', 0, 0, TEMP, NOERR)
WRITE(*,FMT=50) 'Calculated solidus temperature: ',
* TEMP, 'K'
Output:
Calculated solidus temperature: 426.36 K |
C Looking at the Pb-Sn phase diagram, this temperature is certainly
C wrong. This can be demonstrated by retrieving the activity of the
C liquid phase:
CALL TQGETR('AC ', ILIQ, 0, ACT, NOERR)
WRITE(*,FMT=51) 'Activity of liquid phase at ',TEMP, ' K: ',
* ACT
Output:
Activity of liquid phase at 426.36 K: 0.89170 |
C Since the activity is less than unity, the liquid phase is not stable,
C thus this cannot be the solidus point. The reason is that ChemApp
C found the phase boundary between FCC and the two-phase region FCC+BCT,
C instead of that between FCC and FCC+Liquid. Note also that although the
C initial estimate for the target variable has been set to 1000 K, which
C is certainly closer to the solidus point than to the FCC/FCC+BCT phase
C boundary, this does not guarantee that of two possible solutions, the one
C closer to the initial estimate is found.
C To keep ChemApp from finding the unwanted phase boundary at lower
C temperatures, tell it to limit its search to temperatures above 450 K:
CALL TQCLIM('TLOW ', 450.D0, NOERR)
C Recalculate the equilibrium
CALL TQCE('T ', 0, 0, VALS, NOERR)
C Retrieve the calculated temperature
CALL TQGETR('T ', 0, 0, TEMP, NOERR)
WRITE(*,FMT=50) 'Calculated solidus temperature: ',
* TEMP, 'K'
Output:
Calculated solidus temperature: 505.37 K |
C Check the activity of the liquid phase again to verify that it is
C indeed stable:
CALL TQGETR('AC ', ILIQ, 0, ACT, NOERR)
WRITE(*,FMT=51) 'Activity of liquid phase at ',TEMP, ' K: ',
* ACT
Output:
Activity of liquid phase at 505.37 K: 1.0000 |
C Since the activity is unity, we know that the temperature we found is
C correct.
ENDIF
END
/* Program cac22 */
/* Change the limits of target variables */
/* 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, numcon, iPb, iSn, iLIQ, iFCC;
DB temp, act, vals[2];
/* Initialise ChemApp */
tqini(&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
{
/* Open data-file for reading */
tqopna("pbsn.dat",10,&noerr);
/* Read data-file */
tqrfil(&noerr);
/* Close data-file */
tqclos(10,&noerr);
/* For this example, let us assume one intends to find the solidus
point for an Pb-Sn alloy consisting of 20 mol-% Sn and 80 mol-%
Pb by performing a precipitation target calculation from the FCC
phase. Figure 7 shows the Pb-Sn phase diagram as
calculated by ChemSage. The line marked "1" indicates the
concentration that will be used for the precipitation target
calculations below, using the temperature as the target
variable. */
/* Get index numbers of system components */
tqinsc("Pb", &iPb, &noerr);
tqinsc("Sn", &iSn, &noerr);
/* Get phase index numbers of the FCC and liquid phases */
tqinp("FCC", &iFCC, &noerr);
tqinp("LIQ", &iLIQ, &noerr);
/* Input 0.2 mol Sn and 0.8 mol Pb */
tqsetc("ia", 0, iSn, 0.2, &numcon, &noerr);
tqsetc("ia", 0, iPb, 0.8, &numcon, &noerr);
/* Define the precipitation target */
tqsetc("a", iFCC, 0, -1.0, &numcon, &noerr);
/* Define the target variable (temperature) and perform the
equilibrium calculation. The estimate for the target variable,
passed C via vals[0], is set to 1000 K. */
vals[0] = 1000.0;
tqce("T", 0, 0, vals, &noerr);
/* Retrieve the calculated temperature */
tqgetr("T", 0, 0, &temp, &noerr);
printf("Calculated solidus temperature: %g K\n", temp);
Output:
Calculated solidus temperature: 426.36 K |
/* Looking at the Pb-Sn phase diagram, this temperature is certainly
wrong. This can be demonstrated by retrieving the activity of the
liquid phase: */
tqgetr("ac", iLIQ, 0, &act, &noerr);
printf("Activity of liquid phase at %g K: %g\n", temp, act);
Output:
Activity of liquid phase at 426.36 K: 0.891702 |
/* Since the activity is less than unity, the liquid phase is not
stable, thus this cannot be the solidus point. The reason is that
ChemApp found the phase boundary between FCC and the two-phase
region FCC+BCT, instead of that between FCC and FCC+Liquid. Note
also that although the initial estimate for the target variable
has been set to 1000 K, which is certainly closer to the solidus
point than to the FCC/FCC+BCT phase boundary, this does not
guarantee that of two possible solutions, the one closer to the
initial estimate is found. */
/* To keep ChemApp from finding the unwanted phase boundary at lower
temperatures, tell it to limit its search to temperatures above
450 K: */
tqclim("TLOW", 450.0, &noerr);
/* Recalculate the equilibrium */
tqce("T", 0, 0, vals, &noerr);
/* Retrieve the calculated temperature */
tqgetr("T", 0, 0, &temp, &noerr);
printf("Calculated solidus temperature: %g K\n", temp);
Output:
Calculated solidus temperature: 505.369 K |
/* Check the activity of the liquid phase again to verify that it is
indeed stable: */
tqgetr("ac", iLIQ, 0, &act, &noerr);
printf("Activity of liquid phase at %g K: %g\n", temp, act);
Output:
Activity of liquid phase at 505.369 K: 1 |
/* Since the activity is unity, we know that the temperature we
found is correct. */
}
return 0;
}