0% found this document useful (0 votes)
176 views247 pages

MFP Guide 43

Uploaded by

ToufikNech
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
176 views247 pages

MFP Guide 43

Uploaded by

ToufikNech
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 247

MULTIFLASH PROGRAMMER’S GUIDE

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

4 Defining pure components and data sources 17


4.1 Initialisation sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.2 Initialisation of the pure component data software . . . . . . . . . . . . . . . 17
4.3 Databank files used by Multiflash . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.4 Opening pure component databanks . . . . . . . . . . . . . . . . . . . . . . . 18
4.5 Unloading databanks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.6 Loading pure component data . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.7 Loading components from a databank . . . . . . . . . . . . . . . . . . . . . . 20
4.8 Defining a component by entering data directly . . . . . . . . . . . . . . . . . 21
4.8.1 Entering numerical constants . . . . . . . . . . . . . . . . . . . . . . . 21
4.8.2 Setting numerical constants to undefined . . . . . . . . . . . . . . . . 22
4.8.3 Entering character constants . . . . . . . . . . . . . . . . . . . . . . . 23
4.8.4 Entering correlations for temperature-dependent properties . . . . . . 24
4.8.5 Entering Unifac subgroup structures . . . . . . . . . . . . . . . . . . . 25
4.9 Petroleum fractions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.9.1 Correlations for petroleum fraction properties . . . . . . . . . . . . . . 26
4.9.2 Defining petroleum fractions . . . . . . . . . . . . . . . . . . . . . . . 27
4.10 Searching for compounds on a databank . . . . . . . . . . . . . . . . . . . . . 29
4.10.1 AYPDBI: Search for a compound name: . . . . . . . . . . . . . . . . . . 29
4.10.2 AYPDBS: Search for compound names containing specified string: . . . 30
4.10.3 AYPDBY: Return synonyms for compound name: . . . . . . . . . . . . . 30
4.10.4 AYPDBF: Search for compounds with specified formula: . . . . . . . . . 31
4.11 Reading data directly from a databank . . . . . . . . . . . . . . . . . . . . . . 32
4.11.1 AYPDBK: Pure component character data: . . . . . . . . . . . . . . . . . 32
4.11.2 AYPDBV: Pure component real-valued constant data: . . . . . . . . . . 33
4.12 Other utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.12.1 AYPNC1: Number of components defined: . . . . . . . . . . . . . . . . . 33

2
4.12.2 AYPDEL: Delete data for a component: . . . . . . . . . . . . . . . . . . 33
4.12.3 AYSALN: Equivalent salt component/ions concentration: . . . . . . . . 34

5 Evaluating pure component properties 36


5.1 Summary of routines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
5.2 Use of NCO and IC arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
5.3 Constant properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
5.3.1 AYPCNK: character valued constants . . . . . . . . . . . . . . . . . . . . 36
5.3.2 AYPCNR: real valued constants . . . . . . . . . . . . . . . . . . . . . . . 37
5.3.3 AYPCNS: status of constants . . . . . . . . . . . . . . . . . . . . . . . . 38
5.3.4 AYPHC: test for hydrocarbons . . . . . . . . . . . . . . . . . . . . . . . 38
5.4 Temperature-dependent properties . . . . . . . . . . . . . . . . . . . . . . . . 38
5.4.1 AYPDIE: dielectric constant of liquid . . . . . . . . . . . . . . . . . . . 39
5.4.2 AYPDNL: density of liquid on the saturation line . . . . . . . . . . . . . 39
5.4.3 AYPHLV: enthalpy change on evaporation (latent heat) . . . . . . . . . 40
5.4.4 AYPHSI: perfect gas enthalpy, entropy and heat capacity . . . . . . . . 41
5.4.5 AYPLCP: liquid heat capacity on the saturation line . . . . . . . . . . . 41
5.4.6 AYPLH1: liquid enthalpy, entropy and heat capacity on the saturation
line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
5.4.7 AYPLTC: thermal conductivity of liquid on the saturation line . . . . . 42
5.4.8 AYPLVS: viscosity of liquid on the saturation line . . . . . . . . . . . . 43
5.4.9 AYPSCP: solid heat capacity . . . . . . . . . . . . . . . . . . . . . . . . 44
5.4.10 AYPSDN: density of solid . . . . . . . . . . . . . . . . . . . . . . . . . . 44
5.4.11 AYPST: surface tension of liquid on the saturation line . . . . . . . . . 45
5.4.12 AYPSVP: saturated liquid vapour pressure . . . . . . . . . . . . . . . . 45
5.4.13 AYPSVR: second virial coefficient . . . . . . . . . . . . . . . . . . . . . . 46
5.4.14 AYPVTC: vapour thermal conductivity in the zero-density limit . . . . . 47
5.4.15 AYPVVS: vapour viscosity in the zero-density limit . . . . . . . . . . . . 47
5.5 Fetching coefficients in temperature-dependent property correlations . . . . . 48

6 Petroleum fluid characterisation 50


6.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
6.2 Using the characterisation procedure . . . . . . . . . . . . . . . . . . . . . . . 51
6.3 Black Oil characterisation procedure . . . . . . . . . . . . . . . . . . . . . . . 55
6.4 Blending petroleum fluids . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

7 Binary interaction parameters 60


7.1 Defining BIPs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
7.2 Initialising the BIP software . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
7.3 Using BIP databanks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
7.3.1 Opening BIP databanks . . . . . . . . . . . . . . . . . . . . . . . . . . 60
7.3.2 Loading BIPs from a databank . . . . . . . . . . . . . . . . . . . . . . 62
7.3.3 Unloading databanks . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
7.4 Entering BIPs directly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
7.5 BIPs for oil and gas mixtures . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
7.6 Utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
7.6.1 Getting values of stored BIP coefficients . . . . . . . . . . . . . . . . . 68
7.6.2 Freeing BIP load numbers . . . . . . . . . . . . . . . . . . . . . . . . . 70
7.6.3 Deleting BIPs for a component . . . . . . . . . . . . . . . . . . . . . . 70

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

10 Evaluating mixture properties 86


10.1 Thermodynamic properties: AYMIX . . . . . . . . . . . . . . . . . . . . . . . . 86
10.2 Enthalpy and entropy for activity coefficient models . . . . . . . . . . . . . . 88
10.3 Average molecular weight: AYAVMW . . . . . . . . . . . . . . . . . . . . . . . . 88
10.4 Viscosity: AYVISC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
10.5 Thermal conductivity: AYTCND . . . . . . . . . . . . . . . . . . . . . . . . . . 90
10.6 Surface tension: AYSURF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
10.7 Binary diffusion coefficient: AYDIFF . . . . . . . . . . . . . . . . . . . . . . . . 91
10.8 Specification of datum: AYDATM . . . . . . . . . . . . . . . . . . . . . . . . . . 92

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

13 Flash sensitivity calculations 118


13.1 Flashes at fixed pressure and temperature: AXSN01 . . . . . . . . . . . . . . . 118
13.2 Flashes with a temperature or pressure search: AXSN02 . . . . . . . . . . . . . 119
13.3 Double flashes: AXSN04 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121

14 Phase envelope calculations 124


14.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
14.2 Calling the phase envelope routines . . . . . . . . . . . . . . . . . . . . . . . . 124
14.3 Phase envelope for flow assurance . . . . . . . . . . . . . . . . . . . . . . . . . 129

15 Property matching routines 131


15.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
15.2 Phase equilibrium data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
15.3 Gas/Liquid viscosity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
15.4 Volumetric data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
15.5 GOR and Bubble Point Matching . . . . . . . . . . . . . . . . . . . . . . . . . 135

16 Chemical equilibrium calculations 138


16.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
16.2 Chemreact operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
16.3 Initialising Chemreact . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
16.4 Chemical equilibrium at fixed pressure and temperature: CREA01 . . . . . . . 139
16.5 Dew and bubble point searches at chemical equilibrium: CREA02 . . . . . . . 140

17 Configuring Multiflash with a command file 143


17.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
17.2 Reading a command file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
17.3 Reading a command file without loading it . . . . . . . . . . . . . . . . . . . 145
17.4 Carrying out Calculations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
17.5 Writing a command file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
17.6 Ending the Multiflash session . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
17.7 Converting a PVTSim CHC file into an MFL file . . . . . . . . . . . . . . . . 148

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

A Summary of Multiflash routines 157

B Infochem data banks 160


B.1 Infodata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
B.1.1 Data bank structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
B.1.2 Creating the data bank . . . . . . . . . . . . . . . . . . . . . . . . . . 165
B.2 Infocond . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
B.2.1 Data bank structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
B.3 Binary interaction parameter databanks . . . . . . . . . . . . . . . . . . . . . 166
B.3.1 Input specification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
B.3.2 BIP data line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
B.3.3 Component Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
B.3.4 Model/variant identifiers . . . . . . . . . . . . . . . . . . . . . . . . . . 166
B.3.5 BIP T-dependent correlation functions . . . . . . . . . . . . . . . . . . 167
B.3.6 Entering BIP correlation coefficients . . . . . . . . . . . . . . . . . . . 167
B.3.7 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168

C Identification codes for pure component properties 169


C.1 Numerical values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
C.2 Character values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
C.3 Temperature-dependent property correlations . . . . . . . . . . . . . . . . . . 170

D Pure component properties 172


D.1 Constant properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
D.2 Temperature dependent properties . . . . . . . . . . . . . . . . . . . . . . . . 173
D.3 Perfect gas molar heat capacity/enthalpy/entropy . . . . . . . . . . . . . . . . 173
D.4 Gas viscosity at zero density . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
D.5 Gas thermal conductivity at zero density . . . . . . . . . . . . . . . . . . . . . 176
D.6 Second virial coefficient . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
D.7 Saturated liquid vapour pressure . . . . . . . . . . . . . . . . . . . . . . . . . 177
D.8 Enthalpy change on evaporation for saturated liquid (latent heat) . . . . . . . 178
D.9 Saturated liquid density . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
D.10 Saturated liquid viscosity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
D.11 Saturated liquid thermal conductivity . . . . . . . . . . . . . . . . . . . . . . 181
D.12 Surface tension of saturated liquid . . . . . . . . . . . . . . . . . . . . . . . . 182
D.13 Saturated liquid Cp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
D.14 Dielectric constant of liquid . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
D.15 Solid density . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183

6
D.16 Solid heat capacity Cp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183

E Equations of state models for fluid mixtures 184


E.1 Perfect gas equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
E.2 Hayden-O’Connell gas phase model . . . . . . . . . . . . . . . . . . . . . . . . 184
E.3 Redlich-Kwong and Redlich-Kwong-Soave equation . . . . . . . . . . . . . . . 184
E.4 Peng-Robinson equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
E.5 Infochem advanced equation of state features . . . . . . . . . . . . . . . . . . 186
E.5.1 The Peneloux density correction . . . . . . . . . . . . . . . . . . . . . 186
E.5.2 Fitting the vapour pressure curve . . . . . . . . . . . . . . . . . . . . . 187
E.5.3 MHV2-type mixing rules . . . . . . . . . . . . . . . . . . . . . . . . . . 187
E.5.4 Huron-Vidal-type mixing rules . . . . . . . . . . . . . . . . . . . . . . 188
E.5.5 Infochem NRTL-type mixing rules . . . . . . . . . . . . . . . . . . . . 188
E.5.6 Huron-Vidal-Pedersen (HVP) mixing rules . . . . . . . . . . . . . . . . 188
E.5.7 PSRK mixing rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
E.5.8 LCVM mixing rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
E.6 Equation of state with chemical association model . . . . . . . . . . . . . . . 190
E.7 Lee-Kesler and Lee-Kesler-Plöcker methods . . . . . . . . . . . . . . . . . . . 190
E.8 Benedict-Webb-Rubin-(Starling) equation of state . . . . . . . . . . . . . . . 191
E.9 Multi-reference fluid corresponding states model . . . . . . . . . . . . . . . . 191
E.9.1 Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
E.9.2 GERG-2008 model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
E.9.3 Reference fluids . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
E.10 IAPWS formulation for water . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
E.11 High-accuracy formulation for pure Carbon Dioxide . . . . . . . . . . . . . . 192
E.12 Electrolyte model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
E.13 PC-SAFT model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192

F Activity coefficient equations 193


F.1 Ideal solution model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
F.2 Wilson equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
F.2.1 Wilson E equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
F.2.2 Wilson A equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
F.3 NRTL equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
F.4 UNIQUAC equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
F.5 UNIFAC method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
F.6 Regular solution model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
F.7 Flory-Huggins model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195

G Other thermodynamic models for fluids 195


G.1 Henry’s Law water model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
G.2 COSTALD liquid density model . . . . . . . . . . . . . . . . . . . . . . . . . . 196

H Thermodynamic models for solids 196


H.1 Solid freeze-out model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
H.2 Scaling and general freeze-out model . . . . . . . . . . . . . . . . . . . . . . . 196
H.3 Solid solution model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
H.4 Multi-solid solution model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
H.5 Coutinho wax model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
H.6 Gas hydrate model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197

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

J Thermal conductivity models for fluid mixtures 200


J.1 Chung-Lee-Starling method . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
J.2 Super TRAPP thermal conductivity method . . . . . . . . . . . . . . . . . . 201
J.3 Mixing rule for gas thermal conductivities . . . . . . . . . . . . . . . . . . . . 201
J.4 Mixing rule for liquid thermal conductivities . . . . . . . . . . . . . . . . . . . 201

K Surface tension 202


K.1 Linear Gradient Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
K.2 MacLeod-Sugden correlation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
K.3 Sutton correlation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
K.4 Mixing rule for surface tension . . . . . . . . . . . . . . . . . . . . . . . . . . 203

L Diffusion coefficients 203


L.1 Fuller method for the vapour phase . . . . . . . . . . . . . . . . . . . . . . . . 203
L.2 Hayduk-Minhas model for the liquid phase . . . . . . . . . . . . . . . . . . . . 203

M Nomenclature 205

N Examples of use 206


N.1 Pure component properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
N.1.1 Low-level initialisation . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
N.1.2 Command file initialisation . . . . . . . . . . . . . . . . . . . . . . . . 208
N.2 Thermodynamic and transport properties of a mixture . . . . . . . . . . . . . 210
N.2.1 Low-level initialisation . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
N.2.2 Command file initialisation . . . . . . . . . . . . . . . . . . . . . . . . 214
N.3 Simple flash with an equation of state . . . . . . . . . . . . . . . . . . . . . . 218
N.4 Simple flash with an activity model . . . . . . . . . . . . . . . . . . . . . . . . 223
N.5 Flash with hydrates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
N.6 Flash and phase properties from LKP model . . . . . . . . . . . . . . . . . . 234
N.6.1 Low-level initialisation . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
N.6.2 Command file initialisation . . . . . . . . . . . . . . . . . . . . . . . . 240

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.

1.2 Automated phase envelope plotting


There is a new API routine, AXPHES which calculates phase boundaries automatically. The
routine considers phases relevant to flow assurance applications, including hydrate, wax and
asphaltene boundaries.

1.3 PVTSim import tool


It is now possible to import characterised fluids from PVTSim if they were exported to a
CHC file, by calling the routine MF PVTSF Convert.

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);

2. pure component data system (section 4 and Appendix B) ;

3. binary interaction parameter data system (section 7);

4. mixture models for thermodynamic and transport properties (sections 8, 9 and 10);

5. phase/chemical equilibrium calculations (sections 11 to 16).


It is only necessary to follow the initialisation sequence up to the level at which properties
or calculations are required. For example, if mixture viscosities are required it is necessary
to initialise levels 1 to 4 before making a call to the viscosity routine but if pure component
viscosities are required it is only necessary to initialise level 2. If any alteration is made to
the initialisation at a later stage in running a program, then all steps in the initialisation
sequence after the alteration must be repeated, e.g. if the binary interaction parameters are
changed the models must be reinitialised.

3.2 Security system


The security system allows the Multiflash DLL to be used in accordance with Infochem’s
commercial license agreement. It may operate in conjunction with a hardware device (dongle)
or a license manager software system (RLM). See the instalation manual regarding licensing
systems.

3.2.1 Initialising the security system


The security system must be initialised before Multiflash can access databanks, set up models
or perform calculations. This is done by calling the routine MFSINI. The calling specification
is:

INTEGER, INTENT(OUT) :: IERR, IERRLS


CHARACTER*(*), INTENT(IN) :: PSWORD
CHARACTER*(*), INTENT(OUT) :: ERRMES

SUBROUTINE MFSINI( PSWORD, IERR, IERRLS, ERRMES )


C
C Initialise security system and check user and licence information.
C
C Input arguments:
C PSWORD password - may be required depending on implementation.
C Must be set to a blank string if no password is supplied.
C
C Output arguments:
C IERR Multiflash error flag
C 0 OK
C 684 cannot initialise licensing system
C 685 consistency check failed
C 686 license expired
C 687 MF serial number not valid

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

3.2.2 Closing the security system


The security system should be closed when the calling application has finished using the
Multiflash DLL . This will release any locked licenses. To close the security system call
MFSCLO. The routine has no arguments. Calling MFEND (see p.147) will also release any
licenses.

3.3 Numerical parameters


A set of machine-dependent numerical parameters is used internally by Multiflash in numer-
ical algorithms and to mark special values, e.g. ‘value undefined’. Only one value DLARGE is
used as part of the Multiflash external programming interface. It is generally used to signal
missing or undefined data values.
The machine-dependent numerical parameters must be initialised before Multiflash rou-
tines are used. This is usually achieved by calling any of the initialisation routines such
as AYPINI. Alternatively, the user may initialise the values directly by calling AYNUMI. The
routine has no arguments.
To obtain the value of DLARGE call the utility routine AYNUMV. The calling sequence is:

REAL*8, INTENT(OUT) :: DLARGE


CALL AYNUMV( DLARGE )

3.4 Include files


3.4.1 Numerical parameters
A number of dimensioning limits, identification codes, numerical constants and physical con-
stants are used by Multiflash and may be required by the programmer. These values are
provided in Fortran include files that contain parameters. The following is a list of include
files that may be used by the programmer. Details of the parameters or variables are given
in comments in the files.

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

3.4.2 Unique compound identifiers


Multiflash treats certain compounds in a special way. For example, the hydrates model
(Appendix H) needs to recognise water and hydrate-forming compounds. The file aykcar.inc
contains a list of character constants that may be used to identify compounds in a unique
way by comparing with the Chemical Abstracts Registry Number (CARN).
The character string parameters in aykcar.inc may be compared with values returned
by AYPCNK (see section 5). For example the following code fragment searches for KWATER
which has the CARN value for water.
INCLUDE ’aymncs.inc’
INCLUDE ’aykcar.inc’
INCLUDE ’ayjpid.inc’
INTEGER MXERR
PARAMETER (MXERR=10)
INTEGER NCO, IC(MAXNCS), NERR, IERR(MXERR), I, IWATER
CHARACTER*12 CARN(MAXNCS)
C
C Get chemical abstracts registry numbers
C
CALL AYPCNK( NCO, IC, JKCARN, CARN, NERR, MXERR, IERR )
C
C Find water in compound list
C
IWATER = 0
DO I = 1, NCO
IF ( CARN(I).EQ.KWATER ) THEN
IWATER = I
EXIT
ENDIF
END DO

3.5 Error reporting


There are two types of error reporting systems used by Multiflash. The standard system
that returns an error vector is used by all high-level external interfaces. A simplified system
is used by some low-level utility routines such as the unit conversion routines described in
section 18.

3.5.1 Standard error reporting system


The Multiflash error reporting system returns a vector of error codes that may trace the
error condition back through a number of subroutines. Each subroutine returns unique
identification numbers for any error condition or warning. A typical calling sequence might
be:

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 )

3.5.2 Error codes


If no error condition was detected NERR will be returned as zero. If there were any errors or
warnings NERR will be set to a positive number. A maximum of MXERR error codes may be
returned in the array IERR. Positive values denote errors and negative values are warnings.
NERR gives the total number of errors detected by the routine called and any lower level
routines and may exceed MXERR. The first error code is returned in IERR(1) and the most
recent in IERR(NERR) if NERR is less than or equal to MXERR. If NERR is equal to 0 any values
in the IERR array have no significance and should be ignored.
The error codes in the standard system are unique. The meaning of each code is listed in
error text files:
Module Error codes Error text file
(diagnostic codes) 0 - 200
Command processor 201 - 9999 MFI.ETX
Models 10000 - 19999 MODELS.ETX
Multiflash 20000 - 29999 MULTIFLA.ETX
Chemreact 30000 - 39999 CREACT.ETX
Numerical methods 40000 - 49999 NUMETH.ETX

3.5.3 Error-handling utilities


The following utility routines are provided for handling the error codes.

ERTEST: testing for a particular error code


INTEGER, INTENT(IN) :: MXERR, NERR, IERR(MXERR), IERNO
LOGICAL FUNCTION ERTEST( NERR, MXERR, IERR, IERNO )
C
C Tests a set of error numbers to see if any is equal to IERNO.
C
C Input arguments:
C NERR Number of errors to be tested
C MXERR Dimension of array IERR
C IERR Array of error numbers to be tested
C IERNO Error number to be tested for
C
C Function value:
C .TRUE. if error number found, otherwise .FALSE.

ERFATL: testing for a serious error


This routine scans the error array IERR and checks for a serious error, i.e. a positive error
code, as opposed to a negative warning code. If ERFATL is called with a value of NERR greater

14
than MXERR it will return a result of .TRUE. irrespective of the error codes present because
not all errors reported have been recorded.

INTEGER, INTENT(IN) :: NERR, MXERR, IERR(MXERR)


LOGICAL FUNCTION ERFATL( NERR, MXERR, IERR )
C
C Tests a set of error numbers to see if any is a fatal error.
C
C Input arguments:
C NERR Number of errors to be tested
C MXERR Dimension of array IERR
C IERR Array of error numbers to be tested
C
C Function value:
C .TRUE. if serious error found, otherwise .FALSE.

ERLAST: getting the last error


INTEGER, INTENT(IN) :: NERR, MXERR, IERR(MXERR)
INTEGER, INTENT(OUT) :: NERR0, LASTER
LOGICAL, INTENT(OUT) :: FATAL
SUBROUTINE ERLAST( NERR, MXERR, IERR, NERR0, LASTER, FATAL )
C
C Returns the last error code stored in IERR.
C
C Input arguments:
C NERR Number of errors to be tested
C MXERR Dimension of array IERR
C IERR Array of error numbers to be tested
C
C Output arguments:
C NERR0 number of error flags stored in IERR
C LASTER most recent error code in IERR. Zero if none.
C FATAL .TRUE. if most recent code was positive (serios error),
C otherwise .FALSE.

MFDEMS: getting the error message for a given error number


INTEGER, INTENT(IN) :: IERNO
CHARACTER*80, INTENT(OUT) :: EMS

INTEGER FUNCTION MFDEMS( IERNO, EMS )


C
C Returns an error message associated with an error number.
C
C Input arguments:
C IERNO Error number
C
C Output values returned:
C 0 OK
C 1 error getting message - see EMS for details
C
C Output arguments:
C EMS Error message

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:

CHARACTER*(*), INTENT(OUT) :: VERSN, DATE


SUBROUTINE MFVERS( VERSN, DATE )
C
C Output arguments:
C VERSN version number (character string)
C DATE revision date (character string)

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:

1. Initialise the pure component data software.

2. Set location of standard databank files (optional).

3. Open pure component data banks - if any.

4. Load pure component data for particular components.

5. Retrieve pure component data as required.

6. Unload databank if not necessary. (optional but recommended)

Steps 1 - 5 are described in this section whilst the procedures for retrieving data are detailed
in section 5 starting on p.36.

4.2 Initialisation of the pure component data software


The pure component data software is initialised by calling AYPINI. This erases all loaded
components if any. The calling specification is:
INTEGER, INTENT(IN) :: MXERR
INTEGER, INTENT(OUT):: NERR, IERR(*)

SUBROUTINE AYPINI( NERR, MXERR, IERR )


C
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 error codes. Values for this routine:
C 10001 - 10004 licensing errors.

4.3 Databank files used by Multiflash


Multiflash has interfaces to a number of databanks. These include the internal INFODATA
and INFOCOND as well as DIPPR databanks. A separate license is needed for the DIPPR
databank. The standard file names used for the Infochem and DIPPR databanks are listed
in the following table:

17
infodata.bin Infochem pure component databank for fluids
infodata.idx component names index for Infodata

infobips.bin Infochem VLE BIP databank


infobips.idx Index for Infochem VLE BIP databank
infollbips.bin Infochem LLE BIP databank
infollbips.idx Index for Infochem LLE BIP databank

infocond.bin Infochem databank for condensed components


infocond.idx component names index for Infocond

dippr.bin DIPPR databank


dippr.idx DIPPR databank names index

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

SUBROUTINE AYFLFL( APPDIR )


C
C Input arguments:
C APPDIR complete pathname (directory) for location of
C Multiflash files.

4.4 Opening pure component databanks


Before information stored on a databank can be accessed the databank must be opened. The
routine AYPDBO is used to open all databanks for Multiflash. The databanks may contain pure
component data for defined components, binary interaction parameters (BIPs) or data for
the properties of petroleum fractions. The ‘databanks’ may be external data files, data stored
internally within the code or collections of methods or correlations that are used to estimate
the required data. This section deals only with data banks for defined pure components. For
petroleum fraction correlations see section 4.9 and for BIP databanks see section 7.3.1. The
calling specification for AYPDBO is:

INTEGER, INTENT(IN) :: NFIL, NBANK, JBANK(*), MXERR


INTEGER, INTENT(OUT):: LNODB, NERR, IERR(*)
CHARACTER*(*), INTENT(IN) :: NAMFIL(*)

SUBROUTINE AYPDBO( NBANK, JBANK, NFIL, NAMFIL, LNODB, NERR,


+ MXERR, IERR )
C
C Input arguments:
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 NFIL Number of filenames passed in NAMFIL. If NFIL is set

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.

4.5 Unloading databanks


Although there is no logical limit to the number of databanks that may be opened simultane-
ously by Multiflash, there is a limit to the internal storage allocated to databank information.
Unloading (closing) a databank frees the internal storage associated with an open bank. The
databank load number is then no longer valid.
The normal pattern for using databanks is to open them, load data for selected compounds
(section 4.7) and then to unload the databank(s). However, if a databank is to be accessed
frequently then unloading is not usually desirable because there is an overhead associated
with re-opening the bank.
The routine AYPDBU is used to unload pure component data banks. The calling specifica-
tion is:
INTEGER, INTENT(INOUT):: LNODB
SUBROUTINE AYPDBU( LNODB )
C
C Input/output arguments:
C LNODB Data bank load number (set to zero on return)
C

If AYPDBU is called with an invalid load number no action is taken and no error is reported.

4.6 Loading pure component data


Components used by Multiflash can be defined in a number of ways:

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);

• the component may be specified as a petroleum fraction (section 4.9);

• or a set of components may be defined by entering a petroleum fluid analysis (section


6).

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.

4.7 Loading components from a databank


Pure component data for the required components may be loaded from any (previously
opened) databanks. Components are identified by name. A valid name, stored on the data-
bank, must be specified to the loading routine. Note that there may be several alternative
names for any compound. The valid names depend on the databank that is specified and it
is necessary to consult the documentation provided with the databank to establish the com-
pounds that are available. A set of routines is provided to facilitate searching for compounds
on a databank. These routines are described in section 4.10.
The routine AYPDBC is used to load a compound. It has the following calling specification:

INTEGER, INTENT(IN) :: LNODB, MXERR


INTEGER, INTENT(INOUT) :: ICO
INTEGER, INTENT(OUT) :: NERR, IERR(*)
CHARACTER*(*), INTENT(IN) :: CNAME

SUBROUTINE AYPDBC( LNODB, CNAME, ICO, NERR, MXERR, IERR )


C
C Input arguments:
C LNODB Data bank load number
C CNAME component name (must be a valid name for the databank)
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. If equal to 0 a new component
C is set up. If an existing component load number is
C given the entries for that component will be overwritten.
C
C Output values:
C ICO New component load number created (if zero entered)
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 10421 unrecognised data bank load number
C 10422 unrecognised data bank type
C 10423 component not loaded (see subsequent error codes)

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 )

