MFP Guide 43
MFP Guide 43
Version 4.3
28 August 2013
Infochem Computer Services Ltd
4 The Flag Store
23 Queen Elizabeth Street
London SE1 2LP
Tel: +44 (0)20 7357 0800
Fax: +44 (0)20 7407 3927
email: [email protected]
website: www.infochemuk.com
Infochem
c Computer Services Ltd, 1988-2013
NOTICE
This document and the information contained within it is the copyright of Infochem
Computer Services Ltd.
While every effort has been made to ensure that the information contained in this doc-
ument is correct and that the software and data to which it relates are free from errors, no
guarantee is given or implied as to their correctness or accuracy. Neither Infochem Computer
Services Ltd nor any of its employees, contractors or agents shall be liable for direct, indirect
or consequential losses, damages, costs, expenses, claims or fee of any kind resulting from
any deficiency, defect or error in this document, the software or the data.
1
Contents
1 Changes to Multiflash in Version 4.3 9
1.1 Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.2 Automated phase envelope plotting . . . . . . . . . . . . . . . . . . . . . . . . 9
1.3 PVTSim import tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2 Introduction 10
3 Preliminaries 11
3.1 Initialisation sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.2 Security system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.2.1 Initialising the security system . . . . . . . . . . . . . . . . . . . . . . 11
3.2.2 Closing the security system . . . . . . . . . . . . . . . . . . . . . . . . 12
3.3 Numerical parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.4 Include files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.4.1 Numerical parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.4.2 Unique compound identifiers . . . . . . . . . . . . . . . . . . . . . . . 13
3.5 Error reporting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.5.1 Standard error reporting system . . . . . . . . . . . . . . . . . . . . . 13
3.5.2 Error codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.5.3 Error-handling utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.6 Multiflash version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2
4.12.2 AYPDEL: Delete data for a component: . . . . . . . . . . . . . . . . . . 33
4.12.3 AYSALN: Equivalent salt component/ions concentration: . . . . . . . . 34
3
8 Setting up mixture property models 72
8.1 Initialising the Models software . . . . . . . . . . . . . . . . . . . . . . . . . . 72
8.2 Loading models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
8.3 Thermodynamic models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
8.3.1 Cubic equations of state . . . . . . . . . . . . . . . . . . . . . . . . . . 73
8.3.2 Non-cubic equations of state . . . . . . . . . . . . . . . . . . . . . . . 75
8.3.3 Free energy addition model . . . . . . . . . . . . . . . . . . . . . . . . 75
8.3.4 Liquid activity equations . . . . . . . . . . . . . . . . . . . . . . . . . 76
8.3.5 User-modified Unifac groups and subgroups . . . . . . . . . . . . . . . 77
8.3.6 Electrolyte model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
8.3.7 Solids . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
8.3.8 Other thermodynamic models . . . . . . . . . . . . . . . . . . . . . . . 79
8.4 Transport property models . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
8.5 Information about a loaded model . . . . . . . . . . . . . . . . . . . . . . . . 80
8.6 Setting model parameter data values . . . . . . . . . . . . . . . . . . . . . . . 80
8.7 Freeing model load numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
8.8 Reinitialising models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
8.9 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
9 Phase descriptors 83
9.1 Setting up phase descriptors . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
9.1.1 Initialise PD system . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
9.1.2 Define PDs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
9.2 Getting PD information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
9.2.1 PDs defined . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
9.2.2 Phase, key component and models associated with a PD . . . . . . . . 84
9.3 Removing a PD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
11 Streams 94
11.1 Setting up streams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
11.1.1 Initialise stream type system . . . . . . . . . . . . . . . . . . . . . . . 94
11.1.2 Define stream types . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
11.2 Getting stream type information . . . . . . . . . . . . . . . . . . . . . . . . . 94
11.2.1 Number of stream types defined . . . . . . . . . . . . . . . . . . . . . 94
11.2.2 Phase descriptors and components associated with a stream type . . . 95
11.3 Removing a stream type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
4
12 Phase equilibrium calculations 96
12.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
12.2 Multiflash operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
12.3 Thermodynamic property interface . . . . . . . . . . . . . . . . . . . . . . . . 97
12.4 Initialising the phase equilibrium module . . . . . . . . . . . . . . . . . . . . 98
12.5 Flash at fixed pressure and temperature: AXFL01 . . . . . . . . . . . . . . . . 98
12.6 Temperature or pressure searches and tolerance calculations: AXFL02 . . . . . 101
12.7 Search for hydrate temperature or pressure: AXHYD . . . . . . . . . . . . . . . 106
12.8 Double flashes: AXFL04 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
12.9 Stability test: AXST01 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
12.10Setting low-level calculation options . . . . . . . . . . . . . . . . . . . . . . . 115
12.10.1 First-order phase split . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
12.10.2 Second-order phase split . . . . . . . . . . . . . . . . . . . . . . . . . . 115
12.10.3 Stability test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
12.10.4 Temperature/pressure searches . . . . . . . . . . . . . . . . . . . . . . 117
5
18 Unit conversion utilities 150
18.1 UNF: Amount/composition/flowrate . . . . . . . . . . . . . . . . . . . . . . . . 150
18.2 UND: Density/volume . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
18.3 UNI: Diffusion coefficient . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
18.4 UNH: Energy (molar/specific) . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
18.5 UNS: Entropy/heat capacity (molar/specific) . . . . . . . . . . . . . . . . . . . 153
18.6 UNP: Pressure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
18.7 UNR: Surface tension . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
18.8 UNT: Temperature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
18.9 UNU: Thermal conductivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
18.10UNV: Viscosity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
18.11UNVOL: Volume . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
6
D.16 Solid heat capacity Cp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
7
I Viscosity models for fluid mixtures 198
I.1 SuperTRAPP viscosity model . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
I.2 Pedersen model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
I.3 Twu model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
I.4 Lohrenz-Bray-Clark method . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
I.5 Mixing rule for gas viscosities . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
I.6 Mixing rule for liquid viscosities . . . . . . . . . . . . . . . . . . . . . . . . . . 200
M Nomenclature 205
8
1 Changes to Multiflash in Version 4.3
This appendix lists significant changes to Multiflash and the Multiflash programming interface
made in the current release. For a full list of changes, please refer to the Multiflash for
Windows user manual.
1.1 Models
Descriptions and references detailing the models are provided in the User Guide for Models
and Physical Properties.
• Huron-Vidal-Pedersen mixing rule This mixing rule has been implemented for
both the Peng-Robinson and the Redlich-Kwong-Soave equations of state.
• Sutton model for surface tension This model has been implemented to allow for a
computationally inexpensive way to calculating the surface tension of systems contain-
ing water.
• LBC model It is now possible to specify a critical volume specifically for the LBC
model for each component, and to specify the LBC model parameters A1-A5.
9
2 Introduction
Multiflash is Infochem’s physical property software. It is a comprehensive and flexible system
that returns the thermophysical properties of pure substances and mixtures and carries out
phase and chemical equilibrium calculations for fluid and solid phases. Multiflash consists
of a number of distinct software modules that may be used individually or together. These
modules are: databanks; databank access software; pure component property evaluation; bi-
nary interaction parameter handling; mixture models for thermodynamic properties; mixture
models for transport properties; phase equilibrium calculations; and chemical equilibrium
calculations. This document describes the use of Multiflash from the point of view of the
programmer incorporating part or all of the system in other software. It does not attempt
to explain how to use Multiflash to solve problems in applied thermodynamics.
Multiflash is written in standard Fortran 77/95/2003 and all the example code shown in
this document is Fortran. The descriptions of the argument lists of the various routines are
intended to be sufficiently detailed to allow the programmer to set up and use the Multiflash
software. In addition some example programs are included in Appendix N. It should be
noted that only the software interfaces and data structures described in this manual are
supported. The use of any undocumented features may result in code that fails to work or
that produces incorrect results. A summary and index to all the Multiflash routines in the
interface is provided in Appendix A. In all subroutines mentioned in this API, all the units
for any input or output argument that requires them are SI units, unless otherwise stated. A
brief description of new features in the current version of Multiflash is provided in Appendix
1.
Although this document describes the Fortran interface to Multiflash it is straightforward
on many computer systems to make the equivalent calls from software written in other lan-
guages. Multiflash is available as a Win32 and 64 Dynamic Link Library (DLL). A Linux
32bit version is also available on request although that is not distributed by default. All the
routines described in this document are exported from the Multiflash DLL and an import
library is provided with the DLL. Additional information about how to call the Multiflash
DLL from C++ or Visual Basic applications is provided in the Programmer’s Guide for
Multiflash C++/C Interface and the Programmer’s Guide for the Multiflash Visual Basic
Interface. All Multiflash implementations can use the Multiflash command language which
is described in the Multiflash Command Reference. Information contained in the Multiflash
Command Reference and th User Guide for Models and Physical Properties may also be
useful as background material for the programmer.
10
3 Preliminaries
3.1 Initialisation sequence
The Multiflash software is made up of a number of different modules that must be initialised
in the correct order. This is:
1. security system (see below);
4. mixture models for thermodynamic and transport properties (sections 8, 9 and 10);
11
C 688 version limit in license < MF version being used
C 689 other licensing system error
C 690 no more licenses available
C 691 server not running on network
C IERRLS error code returned by licensing system
C 0 OK
C >0 error returned by licensing interface routine
C <0 error returned by license system
C ERRMES error message returned by license system
axjnum.inc Symbolic codes for Multiflash module, e.g. codes for variables, type of
solution in fixed phase fraction flashes, etc.
axpara.inc Dimensioning limits for Multiflash module
aygcon.inc Gas constant
aybfid.inc Identification codes for BIP temperature functions (Section 7.4)
ayjdbk.inc Identification codes for databanks (Section 4.4)
ayjmid.inc Identification codes for mixture models and options (Section 8.2)
ayjpid.inc Identification codes for pure component properties (Appendix C)
ayjuid.inc Symbolic constants for status of pure component properties or BIPs.
ayjxid.inc Symbolic constants for calculation options for AYMIX (Section 10)
aykcar.inc CAS registry numbers for popular components
aymbco.inc Maximum no. of BIP arrays that can be defined
aymbin.inc Maximum no. of BIP load numbers that can be defined
12
aymlda.inc Maximum no. of (integer) items of model identifiers/options
aymlno.inc Maximum no. of model load numbers that can be defined
aymncs.inc Maximum no. of components for Models module
aympd.inc Limits for phase descriptors
aympdk.inc Size of stored character-valued data items
ayptid.inc Phase type identification codes
crpara.inc Dimensioning limits for Chemreact module
unjerr.inc Error codes for unit-conversion software
mfvbjn.inc Codes used by the VB/VBA interface
13
C Input arguments:
C MXERR maximum number of error codes to return in IERR
C
C Output arguments:
C NERR number of error codes returned in IERR
C IERR vector of error codes.
C
INTEGER MXERR
PARAMETER (MXERR=10)
INTEGER NERR, IERR(MXERR)
CALL AYZZZZ( NERR, MXERR, IERR )
14
than MXERR it will return a result of .TRUE. irrespective of the error codes present because
not all errors reported have been recorded.
15
3.6 Multiflash version
The MFVERS routine returns the software version number and modification date for Multiflash.
It may be called at any time and does not require that any initialisation has been performed.
The calling specification is as follows:
To retrieve all the information the VERSN string should be at least 8 characters long and
the DATE string should be at least 20 characters long.
16
4 Defining pure components and data sources
4.1 Initialisation sequence
The pure component data section of the software must be initialised before any other. Typ-
ically, the following initialisation sequence would be followed:
Steps 1 - 5 are described in this section whilst the procedures for retrieving data are detailed
in section 5 starting on p.36.
17
infodata.bin Infochem pure component databank for fluids
infodata.idx component names index for Infodata
For convenience, the location of standard data files which Multiflash uses may be set by
calling AYFLFL (see below). It is not necessary to set the location in this way but if AYFLFL
is not called the programmer is responsible for supplying complete file access strings to the
databank opening routines described in section 4.4.
The calling specification for AYFLFL is:
CHARACTER*(*), INTENT(IN) :: APPDIR
18
C to zero the default filenames will be used for each
C databank. To open a databank with the same structure as
C one of the standard databanks it is necessary to set NFIL
C and NAMFIL correctly (see below).
C NAMFIL Array of NFIL file names. The following information
C is required for each databank structure:
C structure JBANK NFIL NAMFIL
C INFODATA JDOINF 2 1) index file
C 2) databank file
C MXERR maximum number of error flags to be returned in IERR
C
C Output arguments:
C LNODB Data bank load number (used to refer to databank in
C all subsequent operations)
C NERR no. errors reported by this routine and lower level routines
C IERR array of error codes. Values returned by this routine:
C 10401 Unrecognised data bank
C 10402 Run out of data bank load numbers
C 10403 Run out of space in data bank load information array
C 10404 Data files not appropriate for this data source
C 10405 Data files required for this data source
The databank identity or type of databank structure is specified by the argument JBANK
which must be one of the parameters in the file ayjdbk.inc. The standard databanks are
opened by setting NFIL to zero. In this case the location of the files used is determined by
the databank path set by calling AYFLFL. To open other databanks with one of the standard
structures the appropriate databank structure code (JDOINF or JDOINC) must be set the
required file names must be specified. The databank load number returned by AYPDBO must be
stored and passed without alteration to any routine that subsequently accesses the databank.
For an example of using AYPDBO see section 4.7.
If AYPDBU is called with an invalid load number no action is taken and no error is reported.
19
• data may be loaded from a databank (this is the usual method);
• the data can be directly loaded by making subroutine calls (section 4.8);
Components may be loaded in any order and each component may be loaded from a distinct
databank or data source. All data loading subroutines return a component load number for
each component loaded. This number is used subsequently by all other Multiflash routines
that need to refer to a particular component. The maximum number of components that
may be loaded simultaneously is set by the parameter MAXNCS in file aymncs.inc.
If the required compound is not found or not loaded error information is returned in IERR
from lower level routines. The loading routine attempts to find the compound in the names
20
index for the databank and, if successful, attempts to read stored data from the databank
itself. A cross-check is performed to ensure that the compound name in the databank is
consistent with the entry in the databank index. If the cross-check fails this usually means
that the databank has the wrong file structure or that the index and databank are out of
step because of version changes.
Example
INTEGER MXERR
PARAMETER (MXERR=10)
INTEGER JBANK(1), LNODB1, LNODB2, ID, LNOC1, LNOC2,
+ NERR, IERR(MXERR)
CHARACTER*1 KDUM(1)
C
C Data bank i.d. codes:
C
INCLUDE ’ayjdbk.inc’
C
CALL AYPINI( NERR, MXERR, IERR )
C
C Open INFODATA data bank:
C
JBANK(1) = JDINFO
CALL AYPDBO( 1, JBANK, 0, KDUM, LNODB1, NERR, MXERR,
+ IERR )
C
C Open DIPPR data bank:
C
JBANK(1) = JDIPPR
CALL AYPDBO( 1, JBANK, 0, KDUM, LNODB2, NERR, MXERR,
+ IERR )
C
C Component with load number LNOC1 is methane loaded from INFODATA
C
LNOC1 = 0
CALL AYPDBC( LNODB1, ’METHANE’, LNOC1, NERR, MXERR, IERR )
C
C Component with load number LNOC2 is ethane loaded from DIPPR
C
LNOC2 = 0
CALL AYPDBC( LNODB2, ’ETHANE’, LNOC2, NERR, MXERR, IERR )
21
INTEGER, INTENT(INOUT) :: ICO
INTEGER, INTENT(OUT) :: NERR, IERR(*)
REAL*8, INTENT(IN) :: RCONST(*)
LOGICAL, INTENT(IN) :: INIT
If the component load number ICO is zero a new component is set up and its load number
is returned otherwise properties are stored for an existing component. The array of property
codes JVALUE should be set using the parameter values listed in Appendix C.1 and defined
in file ayjpid.inc. Setting a property value in RCONST to -DLARGE (from routine AYNUMV)
means the existing value for that property is not to be overwritten. Unless otherwise stated
in C.1 the units are always SI units.
The following example shows how to set the critical temperature and pressure for a
component that is already loaded with load number LNOC3:
INCLUDE ’ayjpid.inc’
INTEGER MAXVAL, MXERR
PARAMETER ( MAXVAL=2, MXERR=10 )
INTEGER LNOC3, NVALUE, JVALUE(MAXVAL), NERR, IERR(MXERR)
REAL*8 RCONST(MAXVAL)
JVALUE(1) = JTCRIT
RCONST(1) = 513.9D0
JVALUE(2) = JPCRIT
RCONST(2) = 61.4D5
CALL AYPSTR( LNOC3, .FALSE., 2, JVALUE, RCONST, NERR, MXERR, IERR)
22
INTEGER, INTENT(IN) :: NVALUE, JVALUE(*), MXERR
INTEGER, INTENT(INOUT) :: ICO
INTEGER, INTENT(OUT) :: NERR, IERR(*)
23
C IERR Array of error codes. Values returned by this routine:
C -13281 the JVALUE is not a recognised property
C 13281 error in component number (<1 or > maxncs)
C 13282 component storage exhausted
If the component load number ICO is zero a new component is set up and its load number
is returned otherwise properties are stored for an existing component. The array of property
codes JVALUE should be set using the parameter values listed in Appendix C.2 and defined
in file ayjpid.inc. Setting a property value in KCONST to a blank means the existing value
for that property is not to be overwritten.
For example, to set the name and formula for a component that is already loaded with
load number LNOC3 to ethanol and C2 H6 O, the call of AYPSTK should be:
INTEGER MXERR
PARAMETER ( MXERR=10 )
INTEGER JVALUE(2), LNOC3, NERR, IERR(MXERR)
CHARACTER*7 KCONST(2)
LOGICAL INIT
INIT = .TRUE.
JVALUE(1) = JKNAME
JVALUE(2) = JKFORM
KCONST(1) = ’ETHANOL’
KCONST(2) = ’C2H6O’
CALL AYPSTK( LNOC3, INIT, 2, JVALUE, KCONST, NERR, MXERR, IERR )
The property code jval should be set to the code number from file ayjpid.inc. The num-
ber of correlation coefficients ncof is equation-dependent. Details of the correlating equations
used are given in Appendix D.
For example, consider the extended Antoine equation which has the following form (see
Appendix D.7):
a2
ln p = a1 + + a4 T a6 + a5 ln T + a7 /T 2
T + a3
The property code is vapour pressure, JPSAT. The Antoine equation is vapour pres-
sure equation type 2 which is specified by setting the coefficient corresponding to JPSAT
to DBLE(2). Note: a REAL*8 number is required. The nine coefficients a1 - a7 , Tmin and
Tmax are denoted by JPSAT+1 to JPSAT+9. To define an Antoine equation for a component
that is already loaded with load number LNOC3 with a1 = 23.5, a2 = 2537.2, a3 = −11.3,
24
a4 = a5 = 0, a6 = 1.0, a7 = 0, Tmin = 275.0 and Tmax = 420.0, AYPSTR should be called as
follows:
INTEGER MXERR
PARAMETER ( MXERR=10 )
INTEGER LNOC3, JVALUE(10), NERR, IERR(MXERR)
REAL*8 RCONST(10)
LOGICAL INIT
INIT = .TRUE.
JVALUE(1) = JPSAT
JVALUE(2) = JPSAT + 1
JVALUE(3) = JPSAT + 2
JVALUE(4) = JPSAT + 3
JVALUE(5) = JPSAT + 4
JVALUE(6) = JPSAT + 5
JVALUE(7) = JPSAT + 6
JVALUE(8) = JPSAT + 7
JVALUE(9) = JPSAT + 8
JVALUE(10) = JPSAT + 9
RCONST(1) = DBLE( 2 )
RCONST(2) = 23.5D0
RCONST(3) = 2537.2D0
RCONST(4) = -11.3D0
RCONST(5) = 0.0D0
RCONST(6) = 0.0D0
RCONST(7) = 1.0D0
RCONST(8) = 0.0D0
RCONST(9) = 275.0D0
RCONST(10) = 420.0D0
CALL AYPSTR( LNOC3, INIT, 10, JVALUE, RCONST, NERR, MXERR, IERR )
INTEGER MXERR
PARAMETER ( MXERR=10 )
INTEGER LNOC3, JVALUE(5), NERR, IERR(MXERR)
REAL*8 RCONST(5)
LOGICAL INIT
INIT = .TRUE.
JVALUE(1) = JUNIF
JVALUE(2) = JUNIF + 1
JVALUE(3) = JUNIF + 2
JVALUE(4) = JUNIF + 3
JVALUE(5) = JUNIF + 4
RCONST(1) = 0.0D0
RCONST(2) = DBLE( 1 )
RCONST(3) = DBLE( 2 )
RCONST(4) = DBLE( 2 )
RCONST(5) = DBLE( 4 )
CALL AYPSTR( LNOC3, INIT, 5, JVALUE, RCONST, NERR, MXERR, IERR )
25
All the integer code numbers and abundances have to be converted to double precision
(REAL*8) before entering into AYPSTR. There is a useful utility AYPUFS which can return the
Multiflash code number corresponding to the character-string name of the subgroup, or vice-
versa. All current subgroups names are given in the Multiflash Command Reference. The
call specification is:
26
C Input arguments:
C NBANK Dimension of the array JBANK.
C JBANK array of codes for characterisation method.
C The available codes for JBANK are listed in the include
C file AYJDBK.INC:
C JCINFO Infochem original characterisation methods
C (must be specified in JBANK(1))
C This method has 2 variants (may be specified in JBANK(2)):
C JVTBSO Soreide correlation for Tb (default)
C JVTBAP API correlation for Tb
C NFIL should be set to zero.
C NAMFIL Array of NFIL file names. A dummy array should be passed.
C MXERR maximum number of error flags to be returned in IERR
C
C Output arguments:
C LNODB characterisation method load number (used to refer to
C method all subsequent operations)
C NERR no. errors reported by this routine and lower level routines
C IERR array of error codes. Values returned by this routine:
C 10401 Unrecognised data bank
C 10402 Run out of data bank load numbers
C 10403 Run out of space in data bank load information array
The characterisation method load number returned by AYPDBO must be stored and passed
without alteration to any routine (e.g. AYPPF) that subsequently uses the method.
27
The calling specification of AYPPF is:
INTEGER, INTENT(IN) :: LNOPF, ITYPE, MXERR
INTEGER, INTENT(INOUT) ::ICO
INTEGER, INTENT(OUT) :: NERR, IERR(*)
REAL*8, INTENT(INOUT) :: CNN, AMW, SG, TB, TC, PC, W
CHARACTER*(*), INTENT(IN) :: NAME
LOGICAL, INTENT(IN) :: INIT
SUBROUTINE AYPPF( LNOPF, ICO, INIT, NAME, ITYPE, CNN, AMW, SG,
+ TB, TC, PC, W, NERR, MXERR, IERR )
C
C Input arguments:
C LNOPF load number for characterisation method.
C Obtained by calling aypdbo.
C INIT .TRUE. if all properties to be initialised, .FALSE. if
C only undefined properties to be intialised
C NAME component name
C ITYPE type of petroleum fraction component
C (parameters from ayjxid.inc)
C The estimated physical properties will, in general,
C depend on ITYPE but not all characterisation methods
C distinguish between the type of component.
C MXERR maximum number of error flags to be returned in IERR
C
C Input/output arguments:
C Input values:
C ICO Component load number (0=set up new component)
C CNN carbon number of petroleum fraction
C AMW molecular weight (g/mol) (relative molar mass)
C SG specific gravity at 60degF (relative density at 288.71K)
C TB boiling point (K)
C TC critical temperature (K)
C PC critical pressure (Pa)
C W acentric factor
C If any of the arguments CNN to W is set to -DLARGE it is estimated
C
C Output values:
C ICO Component load number
C CNN carbon number of petroleum fraction
C AMW molecular weight (g/mol) (relative molar mass)
C SG specific gravity at 60degF (relative density at 288.71K)
C TB boiling point (K)
C TC critical temperature (K)
C PC critical pressure (Pa)
C W acentric factor
C
C Output arguments:
C NERR no. errors reported by this routine and lower level routines
C IERR Array of error codes.
For example, the code below defines a new component called ’C7+’ as a petroleum fraction
of unspecified type with molecular weight of 224, specific gravity of 0.842 and boiling point
of 552.59K. The critical temperature, critical pressure and acentric factor are unknown and
will be estimated (along with other properties) using the Infochem characterisation method.
The load number for this component is LNOC4
INCLUDE ’ayjxid.inc’
28
INTEGER MXERR
PARAMETER(MXERR=10)
REAL*8 DLARGE, CN, MW, SG, TB, TC, PC, W
LOGICAL INIT
INTEGER JBANK(1), LNOPF, LNOC4, NERR, IERR(MXERR)
CHARACTER*1 NAMFIL(1)
29
C 10432 Unrecognised data bank type
30
INTEGER, INTENT(IN) :: LNODB, MXERR
INTEGER, INTENT(OUT) :: IREC, NERR, IERR(*)
CHARACTER*(*), INTENT(IN) :: KNAME
CHARACTER*(*), INTENT(OUT):: KSYNM
LOGICAL, INTENT(IN) :: FIRST
31
C TRUE first call for current formula, databank position
C is reset prior to search
C FALSE for second and subsequent calls, starts search at
C current position of databank
C MXERR maximum number of error flags to be returned in IERR
C
C Output arguments:
C IREC record number in databank file if a matching formula
C found. Zero if formula not found.
C Negative if end of file reached.
C NAME component name found (if irecdb is positive)
C FORM chemical formula found (if irecdb is positive)
C NERR no. errors reported by this routine and lower level routines
C IERR array of error codes. Values returned by this routine:
C 10491 Unrecognised data bank load number
C 10492 Unrecognised data bank type
32
4.11.2 AYPDBV: Pure component real-valued constant data:
AYPDBV returns real-valued constants from a specified record on a databank. Its function is
similar to the routine AYPCNR which can only be used once a component has been loaded.
See Appendix C for a list of property codes. Note that only constant property values can be
returned e.g. critical properties and not coefficients in temperature-dependent correlations.
The calling specification is:
33
C Input/output arguments:
C Input values:
C ICO Component load number
C
C Output values:
C ICO Component load number (0=deleted)
C
C Output arguments:
C NERR number of error codes returned in IERROR
C IERR error codes. Values for this routine:
C 13291 Erroneous component number
C 13292 Maximum number of components has already been entered
AYPDEL frees the storage associated with the load number and makes it available for loading
new components. However, the recomended routine to call when deleting components is
AYBDEL as it also deletes BIP references for that component.
34
C 1 Total dissolved solid in mg/litre
C 2 Salt molalities
C 3 Salt mole fractions
C 4 Salt mass fractions
C MODEL 1 NaCl equivalant ( salt component )
C 2 NaCl, KCl and CaCl2 equivalents
C 3 NaCl equivalent for electrolyte model
C DEN Salt density if known in kg/m3
C ANAL Salt concentrations:
C INOPT=0 Ion analyses in mg/litre. Ions in order Na+, Ca++,
C Mg++, K+, Sr++, Ba++, Fe++, Cl-, SO4--, HCO3-, Br-
C INOPT=1 Total dissolved solid in mg/litre in ANAL(1)
C INOPT=2 Salt concentrations in molalities. Salts in order
C NaCl, CaCl2, MgCl2, KCl, SrCl2, BaCl2, FeCl2,
C Na2SO4, NaHCO3, NaBr
C INOPT=3 Salt concentrations in mole fractions. Salts in
C order NaCl, CaCl2, MgCl2, KCl, SrCl2, BaCl2, FeCl2,
C Na2SO4, NaHCO3, NaBr
C INOPT=4 Salt concentrations in mass fractions. Salts in
C order NaCl, CaCl2, MgCl2, KCl, SrCl2, BaCl2, FeCl2,
C Na2SO4, NaHCO3, NaBr
C MXERR maximum number of error codes to return in IERR
C
C Output arguments:
C ZSALT Equivalent NaCl/KCl/CaCl2/NaBr molar concentration relative
C to water
C NERR no. errors reported by this routine and lower level routines
C IERR Error codes. Values for this routine:
C 13611 total salt mole/mass fractions > 1
C 13612 ion analysis entered with no negative or no
C positive ions
35
5 Evaluating pure component properties
5.1 Summary of routines
Pure component properties may be evaluated by calling the following routines:
The models used are defined in Appendix D. Complete information on how to call each
routine is given below. A working example of a complete program is provided in Appendix
N.1.1.
36
C Input arguments:
C NCO Number of components in subcomponent list.
C If zero, constants returned for all components.
C If negative, changes placing of output values.
C IC Subcomponent list
C JVALUE Property identification code (from ayjpid.inc)
C MXERR maximum number of error flags to be returned in IERR
C
C Output arguments:
C KCONST pure component character constants.
C If NCO +ve prop. for component I placed in KCONST(I),
C if NCO -ve prop. for component I placed in KCONST(IC(I))
C NERR no. errors reported by this routine and lower level routines
C IERR Array of error codes. Values returned by this routine:
C -13261 missing constants for one or more components
C -13262 invalid component number
C 13261 property id (JVALUE) not recognised
37
5.3.3 AYPCNS: status of constants
This subroutine can be used to check if some property is defined from a databank or user
defined. The calling specification is:
38
properties of gases are normally correlated in the perfect gas state, i.e. the low pressure limit
of real gas behaviour. Gas phase transport properties are normally correlated in the zero-
density limit where pressure effects are unimportant. Liquid phase properties are normally
correlated on the saturation line, i.e. at a pressure corresponding to the saturated liquid
vapour pressure at the given temperature. All the routines described in this section include
extrapolation procedures to ensure that a value is returned even if the temperature is outside
the limits for the correlation.
SUBROUTINE AYPDIE( NCO, IC, TIN, IDT, DIEL, DDIEL, DDDIEL, NERR,
+ MXERR, IERR )
C
C Input arguments:
C NCO Number of components in subcomponent list.
C If zero, constants returned for all components.
C If negative, changes placing of output values.
C IC Subcomponent list
C TIN Temperature (K)
C IDT derivative flag (0=none, 1=first derivatives,
C 2=second derivatives)
C MXERR Maximum number of error flags to be returned in IERR
C
C Output arguments:
C DIEL Dielectric constant
C (If NCO +ve prop. for component I placed in element I,
C if NCO -ve prop. for component I placed in element IC(I))
C DDIEL T derivative of dielectric constant
C Only returned if IDT>0.
C DDDIEL Second T derivative of dielectric constant
C Only returned if IDT=2.
C NERR no. errors reported by this routine and lower level routines
C IERR Array of error codes. Values returned by this routine:
C -13921 Temperature below lower limit or above upper
C limit for one or more components. Extrapolated
C values returned
C 13921 Unrecognised equation type
SUBROUTINE AYPDNL( NCO, IC, TIN, IDT, DL, DDL, DDDL, NERR,
+ MXERR, IERR )
C
39
C Input arguments:
C NCO Number of components in subcomponent list.
C If zero, constants returned for all components.
C If negative, changes placing of output values.
C IC Subcomponent list.
C TIN temperature (K)
C IDT derivative flag (0=none, 1=first derivatives,
C 2=second derivatives)
C MXERR maximum number of error flags to be returned in IERR
C
C Output arguments:
C DL saturated liquid density for components selected (mol m-3)
C DDL T derivative of DL (mol m-3 K-1); if IDT=1 or 2
C DDDL second T derivative of DL (mol m-3 K-2); if IDT=2
C (If NCO +ve prop. for component I placed in element I,
C if NCO -ve prop. for component I placed in element IC(I))
C NERR no. errors reported by this routine and lower level routines
C IERR Array of error codes. Values returned by this routine:
C -13161 temperature below lower limit or above upper
C limit for one or more components. Extrapolated
C values returned
C 13161 unrecognised equation type
C 13162 erroneous/missing data for one or more components.
C -DLARGE returned.
40
C values returned
C 13171 unrecognised equation type
C 13172 erroneous/missing data for one or more components.
C -DLARGE returned.
SUBROUTINE AYPHSI( NCO, IC, TIN, LDERIV, HIG, SIG, DHIG, NERR,
+ MXERR, IERR )
C
C Input arguments:
C NCO Number of components in subcomponent list.
C If zero, constants returned for all components.
C If negative, changes placing of output values.
C IC Subcomponent list.
C TIN temperature (K)
C LDERIV logical flag. If set to .TRUE. both property and
C derivative are returned. If .FALSE. only the property
C is returned.
C MXERR maximum number of error flags to be returned in IERR
C
C Output arguments:
C HIG enthalpy of components in ideal gas state (J mol-1)
C SIG entropy of components in ideal gas state (J K-1 mol-1)
C DHIG T derivative of HIG (J mol-1 K-1); if LDERIV is .TRUE.
C (If NCO +ve prop. for component I placed in element I,
C if NCO -ve prop. for component I placed in element IC(I))
C NERR no. errors reported by this routine and lower level routines
C IERR Array of error codes. Values returned by this routine:
C -13241 temperature below lower limit or above upper
C limit for one or more components. Extrapolated
C values returned
C 13241 component type is not fluid
C 13242 unrecognised equation type
C 13243 T value unacceptable
41
C MXERR maximum number of error flags to be returned in IERR
C
C Output arguments:
C DPROP Cp (J/mol K)
C (If NCO +ve prop. for component I placed in element I,
C if NCO -ve prop. for component I placed in element IC(I))
C NERR no. errors reported by this routine and lower level routines
C IERR Array of error codes. Values returned by this routine:
C 10151 Equation number not recognised.
C 10152 Critical temperature undefined for component
C -10151 Temperature below lower limit or above upper
C limit. Extrapolated values returned.
5.4.6 AYPLH1: liquid enthalpy, entropy and heat capacity on the saturation line
INTEGER, INTENT(IN) :: NCO, IC(*), MXERR
INTEGER, INTENT(OUT) :: NERR, IERR(*)
REAL*8, INTENT(IN) :: TIN
REAL*8, INTENT(OUT) :: HLIQ(*), CPLIQ(*), SLIQ(*)
LOGICAL, INTENT(IN) :: LDERIV
SUBROUTINE AYPLH1( NCO, IC, TIN, LDERIV, HLIQ, CPLIQ, SLIQ, NERR,
+ MXERR, IERR )
C
C Input arguments:
C NCO Number of components in subcomponent list.
C If zero, constants returned for all components.
C If negative, changes placing of output values.
C IC Subcomponent list
C TIN Temperature (K)
C LDERIV Logical flag. If .TRUE. CPLIQ is also returned
C If .FALSE. only HLIQ and SLIQ are returned.
C MXERR Maximum number of error flags to be returned in IERR
C
C Output arguments:
C HLIQ Saturated liquid enthalpy relative to 298.15 K (J/mol)
C (If NCO +ve prop. for component I placed in element I,
C if NCO -ve prop. for component I placed in element IC(I))
C CPLIQ Derivative of saturated liquid enthalpy (Cp) (J/mol K)
C SLIQ Saturated liquid entropy relative to 298.15 K (J/mol K)
C NERR No. errors reported by this routine and lower level routines
C IERR Array of error codes. Values returned by this routine:
C 13651 Equation number not recognised.
C 13652 Critical temperature undefined for component
C -13651 Temperature below lower limit or above upper
C limit. Extrapolated values returned.
C -13652 Reference temperature below lower limit or above
C upper limit.
42
SUBROUTINE AYPLTC( NCO, IC, TIN, LDERIV, PROP, DPROP, NERR,
+ MXERR, IERR )
C
C Input arguments:
C NCO Number of components in subcomponent list.
C If zero, constants returned for all components.
C If negative, changes placing of output values.
C IC subcomponent list
C TIN temperature (K)
C LDERIV logical flag. If set to .TRUE. both property and
C derivative are returned. If .FALSE. only the property
C is returned.
C MXERR maximum number of error flags to be returned in IERR
C
C Output arguments:
C PROP saturated liquid thermal conductivity for components
C selected (W/m K)
C DPROP T derivative of saturated liquid thermal conductivity
C (W/m K2)
C Only returned if LDERIV is .TRUE.
C (If NCO +ve prop. for component I placed in element I,
C if NCO -ve prop. for component I placed in element IC(I))
C NERR no. errors reported by this routine and lower level routines
C IERR Array of error codes. Values returned by this routine:
C 10121 Equation number not recognised.
C 10122 Critical temperature undefined for component
C -10121 Temperature below lower limit or above upper
C limit. Extrapolated values returned.
43
C NERR no. errors reported by this routine and lower level routines
C IERR Array of error codes. Values returned by this routine:
C 10101 Equation number not recognised.
C -10101 Temperature below lower limit or above upper
C limit. Extrapolated values returned.
44
C DPROP T derivative of solid density (mol/m3/K)
C Only returned if LDERIV is .TRUE.
C (If NCO +ve prop. for component I placed in element I,
C if NCO -ve prop. for component I placed in element IC(I))
C NERR no. errors reported by this routine and lower level routines
C IERR Array of error codes. Values returned by this routine:
C 10181 Equation number not recognised.
C -10181 Temperature below lower limit or above upper
C limit. Extrapolated values returned.
C Input arguments:
45
C NCO Number of components in subcomponent list.
C If zero, constants returned for all components.
C If negative, changes placing of output values.
C IC Subcomponent list.
C TIN temperature (K)
C LDERIV logical flag. If set to .TRUE. both property and
C derivative are returned. If .FALSE. only the property
C is returned.
C MXERR maximum number of error flags to be returned in IERR
C
C Output arguments:
C VP saturated vapour pressure for components selected (Pa)
C DVP T derivative of saturated vapour pressure (Pa/K).
C Only returned if LDERIV is .TRUE.
C (If NCO +ve prop. for component I placed in element I,
C if NCO -ve prop. for component I placed in element IC(I))
C NERR no. errors reported by this routine and lower level routines
C IERR Array of error codes. Values returned by this routine:
C -13151 temperature below lower limit or above upper
C limit for one or more components. Extrapolated
C values returned
C 13151 unrecognised equation type
C 13152 erroneous/missing data for one or more components.
C -DLARGE returned.
C Input arguments:
C NCO Number of components in subcomponent list.
C If zero, constants returned for all components.
C If negative, changes placing of output values.
C IC subcomponent list
C TIN temperature (K)
C LDERIV logical flag. If set to .TRUE. both property and
C derivative are returned. If .FALSE. only the property
C is returned.
C MXERR maximum number of error flags to be returned in IERR
C
C Output arguments:
C PROP second virial coefficient for components selected (m3/mol)
C DPROP T derivative of second virial coefficient (m3/mol/K)
C Only returned if LDERIV is .TRUE.
C (If NCO +ve prop. for component I placed in element I,
C if NCO -ve prop. for component I placed in element IC(I))
C NERR no. errors reported by this routine and lower level routines
C IERR Array of error codes. Values returned by this routine:
C 10191 Equation number not recognised.
C 10192 Critical temperature undefined for component
46
C -10191 Temperature below lower limit or above upper
C limit. Extrapolated values returned.
C Input arguments:
C NCO Number of components in subcomponent list.
C If zero, constants returned for all components.
C If negative, changes placing of output values.
C IC subcomponent list
C TIN temperature (K)
C LDERIV logical flag. If set to .TRUE. both property and
C derivative are returned. If .FALSE. only the property
C is returned.
C MXERR maximum number of error flags to be returned in IERR
C
C Output arguments:
C PROP ideal gas thermal conductivity for components selected (W/m K)
C DPROP T derivative of ideal gas thermal conductivity (W/m K2).
C Only returned if LDERIV is .TRUE.
C (If NCO +ve prop. for component I placed in element I,
C if NCO -ve prop. for component I placed in element IC(I))
C NERR no. errors reported by this routine and lower level routines
C IERR Array of error codes. Values returned by this routine:
C 10131 Equation number not recognised.
C 10132 Critical temperature undefined for component
C 10133 Relative molar mass undefined for component
C -10131 Temperature below lower limit or above upper
C limit. Extrapolated values returned.
C Input arguments:
C NCO Number of components in subcomponent list.
C If zero, constants returned for all components.
C If negative, changes placing of output values.
C IC subcomponent list
C TIN temperature (K)
C LDERIV logical flag. If set to .TRUE. both property and
47
C derivative are returned. If .FALSE. only the property
C is returned.
C MXERR maximum number of error flags to be returned in IERR
C
C Output arguments:
C PROP ideal gas viscosity for components selected (Pas)
C DPROP T derivative of ideal gas viscosity (Pas/K).
C Only returned if LDERIV is .TRUE.
C (If NCO +ve prop. for component I placed in element I,
C if NCO -ve prop. for component I placed in element IC(I))
C NERR no. errors reported by this routine and lower level routines
C IERR Array of error codes. Values returned by this routine:
C 10111 Equation number not recognised.
C 10112 Critical temperature undefined for component
C 10113 Relative molar mass undefined for component
C -10111 Temperature below lower limit or above upper
C limit. Extrapolated values returned.
SUBROUTINE AYPCOR( NCO, IC, JPROP, NCRDIM, NEQN, NCOR, CORR, TMIN,
+ TMAX, NERR, MXERR, IERR )
C
C Input arguments:
C NCO Number of components in subcomponent list.
C If zero, constants returned for all components.
C If negative, changes placing of output values.
C IC subcomponent list
C JPROP property identification code (must be one of the
C temperature-dependent properties listed in ayjpid.inc)
C NCRDIM size of 1st dimension of CORR as declared in calling
C routine. If NCRDIM is not large enough to contain all
C the information to be returned in CORR, an error code
C is returned.
C MXERR maximum number of error flags to be returned in IERR
C
C Output arguments:
C (If NCO is positive or zero , information for component I is
C placed in element I of the following arrays. If NCO is negative,
C information is placed in element IC(I))
C NEQN equation type code for each component. If no correlation
C is stored, a value of zero is returned and values are
C not set in NCOR, CORR, TMIN and TMAX.
C NCOR number of coefficients in correlation (which may be
C greater than NCRDIM)
48
C CORR correlation coefficients - a maximum of NCRDIM values
C are returned. If NCOR(I) is greater than NCRDIM then
C some coefficients are missing for component I.
C TMIN array of minimum temperature limits for correlation
C TMAX array of maximum temperature limits for correlation
C NERR no. errors reported by this routine and lower level routines
C IERR Array of error codes. Values returned by this routine:
C 10161 J-number not a recognised temperature dependent
C property
The models and equation numbers are defined in Appendix D. The maximum number of
coefficients for any property (the setting for NCRDIM) can be found from the parameter values
in include file ayjpid.inc.
49
6 Petroleum fluid characterisation
6.1 Introduction
The aim of the Infochem characterisation procedures is to make optimum use of available
experimental data relating to petroleum fluid composition to construct an equation of state
model of the fluid. The model must be sufficiently detailed, i.e. contain enough components,
to describe accurately the phase behaviour of interest but be simple enough for practical
engineering calculations. We also wish to apply the same characterisation procedure to model
all types of phase behaviour including straightforward vapour-liquid and vapour-liquid-liquid
equilibria, hydrate formation and wax and asphaltene formation. It is essential therefore
that the same set of real components and pseudocomponents can be used simultaneously
with models for all phases of interest (fluid and solid).
We take as a starting point a typical modern fluid analysis as provided by a PVT lab-
oratory. The laboratory will depressurise the reservoir fluid to obtain separate liquid and
gas samples. The gas-oil ratio (GOR) is recorded in one way or another. The samples are
analysed by gas chromatography (GC) to obtain their compositions. For the gas, the com-
ponents will be real discrete components of known molecular weight, so the composition can
be expressed in mole or weight fractions with equal validity. The GC analysis of the liquid
also identifies some discrete components, but mostly the individual hydrocarbons cannot be
identified. Conventionally, the analysis is expressed as a series of single carbon number (SCN)
cuts terminating with a plus fraction which gives the remainder. The liquid GC analysis mea-
sures the weight fractions not the mole fractions. In addition some properties of the liquid
sample such as density and molecular weight can be measured.
Another option is to have the fluid defined as a series of boiling point cuts. In this method
the smaple is distilled with a very high relux ratio to separate the several cuts. Multiflashcan
handle two methods: True Boiling Point curves (TBP) and D86 boiling point curves.
There are a number of steps in the characterisation of a petroleum fluid which are interre-
lated but can also be separated out. The procedure used within Infochem’s characterisation
algorithm is:
1. The SCN weight fractions in the liquid, including the plus fraction, in the liquid are
correlated against carbon number using a distribution function.
2. By extrapolating the distribution function, the plus fraction can be split into a number
of pseudocomponents of varying molecular weight as required. Some SCN cuts can also
be grouped into pseudocomponents as required.
3. Molecular weights and specific gravities are assigned to each component from a suitable
correlation against carbon number.
4. The molecular weights and specific gravities of the components are all adjusted to match
the measured values for the whole liquid sample.
5. The liquid weight fractions are converted to mole fractions using the molecular weights
of the components.
6. The gas and liquid mole fractions are combined in the correct proportions to give the
mole fractions of the total recombined fluid.
7. Using established correlations, the critical properties and acentric factors of the SCN
cuts and pseudocomponents can be estimated from the values of molecular weight and
specific gravity for that component. The correlations described in section 4.9.1 are used
to estimate these properties.
50
8. For asphaltenes we use the information from a SARA characterisation to split off an
asphaltene component and one or more resin components from the fluid.
9. For waxes we use the information from a UOP wax content test or the normal-paraffin
distribution to characterise the wax-forming fraction of the fluid.
51
+ TBCUT, TCCUT, PCCUT, WCUT, TMCUT, DHMCUT,
+ DSMCUT, DCPCUT, WATCUT, ZWAT, MWWAT, SGWAT,
+ TOTAL, LUT, NERR, MXERR, IERR )
C
C Note: if a total fluid analysis is entered rather than separator
C gas and liquid analyses the amounts should be entered in the
C liquid phase arguments (ADIS, ACIN)
C
C must be the last entry.
C CNCNL Lower boundary of liquid CN cut
C MWCNL Molecular weight of liquid CN cut
C SGCNL Specific gravity of liquid CN cut
C NCNN number of composition values for n-paraffins.
C NCNN is the number of values entered in array ACNN.
C If an n-paraffin distribution is not provided, set NCNN=0.
C ACNN compositional information for n-paraffins.
C If NPRFIN=1 ACNN(I) is the percentage of n-paraffins in
C the Ith CN fraction in the STO. The values must sum to
C less than 100%. The n-paraffin distribution may extend to
C higher carbon numbers than the analysis in ACNL in which
C case NCNN will be greater than NCNL. Otherwise NCNN
C may be less than or equal to NCNL.
C If NPRFIN=2 ACNN(I) is the fraction of material in
C ACNL(I) that is n-paraffin. Each fractions must be between
C zero and one. In this case NCNN must be less than NCNL.
C Any value entered for the plus fraction is ignored.
C Percentages or fractions are either on a mass basis or a
C molar basis depending on the setting of NPLUL
C LUL flag for liquid/total amounts: 0=molar units, 1=mass units,
C 2=volume units
C MW molecular weight (set to -DLARGE if not specified).
C LMW = 0 MW refers to the plus fraction
C = 1 MW refers to the total fluid
C = 2 MW refers to the STO
C SG specific gravity (set to -DLARGE if not specified)
C LSG = 0 SG refers to the plus fraction
C = 2 SG refers to the STO
C NPLUL flag for n-paraffin amounts: 0=molar units, 1=mass units
C NPFRIN code for the percentage/fraction of n-paraffins.
C 1 for percentage of n-paraffins in STO
C 2 for fraction of n-paraffins in each CN cut.
C The percentage/fraction is on a mass or molar basis
C depending on the setting of NPLUL
C NDISG number of discrete components present in gas analysis
C given in array ADISG. NDISG must be less than or equal to
C NNMDIS. If NDISG<NNMDIS, this means that remaining components
C defined in NMDIS are not present in this particular gas sample.
C ADISG amounts of discrete components in gas analysis in units
C denoted by LUG (NDISG values).
C NCNG Number of CN cuts in gas, i.e. NCNG is the number of
C values entered in array ACNG. If no gas distribution is to
C be entered, set NCNG=0.
C ACNG amounts for CNs in gas starting at CSTART
C LUG .TRUE. if gas amounts (ADISG/ACNG) are on a mass basis,
C .FALSE. if on a molar basis
C GOR recombination gas-oil ratio in sm3/m3
C SARA SARA analysis as mass fractions of saturates,
52
C aromatics, resins and asphaltenes(nC7) in STO.
C Only the values for resins and aspaltenes are actually used.
C Undefined values should be set -DLARGE.
C ESARA .TRUE. if missing SARA data to be estimated, otherwise .FALSE.
C This is only required if an asphaltene model is used.
C TWC total (UOP) wax content in STO as mass fraction.
C An undefined value should be set -DLARGE.
C ETWC .TRUE. if n-paraffin distribution to be estimated.
C This is only required if the Coutinho wax model is used.
C CRSTRT carbon number at which regression of CN analytical
C data is to start
C CSPLIT carbon number at which pseudocomponents to start
C (1) value for non n-paraffin distribution
C (2) value for n-paraffin distribution. Set to 0 for default.
C (Only required if wax content entered or estimated).
C NSPLIT number of pseudocomponents required
C (1) value for non n-paraffin distribution
C (2) value for n-paraffin distribution. Set to 0 for default.
C (Only required if wax content entered or estimated).
C CNSPLT Lower carbon number bounds defined for pseudocomponents
C WATCUT water cut as volume fraction of liquid hydrocarbon phase
C at 60F and 1 atm. An undefined value should be set -DLARGE.
C TOTAL total amount of fluid. All compositions are scaled to give
C this amount. An undefined value should be set -DLARGE.
C LUT .TRUE. if total amount (TOTAL) is in mass units, .FALSE.
C if in molar units
C MXERR maximum number of error codes to be returned in IERR
C
C Output arguments:
C NDIS number of discrete components with values set in ZDIS,
C MWDIS and SGDIS. (excluding water)
C ZDIS mole numbers of discrete components
C MWDIS molecular weights of discrete components
C SGDIS specific gravities of discrete components
C NCUT number of pseudocomponents returned
C NMCUT assigned names of pseudocomponents
C ZCUT molar amounts of pseudocomponents
C ITCUT type of pseudocomponent (code from AYJXID.inc)
C CNLCUT lower carbon number boundary of pseudocomponents
C CNCUT average carbon number of pseudocomponents
C MWCUT average molecular weight of pseudocomponents
C SGCUT average specific gravity of pseudocomponents
C TBCUT average true boiling point of pseudocomponents
C TCCUT average critical temperature of pseudocomponents
C PCCUT average critical pressure of pseudocomponents
C WCUT average acentric factor of pseudocomponents
C TMCUT normal melting point of pseudocomponents
C DHMCUT enthalpy of fusion of pseudocomponents
C DSMCUT entropy of fusion of pseudocomponents
C DCPCUT change in Cp on fusion of pseudocomponents
C ZWAT number of moles of water present
C MWWAT molecular weight of water
C SGWAT specific gravity of water
C NERR no. errors reported by this routine and lower level routines
C IERR Array of error codes. Values returned by this routine:
C 13941 Discrete component not in databank
C 13942 Reading data bank has failed
53
C 13943 Discrete component not hydrocarbon, CO2, H2S or nitrogen
C 13944 Insufficient discrete components named
C 13946 Procedure to model CN distribution has failed
C -13941 Fluid a gas and mol.wt. or sp.grav. specified
C -13942 Fluid an oil and mol.wt. and sp.grav. not. specified
The simplified version to be used for TBP and D86 curves, AYPVT1 TBP is defined as:
INTEGER, INTENT(IN) :: LNOPF, NCN, LMW,LSG, NSPLT(2), SSPLT(2), MXERR
INTEGER, INTENT(OUT) :: NCUT, ITCUT(*), NERR, IERR(*)
INTEGER, INTENT(INOUT) :: ISTART
LOGICAL, INTENT(IN) :: LUT, LSARA, LTWC, D86, CUTUNITS
REAL*8, INTENT(IN) :: ACN(*), TB_CN(*), MWCN, SGCN, MW, SG,
+ SARA(4), TWC, CNSPLT(MAXNCS,2), WVOL, TOTAL
REAL*8, INTENT(OUT) :: ZCUT(*), CNLCUT(*), CNCUT(*), MWCUT(*),
+ SGCUT(*), TBCUT(*), TCCUT(*), PCCUT(*), WCUT(*), TMCUT(*),
+ DHMCUT(*), DSMCUT(*), DCPCUT(*), ZWAT, MWWAT, SGWAT
CHARACTER*(*), INTENT(OUT) :: NMCUT(*)
C Input arguments:
C LNOPF Load number of characterisation databank (correlations)
C D86 Flag indicating if the analysis is D86 (.TRUE.) or TBP (.FALSE.)
C NCN Number of boiling point cuts
C ACN cumulative volume of boiling point cuts (cm3)
C TB_CN Temperature in K or carbon number for boiling point cuts
C MWCN Molecular weight for boiling point cuts (set to -DLARGE if not specified)
C SGCN Specific gravity for boiling point cuts (set to -DLARGE if not specified)
C CUTUNITS .TRUE. TB_CN units in K, .FALSE. TB_CN indicates carbon number
C MW molecular weight (set to -DLARGE if not specified).
C LMW = 0 MW refers to the plus fraction
C = 1 MW refers to the total fluid
C = 2 MW refers to the STO
C SG specific gravity (set to -DLARGE if not specified)
C LSG = 0 SG refers to the plus fraction
C = 2 SG refers to the STO
C SARA values of the SARA analysis. Set not specified values to -DLARGE.
C LSARA .TRUE. if missing SARA data to be estimated, otherwise .FALSE.
C This is only required if an asphaltene model is used.
C TWC Total (UOP) wax content as mass fraction. (set to -DLARGE if not specified)
C LTWC .TRUE. if n-paraffin distribution to be estimated.
C SSPLT carbon number at which pseudocomponents to start
C (1) value for non n-paraffin distribution
C (2) value for n-paraffin distribution. Set to 0 for default.
C (Only required if wax content entered or estimated).
C NSPLT number of pseudocomponents required
C (1) value for non n-paraffin distribution
C (2) value for n-paraffin distribution. Set to 0 for default.
C (Only required if wax content entered or estimated).
C CNSPLT User defined lower carbon number bounds defined for pseudocomponents.
C (set to -DLARGE if not specified)
C (*,1) value for non n-paraffin distribution
54
C (*,2) value for n-paraffin distribution. Set to 0 for default.
C WVOL water cut as volume fraction of liquid hydrocarbon phase. (set to -DLARGE
C if not specified)
C TOTAL Total amount of fluid. Compositions are scaled to give this amount.
C LUT .TRUE. if total amount (TOTAL) is in mass units (g), .FALSE.
C if in molar units (mol).
C MXERR Dimension of IERR array.
C
C Input/Output Arguments
C ISTART Carbon number at which regresion should start.
C The output is the CN at which the regression actually starts.
C
C Output arguments
C NCUT number of pseudocomponents returned
C NMCUT assigned names of pseudocomponents
C ZCUT molar amounts of pseudocomponents
C ITCUT type of pseudocomponent (code from AYJXID.inc)
C CNLCUT lower carbon number boundary of pseudocomponents
C CNCUT average carbon number of pseudocomponents
C MWCUT average molecular weight of pseudocomponents
C SGCUT average specific gravity of pseudocomponents
C TBCUT average true boiling point of pseudocomponents
C TCCUT average critical temperature of pseudocomponents
C PCCUT average critical pressure of pseudocomponents
C WCUT average acentric factor of pseudocomponents
C TMCUT normal melting point of pseudocomponents
C DHMCUT enthalpy of fusion of pseudocomponents
C DSMCUT entropy of fusion of pseudocomponents
C DCPCUT change in Cp on fusion of pseudocomponents
C ZWAT number of moles of water present
C MWWAT molecular weight of water
C SGWAT specific gravity of water
C NERR no. errors reported by this routine and lower level routines
C IERR Array of error codes. Values returned by this routine:
C 14221 Cut bounds must be defined for the D86 method - method failed
C 14222 Amounts distilled must be defined by volume for the D86 method -
C method failed
The information provided by AYPVT1 or AYPVT1 TBP should be used to load the discrete
components (using AYPDBC and pseudocomponents (using AYPPF) as described in section 4.
The amounts of the components should be used to calculate the properties of the mixture
using the thermodynamic and transport property models described in section 8.
55
+ IERR(*), NADIS, NDIS, SSPLIT(*), LSG
REAL*8 GOR, GG, SG, WK, GASAMT(*), SARA(*), TWC, ZDIS(*),
+ ZCUT(*), CNLCUT(*), CNCUT(*), MWCUT(*), SGCUT(*), TBCUT(*),
+ TCCUT(*), PCCUT(*), WCUT(*), TMCUT(*), DHMCUT(*),
+ DSMCUT(*), DCPCUT(*), WATCUT, ZWAT, MWWAT, SGWAT, TOTAL
CHARACTER*(*) NMDIS(*), NMCUT(*)
LOGICAL ESARA, ETWC, LUT
SUBROUTINE AYPVB1( LNODB, LNOPF, GG, SG, LSG, GOR, WK, NADIS,
+ GASAMT, SARA, ESARA, TWC, ETWC, SSPLIT, NSPLIT,
+ CNSPLT, NDIS, ZDIS, NMDIS, NCUT, NMCUT, ZCUT,
+ ITCUT, CNLCUT, CNCUT, MWCUT, SGCUT, TBCUT,
+ TCCUT, PCCUT, WCUT, TMCUT, DHMCUT, DSMCUT,
+ DCPCUT, WATCUT, ZWAT, MWWAT, SGWAT, TOTAL, LUT,
+ NERR, MXERR, IERR )
C
C Input arguments:
C LNODB load number for pure component databank used to obtain
C properties of the discrete components
C (obtained from AYPDBO call)
C LNOPF load number for characterisation method to use for
C estimating petroleum fraction properties.
C (obtained from AYPDBO call)
C GOR solution GOR (Rs) (m3/m3)
C GG gas gravity (relative to air) = MWgas/MWair = MWgas/28.966
C SG liquid specific gravity (relative to water at 1 atm, 60F)
C LSG code to identify liquid to which SG refers:
C 2 SG is for stock tank oil
C 1 SG is for the total fluid (oil plus dissolved gas)
C WK Watson K-factor for oil (optional).
C An undefined value should be set -DLARGE.
C NADIS Number of gas discrete components
C GASAMT amounts (moles) of the gas discrete components in the
C following order: N2, CO2, methane, ethane, propane,
C isobutane, butane
C TOTAL total amount for fluid stream (after recombination) - in
C units set bu LUL
C LUT units of TOTAL amount:
C .TRUE. for mass units (g)
C .FALSE. for molar units (mole)
C SARA SARA analysis as weight fractions of saturates,
C aromatics, resins and asphaltenes. Only the values for resins
C and aspaltenes are actually used. Undefined values should
C be set -DLARGE.
C ESARA .TRUE. if missing SARA data to be estimated, otherwise .FALSE.
C This is only required if an asphaltene model is used.
C TWC Total (UOP) wax content in liquid as mass fraction
C An undefined value should be set -DLARGE.
C ETWC .TRUE. if n-paraffin distribution to be estimated
C This is only required if the Coutinho wax model is used.
C SSPLIT Carbon number at which pseudocomponents to start
C (1) value for non n-paraffin distribution
C (2) value for n-paraffin distribution. Set to 0 for default.
C (Only required if wax content entered or estimated).
C NSPLIT Number of pseudocomponents required
C (1) value for non n-paraffin distribution
C (2) value for n-paraffin distribution. Set to 0 for default.
56
C (Only required if wax content entered or estimated).
C CNSPLT Lower carbon number bounds defined for pseudocomponents
C An undefined value should be set -DLARGE.
C WATCUT Water cut as volume fraction of liquid at 60F and 1 atm
C MXERR maximum number of error codes to return in IERR
C
C Output arguments:
C NDIS Number of discrete components required (excluding water)
C ZDIS Mole numbers of discrete components
C NMDIS Names of discrete components
C NCUT Number of pseudocomponents returned
C NMCUT Assigned names of pseudocomponents
C ZCUT Molar amounts of pseudocomponents
C ITCUT Type of pseudocomponent (from AYJXID.inc)
C CNLCUT Lower carbon number boundary of pseudocomponents
C CNCUT Average carbon number of pseudocomponents
C MWCUT Average molecular weight of pseudocomponents
C SGCUT Average specific gravity of pseudocomponents
C TBCUT Average true boiling point of pseudocomponents
C TCCUT Average critical temperature of pseudocomponents
C PCCUT Average critical pressure of pseudocomponents
C WCUT Average acentric factor of pseudocomponents
C TMCUT Normal melting point of pseudocomponents
C DHMCUT Enthalpy of fusion of pseudocomponents
C DSMCUT Entropy of fusion of pseudocomponents
C DCPCUT Change in Cp on fusion of pseudocomponents
C ZWAT Number of moles of water present
C MWWAT Molecular weight of water
C SGWAT Specific gravity of water
C NERR No. errors reported by this routine and lower level routines
C IERR Array of error codes. Values returned by this routine:
C 14061 Liquid specific gravity not defined
C 14062 SG specified is too small.
C 14063 The liquid specific gravity is too big.
C 14064 GG specified is either too small or too big.
C 14065 GOR not defined
C 14066 Discrete component not in databank
C 14067 Reading data bank has failed
C 14068 The Watson K-factor and the SG of the liquid are not
C consistent, so that MW of C5+ is too small from the correlation
C 14069 Maximum iteration reached
C 14070 Blackoil analysis procedure to model CN distribution has failed.
C -14061 The gas analysis is not consistent with the gas gravity,
C default values used.
C -14062 The Watson K-factor is too big, default value used.
C -14063 The Watson K-factor is too small, default value used.
C -14064 The amount or MW of the gas stream is too small based
C on the the gas analysis and the input data, so that
C the gas analysis is ignored.
57
the Multiflash blending procedure. The method of averaging the properties of the blended
pseudo-components is exactly the same as that used in the PVT analysis procedure to cre-
ate the pseudo-components used to represent the properties of the original petroleum fluids.
The method also handles waxy and asphaltenic crudes thereby predicting the likely wax or
asphaltene formation from the fluid blend.
The calling specification for AYBLND is:
INTEGER MODEL, N(3), TYPE(MAXNCS,3), NERR, MXERR, IERR(*),
+ IDVIS(MAXNCS,3)
REAL*8 Z(MAXNCS,3), CN(MAXNCS,3), MW(MAXNCS,3), SG(MAXNCS,3),
+ TB(MAXNCS,3), TC(MAXNCS,3), PC(MAXNCS,3), W(MAXNCS,3),
+ TM(MAXNCS,3), DHM(MAXNCS,3),DSM(MAXNCS,3),DCPM(MAXNCS,3),
+ RA(2,3), MCRKS(MAXNCS,3,3), MCPR(MAXNCS,3,3),
+ VRKS(MAXNCS,3,3), VPR(MAXNCS,3,3), REFVIS(MAXNCS,3)
CHARACTER*72 NAME(MAXNCS,3), ALIAS(MAXNCS,3)
CHARACTER*12 CARN(MAXNCS,3)
LOGICAL HC(MAXNCS,3)
58
C MCRKS Array of component MC parameters for RKS model, (1) for first stream;
C (2) for second stream
C MCPR Array of component MC parameters for PR model, (1) for first stream;
C (2) for second stream
C VRKS Array of component volume shift for RKS model, (1) for first stream;
C (2) for second stream
C VPR Array of component volume shift for PR model, (1) for first stream; (2)
C for second stream
C REFVIS Array of component reference viscosity,, (1) for first stream; (2) for
C second stream
C IDVIS Viscosity model ID for reference viscosity, (1) for first stream; (2)
C for second stream
C RA Resin-asphaltene parameters, (1) for first, (2) for the second mixture
C MXERR maximum number of error codes to return in IERR
C
C Output arguments:
C N Number of components, (3) for blended mixture
C NAME Array of component names, (3) for blended mixture
C ALIAS Array of component aliases , (3) for blended mixture
C CARN Array of component CAR numbers , (3) for blended mixture
C TYPE Array of component types , (3) for blended mixture
C Z Array of component mole fractions , (3) for blended mixture
C CN Array of component carbon numbers , (3) for blended mixture
C MW Array of component molecular weights , (3) for blended mixture
C SG Array of component specific gravities , (3) for blended mixture
C TB Array of component normal boiling points , (3) for blended mixture
C TC Array of component critical temperatures , (3) for blended mixture
C PC Array of component critical pressures , (3) for blended mixture
C W Array of component acentric factors , (3) for blended mixture
C TM Array of component normal melting points , (3) for blended mixture
C DHM Array of component enthalpies of fusion , (3) for blended mixture
C DSM Array of component entropies of fusion , (3) for blended mixture
C DCPM Array of component changes in Cp on fusion , (3) for blended mixture
C MCRKS Array of component MC parameters for RKS model , (3) for blended mixture
C MCPR Array of component MC parameters for PR model , (3) for blended mixture
C VRKS Array of component volume shift parameters , (3) for blended mixture
C for RKSA
C VPR Array of component volume shift parameters , (3) for blended mixture
C for PRA
C REFVIS Array of component reference viscosity parameters , (3) for blended
C mixture
C IDVIS Viscosity model ID for reference viscosity, (3) for blended mixture
C RA Resin-asphaltene parameters, (3) for the blended mixture.
C NERR no. errors reported by this routine and lower level routines
C IERR Array of error codes. Values returned by this routine:
C 14151 Mol. wt. and/or carbon number missing for pseudocomponent
C -14151 Viscosity models are not consistent among the blended fluids.
59
7 Binary interaction parameters
Binary interaction parameters (BIPs) are required by most of the mixture property models
in Multiflash. Some models, such as cubic equations of state, can produce useful property
predictions for many mixtures without specially fitted BIPs. Other models e.g. , most activity
models, require specific non-default BIPs to make realistic predictions. For more information
on the models available and their BIPs see Appendices E - L.
Before setting up a mixture model that requires non-default BIPs it is necessary to define
the BIP values. The procedures for doing this are described in this section.
3. Load BIPs
• from databanks.
• and/or entering directly
CALL AYBINI()
60
C NBANK Dimension of the array JBANK.
C JBANK code for databank to be opened or for databank structure.
C If NFIL is zero JBANK refers to a particular databank
C that is known to Multiflash. Otherwise it is used to
C identify the file structure.
C The available codes for JBANK are listed in the include
C file ayjdbk.inc:
C JBOG1 Infochem ’Oilandgas1’ correlations for BIPs
C JBOG2 Infochem ’Oilandgas2’ correlations for BIPs
C JBOG3 Infochem ’Oilandgas3’ correlations for BIPs
C JBOG4 Infochem ’Oilandgas4’ correlations for BIPs
C JBINFO Infochem-supplied binary parameter bank (VLE)
C JBINFL Infochen-supplied binary parameter bank (LLE)
C JBOINF generic BIP bank in Infochem format
C NFIL Number of filenames passed in NAMFIL. If NFIL is set
C to zero the default filenames will be used for each
C databank. To open a databank with the same structure as
C one of the standard databanks it is necessary to set NFIL
C and NAMFIL correctly (see below).
C NAMFIL Array of NFIL file names. The following information
C is required for each databank structure:
C structure JBANK NFIL NAMFIL
C Infochem BIP JBOINF 1 databank file
C Infochem BIP JBOG1-4 not allowed - these are sets of
C internal correlations
C MXERR maximum number of error flags to be returned in IERR
C
C Output arguments:
C LNODBB Data bank load number (used to refer to databank in
C all subsequent operations)
C NERR no. errors reported by this routine and lower level routines
C IERR array of error codes. Values returned by this routine:
C 10401 Unrecognised data bank
C 10402 Run out of data bank load numbers
C 10403 Run out of space in data bank load information array
C 10404 Data files not appropriate for this data source
C 10405 Data files required for this data source
For example, the following call opens the INFOBIPS BIP bank:
INCLUDE ’ayjdbk.inc’
INTEGER MXERR
PARAMETER ( MXERR = 10 )
INTEGER JBANK(1), LNODBB, NERR, IERR(MXERR)
CHARACTER*1 CDUM(1)
JBANK(1) = JBINFO
CALL AYPDBO( 1, JBANK, 0, CDUM, LNODBB, NERR, MXERR, IERR )
This call returns BIP data source load number in LNODBB which must be passed without
alteration to subroutine AYBDBL which loads the BIP values. Note: all BIP databanks must
be in the required Infochem format.
AYPDBO can also open a user’s own data file with the same structure as the Infochem BIP
bank. To do this the name of the files containing the BIP data and the index file (BIPFIL)
must be passed to AYPDBO rather than a blank. For example:
INCLUDE ’ayjdbk.inc’
INTEGER MXERR
61
PARAMETER ( MXERR = 10 )
INTEGER JBANK(1), LNODBB, NERR, IERR(MXERR)
CHARACTER*10 BIPFIL(2)
BIPFIL(1) = ’myfile.bin’
BIPFIL(2) = ’myfile.idx’
JBANK(1) = JBOINF
CALL AYPDBO( 1, JBANK, 2, BIPFIL, LNODBB, NERR, MXERR, IERR )
62
For example, the following code sets up a BIP load number (LNOB1 for the RKS model
by loading BIPs from a databank:
INTEGER MAXMDL
PARAMETER ( MAXMDL = 5 )
INTEGER MXERR
PARAMETER ( MXERR = 10 )
INCLUDE ’aymncs.inc’
INCLUDE ’ayjmid.inc’
INTEGER IC(1), NMDL, LMDL(MAXMDL), LNOB1, LNOB2, NBIP,
+ LNODBB, NERR, IERR(MXERR)
LOGICAL INIT
LMDL(1) = JMRKS
NMDL = 1
INIT = .TRUE.
NBIP = 1
LNOB1 = 0
CALL AYBDBL( LNODBB, 0, IC, INIT, NMDL, LMDL, NBIP, LNOB1, NERR,
+ MXERR, IERR )
The thermodynamic model for which the BIPs are required is referred to by array LMDL
with LMDL(1) set to the model identifier (JM-number from file ayjmid.inc) and LMDL(2),
LMDL(3), etc. set to the (optional) model variant numbers (other J numbers from file
ayjmid.inc). The BIPs are stored in a linear form as half-arrays: for most equations of
state one half-array is needed as the BIP array is symmetric (NBIP=1); for the Wilson and
UNIQUAC equations two half-arrays are needed as the BIP array is asymmetric (NBIP=1,2);
for the NRTL equation and the Infochem-NRTL mixing rule for cubic equations of state three
half-arrays are needed to store the asymmetric BIP array (NBIP=1,2) and the symmetric al-
pha array (NBIP=3).
63
SUBROUTINE AYBIP_USR( NC, IC, INIT, LNO, IBFUN, NBCO, DEFBIP,
+ ORD_DIM, BCOIN, NERR, MXERR, IERR )
C
C NC number of components for which BIPs are entered.
C Zero means "all components currently defined".
C IC subcomponent list; if NC is not set to zero the array
C IC must be filled with the NC component load numbers
C for which BIPs are supplied.
C INIT logical flag.
C If .TRUE. all BIP values entered in the BCOn arrays will
C be stored internally.
C If .FALSE. the BIPs entered will only be stored for those
C cases where a BIP has not already been set. This option
C is provided to allow the routine to be called several
C times with subsets of BIPs estimated by different methods.
C IBFUN BIP function number (id codes defined in aybfid.inc)
C JBFUND undefined
C JBFT1 a + bT + cT^2 (dimensionless, T in K, for eos)
C JBFT2 a + bT + c/T (dimensionless, T in K, for eos)
C JBACT a + bT + cT^2 (J/mol, T in K, for activity models)
C JBFASS for association models
C JBGERT for gerg mixing rule in csma model, TC
C JBGERV for gerg mixing rule in csma model, VC
C NBCO number of coefficients entered for the T-function
C specified by IBFUN:
C NBCO values must be entered in
C 1 BCOIN(1,*)
C 2 BCOIN(1,*) to BCOIN(2,*)
C 3 BCOIN(1,*) to BCOIN(3,*)
C 4 BCOIN(1,*) to BCOIN(4,*)
C DEFBIP default value of BIPs for BCO(1,*). This value is stored
C in any unspecifed BIPs when the BIPload number is set up.
C Eg. for a cubic eos DEFBIP would usuallly be set to 0.
C ORD_DIM Leading dimension of the BCOIN array.
C BCOIN(1,*) first order BIP coefficients
C BCOIN(2,*) second order BIP coefficients
C BCOIN(3,*) third order BIP coefficients
C BCOIN(4,*) fourth order BIP coefficients
C Note: BIPs in BCOIN1,2,3,4 are entered as linear arrays.
C Values in these arrays must be ordered correctly to
C correspond with the pairs of components in listed in IC.
C The BIP between the Ith and Jth components , where J < I,
C must be placed in BCO(K), where K = (I-1)(I-2)/2 + J
C the size of the second dimension must be at least 1+NC/2(NC-1)
C MXERR maximum number of error codes to return in IERR
C
C Input/output argument:
C Input values:
C LNO BIP load number. If set to 0 a new BIP load number is
C returned and all BIPs are set to default values before
C the specified values are entered.
C
C Output values:
C LNO BIP load number as entered, or new load number if 0 entered
C
C Output arguments:
64
C NERR number of error codes returned in IERR
C IERR error codes. Values for this routine:
C 13121 Run out of BIP load numbers
C 13122 Run out of space in BIP load array
C 13123 Incompatible function type
C -13121 BIP temperature function incompatible with some/all
C stored BIPs
The function AYBUSR is also supplied and it is applicable for the majority of the BIPs
necessary.
SUBROUTINE AYBUSR( NC, IC, INIT, LNO, IBFUN, NBCO, DEFBIP, BCO1,
+ BCO2, BCO3, NERR, MXERR, IERR )
C Input arguments:
C NC number of components for which BIPs are entered.
C Zero means "all components currently defined".
C IC subcomponent list; if NC is not set to zero the array
C IC must be filled with the NC component load numbers
C for which BIPs are supplied.
C INIT logical flag.
C If .TRUE. all BIP values entered in the BCOn arrays will
C be stored internally.
C If .FALSE. the BIPs entered will only be stored for those
C cases where a BIP has not already been set. This option
C is provided to allow the routine to be called several
C times with subsets of BIPs estimated by different methods.
C IBFUN BIP function number (id codes defined in aybfid.inc)
C JBFUND undefined
C JBFT1 a + bT + cT^2 (dimensionless, T in K, for eos)
C JBFT2 a + bT + c/T (dimensionless, T in K, for eos)
C JBACT a + bT + cT^2 (J/mol, T in K, for activity models)
C JBFASS for association models
C JBGERT for gerg mixing rule in csma model, TC
C JBGERV for gerg mixing rule in csma model, VC
C NBCO number of coefficients entered for the T-function
C specified by IBFUN:
C NBCO values must be entered in
C 1 BCO1
C 2 BCO1, BCO2
C 3 BCO1, BCO2, BCO3
C DEFBIP default value of BIPs for BCO1. This value is stored
C in any unspecifed BIPs when the BIPload number is set up.
C Eg. for a cubic eos DEFBIP would usuallly be set to 0.
C BCO1 first order BIP coefficients
C BCO2 second order BIP coefficients
C BCO3 third order BIP coefficients
C Note: BIPs in BCO1,2,3 are entered as linear arrays.
C Values in these arrays must be ordered correctly to
C correspond with the pairs of components in listed in IC.
C The BIP between the Ith and Jth components , where J < I,
65
C must be placed in BCO(K), where K = (I-1)(I-2)/2 + J
C MXERR maximum number of error codes to return in IERR
C
C Input/output argument:
C Input values:
C LNO BIP load number. If set to 0 a new BIP load number is
C returned and all BIPs are set to default values before
C the specified values are entered.
C
C Output values:
C LNO BIP load number as entered, or new load number if 0 entered
C
C Output arguments:
C NERR number of error codes returned in IERR
C IERR error codes. Values for this routine:
C -13122 BIP temperature function needs more bip values.
C Bip index 4 is set to zero.
AYBUSR may be called as often as is required to enter BIPs. If the load number LNO is
entered as zero, new BIP half-arrays are created and the load number is returned in LNO. If
an existing load number is entered, the existing values of the BIPs are overwritten. Setting
a BCO value to -DLARGE (from routine AYNUMV) means that the existing value is not to be
overwritten. If INIT is .TRUE., all other existing values are overwritten, if INIT is .FALSE.,
only default existing values are overwritten.
The ordering of values in the arrays BCO1, BCO2 and BCO3 or BCOIN is according to the
following rules. The BIP between the the ith. and jth. components in the subcomponent list
IC must be placed in BCO(k) where k = (i − 1)(i − 2)/2 + j and j < i. The diagonal elements
of the BIP array are not stored as they are not significant. For models that require more
than one BIP it is necessary to define a separate BIP load number and associated BIP values
for each set of BIPs. The number of BIP load numbers required be each model is listed in
section 8.2. Note that it is only necessary to define BIP load numbers when non-default BIP
values are required.
The function used to correlate BIPs is denoted by the argument IBFUN. The following
options are available:
• JBFUND: the correlation is undefined which means that a set of values is stored but no
restriction is placed on their use. When the BIP set is connected to a model the model
is responsible for determining how the values are used.
• JBFT2: the correlation has the form: B = a + bT + c/T where the temperature T is in
K. The BIP is dimensionless and is intended for use by an equation of state model.
• JBFASS: Up to 3 parameters may be specified for use by the association model (CPA).
• JBEOSV: Up to 3 parameters may be specified for use by the CSMA BIP for Vc.
66
• JBGERGF: 1 parameter that specified the weighting factor used by the GERG model.
INCLUDE ’aymncs.inc’
INCLUDE ’aybfid.inc’
INTEGER MXERR
PARAMETER (MXERR=10)
INTEGER IC(1), LNOB1, LNOB2, NERR, IERR(MXERR)
REAL*8 BCO(4,MAXNCS*(MAXNCS-1)/2)
LOGICAL INIT
INIT = .TRUE.
LNOB1 = 0
BCO1(1,1) = -459.02D0
BCO1(1,2) = 1916.20D0
BCO1(1,3) = 7846.20D0
CALL AYBIP_USR( 0, IC, INIT, LNOB1, JBFACT, 1, 0.0D0, 4, BCO,
+ NERR, MXERR, IERR )
LNOB2 = 0
BCO1(1,1) = 5578.10D0
BCO1(1,2) = 606.30D0
BCO1(1,3) = -2229.10D0
CALL AYBIP_USR( 0, IC, INIT, LNOB2, JBFACT, 1, 0.0D0, 4, BCO,
+ NERR, MXERR, IERR )
INCLUDE ’ayjdbk.inc’
INTEGER MAXMDL
PARAMETER ( MAXMDL = 5 )
67
INTEGER MXERR
PARAMETER ( MXERR = 10 )
INCLUDE ’aymncs.inc’
INTEGER IC(MAXNCS), NMDL, LMDL(MAXMDL), LNOB1, N, LNODBB, NERR,
+ IERR(MXERR), JBANK(1)
CHARACTER*1 CDUM(1)
LOGICAL INIT
JBANK(1) = JBOG4
CALL AYPDBO( 1, JBANK, 0, CDUM, LNODBB, NERR, MXERR, IERR )
INIT = .TRUE.
N = 1
LNOB1 = 0
CALL AYBDBL( LNODBB, 0, IC, INIT, NMDL, LMDL, N, LNOB1, NERR, MXERR, IERR )
7.6 Utilities
7.6.1 Getting values of stored BIP coefficients
The routine AYBIP VAL returns the values of stored BIP coefficients for a particular BIP load
number. The calling specification is:
INTEGER, INTENT(IN) :: NC, IC(*), LNO, MXERR, ORD_DIM
INTEGER, INTENT(OUT) :: IBFUN, NBCO, NERR, IERR(*)
REAL*8, INTENT(OUT) :: BCO_OUT(ORD_DIM,*)
C Input arguments:
C NC number of components for which BIP values are required.
C Zero means "all components currently defined".
C IC subcomponent list; if NC is not set to zero the array
C IC must be filled with the NC component load numbers
C for which BIPs are required.
C LNO BIP load number
C ORD_DIM Leading dimension of BCO_OUT
C MXERR maximum number of error codes to return in IERR
C
C Output arguments:
C IBFUN BIP function number (id codes defined in aybfid.inc)
C JBFUND undefined
C JBFT1 a + bT + cT^2 (dimensionless, T in K, for eos)
C JBFT2 a + bT + c/T (dimensionless, T in K, for eos)
C JBACT a + bT + cT^2 (J/mol, T in K, for activity models)
C JBFASS for association models
C NBCO number of coefficients entered for the T-function
C specified by IBFUN:
C NBCO values must be entered in
C 1 BCO_OUT(1,*)
C 2 BCO_OUT(1,*) to BCO_OUT(2,*)
C 3 BCO_OUT(1,*) to BCO_OUT(3,*)
C 4 BCO_OUT(1,*) to BCO_OUT(4,*)
C BCO_OUT BIP coefficients
C Note: BIPs in BCO_OUT 1,2,3 are returned as linear arrays.
C The BIP between the Ith and Jth components , where J < I,
C is returned in BCO(K), where K = (I-1)(I-2)/2 + J
C NERR number of error codes returned in IERR
C IERR error codes. Values for this routine:
68
C 13131 Unrecognised BIP load number
The previous utility to fetch the values of BIPs is also provided for backward compatibility.
SUBROUTINE AYBVAL( NC, IC, LNO, IBFUN, NBCO, BCO1, BCO2, BCO3,
+ NERR, MXERR, IERR )
C
C Input arguments:
C NC number of components for which BIP values are required.
C Zero means "all components currently defined".
C IC subcomponent list; if NC is not set to zero the array
C IC must be filled with the NC component load numbers
C for which BIPs are required.
C LNO BIP load number
C MXERR maximum number of error codes to return in IERR
C
C Output arguments:
C IBFUN BIP function number (id codes defined in aybfid.inc)
C JBFUND undefined
C JBFT1 a + bT + cT^2 (dimensionless, T in K, for eos)
C JBFT2 a + bT + c/T (dimensionless, T in K, for eos)
C JBACT a + bT + cT^2 (J/mol, T in K, for activity models)
C JBFASS for association models
C NBCO number of coefficients stored for the T-function
C specified by IBFUN:
C NBCO values returned in
C 1 BCO1
C 2 BCO1, BCO2
C 3 BCO1, BCO2, BCO3
C BCO1 first order BIP coefficients
C BCO2 second order BIP coefficients
C BCO3 third order BIP coefficients
C Note: BIPs in BCO1,2,3 are returned as linear arrays.
C The BIP between the Ith and Jth components , where J < I,
C is returnrd in BCO(K), where K = (I-1)(I-2)/2 + J
C NERR number of error codes returned in IERR
C IERR error codes. Values for this routine:
C 13131 Unrecognised BIP load number
Besides being possible to get the BIP values, it is also possible to know where do the
values come from. As for the pure component data, the BIP values also stored its status.
Databank defined, user defined or undefined. The function used to get the BIP values status
is AYBVLS
C Input arguments:
C NC number of components for which BIP values are required.
69
C Zero means "all components currently defined".
C IC subcomponent list; if NC is not set to zero the array
C IC must be filled with the NC component serial numbers
C for which BIPs are required.
C LNO BIP load number
C ORD_DIM Leading dimenstion for the IBCO_OUT array
C MXERR maximum number of error codes to return in IERR
C
C Output arguments:
C IBFUN BIP function number (JBFT1=a+bT+cT^2(eos), JBFT2=a+bT+c/T(eos),
C JBACT=a+bT+cT^2(activity eqn), JBFASS=association,
C JBGERT=GERG mixing rule in CSMA model)
C JBGERV=GERG mixing rule in CSMA model)
C NBCO number of coefficients entered for the T-function
C specified by IBFUN:
C NBCO values must be entered in
C 1 IBCO_OUT(1,*)
C 2 IBCO_OUT(1,*) to IBCO_OUT(2,*)
C 3 IBCO_OUT(1,*) to IBCO_OUT(3,*)
C 4 IBCO_OUT(1,*) to IBCO_OUT(4,*)
C IBCO_OUT status of BIP coefficients
C Note: BIPs in IBCO_OUT are returned as linear arrays.
C The status between the Ith and Jth components , where J < I,
C is returned in IBCO(K), where K = (I-1)(I-2)/2 + J
C status values are found in ayjuid.inc
C NERR number of error codes returned in IERR
C IERR error codes. Values for this routine:
C 13141 Unrecognised BIP load number
The load number LNOB and associated storage is released for subsequent reuse. This
routine is provided, principally, for use in interactive programs as there has to be a finite
limit to the total number of BIP load numbers that the software can handle. The limit
can be altered by changing the appropriate dimensioning parameters in files aymbco.inc,
aymbin.inc, and recompiling the Models software. See also section 8.7 on freeing model load
numbers.
70
C
C Input arguments:
C MXERR maximum number of error codes to return in IERR
C
C Input/output arguments:
C Input values:
C ICO Component load number
C
C Output values:
C ICO Component load number (0=deleted)
C
C Output arguments:
C NERR number of error codes returned in IERROR
C IERR error codes. None specific to this routine.
Deleting the BIPs means that default values will be used by the models.
71
8 Setting up mixture property models
The following steps are required:
3. Load models.
72
C 10021 model identification code is not valid
C 10022 model cannot be initialised
C 10023 run out of model load numbers
C 10024 Run out of space in model load information array
The value of NMDL and the information required in LMDL is model-dependent and is defined
in the tables below. If the full options list is not passed to AYLOAD, the missing options are
set to the defaults; the default values are always the first ones in each list. Any option
values beyond those expected are ignored. The model option identifiers are all held in file
ayjmid.inc. The models available are defined in Appendices E - L.
The flag FULL, as stated in the description of the arguments is to be used to test model
definitions. For example, if the hydrate model is to be loaded but no water is present and
FULL == .TRUE., the model loading will fail as it needs water to perform calculations.
One model may be defined in terms of another model. Whenever a model depends on
another, the model on which it is dependent must be loaded first and its load number is
passed to the dependent model in the LMDL array. AYLOAD may be called as many times as
is necessary to load the models that will be required. The models software permits several
models to be loaded at any time. The number of models that may be loaded is limited by
parameters in files aymlno.inc and aymlda.inc.
73
model NMDL LMDL(1) (2) (3) (4) (5) (6) (7)
RKS type EOS
GUI Models:
RKS 5 JMRKSA JVRKS JVRKS JVVDW LBIP1
RKS API 5 JMRKSA JVAPI JVRKS JVVDW LBIP1
RKS (Advanced) 5 JMRKSA JVSVP JVDEN JVVDW LBIP1
RKSA (Infochem) 7 JMRKSA JVSVP JVDEN JVNRTL LBIP1 LBIP2 LBIP3
RKS-HVP 7 JMRKSA JVRKS JVDEN JVHVPS LBIP1 LBIP2 LBIP3
PSRK 5 JMRKSA JVMC JVDEN JVPSRK LNOGEX
PSRK-NRTL model 5 JMRKSA JVMC JVDEN JVPSRK LNOGEX
Other variants:
RK EOS 5 JMRKSA JVRK JVRKS JVVDW LBIP1
RKS with volume shift 5 JMRKSA JVRKS JVDEN JVVDW LBIP1
PR type EOS
GUI Models:
PR 5 JMPRA JVPR JVPR JVVDW LBIP1
PR (Advanced) 5 JMPRA JVSVP JVDEN JVVDW LBIP1
PR78 5 JMPRA JVPR78 JVPR JVVDW LBIP1
PR78 (Advanced) 5 JMPRA JVSV78 JVDEN JVVDW LBIP1
PR-HVP 7 JMPRA JVPR JVDEN JVHVPS LBIP1 LBIP2 LBIP3
Other variants:
PR with volume shift 5 JMPRA JVPR JVDEN JVVDW LBIP1
PR78 with volume shift 5 JMPRA JVPR78 JVDEN JVVDW LBIP1
PRA with NRTL-type mixing rule 7 JMPRA JVSVP JVDEN JVNRTL LBIP1 LBIP2 LBIP3
ZJ EoS 5 JMZJ JVZJ LBIP
74
8.3.2 Non-cubic equations of state
model NMDL LMDL(1) (2) (3) (4) (5)
Ideal gas EoS 1 JMIDG
HOC (2nd virial) 1 JMHOC
LKP method 3 JMLKP JVLKP LBIP1
LK method 3 JMLKP JVLK LBIP1
BWR(S) EoS
BWRS 3 JMBWRS JVBWRS LBIP1
BWRS (Starling-Han) 3 JMBWRS JVSH LBIP1
BWR 3 JMBWRS JVBWR LBIP1
Corresponding states
CSMA with vdw mixing rule 4 JMCSMA JVVDW LBIP1
CSMA with GERG mixing rule 5 JMCSMA JVCGER LBIP1 LBIP2 LBIP3
GERG-2008 model 5 JMGERG JVCGER LBIP1 LBIP2 LBIP3
IAPWS-95 water model 1 JMSTEA
CO2 high-accuracy model 1 JMCDIO
CPA models
CPA (Infochem) 4 JMASSO JVSVP LBIP1 LBIP2
Asphaltene model
Default model 1 JMASP
Full specification 2+ JMASP NDPAR JPi Pi repeated
NDPAR*2
PC-SAFT model
Standard model 5 JMSAFT JVPC 0 LBIP1 LBIP2
Simplified Michelsen version 5 JMSAFT JVLYNG 0 LBIP1 LBIP2
Model variants:
JPi model data parameter identifier (model-dependent, see ayjmid.inc)
JVBWR Original BWR eos
JVBWRS Starling modified BWR eos using stored parameters (where available) and SH
correlation otherwise
JVLKP Use standard LKP mixing rules
JVLK Use original LK mixing rules
JVLYNG Simplified PC-SAFT model
JVPC Original PC-SAFT model
JVSH Starling modified BWR eos using Staring-Han correlation for parameters
JVSVP a parameter fitted to vapour pressure
LBIP1 Load number for kij or Aij binary interaction parameters
LBIP2 Load number for Aji binary interaction parameters
LBIP3 Load number for Fij weighting factor of binary departure eos contribution
LNOFL Load number of fluid (gas/liquid) phase model
NDPAR number of data parameters for model
Pi model data parameter value (model-dependent)
Model variants:
JVANAL Original variant of the addition model
LNOM Load number of previously loaded model
75
Asphaltene model. To use the asphaltene model it is necessary to combine it with a
fluid model. In principle the asphaltene model can be combined with any fluid model, but it
has been optimized for the RKSA model, and it is not recommended to combine it with any
other model.
model NMDL LMDL(1) (2) (3) (4)
Free energy addition model 4 JMADD JVANAL LNOASP LNOFL
Model variants:
LNOASP Load number for asphaltene model
LNOFL Load number of fluid (gas/liquid) phase model
Electrolyte model. The electrolyte model also needs to be combined with a fluid model
using the free energy addition model. See also section 8.3.6.
Model variants:
LNOLRI Load number for electrolyte phase check model
LNOLRE Load number for long-range electrolyte model
LNOFL Load number of fluid (gas/liquid) phase model
Model variants:
JVFH Flory-Huggins model
JVLLE Use LLE variant
JVPSRK Predictive SRK parameters/mixing rule
JVPNHC Predictive SRK parameters/mixing rule with no hydrocarbon correction
76
JVORIG Original UNIFAC parameters/mixing rule
JVDORT Dortmund modified UNIFAC parameters/mixing rule
JVREG Regular solutions model
JVSL Use E (or small lambda) variant
JVVLE Use VLE variant
JVWILA Use A (or large lambda) variant
JVACG Activity coefficient model for gas phase
LBIP1 Load number for kij or Aij binary interaction parameters
LBIP2 Load number for Aji binary interaction parameters
LBIP3 Load number for NRTL ‘alpha’ binary interaction parameters
LNOG Load number of gas phase model
LNOL Load number of liquid activity model
Jpc Switch for Poynting correction: JVPOYN (default) or JVNOPO
Data entries:
n A subscript number of array LMDL
JPSUB Integer parameter specifying a subgroup
IDSUB Subgroup identifier - value between -1 and -10 denotes a user-defined subgroup
IEQR r-value, single precision real equivalenced to an integer
IEQQ q-value, single precision real equivalenced to an integer
IDGRP Identifier of group to which subgroup belongs - value between -1 and -10
denotes a user-defined group
Each group definition requires a sequence of 6 contiguous elements LMDL as shown in the
following table.
Data entries:
n A subscript number of array LMDL
JPGRP Integer parameter specifying a group interaction parameter
IDGRP1 First group identifier - value between -1 and -10 denotes a user-defined group
IDGRP2 Second group identifier - value between -1 and -10 denotes a user-defined group
IEQIP0 constant term in (non-symmetric) group interaction parameter - single
precision real equivalenced to an integer
IEQIP1 linear temperature term in (non-symmetric) group interaction parameter - single
precision real equivalenced to an integer
IEQIP2 quadratic temperature term in (non-symmetric) group interaction parameter - single
precision real equivalenced to an integer
77
8.3.6 Electrolyte model
Model variants:
JVBORN Born charging term
JVDH Debye-Huückel long-range model
JVVIR Virial term for electrolytes
IBIP1 Bip load number for Deby-Huckel term
IBIP2 Bip load number for second virial term
IBIP3 Bip load number for third virial term
8.3.7 Solids
Model variants:
ICO Component number (for freeze-out model)
JVTYP1 Type I hydrate
JVTYP2 Type II hydrate
JVTYPH Type H hydrate
JVLIQ Relative to liquid phase
JVACT Absolute
JVUNQ Use UNIQUAC mixing rule in Coutinho wax model
JVWIL Use Wilson mixing rule in Coutinho wax model
LNOL Load number of liquid phase model
LNOS Load number of solid phase model
NDPAR Number of data parameters for model
JPi Model parameter identifier (see ayjmid.inc)
Pi Model parameter value
Note that if model parameter identifier JPCOMP is used it must be followed by two values,
the component load number followed by the component abundance.
78
8.3.8 Other thermodynamic models
model NMDL LMDL(1) (2)
Henry’s Law water 2 JMHWT LNOL
COSTALD model 1 JMCOS LBIP1
Model variants:
LBIP1 Load number for kij or Aij binary interaction parameters
LNOL Load number of liquid phase model
Model variants:
JV1PHA 1-phase variant
JV2PHA 2-phase variant
JVLBC standard LBC method
JVSPPV standard superTRAPP viscosity method
79
JVLFIT fit model parameters to match pure component liquid viscosity
JVPDV standard Pedersen viscosity method
JVSPTH standard superTRAPP thermal conductivity method
JVTWV standard Twu method
LBIP BIP load number
LNOVOL Load number of model to use for calculating
volumetric properties
(may be gas or liquid)
LNOVIS Load number of viscosity model
LNOLIQ Load number of thermodynamic model for liquid phase
NDPAR Number of data parameters for model
JPi Model parameter identifier (see ayjmid.inc)
Pi Model parameter value
The JVLFIT option changes the way that pure component model parameters are set. If
a value is set for the reference viscosity (pure component constant property JLVSRF) the
internal model parameters are adjusted to reproduce this value. If the property JLVSRF is
not set (i.e. equalt to -DLARGE) the default method for the model is used to set the required
parameters. To use the viscosity data matching routine AXMT04 the JVLFIT variant should
be specified.
REAL*8, INTENT(IN) :: PV
INTEGER*4 FUNCTION AYMPDV( PV )
For example, the following code fragment defines the asphaltene model and sets the
parameter JPAAA to 1.06.
NMDL = 4
LMDL(1) = JMASP
80
LMDL(2) = 1
LMDL(3) = JPAAA
LMDL(4) = AYMPDV( 1.06D0 )
CALL AYLOAD( 4, LMDL, .TRUE., LNO, NERR, MXERR, IERR )
The reverse operation is also possible. Convert the integer that comes from LMDL into a
real number. This is acomplished using AYMPDV R
which releases the model load number LNO for subsequent reuse. This routine is provided,
principally, for use in interactive programs as there has to be a finite limit to the total
number of model load numbers that the software can handle. The limit can be checked in
appropriate dimensioning parameters in files aymlno.inc and aymlda.inc. See also section
7.6.2 on freeing BIP load numbers.
8.9 Example
The following code fragment shows how to define the Redlich-Kwong equation of state with
default (zero) interaction parameters. The RK eos is treated as a variant of the RKS eos.
C
C Codes for models:
C
INCLUDE ’ayjmid.inc’
C
INTEGER MXERR
81
PARAMETER (MXERR=10)
INTEGER NERR, IERR(MXERR), NMDL, LMDL(5), LNO
C
C Initialise models module:
C
CALL AYMINI( NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error initialising models module’
GO TO 990
ENDIF
C
C Load RK model:
C
NMDL = 5
LMDL(1) = JMRKSA
LMDL(2) = JVRK
LMDL(3) = JVRKS
LMDL(4) = JVVDW
LMDL(5) = 0
CALL AYLOAD( NMDL, LMDL, .TRUE., LNO, NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error loading RK model’
GO TO 990
ENDIF
82
9 Phase descriptors
The idea of a phase descriptor (PD) is central to the operation of all the modules of Multiflash
that deal with mixtures. These include single phase mixture properties (section 10) where the
PD is used directly in the subroutine calls and the phase and chemical equilibrium calculations
(sections 12 and 16) where the PDs are encapsuslated in the stream type identifier. The PD
contains all the information required to identify a phase and to retrieve its thermophysical
properties. A PD must be specified for any phase for which mixture properties are required
and for each possible phase in a phase/chemical equilibrium calculation. Usually, only a
subset of the list of possible phases will actually be present at equilibrium.
INCLUDE ’aympd.inc’
INTEGER, INTENT(IN) :: PHID, KEY, LNOMOD(MXMDPD), MXERR
INTEGER, INTENT(OUT) :: LNOPD, NERR, IERR(*)
83
C (3) thermal properties model load number
C (4) viscosity model load number
C (5) thermal conductivity model load number
C (6) surface tension model load number
C (7) nucleation model load number
C (8) diffusivity model load number
C MXERR maximum number of error codes to return in IERR
C
C Output arguments:
C LNOPD identifier assigned to the defined phase descriptor.
C NERR number of error codes returned in IERR
C IERR error codes. Values for this routine:
C 10291 key component pointer out of range
C 10292 no free space for any PDs
For examples of defining and using PDs see the examples in section N.
INCLUDE ’aympd.inc’
INTEGER, INTENT(OUT) :: NPD, IPD(MAXPD)
INCLUDE ’aympd.inc’
INTEGER, INTENT(IN) :: LNOPD, MXERR
INTEGER, INTENT(OUT) :: PHID, KEY, LNOMOD(MXMDPD), NERR, IERR(*)
84
C AYJXID.INC may be returned.
C LNOMOD model load numbers in phase descriptor definitions.
C The load numbers for which models are not defined are
C set to zero.
C (1) fugacity coefficient model load number
C (2) volumetric properties model load number
C (3) thermal properties model load number
C (4) viscosity model load number
C (5) thermal conductivity model load number
C (6) surface tension model load number
C (7) nucleation model load number
C (8) diffusivity model load number
C NERR number of error codes returned in IERR
C IERR error codes. Values for this routine:
C 10311 LNOPD not a valid PD identifier
9.3 Removing a PD
The maximum number of PDs that can be defined is set by the parameter MAXPD in the
include file aympd.inc. If a previously defined PD is no longer needed it may be removed by
calling AYRMPD. This call frees storage and allows new PDs to be defined if the maximum had
been reached. The calling specification is:
85
10 Evaluating mixture properties
The routines described in this section evaluate the thermodynamic or transport properties
of a mixture in a single phase (vapour, liquid, hydrate,... etc. ). Before calling any of the
routines it is necessary to define a phase descriptor for each phase of interest. The procedure
for doing this is described in section 9.
86
C DF Array of logical flags to control calculation of fugacity
C coefficients and derivatives. Set elements TRUE to return
C required quantities, otherwise set FALSE. The fugacity
C coefficients themselves must always be requested if any
C derivatives are required.
C DF(0) = log fugacity coefficients
C DF(1) = T derivatives
C DF(2) = P derivatives
C DF(3) = mole number derivatives
C IHTYPE Total/residual properties flag for enthalpy and entropy
C (flag values from file AYJXID.INC):
C JHTTOT = total quantities
C JHTRES = residual quantities
C JGEX = excess quantities
C DH Array of logical flags to control calculation of enthalpy/
C entropy and derivatives. Set elements TRUE to return
C required quantities, otherwise set FALSE. The enthalpy/
C entropy must always be requested if any derivatives
C are required.
C DH(0) = enthalpy and entropy
C DH(1) = T derivatives
C DH(2) = P derivatives
C DH(3) = mole number derivatives
C MXERR maximum number of error codes to return in IERR
C
C Output arguments:
C IPHID Phase type found (flag values from file ayptid.inc):
C UNPHAS = no stable phase found
C VPHAS = vapour phase
C LPHAS = liquid phase
C HPHAS = hydrate phase
C CPHAS = pure condensed (solid) phase
C MPHAS = multisolid phase
C SPHAS = mixed solid phase
C AMBIG .TRUE. if fluid supercritical, otherwise .FALSE.
C ZFUG Compressibility factor as calculated by the fugacity
C coefficient model
C V Total volume (m3)
C VT Derivative of V wrt temperature
C VP Derivative of V wrt pressure
C VN Derivative of V wrt mole numbers
C FUG Logarithm of the fugacity coefficients (see note below)
C FUGT Derivative of FUG wrt temperature
C FUGP Derivative of FUG wrt pressure
C FUGN Derivative of FUG wrt mole numbers
C H Total enthalpy (J)
C HT Derivative of H wrt temperature
C HP Derivative of H wrt pressure
C HN Derivative of H wrt mole numbers
C S Total entropy (J K-1)
C ST Derivative of S wrt temperature
C SP Derivative of S wrt pressure
C SN Derivative of S wrt mole numbers
C NERR number of error codes returned in IERR
C IERR error codes. Values for this routine:
C 10251 cannot match fugacity coefficient phase type in doing
C volumetric calculations
87
C 10252 cannot match fugacity coefficient phase type in doing
C enthalpy/entropy calculations
C 10253 requested phase unstable
C 10254 model not valid for fugacity calculation
C 10255 model not valid for volume calculation
C 10256 model not valid for enthalpy, entropy calculation
C 10257 no calculations requested
C 10258 model not valid for activity/GE calculation
C
C Note on derivatives of fugacity coefficient with respect to the
C mole numbers:
C These derivatives form a NCxNC symmetric matrix which is returned
C by AYMIX in a linear array FUGN. The I,Jth element of the matrix
C is placed in FUGN(I*(I-1)/2+J) where J is less than or equal to I.
C Cases where J is greater than I do not have to be returned as the
C matrix is symmetrical.
C The dimension of FUGN must be at least FUGN(NC*(NC+1)/2).
It is also possible to calculate gas phase enthalpy and entropy from the liquid heat capacity.
To do this set CPIDLIQ = 2 by calling AYPSTR with:
JVALUE = JCPLIQ
RCONST = 2.D0
Load the ACG model (Activity coefficient model for gas phase) as descriped in section 8,
and define this model for the gas phase. The ACG model uses an EoS to calculate fugacity
and volumetric properties for the gas phase, and saturated liquid heat capacity and heat of
vaporisation to calculate perfect gas thermal properties.
88
C Z Mole numbers of components
C D .TRUE.=component molecular weights returned in AVMWN,
C otherwise AVMWN values are undefined
C MXERR Maximum number of error flags to be returned in IERR
C
C Output arguments:
C AVMW Average molecular weight
C AVMWN Component molecular weights
C NERR No. errors reported by this routine and lower level routines
C IERR Array of error codes. Values returned by this routine:
C 10091 Undefined molecular weight
C 10092 Negative mole number
C 10093 zero total number of moles
89
10.5 Thermal conductivity: AYTCND
To obtain the thermal conductivity of a phase and its analytical derivatives call AYTCND:
INTEGER, INTENT(IN) :: LNOPD, NC, IC(*), MXERR
INTEGER, INTENT(OUT) :: NERR, IERR(*)
REAL*8, INTENT(IN) :: T, P, Z(*)
REAL*8, INTENT(OUT) :: TCN, TCNT, TCNP, TCNN(*)
LOGICAL, INTENT(IN) :: DER(3)
90
INTEGER, INTENT(OUT) :: NERR, IERR(*)
REAL*8, INTENT(IN) :: T, P, Z1(*), Z2(*)
REAL*8, INTENT(OUT):: ST, STT, STP, STN1(*), STN2(*)
LOGICAL, INTENT(OUT) :: DER(4)
91
REAL*8, INTENT(OUT) :: DC(NCDIM,*), DCT(NCDIM,*), DCP(NCDIM,*),
+ DCN(NCDIM,NCDIM,*)
LOGICAL, INTENT(IN) :: DER(3)
C Input arguments:
C NCO Number of components in subcomponent list.
C If zero the datum is set for all components.
C IC subcomponent list
C HDATM enthalpy datum (codes in ayjxid.inc)
C JHSCOM zero for compounds at 298.15 K for pg
C JHSELE enthalpy of formation in PG phase 298.15 K, 1 bar
92
C SDATM entropy datum (codes in ayjxid.inc)
C JHSCOM zero for compounds at 298.15 K for pg
C JHSELE entropy of formation in PG phase 298.15 K, 1 bar
C JHSSTD standard entropy at 298.15 K, 1 bar
C
C Output arguments:
C NERR no. errors reported by this routine and lower level routines
C IERR Array of error codes. Values returned by this routine:
C 16921 code for enthalpy datum is not recognised
C 16922 code for entropy datum is not recognised
93
11 Streams
A stream is defined as a collection of components and phase descriptors. Multiflash uses the
concept of a stream when carrying out phase and chemical equilibrium calculations. The
components in a stream may be a subset of all the components defined. The PDs in a stream
define a list of the possible phases that may be present at equilibrium. It is not necessary
to define a stream explicitly in order to use the phase/chemical equilibrium routines. The
default stream identifier of 0 includes all the currently defined PDs and components.
SUBROUTINE AXDFST( NC, IC, NPD, IPD, IST, NERR, MXERR, IERR )
C
C Input arguments:
C NC number of components in stream type
C (-1=use all defined components)
C IC subcomponent list for stream type (array of component
C load numbers). Not used if NC = -1
C NPD number of phase descriptors in stream type
C (-1=use all defined PDs)
C IPD List of phase descriptors in stream type
C MXERR Maximum number of error codes to return in IERR
C
C Output arguments:
C IST Identifier assigned to the defined stream type
C NERR Number of error codes returned in IERR
C IERR Error codes. Values for this routine:
C 20421 Too many components defined in subcomponent list
C 20422 Invalid subcomponent number
C 20423 Repeated subcomponent number
C 20424 Too many phase descriptors defined
C 20425 Invalid phase descriptor load number
C 20426 Repeated phase descriptor load number
C 20427 No free space for any stream descriptor
94
INCLUDE ’axpara.inc’
INTEGER, INTENT(OUT) :: NST, IST(MAXST)
INCLUDE ’aympd.inc’
INCLUDE ’axpara.inc’
INTEGER, INTENT(IN) :: IST, MXERR
INTEGER, INTENT(OUT) :: NC, IC(MAXNCS), NPD, IPD(MAXPD), NERR, IERR(*)
SUBROUTINE AXGTST( IST, NC, IC, NPD, IPD, NERR, MXERR, IERR )
C
C Input arguments:
C IST Stream type identifier
C MXERR Maximum number of error codes to return in IERR
C
C Output arguments:
C NC number of components in stream type
C IC subcomponent list (array of component load numbers)
C for stream type
C NPD number of phase descriptors in stream type
C IPD List of phase descriptors in stream type
C NERR Number of error codes returned in IERR
C IERR Error codes. Values for this routine:
C 20441 IST not a valid stream type identifier
After this call, the stream type referred to by IST is no longer defined.
95
12 Phase equilibrium calculations
12.1 Introduction
The Multiflash phase equilibrium module can handle any number of vapour, liquid, and solid
phases. It performs the full range engineering flash calculations for multiphase situations
including:
• fixed (molar) phase fraction flashes (e.g. dew or bubble points) at defined pressure or
temperature.
In addition, Multiflash offers ‘double’ flashes where two variables are adjusted to match two
constraints and tolerance calculations where a second fluid is added to the feed to match a
constraint.
The solution procedures used in Multiflash are extensions of methods described by Michelsen:
1. Initialise physical properties data system, define databanks and load the components
(section 4).
3. Specify and initialise the set of models that will be available (section 8).
4. Initialise phase descriptor system and set up all the phase descriptors (PDs) which
Multiflash may use (section 9).
5. Initialise the stream type system and the phase equilibrium module by calling AXINIT.
96
6. Set up all the stream types required (section 11).
See section 12.10 for guidelines on setting algorithm parameters to enhance convergence
in difficult regions or to reduce computation time.
Multiflash is designed to work with a subset of the previously defined components and
PDs. These subsets may be specified in the calls to AXFL01 etc. through the stream type
load number.
1. A model may return one or more of the following three classes of properties: fugacity
coefficients; volume; enthalpy and entropy. An enthalpy model must also handle the
entropy.
2. A model may evaluate the temperature, pressure and mole number derivatives of the
property for which it is defined. Finite difference derivatives are not adequate unless
they are indistinguishable from analytic derivatives. Multiflash will operate with or
without property derivatives.
If mole number derivatives of the fugacity coefficients are available, the second order
minimisation method can be used in the isothermal flash. Variable I2ORD, set by calling
AXSE02 controls whether the second order method is used. Most problems can be solved
reliably without use of the second order method. The default behaviour is recomended
as the second order method is only called if needed.
97
3. A model must be able to return properties for a specified phase type or, if the model
can describe more than one phase, for the phase of minimum Gibbs energy. This is
only meaningful for equation-of-state type models. Models which can only represent
one phase type, eg. activity models, should always regard that phase as the one of
minimum Gibbs energy. If a specific phase is requested and the model cannot represent
that phase, it should return an error flag.
4. For models based on equations of state, the phase type returned by the model may be
ambiguous. The model should be able to detect whether this is the case, i.e. whether
a van der Waals loop exists or not, and return a status flag. For non-eos type models
the phase type should always be identified as unambiguous.
5. Every model must be related to a well-defined reference state for the fugacity coef-
ficients and thermal properties. This will usually be the perfect gas state, with the
fugacity coefficients having their conventional interpretation. The model description
must contain enough information to relate the model to the reference state. For exam-
ple, a liquid-phase activity model must have an accompanying equation of state model
that relates the liquid properties to the perfect gas reference state.
6. Multiflash is designed to work with subsets of the total list of components defined to
the property package. To use this feature the models must be able to return properties
for a subset of components. If it is not possible to work on subsets then Multiflash
should always be called with a full component list.
Details of the models routines provided by Infochem are given in section 8.
It is not necessary to set up stream types explicitly if only one stream is to be used. The
default steam type identifier of zero may be used. It includes all components and all PDs
defined. If it is required to use a subcomponent list or a subset of the defined PDs it is
necessary to define suitable suitable stream types explicitly by calling the routines described
in section 11.
98
LOGICAL, INTENT(IN) :: FEST1
99
C values in XX and NMOLPH.
C X If FEST1 is .TRUE. X must be set on entry.
C See below for full description.
C NMOLPH If FEST1 is .TRUE. NMOLPH must be set on entry.
C See below for full description.
C
C Output values:
C NP number of phases at equilibrium or at best estimate of
C solution. When an estimate of the solution is supplied
C some of the input phases may be eliminated.
C LNOPD Array of NP PD load numbers corresponding to output
C values in XX, NMOLPH, ZCOMP and IPHID.
C X X(I,J) holds the mole fraction of component I in phase
C J for J = 1,NP.
C NMOLPH NMOLPH(J) holds the number of moles in phase J for
C J = 1,NP.
C
C Output arguments:
C ZCOMP compressibility factor of each output phase (as
C calculated by the fugacity model, not the volumetric
C model).
C IPHID identity (V,L,..etc) of each output phase. If the
C calculation is successful, the phase id. is set to that
C specified in the phase descriptor definition. Note that
C for supercritical phases described by equations of state,
C the phase label is ambiguous.
C The phase codes used are defined in AYPTID.INC
C ISTABO stability indicator for solution.
C (codes are defined in axjnum.inc)
C JXSTUN definitely unstable. Another phase would be
C formed or an existing phase removed if problem
C specification allowed.
C JXSTMU marginally unstable (see above).
C JXSTIN indeterminate.
C This value is returned if no final stability
C test was requested (ISTABI=JXNOSC) and no
C other error condition was detected.
C If ISTABI=JXDOSC it means that the solution is
C on the stability limit.
C JXSTMS marginally stable.
C JXSTST definitely stable.
C NERR no. errors reported by this routine and sub-routines
C IERR error codes returned. Values for this routine:
C -20001 unstable solution returned.
C Phase split converged but solution is not stable.
C All specified phase descriptors have been used up
C or the maximum number of phases has been reached
C so no further phase split can be done.
C -20002 more phases found than requested. Best solution
C with NPD phases returned (unstable).
C -20003 unstable solution returned.
C Cannot allocate PDs to the phase distribution.
C i.e. the actual phase split cannot be described by
C the specified phase types.
C Values returned correspond to the last phase split
C with an acceptable set of phases but this phase
C distribution is unstable.
100
C -20004 phase split converged to low accuracy
C -20005 cannot allocate PDs to the phase distribution
C i.e. the actual phase split cannot be described by
C the specified phase types.
C 20001 illegal input specification negative or zero
C P or T
C 20002 illegal input specification reported by startup
C routine. Negative or zero:
C number of moles of feed; feed mole
C fractions; number of phase descriptors;
C phase descriptors wrongly specified in input or
C wrongly set up prior to calling AXFL01.
C 20003 fatal error finding most stable single phase.
C 20004 fatal error in stability analysis
C 20005 PD identifier has unacceptable value
C 20006 fatal error in phase split calculation.
C 20007 reached maximum number of cycles of stability
C analysis/phase split
101
where N feed is the sum of nfeed
i . If mole fractions are passed in, N2 in equation 2 is the
amount of the second fluid to add per mole feed.
Only certain combinations of specifications handled by AXFL02 lead to a phase equilibrium
problem that has a unique solution. These combinations are: p, H; p, S and V, T . The
remaining specifications may have more than one solution or no solution.
One of the most common applications for AXFL02 is to calculate the dew point or bubble
point of a mixture. For multi-phase systems the best way to specify a dew point calculation
is to set phase fraction of the vapour phase PD to 1.0 . This specification identifies the
primary dew point. To find the dew point of a specific liquid phase, e.g. the water dew point,
the target phase fraction of the PD corresponding to an aqueous phase should be set to 0.0
. For a bubble point calculation the target fraction of the gas phase PD should be set to
0.0. Note that there may not be any solution or multiple solutions corresponding to these
specifications.
In addition, AXFL02 can be called at fixed temperature and pressure to return the deviation
index. The deviation index is a smoothly varying function that shows how far the constrained
equilibrium is from satisfying the constraint at the defined pressure or temperature. If the
contraint is satisfied, the deviation index is zero. (The search procedures in AXFL02 operate
by adjusting either temperature, pressure or amount of second fluid until the deviation index
is zero.)
The calling specification for AXFL02 is:
102
C type (NPD) and MAXPHA (the maximum number of coexisting
C phases for which AXFL02 is set up). The parameter MAXPHA
C is defined in the file axpara.inc. If NPHMAX is outside
C the range 1 to MAXPHA it is equivalent to setting it to
C MAXPHA.
C The arrays LNOPD, X, NMOLPH, ZCOMP and IPHID must be
C dimensioned to at least MIN( NPHMAX, NPD, MAXPHA ) in
C the calling routine.
C IPROB identifer for type of calculation required
C IPROB(1) = problem type
C (codes are defined in axjnum.inc)
C JXENTH total enthalpy (J)
C JXENTR total entropy (J K-1)
C JXVOL total volume (m3)
C JXINTE total internal energy (J)
C JXPHML phase molar fraction
C JXPHMS phase mass fraction
C JXPHVL phase volume fraction
C JXNUCL phase nucleation
C IPROB(2) = fixed phase load number if phase fraction problem
C IPROB(3) = upper/lower phase fraction search
C (codes are defined in axjnum.inc)
C JSNL lower normal solution
C JSRU upper retrograde solution
C JSNU upper normal solution
C JSRL lower retrograde solution
C JSANY any solution
C JSDEF default normal solution
C
C The normal settings for dew/bubble points are:
C Search for setting
C Normal dew point T upper
C P lower
C
C Retrograde dew point T lower
C P upper
C
C Normal bubble point T lower
C P upper
C
C Retrograde bubble point T upper
C P lower
C
C For phase fractions between 0 and 1 the best setting
C depends on the shape of the phase diagram.
C
C It is important to specify the correct search code
C because the value of IPROB(3) is used as a guide, both to
C generate initial estimates of T or P, and also to decide
C on a search direction towards the required solution.
C Particularly for difficult calculations, the user needs
C to have an idea of the layout of the phase diagram.
C Note that the JSANY specification is less reliable than
C any of the others because the routine has no guidance
C about where to look for a solution.
C TARGET function values to be matched
C FEST1 first estimates of the phase fractions and compositions
103
C at the solution must be supplied if FEST1 is .TRUE.
C If FEST1 is .FALSE. the initial phase distribution
C is obtained from a stability analysis using the
C phase descriptors specified in the stream type.
C FEST2 first estimates of the variable (temperature, pressure or
C tolerance ratio ) at the solution must be supplied if FEST2
C is .TRUE. If FEST2 is .FALSE. the initial value of T or P
C is obtained using an internal procedure.
C ISTABI controls whether a stability test is done on a final
C solution that contains all PDs in the stream type.
C Omitting the stability test saves time but an
C erroneous solution may be returned.
C (codes are defined in axjnum.inc)
C JXNOSC no final stability check
C JXDOSC do final stability check
C NPRINT diagnostic output flag.
C -1 no output
C 0 minimum output in case of serious errors
C 1 errors and serious warnings
C 2 warnings plus above
C 3 informative messages plus above
C MXERR maximum number of error codes to be returned in IERR
C
C Input/output arguments:
C Input values:
C T if IVAR=JXPRES or JXTOL, temperature (K),
C if IVAR=JXTEMP and FEST2=TRUE, estimated temperature (K),
C else not defined
C P if IVAR=JXTEMP or JXTOL, pressure (Pa),
C if IVAR=JXPRES and FEST2=TRUE, estimated pressure (Pa),
C else not defined
C VAR If IVAR=JXTOL and FEST2=TRUE, estimated tolerance
C variable else not defined
C NP If FEST1 is .TRUE. NP must be set to the number of
C phases present at the estimate of the solution supplied
C in LNOPD, XX and NMOLPH.
C LNOPD If FEST1 is .TRUE. LNOPD must be set on entry.
C Array of NP PD load numbers corresponding to input
C values in XX and NMOLPH.
C XX If FEST1 is .TRUE. XX must be set on entry.
C See below for full description.
C NMOLPH If FEST1 is .TRUE. NMOLPH must be set on entry.
C See below for full description.
C
C Output values:
C T Temperature (K)
C P Pressure (Pa)
C VAR Tolerance variable, if IVAR=JXTOL,
C deviation index, if IVAR=JXDVIX.
C NP number of phases at equilibrium or at best estimate of
C solution. When an estimate of the solution is supplied
C some of the input phases may be eliminated.
C LNOPD Array of NP PD load numbers corresponding to output
C values in XX, NMOLPH, ZCOMP and IPHID.
C XX XX(I,J) holds the mole fraction of component I in phase
C J for J = 1,NP.
C NMOLPH NMOLPH(J) holds the number of moles in phase J for
104
C J = 1,NP. A zero value will be returned for phases at a
C saturation point (eg. a dew point or bubble point).
C
C Output arguments:
C ZCOMP compressibility factor of each output phase (as
C calculated by the fugacity model, not the volumetric
C model).
C IPHID identity (V,L,..etc) of each output phase. If the
C calculation is successful, the phase id. is set to that
C specified in the phase descriptor definition. Note that
C for supercritical phases described by equations of state,
C the phase label is ambiguous.
C The phase codes used are defined in AYPTID.INC
C ISTABO stability indicator for solution.
C (codes are defined in axjnum.inc)
C JXSTUN definitely unstable. Another phase would be
C formed or an existing phase removed if problem
C specification allowed.
C JXSTMU marginally unstable (see above).
C JXSTIN indeterminate.
C This value is returned if no final stability
C test was requested (ISTABI=JXNOSC) and no
C other error condition was detected.
C If ISTABI=JXDOSC it means that the solution is
C on the stability limit.
C JXSTMS marginally stable.
C JXSTST definitely stable.
C NERR no. errors reported by this routine and sub-routines
C IERR error codes returned. Values for this routine:
C -20021 unstable solution returned.
C Phase split converged but solution is not stable.
C All specified phase descriptors have been used up
C or the maximum number of phases has been reached
C so no further phase split can be done.
C -20022 phase split converged to low accuracy
C -20023 other warning
C 20021 condition to match IPROB(1) is not correctly specified
C 20022 illegal input specification reported by startup
C routine. Negative or zero:
C number of moles of feed; feed mole
C fractions; number of phase descriptors;
C phase descriptors wrongly specified in input or
C wrongly set up prior to calling AXFL02.
C 20023 inconsistent user-supplied estimates.
C Number of input phases NP does not agree
C with flags for phases present in LNOPD
C or initial number of phases NP is greater than
C number of available phase descriptors NPD.
C 20024 cannot find starting point for calculation - this
C may mean there is no solution.
C 20025 PD identifier has unacceptable value
C 20026 cannot converge temperature or pressure search
C 20027 not enough phase descriptors to solve problem.
C Calculation abandoned.
C 20028 other fatal error
C 20029 input pressure not in acceptable range
C 20030 input temperature not in acceptable range
105
C 20031 variable to search for (IVAR) is not correctly specified
C 20032 input volume not in acceptable range
C 20033 inconsistent user-supplied estimates.
C An input phase has a value in LNOPD which does
C not correspond to any of the current PDs.
106
! MAXPHA.
! The arrays LNOPD, X, NMOLPH, ZCOMP and IPHID must be
! dimensioned to at least MIN( NPHMAX, NPD, MAXPHA ) in
! the calling routine.
! Fest1 first estimates of the phase fractions and compositions
! at the solution must be supplied if FEST1 is .TRUE.
! If FEST1 is .FALSE. the initial phase distribution
! is obtained from a stability analysis using the
! phase descriptors specified in the stream type.
! Fest2 first estimates of the variable (temperature, pressure or
! tolerance ratio ) at the solution must be supplied if FEST2
! is .TRUE. If FEST2 is .FALSE. the initial value of T or P
! is obtained using an internal procedure.
! Istabi controls whether a stability test is done on a final
! solution that contains all PDs in the stream type.
! Omitting the stability test saves time but an
! erroneous solution may be returned.
! (codes are defined in axjnum.inc)
! JXNOSC no final stability check
! JXDOSC do final stability check
! Nprint diagnostic output flag.
! -1 no output
! 0 minimum output in case of serious errors
! 1 errors and serious warnings
! 2 warnings plus above
! 3 informative messages plus above
! Mxerr maximum number of error codes to be returned in IERR
!
! Input/output arguments:
! Input values:
! T if IVAR=JXPRES, temperature (K),
! if IVAR=JXTEMP and FEST2=TRUE, estimated temperature (K),
! else not defined
! P if IVAR=JXTEMP, pressure (Pa),
! if IVAR=JXPRES and FEST2=TRUE, estimated pressure (Pa),
! else not defined
! Np If FEST1 is .TRUE. NP must be set to the number of
! phases present at the estimate of the solution supplied
! in LNOPD, XX and NMOLPH.
! Lnopd If FEST1 is .TRUE. LNOPD must be set on entry.
! Array of NP PD load numbers corresponding to input
! values in XX and NMOLPH.
! Xx If FEST1 is .TRUE. XX must be set on entry.
! See below for full description.
! Nmolph If FEST1 is .TRUE. NMOLPH must be set on entry.
! See below for full description.
!
! Output values:
! T Temperature (K)
! P Pressure (Pa)
! Np number of phases at equilibrium or at best estimate of
! solution. When an estimate of the solution is supplied
! some of the input phases may be eliminated.
! Lnopd Array of NP PD load numbers corresponding to output
! values in XX, NMOLPH, ZCOMP and IPHID.
! Xx XX(I,J) holds the mole fraction of component I in phase
! J for J = 1,NP.
107
! Nmolph NMOLPH(J) holds the number of moles in phase J for
! J = 1,NP. A zero value will be returned for phases at a
! saturation point (eg. a dew point or bubble point).
!
! Output arguments:
! Zcomp compressibility factor of each output phase (as
! calculated by the fugacity model, not the volumetric
! model).
! Iphid identity (V,L,..etc) of each output phase. If the
! calculation is successful, the phase id. is set to that
! specified in the phase descriptor definition. Note that
! for supercritical phases described by equations of state,
! the phase label is ambiguous.
! The phase codes used are defined in AYPTID.INC
! Lnbest The load number of the most satble hydrate phase
! Istabo stability indicator for solution.
! (codes are defined in axjnum.inc)
! JXSTUN definitely unstable. Another phase would be
! formed or an existing phase removed if problem
! specification allowed.
! JXSTMU marginally unstable (see above).
! JXSTIN indeterminate.
! This value is returned if no final stability
! test was requested (ISTABI=JXNOSC) and no
! other error condition was detected.
! If ISTABI=JXDOSC it means that the solution is
! on the stability limit.
! JXSTMS marginally stable.
! JXSTST definitely stable.
! Nerr no. errors reported by this routine and sub-routines.
! Ierr error codes returned.
! 21071: Number of phase descriptors in unsufficient to continue
! 21072: No hydrate phase descriptors found.
! 21073: The calculation of the more stable hydrate phase has failed.
! 21074: A stable hydrate phase was not found.
! 21075: Invalid temperature input.
! 21076: Invalid pressure input.
! 21077: Water not present or amount not defined.
! 21078: Invalid specification for the flash routine.
1. Total enthalpy H
2. Total entropy S
3. Total volume V
108
7. Cricondentherm/cricondenbar
The fluid fractions for tolerance calculations are defined as previously. It is possible for both
constraints to be phase fractions but in this case the phase fractions must be fixed for two
different phases for which phase descriptors are included in the stream type passed to AXFL04.
On convergence, the pressure, temperature and fluid fraction are returned together with the
amounts and compositions of the phases present at equilibrium.
Only certain combinations of specifications handled by AXFL04 lead to a phase equilibrium
problem that has a unique solution. These combinations are: U, V ; S, V ; U, S and H, S.
The remaining specifications may have more than one solution or no solution. The calling
specification for AXFL04 is:
109
C (codes are defined in axjnum.inc)
C JXENTH total enthalpy (J)
C JXENTR total entropy (J K-1)
C JXVOL total volume (m3)
C JXINTE total internal energy (J)
C JXPHML phase molar fraction
C JXPHMS phase mass fraction
C JXPHVL phase volume fraction
C JXNUCL phase nucleation
C JXCCTH cricondentherm
C JXCCBA cricondenbar
C IPROB1(2) = fixed phase load number if phase fraction problem
C IPROB1(3) = upper/lower phase fraction search
C (codes are defined in axjnum.inc)
C JSNL lower normal solution
C JSRU upper retrograde solution
C JSNU upper normal solution
C JSRL lower retrograde solution
C JSANY any solution
C JSDEF default normal solution
C
C The normal settings for dew/bubble points are:
C Search for setting
C Normal dew point T upper
C P lower
C
C Retrograde dew point T lower
C P upper
C
C Normal bubble point T lower
C P upper
C
C Retrograde bubble point T upper
C P lower
C
C For phase fractions between 0 and 1 the best setting
C depends on the shape of the phase diagram.
C
C It is important to specify the correct search code
C because the value of IPROB1(3) is used as a guide, both to
C generate initial estimates of T or P, and also to decide
C on a search direction towards the required solution.
C Particularly for difficult calculations, the user needs
C to have an idea of the layout of the phase diagram.
C Note that the JSANY specification is less reliable than
C any of the others because the routine has no guidance
C about where to look for a solution.
C IPROB2 identifer for type of calculation required for inner loop
C (codes as for IPROB1)
C TARG1 function values to be matched (depends on IPROB1) in outer loop
C TARG2 function values to be matched (depends on IPROB2) in inner loop
C FEST1 first estimates of the phase fractions and compositions
C at the solution must be supplied if FEST1 is .TRUE.
C If FEST1 is .FALSE. the initial phase distribution
C is obtained from a stability analysis using the
C phase descriptors specified in the stream type.
C FEST2 first estimates of the temperature and pressure
110
C at the solution must be supplied if FEST2 is .TRUE.
C If FEST2 is .FALSE. the initial value of T and P
C are obtained using an internal procedure.
C ISTABI controls whether a stability test is done on a final
C solution that contains all PDs in the stream type.
C Omitting the stability test saves time but an
C erroneous solution may be returned.
C (codes are defined in axjnum.inc)
C JXNOSC no final stability check
C JXDOSC do final stability check
C NPRINT diagnostic output flag.
C -1 no output
C 0 minimum output in case of serious errors
C 1 errors and serious warnings
C 2 warnings plus above
C 3 informative messages plus above
C MXERR maximum number of error codes to be returned in IERR
C
C Input/output arguments:
C Input values:
C T If FEST2=TRUE, estimated temperature (K), else not
C defined
C P If FEST2=TRUE, estimated pressure (Pa), else not defined
C TOLIN If IVAR1=JXTOL or IVAR2=JXTOL and FEST2=TRUE, estimated
C tolerance variable, else not defined
C NP If FEST1 is .TRUE. NP must be set to the number of
C phases present at the estimate of the solution supplied
C in LNOPD, XX and NMOLPH.
C LNOPD If FEST1 is .TRUE. LNOPD must be set on entry.
C Array of NP PD load numbers corresponding to input
C values in XX and NMOLPH.
C XX If FEST1 is .TRUE. XX must be set on entry.
C See below for full description.
C NMOLPH If FEST1 is .TRUE. NMOLPH must be set on entry.
C See below for full description.
C
C Output values:
C T Temperature (K)
C P Pressure (Pa)
C TOLIN Tolerance variable, if IVAR1=JXTOL or IVAR2=JXTOL
C NP number of phases at equilibrium or at best estimate of
C solution. When an estimate of the solution is supplied
C some of the input phases may be eliminated.
C LNOPD Array of NP PD load numbers corresponding to output
C values in XX, NMOLPH, ZCOMP and IPHID.
C XX XX(I,J) holds the mole fraction of component I in phase
C J for J = 1,NP.
C NMOLPH NMOLPH(J) holds the number of moles in phase J for
C J = 1,NP. A zero value will be returned for phases at a
C saturation point (eg. a dew point or bubble point).
C
C Output arguments:
C ZCOMP compressibility factor of each output phase (as
C calculated by the fugacity model, not the volumetric
C model).
C IPHID identity (V,L,..etc) of each output phase. If the
C calculation is successful, the phase id. is set to that
111
C specified in the phase descriptor definition. Note that
C for supercritical phases described by equations of state,
C the phase label is ambiguous.
C The phase codes used are defined in AYPTID.INC
C ISTABO stability indicator for solution.
C (codes are defined in axjnum.inc)
C JXSTUN definitely unstable. Another phase would be
C formed or an existing phase removed if problem
C specification allowed.
C JXSTMU marginally unstable (see above).
C JXSTIN indeterminate.
C This value is returned if no final stability
C test was requested (ISTABI=JXNOSC) and no
C other error condition was detected.
C If ISTABI=JXDOSC it means that the solution is
C on the stability limit.
C JXSTMS marginally stable.
C JXSTST definitely stable.
C NERR no. errors reported by this routine and sub-routines
C IERR error codes returned. Values for this routine:
C -20041 unstable solution returned.
C Phase split converged but solution is not stable.
C All specified phase descriptors have been used up
C or the maximum number of phases has been reached
C so no further phase split can be done.
C -20043 other warning
C 20041 conditions to match (IPROB1/2) not correctly specified
C 20042 illegal input specification reported by startup
C routine. Negative or zero:
C number of moles of feed; feed mole
C fractions; number of phase descriptors;
C phase descriptors wrongly specified in input or
C wrongly set up prior to calling AXFL02.
C 20043 inconsistent user-supplied estimates.
C Number of input phases NP does not agree
C with flags for phases present in LNOPD
C or initial number of phases NP is greater than
C number of available phase descriptors NPD.
C 20045 PD identifier has unacceptable value
C 20046 cannot converge temperature or pressure search
C 20047 Same variable specified twice
C 20048 Same constraint specified twice
C 20049 other serious error
C 20050 variables to search for (IVAR1/2) not correctly specified
C 20051 input pressure not in acceptable range
C 20052 input temperature not in acceptable range
C 20053 input volume not in acceptable range
C 20054 inconsistent user-supplied estimates.
C An input phase has a value in LNOPD which does
C not correspond to any of the current PDs.
112
Gibbs energy, in which case the original mixture is unstable, or increase the Gibbs energy
which indicates that the mixture is stable. The Gibbs energy stability indicator for each
incipient phase is returned in array GSTB. The calling specification is:
113
C Output values:
C ALLTP if the input value was F, ALLTP will be reset to T if
C NP=NPD or the PD specification is such that that all
C possible TPs were used in the stability test.
C (See AXSTPC).
C XIP XIP(I,K) holds the composition (mole fraction) of
C component I in the Kth incipient phase
C
C Output arguments:
C IPD0 phase descriptor for test mixture in most stable phase
C (set if FEST is FALSE)
C IPHID0 identity (V,L,..etc) of most stable phase
C ZCOMP0 compressibility factor for test mixture in most stable
C phase
C NIP number of incipient phases found. NIP <= MAXIP.
C (set if FEST is FALSE)
C IPDIP phase descriptor for each incipient phase.
C (set if FEST is FALSE)
C GSTB stability indicator for each incipient phase.
C Modified tangent plane distance (g* in eq. 14) for
C each phase returned by stability test arranged in
C order of increasing g*.
C A negative g* shows the phase can decrease the GE,
C i.e. system is unstable. A zero g* shows the phase is
C in equilibrium with existing phases. A positive g*
C shows the system is stable but the phase composition
C is an indication of the composition of an incipient
C phase which may form at a different T or P.
C ZCOMP compressibility factor of each incipient phase.
C IPHID identity (V,L,..etc) of each incipient phase.
C The phase id. is set to that specified in the phase
C descriptor definition. Note that for supercritical
C phases described by equations of state, the phase label
C is ambiguous.
C The phase codes used are defined in AYPTID.INC
C ISTABO stability indicator for solution.
C (codes are defined in axjnum.inc)
C JXSTUN definitely unstable. Another phase would be
C formed or an existing phase removed if problem
C specification allowed.
C JXSTMU marginally unstable (see above).
C JXSTIN indeterminate.
C This value is returned if no final stability
C test was requested (ISTABI=JXNOSC) and no
C other error condition was detected.
C If ISTABI=JXDOSC it means that the solution is
C on the stability limit.
C JXSTMS marginally stable.
C JXSTST definitely stable.
C NERR no. errors reported by this routine and sub-routines
C IERR error codes returned. Values for this routine:
C 20061 bad input specification: negative or zero
C P or T
C 20062 bad input specification reported by startup
C routine. Negative or zero:
C number of moles of feed; feed mole
C fractions; number of phase descriptors;
114
C phase descriptors wrongly specified in input or
C wrongly set up prior to calling AXST01.
C 20063 fatal error getting properties of reference phase
C 20064 fatal error in stability analysis
C 20065 bad input specification of phase descriptor for
C reference phase (negative, exceeds MAXPD or not
C in input list of PDs)
Notes:
ITMX0 Default is 60, should not normally be changed unless second-order method is disabled.
EEPS0 Default is 10−16 . A larger value e.g. (10−12 ) may reduce calculation time but it is
possible that flashes in the critical region may not be adequately converged. If EEPS0
is set to a value greater than the default, the convergence of the temperature/pressure
search flashes (AXFL02 and AXFL04) could be impaired because the low-level calls to
the T, P flash may return noisy values. The convergence parameters for the temper-
ature/pressure searches should therefore be set to the lower-accuracy values recom-
mended for AXSE04.
115
INTEGER, INTENT(IN) :: ITMX0
REAL*8, INTENT(IN) :: EEPS0, XXTRA
LOGICAL, INTENT(IN) :: I2OR0
Notes:
Notes:
ITMX0 Default is 100, may be reduced to 20 in most cases but extra phases in the near-critical
region may be missed.
116
EEPS0 Default is 10−9 , should not normally be changed.
ITP The default value is ITP=0, i.e. the most exhaustive search. For oil/gas/water systems
ITP=6 is much faster and quite reliable.
Notes:
EPSS Default is 10−5 J K−1 , may often be increased safely to 10−3 J K−1 .
It is recommended that the lower-accuracy values are used if the parameter EEPS0 in
AXSE01 or AXSE02 is set to a value greater than the default.
117
13 Flash sensitivity calculations
The routines described in this section return the (analytical) derivatives of output quantities
in flash calculations with respect to the specified conditions (such as temperature, pressure
and feed composition) whilst keeping the phases at equilibrium. Note that to operate correctly,
the equilibrium values returned by the flash routines must be passed unaltered into the
sensitivity routines.
118
C PHFN Partial derivative of phase amount PHF(J) w.r.t.
C feed composition
C V Total and phase volumes (index=0 denotes total)
C VT Partial derivative of volume V w.r.t. T
C VP Partial derivative of volume V w.r.t. P
C VN Partial derivative of volume V w.r.t. feed composition
C H Total and phase enthalpies (index=0 denotes total)
C HT Partial derivative of enthalpy H w.r.t. T
C HP Partial derivative of enthalpy H w.r.t. P
C HN Partial derivative of enthalpy H w.r.t. feed composition
C S Total and phase entropies (index=0 denotes total)
C ST Partial derivative of entropy S w.r.t. T
C SP Partial derivative of entropy S w.r.t. P
C SN Partial derivative of entropy S w.r.t. feed composition
C NERR no. errors reported by this routine and sub-routines
C IERR error codes returned. Values for this routine:
C 20151 error reported by startup routine AXSTRT
C 20153 cannot evaluate fugacity and derivatives
C 20154 cannot solve for derivatives
C 20155 cannot solve for mole number derivatives
2. Total entropy S
3. Total volume V
119
C IVAR code denoting variable to search for:
C (codes are defined in axjnum.inc)
C JXTEMP temperature (constraint 2 = pressure)
C JXPRES pressure (constraint 2 = temperature)
C IPROB identifer for type of calculation required
C IPROB(1) problem type (= constraint 1)
C JXENTH total enthalpy (J)
C JXENTR total entropy (J K-1)
C JXVOL total volume (m3)
C JXINTE total internal energy (J)
C JXPHML phase molar fraction
C JXPHMS phase mass fraction
C JXPHVL phase volume fraction
C (codes are defined in axjnum.inc)
C IPROB(2) fixed phase load number if phase fraction problem
C D Derivative flags:
C D(1) .TRUE. return derivatives w.r.t. constraint 1,
C otherwise not
C D(2) .TRUE. return P derivatives w.r.t. constraint 2,
C otherwise not
C D(3) .TRUE. return mole number derivatives, otherwise not
C T Temperature (K)
C P Pressure (Pa)
C NCDIM dimensioning parameter for arrays X, X1, X2, XN and PHFN as
C declared in calling routine. NCDIM must be greater than or
C equal to the number of components for the stream type.
C NMOLIN Number of moles of each component in the feed
C X X(I,J) holds the composition (mole fraction) of
C component I in phase J.
C NP Number of phases in equilibrium
C PHF Number of moles of each phase
C LNOPD Array of NP PD load numbers corresponding to values
C in X and PHF
C RETV .TRUE. if volumes and their derivatives are to be returned,
C otherwise .FALSE.
C RETH .TRUE. if enthalpies and entropies and their derivatives are
C to be returned, otherwise .FALSE.
C MXERR maximum number of error flags to be returned in IERR
C
C Output arguments:
C T1 Partial derivative of temperature T w.r.t. constraint 1
C T2 Partial derivative of temperature T w.r.t. constraint 2
C TN Partial derivative of temperature T w.r.t. feed composition
C P1 Partial derivative of pressure P w.r.t. constraint 1
C P2 Partial derivative of pressure P w.r.t. constraint 2
C PN Partial derivative of pressure P w.r.t. feed composition
C X1 Partial derivative of mole fraction X(I,J) w.r.t. constraint 1
C X2 Partial derivative of mole fraction X(I,J) w.r.t. constraint 2
C XN Partial derivative of mole fraction X(I,J) w.r.t.
C feed composition
C PHF1 Partial derivative of phase amount PHF(J) w.r.t. constraint 1
C PHF2 Partial derivative of phase amount PHF(J) w.r.t. constraint 2
C PHFN Partial derivative of phase amount PHF(J) w.r.t.
C feed composition
C V Total and phase volumes (index=0 denotes total)
C V1 Partial derivative of volume V w.r.t. constraint 1
C V2 Partial derivative of volume V w.r.t. constraint 2
120
C VN Partial derivative of volume V w.r.t. feed composition
C H Total and phase enthalpies (index=0 denotes total)
C H1 Partial derivative of enthalpy H w.r.t. constraint 1
C H2 Partial derivative of enthalpy H w.r.t. constraint 2
C HN Partial derivative of enthalpy H w.r.t. feed composition
C S Total and phase entropies (index=0 denotes total)
C S1 Partial derivative of entropy S w.r.t. constraint 1
C S2 Partial derivative of entropy S w.r.t. constraint 2
C SN Partial derivative of entropy S w.r.t. feed composition
C NERR no. errors reported by this routine and sub-routines
C IERR error codes returned. Values for this routine:
C 20161 error reported by startup routine AXSTRT
C 20162 unacceptable variable type
C 20163 cannot evaluate fugacity and derivatives
C 20164 cannot solve for derivatives
C 20165 cannot solve for T and mole number derivatives
C 20166 unacceptable problem specification
C 20167 fixed phase fraction flash cannot be single phase
2. Total entropy S
3. Total volume V
121
C JXENTH total enthalpy (J)
C JXENTR total entropy (J K-1)
C JXVOL total volume (m3)
C JXINTE total internal energy (J)
C JXPHML phase molar fraction
C JXPHMS phase mass fraction
C JXPHVL phase volume fraction
C (codes are defined in axjnum.inc)
C IPROB1(2) fixed phase load number if phase fraction problem
C IPROB2 identifer for type of calculation required (constraint 2)
C (Codes as for IPROB1)
C D Derivative flags:
C D(1) .TRUE. return derivatives w.r.t. constraint 1,
C otherwise not
C D(2) .TRUE. return P derivatives w.r.t. constraint 2,
C otherwise not
C D(3) .TRUE. return mole number derivatives, otherwise not
C T Temperature (K)
C P Pressure (Pa)
C NCDIM dimensioning parameter for arrays X, X1, X2, XN and PHFN as
C declared in calling routine. NCDIM must be greater than or
C equal to the number of components for the stream type.
C NMOLIN Number of moles of each component in the feed
C X X(I,J) holds the composition (mole fraction) of
C component I in phase J.
C NP Number of phases in equilibrium
C PHF Number of moles of each phase
C LNOPD Array of NP PD load numbers corresponding to values
C in X and PHF
C RETV .TRUE. if volumes and their derivatives are to be returned,
C otherwise .FALSE.
C RETH .TRUE. if enthalpies and entropies and their derivatives are
C to be returned, otherwise .FALSE.
C MXERR maximum number of error flags to be returned in IERR
C
C Output arguments:
C T1 Partial derivative of temperature T w.r.t. constraint 1
C T2 Partial derivative of temperature T w.r.t. constraint 2
C TN Partial derivative of temperature T w.r.t. feed composition
C P1 Partial derivative of pressure P w.r.t. constraint 1
C P2 Partial derivative of pressure P w.r.t. constraint 2
C PN Partial derivative of pressure P w.r.t. feed composition
C X1 Partial derivative of mole fraction X(I,J) w.r.t. constraint 1
C X2 Partial derivative of mole fraction X(I,J) w.r.t. constraint 2
C XN Partial derivative of mole fraction X(I,J) w.r.t.
C feed composition
C PHF1 Partial derivative of phase amount PHF(J) w.r.t. constraint 1
C PHF2 Partial derivative of phase amount PHF(J) w.r.t. constraint 2
C PHFN Partial derivative of phase amount PHF(J) w.r.t.
C feed composition
C V Total and phase volumes (index=0 denotes total)
C V1 Partial derivative of volume V w.r.t. constraint 1
C V2 Partial derivative of volume V w.r.t. constraint 2
C VN Partial derivative of volume V w.r.t. feed composition
C H Total and phase enthalpies (index=0 denotes total)
C H1 Partial derivative of enthalpy H w.r.t. constraint 1
C H2 Partial derivative of enthalpy H w.r.t. constraint 2
122
C HN Partial derivative of enthalpy H w.r.t. feed composition
C S Total and phase entropies (index=0 denotes total)
C S1 Partial derivative of entropy S w.r.t. constraint 1
C S2 Partial derivative of entropy S w.r.t. constraint 2
C SN Partial derivative of entropy S w.r.t. feed composition
C NERR no. errors reported by this routine and sub-routines
C IERR error codes returned. Values for this routine:
C 20511 error reported by startup routine AXSTRT
C 20513 cannot evaluate fugacity and derivatives
C 20514 cannot solve for derivatives
C 20515 cannot solve for T and mole number derivatives
C 20516 unacceptable problem specification
C 20517 fixed phase fraction flash cannot be single phase
123
14 Phase envelope calculations
14.1 Introduction
The Multiflash phase envelope routines are designed for tracing lines of constant phase frac-
tion, enthalpy, entropy, internal energy or volume for multiphase systems in the pressure-
temperature plane.
There are two subroutines, AXPT01 and AXPT02 which are called as follows. To trace a
particular iso-property line an initial flash calculation must be done by calling AXPT01 at a
defined pressure or temperature. The line is then traced by repeated calls of AXPT02. On
each call, the pressure and temperature returned by AXPT02 is automatically incremented
by a small amount. Calling AXPT02 should continue until either it returns in an error state
indicating that it is impossible to trace the iso-property line further, or else if the pressure or
temperature has reached some high or low value beyond which one does not wish to proceed.
Once a line has been traced, the results can be plotted with a suitable graphics facility, if
required. A new iso-property line can then be traced by calling AXPT01 again with a different
specification followed by repeated calls of AXPT02. Likewise, a new fluid can be introduced
by again calling AXPT01 followed by repeated calls of AXPT02.
Before any of the phase envelope routines are called, Multiflash must be initialised as
described in section 12.4. The phase envelope routines may be called interchangeably with
the Multiflash flash routines AXFL01, AXFL02 and AXFL04.
INTEGER, INTENT(IN) :: LNOST, IVAR, IPRBIN(3), ISTABI, NPHMAX, NCDIM, NPRINT, MXERR
INTEGER, INTENT(INOUT) :: NPOUT, LNOPD(*)
INTEGER, INTENT(OUT) :: ISTABO, IPHOUT(*), NERR, IERR(*)
REAL*8, INTENT(IN) :: NMOLIN(*), TARGIN
REAL*8, INTENT(INOUT) :: T, P, XX(NCDIM,*), NMOLPH(*)
REAL*8, INTENT(OUT) :: VV, HH, SS, ZCOUT(*)
LOGICAL, INTENT(IN) :: UP, FEST1, FEST2
124
C that may actually be returned by AXPT01 is the minimum
C of NPHMAX, NPD (the number of phases in the stream type
C and MAXPHA (the maximum number of coexisting phases for
C the phase equilibrium module). The parameter MAXPHA is
C defined in the file AXPARA.INC. If NPHMAX is outside the
C range 1 to MAXPHA it is equivalent to setting it to MAXPHA.
C The arrays LNOPD, X, NMOLPH, ZCOMP and IPHID must be
C dimensioned to at least MIN( NPHMAX, NPD, MAXPHA ) in
C the calling routine.
C IPRBIN identifer for type of calculation required
C (codes are defined in axjnum.inc)
C IPRBIN(1) = problem type
C JXENTH total enthalpy (J)
C JXENTR total entropy (J K-1)
C JXVOL total volume (m3)
C JXINTE total internal energy (J)
C JXNUCL nucleation current
C JXPHML phase molar fraction
C JXPHMS phase mass fraction
C JXPHVL phase volume fraction
C IPRBIN(2) = fixed phase load number if phase fraction problem
C IPRBIN(3) = upper/lower phase fraction search
C JSNL lower normal solution
C JSRU upper retrograde solution
C JSNU upper normal solution
C JSRL lower retrograde solution
C JSANY any solution
C JSDEF default normal solution
C
C The normal settings for dew/bubble points are:
C Search for setting
C Normal dew point T upper
C P lower
C
C Retrograde dew point T lower
C P upper
C
C Normal bubble point T lower
C P upper
C
C Retrograde bubble point T upper
C P lower
C
C For phase fractions between 0 and 1 the best setting
C depends on the shape of the phase diagram.
C
C It is important to specify the correct search code
C because the value of IPROB(3) is used as a guide, both to
C generate initial estimates of T or P, and also to decide
C on a search direction towards the required solution.
C Particularly for difficult calculations, the user needs
C to have an idea of the layout of the phase diagram.
C Note that the JSANY specification is less reliable than
C any of the others because the routine has no guidance
C about where to look for a solution.
C TARGIN Function values to be matched
C FEST1 First estimates of the phase fractions and compositions
125
C at the solution must be supplied if FEST1 is TRUE.
C If FEST1 is FALSE the initial phase distribution
C is obtained from a stability analysis using the
C phase descriptors specified in the stream type.
C FEST2 First estimates of the variable (temperature, pressure or
C tolerance ratio ) at the solution must be supplied if FEST2
C is TRUE. If FEST2 is FALSE the initial value of T or P
C is obtained using an internal procedure.
C ISTABI Controls whether a stability test is done on the final
C solution which matches the specifications in NPD and
C IPD. Omitting the stability test saves time but an
C erroneous solution may be returned.
C JXNOSC = no final stability check
C JXDOSC = do final stability check
C NPRINT Parameter for diagnostics output:
C = -1 none
C = 0 none unless serious error
C > 0 diagnostics, increasing as NPRINT increased
C MXERR maximum number of error flags to be returned in IERR
C
C Input/output arguments:
C Input values:
C T If IVAR=JXTEMP, temperature (K).
C If IVAR=JXPRES and FEST2=TRUE, estimated temperature (K),
C else not defined
C P If IVAR=JXPRES, pressure (Pa).
C If IVAR=JXTEMP and FEST2=TRUE, estimated pressure (Pa),
C else not defined
C NPOUT If FEST1 is .TRUE. NPOUT must be set to the number of
C phases present at the estimate of the solution supplied
C in LNOPD, XX and NMOLPH.
C LNOPD If FEST1 is .TRUE. LNOPD must be set on entry.
C Array of NP PD load numbers corresponding to input
C values in XX and NMOLPH.
C XX If FEST1 is .TRUE. XX must be set on entry.
C See below for full description.
C NMOLPH If FEST1 is .TRUE. NMOLPH must be set on entry.
C See below for full description.
C
C Output values:
C T Temperature (K)
C P Pressure (Pa)
C NPOUT number of phases at equilibrium or at best estimate of
C solution. When an estimate of the solution is supplied
C some of the input phases may be eliminated.
C LNOPD Array of NP PD load numbers corresponding to output
C values in XX, NMOLPH, ZCOMP and IPHID.
C XX XX(I,J) holds the mole fraction of component I in phase
C J for J = 1,NPOUT.
C NMOLPH NMOLPH(J) holds the number of moles in phase J for
C J = 1,NPOUT. A zero value will be returned for phases at a
C saturation point (eg. a dew point or bubble point).
C
C Output arguments:
C VV Total volume (m3)
C HH Total enthalpy (J)
C SS Total entropy (J/K)
126
C ZCOUT Compressibility factor of each output phase (as
C calculated by the fugacity model, not the volumetric
C model).
C IPHOUT identity (V,L,..etc) of each output phase. If the
C calculation is successful, the phase id. is set to that
C specified in the phase descriptor definition. Note that
C for supercritical phases described by equations of state,
C the phase label is ambiguous.
C The phase codes used are defined in AYPTID.INC
C ISTABO Stability indicator for solution.
C = -2 definitely unstable. Another phase would be formed
C or an existing phase removed if problem
C specification allowed.
C = -1 marginally unstable (see above).
C = 0 indeterminate. This value is returned if no final
C stability test was requested (ISTABI=0) and no
C other error condition was detected. If ISTABI=1 it
C means that the solution is on the stability limit.
C = 1 marginally stable.
C = 2 definitely stable.
C NERR No. errors reported by this routine and sub-routines
C IERR Error codes returned. Values for this routine:
C -21011 Unstable solution returned.
C Phase split converged but solution is not stable.
C All specified phase descriptors have been used up
C or the maximum number of phases has been reached
C so no further phase split can be done.
C -21012 Phase split converged to low accuracy
C -21013 Other warning
C 21011 Illegal input specification. IVAR, IPROB
C or TARGET set wrongly. Negative or zero:
C P; T; volume.
C 21012 Inconsistent user-supplied estimates.
C Number of input phases NPOUT does not agree
C with flags for phases present in LNOPD
C or initial number of phases NPOUT is greater than
C number of available phase descriptors NPD.
C 21013 Cannot find starting point for calculation - this
C may mean there is no solution.
C 21014 PD identifier has unacceptable value
C 21015 Cannot converge temperature or pressure search
C 21016 Not enough phase descriptors to solve problem.
C Calculation abandoned.
C 21017 Other fatal error
C 21018 Phase envelope not enabled
AXPT02 is called repeatedly to calculate subsequent points on the line being traced. Crit-
ical points and gradient discontinuities are fixed by interpolation and codes to denote such
points are returned in argument KI. The calling specification is:
127
+ KI, TI, PI, STEPI, NPRINT, NERR, MXERR, IERR )
C
C Input arguments:
C ISTABI controls whether a stability test is done on the final
C solution which matches the specifications in NPDIN and
C IPDIN. Omitting the stability test saves time but an
C erroneous solution may be returned.
C JXNOSC = no final stability check
C JXDOSC = do final stability check
C NCDIM dimension of mole fraction arrays NMOLIN and XX declared
C in calling routine. NCDIM must be greater than or equal
C to the the number of components for the flash.
C NIDIM dimension of arrays KI, TI, PI
C NPRINT parameter for diagnostics output:
C = -1 none
C = 0 none unless serious error
C > 0 diagnostics, increasing as NPRINT increased
C MXERR maximum number of error flags to be returned in IERR
C
C Output arguments:
C T Temperature (K)
C P Pressure (Pa)
C VV Total volume (m3)
C HH Total enthalpy (J)
C SS Total entropy (J/K)
C NPOUT number of phases at equilibrium or at best estimate of
C solution.
C LNOPD Array of NP PD load numbers corresponding to output
C values in XX, NMOLPH, ZCOMP and IPHOUT.
C XX XX(I,J) holds the mole fraction of component I in phase
C J for J = 1,NPOUT.
C NMOLPH NMOLPH(J) holds the number of moles in phase J for
C J = 1,NPOUT. A zero value will be returned for phases at a
C saturation point (eg. a dew point or bubble point).
C ZCOUT Compressibility factor of each output phase (as
C calculated by the fugacity model, not the volumetric
C model).
C IPHOUT Identity (V,L,..etc) of each output phase. If the
C calculation is successful, the phase id. is set to that
C specified in the phase descriptor definition. Note that
C for supercritical phases described by equations of state,
C the phase label is ambiguous.
C The phase codes used are defined in AYPTID.INC
C ISTABO Stability indicator for solution.
C = -2 definitely unstable. Another phase would be formed
C or an existing phase removed if problem
C specification allowed.
C = -1 marginally unstable (see above).
C = 0 indeterminate. This value is returned if no final
C stability test was requested (ISTABI=0) and no
C other error condition was detected. If ISTABI=1 it
C means that the solution is on the stability limit.
C = 1 marginally stable.
C = 2 definitely stable.
C NI Number of special interpolated points returned
C KI Codes of special interpolated points
C = 1 critical point
128
C = 2 discontuity on crossing phase boundary
C TI Interpolated temperature
C PI Interpolated pressure
C STEPI Step to discontinuity/critical point as fraction of normal step
C NERR No. errors reported by this routine and sub-routines
C IERR Error codes returned. Values for this routine:
C -21021 Unstable solution returned.
C Phase split converged but solution is not stable.
C All specified phase descriptors have been used up
C or the maximum number of phases has been reached
C so no further phase split can be done.
C -21022 Phase split converged to low accuracy
C 21021 Cannot converge temperature or pressure search
C 21022 Other fatal error
C 21023 PD identifier has unacceptable value
C 21024 Outside allowed range for p/T search
C 21025 No initial points stored, subroutine aborted
129
! (INP,7) values).
! 0 normal point
! 1 discontinuity (where phase boundaries cross)
! 2 critical point
! Phase boundaries: Same as for MTEMP.
! NP Actual number of points for each phase boundary
! NERR Number of status codes returned in IERR
! IERR Multiflash warning/error codes
!
! Arguments
!
REAL*8, INTENT (IN) :: NMOL(*), TPGRID(4)
INTEGER, INTENT (IN) :: LNOST, INP, MXERR
REAL*8, INTENT (OUT) :: MTEMP(INP,MAXPHA), MPRES(INP,MAXPHA)
INTEGER, INTENT (OUT) :: MISTAT(INP,MAXPHA), NP(MAXPHA),
+ NERR, IERR(MXERR)
130
15 Property matching routines
15.1 Introduction
The Multiflash matching routines are provided to allow the user to match measured phase
equilibrium data (e.g. bubble points, dew points or wax appearance points), volumetric data
or liquid viscosity values. They operate by adjusting the pure-component properties of the
petroleum fractions present in the mixture. Note that if no petroleum fractions are present,
none of the matching routines can function.
131
C Retrograde dew point T lower
C P upper
C
C Normal bubble point T lower
C P upper
C
C Retrograde bubble point T upper
C P lower
C
C For phase fractions between 0 and 1 the best setting
C depends on the shape of the phase diagram.
C
C It is important to specify the correct search code
C because the value of IPROB(3) is used as a guide, both to
C generate initial estimates of T or P, and also to decide
C on a search direction towards the required solution.
C Particularly for difficult calculations, the user needs
C to have an idea of the layout of the phase diagram.
C Note that the JSANY specification is less reliable than
C any of the others because the routine has no guidance
C about where to look for a solution.
C SR super/sub saturation ratio. The value of SR
C should normally be set to 1.0. Values greater than 1
C mean that the phase is super-saturated and less than 1
C mean that the phase is undersaturated.
C NPTS number of data points to be matched (in T, P, and TARGET
C arrays)
C TARGET array of property values (phase fractions) to be matched
C (corresponding to the setting of IPROB(1))
C T arrays of temperature (K) and pressure (Pa) points
C P corresponding to values in TARGET
C WT array of weighting factors for data points
C MXERR maximum number of error flags to be returned in IERR
C
C Output arguments:
C NFITP number of parameters fitted
C IFITP pure component property ID codes (array) for the
C parameters fitted (codes are in ayjpid.inc).
C IFITP should be dimensioned to receive the maximum number
C of parameters that can be fiited (currently this is 2).
C NERR no. errors reported by this routine and sub-routines
C IERR error codes returned. Values for this routine:
C -20551 could not fit to all points - there were some
C failures
C 20551 there are no data points to match
C 20552 unacceptable problem specification. This includes
C IPROB(1) not being set to one of the codes listed
C above, a zero or negative T/P, or a negative phase
C fraction target
C 20553 failure initialising Multiflash
C 20554 failure getting model info. for matching
C 20555 failure during single-point match
C 20556 zero total weighting factor - cannot evaluate
C optimum parameter
The saturation ratio allows for departure from equilibrium in phase formation. A value of
1.0 means equilibrium, values less than 1.0 is sub-saturated relative to equilibrium and valued
132
greater than 1.0 mean super-saturation. The saturation ratio is used to scale the fugacities
of the phase that is present in fixed amount.
133
C NFITP number of parameters fitted
C IFITP pure component property ID codes (array) for the
C parameters fitted (codes are in ayjpid.inc).
C IFITP should be dimensioned to receive the maximum number
C of parameters that can be fiited (currently this is 2).
C NERR no. errors reported by this routine and sub-routines
C IERR error codes returned. Values for this routine:
C 20531 PD specified for matching is not part of stream
C 20532 there are no data points to match
C 20533 temp, pressure or viscosity is zero or negative
C 20534 cannot evaluate objective function at initial point
C 20535 cannot increment solution to get a 2nd point
C 20536 function value independent of variable, model
C is probably not set up for fitting
C 20537 cannot improve solution to get a third point
C 20538 quadratic extrapolation failed to improve solution
C 20539 run out of iterations
134
C 0 m3/mol
C 1 m3/kg
C MXERR maximum number of error flags to be returned in IERR
C
C Output values:
C NFITP number of parameters fitted
C IFITP pure component property ID codes (array) for the
C parameters fitted (codes are in ayjpid.inc).
C IFITP should be dimensioned to receive the maximum number
C of parameters that can be fiited (currently this is 2).
C
C Output arguments:
C NERR no. errors reported by this routine and sub-routines
C IERR error codes returned. Values for this routine:
C 20651 The model for the volume calculation and the fluid
C model should be same.
C 20652 Matching the volume data only works with RKSA and PRA.
C 20653 Error in problem specification
C 20654 There are no data points to match
C 20655 Too many failures in matching the volume data, calculation was terminated.
C 20656 Maximum iteration reached, calculation was terminated.
C 20657 specified phase for matching is not in the stream
• Bubble points
• Water cut
Only one of the above properties will have to be supplied. Additionally, when matching
GOR, the hydrocarbon liquid density can also be matched. Note that when matching GOR
and/or water cut the compositions (NMOL) will have changed.
The calling specification for AXMT07 A is:
C Input arguments:
C LNOST stream type load number: used to find the number of
135
C components and subcomponent list
C NMOLIN number of moles of each component in the mixture
C IPROB array of codes for type of calculation required
C (codes are defined in axjnum.inc)
C IPROB(1) quantity to match
C JXPHML phase molar fraction
C JXPHMS phase mass fraction
C JXPHVL phase volume fraction
C IPROB(2) fixed phase load number
C IPROB(3) upper/lower phase fraction search
C JSNL lower normal solution
C JSRU upper retrograde solution
C JSNU upper normal solution
C JSRL lower retrograde solution
C JSANY any solution
C JSDEF default normal solution
C
C The normal settings for dew/bubble points are:
C Search for setting
C Normal dew point T upper
C P lower
C
C Retrograde dew point T lower
C P upper
C
C Normal bubble point T lower
C P upper
C
C Retrograde bubble point T upper
C P lower
C
C For phase fractions between 0 and 1 the best setting
C depends on the shape of the phase diagram.
C
C It is important to specify the correct search code
C because the value of IPROB(3) is used as a guide, both to
C generate initial estimates of T or P, and also to decide
C on a search direction towards the required solution.
C Particularly for difficult calculations, the user needs
C to have an idea of the layout of the phase diagram.
C Note that the JSANY specification is less reliable than
C any of the others because the routine has no guidance
C about where to look for a solution.
C SR super/sub saturation ratio. The value of SR
C should normally be set to 1.0. Values greater than 1
C mean that the phase is super-saturated and less than 1
C mean that ther phase is undersaturated.
C IWAT Position of water component in component sublist for the
C stream type refered by LNOST
C IPDV PD load number for gas phase for GOR calculation
C IPDL PD load number for liquid phase for GOR and density
C calculation
C NPT number of point data ppoints to be matched (in T
C and P)
C T arrays of temperature (K) and pressure (Pa) points
C P corresponding to phase fractions in PHFRAC
C PHFRAC values of phase fractions to be matched (for phase
136
C with PD given by IPROB(2))
C WT array of weighting factors for each data point
C WVOL Fraction of water present in liquid phase (%)
C GOR value of gas/oil ratio in sm3/m3, i.e. m3 of gas at
C standard conditions (15C, 1bar) per m3 of liquid at
C TGOR and PGOR
C TGOR temperature corresponding to GOR (K)
C PGOR pressure corresponding to GOR (Pa)
C LDGOR liquid density at GOR conditions (kg/m3). If no value
C is available LDGOR should be set to -DLARGE
C MXERR maximum number of error flags to be returned in IERR
C
C Output values:
C NMOUT component mole numbers adjusted to match the GOR
C NFITPH number of parameters fitted for the fixed phase fraction data
C IFITPH pure component property ID codes (array) for the
C parameters fitted (codes are in ayjpid.inc).
C IFITPH should be dimensioned to receive the maximum number
C of parameters that can be fiited (currently this is 2).
C NFITLD number of parameters fitted for the liquid density data
C IFITLD pure component property ID codes (array) for the
C parameters fitted (codes are in ayjpid.inc).
C IFITPH should be dimensioned to receive the maximum number
C of parameters that can be fitted (currently this is 2).
C
C Output arguments:
C NERR no. errors reported by this routine and sub-routines
C IERR error codes returned. Values for this routine:
C 21051 failure matching phase fraction point(s)
C 21052 failure flashing stream at GOR conditions
C 21053 vapour phase not present at GOR conditions
C 21054 liquid phase not present at GOR conditions
C 21055 failure matching liquid volume
C 21056 failure calculating liquid MW
C 21057 failure calculating liquid volume at GOR conditions
C 21058 failure calculating vapour volume at GOR conditions
C 21059 Failed to find the minimum amount of water to add
C 21101 Water phase descriptor not present. Water phase fraction matching not possible.
C 21102 Failure calculating water phase volume at GOR conditions.
C -21051 specified GOR is too big, not consistent with the fluid.
C -21052 specified GOR is too small, not consistent with the fluid.
137
16 Chemical equilibrium calculations
16.1 Introduction
The Multiflash chemical equilibrium module (Chemreact) is a suite of software for performing
simultaneous phase and chemical equilibrium calculations. It can handle mixtures in vapour
and/or liquid phases, plus any number of pure solid phases. It incorporates a phase stability
analysis procedure whereby it can establish which of the possible phases are present at equi-
librium automatically. It has been improved in version 4.2 to handle more liquid phases and
make it more robust for generic applications. There is the option of using reaction squemes
but this feature is not supported yet.
Chemreact can determine phase and chemical equilibrium for the following specifications:
Additional facilities include the ability to impose a number of empirical corrections to the
computed equilibria to allow for situations in real reactors when equilibrium has not been
attained.
2. Define list of all components that may be present and load the data for these compo-
nents.
4. Specify and initialise the set of models that will be available. Define which variants of
the models are required and which BIPs the models will use. It is assumed that models
are defined in advance of use. A subset of the models defined may be used in any given
calculation.
5. Set up all the phase descriptors (PDs) which Multiflash may use: CALL AYDFPD See
section 9 for a description of PDs.
6. Initialise stream type system and set up all the stream types required (section 11).
138
CREA01 reaction at fixed p and T
CREA02 reaction at dew/bubble point at fixed p or T
Chemreact is designed to work with a subset of the previously defined components and
PDs. These subsets are specified in the calls to CREA01 etc.
139
C MXERR maximum number of error flags to be returned in IERR
C
C Input/output arguments:
C Input value:
C ZEQUIL starting values for the equilibrium mole fractions
C VAP starting value for phase distribution
C XX starting values for fluid phase mole fractions
C
C Output value:
C ZEQUIL mole fractions at equilibrium
C VAP equilibrium phase distribution
C XX equilibrium phase mole fractions
C
C Output arguments:
C ZETOT total number of moles in fluid phases at
C equilibrium
C NP number of phases at equilibrium or at best estimate of
C solution. When an estimate of the solution is supplied
C some of the input phases may be eliminated.
C LNOPD Array of NP PD load numbers corresponding to output
C values in XX, NMOLPH, ZCOMP and IPHID.
C ZCOMP compressibility factor of each output phase (as
C calculated by the fugacity model, not the volumetric
C model).
C IPHID identity (V,L,..etc) of each output phase. If the
C calculation is successful, the phase id. is set to that
C specified in the phase descriptor definition. Note that
C for supercritical phases described by equations of state,
C the phase label is ambiguous.
C The phase codes used are defined in AYPTID.INC
C NERR no. errors reported by this routine and sub-routines
C IERR error codes returned. Values for this routine:
C -30001 WARNING: calculation successful but warning from
C thermodynamic model(s) getting properties of
C reactants or products
C 30001 illegal input specification negative or zero
C P or T
C 30002 illegal input specification reported by startup
C routine. Negative or zero:
C number of moles of feed; feed mole
C fractions; number of phase descriptors;
C phase descriptors wrongly specified in input or
C wrongly set up prior to calling CREA01.
C 30003 cannot get equilibrium constants
C 30004 convergence failure in CREQ01
140
REAL*8, INTENT(OUT) :: ZETOT, ZEQUIL(*), ZCOMP(*),
LOGICAL, INTENT(IN) :: FEST
CHARACTER*72, INTENT(IN) :: CRNAME(MAXRXN, *)
141
C VAP equilibrium phase distribution
C XX equilibrium phase mole fractions
C
C Output arguments:
C ZETOT total number of moles in fluid phases at
C equilibrium
C ZEQUIL mole fractions at equilibrium
C NP number of phases at equilibrium or at best estimate of
C solution. When an estimate of the solution is supplied
C some of the input phases may be eliminated.
C LNOPD Array of NP PD load numbers corresponding to output
C values in XX, NMOLPH, ZCOMP and IPHID.
C ZCOMP compressibility factor of each output phase (as
C calculated by the fugacity model, not the volumetric
C model).
C IPHID identity (V,L,..etc) of each output phase. If the
C calculation is successful, the phase id. is set to that
C specified in the phase descriptor definition. Note that
C for supercritical phases described by equations of state,
C the phase label is ambiguous.
C The phase codes used are defined in AYPTID.INC
C NERR no. errors reported by this routine and sub-routines
C IERR error codes returned. Values for this routine:
C 30021 illegal input specification negative or zero
C P or T, Bad IVAR or NTYPE
C 30022 illegal input specification reported by startup
C routine. Negative or zero:
C number of moles of feed; feed mole
C fractions; number of phase descriptors;
C phase descriptors wrongly specified in input or
C wrongly set up prior to calling CREA02.
C 30023 cannot find starting point (P or T) for calculation
C 30024 convergence failure in CREQ01
C 30024 unconverged - too many successive failures in
C equilibrium routine
C 30025 unconverged - out of iterations
142
17 Configuring Multiflash with a command file
17.1 Introduction
The previous sections of this manual have described how to initialise Multiflash by making
low-level subroutine calls. This is the most efficient and direct method of setting up precisely
those Multiflash features required by a higher level program such as a process simulator.
An alternative and simpler approach is to perform the initialisation by reading a Multiflash
command file. The Multiflash command language allows all aspects of a problem setup
to be defined. This would typically include databank(s), components, models and phase
descriptors. The command language is described in the Multiflash Command Reference.
C Input arguments:
C CMDFIL name of Multiflash command file to be processed
C APPNAM directory path used to locate Multiflash files
C (databanks etc.)
C ERRFIL name of file for error information generated as the
C command processor parses the command file. Note that
C error codes are always returned in the IERR array
C whatever the setting of ERRFIL.
C Three operating modes are possible:
C 1. If set to a blank character error codes are only
C returned in the IERR array.
C 2. If set to a ’*’ character, the contents of the command
C file are echoed to the default output unit (eg. the
C screen) and any errors or warnings generated by the
C commands in the file are also displayed.
C The output is paused after each screenfull and
C the <Enter> key must be pressed to resume.
C 3. If set to a valid file name, the contents of the command
C file are echoed to the error file together with any
C errors or warnings
C MXERR maximum number of error codes to return in IERR
C
C Output arguments:
C NC highest seial number for defined components.
143
C This is usually the same as the number of components
C defined but it possible that the component list
C (in CNAME) contains gaps.
C IC component load numbers
C NMOL Component amounts in mol stored in MFL file.
C CNAME component names (aliases). The alias is a name by which a
C user wishes to refer to a component. It need not be one
C of the names by which the component is recognises on
C any databank. If an aliases is not specified explicitly
C the name is the same as the databank name.
C The list may contain gaps which are denoted by blanks.
c The highest non-blank entry is CNAME(NC)
C NPD number of phase descriptors defined
C IPD array of PD load numbers
C PDNAME PD names defined in the command file
C IPHID phase type of each PD (codes from ayptid.inc)
C NST number of stream types defined
C IST array of stream type load numbers
C STNAME stream names defined in the command file.
C NERR number of error codes returned in IERR
C IERR error codes. Values for this routine:
C -230 processing the command file produced warnings
C 576 cannot open MF command file CMDFIL
C 577 cannot open the error file ERRFIL
C 578 MF command file contains serious errors
144
C Output arguments:
C NC highest seial number for defined components.
C This is usually the same as the number of components
C defined but it possible that the component list
C (in CNAME) contains gaps.
C IC component load numbers
C CNAME component names (aliases). The alias is a name by which a
C user wishes to refer to a component. It need not be one
C of the names by which the component is recognises on
C any databank. If an aliases is not specified explicitly
C the name is the same as the databank name.
C The list may contain gaps which are denoted by blanks.
c The highest non-blank entry is CNAME(NC)
C NPD number of phase descriptors defined
C IPD array of PD load numbers
C PDNAME PD names defined in the command file
C IPHID phase type of each PD (codes from ayptid.inc)
C NST number of stream types defined
C IST array of stream type load numbers
C STNAME stream names defined in the command file.
C NERR number of error codes returned in IERR
C IERR error codes. Values for this routine:
C -230 processing the command file produced warnings
C 576 cannot open MF command file CMDFIL
C 577 cannot open the error file ERRFIL
C 578 MF command file contains serious errors
Notes:
1. Before calling MFRDFL NMOL the security system must be initialised by calling MFSINI
as described in section 3.2.
3. The arguments CMDFIL and, optionally, ERRFIL should contain complete file access
strings (pathnames).
4. For a description of the databank files used by Multiflash see section 4.3.
5. Component load numbers and names are only returned if the components are defined
in the command file.
6. Phase descriptor information is only returned if the models and PDs are defined in the
command file.
7. All components and PDs defined in all stream types are returned. To get information
on the component list and PD list for a particular stream it is necessary to call the
routines described in section 11.
8. Only stream types defined explicitly are returned. The default stream type (0) can be
used to refer to all components and PDs.
145
INTEGER, INTENT(OUT) :: NCOMP, TYPE(*), NERR, IERR(*)
INTEGER, INTENT(IN):: MXERR
CHARACTER*(*), INTENT(OUT) :: NAME(*), ALIAS(*)
CHARACTER*(*), INTENT(IN) :: FILNAM
puredata infodata;
components WATER;
Provided that the security system has been successfully initialised the following code fragment
will return the vapour pressure of water at 373.15 K using the correlation on the INFODATA
databank (which is located in directory c:\mfl).
C
C Error reporting system:
C
INTEGER MXERR
PARAMETER (MXERR=10)
INTEGER NERR, IERR(MXERR)
C
INTEGER NC, IC(MAXNCS), NPD, IPD(MAXPD), IPHID(MAXPD), IC(1),
+ NST, IST(MAXST)
146
REAL*8 VP(1), ADUM(1), NMOL(MAXNCS)
CHARACTER*20 CNAME(MAXNCS), PDNAME(MAXPD), STNAME(MAXST)
C
C Read and process Multiflash command file:
C
CALL MFRDFL_NMOL( ’ex1a.mfl’, ’c:\mfl’, ’ ’, NC, IC, NMOL, CNAME,
+ NPD, IPD, PDNAME, IPHID, NST, IST, STNAME,
+ NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error processing MF command file. Errors:’
PRINT*,(IERR(I),I=1,NERR)
GO TO 990
ENDIF
C
C Get vapour pressure:
C
CALL AYPSVP( 1, IC, 373.15D0, .FALSE., VP, ADUM,
+ NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error evaluating VP’
ELSE
PRINT*,’VP of ’,CNAME(1),’ at 373.15K is ’,VP(1),’ Pa’
ENDIF
147
INTEGER STATUS
STATUS = MFEND()
MFEND should only be called if no further calls will be made to the Multiflash dll.
• van der Waals mixing rule binary parameters. Constant and temperature dependent;
• Which Peneloux volume correction function was used: none, constant, linear with tem-
perature;
In addtion, the converter gives the user the following extra options:
• Allows adding water to the list of define components (if water was not defined in the
CHC file).
• Gives the choice of calculating vapour phase density using GERG 2008 model (from
version 4.3.11).
148
INTEGER, DIMENSION(*), INTENT(OUT) :: Ierr
149
18 Unit conversion utilities
A set of of basic unit conversion routines is provided. Before any of the following routines
is called it is necessary to initialise the machine-dependent numerical constants stored by
Multiflash. This is done by calling any of the initialisation routines described in other sections
or by a direct call to AYNUMI (the routine has no arguments). The following conversion routines
are available:
property conversion
routine
amount/composition/flowrate UNF
density/volume (molar/specific) UND
diffusion coefficient UNI
energy (molar/specific) UNH
entropy/heat capacity (molar/specific) UNS
pressure UNP
surface tension UNR
temperature UNT
thermal conductivity UNU
viscosity UNV
volume UNVOL
150
C
C Output values:
C F component mole or mass fractions amounts for components
C with defined MW in units corresponding to OU
C FTOT total amount for components with defined MW
C
C Output arguments:
C AVMW relative molar mass for mixture. The value returned is
C only meaningful if MW has been correctly set on input.
C IERROR Error code (defined in unjerr.inc)
C JUNERR_OK OK
C JUNERR_BADVALUE numerical value is below physical limit
C JUNERR_BADCODE unit id. code is not recognised
C JUNERR_NOMW the molecular weight is not set
C JUNERR_NOMATERIAL total amount of material is zero
151
18.3 UNI: Diffusion coefficient
This routine converts diffusion coefficient units. The calling specification is:
INTEGER I, O, IERROR
REAL*8 DI
INTEGER I, O, IERROR
REAL*8 AVMW, H
152
C H Specific/molar energy
C
C Output argument:
C IERROR Error code (defined in unjerr.inc)
C JUNERR_OK OK
C JUNERR_BADVALUE numerical value is below physical limit
C JUNERR_BADCODE unit id. code is not recognised
C JUNERR_NOMW the molecular weight is not set
INTEGER I, O, IERROR
REAL*8 AVMW, S
INTEGER I, O, IERROR
REAL*8 P
153
SUBROUTINE UNP( I, O, P, IERROR )
C
C Input arguments:
C I Input pressure units
C 1 pascal
C 2 kilo pascal
C 3 mega pascal
C 4 bar
C 5 bar gauge
C 6 atmosphere
C 7 atmosphere gauge
C 8 psi
C 9 psi gauge
C 10 mm mercury
C 11 inches water gauge
C 12 at (technical atmosphere kgf/cm2)
C 13 at gauge
C O Output pressure units - codes as above
C
C Input/output arguments:
C P Pressure
C
C Output argument:
C IERROR Error code (defined in unjerr.inc)
C JUNERR_OK OK
C JUNERR_BADVALUE numerical value is below physical limit
C JUNERR_BADCODE unit id. code is not recognised
154
INTEGER I, O, IERROR
REAL*8 T
INTEGER I, O, IERROR
REAL*8 U
INTEGER I, O, IERROR
155
REAL*8 V
156
Appendices
157
AYMPDV sets a model parameter data value 80
AYMPDV R Retrives a model parameter data value 81
AYNPD get number of phase descriptors defined 84
AYNUMI initialises machine-dependent numerical parameters 12
AYNUMV gets value of machine-dependent numerical parameters 12
AYPCNK pure component constant property (character string) 36
AYPCNR pure component constant property (number) 37
AYPCNS pure component constant property status 38
AYPCOR get coefficients in T-dependent property correlation 48
AYPDBC load a component from a databank 20
AYPDBF search databank for components with specified formula 31
AYPDBI search databank for component with specified name 29
AYPDBK return character data from a databank 32
AYPDBO open a databank (pure component data, BIPs or characterisation) 18, 60, 26
AYPDBS search databank for component name containing a specified string 30
AYPDBU unload a databank 19
AYPDBV return real-valued data from a databank 33
AYPDBY search databank for synonyms for a component name 30
AYPDEL delete a component 33
AYPDIE dielectric constant of liquid 39
AYPDNL pure component saturated liquid density 39
AYPHC test whether components are hydrocarbons 38
AYPHLV pure component latent heat 40
AYPHSI enthalpy, entropy, heat capacity for p.g. 41
AYPINI initialises pure component data module 17
AYPLCP pure component saturated liquid heat capacity 41
AYPLH1 pure component saturated liquid enthalpy, entropy and heat capacity 42
AYPLTC pure component saturated liquid thermal conductivity 42
AYPLVS pure component saturated liquid viscosity 43
AYPNC1 get number of pure components defined and component load numbers 33
AYPPF define a petroleum fraction 28
AYPSCP pure component solid heat capacity 44
AYPSDN pure component solid density 44
AYPST pure component saturated liquid surface tension 45
AYPSTK set a string constant for a pure component 23
AYPSTR set a numerical constant for a pure component 21
AYPSVP pure component saturated liquid vapour pressure 45
AYPSVR second virial coefficient 46
AYPUND set a numerical constant for a pure component to undefined 22
AYPUFS return integer code corresponding to UNIFAC subgroup 26
AYPVB1 generates pseudocomponents using black oil input data 55
AYPVT1 uses a compositional analysis to generate pseudocomponents 51
AYPVT1 TBP uses TBP or D86 Boling point curves to generate compositional fluid 54
AYPVTC pure component vapour thermal conductivity 47
AYPVVS pure component vapour viscosity 47
AYRMPD remove a phase descriptor 85
AYSALN convert ion analysis to equivalent salinity 34
AYSURF evaluate mixture surface tension 90
AYTCND evaluate thermal conductivity of a mixture 90
AYUNLO frees a model load number 81
AYVISC frees a model load number 89
158
CREA01 chemical equilibrium calculation at fixed P and T 139
CREA02 chemical equilibrium dew/bubble point calculations 140
CRINIT initialise Chemreact chemical equilibrium module 139
ERFATL test for a fatal error 15
ERLAST return the most recent error code 15
ERTEST test for an error code 14
MFDEMS returns error message for given error number 15
MFEND ends a Multiflash run started by MFRDFL 147
MFRDFL NMOL reads and processes a file of Multiflash commands 143
MFSCLO closes the security system 12
MFSINI initialises the security system 11
MFVERS returns Multiflash version and revision date 16
UND density/volume (specific/molar) unit conversion 151
UNF amount/composition/flowrate unit conversion 150
UNH energy (specific/molar) unit conversion 152
UNI diffusion coefficient unit conversion 152
UNP pressure unit conversion 153
UNR surface tension unit conversion 154
UNS entropy/heat capacity (specific/molar) unit conversion 153
UNT temperature unit conversion 154
UNU thermal conductivity unit conversion 155
UNV viscosity unit conversion 155
UNVOL volume (total) unit conversion 156
159
B Infochem data banks
This section describes the contents and structures of the databanks supplied by and supported
by Infochem. These include databanks for pure component data and for binary interaction
parameters. This information should allow the programmer to extend or modify the supplied
databanks or to create new databanks in a compatible format.
B.1 Infodata
Infodata is the Infochem pure component data bank for normal components. These are
components that may be present in mixed fluid or solid phases. Some thermodynamic models
may only be valid for pure solid or fluid phases but any component from an Infodata format
databank could, in principle, be part of a mixed phase. The other class of components
recognised by Multiflash are pure condensed components (see Section B.2). This format is
also used for the Infochem version of the DIPPR databank.
Table 2: The component name and its synonyms in Infodata ASCII file record.
data entry Description
COMPONENT keyword for a component name
Name1 Component main name Up to 72 characters
DATA SYNONYMS keyword for starting synonyms
Name2 1st synonym Up to 72 characters
Name3 2nd synonym Up to 72 characters
etc.
Notes:
1. The Chemical Abstracts Registry (CAR) number should be a 12 character string con-
sisting of 6 digits (left padded with zeros if necessary) followed by a hyphen (-) followed
by 2 digits followed by another hyphen followed by a single digit followed by a blank.
Multiflash uses the CAR numbers to recognise special components such as water etc.
160
Table 3: Constant properties in Infodata ASCII file record: Part I
keywords Description
ACENTRICFACTOR acentric factor
ASSAC CPA ac parameter (Jm3 mol−2 )
ASSBC CPA b parameter (m3 mol−1 )
ASSBETA CPA β parameter
ASSDELTA CPA δAB parameter (K−1 )
ASSEPSILON CPA AB parameter (Jmol−1 )
ASSFF Number of association sites ( CPA )
ASSGAMMA CPA γAB parameter
ASSKAPPA CPA κ parameter
CARNUMBER CAR number ( up to 12 character )
COMPREFNO Component reference number
CNUMBER Carbon number for petroleum fractions
CPMELT Difference in Cp on fusion at the normal melting point (in Jmol−1 )
DIPOLEMOMENT Dipole moment (Debye units)
EOSC Corresponding states reference equation code
EXPANSIVITY thermal expansivity of liquid at 1 atm and 60 F (K−1 )
FAMILYCODE Chemical family code ( up to 20 character )
FLAMLOWER Lower flammability limit (volume % in air)
FLAMUPPER Upper flammability limit (volume % in air)
FORMULA Chemical formula ( up to 20 character )
GFORMATION Gibbs energy change on formation in the perfect gas state at 298.15K
and 105 Pa (Jmol−1 )
HCOMBUSTION Standard net enthalpy change on combustion
at 298.15K and 105 Pa (Jmol−1 )
HFORMATION Enthalpy change on formation in the perfect gas state
at 298.15K (Jmol−1 )
HMELT Enthalpy change on fusion at the normal melting point (Jmol−1 )
HOCASS Hayden-O’Connell self-association parameter
HYD1 Hydrate parameter 1
HYD2 Hydrate parameter 2
HYD3 Hydrate parameter 3
HYDOC Hydrate cavity occupation codes
LJBVISC Lennard-Jones σ parameter (m)
LJEVISC Lennard-Jones /k parameter for viscosity (K )
MCPR1 Mathias-Copeman parameter 1 for PRA EOS
MCPR2 Mathias-Copeman parameter 2 for PRA EOS
MCPR3 Mathias-Copeman parameter 3 for PRA EOS
MCRKS1 Mathias-Copeman parameter 1 for RKSA EOS
MCRKS2 Mathias-Copeman parameter 2 for RKSA EOS
MCRKS3 Mathias-Copeman parameter 3 for RKSA EOS
MOLECULARWEIGHT Molecular weight (relative molar mass)
OMASCALE scaling factor to give conventional value of Ωa for cubic EOS
OMBSCALE scaling factor to give conventional value of Ωb for cubic EOS
1
PARACHOR Parachor ( (dyne cm−1 ) 4 cm3 /mol )
161
Table 4: Constant properties in Infodata ASCII file record: Part II
keywords Description
PCRIT Critical pressure (Pa)
PTRIPLE Triple point pressure (Pa)
QUNIQUAC Uniquac q parameter
RADGYR Radius of gyration (m)
REFRACTINDEX Refractive index at 298.15K
REFVISCOSITY liquid viscosity at reference temperature and 1 atm (Pa s)
RUNIQUAC Uniquac r parameter
SAFTBOND PC-SAFT: bond segment id. and abundance
SAFTEPSILON PC-SAFT: AB parameter (K)
SAFTEK PC-SAFT: /k parameter (K)
SAFTFF PC-SAFT: number of association sites
SAFTGAMMA PC-SAFT: γAB parameter
SAFTKAPPA PC-SAFT: κ parameter
SAFTLAMBDA PC-SAFT: λ parameter
SAFTM PC-SAFT: m parameter
SAFTSIGMA PC-SAFT: σ parameter (m)
SMELT Entropy change on fusion at the normal melting point (Jmol−1 K−1 )
SOLIDSOLUPAR Solubility parameter for solid at 298.15K ((Jm−3 )1/2 )
SOLUPAR Solubility parameter for liquid at 298.15K ((Jm−3 )1/2 )
SPGRAVITY Specific gravity of liquid at 60F, 1atm relative to water
SSTANDARD Standard entropy in the perfect gas state at 298.15K and 105 Pa (Jmol−1 K−1 )
TAUTO Autoignition temperature (K)
TBOIL Normal boiling point (K)
TCRIT Critical temperature (K)
TFLASH Flash point temperature (K)
THLWATER Characteristic temperature for Henry’s Law correlation for
solubility of a component in water (K)
TMELT Normal melting point (K)
TTRIPLE Triple point temperature (K)
TYPE Type of components
UNIFAC UNIFAC subgroups and abundance
V25 Liquid molar volume at 298.15K (m3 mol−1 )
VCRIT Critical molar volume (m3 mol−1 )
VHLWATER Characteristic volume for Henry’s Law correlation for solubility
of a component in water (m3 mol−1 )
VMELT Difference in molar volume on fusion at the normal melting point (m3 mol−1 )
VSRKS1 Peneloux volume shift parameter 1 for RKSA EOS
VSRKS2 Peneloux volume shift parameter 2 for RKSA EOS
VSRKS3 Peneloux volume shift parameter 3 for RKSA EOS
VSPR1 Peneloux volume shift parameter 1 for PRA EOS
VSPR2 Peneloux volume shift parameter 2 for PRA EOS
VSPR3 Peneloux volume shift parameter 3 for PRA EOS
ZCRIT Critical compressibility factor
162
Table 5: Temperature-dependent properties in Infodata ASCII file record
keywords Description
CPIDEAL Perfect gas Cp equation number
Coefficients for perfect gas Cp
CPLIQUID Saturated liquid Cp equation number
Coefficients for saturated liquid Cp
CPSOLID Solid Cp equation number
Coefficients for solid Cp
DIELECTRIC Dielectric constant equation number
Coefficients for dilecrtic constsnt correlation
HVAP Enthalpy of vaporisation equation number
Coefficients for enthalpy of vaporisation
LDENS Saturated liquid density equation number
Coefficients for saturated liquid density
LVISC Saturated liquid viscosity equation number
Coefficients for saturated liquid viscosity
LTHCOND Saturated liquid thermal conductivity equation number
Coefficients for saturated liquid thermal conductivity
PSAT Saturated vapour pressure equation number
Coefficients for saturated vapour pressure
STENSION Surface tension equation number
Coefficients for surface tension
SDENS Solid density equation number
Coefficients for solid density
VIRIALCOEFF Second virial coefficient equation number
Coefficients for second virial correlation
VTHCOND Zero density gas thermal conductivity equation number
Coefficients for zero density thermal conductivity
VVISC Zero density gas viscosity equation number
Coefficients for zero density gas viscosity
163
Any character string may be entered for the CAR number but the component may not
then be recognised for what it is.
2. The compound names are any set of 72 characters. The program suppresses blanks and
(most) punctuation marks in the names. Each name in every file must be unique in its
converted form.
4. The chemical family code is a string of up to 20 characters. The codes stored in the
Infodata and DIPPR databanks are the DIPPR chemical family codes which use 3
characters.
5. The UNIFAC subgroups are indicated by their identifiers enclosed in apostrophes. The
Multiflash UNIFAC subgroup identifiers valid for the cuurent version of Multiflash can
be found in the Multiflash Command Reference.
6. The component reference number can be assigned any value the user may wish. The
number is stored by Multiflash but not used in any other way. The number entered
must be an integer, but it is subsequently stored as a real by Multiflash.
7. All numerical data are stored as REAL*4 values. The precision and range are machine-
dependent but on most computer systems 7 significant (decimal) digits are stored and
the (decimal) exponent must be in the range −38 to +38.
8. The databank header must be at the top of the Infodata ASCII file with a correct order
and keywords which are given in Table 1.
9. The data record for each component is terminated by a semi-colon and separated by a
line starting with # which is followed by hyphen to separate the data record of each
component. Within a data block for a component or the data bank header, each line
starts with a keyword followed by either a character string or numeric value, then
terminated by a semi-colon except for the keywords COMPONENT and DATA SYNONYMS.
10. For each component, the data record starts with the keyword COMPONENT, which is
then followed by the component’s main name on a new line. Then the keyword
DATA SYNONYMS must be present in the next new line for the components’ synonyms.
Each component can have several synonyms which includes its CARN number. Each of
the synonyms occupies a line after the keyword DATA SYNONYMS. Finally the keyword
COMPONENT is terminated by a semi-colon. The correct order for a component name and
its synonyms is given in Table 2.
11. The other constant properties in the data record are defined in Tables 3 and 4. In
general, each entry of the constant physical properties starts with a Multiflash keyword
on a new line, followed by either character string or numeric value and terminated
by a semi-colon. For the UNIFAC structure, it starts with the keyword UNIFAC, but
followed by a set of subgroups. Each set of the subgroup includes character string and
its abundance separated by a space, and then terminated by a semi-colon. The constant
properties can be in any kind of orders as long as the keywords for physical properties
164
are recognised by Multiflash. If the value of any is unknown, the entry of the property
can be omitted. However, if it is not omitted, it should be set to the data unknown
value of -SLARGE (SLARGE is set up by subroutine AYNUMI and is currently 1.0E35).
12. For each of the temperature dependent properties, the data starts with a Multiflash
keyword followed by the Infochem equation number, the appropriate number of coef-
ficients and the minimum and maximum temperature limits for the correlation. The
record is terminated by a semi-colon. Details of all the equations are given in Appendix
D. The correct number of coefficients for each equation can also obtained from Ap-
pendix D by adding 2 to the number of coefficients listed (for Tmin and Tmax . Note that
for the perfect gas Cp the coefficients start at coefficient a3 ; coefficients a1 and a2 are
calculated by the program.
13. If the data for any temperature dependent property are unknown, the data entry for the
temperature dependent property can be omitted or the equation number should be set
to zero and no coefficients should be entered for that property. There is no restriction
about the order of the temperature properties.
The data structure described above contains a complete specification of the data for one
compound. To build a up a data file, data is entered in sequence for as many compounds as
required.
B.2 Infocond
Infocond is the Infochem condensed component data bank. It is only used by the chemi-
cal equilibrium module when considering pure condensed phases. It is not used for phase
equilibrium calculations.
• File header.
165
• T-dependent properties. CPSOLID.
166
JMBWRS BWRS * 1 -
JMSAFT SAFT * 1 -
JMASSO ASSOC * 2 (See below)
JMREG REGULAR REGULAR (default)
1 -
FH 1 J/mol
JMWIL WILSON A (default) 2 J/mol
E 2 -, -
JMNRTL NRTL * 3 J/mol, J/mol, -
JMUNQ UNIQUAC * 2 J/mol, J/mol
JMOWN OWN *
JMPRA PRA VDW (default) 1 -
NRTL 3 -, -, -
JMRKS RKSA VDW (default) 1 -
NRTL 3 -, -, -
JMCOS COSTALD * 1 -
JMCSM CSM * 1 -
JMCSMA CSMA VDW 2 -, -
JMCSMA CSMA GERG 3 -, -, -
JMGERG GERG GERG 3 -, -, -
JMPDV PDVISC * 1 -
JMASP ASPHALTENE * 1 -
JMLGST LGST * 1 -
JMZJ ZJ ZJ 1 -
Note: the * model variant is used for those models that have no variants (as far as BIPs
are concerned). If a * is entered for a model with a variant, the default is taken, i.e. WILSON
* is equivalent to WILSON A, etc.
The CPA model ASSOC has two sets of BIPs. The fist is dimensionless, but the second
has a dimensionless first temperature coefficient, a second coefficient in J/mol and the third
coefficient is again dimensionless.
167
The units of BIPs are model-dependent (see above). For cubic eos the BIP are usually
dimensionless. For the activity models the Infochem implementations use BIPs in energy
units (J/mol).
B.3.7 Examples
1. Comment line
# value fitted to bubble point data 100-120K
2. BIP data lines
METHANE ETHANE PRA VDW 1 .011 ! trailing comment
ACETONE WATER NRTL * 1 1514 4342 .2908 # values from Dechema I/1 p248
168
C Identification codes for pure component properties
The following i.d. codes are defined as PARAMETER values in the file ayjpid.inc
169
JSOLPR solubility parameter (for liquid) at 25 C ((J/m3 )1/2 )
JSSLPR solubility parameter (for solid) at 25 C ((J/m3 )1/2 )
JSSTND standard entropy in perfect gas state at 298.15K and 105 Pa (J/mol K)
JTAUIG autoignition temperature (K)
JTBOIL normal boiling point temperature (K)
JTCRIT critical temperature (K)
JTFLSH flash point temperature (K)
JTHLWT Henry’s law characteristic T for solubility in water (K)
JTMELT normal melting point temperature (K)
JTTRPL triple point temperature (K)
JUFLAM upper flammability limit (vol. % in air)
JUNIF UNIFAC group structure
JUNIQQ UNIQUAC q parameter
JUNIQR UNIQUAC r parameter
JVCRIT critical volume (m3 /mol)
JVHLWT Henry’s law characteristic v for solubility in water (m3 /mol)
JVMELT solid/liquid difference in volume at melting point (m3 /mol)
JVSPR1 Peneloux volume shift parameters for PR EOS (m3 /mol)
JVSPR2 (m3 /molK)
JVSPR3 (m3 K/mol)
JVSRK1 Peneloux volume shift parameters for RKS EOS (m3 /mol)
JVSRK2 (m3 /molK)
JVSRK3 (m3 K/mol)
JZCRIT critical compressibility factor
JCPLIQ Set to use saturated liquid heat capacity as enthalpy reference.
170
JVVIS zero-density gas viscosity
The J-values listed above are used to access the property correlation coefficients not the
properties themselves. To evaluate a property at a given temperature it is necessary to call
one of the routines listed in section 5.4.
171
D Pure component properties
D.1 Constant properties
The following constant properties and information can be stored in the Multiflash data struc-
ture for each compound during execution of the program. Many of these quantities are not
stored on any databank but may be calculated when a component is loaded or as a result of
matching experimental data. Note that some of the property values may be missing for some
compounds depending on the databank(s) in use.
172
Lower flammability limit (volume % in air)
Upper flammability limit (volume % in air)
Solubility parameter (for solid) at 298.15K ((Jm−3 )1/2 )
Specific gravity of liquid at 60 F and 1 atm relative to water
Thermal expansivity of liquid at 60 F and 1 atm (K−1 )
Ωa and Ωb scaling parameters for cubic EOS
carbon number (for petroleum fractions)
Viscosity of liquid at reference temperature and 1 atm (Pas)
Reference temperature for viscosity of liquid (K)
Unifac group structure Type of reference to use for enthalpy in excess energy
models
173
Infochem equation 1: Harmens’ equation
Harmens 3 proposed the following equation
174
Infochem equation 5: DIPPR equation 100
Cp = a3 + a4 T + a5 T 2 + a6 T 3 + a7 T 4 (18)
T > Tmax : Cp = Cp (Tmax ) (19)
T < Tmin : Cp = Cp (Tmin ) (20)
This equation does not extrapolate to physical limits at zero and infinite temperature.
175
Infochem equation 5: DIPPR equation 100
η = a1 + a2 T + a3 T 2 + a4 T 3 + a5 T 4 (32)
√ √
T > Tmax : η = b1 / T + b2 T (33)
√
b1 T
T < Tmin : η = (34)
b2 + T
The values of Tmin and Tmax are only used to return warnings, no extrapolation is applied.
176
D.6 Second virial coefficient
Infochem equation 1: reduced form of DIPPR equation 104
B = a1 + a2 τ + a3 τ 3 + a4 τ 8 + a5 τ 9 (48)
where:
τ = Tc /T (49)
T > Tmax : B = B(T ) (50)
T < Tmin : B = b1 + (T − Tmin )b2 (51)
177
Infochem equation 4: Wagner equation (alternative form)
3 5
ln p = ln pc + (a1 τ + a2 τ 2 + a3 τ 2 + a4 τ 5 )/Tr (67)
where:
Tr = T /Tc (68)
τ = 1 − Tr (69)
T > Tc : ln p = ln pc + (a1 τ )/Tr (70)
T < Tmin : ln p = ln pc + (b1 + b2 /Tr ) (71)
178
Infochem equation 5: DIPPR equation 100
Hvap = a1 + a2 T + a3 T 2 + a4 T 3 + a5 T 4 (90)
b1
T > Tmax : Hvap = (91)
b2 + T
T < Tmin : Hvap = b1 + b2 τ 0.3775 (92)
179
Infochem equation 5: DIPPR equation 100
ρ = a1 + a2 T + a3 T 2 + a4 T 3 + a5 T 4 (110)
TH = min(0.99Tc , Tmax ) (111)
1 b1 + T
T > TH : = (112)
ρ ρc (b2 + T )
where:
ρc = ρ(Tc ) (113)
2
T < Tmin : ln ρ = b1 + b2 τ 7 (114)
where:
τ = 1 − T /Tc (115)
180
Infochem equation 4: Reid, Prausnitz and Poling
This is a combination of Reid, Prausnitz and Poling6 equations 2/3:
ln η = a1 + a2 /T + a3 T + a4 T 2 (130)
λ = a1 + a2 T + a3 T 2 + a4 T 3 + a5 T 4 (144)
181
D.12 Surface tension of saturated liquid
Infochem equation 1: DIPPR equation 106
σ = a1 (1 − Tr )Y (147)
where:
Y = a2 + a3 Tr + a4 Tr2 + a5 Tr3 (148)
and:
Tr = T /Tc (149)
TH = min(0.99Tc , Tmax ) (150)
1
for T > TH : σ = σ(TH ) (151)
1 + b1 ∆T
where
b1 = σ 0 (TH ) and ∆T = TH − T (152)
for T < Tmin : linear/quadratic extrapolation (153)
182
Infochem equation 5: DIPPR equation 100
Cp = a1 + a2 T + a3 T 2 + a4 T 3 + a5 T 4 (168)
1 + 2(b1 + b2 T )
T > Tmax : Cp = Cp (Tmax ) (169)
1 + (b1 + b2 T )
T < Tmin : Cp = Cp (Tmin )(b1 + b2 T ) (170)
Infochem equation 2
Matyott and Smith.
= exp(a1 + a2 T ) (174)
The above equation is also used for extrapolation.
In total, 31 coefficients a0 , a11 , a21 , a31 , a41 , a51 , a61 , a12 , a22 , a32 , a42 , a52 , a62 , a13 , a23 ,
a33 , a43 , a53 , a63 , a14 , a24 , a34 , a44 , a54 , a64 , a15 , a25 , a35 , a45 , a55 , a65 are used. a0 is set to
the number of temperature ranges used; the maximum permitted value is 5. Coefficient a5k
represents the transition temperature at which the kth. temperature range ends and which
the (k + 1)th. temperature range, if it exists, begins. Coefficient a6k represents the enthalpy
of transition between the kth. and, if it exists, the (k + 1)th. temperature range.
H is calculated by integrating Cp appropriately. At each transition temperature, the
enthalpy of transition is added to the enthalpy at that point and then the next expression for
Crmp is integrated, and so on until the desired temperature is reached. S is also found by the
appropriate integration. The transition entropies are calculated by dividing the enthalpies
of transition by the transition temperatures, since the Gibbs energies of transition must be
zero (condition for equilibrium).
Cp is in Jmol−1 K−1 , a5k is in K and a6k is in Jmol−1 .
183
Infochem equation 5: DIPPR equation 100
Cp = a1 + a2 T + a3 T 2 + a4 T 3 + a5 T 4 (179)
T > Tmax : Cp = b1 (180)
T < Tmin : Cp = b1 (181)
The second virial coefficient B is estimated for each component from a generalised corre-
lation 7 This correlation accounts for non-polar, polar and chemical association effects. The
pure component properties required by the model are: critical temperature, critical pressure,
radius of gyration, dipole moment and an empirical association parameter. Values for these
quantities are stored in the Infodata databank. A second virial coefficient model such as HOC
can account for gas phase non-idealities up to pressures of about 5 to 10 bar. The imple-
mentation of the HOC model in Multiflash allows the vapour phase association of substances
such as acetic acid to be represented
R2 Tci2
aci = Ω0a 0.42748 (188)
pci
where Ω0a is a scaling factor normally equal to unity.
7
J.G. Hayden and J.P. O’Connell, Ind. Eng. Chem.. Proc. Des. Dev, 14, 209 (1975).
8
O. Redlich and J. N. S. Kwong, Chem. Rev., 44, 233, (1949).
184
For the Soave variant9 :
q 2
ai = aci 1 + κi 1 − T /Tci (189)
where:
κi = 0.48 + 1.574ωi − 0.176ωi2 (190)
and for the Soave/API variant10 :
q 2
ai = aci 1 + κi 1 − T /Tci (191)
where:
κi = 0.48508 + 1.55171ωi − 0.15613ωi2 (192)
except for hydrogen which in the API variant is given by:
T
ai = 1.202aci exp −0.30228 (193)
Tci
The mixing rules are: X
N= ni (194)
i
X√
a= ai aj (1 − kij )ni nj (195)
ij
X
b= bi ni (196)
i
RTci
bi = Ω0b 0.08664 (197)
pci
where Ω0b is a scaling factor normally equal to unity.
R2 Tci2
aci = Ω0a 0.45724 (200)
pci
where Ω0a is a scaling factor normally equal to unity.
185
p
except for water when T /Tci < 0.85 where the following alternative relation is used:
q 2
ai = aci 1.0085677 + 0.82154 1 − T /Tci (202)
In the 1978 variant of the Peng-Robinson equation 12 (PR78), the expression for κ is
replaced by the following expression for all components for which the acentric factor is greater
or equal than 0.49:
The coefficients ci,0 , ci,1 and ci,2 for each component are stored separately for the PR and
RKS equations.
The volume shift parameter is calculated for each component to match the saturated liquid
density stored in the physical property data system at a reduced temperature of 0.7 or at
298.15K, whichever temperature is the lower. If the density is not available, the volume shift is
set to zero for that component. If the temperature-dependent volume shift is selected a linear
temperature-dependence is estimated from the liquid density correlation at two temperatures
close to the boiling point. The temperature-dependent version is only applied to components
with a critical temperature above 313 K.
12
D.B.Robinson and D.-Y. Peng, GPA Research Report 28, Gas Processors Association, Tulsa, (1978).
13
A. Peneloux and E. Rauzy, Fluid Phase Equil., 8, 7, (1982).
186
E.5.2 Fitting the vapour pressure curve
The function for ai is generalised to the following form:
2
ai = aci 1 + κi1 ti + κi2 t2i + κi3 t3i + κi4 t4i + κi5 t5i (210)
where q
ti = 1 − T /Tci (211)
For each component, the constants κi1 , κi2 , κi3 , κi4 and κi5 are fitted to the vapour
pressure over a range of reduced temperatures. For cases where T > Tc , a is extrapolated
using the following expression:
ai = aci (1 + κi1 ti )2 (212)
If the vapour pressure is undefined, the correlation for ai reverts to the standard equation
for that component.
It is also possible to select the Mathias-Copeman 14 version of the a function which is a
subset of the above equation including terms up to κ3 .
187
E.5.4 Huron-Vidal-type mixing rules
The Huron-Vidal mixing rules 16 : provide an alternative way of incorporating an excess Gibbs
energy model in equation of state mixing rules.
X
N= ni (219)
i
X
b= bi ni (220)
i
!
GE X ai
a=b − + ni (221)
s1 i
bi
√
For the RKS equation use s1 = ln 2 and for the PR equation use s1 = 2√ 1
2
ln( 2+√2 ) =
2− 2
0.623225.
The excess Gibbs energy GE can be calculated by any of the activity coefficient equations
available in Multiflash, viz. the ideal solution model, the regular solution model, the Flory-
Huggins model, the Wilson equation, the NRTL equation, the UNIQUAC equation or the
UNIFAC method.
where: √
2 ai aj (1 − kji )
ξji = (225)
bi + bj
and:
αji (ξji − ξii )
Gji = exp (226)
RT
These mixing are similar to the original Huron-Vidal mixing rules apart from the form of
the interaction parameters kij , kji and αij which gives a different temperature dependence.
These rules reduce to the conventional van der Waals mixing rules when kij = kji and αij = 0.
188
!
X ai g EX
a=b ni − (229)
i
bi ln 2
where: P
EX
X j nj bj ∆gji Yji
g = ni P (230)
i j nj bj Yji
and,
αji ∆gji
Yji = exp − (231)
RT
The parameters αij are dimensionless. On the other hand, it is common in literature
to encounter the asymmetric parameters expressed in the form ∆gij /R with the units of K.
Indeed, Multiflash accepts the asymmetrical parameters ∆gij /R with units of K only. If
for a given pair of components i-j, the phase behaviour can be accurately described with
classical and symmetric WDW kij , we can obtain the corresponding HVP parameters by
setting αij = 0 and using:
√ !
ai 2 ai aj (1 − kji )
∆gji = ln 2 − (232)
bi bi + bj
Therefore, Multiflash is also able to deal with VDW-like parameters for the HVP mixing
rule. Finally, if all the pairs of component can be described by classical and symmetric kij ,
the HVP mixing rule reduces to the conventional VDW mixing rule.
189
!
λ 1−λ 1−λ X b X ai
E
a=b + G + RT ln + ni (239)
AV AM AM i
bi i
bi
Boukouvalas et al. combined this mixing rule with the PR EOS and used the following
parameter values for the Peng-Robinson equation of state:
λ = 0.36 (240)
AV = −0.623 (241)
AM = −0.52 (242)
The excess Gibbs energy GE should be calculated by the UNIFAC method with the LCVM
group interaction table.
− Xi ) N RT
P
i ni Fi (1 a
p= + + (243)
V − 0.45b V − b V (V + b)
The parameters aci and bci are set for each component to satisfy the critical conditions at Tci
and pci
∂p ∂2p
= =0 (244)
∂V ∂V 2
The parameter ai is a function of temperature given by
2
ai = aci 1 + κ01 t.5 2 3 4 5
i + κi1 ti + κi2 ti + κi3 ti + κi4 ti + κi5 ti (245)
where q
ti = 1 − T /Tci (246)
For each component, the constants κi0 to κi5 fitted to the vapour pressure over a range of
reduced temperatures.
The model uses the standard van der Waals 1-fluid mixing rules. For details of the
association term see the references cited above.
190
E.8 Benedict-Webb-Rubin-(Starling) equation of state
The BWRS eos 22 has the following form
" ! !#
RT B C D C0 γ2 −γ 2
p= N+ + 2+ 5+ 5 1+ 2 exp (247)
V V V V V V V2
The Multiflash implementation offers three variants.
1. Coefficients taken from the Starling book where available and remaining coefficients
estimated using the Starling-Han correlation.
2. All coefficients coefficients estimated using the Starling-Han correlation.
3. Original BWR equation.
191
E.10 IAPWS formulation for water
The international standard formulation for the properties of water is made up from the follow-
ing components. The thermodynamic properties are obtained from the IAPWS95 formulation
23 . The viscosity, thermal conductivity and surface tension are based on the latest IAPWS
releases 24 .
192
F Activity coefficient equations
The fugacity coefficients for the activity coefficient equations are calculated from the standard
relationship32 :
ln φi = ln γi + ln psat sat
i + ln φi − ln p + Πi (249)
where γi is the activity coefficient of component i which is derived from the excess Gibbs
energy as follows:
∂GE
ln γi = (250)
∂ni
psat sat
i is the saturated vapour pressure of component i, φi is the fugacity coefficient of the pure
saturated vapour of component i (calculated from the gas phase model associated with the
activity coefficient equation) and p is the total pressure. The Poynting correction Πi corrects
the fugacity coefficient from the standard state pressure (i.e. the saturation pressure) to the
system pressure. It is evaluated on the assumption of ideality, i.e. assuming that there is zero
excess volume on mixing, and that the liquid is incompressible:
(p − psat sat
i )vi
Πi = (251)
RT
where visat is the saturated liquid volume of component i.
A number of activity coefficient equations are available in Multiflash. Denoting the binary
interaction parameters between components i and j by Aij , and also for the NRTL equation
by αij , these equations are as follows:
!
GE
P
X Gij nj
j
=− ni ln P (253)
RT i j nj
where:
Vj∗ Aij
Gij = ∗ exp − (254)
Vi RT
Vi∗ is the saturated liquid molar volume of component i (extrapolated in the case of super-
critical gases) evaluated at a fixed reference temperature of 298.15K.
metric and Associating Mixtures by von Solms, Michelsen and Kontogeorgis in Industrial and Engineering
Chemistry Research, 42, 1098, (2003)
32
R. C. Reid, J. M. Prausnitz and B. E. Poling, ‘The Properties of Gases and Liquids’, 4th. ed., McGraw-Hill,
New York, (1987), p.250
33
G. M. Wilson, Vapour-liquid equilibrium. XI: A new expression for the excess free energy of mixing, J.
Amer. Chem. Soc., 86, 127, (1964).
193
F.2.2 Wilson A equation
The A form of the equation treats the complete groups Gij and Gji in the above equation
as the adjustable binary parameters. In our standard notation for BIPs these are denoted
denoted as Aij in the definition of the Wilson A equation
!
GE
P
X jAij nj
=− ni ln P (255)
RT i j nj
P !
E
X Aji Gji nj
j
G = ni P (256)
i j nj Gji
where:
αji Aji
Gji = exp − (257)
RT
In cases where the user does not specify any value of αij , it is automatically set to 0.3 if the
VLE version of NRTL is specified or to 0.2 if the LLE version is specified.
! ! !
GE
P P P
X ri j nj zX qi j rj nj X Gji qj nj
j
= ni ln P + qi ni ln P − ni qi ln P (258)
RT i j rj nj 2 i ri j qj nj i j n j qj
where:
z = 10 (259)
and:
Aij
Gij = exp − (260)
RT
194
table as described by Gmheling. It includes parameters for 32 common light gases. It is
intended for use as an excess Gibbs energy model combined with the Infochem advanced
versions of the RKS or PR equations of state and the PSRK mixing rule.
The Unifac method has also been extended by Tassios and coworkers 38 in the LCVM
formulation to handle mixtures containing light gases encountered in petroleum fluids. It
is intended for use as an excess Gibbs energy model combined with the Infochem advanced
versions of the RKS or PR equations of state and the LCVM mixing rule. The LCVM
mixing rule is particularly designed to represent the phase behaviour of asymmetric mixtures
of hydrocarbons.
GE
P
ijni nj Vi Vj Aij
= P (261)
RT RT i ni Vi
where:
(δi − δj )2
Aij = − δi δj kij (262)
2
δi and Vi are the solubility parameter and liquid molar volume at 298.15K for component i
and kij is the interaction parameter.
Regular solution theory can be used for vapour-liquid calculations for mixtures of non-
polar or slightly polar components. The theory is applicable to systems which exhibit negli-
gible entropies and volumes of mixing. However, it has been largely superseded by equations
of state.
The Multiflash expression reduces to the standard Flory-Huggins theory if all interaction
parameters Aij are set to zero. However, to obtain reasonable results it is usually necessary
to adjust the values of the interaction parameters to fit the data.
Flory-Huggins theory is able to describe systems which include some long chain molecules
and it has consequently been applied to model polymer systems. Although it has been to
some extent superseded by other models such as PC-SAFT, Flory-Huggins theory offers the
advantages of speed and simplicity.
195
thermodynamic properties of the mixture at the temperature and pressure of interest are
then calculated using the properties of pure liquid water under the same conditions together
with Henry’s Law. The Henry’s Law constants for the gases or hydrocarbons are found at
the required temperature using a correlation39 .
196
NaCl.2H2 O. If α = 1, the solid fugacity coefficient is defined relative to the liquid phase of
the same composition whereas, if α = 0, the solid fugacity coefficient is an absolute value.
Scorr is a molar enthalpy correction factor that allows the reference temperature Tref to be
different from the normal melting point. For solid phases that are not pure substances, the
parameters ∆H, ∆Cp , ∆V , Scorr , and Tref must be defined specifically for the phase in
question.
197
isopentane 3,3-dimethyl-1-butene
neohexane cycloheptene
2,3-dimethylbutane cis-cyclooctene
2,2,3-trimethylbutane adamantane
2,2-dimethylpentane ethylcyclopentane
3,3-dimethylpentane 1,1-dimethylcyclohexane
methylcyclopentane ethylcyclohexane
methylcyclohexane cycloheptane
cis-1,2-dimethylcyclohexane cyclooctane
2,3-dimethyl-1-butene
A model for the nucleation of hydrate and ice phases is available. This model was de-
veloped as part of the Eucharis joint industry project. The Multiflash phase equilibrium
routines can be used to solve for the critical nucleation rate which characterises the onset of
hydrate or ice formation. Typically this will occur at lower temperature (at fixed pressure)
than the equilibrium dissociation point which is described by the thermodynamic models.
3. The critical parameters, acentric factor and molecular weight of the fluid of the interest
or for each component of the mixture of the interest.
The original method is not applicable to aqueous mixtures of alcohols, glycols or salts.
The Infochem implementation of SuperTRAPP model includes modification to ensure that
the viscosity of aqueous solutions of methanol, ethanol MEG, DEG and TEG or salts and ions
are predicted reasonably well. Two variants of the SuperTRAPP model are implemented:
2. Liquid viscosity fitting. An internal model parameter is adjusted to match the experi-
mental measurements.
49
Huber, M. L. and Hanley, H.J.M. (1996) The corresponding-states principle: Dense Fluids. In J. Millat,
J. H. Dymond and C. A. Nieto (Eds.), Transport properties of Fluids: Their correlation, Prediction and and
Estimation. Cambridge University Press.
198
I.2 Pedersen model
This is a predictive corresponding states model 50 based on the properties of methane as a
reference substance and applies to both gas and liquid states. It was developed specifically for
oil mixtures but is applicable to a wide range of oil, condensate and natural gas mixtures. The
information required for each component in the mixture is the critical temperature, critical
pressure and molecular weight. The original method is not applicable to polar mixtures but
the Infochem implementation includes a modification to ensure that the viscosity of liquid
water, methanol and glycols on the saturation line is accurately reproduced. An additional
modification ensures that the viscosity of the above compounds in liquid mixtures with water
is adequately predicted. Viscosities for water are accurately reproduced to 1000 bar and for
salt solutions up to 350 bar (which is the limit of experiential data).
Two variants of the Pedersen method are implemented.
2. Liquid viscosity fitting. An internal model parameter is is adjusted so that the pure
component saturated liquid viscosity (as obtained from the databank correlation) at
the boiling point is reproduced. This adjustment is not applied to the special polar
components listed above.
199
the thermodynamic models available in Multiflash. This has the advantage that if an equation
of state is used, there is no discontinuity in the dense phase region when moving between the
liquid-like and gas-like regions. Two variants of the LBC method are implemented.
1. Standard LBC method. The method described above is followed. The effective crit-
ical volume for petroleum fractions is obtained from the LBC correlation. For other
components the real critical volume is used.
2. Liquid viscosity fitting. The effective critical volume for all components is adjusted so
that the pure component saturated liquid viscosity (as obtained from the databank cor-
relation) at 60 F is reproduced. For components that are not liquids at this temperature
the standard method is used.
It is possible for both variants to specify the model parameters A1 to A5 . If these parameters
are not specified the default values for LBC are used. It is also possible for each component
to specify a critical volume specifically for the LBC model.
200
J.2 Super TRAPP thermal conductivity method
The Super TRAPP model 58 is an extended corresponding states model that can be used for
petroleum fluids, well-defined components and pure substances. The thermal conductivity
is usually defined as the sum of the internal contribution and the translational contribution.
The translational contribution can be defined as three parts: the dilute gas contribution, the
residual and critical enhancement contribution.
λ = λint + λdilute−gas + λres + λcrit (267)
For a mixture, the internal contribution λint can be estimated from the empirical mixing
and combining rules using the modified Eucken correlation for the individual components.
For the dilute gas term, the expression for the translational contribution is formulated as
15Rη 0 (T )
λdilute−gas = (268)
4M
where η 0 (T ) is the dilute gas viscosity given by Lucas correlation in unit of µP , M is the
molecular weight and the R is the gas constant.
The expression of the residual contribution term is evaluated using the extended cor-
responding state method and is related to the thermal conductivity of a reference fluid of
propane at a corresponding state, (ρres0 , T0 ).
201
K Surface tension
K.1 Linear Gradient Theory
This method predicts the interfacial tension between two phases. The possible pairs of
phases are: Liquid/Gas and Liquid/Liquid. The predition of interfacial tension between
Liquid/Solid and Gas/Solid phases is not yet possible. The model uses the difference in
densities between the two phases and the energy gradient that arrives from the fact that the
phases are immiscible to predict the interfacial tension61 .
Z ρref s
II
ρi (µi (ρ) − µeq
X
eq
σ= 2c( i ) − (P (ρ) − P )) (272)
ρref
I i
The variable c is characteristic of the mixture and varies with temperature. The mixing rule
used for this parameter is of the following type:
√
cij = cii cjj (1 − lij ) (273)
The parameter is the binary interaction parameter (BIP). And the parameter has to be
calculated along the interface gradient:
Nc
Nc X
X ∆ρi ∆ρj
c= cij (274)
i=1 j=1
∆ρref ∆ρref
As the Linear Gradient Theory model is defined in this particular way, an Equation of State
that can describe the interface between the two phases is necessary. The supported Equations
of State in Multiflash are SRK(A), PR(A), CPA, BWRS and SAFT. This method has more
reliable results with components present in the oil and gas processing, while using the SRK,
PR or CPA Equations of State.
61
Zuo, Y. X. and Stenby, E. H., A Linear Gradient Theory Model for Calculating Interfacial Tensions of
Mixtures, Journal of Colloid & Interface Science, 182 p12, Elsevier (1996)
62
R. C. Reid, J. M. Prausnitz and B. E. Poling, ‘The Properties of Gases and Liquids’, 4th. ed., McGraw-Hill,
New York, (1987), pp.640-643.
63
Sutton, Rovert; An Improved Model for Water-Hydrocarbon Surface Tension at Reservoir Conditions,
SPE 124968, 2009
202
Table 6: Correlation constants for the Sutton surface tension model
a1 = 0.272727 c1 = 1.53988
a2 = 0.821976 c2 = 2.08339
a3 = −1.83785 × 10−3 c3 = 1/a1 = 3.66667
a4 = 1.34016 × 10−6
a5 = 302.881
Where σhw is the interfacial tension between water and hydrcarbon phases, T is the
temperature in o R, Tc is the critical temperature of the hydrocarbon phase (o R), ρw and ρh
are the densities of the aqueous and hydrocarbon phases respectively in g/cm3 .
The correlation constants used are given in the following table.
L Diffusion coefficients
L.1 Fuller method for the vapour phase
The Fuller method calculates gas diffusion coefficients. It is an empirical modification of
Chapman-Enskog theory. The Fuller expression for the diffusion coefficient for components i
and j in SI units is:
!1/2
1.0112 × 10−22 T 1.75 kij 1 1
Dij = + (277)
1/3 2 Mi Mj
1/3
p Σi + Σj
where T is the temperature, p is the pressure, Mi is the molecular weight of component i and
Σ is a characteristic volume that is found for each component using Fuller’s tables. kij is an
empirical adjustment factor for the user to match the Fuller method to experimental data if
available; to obtain the standard result from Fuller’s method, kij should be set to unity. See
reference 65 .
203
where
1.02 × 10−5
= − 0.791 (279)
Vi
T is the temperature,Vi is the molar volume of component i and ηi is the liquid viscosity
of component i. The viscosity is calculated from the liquid viscosity model specified by the
user when the phase descriptor is defined. For details of the other correlations that form the
Hayduk-Minhas method see reference 66 .
Multiflash actually returns effective diffusion coefficients for a liquid of defined composi-
tion. The expression used is:
xj xi
0 0
Dij = Dij Dji kij α (280)
where
∂ ln γi ∂ ln γj
α = 1 + xi = 1 + xj (281)
∂xi ∂xj
wherewhere xi and γi are the mole fractions and activity coefficients of component i in the
binary mixture. For the sake of efficiency, the activity coefficients are calculated from the
Margules expression which in turn is fitted to the activity coefficients for an equimolar binary
mixture calculated with the thermodynamic model for the liquid phase specified in th ephase
descriptor definition. kij is an empirical adjustment factor for the user to match the calculated
result to experimental data if available; to obtain the standard result, kij should be set to
unity.
66
Chapter 11 of The Properties of Gases and Liquids, 5th. Ed. by Poling, Prausnitz and O’Connell,
McGraw-Hill, New York, 2001
204
M Nomenclature
a Equation of state parameter
Aij Activity coefficient equation interaction parameter
b Equation of state parameter
Cp Molar heat capacity at constant pressure
Cv Molar heat capacity at constant volume
GE Excess Gibbs energy
H Enthalpy
Hvap Enthalpy of vaporisation
kij Equation of state interaction parameter
M Molecular weight
n Number of moles
N Total number of moles
p Pressure
q UNIQUAC parameter
r UNIQUAC parameter
R Gas constant
S Entropy
T Temperature
V Volume
αij NRTL equation α parameter
γ Activity coefficient
η Viscosity
λ Thermal conductivity
Π Poynting correction
ρ Molar density
σ Surface tension
φ Fugacity coefficient
ω Acentric factor
Ω2,2 Collision integral for zero density viscosity
Subscripts:
0 Zero-density value
c Critical value
i, j Component numbers
r Reduced value
205
N Examples of use
N.1 Pure component properties
Vapour pressure and saturated liquid density for water as a function of temperature. Two
versions of the example are provided. The first uses low-level calls to initialise Multiflash and
the second uses a Multiflash command file and the command processor interface described in
section 17.
206
PRINT*,’Error initialising pure component data system’
GO TO 990
ENDIF
C
C Open INFODATA data bank:
C
JBANK(1) = JDINFO
CALL AYPDBO( 1, JBANK, 0, KDUM, LNODB, NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error opening INFODATA data bank’
GO TO 990
ENDIF
C
C Load pure component data for water:
C
IC(1) = 0
CALL AYPDBC( LNODB, ’WATER’, IC(1), NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
N = MIN( NERR, MXERR )
PRINT*,’Error loading data for water’
PRINT*,’Error flags: ’,(IERR(I),I=1,N)
GO TO 990
ENDIF
C
C Get critical temperature, melting point and enthlpy of formation
C
CALL AYPCNR( 0, IC, JTCRIT, TCRIT, NERR, MXERR, IERR )
CALL AYPCNR( 0, IC, JTMELT, TMELT, NERR, MXERR, IERR )
CALL AYPCNR( 0, IC, JHFORM, HFORM, NERR, MXERR, IERR )
C
C Evaluate vapour pressure and liquid density from melting point to
C critical point
C
WRITE(UNIT=*,FMT=9010) HFORM(1), TMELT(1), TCRIT(1)
NPTS = 10
DT = (TCRIT(1) - TMELT(1))/(NPTS-1)
DO 100 I = 1, NPTS
T = TMELT(1) + (I-1)*DT
CALL AYPSVP( 0, IC, T, .FALSE., VP, DUM, NERR, MXERR, IERR )
CALL AYPDNL( 0, IC, T, 0, DL, DUM, DUM, NERR, MXERR, IERR )
WRITE(UNIT=*,FMT=9020) T, VP(1), DL(1)
100 CONTINUE
C
C Close files and release licenses
C
990 CONTINUE
CALL MFEND()
STOP
C
9010 FORMAT(/T15,’WATER’/
+’ HForm: ’,G12.5,’ Tmelt: ’,G12.5,’ Tcrit: ’,G12.5/
+T4,’T’,T10,’Vap. Pres.’,T25,’Dens.’)
9020 FORMAT(1X,F6.1,T10,E12.6,T25,E12.6)
C
END
207
N.1.2 Command file initialisation
The file ex1a.mfl contains commands to set up the same databank as used in the previous
example but with a different component. The contents are as follows:
puredata infodata;
components nitrogen;
The following program processes the command file and evaluates the requested properties.
PROGRAM EX1A
C
C Example 1A:
C Updated: 23.09.05
C
C Table of pure component properties.
C Uses command file to initialise Multiflash.
C
C Dimensioning limits for Multiflash:
C
INCLUDE ’axpara.inc’
C
C Phase type identifiers:
C
INCLUDE ’ayptid.inc’
C
C Calculation codes for mixture properties:
C
INCLUDE ’ayjxid.inc’
C
C Dimensioning parameters for phase descriptors:
C
INCLUDE ’aympd.inc’
C
C databk.inc defines DIRNAM: the directory that contains the
C Multiflash databanks
C
INCLUDE ’databk.inc’
C
C ex1a.inc defines CMDFIL: the full pathname for the Multiflash
C command file for this example
C
INCLUDE ’ex1a.inc’
C
REAL*8 T, CP(1), S(1), H(1), DT, TSTART
INTEGER IC(MAXNCS), I, NPD, IPD(MAXPD), IPHID(MAXPHA), NC, NPTS,
+ NST, IST(MAXST), IERR1, IERRLS
CHARACTER*20 CNAME(MAXNCS), PDNAME(MAXPD), STNAME(MAXST)
CHARACTER*80 ERRMES
C
C Error reporting system:
C
INTEGER MXERR
PARAMETER (MXERR=10)
INTEGER NERR, IERR(MXERR)
C
C Initialise security system
C
208
CALL MFSINI( ’ ’, IERR1, IERRLS, ERRMES )
IF ( IERR1.NE.0 ) THEN
PRINT*,’Error requesting Multiflash license: ’, IERR1
PRINT*,’License system error code: ’, IERRLS
PRINT*,ERRMES
GO TO 990
ENDIF
C
C Read and process Multiflash command file to define databanks,
C components, models and phase descriptors:
C
CALL MFRDFL( CMDFIL, DIRNAM, ’*’, NC, IC, CNAME,
+ NPD, IPD, PDNAME, IPHID,
+ NST, IST, STNAME, NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error processing MF command file. Errors:’
PRINT*,(IERR(I),I=1,NERR)
GO TO 990
ENDIF
C
C Evaluate PG thermal properties
C
WRITE(UNIT=*,FMT=9010) CNAME(1)
IC(1) = 1
NPTS = 10
DT = 100.D0
TSTART = 100.D0
DO 100 I = 1, NPTS
T = TSTART + (I-1)*DT
CALL AYPHSI( 1, IC, T, .TRUE., H, S, CP, NERR, MXERR, IERR )
WRITE(UNIT=*,FMT=9020) T, CP(1), H(1), S(1)
100 CONTINUE
C
C Close files and release licenses
C
990 CONTINUE
CALL MFEND()
STOP
C
9010 FORMAT(/T15,A/T4,’T’,T10,’Cp’,T25,’H’,T40,’S’)
9020 FORMAT(1X,F6.1,T10,G14.6,T25,G14.6,T40,G14.6)
C
END
209
N.2 Thermodynamic and transport properties of a mixture
Thermodynamic properties and viscosity of a methane-heptane mixture are calculated from
the RKS equation of state and the LBC viscosity model. Two versions of the example are
provided. The first uses low-level calls to initialise Multiflash and the second uses a Multiflash
command file and the command processor interface described in section 17.
210
C
CALL MFSINI( ’ ’, IERR1, IERRLS, ERRMES )
IF ( IERR1.NE.0 ) THEN
PRINT*,’Error requesting Multiflash license: ’, IERR1
PRINT*,’License system error code: ’, IERRLS
PRINT*,ERRMES
GO TO 990
ENDIF
C
C Set calculation option flags for mixture properties
C
DATA DER, D0 / .TRUE., 7*.FALSE. /
C
C Set databank location:
C
CALL AYFLFL( DIRNAM )
C
C Initialize pure component data software:
C
CALL AYPINI( NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error initialising pure component data system’
GO TO 990
ENDIF
C
C Open INFODATA data bank:
C
JBANK(1) = JDINFO
CALL AYPDBO( 1, JBANK, 0, KDUM, LNODB, NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error opening INFODATA data bank’
GO TO 990
ENDIF
C
C Load pure component data:
C
NC = 2
DO 100 I = 1, NC
IC(I) = 0
100 CONTINUE
CNAME(1) = ’METHANE’
CALL AYPDBC( LNODB, CNAME(1), IC(1), NERR, MXERR, IERR )
CNAME(2) = ’HEPTANE’
CALL AYPDBC( LNODB, CNAME(2), IC(2), NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error loading compounds’
GO TO 990
ENDIF
C
C Initialise BIP module
C
CALL AYBINI
C
C Select "oilandgas" method for estimating BIPs
C
JBANK(1) = JBOG3
CALL AYPDBO( 1, JBANK, 0, KDUM, LNODBB, NERR, MXERR, IERR )
211
IF ( NERR.NE.0 ) THEN
PRINT*,’Error selecting "oilandgas" method’
GO TO 990
ENDIF
C
C Get BIP load number for RKS model using "oilandgas" correlation
C
INIT = .TRUE.
NMDL = 4
LMDL(1) = JMRKSA
LMDL(2) = JVRKS
LMDL(3) = JVRKS
LMDL(4) = JVVDW
N = 1
CALL AYBDBL( LNODBB, 0, IC, INIT, NMDL, LMDL, N, LNOB1, NERR,
+ MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error setting BIP values’
GO TO 990
ENDIF
C
C Initialise models and PD syatem:
C
CALL AYMINI( NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error initialising models module’
GO TO 990
ENDIF
C
C Load RKS model with BIPs set above
C
LMDL(5) = LNOB1
CALL AYLOAD( 5, LMDL, .TRUE., LNOTDM, NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error loading RKS model’
GO TO 990
ENDIF
C
C Load Pedersen viscosity model (standard version)
C
LMDL(1) = JMPDV
LMDL(2) = JVPDV
CALL AYLOAD( 2, LMDL, .TRUE., LNOVSM, NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error loading Pedersen viscosity model’
GO TO 990
ENDIF
C
C Load CLS thermal conductivity model (with pointer to RKS
C model for the volumetric properties)
C
LMDL(1) = JMCLS
LMDL(2) = LNOTDM
CALL AYLOAD( 2, LMDL, .TRUE., LNOTCM, NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error loading CLS thermal conductivity model’
GO TO 990
212
ENDIF
C
C Load Mcleod-Sugden surface tension model (1-phase version)
C
LMDL(1) = JMMCS
LMDL(2) = JV1PHA
LMDL(3) = LNOTDM
CALL AYLOAD( 3, LMDL, .TRUE., LNOST, NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error loading surface tension model’
GO TO 990
ENDIF
C
C Initialise PD specification array
C
DO 120 I = 1, MXMDPD
LNOMOD(I) = 0
120 CONTINUE
C
C Define Phase Descriptors for vapour and liquid phases (using
C the same thermodynamic model for fugacities, volumetric properties
C and thermal properties, plus the viscosity model and, for the
C liquid phase, the surface tension model
C (no model is defined for the thermal conductivity)
C
LNOMOD(1) = LNOTDM
LNOMOD(2) = LNOTDM
LNOMOD(3) = LNOTDM
LNOMOD(4) = LNOVSM
LNOMOD(5) = LNOTCM
CALL AYDFPD( VPHAS, 0, LNOMOD, IPDV, NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error defining vapour PD’
GO TO 990
ENDIF
LNOMOD(6) = LNOST
CALL AYDFPD( LPHAS, 0, LNOMOD, IPDL, NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error defining liquid PD’
GO TO 990
ENDIF
C
C Set equimolar composition
C
X(1) = 0.5D0
X(2) = 0.5D0
C
C Enthalpy and volume for gas phase at 300K, 1bar
C
T = 300.D0
P = 1.D5
CALL AYMIX( IPDV, JPHDEF, IPHID, AMBIG, ZCOMP, T, P, 0, IC, X,
+ DER, VV, DUM, DUM, ADUM,
+ D0, ADUM, ADUM, ADUM, ADUM,
+ JHTTOT, DER, HV, DUM, DUM, ADUM, S, DUM, DUM,
+ ADUM, NERR, MXERR, IERR )
C
213
C Viscosity and thermal conductivity for gas phase
C
CALL AYVISC( IPDV, T, P, 0, IC, X, DER, VISV, DUM,
+ DUM, ADUM, NERR, MXERR, IERR )
CALL AYTCND( IPDV, T, P, 0, IC, X, DER, TCV, DUM,
+ DUM, ADUM, NERR, MXERR, IERR )
C
C Liquid phase properties
C
CALL AYMIX( IPDL, JPHDEF, IPHID, AMBIG, ZCOMP, T, P, 0, IC, X,
+ DER, VL, DUM, DUM, ADUM,
+ D0, ADUM, ADUM, ADUM, ADUM,
+ JHTTOT, DER, HL, DUM, DUM, ADUM, S, DUM, DUM,
+ ADUM, NERR, MXERR, IERR )
CALL AYVISC( IPDL, T, P, 0, IC, X, DER, VISL, DUM,
+ DUM, ADUM, NERR, MXERR, IERR )
CALL AYTCND( IPDL, T, P, 0, IC, X, DER, TCL, DUM,
+ DUM, ADUM, NERR, MXERR, IERR )
CALL AYSURF( T, P, 0, IC, IPDL, X, 0, X, DER, ST, DUM,
+ DUM, ADUM, ADUM, NERR, MXERR, IERR )
C
C Output
C
WRITE(UNIT=*,FMT=9110) T, P
WRITE(UNIT=*,FMT=9120) (CNAME(I),X(I),I=1,NC)
WRITE(UNIT=*,FMT=9130) VV, VL, HV, HL, VISV, VISL, TCV, TCL, ST
C
C Close files and release licenses
C
990 CONTINUE
CALL MFEND()
STOP
C
9110 FORMAT(/’ T/K = ’,F8.3,’ P/Pa = ’,E12.6/
+ ’ COMPONENT’,T16,’Composition (mol)’)
9120 FORMAT(1X,A12,1X,G13.6)
9130 FORMAT(/T20,’vapour’,T35,’liquid’/
+’ Volume (m3)’,T20,2G15.6/
+’ Enthalpy (J)’,T20,2G15.6/
+’ Viscosity (Pas)’,T20,2G15.6/
+’ Th. Cond. (W/m/K)’,T20,2G15.6/
+’ Surface tension (N/m)’,T35,G15.6/)
C
END
214
pd LIQUID liquid Meos * * Mlvisc * Mst;
components METHANE HEPTANE;
The following program processes the command file and evaluates mixture properties.
PROGRAM EX2A
C
C Example 2A:
C Updated: 18.11.11
C
C Thermodynamic and transport properties for a mixture.
C As example 2 but use MF command file to set up models and phase
C descriptors.
C
C Dimensioning limits for Multiflash:
C
INCLUDE ’axpara.inc’
C
C Phase type identifiers:
C
INCLUDE ’ayptid.inc’
C
C Calculation codes for mixture properties:
C
INCLUDE ’ayjxid.inc’
C
C Dimensioning parameters for phase descriptors:
C
INCLUDE ’aympd.inc’
C
C Data bank location
C
INCLUDE ’databk.inc’
C
REAL*8 T, P, X(MAXNCS), VV, VL, HV, HL, S, DUM, ADUM(1), VISV,
+ VISL, ZCOMP, ST
INTEGER IC(MAXNCS), I, NPD, IPD(MAXPD), IPHID(MAXPHA), IPDL,
+ IPDV, NC, NST, IST(MAXST), IERR1, IERRLS
LOGICAL AMBIG, DER(0:3), D0(0:3)
CHARACTER*20 CNAME(MAXNCS), PDNAME(MAXPD), STNAME(MAXST)
CHARACTER*80 ERRMES
C
C Error reporting system:
C
INTEGER MXERR
PARAMETER (MXERR=10)
INTEGER NERR, IERR(MXERR)
C
C Initialise security system
C
CALL MFSINI( ’ ’, IERR1, IERRLS, ERRMES )
IF ( IERR1.NE.0 ) THEN
PRINT*,’Error requesting Multiflash license: ’, IERR1
PRINT*,’License system error code: ’, IERRLS
PRINT*,ERRMES
GO TO 990
ENDIF
C
215
C Set calculation option flags for mixture properties
C
DATA DER, D0 / .TRUE., 7*.FALSE. /
C
C Read and process Multiflash command file to define databanks,
C components, models and phase descriptors:
C
CALL MFRDFL( ’ex2a.mfl’, DIRNAM, ’*’, NC, IC, CNAME,
+ NPD, IPD, PDNAME, IPHID,
+ NST, IST, STNAME, NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error processing MF command file. Errors:’
PRINT*,(IERR(I),I=1,NERR)
GO TO 990
ENDIF
C
C Find PDs for gas and liquid phases
C
IPDV = 0
IPDL = 0
DO 100 I = 1, NPD
IF ( IPHID(I).EQ.VPHAS ) THEN
IPDV = IPD(I)
ELSEIF ( IPHID(I).EQ.LPHAS ) THEN
IPDL = IPD(I)
ENDIF
100 CONTINUE
C
C Set composition and conditions
C
DO 110 I = 1, NC
X(I) = 0.5D0
110 CONTINUE
T = 300.D0
P = 1.D5
C
IF ( IPDV.NE.0 ) THEN
C
C Enthalpy and volume for gas phase
C
CALL AYMIX( IPDV, JPHDEF, IPHID, AMBIG, ZCOMP, T, P, 0, IC, X,
+ DER, VV, DUM, DUM, ADUM,
+ D0, ADUM, ADUM, ADUM, ADUM,
+ JHTTOT, DER, HV, DUM, DUM, ADUM, S, DUM, DUM,
+ ADUM, NERR, MXERR, IERR )
C
C Viscosity for gas phase
C
CALL AYVISC( IPDV, T, P, 0, IC, X, DER, VISV, DUM,
+ DUM, ADUM, NERR, MXERR, IERR )
ELSE
VV = 0.D0
HV = 0.D0
VISV = 0.D0
ENDIF
C
C Liquid phase properties
216
C
IF ( IPDL.NE.0 ) THEN
CALL AYMIX( IPDL, JPHDEF, IPHID, AMBIG, ZCOMP, T, P, 0, IC, X,
+ DER, VL, DUM, DUM, ADUM,
+ D0, ADUM, ADUM, ADUM, ADUM,
+ JHTTOT, DER, HL, DUM, DUM, ADUM, S, DUM, DUM,
+ ADUM, NERR, MXERR, IERR )
CALL AYVISC( IPDL, T, P, 0, IC, X, DER, VISL, DUM,
+ DUM, ADUM, NERR, MXERR, IERR )
CALL AYSURF( T, P, 0, IC, IPDL, X, 0, X, DER, ST, DUM,
+ DUM, ADUM, ADUM, NERR, MXERR, IERR )
ELSE
VL = 0.D0
HL = 0.D0
VISL = 0.D0
ENDIF
C
C Output
C
WRITE(UNIT=*,FMT=9110) T, P
WRITE(UNIT=*,FMT=9120) (CNAME(I),X(I),I=1,NC)
WRITE(UNIT=*,FMT=9130) VV, VL, HV, HL, VISV, VISL, ST
C
C Close files and release licenses
C
990 CONTINUE
CALL MFEND()
STOP
C
9110 FORMAT(/’ T/K = ’,F8.3,’ P/Pa = ’,E12.6/
+ ’ COMPONENT’,T16,’Composition (mol)’)
9120 FORMAT(1X,A12,1X,G13.6)
9130 FORMAT(/T20,’vapour’,T35,’liquid’/
+’ Volume (m3)’,T17,2G15.6/
+’ Enthalpy (J)’,T17,2G15.6/
+’ Viscosity (Pas)’,T17,2G15.6/
+’ Surface tension (N/m)’,T32,G15.6/)
C
END
217
N.3 Simple flash with an equation of state
The API RKS equation of state is used for both phases.
PROGRAM EX3
C
C Example 3: Simple flash using API-RKS model,
C data from INFODATA
C Updated: 18.11.11
C
C Data bank i.d. codes:
C
INCLUDE ’ayjdbk.inc’
C
C Codes for models:
C
INCLUDE ’ayjmid.inc’
C
C Phase type identifiers:
C
INCLUDE ’ayptid.inc’
C
C Dimensioning limits for PD system:
C
INCLUDE ’aympd.inc’
C
C Calculation parameters for Multiflash:
C
INCLUDE ’axjnum.inc’
C
C Dimensioning limits for Multiflash:
C
INCLUDE ’axpara.inc’
C
C Data bank location
C
INCLUDE ’databk.inc’
C
REAL*8 T, P, NMOLIN(MAXNCS), X(MAXNCS,MAXPHA), NMOLPH(MAXPHA),
+ ZCOMP(MAXPHA), NMOLF
INTEGER LNOPD(MAXPHA), NP, IPHID(MAXPHA), ISTABO, LNODB, LNODBB,
+ N, IC(MAXNCS), LMDL(5), LNOB, LNO, LNOPDV, LNOPDL,
+ LNOMOD(MXMDPD), NC, I, J, IERROR, NMDL, NERR0, JBANK(1),
+ IERR1, IERRLS
CHARACTER*1 KDUM(1), KPHID(MAXPHA)
CHARACTER*8 KVERSN
CHARACTER*20 KDATE
CHARACTER*72 CNAME(MAXNCS)
CHARACTER*80 ERRMES
LOGICAL INIT, FATAL
C
C Error reporting system:
C
INTEGER MXERR
PARAMETER (MXERR=10)
INTEGER NERR, IERR(MXERR)
C
C Initialise security system
218
C
CALL MFSINI( ’ ’, IERR1, IERRLS, ERRMES )
IF ( IERR1.NE.0 ) THEN
PRINT*,’Error requesting Multiflash license: ’, IERR1
PRINT*,’License system error code: ’, IERRLS
PRINT*,ERRMES
GO TO 990
ENDIF
C
C Multiflash version
C
CALL MFVERS( KVERSN, KDATE )
C
C Set databank location:
C
CALL AYFLFL( DIRNAM )
C
C Initialize pure component data software:
C
CALL AYPINI( NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error initialising pure component data system’
GO TO 990
ENDIF
C
C Open INFODATA data bank:
C
JBANK(1) = JDINFO
CALL AYPDBO( 1, JBANK, 0, KDUM, LNODB, NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error opening databank’
GO TO 990
ENDIF
C
C Load pure component data:
C
NC = 2
DO 50 I = 1, NC
IC(I) = 0
50 CONTINUE
CNAME(1) = ’METHANE’
CALL AYPDBC( LNODB, CNAME(1), IC(1), NERR, MXERR, IERR )
CNAME(2) = ’ETHANE’
CALL AYPDBC( LNODB, CNAME(2), IC(2), NERR, MXERR, IERR )
C
C Initialise BIP module:
C
CALL AYBINI
C
C Select "oilandgas" method for estimating BIPs
C
JBANK(1) = JBOG3
CALL AYPDBO( 1, JBANK, 0, KDUM, LNODBB, NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error selecting "oilandgas" method’
GO TO 990
ENDIF
219
C
C Set BIPs for API RKS model using "oilandgas" correlation
C (BIP load number returned in LNOB)
C
INIT = .TRUE.
NMDL = 4
LMDL(1) = JMRKSA
LMDL(2) = JVAPI
LMDL(3) = JVRKS
LMDL(4) = JVVDW
N = 1
CALL AYBDBL( LNODBB, 0, IC, INIT, NMDL, LMDL, N, LNOB, NERR,
+ MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error setting BIP values’
GO TO 990
ENDIF
C
C Initialise models and PD syatem:
C
CALL AYMINI( NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error initialising models module’
GO TO 990
ENDIF
C
C Load API RKS model:
C (Model load number returned in LNO)
C
LMDL(5) = LNOB
CALL AYLOAD( 5, LMDL, .TRUE., LNO, NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error loading API RKS model’
GO TO 990
ENDIF
C
C Initialise and PD specification array
C
DO 100 I = 1, MXMDPD
LNOMOD(I) = 0
100 CONTINUE
C
C Define vapour and liquid PDs:
C The load numbers for the vapour and liquid PDs are LNOPDV and
C LNOPDL respectively.
C
LNOMOD(1) = LNO
LNOMOD(2) = LNO
LNOMOD(3) = LNO
CALL AYDFPD( VPHAS, 0, LNOMOD, LNOPDV, NERR, MXERR, IERR )
CALL AYDFPD( LPHAS, 0, LNOMOD, LNOPDL, NERR, MXERR, IERR )
C
C Initialise Multiflash and stream type system:
C
CALL AXINIT( NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error initialising Multiflash’
220
GO TO 990
ENDIF
C
C Set input conditions
C
T = 175.0D0
P = 1.0D5
NMOLIN(1) = 0.4D0
NMOLIN(2) = 0.6D0
NMOLF = 0.D0
DO 110 I = 1, NC
NMOLF = NMOLF + NMOLIN(I)
110 CONTINUE
C
C Perform a simple p,T flash (note use of default stream type 0)
C
CALL AXFL01( 0, T, P, MAXNCS, NMOLIN, 0, .FALSE., JXDOSC,
+ NP, LNOPD, X, NMOLPH, ZCOMP, IPHID, ISTABO,
+ 0, NERR, MXERR, IERR )
C
C Test error flags
C
CALL ERLAST( NERR, MXERR, IERR, NERR0, IERROR, FATAL )
C
C Display results on standard output
C
IF ( NERR.GT.0 ) THEN
IF ( FATAL ) THEN
WRITE(UNIT=*,FMT=9306) ’ERROR’, (IERR(I),I=1,NERR0)
ELSE
WRITE(UNIT=*,FMT=9306) ’WARNING’, (IERR(I),I=1,NERR0)
ENDIF
ENDIF
C
C Set phase types
C
DO 120 J = 1, NP
IF ( IPHID(J).EQ.VPHAS ) THEN
KPHID(J) = ’V’
ELSEIF ( IPHID(J).EQ.LPHAS ) THEN
KPHID(J) = ’L’
ELSE
KPHID(J) = ’?’
ENDIF
120 CONTINUE
C
C Display results
C
WRITE(UNIT=*,FMT=9300) KVERSN
WRITE(UNIT=*,FMT=9310) T, P, (J,J=1,NP)
IF ( .NOT.FATAL ) THEN
WRITE(UNIT=*,FMT=9312) ( LNOPD(J), KPHID(J),J=1,NP )
DO 360 I = 1, NC
WRITE(UNIT=*,FMT=9320) CNAME(I), NMOLIN(I),
+ (X(I,J),J=1,NP)
360 CONTINUE
WRITE(UNIT=*,FMT=9330) NMOLF, (NMOLPH(J),J=1,NP)
221
WRITE(UNIT=*,FMT=9340) (ZCOMP(J),J=1,NP)
ENDIF
C
C Close files and release licenses
C
990 CONTINUE
CALL MFEND()
STOP
C
9300 FORMAT(/’ EX3. isothermal flash’/’ Multiflash version: ’,A)
9306 FORMAT(/’ *** ’,A,’ FLAGS RETURNED:’/(1X,10I7))
9310 FORMAT(/’ T/K = ’,F8.3,’ P/Pa = ’,E12.6/
+ ’ COMPONENT’,T16,’Feed (mol)’,T31,’X’,I1:T44,’X’,I1:T57,’X’,
+I1:T70,’X’,I1)
9312 FORMAT(’ PD (phase) ->’,T30,I2,’ (’,A2,’)’,T43,
+I2,’ (’,A2,’)’,T56,I2,’ (’,A2,’)’,T69,I2,’ (’,A2,’)’)
9320 FORMAT(1X,A12,1X,5G13.6)
9330 FORMAT(’ No. moles’,T15,5G13.6)
9340 FORMAT(’ Compress.’,T28,4G13.6)
9390 FORMAT(1X,A,T28,4G13.6)
C
END
222
N.4 Simple flash with an activity model
The NRTL equation with user-entered BIPs is used for for the liquid phase with the RK
equation as gas phase correction. Pure component properties are taken from the Infodata
data bank:
PROGRAM EX4
C
C Example 4: Simple flash using RK eos and NRTL equation
C Updated: 18.11.11
C
C Data bank i.d. codes:
C
INCLUDE ’ayjdbk.inc’
C
C Codes for models:
C
INCLUDE ’ayjmid.inc’
C
C Phase type identifiers:
C
INCLUDE ’ayptid.inc’
C
C Dimensioning limits for PD system:
C
INCLUDE ’aympd.inc’
C
C BIP function ids
C
INCLUDE ’aybfid.inc’
C
C Calculation parameters for Multiflash:
C
INCLUDE ’axjnum.inc’
C
C Dimensioning limits for Multiflash:
C
INCLUDE ’axpara.inc’
C
C Data bank location
C
INCLUDE ’databk.inc’
C
REAL*8 T, P, NMOLIN(MAXNCS), X(MAXNCS,MAXPHA), NMOLPH(MAXPHA),
+ ZCOMP(MAXPHA), BCO(MAXNCS*(MAXNCS-1)/2), NMOLF
INTEGER LNOPD(MAXPHA), NP, IPHID(MAXPHA), ISTABO, LNODB,
+ IC(MAXNCS), LMDL(6), LNOB1, LNOB2, LNOB3, LNOGAS,
+ LNOLIQ, LNOPDV, LNOPDL, NC, LNOMOD(MXMDPD), I, J,
+ JBANK(1), IERR1, IERRLS
CHARACTER*1 KDUM(1), KPHID(MAXPHA)
CHARACTER*8 KVERSN
CHARACTER*20 KDATE
CHARACTER*72 CNAME(MAXNCS)
CHARACTER*80 ERRMES
LOGICAL FATAL
C
C Error reporting system:
C
223
INTEGER MXERR
PARAMETER (MXERR=10)
INTEGER NERR, IERR(MXERR)
C
C Initialise security system
C
CALL MFSINI( ’ ’, IERR1, IERRLS, ERRMES )
IF ( IERR1.NE.0 ) THEN
PRINT*,’Error requesting Multiflash license: ’, IERR1
PRINT*,’License system error code: ’, IERRLS
PRINT*,ERRMES
GO TO 990
ENDIF
C
C Multiflash version
C
CALL MFVERS( KVERSN, KDATE )
C
C Set databank location:
C
CALL AYFLFL( DIRNAM )
C
C Initialize pure component data software:
C
CALL AYPINI( NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error initialising pure component data system’
GO TO 990
ENDIF
C
C Open INFODATA data bank:
C
JBANK(1) = JDINFO
CALL AYPDBO( 1, JBANK, 0, KDUM, LNODB, NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error opening databank’
GO TO 990
ENDIF
C
C Load pure component data:
C
NC = 3
DO 50 I = 1, NC
IC(I) = 0
50 CONTINUE
CALL AYPDBC( LNODB, ’ACETONE’, IC(1), NERR, MXERR, IERR )
CALL AYPDBC( LNODB, ’WATER’, IC(2), NERR, MXERR, IERR )
CALL AYPDBC( LNODB, ’ETHANOL’, IC(3), NERR, MXERR, IERR )
C
C Initialise BIP module:
C
CALL AYBINI
C
C Set BIPs and get BIP load numbers LNOB1, LNOB2, LNOB3
C
C (Note: values below are for illustation only and are not realistic):
C
224
C Aij values
C (water-acetone)
BCO(1) = -500.0D0
C (ethanol-acetone)
BCO(2) = 3000.0D0
C (ethanol-water)
BCO(3) = 8000.0D0
LNOB1 = 0
CALL AYBUSR( 0, IC, .TRUE., LNOB1, JBFACT, 1, 0.0D0, BCO, 0.0D0,
+ 0.0D0, NERR, MXERR, IERR )
C
C Aji values
C (acetone-water)
BCO(1) = -6000.0D0
C (acetone-ethanol)
BCO(2) = 750.0D0
C (water-ethanol)
BCO(3) = -2500.0D0
LNOB2 = 0
CALL AYBUSR( 0, IC, .TRUE., LNOB2, JBFACT, 1, 0.0D0, BCO, 0.0D0,
+ 0.0D0, NERR, MXERR, IERR )
C
C Alphaij values
C (water-acetone/acetone-water)
BCO(1) = 0.3D0
C (ethanol-acetone/acetone-ethanol)
BCO(2) = 0.3D0
C (ethanol-water/water-ethanol)
BCO(3) = 0.3D0
LNOB3 = 0
CALL AYBUSR( 0, IC, .TRUE., LNOB3, JBFACT, 1, 0.0D0, BCO, 0.0D0,
+ 0.0D0, NERR, MXERR, IERR )
C
C Initialise models and PD system:
C
CALL AYMINI( NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error initialising models module’
GO TO 990
ENDIF
C
C Load gas-phase model with zero BIPs:
C
LMDL(1) = JMRKSA
LMDL(2) = JVRK
LMDL(3) = JVRKS
LMDL(4) = JVVDW
LMDL(5) = 0
CALL AYLOAD( 5, LMDL, .TRUE., LNOGAS, NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error loading RKS model’
PRINT*,(IERR(I),I=1,NERR)
GO TO 990
ENDIF
C
C Load NRTL model:
C
225
LMDL(1) = JMNRTL
LMDL(2) = JVVLE
LMDL(3) = LNOGAS
LMDL(4) = LNOB1
LMDL(5) = LNOB2
LMDL(6) = LNOB3
CALL AYLOAD( 6, LMDL, .TRUE., LNOLIQ, NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error loading NRTL model’
PRINT*,(IERR(I),I=1,NERR)
GO TO 990
ENDIF
C
C Initialise PD specification array
C
DO 100 I = 1, MXMDPD
LNOMOD(I) = 0
100 CONTINUE
C
C Define vapour and liquid PDs:
C
LNOMOD(1) = LNOGAS
LNOMOD(2) = LNOGAS
LNOMOD(3) = LNOGAS
CALL AYDFPD( VPHAS, 0, LNOMOD, LNOPDV, NERR, MXERR, IERR )
LNOMOD(1) = LNOLIQ
LNOMOD(2) = LNOLIQ
LNOMOD(3) = LNOLIQ
CALL AYDFPD( LPHAS, 0, LNOMOD, LNOPDL, NERR, MXERR, IERR )
C
C Initialise Multiflash and stream type system:
C
CALL AXINIT( NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error initialising Multiflash’
GO TO 990
ENDIF
C
C Set input conditions
C
T = 350.0D0
P = 1.0D5
NMOLIN(1) = 0.3D0
NMOLIN(2) = 0.2D0
NMOLIN(3) = 0.5D0
NMOLF = 0.D0
DO 110 I = 1, NC
NMOLF = NMOLF + NMOLIN(I)
110 CONTINUE
C
C Perform a simple p,T flash (note use of default stream type 0)
C
CALL AXFL01( 0, T, P, MAXNCS, NMOLIN, 0, .FALSE., JXDOSC,
+ NP, LNOPD, X, NMOLPH, ZCOMP, IPHID, ISTABO,
+ 0, NERR, MXERR, IERR )
C
C Test error flags
226
C
CALL ERLAST( NERR, MXERR, IERR, NERR0, IERROR, FATAL )
C
C Display results on standard output
C
IF ( NERR.GT.0 ) THEN
IF ( FATAL ) THEN
WRITE(UNIT=*,FMT=9306) ’ERROR’, (IERR(I),I=1,NERR0)
ELSE
WRITE(UNIT=*,FMT=9306) ’WARNING’, (IERR(I),I=1,NERR0)
ENDIF
ENDIF
C
C Set phase types
C
DO 120 J = 1, NP
IF ( IPHID(J).EQ.VPHAS ) THEN
KPHID(J) = ’V’
ELSEIF ( IPHID(J).EQ.LPHAS ) THEN
KPHID(J) = ’L’
ELSE
KPHID(J) = ’?’
ENDIF
120 CONTINUE
C
C Display results
C
WRITE(UNIT=*,FMT=9300) KVERSN
WRITE(UNIT=*,FMT=9310) T, P, (J,J=1,NP)
IF ( .NOT.FATAL ) THEN
WRITE(UNIT=*,FMT=9312) ( LNOPD(J), KPHID(J),J=1,NP )
DO 360 I = 1, NC
WRITE(UNIT=*,FMT=9320) CNAME(I), NMOLIN(I),
+ (X(I,J),J=1,NP)
360 CONTINUE
WRITE(UNIT=*,FMT=9330) NMOLF, (NMOLPH(J),J=1,NP)
WRITE(UNIT=*,FMT=9340) (ZCOMP(J),J=1,NP)
ENDIF
C
C Close files and release licenses
C
990 CONTINUE
CALL MFEND()
STOP
C
9300 FORMAT(/’ EX4. isothermal flash’/’ Multiflash version: ’,A)
9306 FORMAT(/’ *** ’,A,’ FLAGS RETURNED:’/(1X,10I7))
9310 FORMAT(/’ T/K = ’,F8.3,’ P/Pa = ’,E12.6/
+ ’ COMPONENT’,T16,’Feed (mol)’,T31,’X’,I1:T44,’X’,I1:T57,’X’,
+I1:T70,’X’,I1)
9312 FORMAT(’ PD (phase) ->’,T30,I2,’ (’,A2,’)’,T43,
+I2,’ (’,A2,’)’,T56,I2,’ (’,A2,’)’,T69,I2,’ (’,A2,’)’)
9320 FORMAT(1X,A12,1X,5G13.6)
9330 FORMAT(’ No. moles’,T15,5G13.6)
9340 FORMAT(’ Compress.’,T28,4G13.6)
9390 FORMAT(1X,A,T28,4G13.6)
C
227
END
228
N.5 Flash with hydrates
The gas hydrate model is loaded for both type I and type II hydrates using the PR equation
as the model for pure liquid water. Pure component properties are taken from the Infochem
data bank with BIPs all zero:
PROGRAM EX5
C
C Example 5: Simple flash using PR eos and hydrates models
C Updated: 18.11.11
C
C Data bank i.d. codes:
C
INCLUDE ’ayjdbk.inc’
C
C Codes for models:
C
INCLUDE ’ayjmid.inc’
C
C Phase type identifiers:
C
INCLUDE ’ayptid.inc’
C
C Dimensioning limits for PD system:
C
INCLUDE ’aympd.inc’
C
C Calculation parameters for Multiflash:
C
INCLUDE ’axjnum.inc’
C
C Dimensioning limits for Multiflash:
C
INCLUDE ’axpara.inc’
C
C Data bank location
C
INCLUDE ’databk.inc’
C
REAL*8 T, P, NMOLIN(MAXNCS), X(MAXNCS,MAXPHA), NMOLPH(MAXPHA),
+ ZCOMP(MAXPHA), NMOLF
INTEGER LNOPD(MAXPHA), NP, IPHID(MAXPHA), ISTABO, LNODB,
+ LMDL(5), LNO, LNO1, LNO2, LNOPDV, LNOPDL, LNOPDW, LNOPD1,
+ LNOPD2, LNOMOD(MXMDPD), NC, I, J, JBANK(1), IC(MAXNCS),
+ IERR1, IERRLS
CHARACTER*1 KDUM(1), KPHID(MAXPHA)
CHARACTER*8 KVERSN
CHARACTER*20 KDATE
CHARACTER*20 CNAME(MAXNCS), PDNAME(MAXPD)
CHARACTER*80 ERRMES
C
C Error reporting system:
C
INTEGER MXERR
PARAMETER (MXERR=10)
INTEGER NERR, IERR(MXERR)
C
C Initialise security system
229
C
CALL MFSINI( ’ ’, IERR1, IERRLS, ERRMES )
IF ( IERR1.NE.0 ) THEN
PRINT*,’Error requesting Multiflash license: ’, IERR1
PRINT*,’License system error code: ’, IERRLS
PRINT*,ERRMES
GO TO 990
ENDIF
C
C Multiflash version
C
CALL MFVERS( KVERSN, KDATE )
C
C Set databank location:
C
CALL AYFLFL( DIRNAM )
C
C Initialize pure component data software:
C
CALL AYPINI( NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error initialising pure component data system’
GO TO 990
ENDIF
C
C Open INFODATA data bank:
C
JBANK(1) = JDINFO
CALL AYPDBO( 1, JBANK, 0, KDUM, LNODB, NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error opening databank’
GO TO 990
ENDIF
C
C Load pure component data:
C
NC = 3
CNAME(1) = ’METHANE’
CNAME(2) = ’BUTANE’
CNAME(3) = ’WATER’
DO 50 I = 1, NC
IC(I) = 0
CALL AYPDBC( LNODB, CNAME(I), IC(I), NERR, MXERR, IERR )
50 CONTINUE
C
C Initialise models and PD syatem:
C
CALL AYMINI( NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error initialising models module’
GO TO 990
ENDIF
C
C Load PR equation for the fluid phases with zero BIPs:
C
LMDL(1) = JMPRA
LMDL(2) = JVPR
230
LMDL(3) = JVPR
LMDL(4) = JVVDW
LMDL(5) = 0
CALL AYLOAD( 5, LMDL, .TRUE., LNO, NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error loading PR model’
GO TO 990
ENDIF
C
C Load type I gas hydrate model:
C
LMDL(1) = JMHYD
LMDL(2) = JVTYP1
LMDL(3) = LNO
CALL AYLOAD( 3, LMDL, .TRUE., LNO1, NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error loading HYDRATE I model’
GO TO 990
ENDIF
C
C Load type II gas hydrate model:
C
LMDL(1) = JMHYD
LMDL(2) = JVTYP2
LMDL(3) = LNO
CALL AYLOAD( 3, LMDL, .TRUE., LNO2, NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error loading HYDRATE II model’
GO TO 990
ENDIF
C
C Initialise PD specification array
C
DO 100 I = 1, MXMDPD
LNOMOD(I) = 0
100 CONTINUE
C
C Define vapour, hydrocarbon liquid, aqueous liquid, hydrate I and
C hydrate II PDs:
C The load numbers for the vapour, hydrocarbon liquid, aqueous
C liquid, hydrate I and hydrate II PDs are LNOPDV, LNOPDL, LNOPDW,
C LNOPD1 and LNOPD2 respectively.
C
LNOMOD(1) = LNO
LNOMOD(2) = LNO
LNOMOD(3) = LNO
PDNAME(1) = ’GAS’
CALL AYDFPD( VPHAS, 0, LNOMOD, LNOPDV, NERR, MXERR, IERR )
PDNAME(2) = ’LIQUID’
CALL AYDFPD( LPHAS, 2, LNOMOD, LNOPDL, NERR, MXERR, IERR )
PDNAME(2) = ’WATER’
CALL AYDFPD( LPHAS, 3, LNOMOD, LNOPDW, NERR, MXERR, IERR )
LNOMOD(1) = LNO1
LNOMOD(2) = LNO1
LNOMOD(3) = LNO1
PDNAME(4) = ’HYDRATE1’
CALL AYDFPD( HPHAS, 3, LNOMOD, LNOPD1, NERR, MXERR, IERR )
231
LNOMOD(1) = LNO2
LNOMOD(2) = LNO2
LNOMOD(3) = LNO2
PDNAME(5) = ’HYDRATE2’
CALL AYDFPD( HPHAS, 3, LNOMOD, LNOPD2, NERR, MXERR, IERR )
C
C Initialise Multiflash and stream type system:
C
CALL AXINIT( NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error initialising Multiflash’
GO TO 990
ENDIF
C
C Set input conditions
C
T = 240.0D0
P = 1.0D5
NMOLIN(1) = 0.3D0
NMOLIN(2) = 0.2D0
NMOLIN(3) = 0.5D0
NMOLF = 1.D0
C
C Perform a simple p,T flash (note use of default stream type 0)
C
CALL AXFL01( 0, T, P, MAXNCS, NMOLIN, 0, .FALSE., JXDOSC,
+ NP, LNOPD, X, NMOLPH, ZCOMP, IPHID, ISTABO,
+ 0, NERR, MXERR, IERR )
IF ( NERR.GT.0 ) PRINT*,’NERR:’, NERR
C
C Set phase types
C
DO 120 J = 1, NP
IF ( LNOPD(J).EQ.LNOPDV ) THEN
KPHID(J) = ’V’
ELSEIF ( LNOPD(J).EQ.LNOPDL ) THEN
KPHID(J) = ’L’
ELSEIF ( LNOPD(J).EQ.LNOPDW ) THEN
KPHID(J) = ’W’
ELSEIF ( LNOPD(J).EQ.LNOPD1 ) THEN
KPHID(J) = ’HI’
ELSEIF ( LNOPD(J).EQ.LNOPD2 ) THEN
KPHID(J) = ’HII’
ELSE
KPHID(J) = ’?’
ENDIF
120 CONTINUE
C
C Display results
C
WRITE(UNIT=*,FMT=9300) KVERSN
WRITE(UNIT=*,FMT=9310) T, P
WRITE(UNIT=*,FMT=9312) ( LNOPD(J), KPHID(J),J=1,NP )
DO 360 I = 1, NC
WRITE(UNIT=*,FMT=9320) CNAME(I), NMOLIN(I), (X(I,J),J=1,NP)
360 CONTINUE
WRITE(UNIT=*,FMT=9330) NMOLF, (NMOLPH(J),J=1,NP)
232
WRITE(UNIT=*,FMT=9340) (ZCOMP(J),J=1,NP)
C
C Close files and release licenses
C
990 CONTINUE
CALL MFEND()
STOP
C
9300 FORMAT(/’ EX5. isothermal flash with hydrates’/
+’ Multiflash version: ’,A)
9310 FORMAT(/’ T/K = ’,F8.3,’ P/Pa = ’,E12.6/
+ ’ COMPONENT’,T16,’Feed (mol)’,T31,’phase mole fractions’)
9312 FORMAT(’ PD (phase) ->’,T30,I2,’ (’,A3,’)’,T43,
+I2,’ (’,A3,’)’,T56,I2,’ (’,A3,’)’,T69,I2,’ (’,A3,’)’)
9320 FORMAT(1X,A12,1X,5G13.6)
9330 FORMAT(’ No. moles’,T15,5G13.6)
9340 FORMAT(’ Compress.’,T28,4G13.6)
C
END
233
N.6 Flash and phase properties from LKP model
This example shows how some thermodynamic properties not directly returned by Multiflash
may be evaluated. Two versions of the example are provided. The first uses low-level calls
to initialise Multiflash and the second uses a Multiflash command file and the command
processor interface described in section 17.
234
+ DLARGE, DSMALL, DSQRTS
INTEGER LNOPD(MAXPHA), NP, IPHID(MAXPHA), ISTABO, IC(MAXNCS),
+ LMDL(6), LNOTD, LNOPDV, LNOPDL, LNOVVS, LNOLVS, NC,
+ I, J, NERR0, IDUM, LNOMOD(MXMDPD), LNODB, JBANK(1),
+ IERROR, IERRLS
LOGICAL FATAL, AMBIGP(MAXPHA), DER0(4), DERV(4), DERH(4),
+ DERVIS(4)
CHARACTER*1 KDUM(1)
CHARACTER*20 CNAME(MAXNCS), PDNAME(MAXPD)
CHARACTER*25 KSTAB
CHARACTER*80 ERRMES
C
C Error reporting system:
C
INTEGER MXERR
PARAMETER (MXERR=10)
INTEGER NERR, IERR(MXERR)
C
C Set calculation option flags for mixture properties
C
DATA DER0 / 4*.FALSE. /
DATA DERV / 3*.TRUE., .FALSE. /
DATA DERH / 2*.TRUE., 2*.FALSE. /
DATA DERVIS / .TRUE., 3*.FALSE. /
C
C Initialise licensing system
C
CALL MFSINI(’ ’, IERROR, IERRLS, ERRMES )
IF ( IERROR.NE.0 ) THEN
PRINT*,’Failure initialising security system.’
PRINT*,’IERRROR: ’, IERROR,’ IERRLS: ’, IERRLS
PRINT*,ERRMES
ENDIF
C
C Set databank location:
C
CALL AYFLFL( DIRNAM )
C
C Initialize pure component data software:
C
CALL AYPINI( NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error initialising pure component data system’
c GO TO 990
ENDIF
C
C Numerical parameters
C
CALL AYNUMV( DLARGE )
DSMALL = 1.D0/DLARGE
DSQRTS = SQRT( DSMALL )
C
C Open INFODATA data bank:
C
JBANK(1) = JDINFO
CALL AYPDBO( 1, JBANK, 0, KDUM, LNODB, NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
235
PRINT*,’Error opening databank’
c GO TO 990
ENDIF
C
C Load pure component data:
C
NC = 2
CNAME(1) = ’BUTANE’
CNAME(2) = ’CARBON DIOXIDE’
DO 100 I = 1, NC
IC(I) = 0
CALL AYPDBC( LNODB, CNAME(I), IC(I), NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error loading data for ’, CNAME(I)
c GO TO 990
ENDIF
100 CONTINUE
C
C Get molecular weights
C
CALL AYPCNR( 0, IC, JMOLWT, MOLWT, NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
WRITE(UNIT=*,FMT=9100)
ENDIF
C
C Initialise BIP module:
C
CALL AYBINI
C
C Initialise models and PD syatem:
C
CALL AYMINI( NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error initialising models module’
c GO TO 990
ENDIF
C
C Load thermodynamic property model with zero BIPs:
C
LMDL(1) = JMLKP
LMDL(2) = JVLKP
LMDL(3) = 0
CALL AYLOAD( 3, LMDL, .TRUE., LNOTD, NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error loading LKP model’
PRINT*,(IERR(I),I=1,NERR)
c GO TO 990
ENDIF
C
C Load vapour viscosity model
C
LMDL(1) = JMVVS1
CALL AYLOAD( 1, LMDL, .TRUE., LNOVVS, NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error loading vapour viscosity model’
c GO TO 990
ENDIF
236
C
C Load liquid viscosity model
C
LMDL(1) = JMLVS1
CALL AYLOAD( 1, LMDL, .TRUE., LNOLVS, NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error loading liquid viscosity model’
c GO TO 990
ENDIF
C
C Initialise PD specification array
C
DO 120 I = 1, MXMDPD
LNOMOD(I) = 0
120 CONTINUE
C
C Define vapour and liquid PDs:
C
LNOMOD(1) = LNOTD
LNOMOD(2) = LNOTD
LNOMOD(3) = LNOTD
LNOMOD(4) = LNOVVS
CALL AYDFPD( VPHAS, 0, LNOMOD, LNOPDV, NERR, MXERR, IERR )
LNOMOD(4) = LNOLVS
CALL AYDFPD( LPHAS, 0, LNOMOD, LNOPDL, NERR, MXERR, IERR )
C
C Initialise Multiflash and stream type system:
C
CALL AXINIT( NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
PRINT*,’Error initialising Multiflash’
c GO TO 990
ENDIF
C
C Set input conditions
C
T = 300.D0
P = 10.D5
NMOLIN(1) = 10.D0
NMOLIN(2) = 10.D0
C
C Perform a simple p,T flash (note use of default stream type 0)
C
CALL AXFL01( 0, T, P, MAXNCS, NMOLIN, 0, .FALSE., JXDOSC,
+ NP, LNOPD, X, NMOLPH, ZCOMP, IPHID, ISTABO,
+ 0, NERR, MXERR, IERR )
IF ( NERR.GT.0 ) THEN
NERR0 = MIN( NERR, MXERR )
FATAL = IERR(NERR0).GT.0
ELSE
FATAL = .FALSE.
ENDIF
C
C Set phase names
C
DO 220 J = 1, NP
IF ( LNOPD(J).EQ.LNOPDV ) THEN
237
PDNAME(J) = ’Vapour’
ELSEIF ( LNOPD(J).EQ.LNOPDL ) THEN
PDNAME(J) = ’Liquid’
ELSE
PDNAME(J) = ’Unknown’
ENDIF
220 CONTINUE
C
C Set stability label
C
IF ( ISTABO.EQ.JXSTUN ) THEN
KSTAB = ’UNSTABLE’
ELSEIF ( ISTABO.EQ.JXSTMU ) THEN
KSTAB = ’MARGINALLY UNSTABLE’
ELSEIF ( ISTABO.EQ.JXSTIN ) THEN
KSTAB = ’ON STABILITY LIMIT’
ELSEIF ( ISTABO.EQ.JXSTMS ) THEN
KSTAB = ’MARGINALLY STABLE’
ELSEIF ( ISTABO.EQ.JXSTST ) THEN
KSTAB = ’STABLE’
ELSE
KSTAB = ’UNSTABLE?’
ENDIF
C
C Calculate H/S/V for converged solutions
C
IF ( .NOT.FATAL ) THEN
NMOLF = 0.D0
DO 300 I = 1, NC
NMOLF = NMOLF + NMOLIN(I)
300 CONTINUE
VTOT = 0.D0
HTOT = 0.D0
STOT = 0.D0
DO 350 J = 1, NP
CALL AYMIX( LNOPD(J), JPHDEF, IDUM, AMBIGP(J), ZCOMP(J), T, P,
+ 0, IC, X(1,J), DERV, V(J), DVDT,
+ DVDP, ADUM, DER0, ADUM, ADUM, ADUM, ADUM,
+ JHTTOT, DERH, H(J), CP(J), DUM, ADUM,
+ S(J), DUM, DUM, ADUM, NERR, MXERR, IERR )
IF ( AMBIGP(J) ) PDNAME(J)(12:12) = ’*’
VTOT = VTOT + NMOLPH(J)*V(J)
HTOT = HTOT + NMOLPH(J)*H(J)
STOT = STOT + NMOLPH(J)*S(J)
G(J) = H(J) - T*S(J)
U(J) = H(J) - P*V(J)
WORK = T*DVDT**2/SIGN( MAX( ABS(DVDP), DSQRTS ), DVDP )
CV(J) = CP(J) + WORK
C
C Average molar mass (g/mol) and mass density
C
AVMW(J) = 0.D0
DO 340 I = 1, NC
AVMW(J) = AVMW(J) + X(I,J)*MOLWT(I)
340 CONTINUE
AVMW(J) = MAX( DSQRTS, AVMW(J) )
RHO(J) = AVMW(J)/MAX( DSQRTS, V(J) )*1.D-3
238
C
C Calculate speed of sound
C
WORK = -CV(J)*AVMW(J)*DVDP*1.D-3
WORK = CP(J)*V(J)**2/MAX( WORK, DSQRTS )
SSOUND(J) = SQRT( MAX( WORK, DSMALL ) )
C
C Get viscosity
C
CALL AYVISC( LNOPD(J), T, P, 0, IC, X(1,J), DERVIS,
+ ETA(J), DUM, DUM, ADUM, NERR, MXERR, IERR )
C
350 CONTINUE
UTOT = HTOT - P * VTOT
GTOT = HTOT - T * STOT
ENDIF
C
C Display results on standard output
C
IF ( NERR.GT.0 ) THEN
IF ( FATAL ) THEN
WRITE(UNIT=*,FMT=9306) ’ERROR’, (IERR(I),I=1,NERR0)
ELSE
WRITE(UNIT=*,FMT=9306) ’WARNING’, (IERR(I),I=1,NERR0)
ENDIF
ENDIF
WRITE(UNIT=*,FMT=9310) T, P
WRITE(UNIT=*,FMT=9312) ( PDNAME(J),J=1,NP )
DO 360 I = 1, NC
WRITE(UNIT=*,FMT=9320) CNAME(I), NMOLIN(I), (X(I,J),J=1,NP)
360 CONTINUE
WRITE(UNIT=*,FMT=9330) NMOLF, (NMOLPH(J),J=1,NP)
WRITE(UNIT=*,FMT=9340) (ZCOMP(J),J=1,NP)
IF ( .NOT.FATAL ) THEN
WRITE(UNIT=*,FMT=9342) (’molar’,J=1,NP)
WRITE(UNIT=*,FMT=9345) GTOT, (G(J),J=1,NP)
WRITE(UNIT=*,FMT=9350) HTOT, (H(J),J=1,NP)
WRITE(UNIT=*,FMT=9360) STOT, (S(J),J=1,NP)
WRITE(UNIT=*,FMT=9370) VTOT, (V(J),J=1,NP)
WRITE(UNIT=*,FMT=9380) UTOT, (U(J),J=1,NP)
WRITE(UNIT=*,FMT=9390) ’ ’
WRITE(UNIT=*,FMT=9390) ’Cp/J K-1 mol-1’, (CP(J),J=1,NP)
WRITE(UNIT=*,FMT=9390) ’Cv/J K-1 mol-1’, (CV(J),J=1,NP)
WRITE(UNIT=*,FMT=9390) ’Ssound/ m s-1’, (SSOUND(J),J=1,NP)
WRITE(UNIT=*,FMT=9390) ’Mw/g mol-1’, (AVMW(J),J=1,NP)
WRITE(UNIT=*,FMT=9390) ’Rho/kg m-3’, (RHO(J),J=1,NP)
WRITE(UNIT=*,FMT=9390) ’Viscosity/Pa s’, (ETA(J),J=1,NP)
WRITE(UNIT=*,FMT=9410) KSTAB
ENDIF
C
990 CONTINUE
C
C Close licensing system
C
CALL MFSCLO()
STOP
C
239
9100 FORMAT(’ Cannot get molecular weights..’)
9306 FORMAT(/’ *** ’,A,’ FLAGS RETURNED:’/(1X,10I7))
9310 FORMAT(/’ T/K = ’,F8.3,’ P/Pa = ’,E12.6/
+ ’ COMPONENT’,T16,’Feed (mol)’,T31,’phase mole fractions’)
9312 FORMAT(’ (PD name) ->’,T30,A12,T43,A12,T56,A12,T69,A12)
9320 FORMAT(1X,A12,1X,5G13.6)
9330 FORMAT(’ No. moles’,T15,5G13.6)
9340 FORMAT(’ Compress.’,T28,4G13.6)
9342 FORMAT(T16,’total’,:T31,A:T46,A:T61,A)
9345 FORMAT(’ G/J’,T15,5G13.6)
9350 FORMAT(’ H/J’,T15,5G13.6)
9360 FORMAT(’ S/J K-1’,T15,5G13.6)
9370 FORMAT(’ V/m3’,T15,5G13.6)
9380 FORMAT(’ U/J’,T15,5G13.6)
9390 FORMAT(1X,A,T28,4G13.6)
9410 FORMAT(’ System is ’,A/)
C
END
The following program processes the command file and carries out a flash calculation and
dew point calculation followed by property evaluations.
PROGRAM EX6A
C
C Example 6A:
C Updated: 18.11.11
C
C Simple P,T flash, dew point and bubble point calculations.
C Similar to example 6 but uses MF command file to set up compounds,
C models and phase descriptors.
C
C Phase type identifiers:
C
INCLUDE ’ayptid.inc’
C
C Dimensioning limits for PD system:
C
INCLUDE ’aympd.inc’
C
C Calculation parameters for Multiflash:
C
INCLUDE ’axjnum.inc’
C
C Dimensioning limits for Multiflash:
240
C
INCLUDE ’axpara.inc’
C
C Calculation codes for mixture properties:
C
INCLUDE ’ayjxid.inc’
C
C Physical property identifiers
C
INCLUDE ’ayjpid.inc’
C
C Data bank location
C
INCLUDE ’databk.inc’
C
REAL*8 T, P, NMOLIN(MAXNCS), X(MAXNCS,MAXPHA), NMOLPH(MAXPHA),
+ ZCOMP(MAXPHA),
+ H(MAXPHA), S(MAXPHA), V(MAXPHA), HTOT, STOT, VTOT, UTOT,
+ GTOT, DUM, U(MAXPHA), G(MAXPHA), CP(MAXPHA), NMOLF,
+ CV(MAXPHA), ADUM(MAXNCS), DVDT, DVDP, WORK, ETA(MAXNCS),
+ MOLWT(MAXNCS), SSOUND(MAXPHA), AVMW(MAXPHA), RHO(MAXPHA),
+ DLARGE, DSMALL, DSQRTS, TARGET, PSAT, VAR, SIGMA(MAXPHA)
INTEGER IPD(MAXPD), NP, IPHID(MAXPHA), ISTABO, IC(MAXNCS), NPD,
+ I, J, NERR0, IDUM, LNOPD(MAXPHA), NST, IST(MAXST), NC,
+ IGAS, ILIQ, IPROB(3), IPD2(MAXPD), IST2, IERR1, IERRLS
LOGICAL FATAL, AMBIGP(MAXNCS), DER0(4), DERV(4), DERH(4),
+ DERVIS(4)
CHARACTER*12 PDNOUT(MAXPHA)
CHARACTER*20 CNAME(MAXNCS), PDNAME(MAXPD), STNAME(MAXST)
CHARACTER*25 KSTAB
CHARACTER*80 ERRMES
C
C Error reporting system:
C
INTEGER MXERR
PARAMETER (MXERR=10)
INTEGER NERR, IERR(MXERR)
C
C Set calculation option flags for mixture properties
C
DATA DER0 / 4*.FALSE. /
DATA DERV / 3*.TRUE., .FALSE. /
DATA DERH / 2*.TRUE., 2*.FALSE. /
DATA DERVIS / .TRUE., 3*.FALSE. /
C
C Initialise security system
C
CALL MFSINI( ’ ’, IERR1, IERRLS, ERRMES )
IF ( IERR1.NE.0 ) THEN
PRINT*,’Error requesting Multiflash license: ’, IERR1
PRINT*,’License system error code: ’, IERRLS
PRINT*,ERRMES
GO TO 990
ENDIF
C
C Read and process Multiflash command file to define databanks,
C components, models and phase descriptors:
241
C
CALL MFRDFL( ’ex6a.mfl’, DIRNAM, ’*’, NC, IC, CNAME,
+ NPD, IPD, PDNAME, IPHID,
+ NST, IST, STNAME, NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
WRITE(UNIT=*,FMT=9306)’Error processing MF command file.’,
+ (IERR(I),I=1,NERR)
GO TO 990
ENDIF
C
C Find (the first) gas phase and liquid phase
C
IGAS = 0
ILIQ = 0
DO I = 1, NPD
IF ( IGAS.EQ.0 .AND. IPHID(I).EQ.VPHAS ) THEN
IGAS = IPD(I)
ELSEIF ( ILIQ.EQ.0 .AND. IPHID(I).EQ.LPHAS ) THEN
ILIQ = IPD(I)
ENDIF
END DO
C
C Numerical parameters
C
CALL AYNUMV( DLARGE )
DSMALL = 1.D0/DLARGE
DSQRTS = SQRT( DSMALL )
C
C Get molecular weights
C
CALL AYPCNR( 0, IC, JMOLWT, MOLWT, NERR, MXERR, IERR )
IF ( NERR.NE.0 ) THEN
WRITE(UNIT=*,FMT=9100)
ENDIF
C
C Set input conditions
C
T = 300.D0
P = 10.D5
C
C Equimolar composition
C
DO I = 1, NC
NMOLIN(I) = 1.D0
END DO
C
C Perform a simple p,T flash (note use of default stream type 0)
C
CALL AXFL01( 0, T, P, MAXNCS, NMOLIN, 0, .FALSE., JXDOSC,
+ NP, LNOPD, X, NMOLPH, ZCOMP, IPHID, ISTABO,
+ 0, NERR, MXERR, IERR )
IF ( NERR.GT.0 ) THEN
NERR0 = MIN( NERR, MXERR )
FATAL = IERR(NERR0).GT.0
ELSE
FATAL = .FALSE.
ENDIF
242
C
C Set phase names
C
DO J = 1, NP
DO I = 1, NPD
IF ( LNOPD(J).EQ.IPD(I) ) THEN
PDNOUT(J) = PDNAME(I)
EXIT
ENDIF
END DO
END DO
C
C Set stability label
C
IF ( ISTABO.EQ.JXSTUN ) THEN
KSTAB = ’UNSTABLE’
ELSEIF ( ISTABO.EQ.JXSTMU ) THEN
KSTAB = ’MARGINALLY UNSTABLE’
ELSEIF ( ISTABO.EQ.JXSTIN ) THEN
KSTAB = ’ON STABILITY LIMIT’
ELSEIF ( ISTABO.EQ.JXSTMS ) THEN
KSTAB = ’MARGINALLY STABLE’
ELSEIF ( ISTABO.EQ.JXSTST ) THEN
KSTAB = ’STABLE’
ELSE
KSTAB = ’UNSTABLE?’
ENDIF
C
C Calculate H/S/V for converged solutions
C
IF ( .NOT.FATAL ) THEN
NMOLF = 0.D0
DO I = 1, NC
NMOLF = NMOLF + NMOLIN(I)
END DO
VTOT = 0.D0
HTOT = 0.D0
STOT = 0.D0
DO J = 1, NP
CALL AYMIX( LNOPD(J), JPHDEF, IDUM, AMBIGP(J), ZCOMP(J), T, P,
+ 0, IC, X(1,J), DERV, V(J), DVDT,
+ DVDP, ADUM, DER0, ADUM, ADUM, ADUM, ADUM,
+ JHTTOT, DERH, H(J), CP(J), DUM, ADUM,
+ S(J), DUM, DUM, ADUM, NERR, MXERR, IERR )
IF ( AMBIGP(J) ) PDNOUT(J)(12:12) = ’*’
VTOT = VTOT + NMOLPH(J)*V(J)
HTOT = HTOT + NMOLPH(J)*H(J)
STOT = STOT + NMOLPH(J)*S(J)
G(J) = H(J) - T*S(J)
U(J) = H(J) - P*V(J)
WORK = T*DVDT**2/SIGN( MAX( ABS(DVDP), DSQRTS ), DVDP )
CV(J) = CP(J) + WORK
C
C Average molar mass (g/mol) and mass density
C
AVMW(J) = 0.D0
DO I = 1, NC
243
AVMW(J) = AVMW(J) + X(I,J)*MOLWT(I)
END DO
AVMW(J) = MAX( DSQRTS, AVMW(J) )
RHO(J) = AVMW(J)/MAX( DSQRTS, V(J) )*1.D-3
C
C Calculate and speed of sound
C
WORK = -CV(J)*AVMW(J)*DVDP*1.D-3
WORK = CP(J)*V(J)**2/MAX( WORK, DSQRTS )
SSOUND(J) = SQRT( MAX( WORK, DSMALL ) )
C
C Viscosity
C
CALL AYVISC( LNOPD(J), T, P, NC, IC, X(1,J), DERVIS,
+ ETA(J), DUM, DUM, ADUM, NERR, MXERR, IERR )
C
C Surface tension
C
IF ( IPHID(J).EQ.LPHAS ) THEN
CALL AYSURF( T, P, NC, IC, LNOPD(J), X(1,J), 0, ADUM,
+ DERVIS, SIGMA(J), DUM, DUM, ADUM, ADUM,
+ NERR, MXERR, IERR )
ELSE
SIGMA(J) = 0.D0
ENDIF
C
END DO
UTOT = HTOT - P * VTOT
GTOT = HTOT - T * STOT
ENDIF
C
C Display results on standard output
C
IF ( NERR.GT.0 ) THEN
IF ( FATAL ) THEN
WRITE(UNIT=*,FMT=9306) ’ERROR’, (IERR(I),I=1,NERR0)
ELSE
WRITE(UNIT=*,FMT=9306) ’WARNING’, (IERR(I),I=1,NERR0)
ENDIF
ENDIF
WRITE(UNIT=*,FMT=9310) T, P
WRITE(UNIT=*,FMT=9312) ( PDNOUT(J),J=1,NP )
DO I = 1, NC
WRITE(UNIT=*,FMT=9320) CNAME(I), NMOLIN(I), (X(I,J),J=1,NP)
END DO
WRITE(UNIT=*,FMT=9330) NMOLF, (NMOLPH(J),J=1,NP)
WRITE(UNIT=*,FMT=9340) (ZCOMP(J),J=1,NP)
IF ( .NOT.FATAL ) THEN
WRITE(UNIT=*,FMT=9342) (’molar’,J=1,NP)
WRITE(UNIT=*,FMT=9345) GTOT, (G(J),J=1,NP)
WRITE(UNIT=*,FMT=9350) HTOT, (H(J),J=1,NP)
WRITE(UNIT=*,FMT=9360) STOT, (S(J),J=1,NP)
WRITE(UNIT=*,FMT=9370) VTOT, (V(J),J=1,NP)
WRITE(UNIT=*,FMT=9380) UTOT, (U(J),J=1,NP)
WRITE(UNIT=*,FMT=9390) ’ ’
WRITE(UNIT=*,FMT=9390) ’Cp/J K-1 mol-1’, (CP(J),J=1,NP)
WRITE(UNIT=*,FMT=9390) ’Cv/J K-1 mol-1’, (CV(J),J=1,NP)
244
WRITE(UNIT=*,FMT=9390) ’Ssound/ m s-1’, (SSOUND(J),J=1,NP)
WRITE(UNIT=*,FMT=9390) ’Mw/g mol-1’, (AVMW(J),J=1,NP)
WRITE(UNIT=*,FMT=9390) ’Rho/kg m-3’, (RHO(J),J=1,NP)
WRITE(UNIT=*,FMT=9390) ’Viscosity/Pa s’, (ETA(J),J=1,NP)
WRITE(UNIT=*,FMT=9390) ’Surface tension/Nm-1’, (SIGMA(J),J=1,NP)
WRITE(UNIT=*,FMT=9410) KSTAB
ENDIF
C
C Set up a stream type containing 1 gas phase and 1 liquid phase for
C dew and bubble point calculations
C
IF ( IGAS.NE.0 .AND. ILIQ.NE.0 ) THEN
IPD2(1) = IGAS
IPD2(2) = ILIQ
CALL AXDFST( NC, IC, 2, IPD2, IST2, NERR, MXERR, IERR )
IF ( NERR.GT.0 ) THEN
WRITE(UNIT=*,FMT=9306) ’Failure defining stream type’,
+ (IERR(I),I=1,NERR)
GO TO 990
ENDIF
C
C Dew point pressure calculation (0 phase fraction of liquid)
C
IPROB(1) = JXPHML
IPROB(2) = ILIQ
IPROB(3) = JSDEF
TARGET = 0.D0
CALL AXFL02( IST2, JXPRES, T, PSAT, VAR, MAXNCS, NMOLIN, 2,
+ IPROB, TARGET, .FALSE., .FALSE., JXDOSC,
+ NP, LNOPD, X, NMOLPH, ZCOMP, IPHID, ISTABO,
+ -1, NERR, MXERR, IERR )
IF ( NERR.GT.0 ) THEN
WRITE(UNIT=*,FMT=9306) ’Failure calculating dew point’,
+ (IERR(I),I=1,NERR)
GO TO 990
ENDIF
DO J = 1, NP
DO I = 1, NPD
IF ( LNOPD(J).EQ.IPD(I) ) THEN
PDNOUT(J) = PDNAME(I)
EXIT
ENDIF
END DO
END DO
WRITE(UNIT=*,FMT=9420) T, ’dew point’, PSAT
WRITE(UNIT=*,FMT=9312) ( PDNOUT(J),J=1,NP )
DO I = 1, NC
WRITE(UNIT=*,FMT=9320) CNAME(I), NMOLIN(I), (X(I,J),J=1,NP)
END DO
WRITE(UNIT=*,FMT=9330) NMOLF, (NMOLPH(J),J=1,NP)
WRITE(UNIT=*,FMT=9340) (ZCOMP(J),J=1,NP)
C
C Bubble point pressure calculation (0 phase fraction of gas)
C
IPROB(2) = IGAS
CALL AXFL02( IST2, JXPRES, T, PSAT, VAR, MAXNCS, NMOLIN, 2,
+ IPROB, TARGET, .FALSE., .FALSE., JXDOSC,
245
+ NP, LNOPD, X, NMOLPH, ZCOMP, IPHID, ISTABO,
+ -1, NERR, MXERR, IERR )
IF ( NERR.GT.0 ) THEN
WRITE(UNIT=*,FMT=9306) ’Failure calculating dew point’,
+ (IERR(I),I=1,NERR)
GO TO 990
ENDIF
DO J = 1, NP
DO I = 1, NPD
IF ( LNOPD(J).EQ.IPD(I) ) THEN
PDNOUT(J) = PDNAME(I)
EXIT
ENDIF
END DO
END DO
WRITE(UNIT=*,FMT=9420) T, ’bubble point’, PSAT
WRITE(UNIT=*,FMT=9312) ( PDNOUT(J),J=1,NP )
DO I = 1, NC
WRITE(UNIT=*,FMT=9320) CNAME(I), NMOLIN(I), (X(I,J),J=1,NP)
END DO
WRITE(UNIT=*,FMT=9330) NMOLF, (NMOLPH(J),J=1,NP)
WRITE(UNIT=*,FMT=9340) (ZCOMP(J),J=1,NP)
ENDIF
C
C Close files and release licenses
C
990 CONTINUE
CALL MFEND()
STOP
C
9100 FORMAT(’ Cannot get molecular weights..’)
9306 FORMAT(/’ *** ’,A/’ Status codes returned:’/(1X,10I7))
9310 FORMAT(/’ T/K = ’,F8.3,’ P/Pa = ’,E12.6/
+ ’ COMPONENT’,T16,’Feed (mol)’,T31,’phase mole fractions’)
9312 FORMAT(’ (PD name) ->’,T30,A12,T43,A12,T56,A12,T69,A12)
9320 FORMAT(1X,A12,1X,5G13.6)
9330 FORMAT(’ No. moles’,T15,5G13.6)
9340 FORMAT(’ Z comp.’,T28,4G13.6)
9342 FORMAT(T16,’total’,:T31,A:T46,A:T61,A)
9345 FORMAT(’ G/J’,T15,5G13.6)
9350 FORMAT(’ H/J’,T15,5G13.6)
9360 FORMAT(’ S/J K-1’,T15,5G13.6)
9370 FORMAT(’ V/m3’,T15,5G13.6)
9380 FORMAT(’ U/J’,T15,5G13.6)
9390 FORMAT(1X,A,T28,4G13.6)
9410 FORMAT(’ System is ’,A/)
9420 FORMAT(/’ T/K = ’,F8.3,’ ’,A,’ P/Pa = ’,E12.6/
+ ’ COMPONENT’,T16,’Feed (mol)’,T31,’phase mole fractions’)
C
END
246