AGA8 WebAssembly
1.0
bindings for AGA8 gas properties calculations
|
Implementation of the AGA 8 Part 1 DETAIL equation of state for natural gas mixtures. More...
Go to the source code of this file.
Functions | |
static void | xTermsDetail (const std::vector< double > &x) |
static void | Alpha0Detail (const double T, const double D, const std::vector< double > &x, double a0[3]) |
Calculates the ideal gas Helmholtz energy and its derivatives with respect to T and D. | |
static void | AlpharDetail (const int itau, const int idel, const double T, const double D, double ar[4][4]) |
Calculates derivatives of the residual Helmholtz energy with respect to temperature and density. | |
double | sq (double x) |
void | MolarMassDetail (const std::vector< double > &x, double &Mm) |
Calculate molar mass of a mixture based on composition. | |
void | PressureDetail (const double T, const double D, const std::vector< double > &x, double &P, double &Z) |
Calculates pressure and compressibility factor as a function of temperature and density. | |
void | DensityDetail (const double T, const double P, const std::vector< double > &x, double &D, int &ierr, std::string &herr) |
Calculates density as a function of temperature and pressure using an iterative method. | |
void | PropertiesDetail (const double T, const double D, const std::vector< double > &x, double &P, double &Z, double &dPdD, double &d2PdD2, double &d2PdTD, double &dPdT, double &U, double &H, double &S, double &Cv, double &Cp, double &W, double &G, double &JT, double &Kappa, double &Cf) |
Calculates thermodynamic properties as a function of temperature and density. | |
void | SetupDetail () |
The following routine must be called once before any other routine. | |
Variables | |
static double | RDetail |
static const int | NcDetail = 21 |
static const int | MaxFlds = 21 |
static const int | NTerms = 58 |
static const double | epsilon = 1e-15 |
static int | fn [NTerms+1] |
static int | gn [NTerms+1] |
static int | qn [NTerms+1] |
static double | an [NTerms+1] |
static double | un [NTerms+1] |
static int | bn [NTerms+1] |
static int | kn [NTerms+1] |
static double | Bsnij2 [MaxFlds+1][MaxFlds+1][18+1] |
static double | Bs [18+1] |
static double | Csn [NTerms+1] |
static double | Fi [MaxFlds+1] |
static double | Gi [MaxFlds+1] |
static double | Qi [MaxFlds+1] |
static double | Ki25 [MaxFlds+1] |
static double | Ei25 [MaxFlds+1] |
static double | Kij5 [MaxFlds+1][MaxFlds+1] |
static double | Uij5 [MaxFlds+1][MaxFlds+1] |
static double | Gij5 [MaxFlds+1][MaxFlds+1] |
static double | Tun [NTerms+1] |
static double | Told |
static double | n0i [MaxFlds+1][7+1] |
static double | th0i [MaxFlds+1][7+1] |
static double | MMiDetail [MaxFlds+1] |
static double | K3 |
static double | xold [MaxFlds+1] |
static double | dPdDsave |
Implementation of the AGA 8 Part 1 DETAIL equation of state for natural gas mixtures.
This implementation is based on the AGA Report No. 8, Part 1 - DETAIL method for the calculation of thermodynamic properties of natural gas mixtures. The code provides routines for calculating:
The mixture compositions are specified using mole fractions for 21 components in the following order:
Definition in file Detail.cpp.
|
static |
Calculates the ideal gas Helmholtz energy and its derivatives with respect to T and D.
This function computes the ideal gas Helmholtz energy and its first and second temperature derivatives. This calculation is not required when only pressure (P) or compressibility factor (Z) is needed.
T | Temperature in Kelvin (K) |
D | Density in moles per liter (mol/l) |
x | Vector of mole fractions representing composition |
a0 | Array to store results:
|
Definition at line 550 of file Detail.cpp.
References epsilon, n0i, NcDetail, RDetail, sq(), and th0i.
Referenced by PropertiesDetail().
|
static |
Calculates derivatives of the residual Helmholtz energy with respect to temperature and density.
This function computes various derivatives of the residual Helmholtz energy based on temperature and density inputs. The xTerms subroutine must be called before this routine if x has changed.
itau | Set to 1 to calculate derivatives with respect to T [ar(1,0), ar(1,1), ar(2,0)], 0 otherwise |
idel | Currently not used, reserved for future use in specifying highest density derivative |
T | Temperature in Kelvin |
D | Density in mol/l |
ar[4][4] | Output array containing the following derivatives:
|
Definition at line 649 of file Detail.cpp.
References bn, Bs, Csn, K3, kn, NTerms, RDetail, Told, Tun, and un.
Referenced by PressureDetail(), and PropertiesDetail().
void DensityDetail | ( | const double | T, |
const double | P, | ||
const std::vector< double > & | x, | ||
double & | D, | ||
int & | ierr, | ||
std::string & | herr ) |
Calculates density as a function of temperature and pressure using an iterative method.
This function uses an iterative Newton's method that calls PressureDetail 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. No checks are made to determine the phase boundary, which would have guaranteed that the output is in the gas phase. It is up to the user to locate the phase boundary, and thus identify the phase of the T and P inputs. If the state point is 2-phase, the output density will represent a metastable state.
T | Temperature in Kelvin (K) |
P | Pressure in kiloPascals (kPa) |
x | Vector of mole fractions representing composition |
D | Density in mol/l (can be negative to use as initial guess) |
ierr | Error number (0 indicates no error) |
herr | Error message string (empty if no error) |
Definition at line 246 of file Detail.cpp.
References dPdDsave, epsilon, PressureDetail(), and RDetail.
Referenced by DensityDetail_wrapper().
void MolarMassDetail | ( | const std::vector< double > & | x, |
double & | Mm ) |
Calculate molar mass of a mixture based on composition.
This function calculates the molar mass of a mixture using the mole fractions of each component provided in the composition array.
x | Vector of mole fractions for each component in the mixture. Must sum to 1.0. Use mole fractions only (not mass fractions or mole percents). Components must be ordered according to the fluid order defined in the implementation. | |
[out] | Mm | Calculated molar mass of the mixture in g/mol |
Definition at line 158 of file Detail.cpp.
References MMiDetail, and NcDetail.
Referenced by MolarMassDetail_wrapper(), and PropertiesDetail().
void PressureDetail | ( | const double | T, |
const double | D, | ||
const std::vector< double > & | x, | ||
double & | P, | ||
double & | Z ) |
Calculates pressure and compressibility factor as a function of temperature and density.
This function computes the pressure and compressibility factor for a gas mixture using the GERG-2008 equation of state. It also calculates d(P)/d(D) which is cached for use in iterative density calculations.
T | Temperature in Kelvin (K) | |
D | Density in moles per liter (mol/l) | |
x | Vector of composition mole fractions (must sum to 1.0) | |
[out] | P | Pressure in kiloPascals (kPa) |
[out] | Z | Compressibility factor (dimensionless) |
Definition at line 196 of file Detail.cpp.
References AlpharDetail(), dPdDsave, RDetail, and xTermsDetail().
Referenced by DensityDetail(), and PressureDetail_wrapper().
void PropertiesDetail | ( | const double | T, |
const double | D, | ||
const std::vector< double > & | x, | ||
double & | P, | ||
double & | Z, | ||
double & | dPdD, | ||
double & | d2PdD2, | ||
double & | d2PdTD, | ||
double & | dPdT, | ||
double & | U, | ||
double & | H, | ||
double & | S, | ||
double & | Cv, | ||
double & | Cp, | ||
double & | W, | ||
double & | G, | ||
double & | JT, | ||
double & | Kappa, | ||
double & | Cf ) |
Calculates thermodynamic properties as a function of temperature and density.
If density is unknown, call DensityDetail first with known pressure and temperature values. Makes calls to Molarmass, Alpha0Detail, and AlpharDetail subroutines.
T | Temperature in Kelvin (K) | |
D | Density in mol/l | |
x | Vector of mole fractions representing composition | |
[out] | P | Pressure in kPa |
[out] | Z | Compressibility factor |
[out] | dPdD | First derivative of pressure with respect to density at constant temperature [kPa/(mol/l)] |
[out] | d2PdD2 | Second derivative of pressure with respect to density at constant temperature [kPa/(mol/l)^2] |
[out] | d2PdTD | Second derivative of pressure with respect to temperature and density [kPa/(mol/l)/K] |
[out] | dPdT | First derivative of pressure with respect to temperature at constant density (kPa/K) |
[out] | U | Internal energy in J/mol |
[out] | H | Enthalpy in J/mol |
[out] | S | Entropy in J/(mol-K) |
[out] | Cv | Isochoric heat capacity in J/(mol-K) |
[out] | Cp | Isobaric heat capacity in J/(mol-K) |
[out] | W | Speed of sound in m/s |
[out] | G | Gibbs energy in J/mol |
[out] | JT | Joule-Thomson coefficient in K/kPa |
[out] | Kappa | Isentropic Exponent |
[out] | Cf | Critical Flow Factor (dimensionless) |
Definition at line 350 of file Detail.cpp.
References Alpha0Detail(), AlpharDetail(), epsilon, MolarMassDetail(), RDetail, sq(), and xTermsDetail().
Referenced by PropertiesDetail_wrapper().
void SetupDetail | ( | ) |
The following routine must be called once before any other routine.
Initializes all constants and parameters for the DETAIL model equations of state
This function sets up all the necessary parameters for the AGA8 equation of state in its "DETAIL" version. It initializes:
The function also performs necessary precalculations of constants used in the equation of state calculations to optimize performance.
This implementation corresponds to the reference equations for natural gas mixtures as published in the DETAIL formulation.
Definition at line 806 of file Detail.cpp.
References an, bn, Bsnij2, Ei25, Fi, fn, Gi, Gij5, gn, Ki25, Kij5, kn, MaxFlds, MMiDetail, n0i, NTerms, Qi, qn, RDetail, th0i, Told, Uij5, un, and xold.
Referenced by EMSCRIPTEN_BINDINGS().
|
inline |
Definition at line 142 of file Detail.cpp.
Referenced by Alpha0Detail(), PropertiesDetail(), and xTermsDetail().
|
static |
Definition at line 430 of file Detail.cpp.
References an, Bs, Bsnij2, Csn, Ei25, Fi, fn, Gi, Gij5, gn, K3, Ki25, Kij5, NcDetail, Qi, qn, sq(), Uij5, un, and xold.
Referenced by PressureDetail(), and PropertiesDetail().
|
static |
Definition at line 131 of file Detail.cpp.
Referenced by SetupDetail(), and xTermsDetail().
|
static |
Definition at line 132 of file Detail.cpp.
Referenced by AlpharDetail(), and SetupDetail().
|
static |
Definition at line 133 of file Detail.cpp.
Referenced by AlpharDetail(), and xTermsDetail().
Definition at line 133 of file Detail.cpp.
Referenced by SetupDetail(), and xTermsDetail().
|
static |
Definition at line 133 of file Detail.cpp.
Referenced by AlpharDetail(), and xTermsDetail().
|
static |
Definition at line 140 of file Detail.cpp.
Referenced by DensityDetail(), DensityGERG(), DensityGross(), PressureDetail(), PressureGERG(), and PressureGross().
|
static |
Definition at line 135 of file Detail.cpp.
Referenced by SetupDetail(), and xTermsDetail().
|
static |
Definition at line 129 of file Detail.cpp.
Referenced by Alpha0Detail(), Alpha0GERG(), AlpharGERG(), DensityDetail(), DensityGERG(), DensityGross(), GrossMethod1(), GrossMethod2(), PropertiesDetail(), PropertiesGERG(), PseudoCriticalPointGERG(), ReducingParametersGERG(), and tTermsGERG().
|
static |
Definition at line 134 of file Detail.cpp.
Referenced by SetupDetail(), and xTermsDetail().
|
static |
Definition at line 130 of file Detail.cpp.
Referenced by SetupDetail(), and xTermsDetail().
|
static |
Definition at line 134 of file Detail.cpp.
Referenced by SetupDetail(), and xTermsDetail().
Definition at line 136 of file Detail.cpp.
Referenced by SetupDetail(), and xTermsDetail().
|
static |
Definition at line 130 of file Detail.cpp.
Referenced by SetupDetail(), and xTermsDetail().
|
static |
Definition at line 139 of file Detail.cpp.
Referenced by AlpharDetail(), and xTermsDetail().
|
static |
Definition at line 135 of file Detail.cpp.
Referenced by SetupDetail(), and xTermsDetail().
Definition at line 136 of file Detail.cpp.
Referenced by SetupDetail(), and xTermsDetail().
|
static |
Definition at line 132 of file Detail.cpp.
Referenced by AlpharDetail(), and SetupDetail().
|
static |
Definition at line 128 of file Detail.cpp.
Referenced by SetupDetail(), and SetupGERG().
|
static |
Definition at line 139 of file Detail.cpp.
Referenced by MolarMassDetail(), and SetupDetail().
|
static |
Definition at line 138 of file Detail.cpp.
Referenced by Alpha0Detail(), Alpha0GERG(), SetupDetail(), and SetupGERG().
|
static |
Definition at line 128 of file Detail.cpp.
Referenced by Alpha0Detail(), MolarMassDetail(), and xTermsDetail().
|
static |
Definition at line 128 of file Detail.cpp.
Referenced by AlpharDetail(), and SetupDetail().
|
static |
Definition at line 134 of file Detail.cpp.
Referenced by SetupDetail(), and xTermsDetail().
|
static |
Definition at line 130 of file Detail.cpp.
Referenced by SetupDetail(), and xTermsDetail().
|
static |
Definition at line 127 of file Detail.cpp.
Referenced by Alpha0Detail(), AlpharDetail(), DensityDetail(), PressureDetail(), PropertiesDetail(), and SetupDetail().
|
static |
Definition at line 138 of file Detail.cpp.
Referenced by Alpha0Detail(), Alpha0GERG(), SetupDetail(), and SetupGERG().
|
static |
Definition at line 137 of file Detail.cpp.
Referenced by AlpharDetail(), AlpharGERG(), ReducingParametersGERG(), SetupDetail(), and SetupGERG().
|
static |
Definition at line 137 of file Detail.cpp.
Referenced by AlpharDetail().
Definition at line 136 of file Detail.cpp.
Referenced by SetupDetail(), and xTermsDetail().
|
static |
Definition at line 131 of file Detail.cpp.
Referenced by AlpharDetail(), SetupDetail(), and xTermsDetail().
|
static |
Definition at line 139 of file Detail.cpp.
Referenced by ReducingParametersGERG(), SetupDetail(), SetupGERG(), and xTermsDetail().