4.8 Defining a component by entering data directly


Compound data may be entered directly by making subroutine calls as described below. An
entirely new compound may be set up or, if required, additional pure component physical
properties may be entered or the existing values overwritten for a compound that has already
been loaded. Three classes of data may be entered: numerical constants, character constants
and coefficients in a temperature-dependent correlation.

4.8.1 Entering numerical constants


The numerical constants are the quantities listed in section B.1.1 and Appendix C.1, e.g.
critical temperature. They are set by calling AYPSTR as follows:

INTEGER, INTENT(IN) :: NVALUE, JVALUE(*), MXERR

21
INTEGER, INTENT(INOUT) :: ICO
INTEGER, INTENT(OUT) :: NERR, IERR(*)
REAL*8, INTENT(IN) :: RCONST(*)
LOGICAL, INTENT(IN) :: INIT

SUBROUTINE AYPSTR( ICO, INIT, NVALUE, JVALUE, RCONST, NERR,


+ MXERR, IERR )
C
C Input arguments:
C INIT .TRUE. if all properties to be initialised, .FALSE. if
C only undefined properties to be intialised
C NVALUE Number of properties to be entered
C JVALUE Property identification codes (from ayjpid.inc)
C RCONST Pure component constants. -DLARGE means don’t overwrite
C existing value.
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
C Output values:
C ICO Component load number
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 -13271 the JVALUE is not a recognised property
C 13271 error in component number (<1 or > maxncs)
C 13272 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.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)

4.8.2 Setting numerical constants to undefined


When AYPSTR is called with one of the input property values set to undefined (-DLARGE), the
input is ignored and the internal value is left unaltered. Sometimes there is a need to set an
internal value to undefined. This can be done by calling AYPUND which sets all stored values
specified in the input list JVALUE to undefined. The definition of AYPUND is:

22
INTEGER, INTENT(IN) :: NVALUE, JVALUE(*), MXERR
INTEGER, INTENT(INOUT) :: ICO
INTEGER, INTENT(OUT) :: NERR, IERR(*)

SUBROUTINE AYPUND( ICO, NVALUE, JVALUE, NERR, MXERR, IERR )


C
C Input arguments:
C NVALUE Number of properties to be set undefined
C JVALUE Property identification codes (from AYJPID.INC)
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
C Output values:
C ICO Component load number
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 -13271 the JVALUE is not a recognised property
C 13271 error in component number (<1 or > maxncs)
C 13272 component storage exhausted

4.8.3 Entering character constants


The character constants are the quantities listed in section B.1.1 and Appendix C.2, e.g.
compound name. They are set by calling AYPSTK as follows:

INTEGER, INTENT(IN) :: NVALUE, JVALUE(*), MXERR


INTEGER, INTENT(INOUT) :: ICO
INTEGER, INTENT(OUT) :: NERR, IERR(*)
CHARACTER*(*) KCONST(*)
LOGICAL INIT

SUBROUTINE AYPSTK( ICO, INIT, NVALUE, JVALUE, KCONST, NERR,


+ MXERR, IERR )
C
C Input arguments:
C INIT .TRUE. if all properties to be initialised, .FALSE. if
C only undefined properties to be intialised
C NVALUE Number of properties to be entered
C JVALUE Property identification codes (from ayjpid.inc)
C KCONST Pure component constants. Blank means don’t overwrite
C existing value.
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
C Output values:
C ICO Component load number
C
C Output arguments:
C NERR no. errors reported by this routine and lower level routines

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 )

4.8.4 Entering correlations for temperature-dependent properties


The temperature-dependent properties are listed in section B.1.1 and Appendix C.3, e.g.
vapour pressure. Temperature correlations are regarded as special cases of numerical con-
stants and are also set by calling AYPSTR as specified above. The arrays JVALUE and RCONST
are used to set up a data structure as follows:

element JVALUE RCONST

1 jval equation type code


2 jval +1 coefficient 1
3 jval +2 coefficient 2
... ... ...
1 + ncof jval + ncof coefficient ncof
1 + ncof + 1 jval + ncof + 1 Tmin
1 + ncof + 2 jval + ncof + 2 Tmax

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 )

4.8.5 Entering Unifac subgroup structures


A component’s subgroup structure is defined by property code JUNIF is then followed by
up to 10 pairs of numbers giving the Multiflash code number for the subgroup in question
followed by its abundance. The following example shows how to define the Unifac subgroup
structure for hexane. Hexane consists of two CH3 subgroups and four CH2 subgroups. The
Multiflash intger code numbers for the CH3 and CH2 subgroups are 1 and 2 respectively.

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:

INTEGER, INTENT(INOUT) :: ISGNO


CHARACTER*12, INTENT(INOUT) :: SYMBOL
LOGICAL, INTENT(IN) :: MODE

SUBROUTINE AYPUFS( MODE, SYMBOL, ISGNO )


C
C Input arguments:
C MODE .TRUE. if SYMBOL is input and ISGNO is output,
C .FALSE. if vice-versa
C
C Input/output arguments:
C SYMBOL Symbol
C ISGNO Subgroup number

4.9 Petroleum fractions


Petroleum fractions or pseudo components are commonly used in modelling oil and gas pro-
cessing operations. A petroleum fraction may be used to represent the aggregate properties
of complex mixtures that are characterised by standard tests such as ASTM distillation.

4.9.1 Correlations for petroleum fraction properties


Multiflash uses industry-standard correlations to estimate all the properties required to use
equations of state and basic transport property models for mixtures that include petroleum
fractions. These properties include: molecular weight, boiling point, critical temperature,
critical pressure, critical volume, parachor, dipole moment, enthalpy of formation, standard
entropy, liquid and solid solubility parameters, melting temperature, enthalpy change on
melting, volume change on melting, heat capacity change on melting, triple point temperature
and pressure, perfect gas Cp, saturated liquid density, latent heat, vapour pressure, liquid
and vapour viscosity, liquid and vapour thermal conductivity and liquid heat capacity.
Before calling the routine AYPPF (see below) to define a petroleum fraction it is necessary to
define the characterisation method (set of correlations) to use. This is done by calling AYPDBO
to obtain a load number for the characterisation method. At present only one characterisation
method JCINFO is supported but other methods may be added in the future. This method
uses the correlations of Riazi and Al-Sahhaf 1 . for molecular weight and specific gravity as a
function of carbon number and the Lee-Kesler correlations 2 to obtain critical properties and
the acentric factor. The calling specification for AYPDBO is:

INTEGER, INTENT(IN):: NFIL, NBANK, JBANK(*), MXERR


INTEGER, INTENT(OUT) :: LNODB, NERR, IERR(*)
CHARACTER*(*), INTENT(IN) :: NAMFIL(*)

SUBROUTINE AYPDBO( NBANK, JBANK, NFIL, NAMFIL, LNODB, NERR,


+ MXERR, IERR )
C
1
M. R. Riazi and T. A. Al-Sahhaf, Physical properties of heavy petroleum fractions and crude oils, Fluid
Phase Equilibria, 117, 217 (1996)
2
M.J. Kesler and B.I. Lee, Hydrocarbon Processing, 53, 153 (1976)

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.

4.9.2 Defining petroleum fractions


Petroleum fractions are defined by calling the routine AYPPF. This routine estimates any nec-
essary properties and loads the component. It is necessary to supply some basic information
which is used as the basis of estimation procedures. Up to seven property values may be
entered for a petroleum fraction. Any user-supplied property values are used in preference to
estimated values. As much data as possible should be entered but the following combinations
are the minimum acceptable:
carbon number
molecular weight and specific gravity (at 60◦ F)
carbon number and molecular weight or specific gravity
boiling point and specific gravity
boiling point and molecular weight
critical temperature, critical pressure and acentric factor
The specific gravity, molecular weight and boiling point are usually available for heavy frac-
tions. If the carbon number is given it is used to estimate the molecular weight and specific
gravity (if not specified) using the single carbon number (SCN) correlations of Riazi and
Al-Sahhaf (see above). The alternative of defining critical properties allows direct input of
pseudocomponents that have already been characterised, for example from a process simula-
tor. If a property is unknown it must be set to the ‘data unknown’ marker -DLARGE, where
DLARGE is obtained from the routine AYNUMV.
The physical properties estimated for petroleum fraction components may depend on the
type of component which may be a petroleum fraction of unspecified type, normal-paraffin,
non-n-paraffin, iso-paraffin, aromatic, resin or asphaltene. Currently the Infochem charac-
terisation method does not distinguish between normal, iso- or aromatic components. The
formula, Family Code and Chemical Abstracts Registry Number for a petroleum fraction are
set to blank strings.

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)

CALL AYNUMV( DLARGE )


JBANK(1) = JCINFO
CALL AYPDBO( 1, JBANK, 0, NAMFIL, LNOPF, NERR, MXERR, IERR )
INIT = .TRUE.
MW = 224.0D0
SG = 0.842D0
TB = 552.59D0
TC = -DLARGE
PC = -DLARGE
W = -DLARGE
CN = -DLARGE
LNOC4 = 0
CALL AYPPF( LNOPF, LNOC4, INIT, ’C7+’, JTPET, CN, MW, SG, TB,
+ TC, PC, W, NERR, MXERR, IERR )

4.10 Searching for compounds on a databank


The routines described in this section are provided to allow databanks previously opened by
AYPDBO (see Section 4.4) to be searched in a number of ways. These routines can be used to
support on-line searching facilities for users of databanks interfaced to Multiflash. Most of
the routines return a databank record number corresponding to compound identified in the
search. The record number can be used in calls to routines described in Section 4.11 to look
up data without loading a component from the databank.

4.10.1 AYPDBI: Search for a compound name:


The integer function subprogram AYPDBI searches the index associated with a databank for
a unique compound name and returns the record number of the compound in the databank
file if the name is identified. The calling specification is:

INTEGER, INTENT(IN) :: LNODB, MXERR


INTEGER, INTENT(OUT) :: NERR, IERR(*)
CHARACTER*(*), INTENT(IN) :: CNAME

INTEGER FUNCTION AYPDBI( LNODB, CNAME, NERR, MXERR, IERR )


C
C Input arguments:
C LNODB Data bank load number
C CNAME component name
C MXERR maximum number of error flags to be returned in IERR
C
C Function return values:
C 0 cannot find compound or error (see IERR)
C >0 record number on databank file for component
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 10431 Unrecognised data bank load number

29
C 10432 Unrecognised data bank type

4.10.2 AYPDBS: Search for compound names containing specified string:


AYPDBS searches the index of compound names associated with a databank for names contain-
ing a specified string. One name is returned per call. The first call for a new name should be
made with the logical flag FIRST set to .TRUE.. Subsequent calls with FIRST set to .FALSE.
will return the next name matching the search criterion until the end of file is reached. The
"*" character is used to specify a sub-string that may occur at the start, end or anywhere in
the name. For example, to find all compounds starting with "METHANE", the string to search
for should be set to "METHANE*". If the search string has the value ** it matches any name
and the effect is to return the next name on the databank index. The calling specification is:

INTEGER, INTENT(IN) :: LNODB, MXERR


INTEGER, INTENT(OUT) :: IREC, NERR, IERR(*)
CHARACTER*(*), INTENT(IN) :: KSTRNG
CHARACTER*(*), INTENT(OUT) :: KNAME
LOGICAL, INTENT(IN) :: FIRST

SUBROUTINE AYPDBS( LNODB, KSTRNG, FIRST, IREC, KNAME, NERR, MXERR,


+ IERR )
C
C Input arguments:
C LNODB Data bank load number
C KSTRNG string to search for:
C STRING exact match on STRING
C *STRING any name ending in STRING
C STRING* any name starting with STRING
C *STRING* any name containing STRING
C ** the next name in the index
C FIRST logical flag.
C TRUE first call for current string, index file is
C rewound prior to search
C FALSE for second and subsequent calls, starts search at
C current position of index file
C MXERR maximum number of error flags to be returned in IERR
C
C Output arguments:
C IREC record number in databank file of compound matching
C search criterion.
C Zero if no match found.
C Negative if end of index file reached.
C KNAME component name matching search criterion. Blank if no
C match found.
C NERR no. errors reported by this routine and lower level routines
C IERR array of error codes. Values returned by this routine:
C 10471 Unrecognised data bank load number
C 10472 Unrecognised data bank type

4.10.3 AYPDBY: Return synonyms for compound name:


AYPDBY searches the index of compound names associated with a databank for a specified
name and returns synonyms, i.e. alternative names for the compound. One synonym is
returned per call. The first call for a new name should be made with the logical flag FIRST
set to .TRUE.. Subsequent calls with FIRST set to .FALSE. will return the next synonym
until the final synonym is returned. The calling specification is:

30
INTEGER, INTENT(IN) :: LNODB, MXERR
INTEGER, INTENT(OUT) :: IREC, NERR, IERR(*)
CHARACTER*(*), INTENT(IN) :: KNAME
CHARACTER*(*), INTENT(OUT):: KSYNM
LOGICAL, INTENT(IN) :: FIRST

SUBROUTINE AYPDBY( LNODB, KNAME, FIRST, IREC, KSYNM, NERR, MXERR,


+ IERR )
C
C Input arguments:
C LNODB Data bank load number
C KNAME component name for which to find synonyms
C FIRST logical flag.
C TRUE first call for current string, index file is
C rewound prior to search
C FALSE for second and subsequent calls, starts search at
C current position of index file
C MXERR maximum number of error flags to be returned in IERR
C
C Output arguments:
C IREC record number in databank file if compound name found.
C Zero if name not found.
C Negative if last synonym has been returned.
C KSYNM synonym for component name (will include original
C name specified)
C NERR no. errors reported by this routine and lower level routines
C IERR array of error codes. Values returned by this routine:
C 10481 Unrecognised data bank load number
C 10482 Unrecognised data bank type

4.10.4 AYPDBF: Search for compounds with specified formula:


AYPDBF searches the databank for compounds with a specified chemical formula. One com-
pound name is returned per call. The first call for a new formula should be made with the
logical flag FIRST set to .TRUE.. Subsequent calls with FIRST set to .FALSE. will return the
next name with the formula until the final name is returned. The formula must be entered
in the correct upper- and lower-case characters. The symbol "*" can be used to specify any
number (non-zero) of atoms of a particular element. The calling specification is:

INTEGER, INTENT(IN) :: LNODB, MXERR


INTEGER, INTENT(OUT) :: IREC, NERR, IERR(*)
CHARACTER*(*), INTENT(IN) :: SFORM
CHARACTER*(*), INTENT(OUT) :: NAME, FORM
LOGICAL, INTENT(IN) :: FIRST

SUBROUTINE AYPDBF( LNODB, SFORM, FIRST, IREC, NAME, FORM, NERR,


+ MXERR, IERR )
C
C Input arguments:
C LNODB Data bank load number
C SFORM chemical formula to search for.
C The formula should contain the standard chemical
C symbols in upper/lower case. Abundances must be integer
C values or * for any number of atoms. Brackets and other
C punctuation are not allowed. An abundance of 1 need not
C be specified.
C FIRST logical flag.

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

4.11 Reading data directly from a databank


The routines described in this section are provided to return information from a databank
without first loading the compound data into Multiflash as described in Section 4.7. The
databanks referenced must have previously been opened by AYPDBO (see Section 4.4). These
routines can be used to support on-line component selection on the basis of component
properties.

4.11.1 AYPDBK: Pure component character data:


AYPDBK returns character constants from a specified record on a databank. Its function is
similar to the routine AYPCNK which can only be used once a component has been loaded.
See Appendix C for a list of property codes. The calling specification is:

INTEGER, INTENT(IN) :: LNODB, JVALUE, MXERR


INTEGER, INTENT(INOUT) :: IREC
INTEGER, INTENT(OUT) :: NERR, IERR(*)
CHARACTER*(*), INTENT(OUT) :: KCONST

SUBROUTINE AYPDBK( LNODB, IREC, JVALUE, KCONST, NERR, MXERR, IERR)


C
C Input arguments:
C LNODB Data bank load number
C JVALUE Property identification code (from ayjpid.inc)
C MXERR maximum number of error flags to be returned in IERR
C
C Input/output arguments:
C Input values:
C IREC record number of desired data
C
C Output values:
C IREC record number for next component
C
C Output arguments:
C KCONST pure component character constant (blank if error)
C NERR no. errors reported by this routine and lower level routines
C IERR array of error codes. Values returned by this routine:
C 10451 Unrecognised data bank load number
C 10452 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:

INTEGER, INTENT(IN) :: LNODB, JVALUE, MXERR


INTEGER, INTENT(INOUT) :: IREC
INTEGER, INTENT(OUT) :: NERR, IERR(*)
REAL*8, INTENT(OUT) :: RCONST

SUBROUTINE AYPDBV( LNODB, IREC, JVALUE, RCONST, NERR, MXERR, IERR)


C
C Input arguments:
C LNODB Data bank load number
C JVALUE Property identification code (from ayjpid.inc)
C MXERR maximum number of error flags to be returned in IERR
C
C Input/output arguments:
C Input values:
C IREC record number of desired data
C
C Output values:
C IREC record number for next component
C
C Output arguments:
C RCONST pure component character constant
C NERR no. errors reported by this routine and lower level routines
C IERR array of error codes. Values returned by this routine:
C 10461 Unrecognised data bank load number
C 10462 Unrecognised data bank type

4.12 Other utilities


The following utility routines are provided:

4.12.1 AYPNC1: Number of components defined:


INTEGER, INTENT(OUT) :: NC, IC(*)
SUBROUTINE AYPNC1( NC, IC )
C
C Output arguments:
C NC number of defined components
C IC load numbers of defined components

4.12.2 AYPDEL: Delete data for a component:


INTEGER, INTENT(IN) :: MXERR
INTEGER, INTENT(INOUT) :: ICO
INTEGER, INTENT(OUT) :: NERR, IERR(*)
SUBROUTINE AYPDEL( ICO, NERR, MXERR, IERR )
C
C Input arguments:
C MXERR maximum number of error codes to return in IERROR
C

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.

4.12.3 AYSALN: Equivalent salt component/ions concentration:


The purpose of this routine is to take a multicomponent ion analysis, salt analysis or total
deposited solids in water and to find the concentration of sodium chloride, potassium chlo-
ride and calcium chloride which will have an equivalent effect on the activity of the water.
This allows the effect of salt solutions on the hydrate formation point or the freezing point
depression to be calculated.
Three electrolyte models are available. The first uses the concept of a salt pseudocom-
ponent. The component called SALTCOMPONENT is included in the Infodata databank. The
SALTCOMPONENT is intented to use with RKSA and PRA using van der Waals and Infochem
mixing rules. To calculate the equivalent amount of the SALTCOMPONENT the MODEL argument
should be set to 1. The usage of the SALTCOMPONENT option is not recomended if calculations
are to be carried out at high pressures and or high temperatures.
The other two make the Infochem electrolyte model (E.12) handling sodium, potassium,
calcium and chloride ions. Setting the MODEL argument to 2 will generate the equivalent
concentrations of NaCl, KCl, CaCl2 and NaBr salts by calculating the correct amounts of
Na+ , K+ , Ca2+ , Cl− and Br− ions. Setting the model to 3 it will return the NaCl equivalent
for the electrolyte model as amounts of Na+ and Cl− . If halide scales are not needed setting
model to 3 is the recommended option.
The properties of the salt component or the ions have also been set to give reasonable
estimates for the density of aqueous solutions. The enthalpy of solutions have not been
fitted. The procedure for calculating the equivalent concentration is based on that described
in: A practical model for the effect of salinity on gas hydrate formation, B. Edmonds, R.A.S.
Moorwood and R. Szczepanski, SPE 35569 (1996).
The calling specification is as follows:

INTEGER, INTENT(IN) :: INOPT, MODEL, MXERR


INTEGER, INTENT(OUT):: NERR, IERR(*)
REAL*8, INTENT(IN) :: DEN, ANAL(*)
REAL*8, INTENT(OUT) :: ZSALT(4)

SUBROUTINE AYSALN( INOPT, MODEL, DEN, ANAL, ZSALT, NERR, MXERR,


+ IERR )
C
C Input arguments:
C INOPT Input option:
C 0 Ion concentrations in mg/litre

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:

AYPCNK character valued constants, e.g. name, formula etc.


AYPCNR real valued constants, e.g. critical properties etc.
AYPCNR returns the status of the set property. Status flags are defined in ayjuid.inc
AYPHC tests whether components are hydrocarbons
AYPDIE dielectric constant of liquid at 1 atm pressure
AYPDNL density of liquid on the saturation line
AYPHLV enthalpy change on evaporation (latent heat)
AYPHSI perfect gas enthalpy, entropy and heat capacity
AYPLCP heat capacity of liquid on the saturation line
AYPLH1 liquid enthalpy, entropy and heat capacity on the saturation line
AYPLTC thermal conductivity of liquid on the saturation line
AYPLVS viscosity of liquid on the saturation line
AYPSCP heat capacity of solid
AYPSDN density of solid
AYPST surface tension of liquid on the saturation line
AYPSVP saturated liquid vapour pressure
AYPSVR second virial coefficient
AYPVTC vapour thermal conductivity in zero density limit
AYPVVS vapour viscosity in zero density limit

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.

5.2 Use of NCO and IC arguments


Properties may be returned for all the components currently loaded by setting NCO to zero.
In this case the contents of the IC array are ignored. IC is the array of component load
numbers.
To return properties for a subset of the complete set of loaded components NCO should be
set to the number of components and the component load numbers should be set in the IC
array. Values are returned in locations 1 to NCO of the output arrays.
If NCO is set to a negative value this is interpreted as a request for subset of kNCOk
components. The IC array must be set. The value for the Ith component is returned in the
location IC(I) of the output arrays. Note that the component load numbers returned by the
component loading routines are always in the range 1 to MAXNCS.

5.3 Constant properties


5.3.1 AYPCNK: character valued constants
Examples of the constants returned by AYPCNK include component name, formula, etc. See
Appendix C for a list of property codes. The calling specification is:

INTEGER, INTENT(IN) :: NCO, IC(*), JVALUE, MXERR


INTEGER, INTENT(OUT) :: NERR, IERR(*)
CHARACTER*(*), INTENT(OUT) :: KCONST(*)

SUBROUTINE AYPCNK( NCO, IC, JVALUE, KCONST, NERR, MXERR, IERR )


C

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

5.3.2 AYPCNR: real valued constants


Examples of the constants returned by AYPCNR include critical properties, etc. See Appendix
C for a list of property codes. The calling specification is:

INTEGER, INTENT(IN) :: NCO, IC(*), JVALUE, MXERR


INTEGER, INTENT(OUT) :: NERR, IERR(*)
REAL*8, INTENT(OUT) :: RCONST(*)

