TransFlow
0.1.0
A transient pipeline flow simulation library
|
The GERG04 class implements the GERG 2004 equation of state. More...
#include <gerg04.hpp>
Public Member Functions | |
GERG04 (const arma::vec &composition=Composition::defaultComposition) | |
GERG04 constructor. More... | |
virtual arma::vec | evaluate (const double pressure, const double temperature) const override |
Evaluate the GERG 2004 equation of state at the given pressure and temperature. More... | |
arma::vec | evaluateAllProperties (const double pressure, const double temperature) const |
Evaluate all available gas properties at a given pressure and temperature. More... | |
virtual double | calculateCompressibility (const double pressure, const double temperature) const override |
Calculate compressibility Z at given pressure and temperature. More... | |
virtual bool | setComposition (const arma::vec &composition, const bool force=true) override |
Set the composition. More... | |
double | findDensity (const double pressure, const double temperature) const |
Find the density of the gas at a given pressure and temperature. More... | |
double | findSpeedOfSound (const double temperature, const double density) const |
Find the soundspeed in the gas at a given temperature and density. More... | |
const arma::uvec & | indicesOfNonZeroComponents () const |
Get the indices of the non-zero components in the composition. More... | |
![]() | |
virtual | ~EquationOfStateBase () |
EquationOfStateBase (const arma::vec &composition=Composition::defaultComposition) | |
EquationOfStateBase constructor. More... | |
virtual arma::vec | evaluate (const double pressure, const double temperature, const arma::vec &composition) |
Virtual function for evaluating the EOS at a new composition. More... | |
virtual double | calculateStandardDensity () const |
double | getMolarMassOfMixture () const |
Get the molar mass of the gas. | |
const arma::vec & | getComposition () const |
Get the current composition stored in the EOS instance. | |
Private Member Functions | |
double | findDensity (const double pressure, const double temperature, double &density, double &aroidelta, double &arijdelta, double &aroideltadelta, double &arijdeltadelta) const |
Internal (private) function used in the process of evaluating the GERG 2004 equations. More... | |
void | evaluateAlpha_roi_deltas (const double tred_temperature, const double start_rhored, const double start_rhored_pow_minusOne, const double start_rhored_pow_minusTwo, double &aroidelta, double &arijdelta, double &aroideltadelta, double &arijdeltadelta) const |
Internal (private) function used in the process of evaluating the GERG 2004 equations. More... | |
void | setNonZeroComponents () |
Internal (private) function that updates the non-zero components. More... | |
void | calculateCoefficients () |
Set the pressure and temperature independent coefficients. More... | |
Private Attributes | |
const arma::uword | N = 10 |
Number of components. | |
arma::vec | X |
Composition in order CH4, N2, CO2, C2H6, C3H8, nC4H10, iC4H10, nC5H12, iC5H12, nC6H14. | |
arma::vec | Tc = {190.56, 126.19, 304.13, 305.32, 369.83, 425.13, 407.82, 469.7, 460.35, 507.82} |
Critical temperature [K] for components CH4, N2, CO2, C2H6, C3H8, nC4H10, iC4H10, nC5H12, iC5H12, nC6H14. | |
arma::vec | rhoc = {10.14*16.04, 11.18*28.01, 10.62*44.01, 6.87*30.07, 5*44.1, 3.92*58.12, 3.86*58.12, 3.21*72.15, 3.27*72.15, 2.71*86.18} |
Critical density [kg/m3] for components CH4, N2, CO2, C2H6, C3H8, nC4H10, iC4H10, nC5H12, iC5H12, nC6H14. | |
arma::uvec | m_indices |
The indices of the non-zero gas fractions (components). More... | |
arma::uvec | m_firstIndices |
The indices of the two first non-zero gas fractions (components). More... | |
arma::uvec | m_lastIndices |
The indices of the two last non-zero gas fractions (components). More... | |
double | rhored |
Inverse reducing function for mixture density \(1/\rho_r(\bar x)\). | |
double | tred |
Reducing function for mixture temperature \(T_r(\bar x)\). | |
double | Ra |
Gas constant of mixture [J/mol K]. | |
Static Private Attributes | |
static arma::mat | betav |
\(\beta_{v, ij}\) density interaction coefficient, from table A3.8 | |
static arma::mat | betat |
\(\beta_{T, ij}\) temperature coefficient, from table A3.8 | |
static arma::mat | gammav |
\(\gamma_{v, ij}\) density interaction coefficient, from table A3.8 | |
static arma::mat | gammat |
\(\gamma_{T, ij}\) temperature interaction coefficient, from table A3.8 | |
static arma::mat | noipol |
\(n_{oi, k}\), from Table A3.2 in TM15, used in the first sum of alpha^r_{oi} | |
static arma::mat | doipol |
\(d_{oi, k}\), from Table A3.2 in TM15, used in the first sum of alpha^r_{oi} | |
static arma::mat | toipol |
\(t_{oi, k}\), from Table A3.2 in TM15, used in the first sum of alpha^r_{oi} | |
static arma::mat | noiexp |
\(n_{oi, k}\), from Table A3.3 in TM15, used in the second sum of alpha^r_{oi} | |
static arma::mat | doiexp |
\(d_{oi, k}\), from Table A3.3 in TM15, used in the second sum of alpha^r_{oi} | |
static arma::mat | coiexp |
\(c_{oi, k}\), from Table A3.3 in TM15, used in the second sum of alpha^r_{oi} | |
static arma::mat | toiexp |
\(t_{oi, k}\), from Table A3.3 in TM15, used in the second sum of alpha^r_{oi} | |
static arma::mat | Fij |
\(F_{ij}\) interaction coefficient | |
static arma::cube | nijpol |
\(n_{ij, k}\), from Table A3.7 in TM15, used in the first sum of alpha^r_{ij} | |
static arma::cube | dijpol |
\(d_{ij, k}\), from Table A3.7 in TM15, used in the first sum of alpha^r_{ij} | |
static arma::cube | tijpol |
\(t_{ij, k}\), from Table A3.7 in TM15, used in the first sum of alpha^r_{ij} | |
static arma::cube | nijexp |
\(n_{ij, k}\), from Table A3.7 in TM15, used in the second sum of alpha^r_{ij} | |
static arma::cube | dijexp |
\(d_{ij, k}\), from Table A3.7 in TM15, used in the second sum of alpha^r_{ij} | |
static arma::cube | tijexp |
\(t_{ij, k}\), from Table A3.7 in TM15, used in the second sum of alpha^r_{ij} | |
static arma::cube | nuijexp |
\(\nu_{ij, k}\), from Table A3.7 in TM15, used in the second sum of alpha^r_{ij} | |
static arma::cube | epijexp |
\(\epsilon_{ij, k}\), from Table A3.7 in TM15, used in the second sum of alpha^r_{ij} | |
static arma::cube | beijexp |
\(\beta_{ij, k}\), from Table A3.7 in TM15, used in the second sum of alpha^r_{ij} | |
static arma::cube | gaijexp |
\(\gamma_{ij, k}\), from Table A3.7 in TM15, used in the second sum of alpha^r_{ij} | |
static arma::mat | noik |
\(n^o_{oi, k}\), from Table A3.1 in TM15, used in alpha^o_{oi} | |
static arma::mat | voik |
\(n^o_{oi, k}\), from Table A3.1 in TM15, used in alpha^o_{oi} | |
static arma::cube | nijpol_times_tijpol |
\(n_{ij, k} \times t_{ij, k}\) (GERG04::nijpol x GERG04::tijpol) | |
static arma::cube | nijpol_times_tijpol_times_tijpol_minus_one |
\((n_{ij, k} \times t_{ij, k}) \times (t_{ij, k} - 1)\) ((GERG04::nijpol x GERG04::tijpol) x (GERG04::tijpol - 1.0)) | |
static arma::cube | nijexp_times_tijexp |
\(n_{ij, k} \times t_{ij, k}\) (GERG04::nijexp x GERG04::tijexp) | |
static arma::cube | nijexp_times_tijexp_times_tijexp_minus_one |
\((n_{ij, k} \times t_{ij, k}) \times (t_{ij, k} - 1)\) ((GERG04::nijpol x GERG04::tijpol) x (GERG04::tijpol - 1.0)) | |
static arma::cube | nijpol_times_dijpol |
\(n_{ij, k} \times d_{ij, k}\) (GERG04::nijpol x GERG04::dijpol) | |
static arma::cube | nijpol_times_dijpol_times_tijpol |
\(n_{ij, k} \times d_{ij, k} \times t_{ij, k}\) (GERG04::nijpol x GERG04::dijpol x GERG04::tijpol) | |
static arma::cube | nijpol_times_dijpol_times_dijpol_minus_one |
\(n_{ij, k} \times d_{ij, k} \times(d_{ij, k} - 1) \) (GERG04::nijpol x GERG04::dijpol x (GERG04::dijpol - 1.0)) | |
Additional Inherited Members | |
![]() | |
arma::vec | m_molarMass = { 16.04, 30.07, 44.1, 58.12, 58.12, 72.15, 72.15, 86.18, 28.13, 44.01} |
The molar mass [g/mol] of the different gas components, in order C1, C2, C3, iC4, nC4, iC5, nC5, C6, N2, CO2. | |
arma::vec::fixed< 10 > | m_composition = arma::vec(10) |
The composition of the gas as fractions, in order C1, C2, C3, iC4, nC4, iC5, nC5, C6, N2, CO2. | |
double | m_molarMassOfMixture |
The molar mass of the gas mixture [g/mol]. | |
double | m_density = 0 |
Cache density for optimization [kg/m3]. | |
The GERG04 class implements the GERG 2004 equation of state.
This is a higly accurate, but extremely complex equation of state. It has explicit forms for a lot of properties like heat capacity etc., which are utilized where possible.
More info:
|
explicit |
GERG04 constructor.
Initializes the coefficients that only depend on composition.
composition | Gas composition in arma::vec, in the order C1, C2, C3, iC4, nC4, iC5, nC5, C6, N2, CO2. |
|
private |
Set the pressure and temperature independent coefficients.
This calculates and sets the pressure and temperature independent factors GERG04::rhored and GERG04::tred, which are stored for efficient' computation.
|
overridevirtual |
Calculate compressibility Z at given pressure and temperature.
pressure | Gas pressure [Pa]. |
temperature | Gas temperature [K]. |
Implements EquationOfStateBase.
|
overridevirtual |
Evaluate the GERG 2004 equation of state at the given pressure and temperature.
This is a wrapper around evaluateAllProperties(), which selects the wanted properties from that function. This could perhaps be optimized a bit, since some of the calculations are not required. But the brunt of the cpu time is spent in findDensity() anyway, so there probably isn't that much to save.
pressure | Gas pressure [Pa] |
temperature | Gas temperature [K] |
Implements EquationOfStateBase.
arma::vec GERG04::evaluateAllProperties | ( | const double | pressure, |
const double | temperature | ||
) | const |
Evaluate all available gas properties at a given pressure and temperature.
We have implemented 15 of the explicit equations for different properties given in the GERG 2004 documentation.
The method returns an arma::vec containing:
pressure | Gas pressure [Pa]. |
temperature | Gas temperature [K]. |
|
private |
Internal (private) function used in the process of evaluating the GERG 2004 equations.
tred_temperature | Inverse reduced mixture temperature. |
start_rhored | Reduced mixture density. |
start_rhored_pow_minusOne | pow(reduced mixture density, -1) |
start_rhored_pow_minusTwo | pow(reduced mixture density, -2) |
aroidelta | Output argument – left sum in eq. (7.21b) in TM15 (also appears in other equations). |
arijdelta | Output argument – the right (double) sum in eq. (7.21b) in TM15 (also appears in other equations). |
aroideltadelta | Output argument – the left sum in eq. (7.21c) in TM15 (also appears in other equations). |
arijdeltadelta | Output argument – the right (double) sum in eq. (7.21c) in TM15 (also appears in other equations). |
double GERG04::findDensity | ( | const double | pressure, |
const double | temperature | ||
) | const |
Find the density of the gas at a given pressure and temperature.
pressure | Gas pressure [Pa]. |
temperature | Gas temperature [K]. |
|
private |
Internal (private) function used in the process of evaluating the GERG 2004 equations.
Uses Newton-Raphson to find the density, so will be pretty cpu heavy (depending on the starting point).
pressure | Gas pressure [P]. |
temperature | Gas Temperature [K]. |
density | Gas density [kg/m3]. |
aroidelta | Output argument - left sum in eq. (7.21b) in TM15 (also appears in other equations). |
arijdelta | Output argument - the right (double) sum in eq. (7.21b) in TM15 (also appears in other equations). |
aroideltadelta | Output argument - the left sum in eq. (7.21c) in TM15 (also appears in other equations). |
arijdeltadelta | Output argument - the right (double) sum in eq. (7.21c) in TM15 (also appears in other equations). |
double GERG04::findSpeedOfSound | ( | const double | temperature, |
const double | density | ||
) | const |
Find the soundspeed in the gas at a given temperature and density.
temperature | Gas temperature [K]. |
density | Gas density [kg/m3] |
|
inline |
Get the indices of the non-zero components in the composition.
|
overridevirtual |
Set the composition.
This calls EquationOfStateBase::setComposition(), updates the non-zero component indices GERG04::m_indices, and calculates the inverse reducing function for mixture density GERG04::rhored and the reducing function for mixture temperature GERG04::tred.
composition | New gas composition. |
force | If the composition should be changed even if it's within machine precision of the previous composition. |
Reimplemented from EquationOfStateBase.
|
private |
Internal (private) function that updates the non-zero components.
This function updates GERG04::m_indices, GERG04::m_firstIndices, and GERG04::m_lastIndices according to the current composition stored in GERG04::X.
|
private |
The indices of the two first non-zero gas fractions (components).
|
private |
The indices of the non-zero gas fractions (components).
|
private |
The indices of the two last non-zero gas fractions (components).