aga92dc - Instructions for use
Revision:
E-mail: info@felib.com
aga92dc is the C source code implementation of the International standard
ISO 12213-2:1997(E): Natural gas
- Calculation of compression factor -
Part 2: Calculation using molar-composition
analysis
The software is written in a C-language and embeds all the restrictions implied by ISO-12213-2.
1. Function prototype
The following is the definition of the function prototype:
void aga92dc(
/* output parameters */
unsigned long int *error_status, /* Error status */
float *sup_cal_value, /*
float *relative_density, /* Relative density */
float *compression, /* Compression (compressibility factor) */
float *density, /* Density [kg/m3] */
float *molar_density, /* Molar density [kg-mole/m3] */
float *mole_average, /* Mole average */
/* input parameters */
float tepmerature_K, /* Temperature [K] */
float pressure_MPa, /* Pressure in [MPa] */
float x20, /* molar fraction of Argon */
float x19, /* molar fraction of Helium */
float x18, /* molar fraction of n-Decane */
float x17, /* molar fraction of n-Nonane */
float x16, /* molar fraction of n-Octane */
float x15, /* molar fraction of n-Heptane */
float x14, /* molar fraction of n-Hexane */
float x13, /* molar fraction of n-Pentane */
float x12, /* molar fraction of i-Pentane */
float x11, /* molar fraction of n-Butane */
float x10, /* molar fraction of i-Butane */
float x9, /* molar fraction of Oxygen */
float x8, /* molar fraction of Carbon Monoxide */
float x7, /* molar fraction of Hydrogen */
float x6, /* molar fraction of Hydrogen Sulfide */
float x5, /* molar fraction of Water */
float x4, /* molar fraction of Propane */
float x3, /* molar fraction of Ethane */
float x2, /* molar fraction of Carbon Dioxide */
float x1, /* molar fraction of Nitrogen */
float x0 /* molar fraction of Methane */
)
2. Input and output
parameters
The following Table shows the description of input and output parameters:
Table 2.1
|
Input parameters |
|||
|
Data type |
Parameter name |
Parameter
description |
Unit of measure |
|
float |
x0 |
molar fraction of Methane |
dimensionless |
|
float |
x1 |
molar fraction of Nitrogen |
" |
|
float |
x2 |
molar fraction of Carbon dioxide |
" |
|
float |
x3 |
molar fraction of Ethane |
" |
|
float |
x4 |
molar fraction of Propane |
" |
|
float |
x5 |
molar fraction of Water |
" |
|
float |
x6 |
molar fraction of Hydrogen sulfide |
" |
|
float |
x7 |
molar fraction of Hydrogen |
" |
|
float |
x8 |
molar fraction of Carbon monoxide |
" |
|
float |
x9 |
molar fraction of Oxygen |
" |
|
float |
x10 |
molar fraction of iso-Butane |
" |
|
float |
x11 |
molar fraction of n-Butane |
" |
|
float |
x12 |
molar fraction of i-Pentane |
" |
|
float |
x13 |
molar fraction of n-Pentane |
" |
|
float |
x14 |
molar fraction of n-Hexane |
" |
|
float |
x15 |
molar fraction of n-Heptane |
" |
|
float |
x16 |
molar fraction of n-Octane |
" |
|
float |
x17 |
molar fraction of n-Nonane |
" |
|
float |
x18 |
molar fraction of n-Decane |
" |
|
float |
x19 |
molar fraction of Helium |
" |
|
float |
x20 |
molar fraction of Argon |
" |
|
float |
pressure_MPa |
operating pressure |
[MPa] |
|
float |
temperature_K |
operating temperature |
[K] |
|
Output parameters |
|||
|
float |
mole_average |
gas mixture molar mass |
dimensionless |
|
float |
molar_density |
gas mixture molar density |
[kg×mol/m3] |
|
float |
density |
gas mixture density |
[kg/m3] |
|
float |
compression |
gas mixture compression factor |
dimensionless |
|
float |
relative density |
gas mixture relative density |
" |
|
float |
sup_cal_value |
gas mixture superior calorific value |
[MJ/m3] |
|
unsigned long int |
error_status |
error status |
dimensionless |
3. Parameter
ranges
The following Table shows the ranges for input parameters and intermediate results, as defined by ISO 12213-2.
Table 3.1
|
Component |
Unit of measure |
A* |
B** |
|
methane |
dimensionless |
0.70 to 1.00 |
0.50 to 1.00 |
|
nitrogen |
" |
0 to 0.20 |
0 to 0.50 |
|
carbon dioxide |
" |
0 to 0.20 |
0 to 0.30 |
|
ethane |
" |
0 to 0.10 |
0 to 0.20 |
|
propane |
" |
0 to 0.035 |
0 to 0.05 |
|
butanes (n-Butane + i-Butane) |
" |
0 to 0.015 |
0 to 0.0015 |
|
pentanes (n-pentane + i-Pentane) |
" |
0 to 0.005 |
0 to 0.005 |
|
hexanes (n-Hexane) |
" |
0 to 0.001 |
0 to 0.001 |
|
heptanes (n-Heptane) |
" |
0 to 0.0005 |
0 to 0.0005 |
|
octanes plus higher hydrocarbons (n-Octane, n-Nonane, n-Decane) |
" |
0 to 0.0005 |
0 to 0.0005 |
|
hydrogen |
" |
0 to 0.10 |
0 to 0.10 |
|
carbon monoxide |
" |
0 to 0.03 |
0 to 0.003 |
|
helium |
" |
0 to 0.005 |
0 to 0.005 |
|
water |
" |
0 to 0.015 |
0 to 0.00015 |
|
argon |
" |
0 to 0.0002 |
0 to 0.0002 |
|
absolute pressure |
[MPa] |
0 to 12 |
0 to 65 |
|
temperature |
[K] |
263 to 338 |
225 to 350 |
|
relative density |
dimensionless |
0.55 to 0.80 |
0.55 to 0.90 |
|
superior calorific value |
[MJ/m3] |
30 to 45 |
20 to 48 |
* A: pipeline quality natural gas
** B: wider ranges of application
The wider ranges of application (B) are implemented in aga92dc routine
4. Error
status
After completion of the routine the error_status (unsigned long integer) will be cleared if there were no errors during the calculation, or the corresponding bits will be set if certain errors were encountered. The error_status is represented in the following way:
Bit 0 =1 (000001H) If there exist at least one molar fraction < 0, else =0.
Bit 1 =1 (000002H) If the total sum of molar fractions <0.98 or >1.02, else =0.
Bit 2 =1 (000004H) If the total sum of molar fractions is <0.999999 or >1.000001, else =0. This bit denotes only a warning that the fractions have been normalized to give the total sum of molar fractions equal to 1. If only bit 2 was set during the calculation the results are valid.
Bit 3 =1 (000008H) If mole fraction of Methane <0.5 or >1.0, else =0.
Bit 4 =1 (000010H) If mole fraction of Nitrogen >0.5, else =0.
Bit 5 =1 (000020H) If mole fraction of Carbon Dioxide >0.3, else =0.
Bit 6 =1 (000040H) If mole fraction of Ethane >0.2, else =0.
Bit 7 =1 (000080H) If mole fraction of Propane >0.05, else =0.
Bit 8 =1 (000100H) If mole fraction of Water >0.00015, else =0.
Bit 9 =1 (000200H) If mole fraction of Hydrogen sulfide > 0.0002, else =0.
Bit 10 =1 (000400H) If mole fraction of Hydrogen >0.10, else =0.
Bit 11 =1 (000800H) If mole fraction of Carbon monoxide > 0.03, else =0.
Bit 12 =1 (001000H) If mole fraction of Oxygen >0.0002, else =0.
Bit 13 =1 (002000H) If mole fraction of Butanes (n-Butane + i-Butane) >0.015, else =0.
Bit 14 =1 (004000H) If mole fraction of Pentanes (n-pentane + i-Pentane) >0.005, else =0.
Bit 15 =1 (008000H) If mole fraction of Hexanes (n-Hexane) >0.001, else =0.
Bit 16 =1 (010000H) If mole fraction of Heptanes (n-Heptane) >0.0005, else =0.
Bit 17 =1 (020000H) If mole fraction of octanes plus higher hydrocarbons (n-Octane + n-Nonane, n-Decane) >0.01, else =0.
Bit 18 =1 (040000H) If mole fraction of Helium >0.005, else =0.
Bit 19 =1 (080000H) If mole fraction of Argon >0.0002, else =0.
Bit 20 =1 (100000H) If pressure <0.1 Pa or >65 MPa, else =0.
Bit 21 =1 (200000H) If temperature <225 K or >350 K, else =0.
Bit 22 =1 (400000H) If relative density <0.55 or >0.90, else =0.
Bit 23 =1 (800000H) If superior calorific value <20 MJ/m3 or >48 MJ/m3, else =0.
Bit 24 =1 (1000000H) If OFF-LINE calculation failed, else=0.
Bit 25,... All higer bits are unused
The error_status is returned as unsigned long integer representing all the errors encountered in the calculation. If bits 0,...,24 are all cleared, or if only bit 2 was set during the calculation, the returned output results are valid, otherwise the results are invalid, i.e. cleared.
5. Example of
a main program calling the function aga92dc
The following example illustrates the call to aga92dc function from a main program. Input parameters yy[igas][0], ..., yy[igas][20] represent natural gas mixture molar fractions where igas = 0 denotes Gas 1, ..., igas =5 denotes Gas 6 (See table 6.1 in chapter 6), yy[21] represents operating pressure (6 MPa) and yy[22] represents temperature 310 K. The output results are saved in yy[23], ..., yy[28] and an error status in error, after the completion of the routine. The program prompts for the selection of the gas mixture, for the operating pressure and temperature and prints the results on the screen.
/*
**************************************** */
/*
THE BEGINNING OF THE MAIN PROGRAM C-CODE */
/*
**************************************** */
#include
"stdio.h"
/*
declaration of the function aga92dc */
void
aga92dc(
/* output parameters */
unsigned long int *error_status, /* Error status */
float *sup_cal_value, /*
float *relative_density, /* Relative density */
float *compression, /* Compression (compressibility factor) */
float *density, /* Density [kg/m3] */
float *molar_density, /* Molar density [kg-mole/m3] */
float *mole_average, /* Mole average */
/* input parameters */
float tepmerature_K, /* Temperature [K] */
float pressure_MPa, /* Pressure in [MPa] */
float x20, /*
molar fraction of Argon */
float x19, /*
molar fraction of Helium */
float x18, /*
molar fraction of n-Decane */
float x17, /*
molar fraction of n-Nonane */
float x16, /*
molar fraction of n-Octane */
float x15, /*
molar fraction of n-Heptane */
float x14, /*
molar fraction of n-Hexane */
float x13, /*
molar fraction of n-Pentane */
float x12, /*
molar fraction of i-Pentane */
float x11, /*
molar fraction of n-Butane */
float x10, /*
molar fraction of i-Butane */
float x9, /*
molar fraction of Oxygen */
float x8, /*
molar fraction of Carbon Monoxide */
float x7, /*
molar fraction of Hydrogen */
float x6, /*
molar fraction of Hydrogen Sulfide */
float x5, /*
molar fraction of Water */
float x4, /*
molar fraction of Propane */
float x3, /*
molar fraction of Ethane */
float x2, /*
molar fraction of Carbon Dioxide */
float x1, /*
molar fraction of Nitrogen */
float x0 /*
molar fraction of Methane */
);
void
main(void)
{
unsigned short int i, j, igas;