SUBROUTINE AYPCNR( NCO, IC, JVALUE, RCONST, 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. Eg. setting NC to 2 , IC(1) to 1
C and IC(2) to 3 would return properties for components 1
C and 3. The simplest way to return properties for all
C components is to set NC to 0 and pass IC as a dummy
C array.
C JVALUE Property identification code.
C The properties returned by AYPCNR are selected by
C setting the appropriate code (J-number) from include
C file ayjpid.inc.
C MXERR maximum number of error flags to be returned in IERR
C
C Output arguments:
C RCONST Pure component constants. Set to -DLARGE if missing.
C If NCO +ve prop. for component I placed in RCONST(I),
C If NCO -ve prop. for component I placed in RCONST(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 -13251 missing constants for one or more components
C -13252 invalid component number
C 13251 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:

INTEGER, INTENT(IN) :: NCO, IC(*), JVALUE, MXERR


INTEGER, INTENT(OUT) :: STATUS(*), NERR, IERR(*)

SUBROUTINE AYPCNS( NCO, IC, JVALUE, STATUS, 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 JVALUE Property identification code (from AYJPID.INC)
C MXERR maximum number of error flags to be returned in IERR
C
C Output arguments:
C STATUS Pure component property status (see AYJUID.INC)
C If NCO +ve prop. for component I placed in STATUS(I),
C If NCO -ve prop. for component I placed in STATUS(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 -13821 invalid component number
C 13821 property id (JVALUE) not recognised

5.3.4 AYPHC: test for hydrocarbons


AYPHC returns a logical flag for each component to indicate whether it is a hydrocarbon. A
.TRUE. value is returned if the component is a petroleum fraction or if its chemical formula
contains just carbon and hydrogen.

INTEGER, INTENT(IN) :: NCO, IC(*), MXERR


INTEGER, INTENT(OUT) :: NERR, IERR(*)
LOGICAL, INTENT(OUT) :: HC(*)

SUBROUTINE AYPHC( NCO, IC, HC, 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 MXERR maximum number of error flags to be returned in IERR
C
C Output arguments:
C HC Elements .TRUE. if component a hydrocarbon, otherwise .FALSE.
C NERR no. errors reported by this routine and lower level routines
C IERR Array of error codes. Values returned by this routine:
C -13351 missing constants for one or more components
C -13352 invalid component number

5.4 Temperature-dependent properties


Temperature-dependent properties for pure components are usually stored on databanks for
limiting conditions where the property value is fixed by the temperature alone. Thermal

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.

5.4.1 AYPDIE: dielectric constant of liquid


The property returned is the dimensionless relative permittivity of the liquid at low pressure
(nominally 1 atm).

INTEGER, INTENT(IN) :: NCO, IC(*), IDT, MXERR


INTEGER, INTENT(OUT) :: NERR, IERR(*)
REAL*8, INTENT(IN) :: TIN
REAL*8, INTENT(OUT):: DIEL(*), DDIEL(*), DDDIEL(*)

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

5.4.2 AYPDNL: density of liquid on the saturation line


INTEGER, INTENT(IN) :: NCO, IC(*), IDT, MXERR
INTEGER, INTENT(OUT) :: NERR, IERR(*)
REAL*8, INTENT(IN) :: TIN
REAL*8, INTENT(OUT) :: DL(*), DDL(*), DDDL(*)

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.

5.4.3 AYPHLV: enthalpy change on evaporation (latent heat)


INTEGER, INTENT(IN) :: NCO, IC(*), MXERR
INTEGER, INTENT(OUT) :: NERR, IERR(*)
REAL*8, INTENT(IN) :: TIN
REAL*8, INTENT(OUT) :: HLV(*), DHLV(*)
LOGICAL, INTENT(IN) :: LDERIV

SUBROUTINE AYPHLV( NCO, IC, TIN, LDERIV, HLV, DHLV, 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 HLV enthalpy change on evaporation for components selected
C (J mol-1)
C DHLV T derivative of HLV (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 -13171 temperature below lower limit or above upper
C limit for one or more components. Extrapolated

40
C values returned
C 13171 unrecognised equation type
C 13172 erroneous/missing data for one or more components.
C -DLARGE returned.

5.4.4 AYPHSI: perfect gas enthalpy, entropy and heat capacity


INTEGER, INTENT(IN) :: NCO, IC(*), MXERR
INTEGER, INTENT(OUT) :: NERR, IERR(*)
REAL*8, INTENT(IN) :: TIN
REAL*8, INTENT(OUT) :: HIG(*), SIG(*), DHIG(*)
LOGICAL, INTENT(OUT) :: LDERIV

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

5.4.5 AYPLCP: liquid 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) :: DPROP(*)

SUBROUTINE AYPLCP( NCO, IC, TIN, 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)

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.

5.4.7 AYPLTC: thermal conductivity of liquid on the saturation line


INTEGER, INTENT(IN) :: NCO, IC(*), MXERR
INTEGER, INTENT(OUT) :: NERR, IERR(*)
REAL*8, INTENT(IN) :: TIN
REAL*8, INTENT(OUT) :: PROP(*), DPROP(*)
LOGICAL, INTENT(IN) :: LDERIV

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.

5.4.8 AYPLVS: viscosity of liquid on the saturation line


INTEGER, INTENT(IN) :: NCO, IC(*), MXERR
INTEGER, INTENT(OUT) :: NERR, IERR(*)
REAL*8, INTENT(IN) :: TIN
REAL*8, INTENT(OUT) :: PROP(*), DPROP(*)
LOGICAL, INTENT(IN) :: LDERIV

SUBROUTINE AYPLVS( 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 viscosity for components selected (Pas)
C DPROP T derivative of saturated liquid 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))

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.

5.4.9 AYPSCP: solid heat capacity


INTEGER, INTENT(IN) :: NCO, IC(*), MXERR
INTEGER, INTENT(OUT) :: NERR, IERR(*)
REAL*8, INTENT(IN) :: TIN
REAL*8, INTENT(OUT) :: DPROP(*)

SUBROUTINE AYPSCP( NCO, IC, TIN, 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 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 10171 Equation number not recognised.
C -10171 Temperature below lower limit or above upper
C limit. Extrapolated values returned.

5.4.10 AYPSDN: density of solid


INTEGER, INTENT(IN) :: NCO, IC(*), MXERR
INTEGER, INTENT(OUT) :: NERR, IERR(*)
REAL*8, INTENT(IN) :: TIN
REAL*8, INTENT(OUT) :: PROP(*), DPROP(*)
LOGICAL, INTENT(IN) :: LDERIV

SUBROUTINE AYPSDN( 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 density of solid for components selected (mol/m3)

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.

5.4.11 AYPST: surface tension of liquid on the saturation line


INTEGER, INTENT(IN) :: NCO, IC(*), MXERR
INTEGER, INTENT(OUT) :: NERR, IERR(*)
REAL*8, INTENT(IN) :: TIN
REAL*8, INTENT(OUT) :: PROP(*), DPROP(*)
LOGICAL, INTENT(IN) :: LDERIV

SUBROUTINE AYPST( 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 surface tension for components selected (N/m)
C DPROP T derivative of saturated liquid surface tension (N/m 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 10141 Equation number not recognised.
C 10142 Critical temperature undefined for component
C -10141 Temperature below lower limit or above upper
C limit. Extrapolated values returned.

5.4.12 AYPSVP: saturated liquid vapour pressure


INTEGER, INTENT(IN) :: NCO, IC(*), MXERR
INTEGER, INTENT(OUT) :: NERR, IERR(*)
REAL*8, INTENT(IN) :: TIN
REAL*8, INTENT(OUT) :: VP(*), DVP(*)
LOGICAL, INTENT(IN) :: LDERIV

SUBROUTINE AYPSVP( NCO, IC, TIN, LDERIV, VP, DVP, NERR,


+ MXERR, IERR )

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.

5.4.13 AYPSVR: second virial coefficient


INTEGER, INTENT(IN) :: NCO, IC(*), MXERR
INTEGER, INTENT(OUT) :: NERR, IERR(*)
REAL*8, INTENT(IN) :: TIN
REAL*8, INTENT(OUT) :: PROP(*), DPROP(*)
LOGICAL, INTENT(IN) :: LDERIV

SUBROUTINE AYPSVR( NCO, IC, TIN, LDERIV, PROP, DPROP, NERR,


+ MXERR, IERR )

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.

5.4.14 AYPVTC: vapour thermal conductivity in the zero-density limit


INTEGER, INTENT(IN) :: NCO, IC(*), MXERR
INTEGER, INTENT(OUT) :: NERR, IERR(*)
REAL*8, INTENT(IN) :: TIN
REAL*8, INTENT(OUT) :: PROP(*), DPROP(*)
LOGICAL, INTENT(IN) :: LDERIV

SUBROUTINE AYPVTC( NCO, IC, TIN, LDERIV, PROP, DPROP, NERR,


+ MXERR, IERR )

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.

5.4.15 AYPVVS: vapour viscosity in the zero-density limit


INTEGER, INTENT(IN) :: NCO, IC(*), MXERR
INTEGER, INTENT(OUT) :: NERR, IERR(*)
REAL*8, INTENT(IN) :: TIN
REAL*8, INTENT(OUT) :: PROP(*), DPROP(*)
LOGICAL, INTENT(IN) :: LDERIV

SUBROUTINE AYPVVS( NCO, IC, TIN, LDERIV, PROP, DPROP, NERR,


+ MXERR, IERR )

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.

5.5 Fetching coefficients in temperature-dependent property correlations


This section describes a routine (AYPCOR) that may be used to return values of correla-
tion coefficients in the temperature-dependent property correlations for pure components. A
complete set of routines (section 5.4) is provided for evaluating temperature-dependent pure
component properties. These routines should be used wherever possible because they sepa-
rate the property values from the details of the correlation equations and how the coefficients
are stored. It is usually unnecessary and undesirable to access the coefficients directly.
The calling specification is:
INTEGER, INTENT(IN) :: NCO, IC(*), JPROP, NCRDIM, MXERR
INTEGER, INTENT(OUT) :: NEQN(*), NCOR(*), NERR, IERR(*)
REAL*8, INTENT(OUT) :: CORR(NCRDIM,*), TMIN(*), TMAX(*)

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.

6.2 Using the characterisation procedure


The Infochem characterisation procedure is implemented in the routine AYPVT1. The concept
is to allow for the input of a gas steam analysis and a liquid stream analysis plus a separator
GOR or, alternatively, a total fluid analysis without a GOR. The specific gravity (SG) and
molecular weight of the liquid, total fluid or the plus fraction (the heavy fraction without a
compositional analysis) may also be specified.
There is also a simplified version to be used with TBP and D86 boiling point curves:
AYPVT1 TBP
The compositional analysis may contain a set of discrete components (real components
such as methane etc. ) plus a series of SCN fractions. It is also possible to enter the liquid
n-paraffin SCN analysis separately from then non-n-paraffin SCN analysis. The gas phase
analysis may include an n-paraffin SCN distribution. Analytical information and may be
entered in molar units or mass units. An analysis to C30+ is routinely available and it is
often possible to obtain a much more detailed analysis. It is also possible to specify a water
cut (as a volume ratio relative to the liquid stream at stock tank conditions).
The procedure will generate a set of petroleum fraction pseudocomponents based on the
information provided. Although it is possible to represent each SCN with a separate pseudo-
component it is more usual to group SCNs to produce a smaller number of pseudocomponents
if a detailed analysis is provided. Conversely, if the analysis only extends to, say, C10, it may
be desirable to split the heavy end into several pseudocomponents. It is necessary to specify
a starting SCN for the pseudocomponents and the number of pseudocomponents required.
If a SARA analysis is provided the procedure will automatically generate asphaltene and
resin pseudocomponents with properties appropriate for the Infochem asphaltene model.
The n-paraffin distribution is used to support the Coutinho wax model (see section H.5).
If the distribution has not been measured it can be estimated from the UOP wax content
(C20+ wax content).
The calling specification for AYPVT1 is:
INTEGER LNODB, LNOPF, NNMDIS, NDISL, NDISG, CSTART, NCNL, NCNN,
+ NPFRIN, NCNG, CRSTRT, CSPLIT(2), NSPLIT(2), NDIS, NCUT,
+ ITCUT(*), LMW, LSG, LUL, NPLUL, NERR, MXERR, IERR(*)
REAL*8 ADISL(*), ACNL(*), CNCNL(*), MWCNL(*), SGCNL(*), ACNN(*),
+ MW, SG, ADISG(*), ACNG(*), GOR, SARA(4), TWC,
+ CNSPLT(MAXNCS,2), ZDIS(*), MWDIS(*), SGDIS(*), ZCUT(*),
+ CNLCUT(*), CNCUT(*), MWCUT(*), SGCUT(*), TBCUT(*),
+ TCCUT(*), PCCUT(*), WCUT(*), TMCUT(*), DHMCUT(*),
+ DSMCUT(*), DCPCUT(*), WATCUT, ZWAT, MWWAT, SGWAT, TOTAL
CHARACTER*(*) NMDIS(*), NMCUT(*)
LOGICAL LUG, ESARA, ETWC, LUT

SUBROUTINE AYPVT1( LNODB, LNOPF, CSTART, NNMDIS, NMDIS, NDISL,


+ ADISL, NCNL, ACNL, CNCNL, MWCNL, SGCNL, NCNN,
+ ACNN, LUL, MW, LMW, SG, LSG, NPLUL, NPFRIN,
+ NDISG, ADISG, NCNG, ACNG, LUG, GOR, SARA,
+ ESARA, TWC, ETWC, CRSTRT, CSPLIT, NSPLIT,
+ CNSPLT, NDIS, ZDIS, MWDIS, SGDIS, NCUT, NMCUT,
+ ZCUT, ITCUT, CNLCUT, CNCUT, MWCUT, SGCUT,

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(*)

SUBROUTINE AYPVT1_TBP( LNOPF, D86, NCN, ACN, TB_CN, MWCN, SGCN,


+ CUTUNITS, MW, LMW, SG, LSG, SARA, LSARA, TWC, LTWC, ISTART,
+ SSPLT, NSPLT, CNSPLT, NCUT, NMCUT, ZCUT, ITCUT, CNLCUT, CNCUT,
+ MWCUT, SGCUT, TBCUT, TCCUT, PCCUT, WCUT, TMCUT, DHMCUT, DSMCUT,
+ DCPCUT, WVOL, ZWAT, MWWAT, SGWAT, TOTAL, LUT, NERR, MXERR,
+ IERR)

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.

6.3 Black Oil characterisation procedure


Black Oil correlations have traditionally been used to represent petroleum fluids as three
pseudocomponents: oil, gas and water. Although such correlations can be effective when
dealing with phases of essentially fixed composition they are not applicable when compositions
change or if the fluid is a volatile oil or a condensate.
The Multiflash Black Oil characterisation procedure takes as input a minimal set of black
oil parameters and generates a compositional fluid model. The minimum input required is
liquid gravity and GOR. A better model will be generated if other properties such as the gas
gravity, Watson characterisation factor and the gas composition can be provided.
The calling specification for AYPVB1 is:
INTEGER LNODB, LNOPF, NSPLIT(*), NCUT, ITCUT(*), NERR, MXERR,

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.

6.4 Blending petroleum fluids


The blending method in Multiflash allows mixing, or blending, of already characterised
petroleum fluids to provide a new fluid characterisation, for example when two pipes in-
tersect. This routine AYBLND allows two fluids to be blended together in relative amounts
specified to produce a new fluid described by its own set of pseudo-components. The prop-
erties and relative amounts of the blend’s pseudo-components is automatically calculated by

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)

SUBROUTINE AYBLND( MODEL, N, NAME, ALIAS, CARN, TYPE, HC, Z, CN,


+ MW, SG, TB, TC, PC, W, TM, DHM, DSM, DCPM,
+ MCRKS, MCPR, VRKS, VPR, REFVIS, IDVIS, RA,
+ NERR, MXERR, IERR )
C Input arguments:
C MODEL Model pointer, 1 for RKS model, 2 for PR model
C N Number of components, (1) for first stream; (2) for second stream
C NAME Array of component names, (1) for first stream; (2) for second stream
C ALIAS Array of component aliases, (1) for first stream; (2) for second stream
C CARN Array of component CAR numbers, (1) for first stream; (2) for second
C stream
C TYPE Array of component types in first mixture, (1) for first stream; (2) for
C second stream
C HC Array of component hydrocarbon flags,(1) for first stream; (2) for
C second stream
C Z Array of component mole fractions, (1) for first stream; (2) for second
C stream
C CN Array of component carbon numbers, (1) for first stream; (2) for second
C stream
C MW Array of component molecular weights, (1) for first stream; (2) for
C second stream
C SG Array of component specific gravities, (1) for first stream; (2) for
C second stream
C TB Array of component normal boiling points, (1) for first stream; (2) for
C second stream
C TC Array of component critical temperatures, (1) for first stream; (2) for
C second stream
C PC Array of component critical pressures, (1) for first stream; (2) for
C second stream
C W Array of component acentric factors, (1) for first stream; (2) for
C second stream
C TM Array of component normal melting points, (1) for first stream; (2) for
C second stream
C DHM Array of component enthalpies of fusion, (1) for first stream; (2) for
C second stream
C DSM Array of component entropies of fusion, (1) for first stream; (2) for
C second stream
C DCPM Array of component changes in Cp on fusion, (1) for first stream; (2)
C for second stream

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.

7.1 Defining BIPs


Before defining BIPs the components in the mixture must be loaded as described in section
4. To define BIPs the following steps are involved:

1. Initialise the BIP software.

2. Open BIP databanks (if required).

3. Load BIPs

• from databanks.
• and/or entering directly

Each step is described in detail below.

7.2 Initialising the BIP software


The following call initialises the BIP data system:

CALL AYBINI()

7.3 Using BIP databanks


7.3.1 Opening BIP databanks
If binary interaction parameters (BIPs) are to be loaded from a databank or other data
source it must first be opened or selected by calling routine AYPDBO. This is the same routine
that is used for handling pure component data sources (section 4.4). The current options
are the Infochem INFOBIPS BIP databank for VLE, the Infochem INFOLLBIPS BIP databank
for LLE and the ‘oilandgas’ estimation methods for equations of state (see section 7.5). The
required option is selected by setting the argument JBANK to one of the values in ayjdbk.inc.
Note that the pure component databank structures are not valid for BIP databanks and
are not described in this section. Once the BIP bank is opened successfully the BIP data
source is subsequently referred to by the load number LNODBB, which is returned. The calling
specification is:

INTEGER, INTENT(IN) :: NFIL, NBANK, JBANK(*), MXERR


INTEGER, INTENT(OUT) :: LNODBB, NERR, IERR(*)
CHARACTER*(*), INTENT(IN) :: NAMFIL(*)

SUBROUTINE AYPDBO( NBANK, JBANK, NFIL, NAMFIL, LNODBB, NERR,


+ MXERR, IERR )
C
C Input arguments:

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 )

7.3.2 Loading BIPs from a databank


The routine AYBDBL can be called repeatedly to load as many BIP arrays into Multiflash as
are needed. Each array can then be referred to by a unique number, the BIP load number
returned by AYBDBL and then passed to the model loading routines. The calling specification
is:

INTEGER, INTENT(IN) :: LNODB, NC, IC(*), NMDL, LMDL(NMDL), NBIP,


+ MXERR
INTEGER, INTENT(INOUT) :: LNO
INTEGER, INTENT(OUT) :: NERR, IERR(*)
LOGICAL, INTENT(IN) :: INIT

SUBROUTINE AYBDBL( LNODBB, NC, IC, INIT, NMDL, LMDL, NBIP,


+ LNO, NERR, MXERR, IERR )
C
C Input arguments:
C LNODBB BIP databank load number
C NC Number of components in subcomponent list IC
C 0=all components selected from data bank
C IC Subcomponent list: array of component load numbers of the
C components selected from the data bank.
C For NC=0, values of IC ignored.
C INIT .TRUE. any BIPs for which information is available on the
C databank should be initialised,
C .FALSE. only BIPs that are currently unset to be given
C values if found on the BIP databank
C NMDL Dimension of array LMDL
C LMDL Integer array specifying the model
C NBIP BIP serial number (1=Aji or kij, 2=Aij, 3=alpha)
C MXERR maximum number of error flags to be returned in IERR
C
C Input/output arguments:
C Input values:
C LNO BIP load number. Set to 0 if a new set of BIPs is
C to be created.
C
C Output values:
C LNO BIP load number.
C If input value was 0, LNO will be set to a new value
C unless no BIPs or only ’ideal’ default BIPs found.
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 10441 Unrecognised data bank load number
C 10442 Unrecognised data bank type

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).

7.3.3 Unloading databanks


As with pure-component databanks, binary databanks can be closed to free storage. As with
pure-component databanks, this is done by calling AYPDBU as follows:

INTEGER, INTENT(INOUT) :: LNODBB


SUBROUTINE AYPDBU( LNODBB )
C
C Input/output arguments:
C LNODBB Data bank load number (set to zero on return)

If AYPDBU is called with an invalid load number no action is taken.

7.4 Entering BIPs directly


If required, additional BIPs may be entered or the existing values overwritten by calling
AYBIP USR. The old routine, AYBUSR is stil provided for backwards compatibility. This routine
can also be used to create a new BIP load number if a BIP databank call (AYBDBL) was not
used to do this. The calling specification for AYBIP USR is:

INTEGER, INTENT(IN):: NC, IC(*), IBFUN, NBCO,MXERR, ORD_DIM


INTEGER, INTENT(INOUT):: LNO
INTEGER, INTENT(OUT) :: NERR, IERR(*)
REAL*8, INTENT(IN):: DEFBIP, BCOIN(NBCO,*)
LOGICAL, INTENT(IN) :: INIT

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.

INTEGER, INTENT(IN):: NC, IC(*),IBFUN, NBCO,MXERR


INTEGER, INTENT(INOUT):: LNO
INTEGER, INTENT(OUT) :: NERR, IERR(*)
REAL*8, INTENT(IN):: DEFBIP, BCO1(*), BCO2(*), BCO3(*)
LOGICAL, INTENT(IN) :: INIT

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.

• JBFT1: the correlation has the form: B = a + bT + cT 2 where the temperature T is in


K. The BIP is dimensionless and is intended for use by an equation of state model.

• 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.

• JBFACT: the correlation has the form: B = a + bT + cT 2 where the temperature T is in


K. The BIP has units of J/mol and is intended for use by an activity 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.

• JBGERGT: Up to 3 parameters may be specified for use by the GERG model.

• JBGERGV: Up to 3 parameters may be specified for use by the GERG model.

66
• JBGERGF: 1 parameter that specified the weighting factor used by the GERG model.

• JBGELDH: up to 3 parameters for electrolyte model Deby-Huckel BIP.

• JBGELV2: up to 4 parameters for electrolyte model second virial BIP.

• JBGELV3: up to 3 parameters for electrolyte model third virial BIP.


For example, the following code sets up new load numbers and enters two sets of constant
BIPs for an activity model for a three component mixture, returning the BIP load numbers
in LNOB1 and LNOB2:

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 )

7.5 BIPs for oil and gas mixtures


BIPs for components that are typically found in oil and gas mixtures have been corelated
for the principal cubic equations of state: RKS, PR and their variants. The components
included in the correlations are: methane, other defined hydrocarbons, pseudocomponents,
CO2 , nitrogen, H2 S, water, methanethiol, ethanethiol, propanethiol, butanethiol and COS.
Hydrate inhibitors may include methanol, MEG, DEG, TEG, SALTCOMPONENT, ethanol,
isopropanol, propylene glycol and glycerol. Note that parameters for SALTCOMPONENT
are only available for the RKSA (or PRA) equation of state with the Infochem-NRTL mixing
rules. For the CPA model BIPs are included for hydrocarbons, water, methanol, ethanol,
MEG, CO2 and H2 S. For the LKP model correlations are provided for hydrocarbons, CO2 ,
nitrogen and H2 S.
BIP values may be set by using the ‘oilandgas’ estimation method by passing parameter
JBOG4 from ayjdbk.inc to subroutine AYPDBO which selects data sources. JBOG4 selects the
latest version of the Infochem BIP correlations and is the recommended option. Access to
previous correlations is provided for compatibility with earlier versions of Multiflash. JBOG3
was the default in Multiflash versions 2.7 and 2.8. JBOG2 was the default in versions 2.3 to
2.5 and JBOG1 was the correlation used prior to version 2.3.
For example, for an equation of state with a single BIP per binary:

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,*)

SUBROUTINE AYBIP_VAL( NC, IC, LNO, IBFUN, NBCO, ORD_DIM, BCO_OUT,


+ NERR, MXERR, IERR )

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.

INTEGER, INTENT(IN) :: NC, IC(*), LNO, MXERR


INTEGER, INTENT(OUT) :: IBFUN, NBCO, NERR, IERR(*)
REAL*8, INTENT(OUT) :: BCO1(*), BCO2(*), BCO3(*)

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

INTEGER, INTENT(IN) :: NC, IC(*), LNO, MXERR, ORD_DIM


INTEGER, INTENT(OUT) :: IBFUN, NBCO, IBCO_OUT(ORD_DIM,*),
+ NERR, IERR(*)

SUBROUTINE AYBVLS( NC, IC, LNO, IBFUN, NBCO, ORD_DIM, IBCO_OUT,


+ NERR, MXERR, IERR )

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

7.6.2 Freeing BIP load numbers


The routine AYBNUL is provided to free BIP load numbers:

INTEGER, INTENT(INOUT) :: LNOB


CALL AYBNUL( LNOB )
C
C Input arguments:
C LNOB BIP load number to be released

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.

7.6.3 Deleting BIPs for a component


The routine AYBDEL deletes all BIPs associated with a particular component and then deletes
it:

INTEGER, INTENT(IN) :: MXERR


INTEGER, INTENT(INOUT) :: ICO
INTEGER, INTENT(OUT) :: NERR, IERR(*)

SUBROUTINE AYBDEL( ICO, NERR, MXERR, IERR )

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:

1. Initialise the models software.

2. Load BIPs if required by the models (as described in section 7).

3. Load models.

Those steps not previously defined are described in detail below.

8.1 Initialising the Models software


The following call initialises the models and phase descriptor software:

INTEGER, INTENT(IN) :: MXERR


INTEGER, INTENT(OUT) :: NERR, IERR(*)
CALL AYMINI( NERR, MXERR, IERR )

8.2 Loading models


When a model is loaded the information that defines the model is checked and as much
initialisation as possible is carried out. This typically involves fetching any pure component
properties required and precalculating any temperature-independent model parameters or
coefficients in temperature-dependent correlations. The loading procedure returns a model
load number which is subsequently used to refer to the model. Most models can be set up
with a number of options. Each instance of the model plus options will correspond to a
different load number.
The required thermodynamic or transport property models may be loaded by calling
AYLOAD and specifying all options and which BIPs (if any) they are to use. The calling
specification is:

INTEGER, INTENT(IN) :: NMDL, LMDL(*), MXERR


INTEGER, INTENT(OUT) :: LNO, NERR, IERR(*)
LOGICAL, INTENT(IN) :: FULL

SUBROUTINE AYLOAD( NMDL, LMDL, FULL, LNO, NERR, MXERR, IERR )


C
C Input arguments:
C NMDL number of integers passed in array LMDL that fully
C define the model and its options
C LMDL integer array specifying the model. The information
C required in LMDL is model-dependent.
C FULL type of load operation required
C .TRUE. if full load required, ie. normal model load.
C .FALSE. if only a test load to check model definition
C (this option is provided to support interactive
C interfaces and is not intended for general use)
C MXERR maximum number of error codes to return in IERR
C
C Output arguments:
C LNO Model load number (unique identifier used subsequently to
C refer to the the model).
C NERR number of error codes returned in IERR
C IERR error codes. Values for this routine:

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.

8.3 Thermodynamic models


8.3.1 Cubic equations of state
The cubic EOS are described in Appendices E.3 to E.5. A more in depth description can
be read in the Models Manual that is distributed with Multiflash. The model specification
requires a primary model identifier plus a number of variant identifiers to specify the treat-
ment of the a parameter, whether a Peneloux volume correction is used, the type of mixing
rule and the correct number of BIP load numbers to match the mixing rule. The number of
possible models resulting from all combinations of these variants is large. Some of the more
common or useful combinations are shown in the table below.

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

The model variants are as follows:

JVAPI API version of RKS (Daubert and Graboski)


JVDEN T-dependent volume shift for EOS to liquid density (Peneloux)
JVDEN1 constant volume shift for EOS to liquid density (Peneloux)
JVMC Mathias-Copeman treatment for a parameter
JVNRTL Infochem NRTL-type mixing rule
JVHVPS Huron-Vidal-Pedersen (HVP) mixing rule
JVPSRK Predictive SRK parameters/mixing rule
JVPR original PR equation
JVPR78 PR78 equation
JVRK original RK equation
JVRKS original Soave version
JVSVP a parameter fitted to vapour pressure
JVSV78 a parameter for PR78 model fitted to vapour pressure
JVVDW van der Waals mixing rule
JVZJ The original ZJ Equation of State method
LBIP1 Load number for kij, Aij, or ∆gij/R binary interaction parameters
LBIP2 Load number for Aji or ∆gji/R binary interaction parameters
LBIP3 Load number for NRTL or HVP ‘alpha’ binary interaction parameters
LNOGEX Load number of activity model to use for GE mixing rule

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)

8.3.3 Free energy addition model


The free energy model allows you to combine models. This is for example necessary if you
want to use the asphaltene model or the electrolyte model.
model NMDL LMDL(1) (2) (3) (4) (5)
Free energy addition model 5 JMADD JVANAL LNOM LNOM LNOM

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 NMDL LMDL(1) (2) (3) (4) (5)


Free energy addition model 5 JMADD JVANAL LNOLRI LNOFL LNOLRE

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

8.3.4 Liquid activity equations

model NMDL LMDL(1) (2) (3) (4) (5) (6) (7)


Ideal solution 3 JMIDL LNOG Jpc
UNIFAC method
VLE variant 4 JMUNF JVVLE LNOG LNOG Jpc
LLE variant 4 JMUNF JVLLE LNOG LNOG Jpc
PSRK variant 4 JMUNF JVPSRK LNOG LNOG Jpc
UNIFACA method
VLE variant 6 JMUNFA JVORIG JVVLE 0 LNOG Jpc
LLE variant 6 JMUNFA JVORIG JVLLE 0 LNOG Jpc
PSRK variant 6 JMUNFA JVORIG JVPSRK 0 LNOG Jpc
PSRK no hydrocarbon correction 6 JMUNFA JVORIG JVPNHC 0 LNOG Jpc
Dortmund modified UNIFAC 6 JMUNFA JVDORT JVDORT 0 LNOG Jpc
UNIQUAC equation 5 JMUNQ LNOG LBIP1 LBIP2 Jpc
NRTL equation
VLE variant 7 JMNRTL JVVLE LNOG LBIP1 LBIP2 LBIP3 Jpc
LLE variant 7 JMNRTL JVLLE LNOG LBIP1 LBIP2 LBIP3 Jpc
Wilson equation
A variant 6 JMWIL JVWILA LNOG LBIP1 LBIP2 Jpc
E variant 6 JMWIL JVSL LNOG LBIP1 LBIP2 Jpc
Regular Solution
Standard regular solution 5 JMREG JVREG LNOG LBIP1 Jpc
Flory-Huggins 5 JMREG JVFH LNOG LBIP1 Jpc
Activity coefficient model for 4 JMACG JVACG LNOG LNOL
gas phase method

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

8.3.5 User-modified Unifac groups and subgroups


For each definition of a Unifac model the user can amend the subgroup and group definitions
by extending the UNIFACA definition beyond LMDL(5). LMDL(6) is set equal to the total
number of subgroup and group definitions. Each subgroup definition requires a sequence of
5 contiguous elements of LMDL as shown in the following table.

LMDL(n) LMDL(n+1) LMDL(n+2) LMDL(n+3) LMDL(n+4)


JPSUB IDSUB IEQR IEQQ IDGRP

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.

LMDL(n) LMDL(n+1) LMDL(n+2) LMDL(n+3) LMDL(n+4) LMDL(n+5)


JPGRP IDGRP1 IDGRP2 IEQIP0 IEQIP1 IEQIP2

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 NMDL LMDL(1) (2) (3) (4) (5) (6) (7)


Long-range electrolyte model
Debye-Hückel 7 JMLRE JVDH IBIP1 IBIP2 IBIP3
Debye-Hückel+Born 7 JMLRE JVDH JVBORN IBIP1 IBIP2 IBIP3
Debye-Hückel+virial 7 JMLRE JVDH 0 JVVIR IBIP1 IBIP2 IBIP3
Debye-Hückel+Born+virial 7 JMLRE JVDH JVBORN JVVIR IBIP1 IBIP2 IBIP3
Electrolyte phase check model 1 JMLRI

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 NMDL LMDL(1) (2) (3) (4) (5) (6)


Gas hydrate model
Hydrate I 3 JMHYD JVTYP1 LNOL
Hydrate II 3 JMHYD JVTYP2 LNOL
Hydrate H 3 JMHYD JVTYPH LNOL
Hydrate/ice
Nucleation model 2 JMBPN LNOS
Freeze-out model 3 JMFRZ ICO LNOL
Advanced freeze-out model
Relative to liquid 3 JMFRZA JVLIQ LNOL NDPAR JPi Pi repeated
Absolute 3 JMFRZA JVACT LNOL NDPAR JPi Pi repeated
Wax
Coutinho model
Wilson variant (recommended) 3 JMCTO JVWIL LNOL
UNIQUAC variant 3 JMCTO JVUNQ LNOL

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

8.4 Transport property models

model NMDL LMDL(1) (2) (3) (4) (5) (6)


Viscosity (gas and liquid)
Lohrenz-Bray-Clark (standard) 3 JMLBC JVLBC LNOVOL
Full specification of LBC 3+2* JMLBC JVLBC LNOVOL NDPAR JPi Pi repeat
NDPAR
LBC (fit liquid viscosity) 3 JMLBC JVLFIT LNOVOL
Pedersen (standard) 2 JMPDV JVPDV
Pedersen (fit liquid viscosity) 2 JMPDV JVLFIT
superTRAPP (standard) 2 JMSPTV JVSPTV
superTRAPP (fit liquid viscosity) 2 JMSPTV JVLFIT
Viscosity (gas)
Vapour mixing rule 1 1 JMVVS1
Viscosity (liquid)
Liquid mixing rule 1 1 JMLVS1
Twu (standard) 2 JMTWV JVTWV
Twu (fit liquid viscosity) 2 JMTWV JVLFIT
Thermal conductivity
(gas and liquid)
Chung-Lee-Starling 2 JMCLS LNOVOL
superTRAPP 2 JMSPTH JVSPTH
Thermal conductivity (gas)
Vapour mixing rule 1 1 JMVTC1
Thermal conductivity (liquid)
Liquid mixing rule 1 1 JMLTC1
Surface tension
Linear Gradient Theory 4 JMLGST 0 LNOVOL LBIP
MacLeod-Sugden 1-phase 3 JMMCS JV1PHA LNOVOL
MacLeod-Sugden 2-phase 3 JMMCS JV2PHA LNOVOL
Sutton Model 2 JMSUT LNOVOL
Mixing rule 1 1 JMST1
Diffusivity (gas)
Chapman-Enskog (LJ) 3 JMCED JVLJ LBIP
Chapman-Enskog (Brockaw) 3 JMCED JVBROK LBIP
Chapman-Enskog (Wilke-Lee) 3 JMCED JVWL LBIP
Chapman-Enskog (Fuller) 3 JMCED JVFULL LBIP
Diffusivity (liquid)
Hayduk-Minhas 5 JMLQD JVHM LNOLIQ LNOVIS LBIP
Tyn-Calus 5 JMLQD JVTC LNOLIQ LNOVIS LBIP

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.

8.5 Information about a loaded model


The definition of a model can be requested from the model load number using AYGTLO. The
LMDL array returns the integers used to specify the model when it was defined using AYLOAD.

INTEGER, INTENT(IN) :: LNO, N


INTEGER, INTENT(OUT :: NMDL, LMDL(N)

SUBROUTINE AYGTLO( LNO, N, NMDL, LMDL )


C
C Input arguments:
C LNO Model load number
C N Dimension of array LMDL
C
C Output arguments:
C NMDL Number of integers stored to specify model,
C 0=load number not found
C LMDL Integer array specifying the model

8.6 Setting model parameter data values


The model parameter data values (Pi in the above table) are real numbers that must be
entered in the LMDL array using the function AYMPDV defined below.

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

INTEGER, INTENT(IN) :: PARVAL


REAL*8 FUNCTION AYMPDV_R( PARVAL )

8.7 Freeing model load numbers


The routine AYUNLO is provided to free model load numbers:

INTEGER, INTENT(INOUT) :: LNO


CALL AYUNLO( LNO )

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.8 Reinitialising models


Routine AYRELA is provided to force all currently defined models to be reinitialised using the
currently defined pure-component data. The procedure is useful if any of the pure-component
data have been modified by calling subroutines such as AYPSTR, etc. The calling procedure
is:

INTEGER, INTENT(IN) :: MXERR


INTEGER, INTENT(OUT) :: NERR, MXERR, IERR(*)

CALL AYRELA( NERR, MXERR, IERR )


C
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 error codes. None for this routine

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

Further examples are provided in Appendix N.

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.

9.1 Setting up phase descriptors


The following steps are required to set up PDs.

9.1.1 Initialise PD system


The PD system is initialised at the same time as the models system by calling AYMINI. See
section 8.1.

9.1.2 Define PDs


Each phase descriptor is set up by calling AYDFPD. This routine returns a PD load number
which is subsequently used in calls to all routines that deal with mixtures. The calling
specification is as follows:

INCLUDE ’aympd.inc’
INTEGER, INTENT(IN) :: PHID, KEY, LNOMOD(MXMDPD), MXERR
INTEGER, INTENT(OUT) :: LNOPD, NERR, IERR(*)

SUBROUTINE AYDFPD( PHID, KEY, LNOMOD, LNOPD, NERR, MXERR, IERR )


C
C Input arguments:
C PHID phase type identifier for the phase descriptor.
C The phase codes used are defined in AYPTID.INC
C KEY key component identifier for the phase descriptor.
C The key component is used to label PDs which
C would otherwise be indistinguishable and/or to control
C the setting up of new phases in phase stability tests.
C KEY may be set to zero if no key component is required.
C Otherwise, ABS(KEY) is the component load number for the
C key component.
C A positive value of KEY means that the component should
C be present in the phase with a high concentration
C (relative to the total mixture composition) and a
C negative value of KEY key means that the component should
C be present in a low concentration.
C Alternatively, the parameters JCMHVY and JCMLIT from
C AYJXID.INC may be used to define the heaviest or
C lightest component as the key component.
C LNOMOD model load numbers in phase descriptor definitions.
C The load number for at least one of the properties listed
C below must be defined. The load numbers for other
C properties may be set to zero if not required.
C (1) fugacity coefficient model load number
C (2) volumetric properties model load number

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.

9.2 Getting PD information


9.2.1 PDs defined
The routine AYNPD returns the number of PDs currently defined and their identifiers:

INCLUDE ’aympd.inc’
INTEGER, INTENT(OUT) :: NPD, IPD(MAXPD)

SUBROUTINE AYNPD( NPD, LNOPD )


C
C Output arguments:
C NPD number of phase descriptors defined
C LNOPD array of phase descriptor load numbers

9.2.2 Phase, key component and models associated with a PD


The routine AYGTPD returns information about a PD:

INCLUDE ’aympd.inc’
INTEGER, INTENT(IN) :: LNOPD, MXERR
INTEGER, INTENT(OUT) :: PHID, KEY, LNOMOD(MXMDPD), NERR, IERR(*)

SUBROUTINE AYGTPD( LNOPD, PHID, KEY, LNOMOD, NERR, MXERR, IERR )


C
C Input arguments:
C LNOPD phase descriptor load number
C MXERR maximum number of error codes to return in IERR
C
C Output arguments:
C PHID phase type identifier for the phase descriptor.
C The phase codes used are defined in AYPTID.INC
C KEY key component identifier for the phase descriptor.
C KEY is zero if no key component has been specified
C otherwise ABS(KEY) is a component load number.
C If KEY is positive it means that the component should be
C present in the phase in a high concentration. If KEY is
C negative it means that the component should be present in
C zero or low concentration.
C Alternatively, one of the parameters JCMHVY and JCMLIT from

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:

INTEGER, INTENT(IN) :: MXERR


INTEGER, INTENT(INOUT) :: LNOPD
INTEGER, INTENT(OUT) :: NERR, IERR(*)

SUBROUTINE AYRMPD( LNOPD, NERR, MXERR, IERR )


C
C Input arguments:
C LNOPD load number of the PD to be removed
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 error codes. Values for this routine:
C 10301 LNOPD not a valid PD identifier

After this call, the PD referred to by LNOPD is no longer defined.

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.

10.1 Thermodynamic properties: AYMIX


Calculations of the thermodynamic properties of mixtures using any successfully loaded phase
descriptor may be performed by calling the standard interface AYMIX. AYMIX can calculate
the fugacity coefficients, volume, enthalpy and entropy together with the derivatives of these
quantities with respect to pressure, temperature and mole numbers for a mixture of specified
composition and conditions. Any combination of properties and derivatives can be requested
with any combination of models previously defined in the phase descriptor. All the derivatives
are calculated using analytical expressions. A working example of a complete program is
provided in Appendix N.2.1. The calling specification for AYMIX is as follows:

INTEGER, INTENT(IN) :: LNOPD, IPHREQ, IPHID, NC, IC(*), IHTYPE, MXERR


INTEGER, INTENT(OUT) :: NERR, IERR(*)
REAL*8, INTENT(IN) :: T, P
REAL*8, INTENT(OUT) :: Z(*), V, VT, VP, VN(*), FUG(*), FUGT(*), FUGP(*)
REAL*8, INTENT(OUT) :: FUGN(*), H, HT, HP, HN(*), S, ST, SP, SN(*), ZFUG
LOGICAL, INTENT(IN) :: DV(0:3), DF(0:3), DH(0:3)
LOGICAL, INTENT(OUT) :: AMBIG

SUBROUTINE AYMIX( LNOPD, IPHREQ, IPHID, AMBIG, ZFUG, T, P, NC, IC,


+ Z, DV, V, VT, VP, VN, DF, FUG, FUGT, FUGP, FUGN,
+ IHTYPE, DH, H, HT, HP, HN, S, ST, SP, SN,
+ NERR, MXERR, IERR )
C
C Input arguments:
C LNOPD Phase descriptor load number
C IPHREQ Requested phase
C (parameter values from file ayjxid.inc):
C JPHDEF default, i.e as in phase descriptor
C JPHMGE phase of minimum Gibbs energy
C JPHASP effective phase (Aspen method) for equations of state
C JPHPSU as JPHASP but default phase is returned if the model
C is able to solve for that phase
C T Temperature (K)
C P Pressure (Pa)
C NC Number of components in subcomponent list IC.
C 0=all components selected from data bank
C IC Subcomponent list: array of load numbers of the
C components selected from the data bank.
C For NC=0, values of IC ignored.
C Z Mole numbers of components
C DV Array of logical flags to control calculation of volume
C and derivatives. Set elements TRUE to return required
C quantities, otherwise set FALSE. The volume itself must
C always be requested if any derivatives are required.
C DV(0) = volume
C DV(1) = T derivative
C DV(2) = P derivative
C DV(3) = mole number derivatives

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).

10.2 Enthalpy and entropy for activity coefficient models


Pure component enthalpy and entropy for activity coefficient models are by default calculated
from the perfect gas heat capacity, residual vapour enthalpy/entropy and heat of vaporisation.
To calculate enthalpy and entropy for the liquid phase from liquid heat capacity instead,
specify the pure component property, CPIDLIQ = 1. This is done by calling AYPSTR with:
JVALUE = JCPLIQ
RCONST = 1.D0

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.

10.3 Average molecular weight: AYAVMW


To calculate the average molecular weight of a mixture call AYAVMW:

INTEGER, INTENT(IN) :: NCO, IC(*), MXERR


INTEGER, INTENT(OUT) :: NERR, IERR(*)
REAL*8, INTENT(IN) :: Z(*)
REAL*8, INTENT(OUT) :: AVMW, AVMWN(*)
LOGICAL, INTENT(IN) :: D

SUBROUTINE AYAVMW( NCO, IC, Z, D, AVMW, AVMWN, NERR, MXERR, IERR )


C
C Input arguments:
C NCO Number of components in subcomponent list IC.
C 0=all components selected from data bank
C IC Subcomponent list: array of load numbers of the
C components selected from the data bank.
C For NC=0, values of IC ignored.

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

10.4 Viscosity: AYVISC


To obtain the viscosity of a phase and its analytical derivatives call AYVISC:

INTEGER, INTENT(IN) :: LNOPD, NC, IC(*), MXERR


INTEGER, INTENT(OUT) :: NERR, IERR(*)
REAL*8, INTENT(IN) :: T, P, Z(*)
REAL*8, INTENT(OUT) :: VIS, VIST, VISP, VISN(*)
LOGICAL, INTENT(IN) :: DER(3)

SUBROUTINE AYVISC( LNOPD, T, P, NC, IC, Z, DER, VIS, VIST,


+ VISP, VISN, NERR, MXERR, IERR )
C
C Input arguments:
C LNOPD Phase descriptor load number
C T temperature (K)
C P pressure (Pa)
C NC number of components in subcomponent list IC.
C 0=all components selected from data bank
C IC subcomponent list: array of load numbers of the
C components selected from the data bank.
C For NC=0, values of IC ignored.
C Z mole numbers of components
C DER derivative flags. Set elements TRUE to
C return required derivatives, otherwise set FALSE:
C DER(1) = T derivatives
C DER(2) = P derivatives
C DER(3) = mole number derivatives
C MXERR maximum number of error codes to return in IERR
C
C Output arguments:
C VIS viscosity (Pa s)
C VIST derivative of VIS wrt temperature
C VISP derivative of VIS wrt pressure
C VISN derivative of VIS wrt mole numbers
C NERR number of error codes returned in IERR
C IERR error codes. Values for this routine:
C -10201 phase descriptor has no defined viscosity model
C 10201 load number does not refer to a valid
C viscosity model
C 10202 failure in viscosity model
C 10203 requested phase type does not exist (unstable)

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)

SUBROUTINE AYTCND( LNOPD, T, P, NC, IC, Z, DER, TCN, TCNT,


+ TCNP, TCNN, NERR, MXERR, IERR )
C
C Input arguments:
C LNOPD Phase descriptor load number
C T temperature (K)
C P pressure (Pa)
C NC number of components in subcomponent list IC.
C 0=all components selected from data bank
C IC subcomponent list: array of load numbers of the
C components selected from the data bank.
C For NC=0, values of IC ignored.
C Z mole numbers of components
C DER derivative flags. Set elements TRUE to
C return required derivatives, otherwise set FALSE:
C DER(1) = T derivatives
C DER(2) = P derivatives
C DER(3) = mole number derivatives
C MXERR maximum number of error codes to return in IERR
C
C Output arguments:
C TCN thermal conductivity (W/m K)
C TCNT derivative of TCN wrt temperature
C TCNP derivative of TCN wrt pressure
C TCNN derivative of TCN wrt mole numbers
C NERR number of error codes returned in IERR
C IERR error codes. Values for this routine:
C -10241 phase descriptor has no defined thermal conductivity model
C 10241 load number does not refer to a valid
C thermal conductivity model
C 10242 failure in thermal conductivity model
C 10243 requested phase type does not exist (unstable)

10.6 Surface tension: AYSURF


To obtain the surface tension of a phase and its analytical derivatives call AYSURF. The surface
tension routine differs from all other property routines in that it accepts two phase descriptor
load numbers. This is because the surface tension depends on the properties of two phases.
The load numbers LNOPD1 and LNOPD2 must refer to PDs with the same surface tension model.
However, the surface tension models may refer to different subsidiary models such as models
for volumetric properties. In practise, most engineering models are one phase models that
ignore the gas phase - examples include the ST1 mixing rule and the one-phase variant of
the MCS model. In such cases LNOPD2 should be set to zero.
The Linear Gradient Theory, which always needs the definition of two phases, will fail if
only one phase load number is passed.
INTEGER, INTENT(IN) :: NC, IC(*), LNOPD1, LNOPD2, MXERR

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)

SUBROUTINE AYSURF( T, P, NC, IC, LNOPD1, Z1, LNOPD2,


+ Z2, DER, ST, STT, STP, STN1, STN2,
+ NERR, MXERR, IERR )
C
C Input arguments:
C T temperature (K)
C P pressure (Pa)
C NC number of components in subcomponent list IC.
C 0=all components selected from data bank
C IC subcomponent list: array of load numbers of the
C components selected from the data bank.
C For NC=0, values of IC ignored.
C LNOPD1 Phase descriptor load number for phase 1 (usually the
C the liquid phase)
C Z1 mole numbers of components in phase 1
C LNOPD2 Phase descriptor load number for phase 2 (usually the
C gas phase for a 2-phase model, should be set to zero if
C a one-phase model)
C Z2 mole numbers of components in phase 2 (unused if
C LNOPD2=0)
C DER derivative flags. Set elements TRUE to
C return required derivatives, otherwise set FALSE:
C DER(1) = T derivatives
C DER(2) = P derivatives
C DER(3) = mole number derivatives for phase 1
C DER(4) = mole number derivatives for phase 2
C MXERR maximum number of error codes to return in IERR
C
C Output arguments:
C ST surface tension (N m-1)
C STT derivative of ST wrt temperature
C STP derivative of ST wrt pressure
C STN1 derivative of ST wrt mole numbers in phase 1
C STN2 derivative of ST wrt mole numbers in phase 2
C NERR number of error codes returned in IERR
C IERR error codes. Values for this routine:
C -10221 phase descriptor has no defined surface tension model
C 10221 load number does not refer to a valid
C surface tension model
C 10222 failure in ST model
C 10223 load numbers for ST models are different for the
C 2 phases
C 10224 invalid option for ST model

10.7 Binary diffusion coefficient: AYDIFF


To obtain the binary diffusion coeffients of components in a fluid phase and the analytical
derivatives call AYDIFF:

INTEGER, INTENT(IN) :: LNOPD, NC, IC(*), NCDIM, MXERR


INTEGER, INTENT(OUT) :: NERR, IERR(*)
REAL*8, INTENT(IN) :: T, P, Z(*)

91
REAL*8, INTENT(OUT) :: DC(NCDIM,*), DCT(NCDIM,*), DCP(NCDIM,*),
+ DCN(NCDIM,NCDIM,*)
LOGICAL, INTENT(IN) :: DER(3)

SUBROUTINE AYDIFF( LNOPD, T, P, NCDIM, NC, IC, Z, DER, DC, DCT,


+ DCP, DCN, NERR, MXERR, IERR )
C
C Input arguments:
C LNOPD Phase descriptor load number
C T Temperature (K)
C P Pressure (Pa)
C NCDIM Dimension of diffusion coefficient array DC declared in
C calling routine. NCDIM must be greater than or equal to the
C the number of components for the stream type.
C NC Number of components in subcomponent list IC.
C 0=all components selected from data bank
C IC Subcomponent list: array of load numbers of the
C components selected from the data bank.
C For NC=0, values of IC ignored.
C Z Mole numbers of components (ignored by models that do not
C require the fluid composition as input)
C DER Derivative flags. Set elements TRUE to
C return required derivatives, otherwise set FALSE:
C DER(1) = T derivatives
C DER(2) = P derivatives
C DER(3) = mole number derivatives
C MXERR Maximum number of error codes to return in IERR
C
C Output arguments:
C DC Diffusion coefficients
C DCT Derivative of DC wrt temperature
C DCP Derivative of DC wrt pressure
C DCN Derivative of DC wrt mole numbers
C NERR Number of error codes returned in IERR
C IERR Error codes. Values for this routine:
C -10381 phase descriptor has no defined diffusivity model
C 10381 load number does not refer to a valid diffusivity model
C 10382 failure in diffusivity model
C 10383 requested phase type does not exist (unstable)

10.8 Specification of datum: AYDATM


Set the enthalpy and entropy datum for the specified components by calling: AYDATM:

INTEGER, INTENT(IN) :: NCO, IC(*), HDATM, SDATM, MXERR


INTEGER, INTENT(OUT) :: NERR, IERR(*)

SUBROUTINE AYDATM( NCO, IC, HDATM, SDATM,


+ NERR, MXERR, IERR )

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.

11.1 Setting up streams


The following steps are required to set up streams.

11.1.1 Initialise stream type system


The stream type system is initialised at the same time as the phase equilibrium module by
making a call to AXINIT. See section 12.4.

11.1.2 Define stream types


Each stream type is set up by calling AXDFST. This routine returns a stream load number
which is subsequently used in calls to all routines that deal with equilibrium calculations.
The calling specification is as follows:

INTEGER, INTENT(IN) :: NC, IC(*), NPD, IPD(*), MXERR


INTEGER, INTENT(OUT) :: IST, NERR, IERR(*)

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

11.2 Getting stream type information


11.2.1 Number of stream types defined
The routine AXNST returns the number of stream types currently defined and their identifiers:

94
INCLUDE ’axpara.inc’
INTEGER, INTENT(OUT) :: NST, IST(MAXST)

SUBROUTINE AXNST( NST, IST )


C
C Output arguments:
C NST Number of stream types defined
C IST Stream type identifiers

11.2.2 Phase descriptors and components associated with a stream type


The routine AXGTST returns information about a stream type:

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

11.3 Removing a stream type


The maximum number of stream types that can be defined is set by the parameter MAXST
in the include file axpara.inc. If a previously defined stream type is no longer needed it
may be removed by calling AXRMST. This call frees storage and allows new stream types to be
defined if the maximum had been reached. The calling specification is:

INTEGER, INTENT(IN) :: MXERR


INTEGER, INTENT(INOUT) :: IST
INTEGER, INTENT(OUT) :: NERR, IERR(*)

SUBROUTINE AXRMST( IST, NERR, MXERR, IERR )


C
C Input arguments:
C IST Identifier of the stream type to be removed. It is set to zero on output.
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 Error codes. Values for this routine:
C 20431 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:

• flashes at fixed pressure and temperature;

• isenthalpic flashes at fixed pressure or temperature;

• isentropic flashes at fixed pressure or temperature;

• isochoric flashes at fixed pressure or temperature;

• flashes at fixed internal energy and pressure or temperature;

• fixed (molar) phase fraction flashes (e.g. dew or bubble points) at defined pressure or
temperature.

• fixed mass phase fraction flashes at defined pressure or temperature.

• fixed volume phase fraction flashes 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:

M. L. Michelsen, The isothermal flash problem. Part I. Stability, Fluid Phase


Equilibria, 9, 1-19 (1982).
M. L. Michelsen, The isothermal flash problem. Part II. Phase-split calculations,
Fluid Phase Equilibria, 9, 21-40 (1982).

12.2 Multiflash operation


Multiflash is designed to allow use of different thermodynamic models for different phases and
for different properties of a given phase. The solution methods used do not make any assump-
tions about thermodynamic consistency between fugacity coefficients, volumetric properties,
and thermal properties. It is the implementer’s responsibility to ensure that the same fu-
gacity reference state is used for all phases and that a sensible combination of models for
different phases is specified.
A typical sequence of operations for using Multiflash is:

1. Initialise physical properties data system, define databanks and load the components
(section 4).

2. Define or load sets of BIPs (section 7).

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).

7. Algorithm parameters for Multiflash eg. (convergence tolerances or iteration limits)


may be set to values different from the internal defaults by calling any of the following
entry functions:

AXSE01 parameters for the 1st order phase split calculation


AXSE02 parameters for the 2nd order phase split calculation
AXSE03 parameters for the stability test
AXSE04 parameters for the T/P search algorithms

See section 12.10 for guidelines on setting algorithm parameters to enhance convergence
in difficult regions or to reduce computation time.

8. Call one of the top level routines to do a calculation:

AXFL01 isothermal flash


AXFL02 fixed phase fraction (FPF), isenthalpic, isentropic, isochoric flash or
flash at constant internal energy
AXFL04 double flash (HV, UV, etc.
AXST01 stability test on a mixture (all flashes include stability tests, this routine is
intended for doing a stability test without a flash)

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.

12.3 Thermodynamic property interface


The maximum number of components that Multiflash can handle is set by the parameter
MAXNCS. The maximum number of phases that may be present at equilibrium is set by the
parameter MAXPHA. Both parameters are defined in the include file axpara.inc. Note that
the maximum number of phases that may be considered (as possible equilibrium phases) by
Multiflash is set by the parameter MAXPD in the file aympd.inc.
The algorithms used in Multiflash do not assume that the same thermodynamic model is
used to represent all phases, or that different properties such as the enthalpy and the fugacity
are mutually consistent. The characteristics required of the property package are:

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.

12.4 Initialising the phase equilibrium module


Once the databank(s), components, models and phase descriptors have been defined, Multi-
flash and the stream type system should be initialised by calling AXINIT. The calling specifi-
cation is as follows:

INTEGER, INTENT(IN) :: MXERR,


INTEGER, INTENT(OUT) :: NERR, IERR(*)

SUBROUTINE AXINIT( NERR, MXERR, IERR )

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.

12.5 Flash at fixed pressure and temperature: AXFL01


AXFL01 calculates a flash at fixed pressure and temperature. This combination of variables
leads to a unique solution of the phase equilibrium problem. The calling specification is:

INTEGER, INTENT(IN) :: LNOST, NCDIM, NPHMAX, ISTABI, NPRINT, MXERR


INTEGER, INTENT(INOUT) :: NP, LNOPD(*)
INTEGER, INTENT(OUT) :: IPHID(*),
+ ISTABO, NERR, IERR(*)
REAL*8, INTENT(IN) :: T, P, NMOLIN(*)
REAL*8, INTENT(INOUT) :: X(NCDIM,*), NMOLPH(*)
REAL*8, INTENT(OUT) :: ZCOMP(*)

98
LOGICAL, INTENT(IN) :: FEST1

SUBROUTINE AXFL01( LNOST, T, P, NCDIM, NMOLIN, NPHMAX, FEST1,


+ ISTABI, NP, LNOPD, X, NMOLPH, ZCOMP, IPHID,
+ ISTABO, NPRINT, NERR, MXERR, IERR )
C
C Input arguments:
C LNOST stream type load number for flash (obtained by calling
C AXDFST). This defines the phase descriptors (PDs) and
C components to be considered in the flash. If set to zero
C this means that all PDs and components will be included.
C T temperature (K)
C P pressure (Pa)
C NCDIM dimension of mole fraction array X declared in calling
C routine. NCDIM must be greater than or equal to the
C the number of components for the stream type.
C NMOLIN number of moles of each component in the feed
C NPHMAX The maximum number of coexisting phases that the flash
C calculation is to search for. The maximum number of
C phases that may actually be returned by AXFL01 is the
C minimum of NPHMAX, the number of phases in the stream
C type (NPD) and MAXPHA (the maximum number of coexisting
C phases for which AXFL01 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 FEST1 logical flag indicating whether an estimate of the
C solution is supplied.
C .TRUE. values of NP, LNOPD, X and NMOLPH must be supplied.
C .FALSE. the initial phase distribution is obtained from a
C stability analysis using the phase descriptors
C specified in the stream type.
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 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, X and NMOLPH.
C LNOPD If FEST1 is .TRUE. LNOPD must be set on entry.
C Array of NP PD load numbers corresponding to input

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

12.6 Temperature or pressure searches and tolerance calculations: AXFL02


AXFL02 performs flashes where one variable is adjusted to satisfy a constraint. The variables
may be either the temperature, the pressure or, for tolerance calculations, the amount of a
second fluid mixture (expressed as a molar fraction) that should be added to the feed. The
possible constraints are:
1. Total enthalpy H
2. Total entropy S
3. Total volume V
4. Total internal energy U
5. Phase fraction (molar, mass or volume basis)
6. Nucleation rate
The phase fraction can be fixed for any phase for which a phase descriptor has been defined in
the stream type passed to AXFL02 and includes dew and bubble point calculations as special
cases. On convergence, the pressure, temperature or fluid fraction is returned together with
the amounts and compositions of the phases present at equilibrium.
For tolerance calculations, a combination ratio, t, is returned in the argument VAR, which
is defined such that:
ni = nfeed
i (1 − t) + nadd
i t (1)
where nfeed
i is the number of moles of component i in the feed, and nadd
i is the number of moles
of component i in the fluid mixture that is to be added to the feed. For a tolerance calculation,
the array NMOLIN passed to AXFL02 must be doubly dimensioned to carry both compositions:
NMOLIN(I,1) is assigned the value of nfeed i and NMOLIN(I,2) is assigned the value of nadd i .
For non-tolerance calculations, NMOLIN may be either singly or doubly dimensioned and only
carries the feed compositions either as NMOLIN(I) or NMOLIN(I,1).
If the same total number of moles is defined in each of the two fluids, t is equal to the
molar fraction of fluid 2 relative to the mixed fluid, and the molar amount of the second fluid
to be added to obtain the specification is then given by:
t
N2 = N feed (2)
1−t

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:

INTEGER, INTENT(IN) :: LNOST, IVAR, NCDIM, NPHMAX, IPROB(3), ISTABI,


+ NPRINT, MXERR
INTEGER, INTENT(INOUT) :: NP, LNOPD(*)
INTEGER, INTENT(OUT) :: IPHID(*), ISTABO, NERR, IERR(*)
REAL*8, INTENT(IN) :: NMOLIN(NCDIM,*), TARGET
REAL*8, INTENT(INOUT):: T, P, VAR, XX(NCDIM,*), NMOLPH(*)
REAL*8, INTENT(OUT) :: ZCOMP(*)
LOGICAL, INTENT(IN) :: FEST1, FEST2

SUBROUTINE AXFL02( LNOST, IVAR, T, P, VAR, NCDIM, NMOLIN,


+ NPHMAX, IPROB, TARGET, FEST1, FEST2, ISTABI,
+ NP, LNOPD, XX, NMOLPH, ZCOMP, IPHID, ISTABO,
+ NPRINT, NERR, MXERR, IERR )
C
C Input arguments:
C LNOST stream type load number for flash (obtained by calling
C AXDFST). This defines the phase descriptors (PDs) and
C components to be considered in the flash. If set to zero
C this means that all PDs and components will be included.
C IVAR code denoting variable to search for:
C (codes are defined in axjnum.inc)
C JXTEMP temperature
C JXPRES pressure
C JXTOL tolerance variable
C JXDVIX deviation index
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 stream type.
C NMOLIN number of moles of each component in the feed and in the
C fluid mixture to be added in tolerance calculations.
C NPHMAX The maximum number of coexisting phases that the flash
C calculation is to search for. The maximum number of
C phases that may actually be returned by AXFL02 is the
C minimum of NPHMAX, the number of phases in the stream

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.

12.7 Search for hydrate temperature or pressure: AXHYD


A special version of AXFL02 has been developed that is useful for hydrates.
In hydrates, when solving for the hydrate phase is not alwyas possible to predict if the
hydrate that is going to form is Hydrate I or II or H.
This function mimics what is done in the GUI when the user presses the hydrate P or T
buttons to get the most stable hydrate at the current Pressure and Temperature , respectevily.
The particular difference between AXHYD and AXFL02 are:

• the constraint for phase amount is set to 0.0

• can only search T or P

• the most stable hydrate phase load number is returned

The calling specification for AXHYD is:

LOGICAL, INTENT(IN) :: Fest1, Fest2


INTEGER, INTENT(IN) :: Lnost, Ivar, Ncdim, Nphmax, Istabi, Nprint, Mxerr
INTEGER, INTENT(OUT) :: Istabo, Nerr, Ierr(*), Iphid(*), Np, Lnbest
INTEGER, INTENT(INOUT) :: Lnopd(*)
REAL*8, INTENT(IN) :: Nmolin(Ncdim, *)
REAL*8, INTENT(INOUT) :: T, P, Xx(Ncdim, *), Nmolph(*)
REAL*8, INTENT(OUT) :: Zcomp(*)

SUBROUTINE AXHYD ( Lnost, Ivar, T, P, Ncdim, Nmolin, Nphmax, Fest1, &


Fest2, Istabi, Np, Lnopd, Xx, Nmolph, Zcomp, Iphid, &
Istabo, Lnbest, Nprint, Nerr, Mxerr, Ierr)
!
! Input arguments:
! Lnost stream type load number for flash (obtained by calling
! AXDFST). This defines the phase descriptors (PDs) and
! components to be considered in the flash. If set to zero
! this means that all PDs and components will be included.
! Ivar code denoting variable to search for:
! (codes are defined in axjnum.inc)
! JXTEMP temperature
! JXPRES pressure
! Ncdim dimension of mole fraction arrays NMOLIN and XX declared
! in calling routine. NCDIM must be greater than or equal
! to the the number of components for the stream type.
! Nmolin number of moles of each component in the feed and in the
! fluid mixture to be added in tolerance calculations.
! Nphmax The maximum number of coexisting phases that the flash
! calculation is to search for. The maximum number of
! phases that may actually be returned by AXFL02 is the
! minimum of NPHMAX, the number of phases in the stream
! type (NPD) and MAXPHA (the maximum number of coexisting
! phases for which AXFL02 is set up). The parameter MAXPHA
! is defined in the file AXPARA.INC. If NPHMAX is outside
! the range 1 to MAXPHA it is equivalent to setting it to

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.

12.8 Double flashes: AXFL04


AXFL04 calculates flashes where two variables are adjusted to match two constraints. The
variables and constraints are as for AXFL02, i.e. temperature, pressure or fluid fraction
(tolerance) and:

1. Total enthalpy H

2. Total entropy S

3. Total volume V

4. Total internal energy U

5. Phase fraction (molar, mass or volume basis)

6. Phase nucleation rate

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:

INTEGER, INTENT(IN) :: LNOST, IVAR1, IVAR2, NCDIM, NPHMAX, IPROB1(3), IPROB2(3),


+ ISTABI, NPRINT, MXERR
INTEGER, INTENT(INOUT) :: NP, LNOPD(*)
INTEGER, INTENT(OUT) :: IPHID(*), ISTABO, NERR, IERR(*)
REAL*8, INTENT(IN) :: NMOLIN(NCDIM,*), TARG1, TARG2, TOLIN
REAL*8, INTENT(INOUT) :: T, P, XX(NCDIM,*), NMOLPH(*)
REAL*8, INTENT(OUT) :: ZCOMP(*)
LOGICAL, INTENT(IN) :: FEST1, FEST2

SUBROUTINE AXFL04( LNOST, IVAR1, IVAR2, T, P, TOLIN, NCDIM,


+ NMOLIN, NPHMAX, IPROB1, IPROB2, TARG1, TARG2,
+ FEST1, FEST2, ISTABI, NP, LNOPD, XX, NMOLPH,
+ ZCOMP, IPHID, ISTABO, NPRINT, NERR, MXERR,
+ IERR )
C
C Input arguments:
C LNOST stream type load number for flash (obtained by calling
C AXDFST). This defines the phase descriptors (PDs) and
C components to be considered in the flash. If set to zero
C this means that all PDs and components will be included.
C IVAR1 code denoting variable to search for in outer loop:
C (codes are defined in axjnum.inc)
C JXTEMP temperature
C JXPRES pressure
C JXTOL tolerance variable
C IVAR2 code denoting variable to search for in inner loop
C (codes as for IVAR1)
C NCDIM dimension of mole fraction array XX declared in calling
C routine. NCDIM must be greater than or equal to the
C the number of components for the stream type.
C NMOLIN number of moles of each component in the feed
C NPHMAX The maximum number of coexisting phases that the flash
C calculation is to search for. The maximum number of
C phases that may actually be returned by AXFL04 is the
C minimum of NPHMAX, the number of phases in the stream
C type (NPD) and MAXPHA (the maximum number of coexisting
C phases for which AXFL04 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 IPROB1 identifer for type of calculation required for outer loop
C IPROB1(1) = problem type

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.

12.9 Stability test: AXST01


AXST01 can perform an independent phase stability analysis on a mixture to detect if any
further phases may form. The routine will determine which is the most stable single phase
for the input composition (out of the list of available phases in the stream LNOST) and then
finds composition of incipient coexisting phases. The incipient phases may either reduce the

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:

INTEGER, INTENT(IN) :: LNOST, MAXIP, NPRINT, MXERR


INTEGER, INTENT(INOUT):: IPD0, NIP, IPDIP(MAXIP)
INTEGER, INTET(OUT) :: IPHID(MAXIP), ISTABO, NERR, IERR(*), IPHID0,
REAL*8, INTENT(IN) :: T, P, NMOLIN(MAXNCS)
REAL*8, INTENT(INOUT) :: XIP(MAXNCS,MAXIP)
REAL*8, INTENT(OUT) :: ZCOMP0, GSTB(MAXIP),ZCOMP(MAXIP)
LOGICAL, INTENT(IB) :: FEST
LOGICAL, INTENT(UNOUT) :: ALLTP

SUBROUTINE AXST01( LNOST, T, P, NMOLIN, MAXIP, FEST, IPD0, IPHID0,


+ ZCOMP0, NIP, IPDIP, GSTB, XIP, ZCOMP, IPHID,
+ ALLTP, ISTABO, NPRINT, NERR, MXERR, IERR )
C
C Input arguments:
C LNOST stream type load number for flash
C T temperature (K)
C P pressure (Pa)
C NMOLIN number of moles of each component in the mixture to be
C tested for stability
C MAXIP maximum number of incipient phases for which compositions
C etc. may be returned
C FEST Logical flag: determines whether information on most
C stable phase and estimates of incipient phase
C compositions are supplied or internally generated
C = T information must be supplied in IPD0, NIP, XIP and
C IPDIP (see below)
C = F most stable phase and incipient phases are
C determined automatically.
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 flags to be returned in IERR
C
C Input/output arguments:
C Input values:
C ALLTP Logical flag, controls number of trial phases generated
C for the stability test.
C = T TPs for all PDs (including that used for the most
C stable phase) this is the most exhaustive search
C = F TPs for PDs corresponding to the phases other
C than the most stable phase.
C If FEST is .TRUE. the following must be set:
C IPD0 phase descriptor for test mixture in reference phase,
C i.e. the phase for which stability is being tested.
C NIP number of incipient phases set in IPDIP and XIP
C IPDIP phase descriptor for each incipient phase.
C XIP initial estimates of incipient phase compositions.
C XIP(I,K) holds the composition (mole fraction) of
C component I in the Kth incipient phase
C

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)

12.10 Setting low-level calculation options


All the phase equilibrium algorithms use the following elements: first order phase split; second
order phase split; stability test. See the references to Michelsen’s work for a mathematical
description. In some circumstances it may be desirable to change some of the numerical
parameters that affect the performance of these algorithms although this is not normally
recommended. The default settings for a number of algorithm parameters can be changed
by calls to the following entry points. A negative value for any of the numerical parameters
in the call means ’set the value to deafult’.

12.10.1 First-order phase split


To set the parameters for the first-order phase-split method call AXSE01:

INTEGER, INTENT(IN) :: ITMX0, ITMX1


REAL*8, INTENT(IN) :: EEPS0, EEPS1

SUBROUTINE AXSE01( ITMX0, EEPS0, ITMX1, EEPS1 )


C
C Input arguments:
C ITMX0 maximum number of iterations for 1st order phase split
C EEPS0 convergence tolerance on gradient norm for 1st order
C phase split
C ITMX1 maximum number of iterations for material balance
C EEPS1 convergence tolerance for material balance

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.

ITMX1 Default is 60, should not normally be changed.

EEPS1 Default is 10−20 , should not normally be changed.

12.10.2 Second-order phase split


To set the parameters for the second-order phase-split method call AXSE02:

115
INTEGER, INTENT(IN) :: ITMX0
REAL*8, INTENT(IN) :: EEPS0, XXTRA
LOGICAL, INTENT(IN) :: I2OR0

SUBROUTINE AXSE02( ITMX0, EEPS0, XXTRA, I2OR0 )


C
C Input arguments:
C ITMX0 maximum number of iterations for 2nd order phase split
C EEPS0 convergence tolerance on gradient norm for 2nd order
C phase split
C XXTRA limit for mole fraction of trace components
C I2OR0 second order minimization flag. If I2OR0=.TRUE.
C 2nd order methods may be used to solve the flash.
C Otherwise only methods that do not require composition
C derivatives of the fugacity coefficients are used.

Notes:

ITMX0 Default is 50, should not normally be changed.

EEPS0 Default is 10−16 . This should not normally be changed.

XXTRA Default is 10−6 , should not normally be changed.

I2ORD Default is .TRUE..

12.10.3 Stability test


To set the parameters for the stability test call AXSE03:

INTEGER, INTENT(IN) :: ITMX0, ITP


REAL*8, INTENT(IN) :: EEPS0

SUBROUTINE AXSE03( ITMX0, EEPS0, ITP )


C
C Input arguments:
C ITMX0 maximum number of iterations for stability test
C EEPS0 convergence tolerance on gradient norm for stability
C test
C ITP flag which controls the type and number of trial
C phases (TP) generated.
C = 0 generate maximum number of TP based on pure
C components (PC), approximate K-values (KV),
C ideal mixtures (IM) and several combinations
C of existing phases
C = 1 generate TP based on PC, KV, IM and arithmetic
C mean of existing phases
C = 2 generate TP based on PC, KV and IM
C = 3 generate TP based on PC and KV
C = 4 generate TP based on PC only
C = 5 generate TP based on KV only
C = 6 generate TP based on PC for phases with key
C components and KV only

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.

12.10.4 Temperature/pressure searches


To set the parameters for the temperature/pressure search routines call AXSE04:

REAL*8, INTENT(IN) :: TMAX, TMIN, PMAX, PMIN, EPST, EPSP,


+ EPSPH, EPSH, EPSS, EPSU, EPSV

SUBROUTINE AXSE04( TMAX, TMIN, PMAX, PMIN, EPST, EPSP, EPSPH,


+ EPSH, EPSS, EPSU, EPSV )
C
C Input arguments:
C TMAX upper temperature limit at which search should stop (K)
C TMIN lower temperature limit at which search should stop (K)
C PMAX upper pressure limit at which search should stop (Pa)
C PMIN lower pressure limit at which search should stop (Pa)
C EPST convergence tolerance for temperature (K)
C EPSP convergence tolerance for pressure (Pa)
C EPSPH convergence tolerance for phase fraction
C EPSH convergence tolerance for enthalpy (J)
C EPSS convergence tolerance for entropy (JK-1)
C EPSU convergence tolerance for internal energy (J)
C EPSV convergence tolerance for volume (m3)

Notes:

TMAX Default is 2000K.

TMIN Default is 1K.

PMAX Default is 109 Pa.

PMIN Default is 10−4 Pa.

EPST Default is 10−4 K, may often be increased safely to 10−3 K.

EPSP Default is 1Pa, may often be increased safely to 10Pa.

EPSPH Default is 10−5 , may often be increased safely to 10−4 .

EPSH Default is 10−3 J, may often be increased safely to 0.1 J.

EPSS Default is 10−5 J K−1 , may often be increased safely to 10−3 J K−1 .

EPSU Default is 10−3 J, may often be increased safely to 0.1 J.

EPSV Default is 10−4 , may often be increased safely to 10−3 .

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.

13.1 Flashes at fixed pressure and temperature: AXSN01


AXSN01 differentiates flashes performed by AXFL01 at specified pressure and temperature.
The calling specification is:
INTEGER LNOST, NCDIM, NP, LNOPD(*), NERR, MXERR, IERR(*)
REAL*8 T, P, X(NCDIM,*), XT(NCDIM,*), XP(NCDIM,*),
+ XN(NCDIM,NCDIM,*), PHF(*), PHFT(*), PHFP(*), PHFN(NCDIM,*),
+ NMOLIN(*), V(0:*), VT(0:*), VP(0:*), VN(NCDIM,0:*), H(0:*),
+ HT(0:*), HP(0:*), HN(NCDIM,0:*), S(0:*), ST(0:*), SP(0:*),
+ SN(NCDIM,0:*)
LOGICAL D(3), RETV, RETH

SUBROUTINE AXSN01( LNOST, D, T, P, NCDIM, NMOLIN, NP, LNOPD, X,


+ PHF, XT, XP, XN, PHFT, PHFP, PHFN, RETV, V, VT,
+ VP, VN, RETH, H, HT, HP, HN, S, ST, SP, SN,
+ NERR, MXERR, IERR )
C
C Input arguments:
C LNOST stream type load number for flash
C D Derivative flags:
C D(1) .TRUE. return T derivatives, otherwise not
C D(2) .TRUE. return P derivatives, 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, XH, XP, 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 XT Partial derivative of mole fraction X(I,J) w.r.t. T
C XP Partial derivative of mole fraction X(I,J) w.r.t. P
C XN Partial derivative of mole fraction X(I,J) w.r.t.
C feed composition
C PHFT Partial derivative of phase amount PHF(J) w.r.t. T
C PHFP Partial derivative of phase amount PHF(J) w.r.t. P

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

13.2 Flashes with a temperature or pressure search: AXSN02


AXSN02 differentiates flashes performed by AXFL02 where one variable is adjusted to satisfy a
constraint. (Tolerance calculations are excluded.) The variables may be either the tempera-
ture or the pressure. The possible constraints are:
1. Total enthalpy H

2. Total entropy S

3. Total volume V

4. Total internal energy U

5. Phase fraction (molar, mass or volume basis)


The phase fraction can be fixed for any phase for which a phase descriptor has been
defined in the stream type passed to AXSN02 and includes dew and bubble point calculations
as special cases. The calling specification for AXSN02 is:

INTEGER LNOST, IVAR, IPROB(2), NCDIM, NP, LNOPD(*), NERR, MXERR,


+ IERR(*)
REAL*8 T, T1, T2, TN(MAXNCS), P, P1, P2, PN(MAXNCS), X(NCDIM,*),
+ X1(NCDIM,*), X2(NCDIM,*), XN(NCDIM,NCDIM,*), PHF(*),
+ PHF1(*), PHF2(*), PHFN(NCDIM,*), NMOLIN(*), V(0:*),
+ V1(0:*), V2(0:*), VN(NCDIM,0:*), H(0:*), H1(0:*), H2(0:*),
+ HN(NCDIM,0:*), S(0:*), S1(0:*), S2(0:*), SN(NCDIM,0:*)
LOGICAL D(3), RETV, RETH

SUBROUTINE AXSN02( LNOST, IVAR, IPROB, D, T, T1, T2, TN, P, P1,


+ P2, PN, NCDIM, NMOLIN, NP, LNOPD, X, X1, X2,
+ XN, PHF, PHF1, PHF2, PHFN, RETV, V, V1, V2, VN,
+ RETH, H, H1, H2, HN, S, S1, S2, SN, NERR,
+ MXERR, IERR )
C
C Input arguments:
C LNOST stream type load number for flash

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

13.3 Double flashes: AXSN04


AXSN04 differentiates flashes performed by AXFL04 where two variables are adjusted to match
two constraints. The variables are temperature and pressure and two contraints are required
from the following:
1. Total enthalpy H

2. Total entropy S

3. Total volume V

4. Total internal energy U

5. Phase fraction (molar, mass or volume basis)


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 AXSN04. The calling specification for AXSN04 is:

INTEGER LNOST, IPROB1(2), IPROB2(2), NCDIM, NP, LNOPD(*), NERR,


+ MXERR, IERR(*)
REAL*8 T, T1, T2, TN(MAXNCS), P, P1, P2, PN(MAXNCS), X(NCDIM,*),
+ X1(NCDIM,*), X2(NCDIM,*), XN(NCDIM,NCDIM,*), PHF(*),
+ PHF1(*), PHF2(*), PHFN(NCDIM,*), NMOLIN(*), V(0:*),
+ V1(0:*), V2(0:*), VN(NCDIM,0:*), H(0:*), H1(0:*), H2(0:*),
+ HN(NCDIM,0:*), S(0:*), S1(0:*), S2(0:*), SN(NCDIM,0:*)
LOGICAL D(3), RETV, RETH

SUBROUTINE AXSN04( LNOST, IPROB1, IPROB2, D, T, T1, T2, TN, P, P1,


+ P2, PN, NCDIM, NMOLIN, NP, LNOPD, X, X1, X2,
+ XN, PHF, PHF1, PHF2, PHFN, RETV, V, V1, V2, VN,
+ RETH, H, H1, H2, HN, S, S1, S2, SN, NERR,
+ MXERR, IERR )
C
C Input arguments:
C LNOST stream type load number for flash
C IPROB1 identifer for type of calculation required (constraint 1)
C IPROB1(1) problem type

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.

14.2 Calling the phase envelope routines


AXPT01 defines the stream (components in mixture and phase descriptors) to be used for the
phase envelope tracing routines and performs the initial flash calculation for each new line
that is to be traced. Its calling specification is as follows:

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

SUBROUTINE AXPT01( LNOST, IVAR, UP, T, P, VV, HH, SS, NCDIM,


+ NMOLIN, NPHMAX, IPRBIN, TARGIN, FEST1, FEST2,
+ ISTABI, NPOUT, LNOPD, XX, NMOLPH, ZCOUT,
+ IPHOUT, ISTABO, NPRINT, NERR, MXERR, IERR )
C
C Input arguments:
C LNOST stream type load number for flash
C IVAR independent variable to be incremented first along
C phase boundary (codes are defined in axjnum.inc):
C JXTEMP = temperature
C JXPRES = pressure
C UP .TRUE. if independent variable is to be increased to start
C plot, .FALSE. if it is to be decreased.
C NCDIM Dimension of mole fraction array XX declared
C in calling routine. NCDIM must be greater than or equal
C to the the number of components for the stream type.
C NMOLIN mole numbers of components in mixture
C NPHMAX The maximum number of coexisting phases that the flash
C calculation is to search for. The maximum number of phases

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:

INTEGER, INTENT(IN) :: ISTABI, NCDIM, NI, NIDIM, NPRINT, MXERR


INTEGER, INTENT(OUT) :: ISTABO, NPOUT, LNOPD(*), IPHOUT(*), KI(*), NERR, IERR(*)
REAL*8, INTENT(OUT) :: T, P, VV, HH, SS, XX(NCDIM,*), NMOLPH(*), ZCOUT(*), TI(*),
+ PI(*), STEPI(*)

SUBROUTINE AXPT02( T, P, VV, HH, SS, ISTABI, NCDIM, NPOUT, LNOPD,


+ XX, NMOLPH, ZCOUT, IPHOUT, ISTABO, NI, NIDIM,

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

14.3 Phase envelope for flow assurance


Apart from the aboce functions, there is a convinience subroutine that can be called that
automatically calculate the phase boundaries for phases relevant to flow assurance appli-
cations: - Vapour-liquid phase envelope - Hydrate I (hydrate model needed) - Hydrate II
(hydrate model needed) - Water dew point line - Ice - Wax (Wax model needed) - Asphaltene
(Asphaltene model needed)
The subroutine that does this calculation automatically is AXPHES.

SUBROUTINE AXPHES( LNOST, NMOL, INP, TPGRID, MTEMP, MPRES,


+ MISTAT, NP, NERR, MXERR, IERR )
!
! Input arguments:
! LNOST Stream type load number
! NMOL Feed molar composition
! INP Number of points to be calculated (Max number of points for output of each line)
! TPGRID Vector of temperature and pressure minimum and maximum values for
! phase ennvelope calculations. If = 0, default values are used.
! (1) Tmin (minimum temperature)
! (2) Tmax (maximum temperature)
! (3) Pmin (minimum pressure)
! (4) Pmax (maximum pressure)
! MXERR Maximum number of status codes to return
!
! Output arguments:
! MTEMP Temperature points on phase boundaries (matrix of
! (INP,7) values). Current temperature units.
! Phase boundaries:
! (:,1) = VLE
! (:,2) = Hydrate I
! (:,3) = Hydrate II
! (:,4) = Water dew point
! (:,5) = Ice
! (:,6) = Wax
! (:,7) = Asphaltene
! MPRES Pressure points on phase boundaries (matrix of (INP,7)
! values). Current pressure units.
! Phase boundaries: Same as for MTEMP.
! MISTAT Status codes for points on phase boundaries (matrix of

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.

15.2 Phase equilibrium data


AXMT03 may be called to match a set of phase equilibrium data. Typical applications might
be to match one or more dew points for a condensate or bubble point points for an oil. In
addition this routine can be used to match solid deposition points such as the wax appearance
temperature (WAT) provided a suitable model is available. The properties adjusted depend
on the model and the number of data points. The number of (pure component) parameters
fitted and the identifiers for the fitted parameters are returned by the routine in the arguments
NFITP and IFITP. To find the values of the matched parameters use the routine AYPCNR as
described in section 5.3.2.
The routine will operate with the following fluid phase models: RKS/RKSA (and vari-
ants), PR/PRA (and variants), CPA. For matching wax phase fractions the routine will
operate with the Coutinho and GFP models.
The calling specification is as follows:

INTEGER, INTENT(IN) :: LNOST, IPROB(*), NPTS, MXERR


INTEGER, INTENT(OUT) :: NFITP, IFITP(*), NERR, IERR(*)
REAL*8, INTENT(IN) :: NMOLIN(*), SR, TARGET(*), T(*), P(*), WT(*)

SUBROUTINE AXMT03( LNOST, NMOLIN, IPROB, SR, NPTS, TARGET, T, P,


+ WT, NFITP, IFITP, NERR, MXERR, IERR )
C
C Input arguments:
C LNOST stream type load number for flash calculations
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

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.

15.3 Gas/Liquid viscosity


AXMT04 matches a set of gas or liquid viscosity points for a mixture by adjusting the reference
viscosities (property code JLVSRF) for all the petroleum fractions in the mixture. The routine
works with the generalised Lohrenz-Bray-Clark, Pedersen, Twu and SuperTRAPP models
provided in the Multiflash models library. To use the matching procedure with these models
the JVLFIT variant must be specified when the model is loaded, see section 8.4 and Appendix
I.
The calling specification is as follows:

INTEGER, INTENT(IN) :: LNOST, IPDIN, NPTS, MXERR


INTEGER, INTENT(INOUT) :: IFLASH(*)
INTEGER, INTENT(OUT) :: NFITP, IFITP(*), NERR, IERR(*)
REAL*8, INTENT(IN) :: NMOLIN(*), VISC(*), T(*), P(*), WT(*)

SUBROUTINE AXMT04( LNOST, NMOLIN, IPDIN, NPTS, VISC, T, P, WT,


+ IFLASH, NFITP, IFITP, NERR, MXERR, IERR )
C
C Input arguments:
C LNOST stream type load number: used to find the number of
C components and subcomponent list
C NMOLIN number of moles of each component in the mixture
C IPDIN phase descriptor (PD) for the phase to be used to match
C viscosity
C NPTS number of data points to be matched (in T, P, and VISC
C arrays)
C VISC array of viscosity (Pas) points to be matched
C T arrays of temperature (K) and pressure (Pa) points
C P corresponding to viscosities in VISC
C WT array of weighting factors for viscosity data points
C MXERR maximum number of error flags to be returned in IERR
C
C Input/output arguments:
C Input values:
C IFLASH indicates whether the overall composition should be
C flashed at the given P,T conditions to obtain the
C phase compositions.
C 0 do not flash (P > bubble point pressure)
C 1 do flash (P < bubble point pressure)
C Note that if a flash is requested it will be performed at
C each iteration in the attempt to match viscosities and
C will take much more time than the ’no flash’ option.
C This option is also less reliable than the ’no flash’
C option because the specified phase may not be present
C or may be mis-identified.
C
C Output values:
C IFLASH if IFLASH(i) is set to 1 the mixture is flashed and the
C value is reset to 0 if only one phase (with PD IPDIN)
C is found. This assumes that matching the viscosity model
C has no effect on the phase behaviour of the mixture.
C
C Output arguments:

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

15.4 Volumetric data


AXMT06 matches a set of molar volume or specific volume data points for a mixture by ad-
justing the properties of the petroleum fractions in the mixture. The volume matched may
be the overall volume or the volume of a a single phase in a multiphase mixture.
The routine works with the RKSA and PRA models with the JVDEN or JVDEN1 variants
and with the CPA model with the JVSVP variant (see section 8.2 and Appendix E.5). The
number of (pure component) parameters fitted and the identifiers for the fitted parameters
are returned by the routine in the arguments NFITP and IFITP. To find the values of the
matched parameters use the routine AYPCNR as described in section 5.3.2.
The calling specification is as follows:

INTEGER, INTENT(IN) :: LNOST, IPDIN, NPTS, IUNIT, MXERR


INTEGER, INTENT(OUT) :: NFITP, IFITP(*), NERR, IERR(*)
REAL*8, INTENT(IN) :: NMOLIN(*), VOL(*), T(*), P(*), WT(*)

SUBROUTINE AXMT06( LNOST, NMOLIN, IPDIN, NPTS, VOL, T, P, WT,


+ IUNIT, NFITP, IFITP, NERR, MXERR, IERR )
C
C Input arguments:
C LNOST stream type load number: used to find the number of
C components and subcomponent list
C NMOLIN number of moles of each component in the mixture
C IPDIN phase descriptor load number corresponding to the phase
C for which volume is to be matched. If set to zero
C this means match the total mixture volume.
C NPTS number of data points to be matched (in T, P, and VOL
C arrays)
C VOL array of volume points to be matched. The units must be
C either m3/mol or m3/kg as set by bthe IUNIT argument.
C If the volume of a single phase is to be matched and if
C more than one phase is present the molecuar weight used
C to convert mass units is obtained by flashing the total
C fluid composition.
C T arrays of temperature (K) and pressure (Pa) points
C P corresponding to volumes in VOL
C WT array of weighting factors for viscosity data points
C IUNIT code for units of data in VOL array.

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

15.5 GOR and Bubble Point Matching


Similar to the Match Bubble Point utility in the GUI, there is an API call to match the GOR
alongside the Bubble points. It can be used to match GOR for single stage separators, even
if no Bubble point information is available. The new function AXMT07 A allows to match the
following properties independently:

• Bubble points

• Single separator GOR

• 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:

INTEGER, INTENT(IN) :: LNOST, IPROB(3), IPDV, IPDL, NPT, MXERR, IWAT


INTEGER, INTENT(OUT) :: NFITPH, IFITPH(*), NFITLD, IFITLD(*), NERR, IERR(*)
REAL*8, INTENT(IN) :: NMOLIN(*), SR, PHFRAC(*), T(*), P(*), WT(*), WVOL
+ GOR, TGOR, PGOR, LDGOR
REAL*8, INTENT(INOUT) :: NMOUT(*)

SUBROUTINE AXMT07_A( LNOST, NMOLIN, IPROB, SR, IPDV, IPDL,


+ NPT, T, P, PHFRAC, WT, IWAT, WVOL,
+ GOR, TGOR, PGOR, LDGOR,
+ NMOUT, NFITPH, IFITPH, NFITLD, IFITLD,
+ NERR, MXERR, IERR )

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:

• fixed pressure and temperature;

• dew point at fixed pressure or temperature;

• bubble point at fixed pressure or temperature;

• fixed pressure and enthalpy;

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.

16.2 Chemreact operation


Chemreact is designed to allow use of different thermodynamic models for different phases and
for different properties of a given phase. The solution methods used do not make any assump-
tions about thermodynamic consistency between fugacity coefficients, volumetric properties,
and thermal properties. It is the implementer’s responsibility to ensure that the same fu-
gacity reference state is used for all phases and that a sensible combination of models for
different phases is specified.
A typical sequence of operations for using Chemreact is:

1. Initialise physical properties data system.

2. Define list of all components that may be present and load the data for these compo-
nents.

3. Define or load sets of binary interaction parameters (BIPs).

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).

7. Initialise Chemreact: CALL CRINIT

8. Call one of the top level routines to do a calculation:

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.

16.3 Initialising Chemreact


Once the databank(s), components, models, phase descriptors and streams, have been defined,
Chemreact should be initialised by calling CRINIT. The calling specification is as follows:

INTEGER, INTENT(IN) :: MXERR


INTEGER, INTENT(OUT) :: NERR, IERR(*)

SUBROUTINE CRINIT( NERR, MXERR, IERR )

16.4 Chemical equilibrium at fixed pressure and temperature: CREA01


CREA01 can be called to perform chemical equilibrium calculations as follows:

INTEGER, INTENT(IN) :: LNOST, NCDIM, NPHMAX, KREAIN(*), NPRINT, MXERR, NR


INTEGER, INTENT(OUT) :: NP, LNOPD(*), IPHID(*), NERR, IERR(*)
REAL*8, INTENT(IN) :: T, P, NMOLIN(*), CRSTCO(MAXRXN, *)
REAL*8, INTENT(INOUT) :: ZEQUIL(*), XX(NCDIM,*), VAP(*)
REAL*8, INTENT(OUT) :: ZETOT, ZCOMP(*)
CHARACTER*72, INTENT(IN) :: CRNAME(MAXRXN, *)

SUBROUTINE CREA01( LNOST, NR, CRNAME, CRSTCO, CRCPNO, T, P, NCDIM,


+ NMOLIN, NPHMAX, KREAIN, ZETOT, ZEQUIL, NP,
+ LNOPD, ZCOMP , VAP, XX, IPHID, NPRINT, NERR,
+ MXERR, IERR )
C
C Input arguments:
C LNOST stream type load number for flash
C NR Number of reactions
C CRNAME Component names present in reactions
C CRSTCO Stoquiometric coefficients for each component in each reaction.
C T temperature (K)
C P pressure (Pa)
C NCDIM dimension of mole fraction array XX declared in calling
C routine. NCDIM must be greater than or equal to the
C the number of mixture components for the calculation.
C NMOLIN mole numbers in the feed.
C NPHMAX The maximum number of coexisting phases that the equilibrium
C calculation is to search for. Used to set value of NPHASE.
C If NPHMAX is outside the range 1 to MXPHCR it
C is equivalent to setting it to MXPHCR.
C KREAIN code numbers marking reacting fluid components
C (1=reacting, 0=non-reacting), condensed
C components (1=solid only, 2=solid or liquid)
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

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

16.5 Dew and bubble point searches at chemical equilibrium: CREA02


CREA02 searches for either the temperature or pressure at which a dew or bubble point
occurs for a system that is simultaneously at chemical equilibrium and at vapour-liquid
phase equilibrium:

INTEGER, INTENT(IN) :: LNOST, IVAR, NCDIM, NPHMAX, KREAIN(*), NTYPE,


+ MXERR, NR, CRCPNO(*)
INTEGER, INTENT(OUT) :: NP, LNOPD(*), IPHID(*), NPRINT, NERR, IERR(*)
REAL*8, INTENT(IN) :: NMOLIN(*), CRSTCO(MAXRXN, *)
REAL*8, INTENT(INOUT) :: TIO, PIO, VAP(*), XX(NCDIM,*)

140
REAL*8, INTENT(OUT) :: ZETOT, ZEQUIL(*), ZCOMP(*),
LOGICAL, INTENT(IN) :: FEST
CHARACTER*72, INTENT(IN) :: CRNAME(MAXRXN, *)

SUBROUTINE CREA02( LNOST, NR, CRNAME, CRSTCO, CRCPNO, IVAR, TIO,


+ PIO, NCDIM, NMOLIN, NPHMAX, KREAIN, NTYPE,
+ FEST,ZETOT, ZEQUIL, NP, LNOPD, ZCOMP, VAP, XX,
+ IPHID, NPRINT, NERR, MXERR, IERR )
C
C Input arguments:
C LNOST stream type load number for flash
C NR Number of reactions
C CRNAME Names of components present in reaction.
C CRSTCO Stoquimetric coefficients for components in reactions.
C CRCPNO Number of components in each reaction.
C IVAR code denoting variable
C = 1 search for temperature at given pressure
C = 2 search for pressure at given temperature
C NCDIM dimension of mole fraction array XX declared in calling
C routine. NCDIM must be greater than or equal to the
C the number of mixture components for the calculation.
C NMOLIN mole numbers in the feed (NCOMIX fluid components
C followed by NCOCND condensed phase components)
C NPHMAX The maximum number of coexisting phases that the equilibrium
C calculation is to search for. Used to set value of NPHASE.
C If NPHMAX is outside the range 1 to MXPHCR it
C is equivalent to setting it to MXPHCR.
C KREAIN code numbers marking reacting fluid components
C (1=reacting, 0=non-reacting), condensed
C components (1=solid only, 2=solid or liquid)
C FEST If .TRUE. an estimate of the equilibrium temperature
C must be supplied in TIO
C NTYPE calculation type (1=dew point, 2=bubble point)
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 flags to be returned in IERR
C
C Input/output arguments:
C Input value:
C TIO If IVAR=2, temperature (K) at which to solve for
C incipient phase.
C If IVAR=1 and FEST=TRUE, estimated temperature (K),
C else not defined
C PIO If IVAR=1, pressure (Pa) at which to solve for
C incipient phase.
C If IVAR=2 and FEST=TRUE, estimated pressure (Pa),
C else not defined
C VAP starting value for phase distribution
C XX starting values for fluid phase mole fractions
C
C Output value:
C TIO temperature (K)
C PIO pressure (Pa)

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.

17.2 Reading a command file


The subroutine MFRDFL NMOL will read a Multiflash command file and process the commands
in the file. To initialise Multiflash the file should contain information on the components,
models and phase descriptors. The intention is that MFRDFL NMOL will be called once to
perform the initialisation followed by multiple calls to property/phase equilibrium routines
as described in section 17.4. The previous version of this routine MFRDFL is also provided
for backwards comptibility. The calling specification is as follows:

INTEGER, INTENT(OUT) :: NC, IC(*), NPD, IPD(*), IPHID(*),


+ NST, IST(*), NERR, IERR(*)
INTEGER, INTENT(IN) :: MXERR
CHARACTER*(*), INTENT(IN) :: APPNAM, CMDFIL, ERRFIL
CHARACTER*(*), CNAME(*), PDNAME(*), STNAME(*)
REAL*8, INTENT(OUT) :: NMOL(*)

SUBROUTINE MFRDFL_NMOL( CMDFIL, APPNAM, ERRFIL, NC, IC, NMOL,


+ CNAME,NPD,IPD, PDNAME, IPHID, NST, IST, STNAME, NERR,MXERR,
+ IERR )

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

And the old subroutine:


INTEGER NC, IC(*), NPD, IPD(*), IPHID(*), NST, IST(*), NERR,
+ MXERR, IERR(*)
CHARACTER*(*) APPNAM, CMDFIL, ERRFIL, CNAME(*), PDNAME(*),
+ STNAME(*)

SUBROUTINE MFRDFL( CMDFIL, APPNAM, ERRFIL, NC, IC, CNAME, NPD,


+ IPD, PDNAME, IPHID, NST, IST, STNAME, NERR,
+ MXERR, IERR )
C
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.
C Three operating modes are possible:
C 1. If set to a blank character, all errors are returned
C 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

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.

2. The Multiflash command file must be a sequential formatted ASCII file.

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.

17.3 Reading a command file without loading it


For convenience a subroutine MFRMFL is provided to read a command file and return the
components defined in that file, but without loading it. That means the currently defined
model in Multiflash is unaffected. The calling specification is:

145
INTEGER, INTENT(OUT) :: NCOMP, TYPE(*), NERR, IERR(*)
INTEGER, INTENT(IN):: MXERR
CHARACTER*(*), INTENT(OUT) :: NAME(*), ALIAS(*)
CHARACTER*(*), INTENT(IN) :: FILNAM

SUBROUTINE MFRMFL( FILNAM, NCOMP, NAME, ALIAS, TYPE, NERR, MXERR,


+ IERR )
C
C COPYRIGHT (C) INFOCHEM COMPUTER SERVICES LTD., 2009.
C ALL RIGHTS RESERVED.
C
C Reads component information from mfl files.
C
C Version 1.0, Tony Moorwood, 17th. February 2009.
C
C Input arguments:
C FILNAM Name of file
C MXERR maximum number of error codes to return in IERR
C
C Output arguments:
C NCOMP Number of components
C NAME Array of component names
C ALIAS Array of component aliases
C TYPE Array of component types
C NERR number of error codes returned in IERR
C IERR error codes. Values for this routine:
C 384 Cannot get a unit number with which to open the file
C 385 Cannot open the file

17.4 Carrying out Calculations


Provided that all the necessary information has been supplied in the command file, the call to
MFRDFL NMOL will initialise Multiflash. The program may now make direct calls to any of the
pure component data routines (described in section 5), flash routines, chemical equilibrium
routines, or else to AYMIX, AYMIXH, AYVISC, AYTCND, AYSURF or AYDIFF to obtain mixture
physical properties. Note that it is not necessary to call any of the initialisation routines
such as AXINIT etc. since these will be called as part of reading the command file.
For example, if the file ex1a.mfl contains the following Multiflash commands

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

It would be straightforward to calculate properties for a different substance simply by


changing the command file. No program changes are necessary. Further examples are pro-
vided in sections N.1.2, N.2.2 and N.6.2 which contain complete working programs. These
can be compared with the equivalent low-level calls in sections N.1.1, N.2.1 and N.6.1 which
require more code to acomplish the same result.

17.5 Writing a command file


The current state of the Multiflash models as stored in the command processor can be writ-
ten out at any time by calling MFWRPF. The user enters the name of the file on which the
commands are to be written and Multiflash writes out a description of the model. The calling
specification is:
INTEGER NERR, MXERR, IERR(*)
CHARACTER*(*) FILNAM

CALL MFWRPF( FILNAM, NERR, MXERR, IERR )


C
C Input arguments:
C FILNAM Name of file
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 error codes. Values for this routine:
C 384 Cannot get a unit number with which to open the file
C 385 Cannot open the file

17.6 Ending the Multiflash session


When MFRDFL NMOL is used to initialise Multiflash a number of files will be opened and the
security system (see section 3.2) will be initialised. To close all files and release any licences
a call should be made to MFEND. This INTEGER function has no arguments. For example:

147
INTEGER STATUS

STATUS = MFEND()

MFEND should only be called if no further calls will be made to the Multiflash dll.

17.7 Converting a PVTSim CHC file into an MFL file


Starting with version 4.2 of Multiflash it is possible to read PVTSim CHC files. It is not
possible to get an exact model replication for the transport properties models (viscosity,
thermal conductivity, and surface tension) since the two software packages have different
models or different implementations of common models. However, in the case of the Lohrenz-
Bray-Clark (LBC) model for viscosity, the converter can retrieve all the necessary parameters
from the CHC file, if this model is selected for the calculation of the viscosity.
Starting with version 4.3 the converter allows you to define the number of phases that
you wish to use (e.g., Vapour, Liquid 1, Liquid 2, and/or Water). In addtion from version
4.3.11, the user has the option of calculating the density of the vapor phase using the GERG
2008 model if so desired, while estimating the rest of the thermodynamic properties with the
model defined in the original CHC file.
The converter can retrieve from the CHC file the following information:

• Pure component parameters. (This includes checking differences in library compo-


nents);

• van der Waals mixing rule binary parameters. Constant and temperature dependent;

• Huron-Vidal-Pedersen (HVP) mixing rule binary parameters. Constant and tempera-


ture dependent;

• Which equation of state was used (RKS or PR);

• Which Peneloux volume correction function was used: none, constant, linear with tem-
perature;

• Amounts of the defined components.

• Parameters for the LBC viscosity model.

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).

• Allows defining phases (e.g., vapour, liquid 1, water, etc.).

• Gives the choice of calculating vapour phase density using GERG 2008 model (from
version 4.3.11).

The resulting MFL can then be read using MFRDFL NMOL.


The interface to the import tool is:
CHARACTER(*), INTENT(IN) :: PVTSFile
CHARACTER(*), INTENT(IN) :: MFLFile
INTEGER, INTENT(IN) :: Mxerr
INTEGER, INTENT(IN) :: opts(*)
INTEGER, INTENT(OUT) :: Nerr

148
INTEGER, DIMENSION(*), INTENT(OUT) :: Ierr

SUBROUTINE MF_PVTSF_Convert( PVTSFile, MFLFile, Opts, Nerr, Mxerr, Ierr )


!
! Input arguments:
! PVTSFile full pathname of PVTsim .chc file
! MFLSFile full pathname of Multiflash .mfl file to be written
! opts User input options: (For transport properties models, 0, means no model.)
! (1) Viscosity model
! (2) Thermal conductivity model
! (3) ST model
! (4) Add water? (0 for no, any other number for yes)
! (5) Define Vapour phase ( 0 = No, 1 = Yes, with model from CHC, 2 =
! Vapour phase with GERG )
! (6) Define Liquid 1 phase ( 0 = No, 1 = Yes, with model from CHC )
! (7) Define Liquid 2 phase ( 0 = No, 1 = Yes, with model from CHC )
! (8) Define Water phase ( 0 = No, 1 = Yes, with model from CHC )
! Model codes come from AYJMID.INC
! Mxerr maximum number of error codes to return in Ierr
!
! Output arguments:
! Nerr no. errors reported by this routine and lower level routines
! Ierr Error codes. Values for this routine:
! 1129 Unable to open PVTSim CHC file
! 1130 Unable to open MFL file to write.
! 1131 Error reading the CHC file contents.
! 1132 The CHC file is empty
! 1133 The CHC file does not define any components or models.
! 1134 Error reading component information from CHC file.
! 1135 Error writing components into MFL file.
! 1136 Unable to allocate components or BIP arrays.
! 1137 Error reading BIP information from CHC files.
! 1138 Error writting BIP information to MFL file.
! 1139 Error writting models information to MFL file.
! 1140 Error writting amounts information to MFL file.
! 1141 Error writting amounts information to MFL file.

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

18.1 UNF: Amount/composition/flowrate


This routine converts amounts, compositions or flowrates. To convert between mole frac-
tions and mass fractions specify mole and kg units as input and output units. The calling
specification is:

INTEGER I, O, NC, IERROR


REAL*8 MW(*), F(*), FTOT, AVMW

SUBROUTINE UNF( I, O, NC, MW, F, FTOT, AVMW, IERROR )


C
C Input arguments:
C IU code for input units:
C 1 mol
C 2 kmol
C 3 kg
C 4 lb
C 5 lbmol
C 6 g
C OU code for output units - as for input units
C NC number of component amounts in vector F
C MW array of relative molar masses for each component
C (average molecular weight in g/mol). Must be set
C correctly if conversion between molar and mass units
C is required but can be set to arbitrary positive
C non-zero values (say 1) if conversion is between two
C sets of mass or molar units. If MW(I) is set to -DLARGE
C (aycnum.inc) this is taken to mean missing data and the
C value in F(I) is not changed.
C
C Input/output arguments:
C Input values:
C F component amounts (array of NC values) in units
C corresponding to IU
C FTOT total amount

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

18.2 UND: Density/volume


This routine converts density, specific volume or molar volume quantities. For total volume
use UNVOL. The calling specification is:
INTEGER I, O, IERROR
REAL*8 AVMW, D

SUBROUTINE UND( I, O, AVMW, D, IERROR )


C
C Input arguments:
C I Input density/volume units
C 1 mol m-3
C 2 kg m-3
C 3 lb ft-3
C 4 lbmol ft-3
C 5 mol cm-3
C 6 g cm-3
C 7 kmol m-3
C 8 m3 mol-1
C 9 m3 kg-1
C 10 ft3 lb-1
C 11 ft3 lbmol-1
C 12 cm3 mol-1
C 13 cm3 g-1
C 14 m3 kmol-1
C O Output density/volume units - codes as above
C AVMW relative molar mass for mixture (average molecular
C weight in g/mol). Must be set correctly if conversion
C between molar and mass units is required but can be set
C to -DLARGE if conversion is between two sets of mass or
C molar units.
C
C Input/output arguments:
C D Density/volume
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

151
18.3 UNI: Diffusion coefficient
This routine converts diffusion coefficient units. The calling specification is:
INTEGER I, O, IERROR
REAL*8 DI

SUBROUTINE UNI( I, O, DC, IERROR )


C
C Input arguments:
C I Input diffusion coefficient units
C 1 m2/s
C 2 cm2/s
C O Output units - codes as above
C (if O and I are the same no conversion is attempted)
C
C Input/output arguments:
C DC diffusion coefficient
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

18.4 UNH: Energy (molar/specific)


This routine converts molar or specific energy units - this includes enthalpy, internal energy
and Gibbs energy. The calling specification is:

INTEGER I, O, IERROR
REAL*8 AVMW, H

SUBROUTINE UNH( I, O, AVMW, H, IERROR )


C
C Input arguments:
C I Input specific/molar energy units
C 1 J mol-1 (kJ kmol-1)
C 2 kJ mol-1 (MJ kmol-1)
C 3 MJ mol-1 (GJ kmol-1)
C 4 cal mol-1
C 5 kcal lbmol-1
C 6 BTU lbmol-1
C 7 kJ kg-1 (J g-1)
C 8 BTU lb-1
C 9 kcal lb-1
C 10 kcal mol-1
C 11 cal g-1 (kcal kg-1)
C 12 J/kmol (mJ/mol)
C 13 J/kg
C O Output specific energy units - codes as above
C AVMW relative molar mass for mixture (average molecular
C weight in g/mol). Must be set correctly if conversion
C between molar and mass units is required but can be set
C to -DLARGE if conversion is between two sets of mass or
C molar units.
C
C Input/output arguments:

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

18.5 UNS: Entropy/heat capacity (molar/specific)


This routine converts molar or specific units of energy/temperature interval - this includes
entropy and heat capacity. The calling specification is:

INTEGER I, O, IERROR
REAL*8 AVMW, S

SUBROUTINE UNS( I, O, AVMW, S, IERROR )


C
C Input arguments:
C I Input specific entropy/heat capacity unit code
C O Output specific entropy/heat capacity unit code
C 1 J/mol/K
C 2 cal/mol/K
C 3 BTU/lbmol/F
C 4 kcal/lbmol/F
C 5 J/kg/K
C 6 kJ/kg/K
C 7 BTU/lb/F
C 8 kcal/lb/F
C 9 GJ/kmol/K
C 10 MJ/mol/K
C 11 kJ/kmol/K
C 12 J/kmol/K
C AVMW relative molar mass for mixture (average molecular
C weight in g/mol). Must be set correctly if conversion
C between molar and mass units is required but can be set
C to -DLARGE if conversion is between two sets of mass or
C molar units.
C
C Input/output arguments:
C S Specific entropy/heat capacity
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

18.6 UNP: Pressure


This routine converts pressure units. The calling specification is:

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

18.7 UNR: Surface tension


This routine converts surface tension units. The calling specification is:
INTEGER I, O, IERROR
REAL*8 ST

SUBROUTINE UNR( I, O, ST, IERROR )


C
C Input arguments:
C I Input surface tension units
C 1 N/m
C 2 mN/m
C 3 dyne/cm
C O Output units - codes as above
C (if O and I are the same no conversion is attempted)
C
C Input/output arguments:
C ST surface tension
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

18.8 UNT: Temperature


This routine converts temperature units. The calling specification is:

154
INTEGER I, O, IERROR
REAL*8 T

SUBROUTINE UNT( I, O, T, IERROR )


C
C Input arguments:
C I Input temperature units
C 1 kelvin
C 2 degrees Celcius
C 3 degrees Fahrenheit
C 4 degrees Rankine
C O Output temperature units - codes as above
C
C Input/output arguments:
C T Temperature
C
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

18.9 UNU: Thermal conductivity


This routine converts thermal conductivity units. The calling specification is:

INTEGER I, O, IERROR
REAL*8 U

SUBROUTINE UNU( I, O, U, IERROR )


C
C I Input thermal conductivity units
C 1 W m-1 K-1
C 2 kW m-1 K-1
C 3 kJ hr-1 m-1 K-1
C 4 BTU hr-1 ft-1 F-1
C 5 kcal hr-1 ft-1 F-1
C 6 cal cm-1 s-1 K-1
C 7 kcal cm-1 hr-1 K-1
C 8 mW cm-1 K-1
C 9 W cm-1 K-1
C 10 mW m-1 K-1
C O Output units - codes as above
C
C Input/output arguments:
C U Thermal conductivity
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

18.10 UNV: Viscosity


This routine converts viscosity units. The calling specification is:

INTEGER I, O, IERROR

155
REAL*8 V

SUBROUTINE UNV( I, O, V, IERROR )


C
C Input arguments:
C I Input viscosity units
C 1 Pa s
C 2 cP (centipoise = mPas)
C 3 mPas
C 4 microPas
C 5 dynes/cm2 (dyne.s/cm2)
C 6 microP (micropoise)
C O Output units - codes as above
C
C Input/output arguments:
C V Viscosity
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

18.11 UNVOL: Volume


This routine converts units of total volume. For specific or molar volume or density use UND.
The calling specification is:
INTEGER I, O, IERROR
REAL*8 VOL

SUBROUTINE UNVOL( I, O, VOL, IERROR )


C
C Input arguments:
C I Input volume units
C 1 m3
C 2 dm3 (l)
C 3 cm3
C 4 mm3
C 5 yd3
C 6 ft3
C 7 in3
C 8 pint (UK)
C 9 gal (UK)
C 10 pint (US)
C 11 gal (US)
C 12 barrel (US)
C O Output volume units - codes as above
C
C Input/output arguments:
C VOL volume
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

156
Appendices

A Summary of Multiflash routines


The following is an alphabetical listing of Multiflash routines described in this document.

routine purpose see page


AXDFST define a stream type 94
AXFL01 flash at fixed pressure and temperature 98
AXFL02 flash at fixed pressure or temperature (plus 1 other 102
constraint)
AXFL04 flash at 2 fixed properties (not pressure or temperature) 109
AXGTST get information about a stream type 94
AXHYD gets the most stable hydrate phase and temperature or pressure 106
AXINIT initialise Multiflash phase equilibrium module and stream system 98
AXMT03 adjusts petroleum fraction properties to match dew or bubble points 131
AXMT04 adjusts petroleum fraction properties to match viscosity 133
AXMT06 adjusts petroleum fraction properties to match volume 134
AXMT07 A adjusts petroleum fraction properties and/or feed to match bubble 134
points and GOR
AXNST number of stream types and their identifiers 94
AXPT01 first flash calculation on phase envelope 124
AXPT02 subsequent flash calculations on phase envelope 127
AXRMST remove a stream type 95
AXSE01 set parameters for first-order phase split algorithm 115
AXSE02 set parameters for second-order phase split algorithm 115
AXSE03 set parameters for stability test 116
AXSE04 set parameters for T and P searches 117
AXSN01 flash sensitivities at fixed pressure and temperature 118
AXSN02 flash sensitivities at fixed pressure or temperature (plus 1 other 119
constraint)
AXSN04 flash sensitivities at 2 fixed properties (not pressure or temperature) 121
AXST01 stability test 113
AYAVMW average molecular weight for a mixture 88
AYBDBL loads BIPs from a databank 62
AYBDEL deletes all BIP values for a component 70
AYBINI initialises BIP data module 60
AYBLND blend two petroleum fluids 58
AYBNUL frees BIP load numbers 70
AYBIP USR enters BIP values 63
AYBIP VAL gets BIP values 68
AYBVLS gets BIP values status 69
AYDATM sepcification of datum 92
AYDFPD define a phase descriptor 83
AYDIFF evaluate diffusion coefficients for mixtures 91
AYFLFL processes databank configuration file 18
AYGTLO get information about a model load number 80
AYGTPD get information about a phase descriptor load number 84
AYLOAD loads a model for a mixture property 72
AYMINI initialises mixture models module and PD system 72
AYMIX evaluate thermodynamic properties of mixtures 86

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.

B.1.1 Data bank structure


The Infodata data bank is supplied in its standard form as two files INFODATA.BIN and
INFODATA.IDX which contain the physical property data and names index respectively. The
.BIN file is a direct access unformatted file with the data for each compound. The .IDX file
is a sequential formatted file that contains a list of all compound names with pointers to
the data record in the .BIN file. The DIPPR data bank is also available in the same format
and is supplied as the files DIPPR.BIN and DIPPR.IDX. To create data files in the Infodata
structure, an ASCII file needs to be created which contains the databank header and a set
of keywords for the properties for each component.

Table 1: Header structure


Keywords Descriptions Fortran input format
DATABANK Name of databank Up to 12 characters
REVISIONDATE The date that the databank was changed Format: dd.mm.yy
VERSION Version number of the databank Numeric value

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.

3. The chemical formula is a string of up to 20 characters giving the empirical chemical


formula. Each element is indicated by its chemical symbol followed by its (integer)
abundance in the molecule. The letters in the chemical symbols must be in the correct
case: first or only letter upper case, second letter lower case. An abundance of 1 can
be omitted. e.g. CO or C1O1 represents carbon monoxide, Co cobalt. Brackets must
not be used.

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.1.2 Creating the data bank


Once the sequential data file has been written, it is converted to a direct access data file and a
names index by the program MKIDBK3. The program works interactively with the user naming
the file he wants to read and the files to be created. An appropriate version of MKIDBK3 is
required for each target operating system and compiler.
The direct access file and names index for the Infodata bank are normally given the names
infodata.bin and infodata.idx respectively. The usual names for the DIPPR databank
files are dippr.bin and dippr.idx. The Infochem models software can recognise these files
if they are present in the databank directory specified in the call to AYFLFL as described in
section 4.3.

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.

B.2.1 Data bank structure


The data bank is supplied in its standard form as two files INFOCOND.BIN and INFOCOND.IDX
which contain the physical property data and names index respectively. The file organisation
and formats are the same as for Infodata. To create data files in the Infocond structure, an
ASCII file needs to be created first which contains sequential data for a number of compounds.
The ASCII data file must include the following elements:

• File header.

• Component name information.

• Constant properties. MOLECULARWEIGHT, HFORMATION, SSTANDARD, TBOIL, TMELT.

165
• T-dependent properties. CPSOLID.

Other properties may be present but are not used by Multiflash.

B.3 Binary interaction parameter databanks


BIP databanks in the INFOBIPS binary format can be created with the MKBIPBANK utility
program. This program processes an ASCII input file that contains the BIP information and
produces a binary format file that can be opened by AYPDBO.

B.3.1 Input specification


The input file is an ASCII text file.
Each line may be up to 256 characters long.
Any text on a line following a comment character is ignored.
Comment characters are # or !.
Blank lines are allowed.
A data line must contain a complete entry - it cannot be split over more than one line.

B.3.2 BIP data line


The format for a BIP data line is:
NAME1 NAME2 model id model variant T function BIPcoeffs

NAME1 name of first component (string, up to 72 characters)


NAME2 name of second component (string, up to 72 characters)
model id identifier for model (string) - see below
model variant identifier for model variant (string) - see below
T function Code for temperature function used to evaluate the BIP values from
the stored coefficients (integer) - see below
BIPcoeffs coefficients in T-dependent correlation, 3 values per BIP (real).
The number of BIPs is model-dependent - see below.

B.3.3 Component Names


Names must be unique and may not contain embedded blanks. Names are translated to
CARNs before the BIPs are stored. It must be possible to determine the CARN for each
name. The NAME is looked for in the Infodata and/or DIPPR databanks and a CARN is
returned. The location of the databanks is given to the program by the user when running
the program. Note that names on Infochem supplied databanks are stored without embedded
blanks so a name like ’CARBONDIOXIDE’ is equivalent to ’CARBON DIOXIDE’.

B.3.4 Model/variant identifiers


The following character strings corresponding to each model identifier in ayjmid.inc must
be used:

ayjmid.inc character number


model id string variants of BIPs units
JMPR PR * 1 -
JMRKS RKS * 1 -
JMLKP LKP LKP (default) 1 -
JMLKP LKP LK 1 -

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.

B.3.5 BIP T-dependent correlation functions


Currently the only function available has the id. code of 1 corresponding to the function
BIPi = ai1 + T ai2 + T 2 ai3 (3)
where T is the temperature in K. The coefficients ai1 , ai2 , ai3 are the values entered in the
file for the ith BIP.

B.3.6 Entering BIP correlation coefficients


Up to 9 values may be entered corresponding to the correlation coefficients for 3 BIPs. If 9
values are provided they are stored as entered and are interpreted as: a11 , a12 , a13 a21 , a22 ,
a23 , a31 , a32 , a33 . If fewer than 9 values are entered the program attempts to assign them as
follows.
Models with 1 BIP.
1 - 3 values: a11 , a12 , a13 coefficients
Models with 2 BIPs.
2 values: a11 , a21 (ie. assumed constant BIPs)
4 values: a11 , a12 , a21 , a22 (ie. assumed linearly T-dependent)
6 values: a11 , a12 , a13 , a21 , a22 , a23 (ie. quadratic T-dependence)
Models with 3 BIPs.
3 values: a11 , a21 , a31 (ie. assumed constant BIPs)
6 values: a11 , a12 , a21 , a22 , a31 , a32 (ie. assumed linearly T-dependent)

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

C.1 Numerical values


For use in calls to AYPCNR and AYPSTR:
JACNTR acentric factor
JCPLIQ liquid enthalpy flag for activity models
JCPMLT solid/liquid difference in Cp at melting point (J/mol K)
JCNUMB carbon number (for petroleum fractions)
JDIPMT dipole moment (debye)
JPOLARZ Polarizability
JQUAD Quadrupole moment
JGFORM Gibbs energy change on formation in perfect gas state at 298.15K and 1 atm (J/mol)
JHCOMB standard enthalpy change on combustion (net) (J/mol)
JHFORM standard enthalpy change on formation in perfect gas state at 298.15K (J/mol)
JHMELT enthalpy change on fusion at melting point (J/mol)
JHOCAS Hayden-O’Connell self-association parameter
JLBCVC critical volume for LBC model (m3 )
JLEX60 thermal expansivity of liquid at 1 atm and 60 F (K−1 )
JLFLAM lower flammability limit (vol. % in air)
JLMV25 liquid molar volume at 25 C (m3 /mol)
JLSG60 specific gravity of liquid (relative to water) at 60 F, 1 atm
JLBCVC Critical volume paramter used in LBC model m3 /mol
JLVSRF liquid viscosity at reference temperature and 1 atm (Pa s)
JLVSRT liquid viscosity reference temperature (K)
JLVSST The reference viscosity for STRAPP model
JLVSPD The reference viscosity for Pedersen model
JLVSTW The reference viscosity for TWU model
JLVSLB The reference viscosity for LBC model
JMCPR1 Mathias-Copeman vapour pressure parameters for PR EOS
JMCPR2
JMCPR3
JMCRK1 Mathias-Copeman vapour pressure parameters for RKS EOS
JMCRK2
JMCRK3
JMOLWT molecular weight (g/mol)
JOMARKS Ωa scaling factor for specific for RKS EOS
JOMBRKS Ωb scaling factor for specific for RKS EOS
JOMAPR Ωa scaling factor for specific for PR EOS
JOMBPR Ωb scaling factor for specific for PR EOS
JPARAC Parachor ( (dyne cm−1 )1/4 cm3 /mol )
JPCRIT critical pressure (Pa)
JPHTYP component type identifier (from ayjxid.inc)
JPTRPL triple point pressure (Pa)
JREFNO reference number for component (databank specific)
JRFINX refractive index at 25 C
JRGYRT radius of gyration (m)
JSFORM Entropy change on formation in perfect gas state at 298.15K and 105 Pa (J/mol K)
JSMELT entropy change on fusion at melting point (J/Kmol)

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.

C.2 Character values


For use in calls to AYPCNK and AYPSTK:

JKCARN Chemical Abstracts Registry Number in the form xxxxxx-yy-z


JKFORM chemical formula
JKNAME compound name
JKFCOD DIPPR chemical family code

C.3 Temperature-dependent property correlations


For use in calls to AYPSTR and AYPCOR:

JDIEL relative permittivity/dielectric constant


JVCHS perfect gas heat capacity
JDENS saturated liquid density
JLATH saturated liquid enthalpy change on evaporation (latent heat)
JLCHS saturated liquid heat capacity
JSURT saturated liquid surface tension
JLTHC saturated liquid thermal conductivity
JPSAT saturated liquid vapour pressure
JLVIS saturated liquid viscosity
JSVR second virial coefficient
JSDN solid density
JSCP solid heat capacity
JVTHC zero-density gas thermal conductivity

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.

Chemical Abstracts Registry number (CAR number)


Name of compound
Chemical formula
DIPPR chemical family code
Component type identifier (from ayjxid.inc)
Compound data bank reference number
Molecular weight
Critical temperature (K)
Critical pressure (Pa)
Critical molar volume (m3 mol−1 )
Critical compressibility factor
Acentric factor
Normal boiling point (K)
Triple point temperature (K)
Triple point pressure (Pa)
Enthalpy change on formation in the perfect gas state at 298.15K (Jmol−1 )
Entropy change on formation in the perfect gas state at 298.15K and 105 Pa
(Jmol−1 K−1 )
Gibbs energy change on formation in the perfect gas state at 298.15K and 105 Pa
(Jmol−1 )
Standard entropy in the perfect gas state at 298.15K and 105 Pa (Jmol−1 K−1 )
Normal melting point temperature (K)
Enthalpy change on fusion at the normal melting point (Jmol−1 )
Entropy change on fusion at the normal melting point (Jmol−1 Kl−1 )
Difference in Cp on fusion at the normal melting point (in Jmol−1 )
Difference in molar volume on fusion at the normal melting point (m3 mol−1 )
Uniquac r parameter
Uniquac q parameter
Characteristic temperature for Henry’s Law correlation for solubility of a compo-
nent in water (K)
Characteristic volume for Henry’s Law correlation for solubility of a component
in water (m3 mol−1 )
Dipole moment (Debye units)
Parachor ( (dyne cm−1 )1/4 cm3 /mol )
Radius of gyration (m)
Hayden-O’Connell self-association parameter
Standard net enthalpy change on combustion at 298.15K and 105 Pa (Jmol−1 )
Liquid molar volume at 298.15K (m3 mol−1 )
Solubility parameter at 298.15K ((Jm−3 )1/2 )
Refractive index at 298.15K
Flash point temperature (K)
Autoignition temperature (K)

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

D.2 Temperature dependent properties


Multiflash can store coefficients for the following temperature dependent properties. Note
that property correlations may be missing for some compounds depending on the databank(s)
in use.
Perfect gas heat capacity Cp (Jmol−1 K−1 )
Zero-density gas viscosity (Pa s)
Zero-density gas thermal conductivity (W m−1 K−1 )
Second virial coefficient (m3 mol−1 )
Saturated liquid vapour pressure (Pa)
Enthalpy change on evaporation for saturated liquid (latent heat) (Jmol−1 )
Saturated liquid density (mol m−3 )
Saturated liquid viscosity (Pa s)
Saturated liquid thermal conductivity (W m−1 K−1 )
Surface tension of saturated liquid (N m−1 )
Saturated liquid heat capacity Cp (Jmol−1 K−1 )
Relative permittivity (dielectric constant)
Solid density (mol m−3 )
Solid heat capacity Cp (Jmol−1 K−1 )
Several alternative correlations can be used for each property. The actual equation used
depends on the databank and component. Different equations may be used for the same
property for different components in a given databank. If the user wishes to override databank
values or to define a component without using a databank, any of the equation forms may
be used. Details of the correlating equations currently implemented are set out below. T
denotes the temperature in K. For each temperature correlation a minimum and maximum
temperature Tmin and Tmax is stored. In most cases, extrapolating equations are given for the
cases T < Tmin and T > Tmax . These extrapolations have two coefficients b1 and b2 which are
found by fitting to the value of the main correlation and its temperature derivative at either
Tmin or Tmax . The b coefficients are calculated internally by Multiflash and are not stored in
the databanks.

D.3 Perfect gas molar heat capacity/enthalpy/entropy


Coefficients for correlating the pg heat capacity Cp are stored. H and S are calculated by
integrating Cp appropriately with the constants of integration stored as a1 and a2 respectively.
On loading the coefficients for any correlation from a data bank, Multiflash automatically
calculates and stores values for a1 and a2 for a datum of 298.15K and 105 Pa, i.e. the enthalpy
and entropy returned by the correlation are zero at these conditions.

173
Infochem equation 1: Harmens’ equation
Harmens 3 proposed the following equation

Cp /R = a3 + (a4 − a3 )y 2 (1 + (y − 1)(a6 + a7 y + a8 y 2 + a9 y 3 )) (4)

where R is the gas constant and:


T
y= (5)
T + a5
Harmens’ equation extrapolates to the limits a3 and a4 at zero and infinite temperatures
and therefore if these coefficients are chosen correctly the equation has an effectively unlimited
range. For a linear molecule a3 should be set to 3.5 and a4 should be set to 3N − 1.5 where N
is the number of atoms in the molecule. For a non-linear molecule a3 should be set to 4 and
a4 should be set to 3N − 2. The values of Tmin and Tmax are only used to return warnings,
no extrapolation is applied.

Infochem equation 2: DIPPR equation 107


2 2
a5 /T a7 /T
 
Cp = a 3 + a 4 + a6 (6)
sinh(a5 /T ) cosh(a7 /T )
T > Tmax : Cp = Cp (Tmax ) (7)
T < Tmin : Cp = Cp (Tmin ) (8)
The properties of this equation are similar to Harmens’ equation, it can be made to match
the physical limits at zero and infinite temperatures.

Infochem equation 3: IUPAC Nitrogen eos form


U 2 exp(U )
Cp = a3 /T 3 + a4 /T 2 + a5 /T + a6 + a7 T + a8 T 2 + a9 /T 3 + a10 (9)
(exp(U ) − 1)2
U = a11 /T (10)
T > Tmax : Cp = Cp (Tmax ) (11)
T < Tmin : Cp = Cp (Tmin ) (12)
The properties of this equation are similar to Harmens’ equation, it can be made to match
the physical limits at zero and infinite temperatures.

Infochem equation 4: Wagner Oxygen eos form


U 2 exp(U ) (2/3)η 2 exp(−η)
Cp = a3 /T 1.5 + a4 + a5 T 2 + a6 + a 7 (13)
(exp(U ) − 1)2 (1 + (2/3) exp(−η))2
U = a8 /T (14)
η = a9 /T (15)
T > Tmax : Cp = Cp (Tmax ) (16)
T < Tmin : Cp = Cp (Tmin ) (17)
The properties of this equation are similar to Harmens’ equation, it can be made to match
the physical limits at zero and infinite temperatures.
3
A.Harmens, Proceedings of the NPL Conference: Chemical Thermodynamic Data on Fluids and Fluid
Mixtures, NPL 11-12 September 1978, IPC Science and Technology Press, 1979.

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.

D.4 Gas viscosity at zero density


Infochem equation 1: DIPPR equation 102
a1 T a2
η= (21)
1 + a3 /T + a4 /T 2
√ √
T > Tmax : η = b1 / T + b2 T (22)

b1 T
T < Tmin : η = (23)
b2 + T

Infochem equation 2: Reichenberg equation:


a1 Tr
η= a3 (24)
(1 + a2 Tr (Tr − 1))1/6
where:
Tr = T /Tc (25)
√ √
T > 0.99Tc : η = b1 / T + b2 T (26)

b1 T
T < Tmin : η = (27)
b2 + T

Infochem equation 3: Chapman-Enskog equation


26.69 × 10−7 (M T )1/2
η= (28)
a21 Ω2,2 (T ∗ , a3 )
where M is the molecular weight and Ω2,2 is a dimensionless collision cross-section calculated
from the correlation of Neufeld, Janzen and Aziz 4 :
−B
Ω2,2 = AT ∗ + C exp (−DT ∗ ) + E exp (−F T ∗ ) + 0.2a23 /T ∗ (29)

and T ∗ = T /a2 , A = 1.16145, B = 0.14874, C = 0.52487, D = 0.77320, E = 2.16178 and


F = 2.43787. See Reid, Prausnitz and Poling 5 , p.393.
√ √
T > Tmax : η = b1 / T + b2 T (30)

b1 T
T < Tmin : η = (31)
b2 + T
4
P.D.Neufeld, A.R.Janzen and R.A.Aziz, J. Chem. Phys., 57, 1100-1102, 1972.
5
R. C. Reid, J. M. Prausnitz and B. E. Poling, ‘The Properties of Gases and Liquids’, 4th. ed., McGraw-
Hill, New York, (1987)

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

D.5 Gas thermal conductivity at zero density


Infochem equation 1: DIPPR equation 102
a1 T a2
λ= (35)
1 + a3 /T + a4 /T 2
√ √
T > Tmax : λ = b1 / T + b2 T (36)

b1 T
T < Tmin : λ = (37)
b2 + T

Infochem equation 2: reduced correlation



Tr
λ= (38)
a1 + a2 Tr + a3 Tr2 + a4 Tr3
where:
Tr = T /Tc (39)
TH = min(0.99Tc , Tmax ) (40)
√ √
T > TH : λ = b1 / T + b2 T (41)

b1 T
T < Tmin : λ = (42)
b2 + T

Infochem equation 3: Monatomic ideal gas


λ = η0 Cv F(T )/M (43)
where η0 is the zero density viscosity, F is the Eucken factor and M is the molecular weight.
For monatomic gases Cv = 1.5R and F = 2500, hence:

λ = 3750η0 R/M (44)

The values of Tmin and Tmax are only used to return warnings, no extrapolation is applied.

Infochem equation 5: DIPPR equation 100


λ = a1 + a2 T + a3 T 2 + a4 T 3 + a5 T 4 (45)
√ √
T > Tmax : λ = b1 / T + b2 T (46)

b1 T
T < Tmin : λ = (47)
b2 + T

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)

Infochem equation 5: DIPPR equation 100


B = a1 + a2 T + a3 T 2 + a4 T 3 + a5 T 4 (52)
T > Tmax : B = b1 (53)
T < Tmin : B = b1 + b2 (T − Tmin ) (54)

D.7 Saturated liquid vapour pressure


Infochem equation 1: Simplified Wagner equation:
ln p = ln pc + (a1 τ + a2 τ 2 + a3 τ 3 )/Tr (55)
where:
Tr = T /Tc (56)
τ = 1 − Tr (57)
T > Tc : ln p = ln pc + (a1 τ )/Tr (58)
For a description of the original Wagner equation see Ambrose 6

Infochem equation 2: Extended Antoine equation (DIPPR equation 101/115)


a2
ln p = a1 + + a4 T a6 + a5 ln T + a7 /T 2 (59)
T + a3
T > Tmax : ln p = b1 + b2 /T (60)
T < Tmin : ln p = b1 + b2 /T (61)

Infochem equation 3: Wagner equation


3
ln p = ln pc + (a1 τ + a2 τ 2 + a3 τ 3 + a4 τ 6 )/Tr (62)
where:
Tr = T /Tc (63)
τ = 1 − Tr (64)
T > T c : ln p = ln pc + (a1 τ )/Tr (65)
T < Tmin : ln p = ln pc + (b1 + b2 /Tr ) (66)
6
Ambrose, D. and Ghiassee, N. B., J. Chem. Thermodynamics, 19, 903 (1987)

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)

Infochem equation 5: DIPPR equation 100


p = a1 + a2 T + a3 T 2 + a4 T 3 + a5 T 4 (72)
T > Tmax : ln p = b1 + b2 /T (73)
T < Tmin : ln p = b1 + b2 /T (74)

Infochem equation 7: IAPWS equation


This equation form is used by IAPWS to correlate the vapour pressure of water.
3 7 15
ln p = ln pc + (a1 τ + a2 τ 2 + a3 τ 3 + a4 τ 2 + a5 τ 4 + a6 τ 2 )/Tr (75)
where:
Tr = T /Tc (76)
τ = 1 − Tr (77)
T > Tc : ln p = ln pc + (a1 τ )/Tr (78)
T < Tmin : ln p = ln pc + (b1 + b2 /Tr ) (79)

D.8 Enthalpy change on evaporation for saturated liquid (latent heat)


Infochem equation 1: DIPPR equation 106/Watson equation
Hvap = a1 τ Y (80)
where:
Y = a2 + a3 Tr + a4 Tr2 + a5 Tr3 (81)
Tr = T /Tc (82)
and:
τ = 1 − Tr (83)
b1
T > 0.999Tc : Hvap = (84)
b2 + T

Infochem equation 2: Wagner-type equation


Hvap 1 2 4 5
= a1 τ 3 + a2 τ 3 + a3 τ + a4 τ 3 + a5 τ 3 + a6 τ 2 + a7 τ 6 (85)
RTc
where:
τ = 1 − T /Tc (86)
TH = min(0.999Tc , Tmax ) (87)
b1
T > TH : Hvap = (88)
b2 + T
T < Tmin : Hvap = b1 + b2 τ 0.3775 (89)

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)

