FUNCTION
FUNCTION [function name]*8 [lowest temp. limit]
[expression 2]; [upper temp. limit 2] Y
[expression 1]; [upper temp. limit 1] Y
[expression 3]; [upper temp. limit 2] Y
.......... ; ..... Y
[expression n-1]; [upper temp. limit n-1] Y
[expression n]; [upper temp. limit n] N {Ref. Index} !
GIBBS can use predefined functions in the expression (TP-Function) of a Gibbs energy parameter or in other functions. This is often used when several parameters (or functions) have a common sub-expression, such as for metastable modifications of elements. This keyword can appear in both files for database definition and sequential storage, but not in FTP files. A valid function name can have up to 8 characters.
A function always starts with a lowest temperature limit of its applicability, followed by one or more (up to 10) expressions (TP-Functions) that are coded as mathematical relations of constants, functions of stable variables (T and P) and other entered functions (normally with a # suffix, e.g. +3*GHSERAL#).
The expression is a FORTRAN-like expression and operators +, -, *, = and ** can be used (** only with integer powers). Unary-functions LN or LOG (both for natural logarithm) and EXP (for exponential) can also be used. There is also the GEIN function available for the Einstein Model.
GEIN(THETA) = 1.5*R*THETA + 3*R*T*LN(1-EXP(-THETA/T))
Each expression (TP-Function) should end with a semicolon (;), and be followed by its upper applicable temperature limit and a continuation indicator (Y to continue with the next expression or N to end the function’s expression). If there is no continuation after a specific expression (TP-Function), the reference index can optionally be given after the N indicator.
A complete/valid function entry can be written in several continuation lines if the function’s expression (TP-Function) is too long or if there is more than one applicable expression (TP-Function), as the maximum length of each line is 78 characters.
It is recommended to always have at least one empty space at the beginning of each continuation line. Otherwise, the DATA module may misunderstand the expression or issue some error messages when reading the function entry. Avoid entering functions like the one below.
FUNCTION GHSERXY 298.15
-1000+1058*T-38.9*T*LOG(T)+GFUNXY#; 6000 N !
Such a function is read by the DATA module as
1000+1058*T-38.9*T*LOG(T)+GFUNXY#
rather than
-1000+1058*T-38.9*T*LOG(T)+GFUNXY#
This is because the DATA module concatenates all lines and removes extra spaces before trying to enter the function in the GIBBS workspace. Thus, the - sign is taken as a delimiter between 298.15 and 1000, and the function incorrectly becomes:
FUNCTION GHSERXY 298.15 1000+1058*T-38.9*T*LOG(T)+GFUNXY#; 6000 N !
Avoid this mistake by giving at least one empty space as the first character of a new line, such as
FUNCTION GHSERXY 298.15
-1000+1058*T-38.9*T*LOG(T)+GFUNXY#; 6000 N !
which is read correctly as
FUNCTION GHSERXY 298.15 -1000+1058*T-38.9*T*LOG(T)+GFUNXY#; 6000 N !
The lowest-temperature limit (in Kelvin) for the applicability of the (first) TP-Function in a function is normally set by default as 298.15 K, in most cases. However, you can set another limit when it is applicable (according to experimental data and assessments).
An upper-temperature limit (in Kelvin; followed by a Y or N sign) for the applicability of each TP-Function in a function must be given after the semicolon (;) immediately following the specific TP-Function. The highest-temperature limit (in Kelvin) for the applicability of the current function is always followed by the N sign. If a negative number is given as the lowest-temperature limit, it assumes there are breakpoints in pressure for this function. In these cases, it is interpreted as the lowest-pressure limit (in Pascal), and the other limits in the current function is also taken as pressure limit values (in Pascal).
The temperature/pressure limits for the functions are checked during calculations. An indicator is set if the actual temperature/pressure condition is below the lowest temperature/pressure limit or above the highest temperature/pressure limit. In these cases, an extrapolation is done using the TP-Function valid in the nearest temperature/pressure range.
The optional reference index {Ref. Index} is an integer number indicating where to find the particular function in a special reference file. The references are listed when doing the GET_DATA command in the DATA module. They can also be listed in the GIBBS module with the command LIST_DATA with the option R.
For accounting for the reference indices, also see the keyword REFERENCE_FILE.
The reference index field can also be an abbreviation (such as REF:250, REF_002, or REF-SGTE) which denotes the original reference. In this case, the reference cannot be obtained when issuing the DATA command GET_DATA or the GIBBS command LIST_DATA (with the option R).
However, the references directly coded in the database definition file (***setup.TDB) starting with a letter can be shown when issuing the DATA command GET_DATA or the GIBBS command LIST_DATA (with the option N or R). Normally, such references must be located after the LIST_OF_REFERENCE keyword. It is recommended to use reference code names such as REF001, REF018, etc. The reference list, which is generated by the GIBBS command LIST_DATA <file> with the N or R option, is also possible to be directly read by the DATA module.
The DATA module can selectively retrieve functions which are necessary for a defined system from a database that has functions stored in its setup file or SEQ sequential function file, while all other functions irrelevant for the defined system are ignored and are not saved in associated GIBBS and POLY workspaces. Previously, this can only be done for large databases that have functions stored in RND1 random or FTP function files.

FUNCTION GFREE 298.15 1000+GFUNXY#; 6000 N !
FUNCTION GFUNXY 298.15 -1000+200*T+30*T*LOG(T); 6000 N 505 !
FUNCTION G0_CAO 298.15 -663538.11+352.67749*T-57.7533*T*LN(T)
+5.3895E-03*T**2-8.879385E-07*T**3+575530*T**(-1);
1400.00 Y -625196.99+78.896993*T-20.40145*T*LN(T)
-1.112923E-02*T**2+5.1896733E-07*T**3-6917350*T**(-1);
2900.00 Y -499226.55-490.37695*T+51.95912*T*LN(T)
-2.961051E-02*T**2+1.4033905E-06*T**3-48114685*T**(-1);
3172.00 Y -587711.89+375.04117-62.76*T*LN(T);
6000.00 N REF020 !