CoolProp
ReducingFunctions.h
1 
7 #ifndef MIXTURE_BINARY_PAIRS_H
8 #define MIXTURE_BINARY_PAIRS_H
9 
10 #include <vector>
11 #include "CoolPropFluid.h"
12 #include "crossplatform_shared_ptr.h"
13 
14 namespace CoolProp{
15 
16 typedef std::vector<std::vector<CoolPropDbl> > STLMatrix;
17 
20  };
21 
22 std::string get_reducing_function_name(const std::string &CAS1, const std::string &CAS2);
23 
30 {
31 protected:
32  std::size_t N;
33 public:
34  ReducingFunction():N(0){};
35  virtual ~ReducingFunction(){};
36 
37  virtual ReducingFunction *copy() = 0;
38 
39  virtual void set_binary_interaction_double(const std::size_t i, const std::size_t j, const std::string &parameter, double value) = 0;
40 
41  virtual double get_binary_interaction_double(const std::size_t i, const std::size_t j, const std::string &parameter) const = 0;
42 
44  static shared_ptr<ReducingFunction> factory(const std::vector<CoolPropFluid*> &components, STLMatrix &F);
45 
47  virtual CoolPropDbl Tr(const std::vector<CoolPropDbl> &x) const = 0;
49  virtual CoolPropDbl dTrdxi__constxj(const std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag) const = 0;
51  virtual CoolPropDbl rhormolar(const std::vector<CoolPropDbl> &x) const = 0;
53  virtual CoolPropDbl drhormolardxi__constxj(const std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag) const = 0;
54  virtual CoolPropDbl dTr_dgammaT(const std::vector<CoolPropDbl> &x) const{throw CoolProp::NotImplementedError("dTr_dgammaT is not implemented for this backend"); }
55  virtual CoolPropDbl dTr_dbetaT(const std::vector<CoolPropDbl> &x) const{throw CoolProp::NotImplementedError("dTr_dbetaT is not implemented for this backend"); }
56  virtual CoolPropDbl drhormolar_dgammaV(const std::vector<CoolPropDbl> &x) const{throw CoolProp::NotImplementedError("drhormolar_dgammaV is not implemented for this backend"); }
57  virtual CoolPropDbl drhormolar_dbetaV(const std::vector<CoolPropDbl> &x) const{throw CoolProp::NotImplementedError("drhormolar_dbetaV is not implemented for this backend"); }
58  virtual CoolPropDbl d2Tr_dxidgammaT(const std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag) const { throw CoolProp::NotImplementedError("d2Tr_dxidgammaT is not implemented for this backend"); }
59  virtual CoolPropDbl d2Tr_dxidbetaT(const std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag) const { throw CoolProp::NotImplementedError("d2Tr_dxidbetaT is not implemented for this backend"); }
60  virtual CoolPropDbl d2rhormolar_dxidgammaV(const std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag) const { throw CoolProp::NotImplementedError("d2rhormolar_dxidgammaV is not implemented for this backend"); }
61  virtual CoolPropDbl d2rhormolar_dxidbetaV(const std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag) const { throw CoolProp::NotImplementedError("d2rhormolar_dxidbetaV is not implemented for this backend"); }
62 
63 
64  virtual CoolPropDbl d2rhormolardxi2__constxj(const std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag) const = 0;
65  virtual CoolPropDbl d2rhormolardxidxj(const std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, x_N_dependency_flag xN_flag) const = 0;
66  virtual CoolPropDbl d3rhormolardxidxjdxk(const std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, std::size_t k, x_N_dependency_flag xN_flag) const = 0;
67  virtual CoolPropDbl d2Trdxi2__constxj(const std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag) const = 0;
68  virtual CoolPropDbl d2Trdxidxj(const std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, x_N_dependency_flag xN_flag) const = 0;
69  virtual CoolPropDbl d3Trdxidxjdxk(const std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, std::size_t k, x_N_dependency_flag xN_flag) const = 0;
70 
82  virtual CoolPropDbl d_ndTrdni_dxj__constxi(const std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, x_N_dependency_flag xN_flag) const;
83 
84  virtual CoolPropDbl d2_ndTrdni_dxj_dxk__constxi(const std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, std::size_t k, x_N_dependency_flag xN_flag) const;
85 
86 
100  virtual CoolPropDbl d_ndrhorbardni_dxj__constxi(const std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, x_N_dependency_flag xN_flag) const;
101 
102  virtual CoolPropDbl d2_ndrhorbardni_dxj_dxk__constxi(const std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, std::size_t k, x_N_dependency_flag xN_flag) const;
103 
104  virtual CoolPropDbl ndrhorbardni__constnj(const std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag) const;
105  virtual CoolPropDbl ndTrdni__constnj(const std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag) const;
106  virtual CoolPropDbl PSI_rho(const std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag) const;
107  virtual CoolPropDbl d_PSI_rho_dxj(const std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, x_N_dependency_flag xN_flag) const;
108  virtual CoolPropDbl d2_PSI_rho_dxj_dxk(const std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, std::size_t k, x_N_dependency_flag xN_flag) const;
109  virtual CoolPropDbl PSI_T(const std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag) const;
110  virtual CoolPropDbl d_PSI_T_dxj(const std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, x_N_dependency_flag xN_flag) const;
111  virtual CoolPropDbl d2_PSI_T_dxj_dxk(const std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, std::size_t k, x_N_dependency_flag xN_flag) const;
112 };
113 
120 {
121 private:
122  GERG2008ReducingFunction(const GERG2008ReducingFunction& that); // No copying
123 protected:
124  STLMatrix v_c;
125  STLMatrix T_c;
126  STLMatrix beta_v;
127  STLMatrix gamma_v;
128  STLMatrix beta_T;
129  STLMatrix gamma_T;
130  std::vector<CoolPropDbl> Yc_T;
131  std::vector<CoolPropDbl> Yc_v;
132  std::vector<CoolPropFluid> pFluids;
133 
134 public:
135  GERG2008ReducingFunction(const std::vector<CoolPropFluid> &pFluids, const STLMatrix &beta_v, const STLMatrix &gamma_v, STLMatrix beta_T, const STLMatrix &gamma_T)
136  {
137  this->pFluids = pFluids;
138  this->beta_v = beta_v;
139  this->gamma_v = gamma_v;
140  this->beta_T = beta_T;
141  this->gamma_T = gamma_T;
142  this->N = pFluids.size();
143  T_c.resize(N,std::vector<CoolPropDbl>(N,0));
144  v_c.resize(N,std::vector<CoolPropDbl>(N,0));
145  Yc_T.resize(N);
146  Yc_v.resize(N);
147  for (std::size_t i = 0; i < N; ++i)
148  {
149  for (std::size_t j = 0; j < N; j++)
150  {
151  T_c[i][j] = sqrt(pFluids[i].EOS().reduce.T*pFluids[j].EOS().reduce.T);
152  v_c[i][j] = 1.0/8.0*pow(pow(pFluids[i].EOS().reduce.rhomolar, -1.0/3.0)+pow(pFluids[j].EOS().reduce.rhomolar, -1.0/3.0),3);
153  }
154  Yc_T[i] = pFluids[i].EOS().reduce.T;
155  Yc_v[i] = 1/pFluids[i].EOS().reduce.rhomolar;
156  }
157  };
158 
159  ReducingFunction * copy(){
160  return new GERG2008ReducingFunction(pFluids, beta_v, gamma_v, beta_T, gamma_T);
161  };
162 
165 
167  void set_binary_interaction_double(const std::size_t i, const std::size_t j, double betaT, double gammaT, double betaV, double gammaV){
168  beta_T[i][j] = betaT; beta_T[j][i] = 1/betaT;
169  gamma_T[i][j] = gammaT; gamma_T[j][i] = gammaT;
170  beta_v[i][j] = betaV; beta_v[j][i] = 1/betaV;
171  gamma_v[i][j] = gammaV; gamma_v[j][i] = gammaV;
172  }
173 
175  virtual void set_binary_interaction_double(const std::size_t i, const std::size_t j, const std::string &parameter, double value){
176  if (parameter == "betaT"){
177  beta_T[i][j] = value; beta_T[j][i] = 1/value;
178  }
179  else if (parameter == "gammaT"){
180  gamma_T[i][j] = value; gamma_T[j][i] = value;
181  }
182  else if (parameter == "betaV"){
183  beta_v[i][j] = value; beta_v[j][i] = 1/value;
184  }
185  else if (parameter == "gammaV"){
186  gamma_v[i][j] = value; gamma_v[j][i] = value;
187  }
188  else{
189  throw KeyError(format("This key [%s] is invalid to set_binary_interaction_double",parameter.c_str()));
190  }
191  }
193  virtual double get_binary_interaction_double(const std::size_t i, const std::size_t j, const std::string &parameter) const{
194  if (parameter == "betaT"){
195  return beta_T[i][j];
196  }
197  else if (parameter == "gammaT"){
198  return gamma_T[i][j];
199  }
200  else if (parameter == "betaV"){
201  return beta_v[i][j];
202  }
203  else if (parameter == "gammaV"){
204  return gamma_v[i][j];
205  }
206  else{
207  throw KeyError(format("This key [%s] is invalid to get_binary_interaction_double",parameter.c_str()));
208  }
209  }
210 
214  CoolPropDbl Tr(const std::vector<CoolPropDbl> &x) const;
215 
219  CoolPropDbl dTr_dgammaT(const std::vector<CoolPropDbl> &x) const;
220 
224  CoolPropDbl dTr_dbetaT(const std::vector<CoolPropDbl> &x) const;
225 
228  CoolPropDbl d2Tr_dxidgammaT(const std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag) const;
229 
232  CoolPropDbl d2Tr_dxidbetaT(const std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag) const;
233 
238  CoolPropDbl dTrdxi__constxj(const std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag) const;
243  CoolPropDbl d2Trdxi2__constxj(const std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag) const;
248  CoolPropDbl d2Trdxidxj(const std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, x_N_dependency_flag xN_flag) const;
253  CoolPropDbl d3Trdxidxjdxk(const std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, std::size_t k, x_N_dependency_flag xN_flag) const;
254 
259  CoolPropDbl dvrmolardxi__constxj(const std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag) const;
264  CoolPropDbl d2vrmolardxi2__constxj(const std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag) const;
269  CoolPropDbl d2vrmolardxidxj(const std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, x_N_dependency_flag xN_flag) const;
274  CoolPropDbl d3vrmolardxidxjdxk(const std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, std::size_t k, x_N_dependency_flag xN_flag) const;
279  CoolPropDbl rhormolar(const std::vector<CoolPropDbl> &x) const;
280 
284  CoolPropDbl drhormolar_dgammaV(const std::vector<CoolPropDbl> &x) const;
285 
289  CoolPropDbl drhormolar_dbetaV(const std::vector<CoolPropDbl> &x) const;
290 
293  CoolPropDbl d2vrmolar_dxidgammaV(const std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag) const;
294 
297  CoolPropDbl d2vrmolar_dxidbetaV(const std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag) const;
298 
301  CoolPropDbl d2rhormolar_dxidbetaV(const std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag) const;
302 
305  CoolPropDbl d2rhormolar_dxidgammaV(const std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag) const;
306 
314  CoolPropDbl drhormolardxi__constxj(const std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag) const;
322  CoolPropDbl d2rhormolardxi2__constxj(const std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag) const;
330  CoolPropDbl d2rhormolardxidxj(const std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, x_N_dependency_flag xN_flag) const;
334  CoolPropDbl d3rhormolardxidxjdxk(const std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, std::size_t k, x_N_dependency_flag xN_flag) const;
335 
342  CoolPropDbl Yr(const std::vector<CoolPropDbl> &x, const STLMatrix &beta, const STLMatrix &gamma, const STLMatrix &Y_c_ij, const std::vector<CoolPropDbl> &Yc) const;
343 
350  CoolPropDbl dYr_dgamma(const std::vector<CoolPropDbl> &x, const STLMatrix &beta, const STLMatrix &gamma, const STLMatrix &Y_c_ij, const std::vector<CoolPropDbl> &Yc) const;
351 
354  CoolPropDbl dYr_dbeta(const std::vector<CoolPropDbl> &x, const STLMatrix &beta, const STLMatrix &gamma, const STLMatrix &Y_c_ij, const std::vector<CoolPropDbl> &Yc) const;
355 
371  CoolPropDbl dYrdxi__constxj(const std::vector<CoolPropDbl> &x, std::size_t i, const STLMatrix &beta, const STLMatrix &gamma, const STLMatrix &Y_c_ij, const std::vector<CoolPropDbl> &Yc, x_N_dependency_flag xN_flag) const;
372 
375  CoolPropDbl d2Yrdxidgamma(const std::vector<CoolPropDbl> &x, std::size_t i, const STLMatrix &beta, const STLMatrix &gamma, const STLMatrix &Y_c_ij, const std::vector<CoolPropDbl> &Yc, x_N_dependency_flag xN_flag) const;
378  CoolPropDbl d2Yrdxidbeta(const std::vector<CoolPropDbl> &x, std::size_t i, const STLMatrix &beta, const STLMatrix &gamma, const STLMatrix &Y_c_ij, const std::vector<CoolPropDbl> &Yc, x_N_dependency_flag xN_flag) const;
379 
394  CoolPropDbl d2Yrdxi2__constxj(const std::vector<CoolPropDbl> &x, std::size_t i, const STLMatrix &beta, const STLMatrix &gamma, const STLMatrix &Y_c_ij, const std::vector<CoolPropDbl> &Yc, x_N_dependency_flag xN_flag) const;
409  CoolPropDbl d2Yrdxidxj(const std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, const STLMatrix &beta, const STLMatrix &gamma, const STLMatrix &Y_c_ij, const std::vector<CoolPropDbl> &Yc, x_N_dependency_flag xN_flag) const;
410 
414  CoolPropDbl d3Yrdxidxjdxk(const std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, std::size_t k, const STLMatrix &beta, const STLMatrix &gamma, const STLMatrix &Y_c_ij, const std::vector<CoolPropDbl> &Yc, x_N_dependency_flag xN_flag) const;
415 
422  const CoolPropDbl c_Y_ij(const std::size_t i, const std::size_t j, const STLMatrix &beta, const STLMatrix &gamma, const STLMatrix &Y_c) const;
423 
428  CoolPropDbl f_Y_ij(const std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, const STLMatrix &beta) const;
435  CoolPropDbl dfYkidxi__constxk(const std::vector<CoolPropDbl> &x, std::size_t k, std::size_t i, const STLMatrix &beta) const;
442  CoolPropDbl dfYikdxi__constxk(const std::vector<CoolPropDbl> &x, std::size_t i, std::size_t k, const STLMatrix &beta) const;
448  CoolPropDbl d2fYkidxi2__constxk(const std::vector<CoolPropDbl> &x, std::size_t k, std::size_t i, const STLMatrix &beta) const;
454  CoolPropDbl d2fYikdxi2__constxk(const std::vector<CoolPropDbl> &x, std::size_t i, std::size_t k, const STLMatrix &beta) const;
461  CoolPropDbl d2fYijdxidxj(const std::vector<CoolPropDbl> &x, std::size_t i, std::size_t k, const STLMatrix &beta) const;
462 
463  /* Third order mixed partial derivative of \f$f_{Y,ij}\f$
464  * \f[
465  * \left(\dfrac{\partial^3 f_{Y,ij}(x_i, x_j)}{\partial x_i^2\partial x_j}\right)_{j\neq i} = \dfrac{-6 \beta^{2} x_{i} x_{j}^{2} \left(\beta^{2} - 1\right)}{\beta^{8} x_{i}^{4} + 4 \beta^{6} x_{i}^{3} x_{j} + 6 \beta^{4} x_{i}^{2} x_{j}^{2} + 4 \beta^{2} x_{i} x_{j}^{3} + x_{j}^{4}}
466  * \f]
467  */
468  CoolPropDbl d3fYijdxi2dxj(const std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, const STLMatrix &beta) const;
469  /* Third order mixed partial derivative of \f$f_{Y,ij}\f$
470  * \f[
471  * \left(\dfrac{\partial^3 f_{Y,ij}(x_i, x_j)}{\partial x_i\partial x_j^2}\right)_{j\neq i} = \dfrac{6 \beta^{2} x_{i}^{2} x_{j} \left(\beta^{2} - 1\right)}{\beta^{8} x_{i}^{4} + 4 \beta^{6} x_{i}^{3} x_{j} + 6 \beta^{4} x_{i}^{2} x_{j}^{2} + 4 \beta^{2} x_{i} x_{j}^{3} + x_{j}^{4}}
472  * \f]
473  */
474  CoolPropDbl d3fYijdxidxj2(const std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, const STLMatrix &beta) const;
475  /* Third order mixed partial derivative of \f$f_{Y,ij}\f$
476  * \f[
477  * \left(\dfrac{ \partial ^ 3 f_{ Y, ki }(x_k, x_i) }{\partial x_i ^ 3}\right)_{ k\neq i } = \dfrac{ \beta_{ Y ki }^{2} x_{ k }^{3} \left(-6 \beta_{ Y ki }^{2} +6\right) }{\left(\beta_{ Y ki }^{2} x_{ k } +x_{ i }\right) ^ { 4 }}
478  * \f]
479  */
480  CoolPropDbl d3fYkidxi3__constxk(const std::vector<CoolPropDbl> &x, std::size_t k, std::size_t i, const STLMatrix &beta) const;
481  /* Third order mixed partial derivative of \f$f_{Y,ij}\f$
482  * \f[
483  * \left(\dfrac{\partial^3 f_{Y,ik}(x_i, x_k)}{\partial x_i^3}\right)_{k\neq i} = \dfrac{6 \beta_{Y ik}^{2} x_{k}^{3} \left(\beta_{Y ik}^{2} - 1\right)}{\beta_{Y ik}^{8} x_{i}^{4} + 4 \beta_{Y ik}^{6} x_{i}^{3} x_{k} + 6 \beta_{Y ik}^{4} x_{i}^{2} x_{k}^{2} + 4 \beta_{Y ik}^{2} x_{i} x_{k}^{3} + x_{k}^{4}}
484  * \f]
485  */
486  CoolPropDbl d3fYikdxi3__constxk(const std::vector<CoolPropDbl> &x, std::size_t i, std::size_t k, const STLMatrix &beta) const;
487 };
488 
495 {
496 private:
497  ConstantReducingFunction(const ConstantReducingFunction& that); // No copying
498  double T_c, rhomolar_c;
499 
500 public:
501  ConstantReducingFunction(const double T_c, const double rhomolar_c) : T_c(T_c), rhomolar_c(rhomolar_c) {};
502 
503  ReducingFunction * copy(){
504  return new ConstantReducingFunction(T_c, rhomolar_c);
505  };
506 
507  void set_binary_interaction_double(const std::size_t i, const std::size_t j, const std::string &parameter, double value){return;}
508  double get_binary_interaction_double(const std::size_t i, const std::size_t j, const std::string &parameter) const{return _HUGE; }
509 
511  CoolPropDbl Tr(const std::vector<CoolPropDbl> &x) const{ return T_c; };
513  CoolPropDbl dTrdxi__constxj(const std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag) const{ return 0; };
515  CoolPropDbl d2Trdxi2__constxj(const std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag) const{ return 0; };
517  CoolPropDbl d2Trdxidxj(const std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, x_N_dependency_flag xN_flag) const{ return 0; };
519  CoolPropDbl d3Trdxidxjdxk(const std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, std::size_t k, x_N_dependency_flag xN_flag) const{ return 0; };
520 
522  CoolPropDbl rhormolar(const std::vector<CoolPropDbl> &x) const{ return rhomolar_c; };
524  CoolPropDbl drhormolardxi__constxj(const std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag) const{ return 0; };
526  CoolPropDbl d2rhormolardxi2__constxj(const std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag) const{ return 0; };
528  CoolPropDbl d2rhormolardxidxj(const std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, x_N_dependency_flag xN_flag) const{ return 0; };
530  CoolPropDbl d3rhormolardxidxjdxk(const std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, std::size_t k, x_N_dependency_flag xN_flag) const{ return 0; };
531 
532  CoolPropDbl dTr_dgammaT(const std::vector<CoolPropDbl> &x) const{ return 0; }
533  CoolPropDbl dTr_dbetaT(const std::vector<CoolPropDbl> &x) const{ return 0; }
534  CoolPropDbl drhormolar_dgammaV(const std::vector<CoolPropDbl> &x) const{ return 0; }
535  CoolPropDbl drhormolar_dbetaV(const std::vector<CoolPropDbl> &x) const{ return 0; }
536 
537  CoolPropDbl d2Tr_dxidgammaT(const std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag) const { return 0; }
538  CoolPropDbl d2Tr_dxidbetaT(const std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag) const { return 0; }
539  CoolPropDbl d2rhormolar_dxidgammaV(const std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag) const { return 0; }
540  CoolPropDbl d2rhormolar_dxidbetaV(const std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag) const { return 0; }
541 
542  //virtual CoolPropDbl d_ndTrdni_dxj__constxi(const std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, x_N_dependency_flag xN_flag){ return 0; };
543  //virtual CoolPropDbl d2_ndTrdni_dxj_dxk__constxi(const std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, std::size_t k, x_N_dependency_flag xN_flag){ return 0; };
544  //virtual CoolPropDbl d_ndrhorbardni_dxj__constxi(const std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, x_N_dependency_flag xN_flag){ return 0; };
545  //virtual CoolPropDbl d2_ndrhorbardni_dxj_dxk__constxi(const std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, std::size_t k, x_N_dependency_flag xN_flag){ return 0; };
546  //virtual CoolPropDbl ndrhorbardni__constnj(const std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag){ return 0; };
547  //virtual CoolPropDbl ndTrdni__constnj(const std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag){ return 0; };
548 
550  virtual CoolPropDbl PSI_rho(const std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag) const{ return 1; };
551  virtual CoolPropDbl d_PSI_rho_dxj(const std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, x_N_dependency_flag xN_flag) const{ return 0; };
552  virtual CoolPropDbl d2_PSI_rho_dxj_dxk(const std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, std::size_t k, x_N_dependency_flag xN_flag) const{ return 0; };
553  virtual CoolPropDbl PSI_T(const std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag) const{ return 0; };
554  virtual CoolPropDbl d_PSI_T_dxj(const std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, x_N_dependency_flag xN_flag) const{ return 0; };
555  virtual CoolPropDbl d2_PSI_T_dxj_dxk(const std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, std::size_t k, x_N_dependency_flag xN_flag) const { return 0; };
556 
557 };
558 
583 {
584 protected:
586 public:
588  static void convert_to_GERG(std::vector<CoolPropFluid> &pFluids,
589  std::size_t i,
590  std::size_t j,
591  const Dictionary &d,
592  CoolPropDbl &beta_T,
593  CoolPropDbl &beta_v,
594  CoolPropDbl &gamma_T,
595  CoolPropDbl &gamma_v)
596  {
597  CoolPropDbl xi_ij = d.get_number("xi");
598  CoolPropDbl zeta_ij = d.get_number("zeta");
599  beta_T = 1;
600  beta_v = 1;
601  gamma_T = (pFluids[i].EOS().reduce.T + pFluids[j].EOS().reduce.T + xi_ij)/(2*sqrt(pFluids[i].EOS().reduce.T*pFluids[j].EOS().reduce.T));
602  CoolPropDbl v_i = 1/pFluids[i].EOS().reduce.rhomolar;
603  CoolPropDbl v_j = 1/pFluids[j].EOS().reduce.rhomolar;
604  CoolPropDbl one_third = 1.0/3.0;
605  gamma_v = (v_i + v_j + zeta_ij)/(0.25*pow(pow(v_i, one_third)+pow(v_j, one_third),3));
606  };
607 };
608 
609 } /* namespace CoolProp */
610 #endif
CoolPropDbl d3Trdxidxjdxk(const std::vector< CoolPropDbl > &x, std::size_t i, std::size_t j, std::size_t k, x_N_dependency_flag xN_flag) const
The third derivative of reducing temperature with respect to component i, j and k mole fractions...
Definition: ReducingFunctions.h:519
virtual CoolPropDbl PSI_rho(const std::vector< CoolPropDbl > &x, std::size_t i, x_N_dependency_flag xN_flag) const
Note: this one is one, not zero.
Definition: ReducingFunctions.h:550
CoolPropDbl Tr(const std::vector< CoolPropDbl > &x) const
The reducing temperature.
Definition: ReducingFunctions.h:511
CoolPropDbl d2Trdxidxj(const std::vector< CoolPropDbl > &x, std::size_t i, std::size_t j, x_N_dependency_flag xN_flag) const
The second derivative of reducing temperature with respect to component i and j mole fractions...
Definition: ReducingFunctions.h:517
std::vector< CoolPropFluid > pFluids
List of fluids.
Definition: ReducingFunctions.h:132
CoolPropDbl drhormolardxi__constxj(const std::vector< CoolPropDbl > &x, std::size_t i, x_N_dependency_flag xN_flag) const
Derivative of the molar reducing density with respect to component i mole fraction.
Definition: ReducingFunctions.h:524
STLMatrix v_c
from GERG-2008
Definition: ReducingFunctions.h:124
x_N is an dependent variable, calculated by
Definition: ReducingFunctions.h:19
CoolPropDbl d2rhormolardxidxj(const std::vector< CoolPropDbl > &x, std::size_t i, std::size_t j, x_N_dependency_flag xN_flag) const
Derivative of the molar reducing density with respect to component i and j mole fractions.
Definition: ReducingFunctions.h:528
STLMatrix T_c
from GERG=2008
Definition: ReducingFunctions.h:125
Abstract base class for reducing function An abstract base class for the reducing function to allow f...
Definition: ReducingFunctions.h:29
CoolPropDbl dTrdxi__constxj(const std::vector< CoolPropDbl > &x, std::size_t i, x_N_dependency_flag xN_flag) const
The derivative of reducing temperature with respect to component i mole fraction. ...
Definition: ReducingFunctions.h:513
Definition: CoolPropTools.h:63
virtual CoolPropDbl rhormolar(const std::vector< CoolPropDbl > &x) const =0
The molar reducing density.
static shared_ptr< ReducingFunction > factory(const std::vector< CoolPropFluid *> &components, STLMatrix &F)
A factory function to generate the required reducing function.
CoolPropDbl d2rhormolardxi2__constxj(const std::vector< CoolPropDbl > &x, std::size_t i, x_N_dependency_flag xN_flag) const
Derivative of the molar reducing density with respect to component i mole fraction.
Definition: ReducingFunctions.h:526
static void convert_to_GERG(std::vector< CoolPropFluid > &pFluids, std::size_t i, std::size_t j, const Dictionary &d, CoolPropDbl &beta_T, CoolPropDbl &beta_v, CoolPropDbl &gamma_T, CoolPropDbl &gamma_v)
Set the coefficients based on reducing parameters loaded from JSON.
Definition: ReducingFunctions.h:588
virtual CoolPropDbl d_ndTrdni_dxj__constxi(const std::vector< CoolPropDbl > &x, std::size_t i, std::size_t j, x_N_dependency_flag xN_flag) const
GERG 2004 Monograph equation 7.56:
Definition: ReducingFunctions.cpp:5
Definition: Exceptions.h:26
CoolPropDbl d3rhormolardxidxjdxk(const std::vector< CoolPropDbl > &x, std::size_t i, std::size_t j, std::size_t k, x_N_dependency_flag xN_flag) const
Derivative of the molar reducing density with respect to component i, j, and k mole fractions...
Definition: ReducingFunctions.h:530
STLMatrix gamma_v
from GERG-2008
Definition: ReducingFunctions.h:127
virtual CoolPropDbl d_ndrhorbardni_dxj__constxi(const std::vector< CoolPropDbl > &x, std::size_t i, std::size_t j, x_N_dependency_flag xN_flag) const
GERG 2004 Monograph equation 7.55: If the are all independent Gernert, JPCRD, 2014, A28 If : .
Definition: ReducingFunctions.cpp:55
virtual CoolPropDbl dTrdxi__constxj(const std::vector< CoolPropDbl > &x, std::size_t i, x_N_dependency_flag xN_flag) const =0
The derivative of reduced temperature with respect to component i mole fraction.
STLMatrix beta_T
from GERG-2008
Definition: ReducingFunctions.h:128
void set_binary_interaction_double(const std::size_t i, const std::size_t j, double betaT, double gammaT, double betaV, double gammaV)
Set all beta and gamma values in one shot.
Definition: ReducingFunctions.h:167
~GERG2008ReducingFunction()
Default destructor.
Definition: ReducingFunctions.h:164
virtual CoolPropDbl drhormolardxi__constxj(const std::vector< CoolPropDbl > &x, std::size_t i, x_N_dependency_flag xN_flag) const =0
Derivative of the molar reducing density with respect to component i mole fraction.
std::vector< CoolPropDbl > Yc_v
Vector of critical molar volumes for all components.
Definition: ReducingFunctions.h:131
Reducing function converter for dry air and HFC blends.
Definition: ReducingFunctions.h:582
x_N is an independent variable, and not calculated by
Definition: ReducingFunctions.h:18
virtual double get_binary_interaction_double(const std::size_t i, const std::size_t j, const std::string &parameter) const
Get a parameter.
Definition: ReducingFunctions.h:193
STLMatrix gamma_T
from GERG-2008
Definition: ReducingFunctions.h:129
CoolPropDbl rhormolar(const std::vector< CoolPropDbl > &x) const
The molar reducing density.
Definition: ReducingFunctions.h:522
std::vector< CoolPropDbl > Yc_T
Vector of critical temperatures for all components.
Definition: ReducingFunctions.h:130
The reducing function model of GERG-2008.
Definition: ReducingFunctions.h:119
x_N_dependency_flag
Definition: ReducingFunctions.h:18
This file contains flash routines in which the state is unknown, and a solver of some kind must be us...
Definition: AbstractState.h:19
virtual void set_binary_interaction_double(const std::size_t i, const std::size_t j, const std::string &parameter, double value)
Set a parameter.
Definition: ReducingFunctions.h:175
STLMatrix beta_v
from GERG-2008
Definition: ReducingFunctions.h:126
CoolPropDbl d2Trdxi2__constxj(const std::vector< CoolPropDbl > &x, std::size_t i, x_N_dependency_flag xN_flag) const
The second derivative of reducing temperature with respect to component i mole fraction.
Definition: ReducingFunctions.h:515
A constant reducing function that does not vary with composition.
Definition: ReducingFunctions.h:494
virtual CoolPropDbl Tr(const std::vector< CoolPropDbl > &x) const =0
The reduced temperature.