D.9 Saturated liquid density


Infochem equation 1
ρ = a1 + a2 τ a3 (93)
where:
τ = 1 − T /Tc (94)
TH = min(0.999Tc , Tmax ) (95)
b1 + T
T > TH : ρ = 0.9a1 (96)
b2 + T

Infochem equation 2: Modified Hankinson and Thompson equation (DIPPR


equation 116)
2 4
ρ0 = 1/Vc0 + a1 τ 0.35 + a2 τ 3 + a3 τ + a4 τ 3 (97)
where: ρ0 is the mass density, Vc0 is the critical volume per unit mass and
τ = 1 − T /Tc (98)
TH = min(0.99Tc , Tmax ) (99)
b1 + T
T > TH : ρ = (100)
Vc (b2 + T )

Infochem equation 3: Extended Rackett equation


1/ρ = a1 (a2 + a3 τ )Y (101)
where:
2
Y =1+τ7 (102)
and:
τ = 1 − T /Tc (103)
TH = min(0.99Tc , Tmax ) (104)
1 b1 + T
T > TH : = a1 (105)
ρ b2 + T

Infochem equation 4: DIPPR equation 105


1 aY
= 2 (106)
ρ a1
where:
Y = 1 + (1 − T /a3 )a4 (107)
TH = min(0.99a3 , Tmax ) (108)
1 b1 + T
T > TH : = (109)
ρ a1 (b2 + T )

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)

