chemapp.basic
This module provides the complete basic ChemApp library API for use in Python programs.
Module Contents
Classes
Available amount units. 

Errors generated by the ChemApp API's standard error reporting mechanism. 

Available variables for setting conditions in equilibrium calculations. 

Configuration options for ChemApp. 

Available energy units. 

Available data items that can be requested for functions. 

Available function sum data for ChemSage.dat with functions. 

Enum to specific the type of interaction parameter to extract. 

Input/output options used by 

Limit variables that can be set during target calculations. 

Available data items that can be requested for phase constituents. 

Available variables for extracting thermodynamic properties of phase 

Variables that can be used to adjust conditions as part of phase map 

Available pressure units. 

Quantities available for setting units. 

Result variables available after equilibrium calculations. 

Available solution models. 

Status values for phases and phase constituents. 

Available variables for stream properties that can be extracted. 

Variables that can be used in target calculations to arrive at a specified 

Available temperature units. 

Available volume units. 
Functions
Turn off logging of ChemApp calls to 'calls.log' 

Set the ChemApp calls to be output including returns to 'calls.log' 


Calculate a quadruplet or pair fraction (only for the models SUBG, QUAS and 

Change selected data of a specified phase constituent or of a specified 

Calculate the equilibrium with the current settings of global conditions or 

Calculate the equilibrium with current settings of global conditions or 

Calculate the equilibrium, taking results from the previous equilibrium 

Calculate the equilibrium, taking results from the previous equilibrium 

Change a coefficient in a function. 

Get the charge of a phase constituent. 

Redirect input and output from ChemApp to another unit than the default, or 

Modify the upper and lower limits of the target variables pressure, 

Close a file that has been previously opened using TQOPNA, TQOPNB, TQOPNT, 

Change the name of the specified system component. 

Set a configuration option. 

Get the ChemApp copyright message. 

Change the status of the specified phase. 

Change the status of a specified phase constituent. 

Change the unit for the specified quantity. 

Change a prefactor of a function for an phase constituent. 

Get the number of expressions of a function. 

Get the current error message. All ChemApp error messages are written 

Get selected thermodynamic data of a specified phase constituent loaded 

Get thermodynamic data for a phase constituent. 

Get calculation results obtained by the last call to tqce, tqcel, tqmap, or 

Get a property of the specified function. 

Get the unit number and language used for error messages, and the unit 

Get the name of the specified sublattice constituent. 

Get the name of a specified phase. 

Get the name of the specified phase constituent. 

Get the name of the specified system component. 

Get selected excess Gibbs energy or excess magnetic parameters of a 

Get the status of a specified phase. 

Get the status of the specified phase constituent. 

Get the unit that is currently in use for a specified quantity. 

List all functions and prefactors of a phase constituent that make the 

Get the ChemApp license expiration date. 

Get the HASP dongle type and id. 

Get the user ID of the ChemApp library license holder. 

Get the calculated equilibrium sublattice site fraction. 

Get the name of the ChemApp library license holder. 

Get the program ID. 

Retrieve information stored in the header of a transparent file. 

Get the name of a function. 

Use this method to initialise ChemApp. 

Get the index number of the specified sublattice constituent. 

Get the zerobased index number of a specified phase. 

Get the zerobased index number of the specified phase constituent. 

Get the zerobased index number of the specified system component. 

Check whether the type of ChemApp currently used is ChemApp light. 

List all excess Gibbs energy or all excess magnetic interactions of a 

Perform a onedimensional phase mapping calculation, giving all phase 

Perform a onedimensional phase mapping calculation and list the results 

Get the solution model name for the specified phase 

Get the number of ternary exceptions of a phase. 

Get the total number of functions. 

Get the number of sublattice constituents of the specified sublattice. 

Get the total number of phases. 

Get the total number of constituents in the specified phase. 

Get the total number of system components. 

Get the number of sublattices of the specified phase. 

Get the number of excess/interaction parameters of a phase. 

Open a file for reading or writing by ChemApp. 

Open an ASCII thermochemical data file for reading by ChemApp. 

Open a transparent thermochemical data file for reading by ChemApp. 

Check if the specified phase constituent is permitted as an incoming 

Read a thermodynamic datafile in transparent format. 

Remove a condition from the equilibrium calculation. 

Read a thermodynamic datafile in ASCII format. 

Set a condition for the equilibrium calculation. 

Display the present settings. 

Get ChemApp's internal array dimensions. 

Set a phase constituent amount for the specified stream. 

Set an invariant state variable for the equilibrium calculation when the 

Get the stoichiometry and molecular mass of the specified phase constituent. 

Remove a stream. 

Get the stoichiometry and molecular mass of a system component. 

Define a stream and set its temperature and pressure. 

Get the calculated thermodynamic properties of a stream. 

Get the dimensions of the currently loaded thermochemical system. 

Get the ChemApp version number. 

Write a thermodynamic datafile in ASCII format. 

Write a character string to the Fortran units associated with 'LIST' and 
 class chemapp.basic.AmountUnit
Bases:
enum.Enum
Available amount units.
Amount
mol
gram
kg
tonne
pound
 class chemapp.basic.ChemAppError
Bases:
ChemAppPyError
Errors generated by the ChemApp API’s standard error reporting mechanism.
It is possible to acquire the ChemApp error number via the errno property. If this is not applicable, it will return 0.
 property errno: int
<int> The error number of ChemApp, if applicable. Defaults to 0.
 Return type:
int
 class chemapp.basic.ConditionVariable
Bases:
enum.Enum
Available variables for setting conditions in equilibrium calculations.
Value
Variable
Description
P
Total pressure
Last entered (pressure or volume) takes precedence. Default value is 1 bar.
VT
Total volume
Last entered (pressure or volume) takes precedence. Note that the use of this option to perform calculations at constant volume is discouraged, see Appendix B.4 for details.
T
Temperature
Default value is 1000 K.
A
Amount of phase
VAL >=0 defines a formation target calculation; VAL <0 a precipitation target calculation for a mixture phase. In a formation target calculation, the target variable is varied until unit activity and zero amount of the target phase is achieved. A precipitation target is defined as one where the target phase is the only one formed at equilibrium, and the second most stable phase has unit activity.
IA
Incoming amount
Valid for phase constituents and system components. Not permitted for TQSTEC.
MU
Chemical potential
Valid only for phase constituents. Not permitted for TQSTEC.
AC
Relative activity,
Valid only for phase constituents. Not permitted for TQSTEC.
CP, H, S, G, V,
Heat capacity, Enthalpy, Entropy, Gibbs energy, Volume
Valid for the entire system or for a phase. Extensive properties are either calculated for the equilibrium phases and are then dependent on the reference state chosen in the datafile, or for the chemical reaction when streams are defined, in which case they are relative to the state defined by the stream conditions.
AT
Relative activity
Relative activity of a phase constituent as target.
XT
Mole fraction
Mole fraction of a phase constituent as target.
XPT
Mole fraction
Mole fraction of a system component in a phase as target.
 class chemapp.basic.ConfigurationOption
Bases:
enum.Enum
Configuration options for ChemApp.
 Parameters:
E – The electron configuration option.
 class chemapp.basic.EnergyUnit
Bases:
enum.Enum
Available energy units.
Energy
J
cal
Btu
kWh
 class chemapp.basic.FunctionData
Bases:
enum.Enum
Available data items that can be requested for functions.
FunctionData
Description
H
Enthalpy
S
Entropy
Cp
Cp function coefficients
Tt
Temperature of transition
Ht
Heat of transition
V
Volume
 class chemapp.basic.FunctionSumVariable
Bases:
enum.Enum
Available function sum data for ChemSage.dat with functions.
Option
Meaning
G
Gibbs energy function parameters
V
Volumetric expansion parameters
 class chemapp.basic.InteractionVariable
Bases:
enum.Enum
Enum to specific the type of interaction parameter to extract.
Option
Meaning
G
Gibbs energy function excess parameters
M
Magnetic interaction parameters
 class chemapp.basic.IoOption
Bases:
enum.Enum
Input/output options used by
tqgio()
andtqcio()
.Option
Meaning
Default value
FILE
Unit from which the thermodynamic datafile is read
10
ERROR
Unit to which error messages are directed
6
LIST
Unit to which optional equilibrium output lists are directed
6
LANGUAGE
Language used for error messages (1=English, 2=German, 3=French, 4=Swedish, 5=Finnish)
1
 class chemapp.basic.LimitVariable
Bases:
enum.Enum
Limit variables that can be set during target calculations.
Option
Variable Limit
Default Value
PLOW
Low pressure limit
1E50 bar
PHIGH
High pressure limit
1E7 bar
VLOW
Low volume limit
1E7 dm3
VHIGH
High volume limit
1E50 dm3
TLOW
Low temperature limit
298.15 K
THIGH
High temperature limit
6000 K
 class chemapp.basic.PhaseConstituentData
Bases:
enum.Enum
Available data items that can be requested for phase constituents.
OPTION
Variable
H
Enthalpy/J at 298.15K
S
Entropy/J*K1 at 298.15K
Cp
Heat capacity expression/J.K1 or Helgeson terms for the models PIHZ, HELZ, HTSZ, HTWZ or HTDZ
V
Molar volume data in input order of a condensed phase constituent
Gc
Critical properties in input order of a gas phase constituent
Ht
Transformation enthalpy/J at the upper temperature limit for a Cp range
M
Curie/Neel temperature and average magnetic moment per atom for a magnetic phase constituent
Tt
Upper temperature limit/K for a Cp range
Ch
Charge of an aqueous phase constituent
 class chemapp.basic.PhaseConstituentVariable
Bases:
enum.Enum
Available variables for extracting thermodynamic properties of phase constituents.
Value
Description
CP
Heat capacity
G
Gibbs energy
H
Enthalpy
S
Entropy
T
Temperature (used to retrieve the upper limit of the current temperature interval for a given phase constituent or a stoichiometric condensed phase)
V
Volume
 class chemapp.basic.PhaseMapVariable
Bases:
enum.Enum
Variables that can be used to adjust conditions as part of phase map calculations.
Option
Variable
Comment
PF / PN
Total pressure
Pressure is the search variable. The upper and lower bounds of the pressure search interval are in VALS(1) and VALS(2). Use option ‘PF’ for the first call to
tqmap()
, and ‘PN’ for all subsequent ones.TF / TN
Temperature
Temperature is the search variable. The upper and lower bounds of the temperature search interval are in VALS(1) and VALS(2). Use option ‘TF’ for the first call to
tqmap()
, and ‘TN’ for all subsequent ones.IA0 / IAF / IAN
Incoming amount
Incoming amount is the search variable. The upper and lower bounds of the composition search interval are in VALS(1) and VALS(2). If 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. Use option ‘IAN’ for all subsequent ones.
 class chemapp.basic.PressureUnit
Bases:
enum.Enum
Available pressure units.
Option
bar
atm
Pa
kPa
psi
torr
 class chemapp.basic.Quantity
Bases:
enum.Enum
Quantities available for setting units.
Quantity
Unit
Pressure
bar
atm
Pa
kPa
psi
torr
Volume
dm3
cm3
m3
ft3
in3
Temperature
K
C
F
Energy
J
cal
Btu
kWh
Amount
mol
gram
kg
tonne
pound
 class chemapp.basic.ResultVariable
Bases:
enum.Enum
Result variables available after equilibrium calculations.
Option
Variable
Comment
P
Total pressure
—
VT
Total volume
—
T
Temperature
—
A
Equilibrium amount
—
IA
Incoming amount
Not valid for phases or for the entire system
MU, AC
Chemical potential, Activity/fugacity
Relative values for phases and constituents; absolute values for system components; fugacities in current pressure unit for gas phase constituents.
pH, Eh
pH, Eh/V
The calculation of pH and Eh/V requires that the constituents H+ in the aqueous phase and H2 in the gas phase be present in the thermochemical datafile. If pH and Eh/V cannot be calculated, theoutput VAL=0.0 will be returned. In order for ChemApp to recognize H+ and H2 in the datafile, the names of the system components hydrogen and aqueous electron must be ‘H’ and ‘EA’, respectively (see TQCNSC).
CP, H, S, G, V,
Heat capacity, Enthalpy, Entropy, Gibbs energy, Volume
Not valid for system components. Extensive properties for the equilibrium state dependent on the inherent reference state of the data. However, when the entire system is selected and streams are used, the values represent balances, i.e. the extensive property for the equilibrium state minus the sum of values for all streams. To obtain the total volume in this case, use option ‘VT’.
CPM, HM, SM, GM, VM
Heat capacity/ amount unit, Enthalpy/ amount unit, Entropy/ amount unit, Gibbs energy/ amount unit, Volume/ amount unit
Not valid for system components. Partial values are returned for constituents, integral values for phases. Values are valid for default or selected amount units.
X
Fraction
Mass or mole fraction of a system component in the system, depending on the default or selected amount unit.
XP
Fraction
Mass or mole fraction of a system component in a phase, depending on the default or selected amount unit.
AP
Equilibrium amount
Equilibrium amount of (a) system component(s) in a phase.
 class chemapp.basic.SolutionModel
Bases:
enum.Enum
Available solution models.
Model
Description
BDEF
Binary defect formalism
GAYE
GayeKapoorFrohberg cell formalism with or without nonoxidic solutes
HOCH
HochArpshofen formalism
HOCHM
HochArpshofen formalism with magnetism
IDBS
Gaseous model  CHOSNAr superfluid formalism
IDMX
Ideal mixing
IDVT
Gaseous model  Virial equation with Tsonopoulos second virial coefficient correlation
PURE
Stoichiometric condensed phase
QKTO
General polynomial Kohler/Toop formalism
QKTOM
General polynomial Kohler/Toop formalism with magnetism
QSOL
Modified quasichemical formalism with nonoxidic solutes
QUAS
Modified quasichemical formalism
QUSL
Twosublattice equivalent fraction formalism as a polynomial
QUSLM
Twosublattice equivalent fraction formalism as a polynomial with magnetism
RKMP
RedlichKisterMuggianu polynomial
RKMPM
RedlichKisterMuggianu polynomial with magnetism
SUBE
Extended compound energy formalism
SUBEM
Extended compound energy formalism with magnetism
SUBG
Quadruplet quasichemical model
SUBGM
Quadruplet quasichemical model with magnetism
SUBI
Twosublattice ionic formalism
SUBL
Compound energy formalism
SUBLM
Compound energy formalism with magnetism
SUBM
Twosublattice equivalent fraction formalism
SUBMM
Twosublattice equivalent fraction formalism with magnetism
SUBO
Twosublattice order/disorder formalism
SUBOM
Twosublattice order/disorder formalism with magnetism
SUBQ
Quadruplet quasichemical model with compositiondependent coordination numbers
SUBQM
Quadruplet quasichemical model with compositiondependent coordination numbers with magnetism
SUBS
Species chemical potential/bond energy formalism
WAGN
Unified interaction parameter formalism
WAGNM
Unified interaction parameter formalism with magnetism
HELZ
Aqueous model  Revised HelgesonKirkhamFlowers formalism
HTDZ
Aqueous model  HelgesonTangerShock formalism (Davies)
HTSZ
Aqueous model  HelgesonTangerShock formalism (ideal)
HTWZ
Aqueous model  HelgesonTangerShock formalism (DebyeHueckel)
IDDZ
Aqueous model  Davies formalism
IDWZ
Aqueous model  Ideal aqueous mixing
PIHZ
Aqueous model  HelgesonTangerShock formalism (Pitzer)
PIMZ
Aqueous model  Pitzer formalism
PITZ
Aqueous model  Pitzer formalism with fixed alpha1 and alpha2
PIWZ
Aqueous model  Pitzer formalism without Etheta and Etheta’
SITZ
Aqueous model  Specific ioninteraction formalism
 class chemapp.basic.Status
Bases:
enum.Enum
Status values for phases and phase constituents.
Status
Description
ENTERED
The phase or constituent is included in the equilibrium calculation. An included phase is not necessarily stable at equilibrium.
DORMANT
The phase or constituent is excluded from the mass balances (it will appear with zero amount at equilibrium), but its activity is calculated. If the calculated activity for a phase is greater than one, it would be stable if entered.
ELIMINATED
The phase or constituent is ignored in the equilibrium calculation
 class chemapp.basic.StreamVariable(*args, **kwds)
Bases:
enum.Enum
Available variables for stream properties that can be extracted.
Option
Variable
Unit
CP
Heat capacity
[current energy unit]/K
H
Enthalpy
[current energy unit]
S
Entropy
[current energy unit]/K
G
Gibbs energy
[current energy unit]
V
Volume
[current volume unit]
 class chemapp.basic.TargetVariable
Bases:
enum.Enum
Variables that can be used in target calculations to arrive at a specified target condition.
Option
Variable
Description
P
Total pressure
Pressure is a target variable. The value VALS(1) serves as an initial estimate, VALS(2) is not used.
V
Total volume
 Volume is a target variable. The value VALS(1) serves as an
initial estimate, VALS(2) is not used.
T
Temperature
Temperature is a target variable. The value VALS(1) serves as an initial estimate, VALS(2) is not used.
IA, IA0, MU
Incoming amount, Chemical potential
Incoming amount is a target variable. The values VALS(1) and VALS(2) denote lower and upper limits, respectively. When defining streams, the constituent is included in the last stream considered. If incoming amounts for more then one substance need to be defined, all except the last one have to be called using ‘IA0’ as option to TQCE/TQCEL. Once ‘IA’ is passed for the last incoming amount, the first calculation is made.
Blank
Calculate without any target variable, VALS is not used.
 class chemapp.basic.TemperatureUnit
Bases:
enum.Enum
Available temperature units.
Temperature
K
C
F
 class chemapp.basic.VolumeUnit
Bases:
enum.Enum
Available volume units.
Volume
dm3
cm3
m3
ft3
in3
 chemapp.basic.disable_logging()
Turn off logging of ChemApp calls to ‘calls.log’
 Return type:
None
 chemapp.basic.enable_logging()
Set the ChemApp calls to be output including returns to ‘calls.log’
 Return type:
None
 chemapp.basic.tqbond(indexp, indexa, indexb, indexc, indexd)
Calculate a quadruplet or pair fraction (only for the models SUBG, QUAS and QSOL).
Note that the second sublattice constituent index = (total number of constituents of the first sublattice + the second sublattice constituent index). The index numbers may be entered in any order, but two sublattice constituents must belong to the first sublattice and two to the second
 Parameters:
indexp (int) – zerobased phase index
indexa (int) – zerobased sublattice constituent index
indexb (int) – zerobased sublattice constituent index
indexc (int) – zerobased sublattice constituent index
indexd (int) – zerobased sublattice constituent index
 Returns:
quadruplet or pair fraction
 Return type:
float
 chemapp.basic.tqcdat(i1, i2, i3, i4, i5, val)
Change selected data of a specified phase constituent or of a specified phase from a thermodynamic datafile in ASCII format. If a phase is included with more than one copy in the datafile, then all copies of the phase will be identically changed.
 Parameters:
i1 (int) – zerobased index number as described below
i2 (int) – zerobased index number as described below
i3 (int) – zerobased index number as described below
i4 (int) – zerobased index number as described below
i5 (int) – zerobased index number as described below
val (float) – new value of the selected quantity for the specified phase constituent of for the specified phase
 Return type:
int
Values of i1i5 required when calling TQCDAT:
Enthalpy:
1, 0, 0, I, M
I
= number of phase constituentM
= number of phaseEntropy:
1, 0, 1, I, M
I
= number of phase constituentM
= number of phaseHeat capacity:
1, INDEXR, N, I, M
INDEXR
= number of Cp expressionN
= number of term in the Cp expressionI
= number of phase constituentM
= number of phase__Note__: The Cp expression will normally contain 4 terms, Cp = a + b*T + c*T2 + d/T2, but can also include six terms of variable powers of temperature. The maximum value of N is thus 10. For the models PIHZ, HELZ, HTSZ, HTWZ and HTDZ, one expression (INDEXR=1) contains seven Helgeson terms. Heat capacity data will be returned also for files with stored values of standard Gibbs energy.
Heat of transformation:
1, INDEXR, N, I, M
INDEXR
= number of Cp expression (this number must always be less than the total number of Cp expressions)N
= the total number of terms in the Cp expressions + 1I
= number of phase constituentM
= number of phaseMolar volume:
4, 1, 1, I, M
I
= number of phase constituentM
= number of phaseCoefficients of the equation of state:
4, INDEXR, N, I, M
INDEXR = 2
: thermal expansion (= a + b*T + c/T + d/T2)INDEXR = 3
: compressibility (= a + b*T + c*T2 + d*T3) or bulk modulus (= a + b*(TT0) + c*(T2T02) + d*(1/T1/T0)), depending on the equation of state being usedINDEXR = 4
: pressure derivative of the bulk modulus (= a + b*(TT0)*ln(T/T0))N
= number of coefficientI
= number of phase constituentM
= number of phaseCritical temperature of a constituent of a gas phase modelled with IDVT or
IDVD:
4, 1, 1, I, 1
I
= number of phase constituentCritical pressure of a constituent of a gas phase modelled with IDVT or
IDVD:
4, 1, 2, I, 1
I
= number of phase constituentCritical volume of a constituent of a gas phase modelled with IDVT or
IDVD:
4, 1, 3, I, 1
I
= number of phase constituentAcentric factor of a constituent of a gas phase modelled with IDVT or
IDVD:
4, 1, 4, I, 1
I
= number of phase constituentDipole moment of a constituent of a gas phase modelled with IDVD:
4, 1, 5, I, 1
I
= number of phase constituentCurie/Neel temperature of a phase constituent of a magnetic phase:
7, 1, 1, I, M
I
= number of phase constituentM
= number of phaseAverage magnetic moment/atom of a phase constituent of a magnetic phase:
7, 1, 2, I, M
I
= number of phase constituentM
= number of phaseExcess Curie temperature term of a magnetic phase:
10, INDEXX, NOEXPR, 1, M
INDEXX
= number of interaction according to the order of the datafileNOEXPR
= number of RedlichKister expression of interaction INDEXXM
= number of phaseNote:
NOEXPR = 1
for the RedlichKister term with power zero, and so on.Excess magnetic moment term of a magnetic phase:
10, INDEXX, NOEXPR, 2, M
INDEXX
= number of interaction according to the order of the datafileNOEXPR
= number of RedlichKister expression of interaction INDEXXM
= number of phaseNote:
NOEXPR = 1
for the RedlichKister term with power zero, and so on.Excess Gibbs energy coefficient:
13, INDEXX, NOEXPR, N, M
INDEXX
= number of interaction according to the order of the datafileNOEXPR
= number of expression of interaction INDEXXN
= number of termM
= number of phaseNote: The standard excess Gibbs energy expression contains maximum 6 terms of a + b*T + c*T*ln(T) + d*T2 + e*T3 + f/T (+g*P + h*P2).
NOEXPR = 1
for the RedlichKister term with power zero, and so on. For phases not containing any RedlichKister terms and SUBG excepted,NOEXPR
is one. SUBG involves excess Gibbs energy expressions containing six terms with variable powers of temperature. For any of these termsNOEXPR
= 2. Excess Gibbs energy expressions with factor P (= pressure) have term numbers (MIT+1) to (MIT+MIT) where MIT is the number of temperature dependent terms used in the standard expression.Stoichiometry:
16 ,1, INDEXC, I, M
INDEXC
= number of system componentI
= number of phase constituentM
= number of phaseNote: Since changing the stoichiometry might lead to erroneous calculations for several solution models, this option is intended for expert users only.
 chemapp.basic.tqce(option, indexp=1, indexc=1, vals=None)
Calculate the equilibrium with the current settings of global conditions or streams.
 Parameters:
option (chemapp.core.TargetVariable) – option indicating the target variable for the calculation
indexp (int) – zerobased phase index
indexc (int) – zerobased phase constituent index
vals (Tuple[float, float]  None) – initial estimate of the target variable, or the lower and upper limits of an incoming amount, if necessary
 Return type:
None
 chemapp.basic.tqcel(option, indexp=1, indexc=1, vals=None)
Calculate the equilibrium with current settings of global conditions or streams, and list the results in the form of a ChemSage format output table.
 Parameters:
option (chemapp.core.TargetVariable) – option indicating the target variable for the calculation
indexp (int) – zerobased phase index
indexc (int) – zerobased phase constituent index
vals (Tuple[float, float]  None) – initial estimate of the target variable, or the lower and upper limits of an incoming amount, if necessary
 Return type:
None
 chemapp.basic.tqcen(option, indexp=1, indexc=1, vals=None)
Calculate the equilibrium, taking results from the previous equilibrium calculation as initial estimates
 Parameters:
option (chemapp.core.TargetVariable) – option indicating the target variable for the calculation
indexp (int) – zerobased phase index
indexc (int) – zerobased phase constituent index
vals (Tuple[float, float]  None) – initial estimate of the target variable, or the lower and upper limits of an incoming amount, if necessary
 Return type:
None
 chemapp.basic.tqcenl(option, indexp=1, indexc=1, vals=None)
Calculate the equilibrium, taking results from the previous equilibrium calculation as initial estimates, and list the results in the form of a ChemSage format output table.
 Parameters:
option (chemapp.core.TargetVariable) – option indicating the target variable for the calculation
indexp (int) – zerobased phase index
indexc (int) – zerobased phase constituent index
vals (Tuple[float, float]  None) – initial estimate of the target variable, or the lower and upper limits of an incoming amount, if necessary
 Return type:
None
 chemapp.basic.tqcfct(indexf, option, indexc, indexr, indexx, value)
Change a coefficient in a function.
Note
You can only use this function if the ChemSage.dat contains functions, which is available when exporting from FactSage 8.1+
 Parameters:
indexf (int) – Index number for the function as obtained by calling
TQIFCT
/TQNFCT
For Volume only: Index number for the solution phaseoption (chemapp.core.FunctionData) – property type (FunctionData enumeration) For Volume only Index number for the constituent of phase indexf
indexc (int) – For Volume only zerobased function index, only used for V
indexr (int) – Index number for the Cp range, not being used for H and S For Volume only Index number for the molar volume function as obtained by calling
TQIFCT
/TQNFCT
indexx (int) –
Index number for a coefficient
This can be maximum 4 when no extra powers are entered, else up to
[(number of extra powers)+4]
. The number of extra powers is maximum 6. The extra powers cannot be modified. Only affecting Cp and Volumevalue (float) – New value of the coefficient
 Return type:
None
 chemapp.basic.tqchar(indexp, indexc)
Get the charge of a phase constituent.
 Parameters:
indexp (int) – zerobased phase index
indexc (int) – zerobased phase constituent index
 Returns:
phase constituent charge
 Return type:
float
 chemapp.basic.tqcio(option, ival)
Redirect input and output from ChemApp to another unit than the default, or select a different language for the error messages than the default.
 Parameters:
option (chemapp.core.IoOption) – input/output option
ival (int) – a legal unit number, or to a language index
 Return type:
None
 chemapp.basic.tqclim(option, val)
Modify the upper and lower limits of the target variables pressure, volume or temperature.
Find more information on the available values for LimitVariable in the chemapp.core.LimitVariable documentation.
 Parameters:
option (chemapp.core.LimitVariable) – target variable limit to set
val (float) – new value for the limit
 Return type:
None
 chemapp.basic.tqclos(unit)
Close a file that has been previously opened using TQOPNA, TQOPNB, TQOPNT, or TQOPEN.
 Parameters:
unit (int) – unit number under which the file was opened
 Return type:
None
 chemapp.basic.tqcnsc(indexs, name)
Change the name of the specified system component.
 Parameters:
indexs (int) – zerobased system component index
name (str) – new name
 Return type:
None
 chemapp.basic.tqconf(option, valuea=1, valueb=1, valuec=1)
Set a configuration option.
 Parameters:
option (chemapp.core.ConfigurationOption) – configuration option
valuea (int) – configuration value A
valuea – configuration value B
valuea – configuration value C
valueb (int) –
valuec (int) –
 Return type:
None
 chemapp.basic.tqcprt()
Get the ChemApp copyright message.
 Returns:
ChemApp copyright message
 Return type:
str
 chemapp.basic.tqcsp(indexp, status)
Change the status of the specified phase.
Find more information on the available values for Status in the chemapp.core.Status documentation.
 Parameters:
indexp (int) – zerobased phase index
status (chemapp.core.Status) – new phase status
 Return type:
None
 chemapp.basic.tqcspc(indexp, indexc, status)
Change the status of a specified phase constituent.
Find more information on the available values for Status in the chemapp.core.Status documentation.
 Parameters:
indexp (int) – zerobased phase index
indexc (int) – zerobased phase constituent index
status (chemapp.core.Status) – new phase constituent status
 Return type:
None
 chemapp.basic.tqcsu(option, unit)
Change the unit for the specified quantity.
Find more information on the available values for the units in the respective parts of the documentation:
Option: chemapp.core.Quantity
PressureUnit: chemapp.core.PressureUnit
VolumeUnit: chemapp.core.VolumeUnit
TemperatureUnit: chemapp.core.TemperatureUnit
EnergyUnit: chemapp.core.EnergyUnit
AmountUnit: chemapp.core.AmountUnit
 Parameters:
option (chemapp.core.Quantity) – the quantity of which the unit is changed
unit (chemapp.core.PressureUnit  chemapp.core.VolumeUnit  chemapp.core.TemperatureUnit  chemapp.core.EnergyUnit  chemapp.core.AmountUnit) – the new unit
 Return type:
None
 chemapp.basic.tqcsum(option, indexp, indexc, nval, value)
Change a prefactor of a function for an phase constituent.
Note
You can only use this function if the ChemSage.dat contains functions, which is available when exporting from FactSage 8.1+
The prefactor is the coefficient of the function in the Gibbs energy function. The existing factors can be listed with chemapp.basic.tqgsum.
 Parameters:
option (chemapp.core.FunctionSumVariable) – Either Gibbs (‘G’) or volume (‘V’) functions
indexp (int) – zerobased phase index
indexc (int) – zerobased constituent index
nval (int) – zerobased index of the factor in the list of functions
value (float) – new value for the prefactor
 Return type:
None
 chemapp.basic.tqefct(indexf)
Get the number of expressions of a function.
Note
You can only use this function if the ChemSage.dat contains functions, which is available when exporting from FactSage 8.2+
 Parameters:
indexf (int) – zerobased function index
 Returns:
number of expressions
 Return type:
str
 chemapp.basic.tqerr()
Get the current error message. All ChemApp error messages are written sequentially to the unit/file associated with ERROR. Use tqcio to change the associated unit/file and on how to prevent the automatic output of error messages.
Note
This routine typically does not need to be called actively. Any error that is interrupting program flow will be raised as an expression, containing the error message that tqerr() would yield.
 Returns:
error message
 Return type:
str
 chemapp.basic.tqgdat(indexp, indexc, option, indexr=0)
Get selected thermodynamic data of a specified phase constituent loaded from a thermodynamic datafile in ASCII format.
 Parameters:
indexp (int) – zerobased phase index
indexc (int) – zerobased phase constituent index
option (chemapp.core.PhaseConstituentData) – option
indexr (int) – zerobased index number of a Cp expression (only used for options Cp, Tt, and Ht)
 Returns:
thermodynamic coefficients
 Return type:
List[float]
 chemapp.basic.tqgdpc(option, indexp, indexc)
Get thermodynamic data for a phase constituent.
Find more information on the available values for PhaseConstituentVariable in the chemapp.core.PhaseConstituentVariable documentation.
 Parameters:
option (chemapp.core.PhaseConstituentVariable) – option identifying the thermodynamic quantity
indexp (int) – zerobased phase index
indexc (int) – zerobased phase constituent index
 Returns:
thermodynamic quantity. The return value (for a single constituent, selected using INDEXP and INDEXC) is dimensionless and is calculated for the default temperature, or for the last temperature set with TQSETC or TQSTEC, or calculated using TQCE/TQMAP
 Return type:
float
Note
To obtain quantities having dimensions, the return value needs to be multiplied by R*T (gas constant times temperature).
 chemapp.basic.tqgetr(option, indexp=1, index=1)
Get calculation results obtained by the last call to tqce, tqcel, tqmap, or tqmapl.
More information:
 Parameters:
option (chemapp.core.ResultVariable) – option indicating the state variable to retrieve
indexp (int) – zerobased phase index
index (int) – zerobased phase constituent or system component index
 Returns:
retrieved float value or array of float values.
indexp
andindex
values determine when a single value or array is returned. See the table below for an explanation.More information:
https://python.gtttechnologies.de/doc/chemapp/autoapi/chemapp/basic/index.html#chemapp.basic.tqgetr
 Return type:
floatList[float]
 chemapp.basic.tqgfct(indexf, option, indexc=0, indexr=0)
Get a property of the specified function.
More information:
Note
You can only use this function if the ChemSage.dat contains functions, which is available when exporting from FactSage 8.1+
 Parameters:
indexf (int) – Index number for the function as obtained by calling
TQIFCT
/TQNFCT
For Volume only: Index number for the solution phaseoption (chemapp.core.FunctionData) – property type For Volume only Index number for the constituent of phase indexf
indexc (int) – For Volume only zerobased function index, only used for V, default=0
indexr (int) – Index number for the Cp range, not being used for H and S, default=0 For Volume only Index number for the molar volume function as obtained by calling
TQIFCT
/TQNFCT
 Return type:
None
 chemapp.basic.tqgio(option)
Get the unit number and language used for error messages, and the unit number for the thermodynamic datafile and optional output lists, respectively.
More information:
https://python.gtttechnologies.de/doc/chemapp/autoapi/chemapp/core/index.html#chemapp.core.IoOption
 Parameters:
option (chemapp.core.IoOption) – input/output option
 Returns:
file unit number or language index
 Return type:
int
 chemapp.basic.tqgnlc(indexp, indexl, indexc)
Get the name of the specified sublattice constituent.
 Parameters:
indexp (int) – zerobased phase index
indexl (int) – zerobased sublattice index
indexc (int) – zerobased sublattice constituent index
 Returns:
sublattice constituent name
 Return type:
str
 chemapp.basic.tqgnp(indexp)
Get the name of a specified phase.
 Parameters:
indexp (int) – zerobased phase index
 Returns:
phase name
 Return type:
str
 chemapp.basic.tqgnpc(indexp, indexc)
Get the name of the specified phase constituent.
 Parameters:
indexp (int) – zerobased phase index
indexc (int) – zerobased phase constituent index
 Returns:
phase constituent name
 Return type:
str
 chemapp.basic.tqgnsc(indexs)
Get the name of the specified system component.
 Parameters:
indexs (int) – zerobased system component index
 Returns:
phase constituent name
 Return type:
str
 chemapp.basic.tqgpar(indexp, object, indexx)
Get selected excess Gibbs energy or excess magnetic parameters of a specified phase from a thermodynamic datafile in ASCII format.
 Parameters:
indexp (int) – zerobased phase index
option – interaction variation, either (‘G’) excess Gibbs energy interactions or (‘M’) excess magnetic interactions
indexx (int) – zerobased interaction index
object (chemapp.core.InteractionVariable) –
 Returns:
int –
noexpr
, the number of temperaturedependent expressions of interaction indexx.int –
nvala
, the number of values of each temperature dependent expression.List[float] –
'noexpr'
by'nvala'
values, i.e.'noexpr'*'nvala'
values of the quantity requested.
 Return type:
Tuple[int, int, List[float]]
 chemapp.basic.tqgsp(indexp)
Get the status of a specified phase.
More information:
https://python.gtttechnologies.de/doc/chemapp/autoapi/chemapp/core/index.html#chemapp.core.Status
 Parameters:
indexp (int) – zerobased phase index
 Returns:
status
 Return type:
 chemapp.basic.tqgspc(indexp, indexc)
Get the status of the specified phase constituent.
More information:
https://python.gtttechnologies.de/doc/chemapp/autoapi/chemapp/core/index.html#chemapp.core.Status
 Parameters:
indexp (int) – zerobased phase index
indexc (int) – zerobased phase constituent index
 Returns:
phase constituent status
 Return type:
 chemapp.basic.tqgsu(option)
Get the unit that is currently in use for a specified quantity.
Quantity
Unit
Pressure
bar
atm
Pa
kPa
psi
torr
Volume
dm3
cm3
m3
ft3
in3
Temperature
K
C
F
Energy
J
cal
Btu
kWh
Amount
mol
gram
kg
tonne
poudn
 Parameters:
option (chemapp.core.Quantity) – the quantity for which the current unit is requested
 Returns:
unit being used
 Return type:
unit
 chemapp.basic.tqgsum(option, indexp, indexc)
List all functions and prefactors of a phase constituent that make the Gibbs energy function or volume function
The lists
factors
andnames
are of the exact length ofnofct
. Parameters:
option (chemapp.core.FunctionSumVariable) – (‘G’) Gibbs energy functions or (‘V’) volume functions
indexp (int) – zerobased phase index
indexc (int) – zerobased constituent index
 Returns:
int – total number of functions used
List[float] – prefactors / coefficients of the used functions
List[str] – names of functions
.. note:: – You can only use this function if the ChemSage.dat contains functions, which is available when exporting from FactSage 8.1+
 Return type:
Tuple[int, List[float], List[str]]
 chemapp.basic.tqgted()
Get the ChemApp license expiration date.
 Returns:
license expiry date
 Return type:
int
 chemapp.basic.tqgthi()
Get the HASP dongle type and id.
 Returns:
(dongle type, dongle id)
 Return type:
Tuple[str,int]
 chemapp.basic.tqgtid()
Get the user ID of the ChemApp library license holder.
 Returns:
User ID
 Return type:
str
 chemapp.basic.tqgtlc(indexp, indexl, indexc)
Get the calculated equilibrium sublattice site fraction.
 Parameters:
indexp (int) – zerobased phase index
indexl (int) – zerobased sublattice index
indexc (int) – zerobased sublattice constituent index
 Returns:
sublattice site fraction
 Return type:
float
 chemapp.basic.tqgtnm()
Get the name of the ChemApp library license holder.
 Returns:
ChemApp user name
 Return type:
str
 chemapp.basic.tqgtpi()
Get the program ID.
 Returns:
Program ID
 Return type:
str
 chemapp.basic.tqgtrh()
Retrieve information stored in the header of a transparent file.
More information:
https://python.gtttechnologies.de/doc/chemapp/autoapi/chemapp/basic/index.html#chemapp.basic.tqgtrh
 Returns:
(ver, nwp, vnw, nrp, vnr, dtc, dte, id, usr, rem) as described in the table.
 Return type:
Tuple[int, str, List[int], str, List[int], List[int], List[int], str, str, str]
 chemapp.basic.tqifct(indexf)
Get the name of a function.
 Parameters:
indexf (int) – index of the function
 Returns:
name of the function
 Return type:
str
Note
You can only use this function if the ChemSage.dat contains functions, which is available when exporting from FactSage 8.1+
 chemapp.basic.tqini()
Use this method to initialise ChemApp.
It must be called before any other ChemApp subroutine, or whenever you wish to reinstate the complete set of default values and units, and read a thermodynamic datafile.
 Return type:
None
 chemapp.basic.tqinlc(name, indexp, indexl)
Get the index number of the specified sublattice constituent.
 Parameters:
name (str) – sublattice constituent name
indexp (int) – zerobased phase index
indexl (int) – zerobased sublattice index
 Returns:
zerobased index
 Return type:
int
 chemapp.basic.tqinp(name)
Get the zerobased index number of a specified phase.
 Parameters:
name (str) – phase name
 Returns:
zerobased index
 Return type:
int
 chemapp.basic.tqinpc(name, indexp)
Get the zerobased index number of the specified phase constituent.
The required
indexp
can be found usingtqinp()
. Parameters:
name (str) – phase constituent name
indexp (int) – zerobased phase index
 Returns:
zerobased index
 Return type:
int
 chemapp.basic.tqinsc(name)
Get the zerobased index number of the specified system component.
 Parameters:
name (str) – system component name
 Returns:
zerobased index
 Return type:
int
 chemapp.basic.tqlite()
Check whether the type of ChemApp currently used is ChemApp light.
 Returns:
Light Version
 Return type:
bool
 chemapp.basic.tqlpar(indexp, object)
List all excess Gibbs energy or all excess magnetic interactions of a specified phase from a thermodynamic datafile in ASCII format.
The third item of the returned tuple will likely be removed in the future. It is obsolete.
 Parameters:
indexp (int) – zerobased phase index (int)
option – interaction variation (‘G’) excess Gibbs energy interactions or (‘M’) excess magnetic interactions
object (chemapp.core.InteractionVariable) –
 Returns:
int – the total number of interactions.
List[str] – all interaction strings
List[int] – lengths of each of the previous strings
 Return type:
Tuple[int, List[str], List[int]]
 chemapp.basic.tqmap(option, indexp, indexc, vals)
Perform a onedimensional phase mapping calculation, giving all phase transitions within a defined interval.
More information:
 Parameters:
option (chemapp.core.PhaseMapVariable) – option indicating the search variable for the calculation
indexp (int) – zerobased phase index
indexc (int) – zerobased phase constituent index
vals (List[float]) – array of two floats, the lower and upper limits of the search variable
 Returns:
whether more calls to tqmap is necessary
 Return type:
bool
 chemapp.basic.tqmapl(option, indexp, indexc, vals)
Perform a onedimensional phase mapping calculation and list the results in the form of a ChemSage format output table.
More information:
 Parameters:
option (chemapp.core.PhaseMapVariable) – option indicating the search variable for the calculation
indexp (int) – zerobased phase index
indexc (int) – zerobased phase constituent index
vals (List[float]) – array of two floats, the lower and upper limits of the search variable
 Returns:
whether more calls to tqmap is necessary
 Return type:
bool
 chemapp.basic.tqmodl(indexp)
Get the solution model name for the specified phase
 Parameters:
indexp (int) – zerobased phase index
 Returns:
solution model name
 Return type:
 chemapp.basic.tqnexc(indexp)
Get the number of ternary exceptions of a phase.
 Parameters:
indexp (int) – zerobased phase index
 Returns:
number of ternary oexceptions
 Return type:
int
 chemapp.basic.tqnfct()
Get the total number of functions.
 Returns:
total number of functions
 Return type:
int
Note
You can only use this function if the ChemSage.dat contains functions, which is available when exporting from FactSage 8.1+
 chemapp.basic.tqnolc(indexp, indexl)
Get the number of sublattice constituents of the specified sublattice.
 Parameters:
indexp (int) – zerobased phase index
indexl (int) – zerobased sublattice index
 Returns:
number of sublattice constituents
 Return type:
int
 chemapp.basic.tqnop()
Get the total number of phases.
 Returns:
number of phases
 Return type:
int
 chemapp.basic.tqnopc(indexp)
Get the total number of constituents in the specified phase.
 Parameters:
indexp (int) – zerobased phase index
 Returns:
number of phase constituents
 Return type:
int
 chemapp.basic.tqnosc()
Get the total number of system components.
 Returns:
number of system components
 Return type:
int
 chemapp.basic.tqnosl(indexp)
Get the number of sublattices of the specified phase.
 Parameters:
indexp (int) – zerobased phase index
 Returns:
number of sublattices
 Return type:
int
 chemapp.basic.tqnpar(indexp, option)
Get the number of excess/interaction parameters of a phase.
 Parameters:
indexp (int) – zerobased phase index
option (chemapp.core.InteractionVariable) – (‘G’) Gibbs energy or (‘V’) volume
 Returns:
number of excess parameters
 Return type:
int
 chemapp.basic.tqopen(file_path, unit)
Open a file for reading or writing by ChemApp.
The
file_path
is instantiated as apathlib.Path
object. Parameters:
file_path (str  pathlib.Path) – path of the file to open
unit (int) – unit number under which to open the file
 Return type:
None
 chemapp.basic.tqopna(file_path, unit)
Open an ASCII thermochemical data file for reading by ChemApp.
The
file_path
is instantiated as apathlib.Path
object. Parameters:
file_path (str  pathlib.Path) – path of the file to open
unit (int) – unit number under which to open the file
 Return type:
None
 chemapp.basic.tqopnt(file_path, unit)
Open a transparent thermochemical data file for reading by ChemApp.
The
file_path
is instantiated as apathlib.Path
object. Parameters:
file_path (str  pathlib.Path) – path of the file to open
unit (int) – unit number under which to open the file
 Return type:
None
 chemapp.basic.tqpcis(indexp, indexc)
Check if the specified phase constituent is permitted as an incoming species.
 Parameters:
indexp (int) – zerobased phase index
indexc (int) – zerobased phase constituent index
 Returns:
permittance
 Return type:
bool
 chemapp.basic.tqrcst()
Read a thermodynamic datafile in transparent format.
 Return type:
None
 chemapp.basic.tqremc(numcon)
Remove a condition from the equilibrium calculation.
 Parameters:
numcon (int) – condition number
 Return type:
None
 chemapp.basic.tqrfil()
Read a thermodynamic datafile in ASCII format.
 Return type:
None
 chemapp.basic.tqsetc(option, indexp, indexc, val)
Set a condition for the equilibrium calculation.
More information:
 Parameters:
option (chemapp.core.ConditionVariable) – option indicating the variable to set
indexp (int) – zerobased phase index
indexc (int) – zerobased phase constituent or system component index
val (float) – condition value
 Returns:
condition number
 Return type:
int
 chemapp.basic.tqshow()
Display the present settings.
tqshow displays information about the currently set conditions and streams, and is useful for debugging. Its output is stored on the unit/file associated with LIST.
It does not, effectively, print the output.
 Return type:
None
 chemapp.basic.tqsize()
Get ChemApp’s internal array dimensions.
More information:
https://python.gtttechnologies.de/doc/chemapp/autoapi/chemapp/basic/index.html#chemapp.basic.tqsize
 Returns:
(na, nb, nc, nd, ne, nf, ng, nh, ni, nj, nk)
 Return type:
Tuple[int, int, int, int, int, int, int, int, int, int, int]
 chemapp.basic.tqstca(idents, indexp, indexc, val)
Set a phase constituent amount for the specified stream.
 Parameters:
idents (str) – stream name
indexp (int) – zerobased phase index
indexc (int) – zerobased phase constituent index
val (float) – phase constituent amount
 Return type:
None
 chemapp.basic.tqstec(option, indexp, val)
Set an invariant state variable for the equilibrium calculation when the input conditions are defined by streams.
More information:
 Parameters:
option (chemapp.core.ConditionVariable) – option indicating the variable to set
indexp (int) – zerobased phase index
val (float) – condition value
 Return type:
None
 chemapp.basic.tqstpc(indexp, indexc)
Get the stoichiometry and molecular mass of the specified phase constituent.
 Parameters:
indexp (int) – zerobased phase index
indexc (int) – zerobased phase constituent index
 Returns:
Stoichiometric coefficients for all system components, and the molar mass of the phase constituent
 Return type:
Tuple[List[float], float]
 chemapp.basic.tqstrm(idents)
Remove a stream.
 Parameters:
idents (str) – stream name
 Return type:
None
 chemapp.basic.tqstsc(indexs)
Get the stoichiometry and molecular mass of a system component.
 Parameters:
indexs (int) – zerobased system component index
 Returns:
Stoichiometric coefficients of the system component, and the molar mass of the system component
 Return type:
Tuple[List[float], float]
 chemapp.basic.tqsttp(idents, T, P)
Define a stream and set its temperature and pressure.
 Parameters:
idents (str) – stream name
T (float) – temperature of the stream
P (float) – pressure of the stream
 Return type:
None
The input variable idents can have a maximum length of 150 characters. VALS must be a list of 2 real values, containing the temperature and pressure of the stream. These are entered with the default unit, or a unit set using
tqcsu()
. A stream is a means for transferring nonreacted matter to a reaction zone. It has constant temperature and pressure, and contains one or more phases of fixed composition. Stream input is required whenever differences in extensive properties between the initial and the equilibrium state are desired; for example, in calculations of the heat evolving from a combustion process, or of the entropy change caused by a phase transition. The maximum number of streams which are defined must not be greater than the maximum number of constituents permitted in the ChemApp version currently used (seetqsize()
, parameter ‘NA’).
 chemapp.basic.tqstxp(idents, option)
Get the calculated thermodynamic properties of a stream.
More information:
 Parameters:
idents (str) – name of the stream
option (chemapp.core.StreamVariable) – option identifying the thermodynamic quantity
 Returns:
thermodynamic quantity
 Return type:
float
 chemapp.basic.tqused()
Get the dimensions of the currently loaded thermochemical system.
 Returns:
Tuple[int, int, int, int, int, int, int, int, int, int, int] – (na, nb, nc, nd, ne, nf, ng, nh, ni, nj, nk)
More information
https (//python.gtttechnologies.de/doc/chemapp/autoapi/chemapp/basic/index.html#chemapp.basic.tqused)
 Return type:
Tuple[int, int, int, int, int, int, int, int, int, int, int]
 chemapp.basic.tqvers()
Get the ChemApp version number.
 Returns:
ChemApp version number
 Return type:
int
 chemapp.basic.tqwasc(file)
Write a thermodynamic datafile in ASCII format.
 Parameters:
file (str  pathlib.Path) – name of the data file
 Return type:
None
 chemapp.basic.tqwstr(option, text)
Write a character string to the Fortran units associated with ‘LIST’ and ‘ERROR’.
 Parameters:
option (chemapp.core.IoOption) – either ‘LIST’ or ‘ERROR’
text (str) – a character string of arbitrary length (be reasonable! ;)
 Return type:
None