TransFlow  0.1.0
A transient pipeline flow simulation library
gerg04.hpp
1 #pragma once
2 
3 #include <armadillo>
4 #include <string>
5 
6 #include "equationofstate/equationofstatebase.hpp"
7 
23 {
24 public:
32  explicit GERG04(const arma::vec& composition = Composition::defaultComposition);
33 
47  virtual arma::vec evaluate(const double pressure, const double temperature) const override;
48 
80  arma::vec evaluateAllProperties(const double pressure, const double temperature) const;
81 
88  virtual double calculateCompressibility(const double pressure, const double temperature) const override;
89 
102  virtual bool setComposition(const arma::vec& composition, const bool force = true) override;
103 
110  double findDensity(const double pressure, const double temperature) const;
111 
118  double findSpeedOfSound(const double temperature, const double density) const;
119 
120 // void useBadHeatCapacities(bool useBadHeatCapacities);
121 
122 // arma::vec getOutput() const;
123 
133  const arma::uvec& indicesOfNonZeroComponents() const { return m_indices; }
134 
135 private:
151  double findDensity(
152  const double pressure,
153  const double temperature,
154  double& density, // output
155  double& aroidelta, // output
156  double& arijdelta, // output
157  double& aroideltadelta, // output
158  double& arijdeltadelta // output
159  ) const;
160 
173  const double tred_temperature,
174  const double start_rhored,
175  const double start_rhored_pow_minusOne,
176  const double start_rhored_pow_minusTwo,
177  double& aroidelta, // output
178  double& arijdelta, // output
179  double& aroideltadelta, // output
180  double& arijdeltadelta // output
181  ) const;
182 
190  void setNonZeroComponents();
191 
199  void calculateCoefficients();
200 
201  const arma::uword N = 10;
202  arma::vec X;
203 
205  arma::vec Tc = {190.56, 126.19, 304.13, 305.32, 369.83, 425.13, 407.82, 469.7, 460.35, 507.82};
207  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};
208  // ch4, n2, c02, c2h6, c3h8, nc4h10, ic4h10, nc5h12, ic5h12 nc6h14
209 
217  arma::uvec m_indices;
218 
226  arma::uvec m_firstIndices;
227 
235  arma::uvec m_lastIndices;
236 
237  static arma::mat betav;
238  static arma::mat betat;
239  static arma::mat gammav;
240  static arma::mat gammat;
241 
242  // Kpol coefficients - used in the first sum in alpha^r_{oi} and derivatives
243  static arma::mat noipol;
244  static arma::mat doipol;
245  static arma::mat toipol;
246 
247  // Kexp coefficient - used in the second sum in alpha^r_{oi} and derivatives
248  static arma::mat noiexp;
249  static arma::mat doiexp;
250  static arma::mat coiexp;
251  static arma::mat toiexp;
252 
253  static arma::mat Fij;
254 
255  static arma::cube nijpol;
256  static arma::cube dijpol;
257  static arma::cube tijpol;
258 
259  static arma::cube nijexp;
260  static arma::cube dijexp;
261  static arma::cube tijexp;
262 
263  static arma::cube nuijexp;
264  static arma::cube epijexp;
265  static arma::cube beijexp;
266  static arma::cube gaijexp;
267 
268  // other coefficients
269  static arma::mat noik;
270  static arma::mat voik;
271 
272  // constant terms
273  static arma::cube nijpol_times_tijpol;
275  static arma::cube nijexp_times_tijexp;
277  static arma::cube nijpol_times_dijpol;
280 
281  double rhored;
282  double tred;
283 
284  double Ra;
285 };
GERG04::doiexp
static arma::mat doiexp
, from Table A3.3 in TM15, used in the second sum of alpha^r_{oi}
Definition: gerg04.hpp:249
GERG04::nijpol_times_tijpol
static arma::cube nijpol_times_tijpol
(GERG04::nijpol x GERG04::tijpol)
Definition: gerg04.hpp:273
GERG04::nijpol_times_dijpol_times_dijpol_minus_one
static arma::cube nijpol_times_dijpol_times_dijpol_minus_one
(GERG04::nijpol x GERG04::dijpol x (GERG04::dijpol - 1.0))
Definition: gerg04.hpp:279
GERG04::m_firstIndices
arma::uvec m_firstIndices
The indices of the two first non-zero gas fractions (components).
Definition: gerg04.hpp:226
GERG04::nijexp_times_tijexp
static arma::cube nijexp_times_tijexp
(GERG04::nijexp x GERG04::tijexp)
Definition: gerg04.hpp:275
GERG04::noik
static arma::mat noik
, from Table A3.1 in TM15, used in alpha^o_{oi}
Definition: gerg04.hpp:269
GERG04::Tc
arma::vec Tc
Critical temperature [K] for components CH4, N2, CO2, C2H6, C3H8, nC4H10, iC4H10, nC5H12,...
Definition: gerg04.hpp:205
GERG04::Fij
static arma::mat Fij
interaction coefficient
Definition: gerg04.hpp:253
GERG04::doipol
static arma::mat doipol
, from Table A3.2 in TM15, used in the first sum of alpha^r_{oi}
Definition: gerg04.hpp:244
GERG04::noiexp
static arma::mat noiexp
, from Table A3.3 in TM15, used in the second sum of alpha^r_{oi}
Definition: gerg04.hpp:248
GERG04::findDensity
double findDensity(const double pressure, const double temperature) const
Find the density of the gas at a given pressure and temperature.
GERG04::voik
static arma::mat voik
, from Table A3.1 in TM15, used in alpha^o_{oi}
Definition: gerg04.hpp:270
Composition::defaultComposition
static const Composition defaultComposition
Default composition.
Definition: composition.hpp:81
GERG04::beijexp
static arma::cube beijexp
, from Table A3.7 in TM15, used in the second sum of alpha^r_{ij}
Definition: gerg04.hpp:265
GERG04::nijpol
static arma::cube nijpol
, from Table A3.7 in TM15, used in the first sum of alpha^r_{ij}
Definition: gerg04.hpp:255
GERG04::nuijexp
static arma::cube nuijexp
, from Table A3.7 in TM15, used in the second sum of alpha^r_{ij}
Definition: gerg04.hpp:263
GERG04::toiexp
static arma::mat toiexp
, from Table A3.3 in TM15, used in the second sum of alpha^r_{oi}
Definition: gerg04.hpp:251
GERG04::coiexp
static arma::mat coiexp
, from Table A3.3 in TM15, used in the second sum of alpha^r_{oi}
Definition: gerg04.hpp:250
GERG04::betat
static arma::mat betat
temperature coefficient, from table A3.8
Definition: gerg04.hpp:238
GERG04::gaijexp
static arma::cube gaijexp
, from Table A3.7 in TM15, used in the second sum of alpha^r_{ij}
Definition: gerg04.hpp:266
GERG04::calculateCoefficients
void calculateCoefficients()
Set the pressure and temperature independent coefficients.
GERG04::rhored
double rhored
Inverse reducing function for mixture density .
Definition: gerg04.hpp:281
GERG04::tijexp
static arma::cube tijexp
, from Table A3.7 in TM15, used in the second sum of alpha^r_{ij}
Definition: gerg04.hpp:261
GERG04::toipol
static arma::mat toipol
, from Table A3.2 in TM15, used in the first sum of alpha^r_{oi}
Definition: gerg04.hpp:245
GERG04
The GERG04 class implements the GERG 2004 equation of state.
Definition: gerg04.hpp:22
GERG04::GERG04
GERG04(const arma::vec &composition=Composition::defaultComposition)
GERG04 constructor.
GERG04::m_indices
arma::uvec m_indices
The indices of the non-zero gas fractions (components).
Definition: gerg04.hpp:217
GERG04::evaluate
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.
GERG04::evaluateAlpha_roi_deltas
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.
GERG04::m_lastIndices
arma::uvec m_lastIndices
The indices of the two last non-zero gas fractions (components).
Definition: gerg04.hpp:235
GERG04::setNonZeroComponents
void setNonZeroComponents()
Internal (private) function that updates the non-zero components.
EquationOfStateBase
The EquationOfStateBase is an abstract class, the base class for different equations of state.
Definition: equationofstatebase.hpp:20
GERG04::dijpol
static arma::cube dijpol
, from Table A3.7 in TM15, used in the first sum of alpha^r_{ij}
Definition: gerg04.hpp:256
GERG04::calculateCompressibility
virtual double calculateCompressibility(const double pressure, const double temperature) const override
Calculate compressibility Z at given pressure and temperature.
GERG04::epijexp
static arma::cube epijexp
, from Table A3.7 in TM15, used in the second sum of alpha^r_{ij}
Definition: gerg04.hpp:264
GERG04::nijexp_times_tijexp_times_tijexp_minus_one
static arma::cube nijexp_times_tijexp_times_tijexp_minus_one
((GERG04::nijpol x GERG04::tijpol) x (GERG04::tijpol - 1.0))
Definition: gerg04.hpp:276
GERG04::Ra
double Ra
Gas constant of mixture [J/mol K].
Definition: gerg04.hpp:284
GERG04::nijexp
static arma::cube nijexp
, from Table A3.7 in TM15, used in the second sum of alpha^r_{ij}
Definition: gerg04.hpp:259
GERG04::N
const arma::uword N
Number of components.
Definition: gerg04.hpp:201
GERG04::tred
double tred
Reducing function for mixture temperature .
Definition: gerg04.hpp:282
GERG04::X
arma::vec X
Composition in order CH4, N2, CO2, C2H6, C3H8, nC4H10, iC4H10, nC5H12, iC5H12, nC6H14.
Definition: gerg04.hpp:202
GERG04::indicesOfNonZeroComponents
const arma::uvec & indicesOfNonZeroComponents() const
Get the indices of the non-zero components in the composition.
Definition: gerg04.hpp:133
GERG04::rhoc
arma::vec rhoc
Critical density [kg/m3] for components CH4, N2, CO2, C2H6, C3H8, nC4H10, iC4H10, nC5H12,...
Definition: gerg04.hpp:207
GERG04::tijpol
static arma::cube tijpol
, from Table A3.7 in TM15, used in the first sum of alpha^r_{ij}
Definition: gerg04.hpp:257
GERG04::noipol
static arma::mat noipol
, from Table A3.2 in TM15, used in the first sum of alpha^r_{oi}
Definition: gerg04.hpp:243
GERG04::nijpol_times_tijpol_times_tijpol_minus_one
static arma::cube nijpol_times_tijpol_times_tijpol_minus_one
((GERG04::nijpol x GERG04::tijpol) x (GERG04::tijpol - 1.0))
Definition: gerg04.hpp:274
GERG04::betav
static arma::mat betav
density interaction coefficient, from table A3.8
Definition: gerg04.hpp:237
GERG04::findSpeedOfSound
double findSpeedOfSound(const double temperature, const double density) const
Find the soundspeed in the gas at a given temperature and density.
GERG04::dijexp
static arma::cube dijexp
, from Table A3.7 in TM15, used in the second sum of alpha^r_{ij}
Definition: gerg04.hpp:260
GERG04::setComposition
virtual bool setComposition(const arma::vec &composition, const bool force=true) override
Set the composition.
GERG04::nijpol_times_dijpol_times_tijpol
static arma::cube nijpol_times_dijpol_times_tijpol
(GERG04::nijpol x GERG04::dijpol x GERG04::tijpol)
Definition: gerg04.hpp:278
GERG04::evaluateAllProperties
arma::vec evaluateAllProperties(const double pressure, const double temperature) const
Evaluate all available gas properties at a given pressure and temperature.
GERG04::gammav
static arma::mat gammav
density interaction coefficient, from table A3.8
Definition: gerg04.hpp:239
GERG04::gammat
static arma::mat gammat
temperature interaction coefficient, from table A3.8
Definition: gerg04.hpp:240
GERG04::nijpol_times_dijpol
static arma::cube nijpol_times_dijpol
(GERG04::nijpol x GERG04::dijpol)
Definition: gerg04.hpp:277