Infochem equation 7: IAPWS equation


This equation form is used by IAPWS to correlate the density of saturated liquid water.
ρ 1 2 5 16 43 110
= 1 + a1 τ 3 + a2 τ 3 + a3 τ 3 + a4 τ 3 + a5 τ 3 + a6 τ 3 (116)
ρc
where: ρc is the critical density and
τ = 1 − T /Tc (117)
T > TH : hyperbolic extrapolation (118)
T < Tmin : linear/quadratic extrapolation (119)

D.10 Saturated liquid viscosity


Infochem equation 1: Reid, Prausnitz and Poling
This is the Reid, Prausnitz and Poling6 (pp.441-455) equation 1:
η = a1 T a2 (120)
The values of Tmin and Tmax are only used to return warnings, no extrapolation is applied.

Infochem equation 2: DIPPR equation 101


ln η = a1 + a2 /T + a3 ln T + a4 T a5 (121)
T > Tmax : ln η = b1 + b2 ln T (122)
T < Tmin : ln η = b1 + b2 ln T (123)

Infochem equation 3: reduced correlation


η
ln = a1 X 1/3 + a2 X 4/3 (124)
a5
where:
a3 − a4
X= −1 (125)
T − a4
TH = min(0.99a3 , Tmax ) (126)
b1
T > TH : ln η = (127)
b2 + T
TL = max(1.01a4 , Tmin ) (128)
T < TL : ln η = b1 + b2 ln(T ) (129)

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)

