C.1: Print data-file contents

The first worked example is a program which reads a thermochemical data-file and prints a table of its contents.

Definition of goals

The aim is to get an overview on what is contained in a particular thermochemical data-file, for instance the ones supplied with this version of ChemApp, or any other data-file that you use with it. It will familiarise the ChemApp user with the concept of how ChemApp handles system components, phases, and phase constituents through index numbers.

The list that the program produces should include information on

For a definition of the terms used above, see Chapter 1.5.

Tools and concepts used

For the program, we will make use of almost all subroutines belonging to group 2 (Identifying Phases, Constituents, and Components). These are

The program will first need to determine the number of system components contained in the data-file, then get the name of each of them in a loop. Next, it will do the same for the phases, with the model name displayed as well. It will also print the number of phase constituents, if the phase is a mixture phase. And finally, it will display the names of the phase constituents of each of the mixture phases contained in the data-file, and check each one whether it is permitted to be used as an incoming species. If one or more are not permitted, a note is added to the list.

Implementation



C Print data-file contents
PROGRAM CAF100 IMPLICIT NONE
INTEGER NOERR, I, J, NSCOM, NPHASE, NPCON, INPCIS, NNPERM CHARACTER FNAME*12, SCNAME*24, PNAME*24, MODEL*6, PCNAME*24
C Initialise the number of phase constituents which cannot be used as C incoming species to 0 NNPERM = 0
C Initialise ChemApp CALL TQINI(NOERR)
FNAME = 'cosi.dat' C For this program to be flexible, add code that asks for the name of C the data-file instead
C Open the thermochemical data-file cosi.dat (system C-O-Si) C for C reading CALL TQOPNA(FNAME, 10, NOERR)
C Read data-file CALL TQRFIL(NOERR)
C Close data-file CALL TQCLOS(10, NOERR)
WRITE(*,FMT='(1X,A)') 'Contents of data-file ' // FNAME
C *************************************************************** C Information on system components C ***************************************************************
C Get the number of system components CALL TQNOSC(NSCOM, NOERR)
WRITE(*,FMT='(1X,A,I3)') 'Number of system components: ', * NSCOM
C Print the names of all system components WRITE(*,FMT='(1X,A)') 'List of system components:'
DO I=1, NSCOM CALL TQGNSC(I, SCNAME, NOERR) WRITE(*,FMT='(1X,I4,A)') I, ' : ' // SCNAME ENDDO WRITE(*,*)

Output:
 Contents of data-file cosi.dat    
 Number of system components:   3
 List of system components:
    1 : C                       
    2 : O                       
    3 : Si

C *************************************************************** C Information on phases C ***************************************************************
C Get the number of phases
CALL TQNOP(NPHASE, NOERR)
WRITE(*,FMT='(1X,A,I3)') 'Number of phases: ', * NPHASE
C Print the names of all phases, the associated model, and the number of C phase constituents, if it is a mixture phase. WRITE(*,FMT='(1X,A)') 'List of phases:'
DO I=1, NPHASE
C Get the phase name CALL TQGNP(I, PNAME, NOERR)
C Get the model name CALL TQMODL(I, MODEL, NOERR)
C Get its number of phase constituents CALL TQNOPC(I, NPCON, NOERR)
C If this phase has more than 1 phase constituent, it is a mixture C phase... IF (NPCON .GT. 1) THEN WRITE(*,FMT='(1X,I4,A,I4,A)') I, ' : ' // PNAME // ' ' // * MODEL, NPCON, ' constituents'
C ... otherwise it is a stoichiometric compound ELSE WRITE(*,FMT='(1X,I4,A)') I, ' : ' // PNAME // ' ' // MODEL ENDIF ENDDO WRITE(*,*)

Output:
 Number of phases:   8
 List of phases:
    1 : GAS                      IDMX    15 constituents
    2 : C                        PURE  
    3 : Si                       PURE  
    4 : SiC                      PURE  
    5 : SiO2(quartz)             PURE  
    6 : SiO2(tridymite)          PURE  
    7 : SiO2(cristobalite)       PURE  
    8 : SiO2(liquid)             PURE


C *************************************************************** C Information on phase constituents of mixture phases C ***************************************************************
C Print information on phase constituents WRITE(*,FMT='(1X,A)') 'List of phase constituents of ' // * 'mixture phases:'
DO I=1, NPHASE C Get its number of phase constituents CALL TQNOPC(I, NPCON, NOERR)
C If this phase has more than 1 phase constituent, it is a mixture C phase, and we want to print the list of phase constituents IF (NPCON .GT. 1) THEN CALL TQGNP(I, PNAME, NOERR) WRITE(*, FMT='(1X,A)') 'List of phase constituents of ' // * 'phase ' // PNAME
C Get and print the name of each phase constituent of the current phase DO J=1, NPCON CALL TQGNPC(I, J, PCNAME, NOERR) C Check whether the phase constituent may be used as incoming C species. If not, increase the total number of such phase constituents C by 1 and print a mark. CALL TQPCIS(I, J, INPCIS, NOERR) IF (INPCIS .EQ. 0) THEN NNPERM = NNPERM + 1 WRITE(*,FMT='(1X,I4,A)') J, ' : ' // PCNAME // ' X' ELSE WRITE(*,FMT='(1X,I4,A)') J, ' : ' // PCNAME ENDIF ENDDO WRITE(*,*)
ENDIF ENDDO
C If there have been phase constituents which cannot be used as incoming C species, print a note. IF (NNPERM .GT. 0) THEN WRITE(*,FMT='(1X,A, I3,A)') 'Note: ', NNPERM, ' phase ' // * 'constituent(s) marked with "X" is/are not permitted ' WRITE(*,FMT='(1X,A)') ' as incoming species.' ENDIF

Output:
 List of phase constituents of mixture phases:
 List of phase constituents of phase GAS                     
    1 : C                       
    2 : C2                      
    3 : C3                      
    4 : CO                      
    5 : CO2                     
    6 : O                       
    7 : O2                      
    8 : O3                      
    9 : Si                      
   10 : Si2                     
   11 : Si2C                    
   12 : Si3                     
   13 : SiC                     
   14 : SiO                     
   15 : SiO2


END

Suggestions for enhancements

  1. Include information on the molecular mass of the system components.

  2. Include information on the molecular mass and the stoichiometry of the mixture phase constituents and of the stoichiometric compounds.

  3. For systems which contain mixture phases modeled with sublattices (e.g. Co-Cr-Fe, see Chapter 1.12.7), include information on the sublattice details.


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