AGA8 WebAssembly
1.0
bindings for AGA8 gas properties calculations
|
Implementation of AGA 8 Part 1 GROSS equation of state (Version 2.0) More...
Go to the source code of this file.
Functions | |
void | Bmix (const double T, const std::vector< double > &xGrs, const double HCH, double &B, double &C, int &ierr, std::string &herr) |
Calculate 2nd and 3rd virial coefficients for the mixture at T. | |
void | MolarMassGross (const std::vector< double > &x, double &Mm) |
Calculate molar mass of the mixture with the compositions contained in the x() input array. | |
void | PressureGross (const double T, const double D, const std::vector< double > &xGrs, const double HCH, double &P, double &Z, int &ierr, std::string &herr) |
Calculate pressure as a function of temperature and density. | |
void | DensityGross (const double T, const double P, const std::vector< double > &xGrs, const double HCH, double &D, int &ierr, std::string &herr) |
Calculate density as a function of temperature and pressure. | |
void | GrossHv (const std::vector< double > &x, std::vector< double > &xGrs, double &HN, double &HCH) |
Calculate ideal heating values based on composition. | |
void | GrossInputs (const double T, const double P, const std::vector< double > &x, std::vector< double > &xGrs, double &Gr, double &HN, double &HCH, int &ierr, std::string &herr) |
Calculate relative density and heating values based on composition. | |
void | SetupGross () |
Initialize all the constants and parameters in the GROSS model. | |
void | GrossMethod1 (const double Th, const double Td, const double Pd, std::vector< double > &xGrs, const double Gr, const double Hv, double &Mm, double &HCH, double &HN, int &ierr, std::string &herr) |
Initialize variables required in the GROSS equation with Method 1 of the AGA 8 Part 1 publication. | |
void | GrossMethod2 (const double Th, const double Td, const double Pd, std::vector< double > &xGrs, const double Gr, double &Hv, double &Mm, double &HCH, double &HN, int &ierr, std::string &herr) |
Initialize variables required in the GROSS equation with Method 2 of the AGA 8 Part 1 publication. | |
Variables | |
static double | RGross |
static const int | NcGross = 21 |
static const int | MaxFlds = 21 |
static const double | epsilon = 1e-15 |
static double | mN2 |
static double | mCO2 |
static double | dPdDsave |
static double | xHN [MaxFlds+1] |
static double | MMiGross [MaxFlds+1] |
static double | b0 [4][4] |
static double | b1 [4][4] |
static double | b2 [4][4] |
static double | bCHx [3][3] |
static double | cCHx [3][3] |
static double | c0 [4][4][4] |
static double | c1 [4][4][4] |
static double | c2 [4][4][4] |
Implementation of AGA 8 Part 1 GROSS equation of state (Version 2.0)
This code implements routines for the calculation of thermodynamic properties from the AGA 8 Part 1 GROSS equation of state (April 2017).
The GROSS method is used for natural gas mixtures and requires less detailed composition information than the DETAIL method. It can use either:
Component order for composition array: 1 - Methane 8 - Isopentane 15 - Hydrogen 2 - Nitrogen 9 - n-Pentane 16 - Oxygen 3 - Carbon dioxide 10 - n-Hexane 17 - Carbon monoxide 4 - Ethane 11 - n-Heptane 18 - Water 5 - Propane 12 - n-Octane 19 - Hydrogen sulfide 6 - Isobutane 13 - n-Nonane 20 - Helium 7 - n-Butane 14 - n-Decane 21 - Argon
Definition in file Gross.cpp.
void Bmix | ( | const double | T, |
const std::vector< double > & | xGrs, | ||
const double | HCH, | ||
double & | B, | ||
double & | C, | ||
int & | ierr, | ||
std::string & | herr ) |
Calculate 2nd and 3rd virial coefficients for the mixture at T.
T | Temperature (K) | |
xGrs | Compositions of the equivalent hydrocarbon, nitrogen, and CO2 (mole fractions) | |
HCH | Molar ideal gross heating value of the equivalent hydrocarbon (kJ/mol) at 298.15 K | |
[out] | B | Second virial coefficient (dm^3/mol) |
[out] | C | Third virial coefficient (dm^6/mol^2) |
[out] | ierr | Error number (0 indicates no error) |
[out] | herr | Error message if ierr is not equal to zero |
Definition at line 412 of file Gross.cpp.
References b0, b1, b2, bCHx, c0, c1, c2, and cCHx.
Referenced by Bmix_wrapper(), GrossMethod1(), GrossMethod2(), and PressureGross().
void DensityGross | ( | const double | T, |
const double | P, | ||
const std::vector< double > & | xGrs, | ||
const double | HCH, | ||
double & | D, | ||
int & | ierr, | ||
std::string & | herr ) |
Calculate density as a function of temperature and pressure.
This is an iterative routine that calls PressureGross to find the correct state point. Generally only 6 iterations at most are required. If the iteration fails to converge, the ideal gas density and an error message are returned.
T | Temperature (K) | |
P | Pressure (kPa) | |
xGrs | Compositions of the equivalent hydrocarbon, nitrogen, and CO2 (mole fractions) | |
HCH | Molar ideal gross heating value of the hydrocarbon components (kJ/mol) at 298.15 K. Call subroutine GrossHv or GrossInputs first to obtain HCH. | |
[out] | D | Density (mol/l) |
[out] | ierr | Error number (0 indicates no error) |
[out] | herr | Error message if ierr is not equal to zero |
Definition at line 236 of file Gross.cpp.
References dPdDsave, epsilon, PressureGross(), and RGross.
Referenced by DensityGross_wrapper(), and GrossInputs().
void GrossHv | ( | const std::vector< double > & | x, |
std::vector< double > & | xGrs, | ||
double & | HN, | ||
double & | HCH ) |
Calculate ideal heating values based on composition.
The mole fractions in the mixture are required in this routine, not just xCH, xN2, and xCO2.
x | Molar compositions of all components in the mixture. The order in this array is given at the top of this code. | |
[out] | xGrs | Compositions of the equivalent hydrocarbon, nitrogen, and CO2 (mole fractions) |
[out] | HN | Molar ideal gross heating value of the mixture (kJ/mol) at 298.15 K |
[out] | HCH | Molar ideal gross heating value of the equivalent hydrocarbon (kJ/mol) at 298.15 K |
Definition at line 317 of file Gross.cpp.
Referenced by GrossHv_wrapper(), and GrossInputs().
void GrossInputs | ( | const double | T, |
const double | P, | ||
const std::vector< double > & | x, | ||
std::vector< double > & | xGrs, | ||
double & | Gr, | ||
double & | HN, | ||
double & | HCH, | ||
int & | ierr, | ||
std::string & | herr ) |
Calculate relative density and heating values based on composition.
This routine should only be used to get these two values for use as inputs to Method 1 or Method 2, and not for the relative density for any T and P. All of the mole fractions in the mixture are required in this routine, not just xCH, xN2, and xCO2.
T | Temperature (K), generally a reference temperature for relative density | |
P | Pressure (kPa), generally a reference pressure for relative density | |
x | Molar compositions of all components in the mixture. The order in this array is given at the top of this code. | |
[out] | xGrs | Compositions of the equivalent hydrocarbon, nitrogen, and CO2 (mole fractions) |
[out] | Gr | Relative density at T and P |
[out] | HN | Molar ideal gross heating value of the mixture (kJ/mol) at 298.15 K |
[out] | HCH | Molar ideal gross heating value of the equivalent hydrocarbon (kJ/mol) at 298.15 K |
[out] | ierr | Error number (0 indicates no error) |
[out] | herr | Error message if ierr is not equal to zero |
Definition at line 364 of file Gross.cpp.
References DensityGross(), GrossHv(), MolarMassGross(), and RGross.
Referenced by GrossInputs_wrapper().
void GrossMethod1 | ( | const double | Th, |
const double | Td, | ||
const double | Pd, | ||
std::vector< double > & | xGrs, | ||
const double | Gr, | ||
const double | Hv, | ||
double & | Mm, | ||
double & | HCH, | ||
double & | HN, | ||
int & | ierr, | ||
std::string & | herr ) |
Initialize variables required in the GROSS equation with Method 1 of the AGA 8 Part 1 publication.
Method 1 requires inputs of volumetric gross heating value, relative density, and mole fraction of CO2.
Th | Reference temperature for heating value (K) | |
Td | Reference temperature for density (K) | |
Pd | Reference pressure for density (kPa) | |
xGrs | Array of size 3 with the molar composition of CO2 in the 3rd position. xCH and xN2 are returned in this array. | |
Gr | Relative density at Td and Pd | |
Hv | Volumetric ideal gross heating value (MJ/m^3) at Th | |
[out] | Mm | Molar mass (g/mol) |
[out] | HCH | Molar ideal gross heating value of the equivalent hydrocarbon (kJ/mol) at 298.15 K |
[out] | HN | Molar ideal gross heating value of the mixture (kJ/mol) at 298.15 K |
[out] | ierr | Error number (0 indicates no error) |
[out] | herr | Error message if ierr is not equal to zero |
Definition at line 517 of file Gross.cpp.
References Bmix(), epsilon, mCO2, mN2, and RGross.
Referenced by GrossMethod1_wrapper().
void GrossMethod2 | ( | const double | Th, |
const double | Td, | ||
const double | Pd, | ||
std::vector< double > & | xGrs, | ||
const double | Gr, | ||
double & | Hv, | ||
double & | Mm, | ||
double & | HCH, | ||
double & | HN, | ||
int & | ierr, | ||
std::string & | herr ) |
Initialize variables required in the GROSS equation with Method 2 of the AGA 8 Part 1 publication.
Method 2 requires inputs of relative density and mole fractions of nitrogen and CO2.
Th | Reference temperature for heating value (K) | |
Td | Reference temperature for density (K) | |
Pd | Reference pressure for density (kPa) | |
xGrs | Array of size 3 with the molar composition of N2 in the 2nd position and CO2 in the 3rd position. xCH is returned in this array. | |
Gr | Relative density at Td and Pd | |
[out] | Hv | Volumetric ideal gross heating value (MJ/m^3) at Th |
[out] | Mm | Molar mass (g/mol) |
[out] | HCH | Molar ideal gross heating value of the equivalent hydrocarbon (kJ/mol) at 298.15 K |
[out] | HN | Molar ideal gross heating value of the mixture (kJ/mol) at 298.15 K |
[out] | ierr | Error number (0 indicates no error) |
[out] | herr | Error message if ierr is not equal to zero |
Definition at line 594 of file Gross.cpp.
References Bmix(), epsilon, mCO2, mN2, and RGross.
Referenced by GrossMethod2_wrapper().
void MolarMassGross | ( | const std::vector< double > & | x, |
double & | Mm ) |
Calculate molar mass of the mixture with the compositions contained in the x() input array.
x | Composition array (mole fraction) Do not send mole percents or mass fractions in the x() array, otherwise the output will be incorrect. The sum of the compositions in the x() array must be equal to one. The order of the fluids in this array is given at the top of this code. |
Mm | [out] Molar mass (g/mol) |
Definition at line 143 of file Gross.cpp.
References MMiGross, and NcGross.
Referenced by GrossInputs(), and MolarMassGross_wrapper().
void PressureGross | ( | const double | T, |
const double | D, | ||
const std::vector< double > & | xGrs, | ||
const double | HCH, | ||
double & | P, | ||
double & | Z, | ||
int & | ierr, | ||
std::string & | herr ) |
Calculate pressure as a function of temperature and density.
The derivative d(P)/d(D) is also calculated for use in the iterative DensityGross subroutine (and is only returned as a common variable).
T | Temperature (K) | |
D | Density (mol/l) | |
xGrs | Compositions of the equivalent hydrocarbon, nitrogen, and CO2 (mole fractions) | |
HCH | Molar ideal gross heating value of the equivalent hydrocarbon (kJ/mol) at 298.15 K. Call subroutine GrossHv or GrossInputs first to obtain HCH. | |
[out] | P | Pressure (kPa) |
[out] | Z | Compressibility factor |
[out] | ierr | Error number (0 indicates no error) |
[out] | herr | Error message if ierr is not equal to zero |
Definition at line 183 of file Gross.cpp.
References Bmix(), dPdDsave, and RGross.
Referenced by DensityGross(), and PressureGross_wrapper().
void SetupGross | ( | ) |
Initialize all the constants and parameters in the GROSS model.
This routine must be called once before any other routine.
Definition at line 651 of file Gross.cpp.
References b0, b1, b2, bCHx, c0, c1, c2, cCHx, mCO2, MMiGross, mN2, RGross, and xHN.
Referenced by EMSCRIPTEN_BINDINGS().
|
static |
Definition at line 130 of file Gross.cpp.
Referenced by Bmix(), and SetupGross().
|
static |
Definition at line 130 of file Gross.cpp.
Referenced by Bmix(), and SetupGross().
|
static |
Definition at line 130 of file Gross.cpp.
Referenced by Bmix(), and SetupGross().
|
static |
Definition at line 130 of file Gross.cpp.
Referenced by Bmix(), and SetupGross().
|
static |
Definition at line 131 of file Gross.cpp.
Referenced by Bmix(), and SetupGross().
|
static |
Definition at line 131 of file Gross.cpp.
Referenced by Bmix(), and SetupGross().
|
static |
Definition at line 131 of file Gross.cpp.
Referenced by Bmix(), and SetupGross().
|
static |
Definition at line 130 of file Gross.cpp.
Referenced by Bmix(), and SetupGross().
|
static |
Definition at line 128 of file Gross.cpp.
Referenced by GrossMethod1(), GrossMethod2(), and SetupGross().
|
static |
Definition at line 129 of file Gross.cpp.
Referenced by MolarMassGross(), and SetupGross().
|
static |
Definition at line 128 of file Gross.cpp.
Referenced by GrossMethod1(), GrossMethod2(), and SetupGross().
|
static |
Definition at line 126 of file Gross.cpp.
Referenced by GrossHv(), and MolarMassGross().
|
static |
Definition at line 125 of file Gross.cpp.
Referenced by DensityGross(), GrossInputs(), GrossMethod1(), GrossMethod2(), PressureGross(), and SetupGross().
|
static |
Definition at line 129 of file Gross.cpp.
Referenced by GrossHv(), and SetupGross().