T > Tmax : ln η = b1 + b2 ln T (131)


T < Tmin : ln η = b1 + b2 ln T (132)

Infochem equation 5: DIPPR equation 100


η = a1 + a2 T + a3 T 2 + a4 T 3 + a5 T 4 (133)
T > Tmax : ln η = b1 + b2 ln T (134)
T < Tmin : ln η = b1 + b2 ln T (135)

D.11 Saturated liquid thermal conductivity


Infochem equation 1: Jamieson equation
1 2
λ = a1 (1 + a2 τ 3 + a3 τ 3 + a4 τ ) (136)
where:
τ = 1 − T /Tc (137)
TH = min(0.99Tc , Tmax ) (138)
b1 + T
T > TH : λ = a1 (139)
b2 + T
T < Tmin : linear/quadratic extrapolation (140)

Infochem equation 2: DIPPR equation 101


ln λ = a1 + a2 /T + a3 ln T + a4 T a5 (141)
T > Tmax : ln λ = b1 + b2 ln T (142)
T < Tmin : ln λ = b1 + b2 ln T (143)

Infochem equation 5: Reid, Prausnitz and Poling


This is the equation defined by Reid et al.6 (pp.546-548):

λ = a1 + a2 T + a3 T 2 + a4 T 3 + a5 T 4 (144)

