FE-ISO20765-2-DLL


FE-ISO20765-2-DLL (felib.iso20765x2) is a component of felib.dll.
Felib.iso20765x2 performs the calculation of thermodynamic and volumetric properties of natural gas completely in accordance with:

ISO-20765-2:2015: Natural gas - Calculation of thermodynamic properties -
  • Part 2: Single phase properties (gas, liquid and dense fluid) for extended ranges of application.

Description of felib.iso20765x2 class interface: properties (variables), method (function) and error status flags.

PROPERTIES
Property Set property value Get property value
I X(I): mole fraction for
0 Methane void Set­Mole­Fraction­(short I, double X(I) double Get­Mole­Fraction­(short I)
1 Nitrogen
2 Carbon dioxide
3 Ethane
4 Propane
5 Water
6 Hydrogen sylfide
7 Hydrogen
8 Carbon monoxide
9 Oxygen
10 iso-Butane
11 n-Butane
12 iso-Pentane
13 n-Pentane
14 n-Hexane
15 n-Heptane
16 n-Octane
17 n-Nonane
18 n-Decane
19 Helium
20 Argon
Pressure [MPa] void Set­PressureMPa­(double newP) double Get­PressureMPa­()
Temperature [K] void Set­TemperatureK­(double newT) double Get­TemperatureK­()
*Ranges of application (RAP) void Set­Range­Of­Application­(short newRAP) short Get­Range­Of­Application­()
Protection key void Set­Key­Code­(long newValue) n/a
Mass-based density [kg/m3] void SetDensity(double newD) double Get­Density()
Reduced density void Set­Reduced­Density­(double newRD) double Get­Reduced­Density­()
Molar mass [kg/kmol] n/a double Get­Molar­Mass()
Molar density [kg⋅mole/m3] n/a double Get­Molar­Density()
Compression factor n/a double Get­Compression­Factor­()
Molar Gibbs free energy [kj/kmol] n/a double Get­Molar­Gibs­Free­Energy­()
Molar internal energy [kJ/kmol] n/a double Get­Molar­Internal­Energy ()
Specific internal energy [kJ/kg] n/a double Get­Specific­Internal­Energy ()
Molar enthalpy [kJ/kmol] n/a double Get­Molar­Enthalpy ()
Specific enthalpy [kJ/kg] n/a double Get­Specific­Enthalpy ()
Molar entropy [kJ/(kmol⋅K)] n/a double Get­Molar­Entropy ()
Specific entropy [kJ/(kg⋅K)] n/a double Get­Specific­Entropy ()
Molar isochoric heat capacity [kJ/(kmol⋅K)] n/a double Get­Molar­Isochoric­Heat­Capacity ()
Specific isochoric heat capacity [kJ/(kg⋅K)] n/a double Get­Specific­Isochoric­Heat­Capacity ()
Molar isobaric heat capacity [kJ/(kmol⋅K)] n/a double Get­Molar­Isobaric­Heat­Capacity ()
Specific isobaric heat capacity [kJ/(kg⋅K)] n/a double Get­Specific­Isobaric­Heat­Capacity ()
Joule-Thomson coefficient [K/MPa] n/a double Get­Joule­Thomson­Coefficient ()
Isentropic exponent n/a double Get­Isentropic­Exponent ()
Speed of sound [m/s] n/a double Get­Speed­Of­Sound ()
**Error status n/a long Get­Error­Flag()
***Error report n/a BSTR Get­Error­Report­()
FUNCTION
long CalculateIso20765x2(short iCalc); Calculates the properties and returns long error status
short iCalc - defines method of calculation Input parameters to selected method of calculation
iCalc=0 (or any iCalc≠1 & ≠2) Pressure, temperature and mole fractions
iCalc=1 Mass-based density, temperature and mole fractions
iCalc=2 Reduced density, temperature and mole fractions
*Ranges of application RAP (short RAP)
Parameter RAP=0 RAP=1 RAP=2
Pressure (absolute) in MPa >0 to 35 >0 to 70 >0 to 70
Temperature in K 90 to 450 60 to 700 60 to 700
Reduced density 5⋅10-9 to 6.00 5⋅10-9 to 6.00 5⋅10-9 to 6.00
Mole fractions ranges
Methane 0.7 to 1.00 0.3 to 1.00 0 to 1.00
Nitrogen 0 to 0.20 0 to 0.55 0 to 1.00
Carbon dioxide 0 to 0.20 0 to 0.30 0 to 1.00
Ethane 0 to 0.10 0 to 0.25 0 to 1.00
Propane 0 to 0.035 0 to 0.14 0 to 1.00
n-Butane + Isobutane 0 to 0.015 0 to 0.06 0 to 1.00
n-Pentane + Isopentane 0 to 0.005 0 to 0.005 0 to 1.00
n-Hexane 0 to 0.001 0 to 0.002 0 to 1.00
n-Heptane 0 to 0.0005 0 to 0.001 0 to 1.00
Octane + Nonane + Decane 0 to 0.0005 0 to 0.0005 0 to 1.00
Hydrogen 0 to 0.10 0 to 0.40 0 to 1.00
Oxygen 0 to 0.0002 0 to 0.02 0 to 1.00
Carbon monoxide 0 to 0.03 0 to 0.13 0 to 1.00
Water 0 to 0.00015 0 to 0.0002 0 to 1.00
Hydrogen sulfide 0 to 0.0002 0 to 0.27 0 to 1.00
Helium 0 to 0.005 0 to 0.005 0 to 1.00
Argon 0 to 0.0002 0 to 0.0005 0 to 1.00
  • RAP=0 corresponds to NORMAL RANGE for Pressure and Temperature and PIPELINE QUALITY RANGE for mole fractions of natural gas, see ISO-20765-2:2015
  • RAP=1 corresponds to FULL RANGE for P and T and INTERMEDIATE QUALITY RANGE for mole fractions of natural gas, see ISO-20765-2:2015
  • RAP=2 corresponds to FULL RANGE for Pressure and Temperature and NO RANGE LIMITATIONS for mole fractions of natural gas
Note that RAP=2 is not in accordance with ISO-20765-2:2015. Use it only for testing purposes e.g. on examples given in Annex G of ISO-20765-2:2015, which do not satisfy neither RAP=0 nor RAP=1.
**ERROR STATUS
long Ge­tError­Flag() Description of Error/Warning flags.
Bit 0 =1 (000001H) Error: There exists at least one mole fraction <0 or >1.
Bit 1 =1 (000002H) Error: Total sum of mole fractions <0.98 or >1.02.
Bit 2 =1 (000004H) Warning: Absolute temperature T<200.
This flag warns that the calculated thermodynamic properties may be invalid but, the calculated volumetric properties (reduced density, mass density and compression factor) are valid if only this bit is set.
Bit 3 =1 (000008H) Error: Mole fraction of Methane out of range defined by RAP
Bit 4 =1 (000010H) Error: Mole fraction of Nitrogen out of range defined by RAP
Bit 5 =1 (000020H) Error: Mole fraction of Carbon Dioxide out of range defined by RAP
Bit 6 =1 (000040H) Error: Mole fraction of Ethane out of range defined by RAP
Bit 7 =1 (000080H) Error: Mole fraction of Propane out of range defined by RAP
Bit 8 =1 (000100H) Error: Mole fraction of Water out of range defined by RAP
Bit 9 =1 (000200H) Error: Mole fraction of Hydrogen sulfide out of range defined by RAP
Bit 10 =1 (000400H) Error: Mole fraction of Hydrogen out of range defined by RAP
Bit 11 =1 (000800H) Error: Mole fraction of Carbon monoxide out of range defined by RAP
Bit 12 =1 (001000H) Error: Mole fraction of Oxygen out of range defined by RAP
Bit 13=1 (002000H) Error: Mole fraction of (n-Butane + i-Butane) out of range defined by RAP
Bit 14 =1 (004000H) Error: Mole fraction of (n-pentane + i-Pentane) out of range defined by RAP
Bit 15 =1 (008000H) Error: Mole fraction of n-Hexane out of range defined by RAP
Bit 16 =1 (010000H) Error: Mole fraction of n-Heptane out of range defined by RAP
Bit 17 =1 (020000H) Error: Mole fraction of (n-Octane + n-Nonane + n-Decane) out of range defined by RAP
Bit 18 =1 (040000H) Error: Mole fraction of Helium out of range defined by RAP
Bit 19 =1 (080000H) Error: Mole fraction of Argon out of range defined by RAP
Bit 20 =1 (100000H) Error: Pressure (absolute) out of range defined by RAP
Bit 21 =1 (200000H) Error: Temperature out of range defined by RAP
Bit 22 =1 (400000H) Error: Reduced density out of range
Bit 23 =1 (800000H) Error: Incorrect protection key
Bit 24,... All higher bits are unused.
***ERROR REPORT
The property "BSTR GetErrorReport()" is used to get an error report in a textual form.

Example 1
The Error report is illustrated by a calculation example using gas mixture denoted by Gas 5 in the Table G.1 of Annex G of ISO 20765-2:2015 with the corresponding absolute pressure (10MPa) and temperature (350K). The calculation method based on pressure, temperature and mole fractions(iCalc=0) is selected. In the first example the calculation is performed with "No range limits" (RAP=2). Upon completion of the method there were no errors and the property "BSTR GetErrorReport()" returns the the following error report string:

No errors

The following is a user interface to a simple VB program displaying the results and error status obtained upon completion of the calculation.

Example1 screenshot


Example 2
Example 2 is the same as the Example 1, except "Full range" (RAP=1) is selected instead of "No range limits" (RAP=2). Upon completion of the calculation method the range violation errors were set and the property "BSTR GetErrorReport()" returns the following error report string:

ErrBit03: Mole fraction of Methane out of range defined by RAP
ErrBit14: Mole fraction of Oxygen out of range defined by RAP
ErrBit18: Mole fraction of Helium out of range defined by RAP
ErrBit19: Mole fraction of Argon out of range defined by RAP

The following is a user interface to a VB program displaying error status after failing to complete the calculation.

Example2 screenshot