T > Tmax : hyperbolic extrapolation (145)


T < Tmin : linear/quadratic extrapolation (146)

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)

Infochem equation 2: Extended Sprow and Prausnitz equation


σ = a1 τ a2 (1 + a3 τ ) (154)
where:
τ = 1 − T /Tc (155)
and:
Tr = T /Tc (156)
TH = min(0.99Tc , Tmax ) (157)
b1
T > TH : σ = (158)
b2 + T
T < Tmin : linear/quadratic extrapolation (159)

Infochem equation 5: DIPPR equation 100


σ = a1 + a2 T + a3 T 2 + a4 T 3 + a5 T 4 (160)
b1
T > Tmax : σ = (161)
b2 + T
T < Tmin : linear/quadratic extrapolation (162)

D.13 Saturated liquid Cp


Infochem equation 1: DIPPR equation 114
Cp = a1 /τ + a2 + a3 τ + a4 τ 2 + a5 τ 3 + a6 τ 4 + a7 τ 5 (163)
where:
τ = 1 − T /Tc (164)
TH = min(0.95Tc , Tmax ) (165)
1 + 2(b1 + b2 T )
T > TH : Cp = Cp (Tmax ) (166)
1 + (b1 + b2 T )
T < Tmin : Cp = Cp (Tmin )(b1 + b2 T ) (167)

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)

D.14 Dielectric constant of liquid


Infochem equation 1
 = a1 + a2 T + a3 T 2 + a4 T 3 (171)
T > Tmax :  = b1 + b2 T (172)
T < Tmin :  = b1 + b2 T (173)

Infochem equation 2
Matyott and Smith.
 = exp(a1 + a2 T ) (174)
The above equation is also used for extrapolation.

D.15 Solid density


Infochem equation 5: DIPPR equation 100
ρ = a1 + a2 T + a3 T 2 + a4 T 3 + a5 T 4 (175)
T > Tmax : ρ = b1 (176)
T < Tmin : ρ = b1 (177)

D.16 Solid heat capacity Cp


Infochem equation 3: Multiple T-ranges
The thermal properties are stored as a series of correlations for Cp over a number of temper-
ature ranges. The equation used for Cp in the kth. range is:

Cp = a1k + a2k T + a3k /T 2 + a4k T 3 (178)

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)

E Equations of state models for fluid mixtures


E.1 Perfect gas equation
N RT
p= (182)
V
where: X
N= ni (183)
i

E.2 Hayden-O’Connell gas phase model


This treats each component in the gas phase as forming a monomer-dimer equilibrium. For
most components that deviate only slightly from ideal behaviour, the model reduces to the
volume-explicit virial equation:
N RT
V = +B (184)
V
where: X
N= ni (185)
i

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

E.3 Redlich-Kwong and Redlich-Kwong-Soave equation


N RT a
p= − (186)
V − b V (V + b)
where for the original RK equation8 :
s
Tci

ai = aci (187)
T

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.

E.4 Peng-Robinson equation


The Peng-Robinson 11 equation has the form
N RT a
p= − 2 (198)
V − b V + 2bV − b2
where:   q 2
ai = aci 1 + κi 1 − T /Tci (199)

R2 Tci2
aci = Ω0a 0.45724 (200)
pci
where Ω0a is a scaling factor normally equal to unity.

κi = 0.37464 + 1.54226ωi − 0.26992ωi2 (201)


9
G. Soave, Chem. Eng. Sci., 27, 1197, (1972).
10
M. S. Graboski and T. E. Daubert, Ind. Eng. Proc. Des. Dev., 17, 443, (1978); ibid., 17, 448, (1978);
ibid., 18, 300, (1979).
11
D.-Y. Peng and D. B. Robinson, Ind. Eng. Chem. Fundam., 15, 1, (1976); ACS Symp. Ser. 133, 193,
(1980).

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:

κi = 0.379642 + 1.48503ωi − 0.164423ωi2 + 0.01666ωi3 (203)

The mixing rules are: X


N= ni (204)
i
X√
a= ai aj (1 − kij )ni nj (205)
ij
X
b= bi ni (206)
i
RTci
bi = Ω0b 0.07780 (207)
pci
where Ω0b is a scaling factor normally equal to unity.

E.5 Infochem advanced equation of state features


The advanced implementations of the RKS and PR equations contain additional features
described below.

E.5.1 The Peneloux density correction


The original Peneloux method 13 adds a constant correction to the volume of both phases
which improves density predictions for the liquid phase but leaves the phase behaviour un-
affected. The Infochem advanced EOS method offers a choice of constant or temperature-
dependent volume shift. The volume calculated from the EOS is adjusted as follows:
X
V = VEOS − ni ci (208)
i

where ci is the volume shift for component i and is calculated as

ci = ci,0 + ci,1 T + ci,2 /T (209)

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 .

E.5.3 MHV2-type mixing rules


The method is based on the work of Michelsen and Soave15 :
X
N= ni (213)
i
X
b= bi ni (214)
i
!
RT b s2 N 2
a=− Q(α) − (215)
s1 Q(α)
where:
GE X b
  
Q(α) = + ni Qi (αi ) + ln (216)
RT i
N bi
p
−αi s1 − (αi s1 )2 + 4s2
Qi (αi ) = (217)
2
and:
ai
αi = (218)
RT bi
For the RKS equation use Soave’s values√ of s1 = ln 2 and s2 = 17.25 and for the PR equation
1
use Infochem’s values of s1 = 2√ 2
ln( 2+√2 ) = 0.623225 and s2 = 20.129.
2− 2
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.
14
P. M. Mathias and T. W. Copeman, Fluid Phase Equil., 13, 91 (1983)
15
M. L. Michelsen, Fluid Phase Equil., 60, 213, (1990); G. Soave, Fluid Phase Equil., 72, 325, (1992).

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.

E.5.5 Infochem NRTL-type mixing rules


X
N= ni (222)
i
X
b= bi ni (223)
i
P
X j nj bj ξji Gji
a=b ni P (224)
i j nj bj Gji

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.

E.5.6 Huron-Vidal-Pedersen (HVP) mixing rules


The HVP mixing rule17 was first designed to extend the validity of cubic equations of state to
systems containing methanol. It requires three binary interaction parameters (i.e., ∆gij /R,
∆gji /R, and αij = αji ). The mixing rule can be summarized as:
X
N= ni (227)
i
X
b= bi ni (228)
i
16
J. M. Huron and J. Vidal, Fluid Phase Equil., 3, 255, (1979).
17
JN Kristensen, PL Christensen, KS Pedersen and P. Skovborg A combined Soave-Redlich-Kwong and
NRTL equation for calculating the distribution of methanol between water and hydrocarbon phases. Fluid
Phase Equilibria. 82, 199-206, 1993

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.

E.5.7 PSRK mixing rules


The PSRK (Predictive SRK) mixing rules 18 are provide another option for incorporating an
excess Gibbs energy model in equation of state mixing rules.
X
N= ni (233)
i
X
b= bi ni (234)
i
!
GE RT X b ai
  X  
a=b − − ln + ni (235)
s1 s1 i bi i
bi
s1 = 0.64663 (236)
The excess Gibbs energy GE should be calculated by the UNIFAC method with the PSRK
group interaction table.

E.5.8 LCVM mixing rules


The LCVM mixing rules 19 are a linear combination of the Vidal and Michelsen rules. They
provide another option for incorporating an excess Gibbs energy model in equation of state
mixing rules. X
N= ni (237)
i
X
b= bi ni (238)
i
18
Holderbaum, T. and J. Gmehling, Fluid Phase Equilibria, 70, 251 (1991)
19
Boukouvalas, C., Spiliotis, N., Coutsikos, P., Tzouvara, N. and Tassios, D., Fluid Phase Equilibria, 92,
75 (1994)

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.

E.6 Equation of state with chemical association model


The CPA model 20 consists of the RKS equation plus an additional term based on Wertheim’s
theory that represents the effect of chemical association. The form of the model is

− 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.

E.7 Lee-Kesler and Lee-Kesler-Plöcker methods


The LKP method is a 3 parameter corresponding states method. It is implemented as de-
scribed by Plöcker et al. 21 . The method predicts fugacity coefficients, thermal properties
and volumetric properties of mixtures using the critical properties Tci , pci and ωi of each com-
ponent i. The Multiflash implementation uses a single temperature-independent interaction
parameter.
The original Lee-Kesler mixing rule is also available and is implemented as a model variant.
20
see Kontogeorgis et al., Fluid Phase Equilibria, 158-160, 201 (1999) and references therein
21
U. J. Plöcker, H. Knapp and J. M. Prausnitz, Ind. Eng. Chem. Proc. Des. Dev., 17, 324, (1978).

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.

E.9 Multi-reference fluid corresponding states model


E.9.1 Model
The CSM model is based on a collection of very accurate equations of state for a number
of reference fluids. It will provide very accurate values of properties for any of the reference
fluids and it uses a 1-fluid corresponding states approach to estimate mixture properties. It
is formulated so that mixture properties will reduce to the (accurate) pure component values
as the mixture composition approaches each of the pure component limits.
All properties are calculated from the following model for the total mixture reduced Gibbs
energy X X
Gmix = ni G0i (Tr , pr )/ ni (248)
i i
where ni is the mole number of component i and Tr = T /Tc,mix , pr = p/pc,mix .

E.9.2 GERG-2008 model


The CSMA model also includes the GERG-2008 natural gas model. This is an industry-
standard high-accuracy model for mixtures of natural gas components: methane, nitrogen,
CO2 , ethane, propane, n-butane, iso-butane, n-pentane, iso-pentane, hexane, heptane, oc-
tane, nonane, decane, argon, oxygen, hydrogen, hydrogen sulphide, CO, water, helium. The
model includes appropriate BIPs for all components in the list. The model is fully described
in the publication by O. Kunz, R. Klimeck, W. Wagner, M. Jaeschke, The GERG-2004 wide-
range equation of state for natural gases and other mixtures, GERG Technical Monograph,
15(2007).

E.9.3 Reference fluids


The model currently includes reference fluids for the following substances: ammonia, argon,
iso-butane, n-butane, 1-butene, cis-2-butene, trans-2-butene, cyclohexane, CO, CO2 , COS,
ethane, ethanol, ethylene, fluorine, H2 S, helium, heptane, hexane, iso-hexane, hydrogen, H2S,
krypton, methane, neon, nitrogen, NF3, octane, oxygen, n-pentane, iso-pentane, neo-pentane,
propane, propylene, SF6, SO2, toluene, water (IAPSW 95), xenon, R11, R113, R114, R115,
R116, R12, R123, R124, R125, R13, R134a, R14, R143a, R152a, R22, R227fa, R23, R245fa,
R32 and RC318. The equations of state are taken from various sources and do not all have
the same quality or range of applicability. Other hydrocarbons and petroleum fractions are
included using a generalised equation of state.
22
Starling, Fluid thermodynamic properties for light petroleum systems, Gulf Publishing Co., Houston
(1973).

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 .

E.11 High-accuracy formulation for pure Carbon Dioxide


The reference equation of state developed by Span and Wagner 25 is combined with the
best-available correlations for the viscosity 26 and the thermal conductivity 27 .

E.12 Electrolyte model


The Infochem electrolyte model uses Debye-Hückel theory plus Pitzer-style additional terms
to model electrolyte interactions in mixed solvents. Currently the model has parameters for
water, methanol, ethanol and MEG solvents and Na+ , K+ , Ca2+ , Cl− and Br− ions.

E.13 PC-SAFT model


The PC-SAFT equation is a development of the SAFT (Statistical Associating Fluid Theory)
model that has been shown to give good results for a wide range of polar and non-polar
substances including polymers. Polymers is one of the most important areas of application
of PC-SAFT. The model appears to be one of the most accurate and realistic equations of
state currently available for modelling polymer systems.
PC-SAFT stands for Perturbed Chain SAFT and it incorporates current ideas of how to
model accurately the detailed thermodynamics of fluids within the framework an equation of
state. The mathematical structure is very complex and cannot be conveniently described in
a manual. Users are referred to Appendix A of the paper 28 . The Multiflash version includes
an implementation of the association term of PC-SAFT which is discussed in the paper 29 .
This paper however does not discuss the mathematical formulation of the association term;
this can be found in the paper 30 . The Multiflash implementation follows the same general
structure as the association term in the CPA model.
Multiflash also has a version of PC-SAFT with simplified mixing rules as proposed by
researchers at the Danish Technical University. It is described in the paper 31 .
23
W. Wagner and A. Pruss, The IAPWS Formulation for the Thermodynamic Properties of Ordinary Water
Substance for General and Scientific Use, J. Phys. Chem. Ref. Data, 31, 387 (2002)
24
Revised Release on the IAPS Formulation 1985 for the Viscosity of Ordinary Water Substance (August
2003); Revised Release on the IAPS Formulation 1985 for the Thermal Conductivity of Ordinary Water
Substance (September 1998); IAPWS Release on Surface Tension of Ordinary Water Substance (September
1994)
25
R. Span and W. Wagner, A New Equation of State for Carbon Dioxide Covering the Fluid Region from
the Triple-Point Temperature to 1100 K at Pressures up to 800 MPa, J. Phys. Chem. Ref. Data, 25, 1509
(1996)
26
A. Fenghour, W. A. Wakeham and V. Vesovic, The Viscosity of Carbon Dioxide, J. Phys. Chem. Ref.
Data, 27, 31 (1998)
27
G. Scalabrin, P. Marchi, F. Finezzo and R. Span, A Reference Multiparameter Thermal Conductivity
Equation for Carbon Dioxide with an Optimized Functional Form, J. Phys. Chem. Ref. Data, 35, 1549 (2006)
28
Perturbed-Chain SAFT: An Equation of State Based on a Perturbation Theory for Chain Molecules by
Gross and Sadowski in Industrial and Engineering Chemistry Research, 40, 1244, (2001).
29
Application of the Perturbed-Chain SAFT Equation of State to Associating Systems by Gross and Sad-
owski in Industrial and Engineering Chemistry Research, 41, 5510, (2002)
30
New Reference Equation of State for Associating Liquids by Chapman, Gubbins, Jackson and Rodosz in
Industrial and Engineering Chemistry Research, 29, 1709, (1990)
31
Computational and Physical Performance of a Modified PC-SAFT Equation of State for Highly Asym-

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:

F.1 Ideal solution model


GE
=0 (252)
RT

F.2 Wilson equation


Two variants of the Wilson equation are implemented.

F.2.1 Wilson E equation


The E or ‘small lambda’ form of the equation is as originally defined by Wilson 33 .

!
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

F.3 NRTL equation


The equation is as defined by Renon and Prausnitz 34 .

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.

F.4 UNIQUAC equation


The equation is as defined by Abrams and Prausnitz 35 .

! ! !
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

F.5 UNIFAC method


This method is similar to UNIQUAC but calculates GE using the solution of groups principle.
Because it is based on molecular group interactions rather than interactions between complete
molecules it is completely predictive. However, results are not as reliable as those that can
be obtained by fitting interaction parameters in other activity models to experimental data.
The method is fully described by Fredenslund et al. 36 .
The method has been extended by Gmehling and coworkers 37 to handle mixtures contain-
ing light gases in the PSRK formulation. This variant uses the extended group interaction
34
H. Renon and J. M. Prausnitz, Local compositions in thermodynamic excess functions for liquid mixtures,
A.I.Ch.E.J., 14, 135, (1968).
35
D. S. Abrams and J. M. Prausnitz, Statistical Thermodynamics of liquid mixtures: A new expression for
the excess Gibbs energy of partly or completely miscible systems, A.I.Ch.E.J., 21, 116, (1975).
36
Aa. Fredenslund, J. Gmehling and P. Rasmussen, ‘Vapor-Liquid Equilibria Using UNIFAC’, Elsevier,
Amsterdam, (1977).
37
T. Holderbaum and J. Gmehling, Fluid Phase Equil., 70, 251, (1991); K. Fischer and J. Gmehling, ibid.,
112, 1, (1995); K. Fischer and J. Gmehling, ibid., 121, 185, (1996); J. Gmehling, J. Li and K. Fischer: ibid.,
141, 113, (1997); J. Li, K. Fischer and J. Gmehling, ibid., 143, 71, (1998); S. Horstmann, K. Fischer and J
Gmehling, ibid., 167, 173, (2000).

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.

F.6 Regular solution model


The expression used for the excess Gibbs energy is

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.

F.7 Flory-Huggins model


The Multiflash implementation of Flory-Huggins theory includes a correction term. It is
defined by: ! P
GE
P
X V i j nj ij ni nj Vi Vj Aij
= ni ln P + P (263)
RT i j n j V j 2RT i ni Vi

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.

G Other thermodynamic models for fluids


G.1 Henry’s Law water model
This models is used to give better values for the solubilities of light gases and hydrocarbons
in water than would be obtained from a normal equation of state. The fugacity of pure water
is calculated using any available model for a liquid phase such as an equation of state. The
38
Boukouvalas, C., Spiliotis, N., Coutsikos, P., Tzouvara, N. and Tassios, D., ibid., 92, 75 (1994); Spiliotis,
N., Boukouvalas, C., Tzouvaras, N., and Tassios, D., Fluid Phase Equilibria, 101, 187, (1994); Boukouvalas,
C. J., Magoulas, K. G., Stamataki, S. K., and Tassios, D. P., Ind. Eng. Chem. Res., 36, 5454, (1997).

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 .

G.2 COSTALD liquid density model


The COSTALD model is a corresponding states method for estimating the density of liquid
mixtures. The basic method 40 is a correlation for saturated liquid densities. Pressure correc-
tions for compressed liquids were subsequently added 41 and a binary interaction parameter
was introduced 42 . The Infochem implementation uses standard acentric factor values and the
V ∗ parameter is calculated for each component to match the density stored in the physical
property data system at a reduced temperature of 0.7 or at 298.15K, whichever temperature
is the lower.
The COSTALD method can be very accurate for pure substances and simple mixtures
such as LNG. It is not necessarily highly accurate for heavy hydrocarbon mixtures. The
method is valid up to a pseudo-reduced temperature of 0.9. Above that temperature a linear
extrapolation is used.

H Thermodynamic models for solids


H.1 Solid freeze-out model
This model permits the calculation of the thermodynamic properties of fixed-composition
solid phases formed by freezing one or more of the components present in the fluid mixture
as follows:
! !
∆H − Tref ∆Cp 1 1 Scorr ∆Cp T (p − patm ) ∆V
 
ln φi = α ln φliq
i − − + + ln −
R T Tref R R Tref RT
(264)
For the freeze-out of pure solids the parameters are as follows: φi is the fugacity coefficient
of pure solid component i, φliq
i is the fugacity coefficient of the same component as a pure
liquid at the same pressure p and temperature T (calculated from the liquid phase model
associated with the freeze-out model), α = 1, ∆H, ∆Cp and ∆V are the changes in molar
enthalpy, molar heat capacity and molar volume respectively on fusion at the normal melting
point, Tref when Scorr = 0. patm is atmospheric pressure. The model assumes that ∆H, ∆Cp
and ∆V are constants.
The freeze-out model can be used to represent the solidification of compounds such as
water, carbon dioxide or methane, for example in natural gases.

H.2 Scaling and general freeze-out model


In its general form, the freeze-out model can be applied to any solid phase of fixed composition,
which must be defined. The model can for example be applied to hydrated salts such as
monoethylene glycol (MEG) monohydrate or to crystalline mineral salts, i.e. scales such as
39
G. R. Cysewski and J. M. Prausnitz, Ind. Eng. Chem. Fundam., 15, 304, (1976)
40
Hankinson, R W, and Thomson, G H, A new correlation for saturated densities of liquids and their
mixtures, AIChEJ, 25, 653 (1979)
41
Thomson, G H, Brobst, K R, and Hankinson, R W, An improved correlation for densities of compressed
liquids and liquid mixtures, AIChEJ, 28, 671 (1982)
42
Hankinson, R W, Coker, T A, and Thomson, G H, Get accurate LNG densities with COSTALD, Hydro-
carbon Processing, April 1982, p.207

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.

H.3 Solid solution model


The implementation of the solid solution model has two variants: the regular solution model43
and the Flory-Huggins model 44

H.4 Multi-solid solution model


The model of Lira-Galeana et al.45 describes wax formation as a series of discrete solid
phases.

H.5 Coutinho wax model


The Coutinho 46 wax model treats the wax phase as a non-ideal solid solution whose properties
may be described with the Wilson or UNIQUAC models.

H.6 Gas hydrate model


The thermodynamic properties of gas hydrates are calculated from a new model developed
by Infochem in collaboration with Shell Research. The hydrate model is based on the van
der Waals-Platteeuw theory47 . The hydrate fugacities are obtained by the direct method
described by Cole and Goodwin48 .
The model includes hydrate structures I, II and H. It has parameters for the following
natural gas hydrate-formers: methane, ethane, propane, iso-butane, butane, nitrogen, CO2
and H2 S.
Other hydrate formers that are not usually present in natural gas but which form structure
I or II hydrates are also included. These compounds are: sulphur hexafluoride, propene,
ethene, argon, krypton, oxygen, xenon, cyclopropane, cyclopentane, cyclohexane, benzene
and tetrahydrofuran.
A model for the recently discovered hydrate structure H has been added. Structure H
includes some large cavities which can accommodate some of the heavier molecules present
in condensates and oils. A small ‘help gas’ such as methane or nitrogen is necessary to
stabilise the hydrate which can form at significantly higher temperatures than pure methane
or nitrogen hydrate. In practise it is often the case that a structure II hydrate forms before
the structure H. The Infochem structure H hydrate model has parameters for:
43
Hildebrand, J.H., Prausnitz, J.M. and Scott, R.L., Regular and related solutions, Van Nostrand Reinhold
Co., N.Y. (1970)
44
Flory, P.J., J. Chem. Phys., 9, 660 (1941), Flory, P.J., J. Chem. Phys., 10, 51 (1942), Huggins,M.L., J.
Chem. Phys., 9, 440 (1941), Huggins,M.L., Ann. N.Y. Acad. Sci., 1, 431 (1942)
45
Lira-Galeana, C., Firoozabadi, A. and Prausnitz, J.M., Thermodynamics of wax precipitation in petroleum
mixtures, A.I.Ch.E. J., 42, 239 (1996)
46
Coutinho, J.A.P., B. Edmonds, T. Moorwood, R. Szczepanski and X. Zhang, Reliable wax predictions for
flow assurance, SPE 78324 (2002)
47
van der Waals, J.W. and Platteeuw, J.C., Adv. Phys. Chem., 1, 1, (1959).
48
W. A. Cole and S. P. Goodwin, Flash calculations for gas hydrates: a rigorous approach, Chem. Eng. Sci.,
45, 569, (1990).

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.

I Viscosity models for fluid mixtures


I.1 SuperTRAPP viscosity model
The SuperTRAPP method 49 is a predictive extended corresponding states model that uses
propane as a reference fluid. It can predict the viscosity of petroleum fluids and well-defined
components over a wide range of thermodynamic states from the dilute gas to the dense
fluid. The basic idea behind this model is that the viscosity of a mixture can be equated to
the viscosity of a hypothetical pure fluid which is then related to the viscosity of a reference
fluid at a corresponding-state point (ρ0 , T0 ). In order to improve the viscosity prediction for
cycloalkanes and highly branched alkanes, the concept of mass shape factor in introduced in
this method. In order to apply the method, the following are required:

1. An equation of state for the reference fluid,

2. Correlation for the viscosity of the reference fluid

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:

1. Standard SuperTRAPP model as described above.

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.

1. Standard Pedersen method as described above.

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.

I.3 Twu model


This is a predictive model suitable for oils. It is based on a correlation of the API nomograph
for kinematic viscosity 51 and a mixing rule 52 . The information required for each petroleum
fraction in the mixture is the boiling point and specific gravity at 60 F. For components that
are not petroleum fractions the model parameters are fitted to the saturated liquid viscosity
at 100 F and 220 F if the component exists in the liquid state. The Twu model is only
applicable to the liquid state. Two variants of the Twu method are implemented.

1. Standard Twu method as described above.

2. Liquid viscosity fitting. An internal model parameter is is adjusted for petroleum


fractions 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.

I.4 Lohrenz-Bray-Clark method


The LBC model 53 predicts the viscosity of either a liquid or gas mixture using the critical
properties Tci , pci and ωi of each component i. The zero density viscosity for each component
is obtained from the Lucas54 correlation. The model was originally developed for oil and gas
mixtures but has been superseaded by more modern methods such as the Pedersen model. It
is provided only for backward-compatibility. In the Multiflash version, the fluid densities are
not calculated using the correlations proposed by Lohrentz, Bray and Clark but from any of
50
K. S. Pedersen, Aa. Fredenslund and P. Thomassen, ‘Properties of oils and natural gases’, Gulf Publishing
Company, Houston (1989)
51
C. H. Twu, ‘Generalized method for predicting viscosities of petroleum fractions’, AIChE Journal, 32,
2091 (1986)
52
C. H. Twu and JK. W. Bulls, ‘Viscosity blending tested’, Hydrocarbon processing, 217, April 1981.
53
J. Lohrenz,B. G. Bray and C. R. Clark, ‘Calculating Viscosities of Reservoir Fluids from their Composi-
tion’, Transactions of the Soc. of Pet. Engs. of the AIMMPE, 231, 1171, (1964).
54
R. C. Reid, J. M. Prausnitz and B. E. Poling, ‘The Properties of Gases and Liquids’, 4th. ed., McGraw-
Hill, New York, (1987), p.400

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.

I.5 Mixing rule for gas viscosities


The viscosity for a gas mixture at low density is calculated from the correlations (section
D.4) for zero-density gas viscosities of the pure components at the same temperature. The
Wilke mixing rule with the Herning and Zipperer approximation is used 55 :
X ηi
η= ni (265)
i
Yi
P q
where Yi = j nj φij and φij = Mj /Mi . Mi and ηi are the molecular weight and pure gas
viscosity for component i.

I.6 Mixing rule for liquid viscosities


The viscosity for a liquid mixture is calculated from the correlations (section D.10) for sat-
urated liquid viscosities of the pure components at the same temperature using a simple
logarithmic mixing rule56 : P
ni ln ηi
ln η = iP (266)
i ni
ni and ηi are the number of moles weight and pure saturated liquid viscosity of component i.

J Thermal conductivity models for fluid mixtures


J.1 Chung-Lee-Starling method
The CLS model 57 predicts the thermal conductivity of either a liquid or gas mixture. The
model is suitable for oil and gas processing and also for polar mixtures. It requires the critical
properties Tci , Vci and ωi for non-polar components . For polar and associating fluids, the
dipole moment and an association parameter are also required. Association parameters for
water, acetic acid and the lower alcohols are provided. The fluid density is required as part
of the calculation and this quantity may be obtained from any of the thermodynamic models
in Multiflash.
55
R. C. Reid, J. M. Prausnitz and B. E. Poling, ‘The Properties of Gases and Liquids’, 4th. ed., McGraw-
Hill, New York, (1987), p.407 and p.410.
56
ibid., p.474.
57
T.-H. Chung, L. L. Lee and K. E. Starling, Ind. Eng. Chem. Fundam., 23, 8, (1984); T.-H. Chung, M.
Ajlan, L. L. Lee and K. E. Starling, Ind. Eng. Chem. Res., 27, 671, (1988).

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 ).

λres (T, ρ) = λres


0 (T0 , ρ0 )Fλ (269)
where the Fλ calculation requires mixing and combining rules for the mixtures. In the current
version of Super TRAPP in Multiflash 3.9, the critical enhancement term, λcrit is omitted as
the critical enhancement for mixtures is usually very small.

J.3 Mixing rule for gas thermal conductivities


The thermal conductivity for a gas mixture at low density is calculated from the correlations
(section D.5) for zero-density gas thermal conductivity of the pure components at the same
temperature. The Wassiljewa mixing rule with the Herning and Zipperer approximation is
used59 :
X λi
λ= ni (270)
i
Yi
P q
where Yi = j nj Aij and Aij = Mj /Mi . Mi and λi are the molecular weight and pure gas
thermal conductivity of component i.

J.4 Mixing rule for liquid thermal conductivities


The thermal conductivity for a liquid mixture is calculated from the correlations (section
D.11) for saturated liquid thermal conductivities of the pure components at the same tem-
perature using a power law model60 as follows:
P −2
i n i Mi λ i
λ−2 = P (271)
i n i Mi
Mi and λi are the molecular weight and pure saturated liquid thermal conductivity of com-
ponent i.
58
M. E. Baltatu, R. A. Chong, M. L. Huber, and Laesecke, A., Int. J. Thermophysics, 20, 85, (1999); B.E.
Poling, J. M. Prausnitz and J. P. O’Connell, p10.24 (2001), ’The Properties of Gases and Liquids’, 5th edition,
McGraw-Hill, New York, USA.
59
R. C. Reid, J. M. Prausnitz and B. E. Poling, ‘The Properties of Gases and Liquids’, 4th. ed., McGraw-
Hill, New York, (1987), p.531 and p.410.
60
R. L. Rowley, G. L. White and M. Chiu, Chem. Eng. Sci., 43, 361, (1988).

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.

K.2 MacLeod-Sugden correlation


This method estimates the surface tension of a liquid mixture on the basis of the value of
the parachor of each component62 . The model is generally suitable for oil and gas processing
applications. The implementation in Multiflash uses liquid densities obtained from one of the
thermodynamic models, e.g. an equation of state.

K.3 Sutton correlation


The MacLeod-Sugden method gives reasonable results for gas hydrocarbon liquid interfaces,
but the performance of this method is not adequate for water interfaces. The correlation
published by Robert Sutton 63 has provided some reasonably good results.
 c3
 c1 (ρw − ρh ) + c2 
σhw =   a +a T +a T 2  (275)
2 3 4
T
Tc

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.

K.4 Mixing rule for surface tension


The surface tension for a liquid mixture is calculated from correlations (section D.12) for
the surface tension of the pure saturated liquids at the same temperature using a power law
model64 as follows: P
1 ni (1/σi )
= iP (276)
σ i ni
σi is the surface tension of the pure saturated liquid for component i.

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 .

L.2 Hayduk-Minhas model for the liquid phase


The Hayduk-Minhas method calculates liquid diffusion coefficients. It consists of a number
of empirical correlations for different classes of mixture. For example for normal paraffins the
diffusion coefficient of a trace amount of component i in component j in SI units is:

0 7.309 × 10−16 T 1.47 (1000ηj )


Dij = (278)
Vi0.71
64
ibid., p.643.
65
Chapter 11 of The Properties of Gases and Liquids, 5th. Ed. by Poling, Prausnitz and O’Connell,
McGraw-Hill, New York, 2001

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.

N.1.1 Low-level initialisation


PROGRAM EX1
C
C Example 1: Pure component properties
C Updated: 18.11.11
C
C Codes for pure component constants:
C
INCLUDE ’ayjpid.inc’
C
C Data bank i.d. codes:
C
INCLUDE ’ayjdbk.inc’
C
C Data bank location
C
INCLUDE ’databk.inc’
C
REAL*8 T, DT, TCRIT(1), TMELT(1), HFORM(1), VP(1), DL(1), DUM(1)
INTEGER LNODB, IC(1), I, NPTS, N, JBANK(1), IERR1, IERRLS
CHARACTER*1 KDUM(1)
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
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

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.

N.2.1 Low-level initialisation


PROGRAM EX2
C
C Example 2:
C Updated: 18.11.11
C
C Thermodynamic and transport properties for a mixture
C
C Data bank i.d. codes:
C
INCLUDE ’ayjdbk.inc’
C
C Codes for model identifiers:
C
INCLUDE ’ayjmid.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(2), VV, VL, HV, HL, S, DUM, ADUM(1), VISV,
+ VISL, ZCOMP, ST, TCV, TCL
INTEGER NMDL, LMDL(5), LNOB1, LNOTDM, LNOVSM, IC(2), N, I,
+ LNODB, LNODBB, IPHID, IPDL, IPDV, LNOMOD(MXMDPD), LNOST,
+ JBANK(1), NC, LNOTCM, IERR1, IERRLS
LOGICAL INIT, AMBIG, DER(0:3), D0(0:3)
CHARACTER*1 KDUM(1)
CHARACTER*20 CNAME(2)
CHARACTER*80 ERRMES
C
C Error reporting system:
C
INTEGER MXERR
PARAMETER (MXERR=10)
INTEGER NERR, IERR(MXERR)
C
C Initialise security system

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

N.2.2 Command file initialisation


The file ex2a.mfl contains commands to set up the same databank, components, models and
phase descriptors as used in the previous example. The contents are as follows:
puredata infodata;
bipdata oilandgas;
model Meos rks;
model Mvvisc vvs1;
model Mlvisc lvs1;
model Mst mcs Meos;
pd VAPOUR vapour Meos * * Mvvisc;

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.

N.6.1 Low-level initialisation


PROGRAM EX6
C
C Example 6: Simple flash using LKP method and calculation of
C phase properties including Cv and speed of sound
C Updated: 26.04.05
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 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(MAXPHA),
+ MOLWT(MAXNCS), SSOUND(MAXPHA), AVMW(MAXPHA), RHO(MAXPHA),

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

N.6.2 Command file initialisation


The file ex6a.mfl contains commands to set up the same databank, components, models and
phase descriptors as used in section N.6.1. The contents are as follows:
puredata infodata;
model Meos lkp;
model Mvvisc vvs1;
model Mlvisc lvs1;
model Mst st1;
pd VAPOUR vapour Meos * * Mvvisc;
pd LIQUID liquid Meos * * Mlvisc * Mst;
components BUTANE, CO2;

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

You might also like