CoolProp
CubicBackend.h
1 /*
2 
3 The goal of this backend is to allow the Helmholtz-based structure for cubics and to replace the entire
4 multi-fluid model with a one-fluid model. The other changes are relatively trivial. The primary
5 change is to replace the core residual Helmholtz energy derivatives from HelmholtzEOSMixtureBackend
6 with the derivatives from this class.
7 
8 The core code for the Helmholtz translations is from the publication
9 "Helmholtz energy translations for common cubic equations of state for use in one-fluid and multi-fluid mixture models"
10 by Ian H. Bell and Andreas Jaeger, J. Res. NIST, 2016
11 
12 */
13 
14 #ifndef CUBICBACKEND_H_
15 #define CUBICBACKEND_H_
16 
17 #include "CoolPropTools.h"
18 #include "DataStructures.h"
19 #include "GeneralizedCubic.h"
20 #include "CubicsLibrary.h"
21 #include "Configuration.h"
22 #include "AbstractState.h"
23 #include "Backends/Helmholtz/HelmholtzEOSMixtureBackend.h"
24 #include "Exceptions.h"
25 #include <vector>
26 
27 namespace CoolProp {
28 
29 // Forward declaration for use in initialization of AbstractCubicBackend
30 class CubicResidualHelmholtz;
31 
33 protected:
34  shared_ptr<AbstractCubic> cubic;
35  std::vector<CubicLibrary::CubicsValues> components;
36 public:
37 
39  void setup(bool generate_SatL_and_SatV = true);
40 
43 
46 
48  shared_ptr<AbstractCubic> &get_cubic(){ return cubic; };
49 
50  std::vector<std::string> calc_fluid_names(void);
51 
52  bool using_mole_fractions(void){return true;};
53  bool using_mass_fractions(void){return false;};
54  bool using_volu_fractions(void){return false;};
55 
56  void set_mass_fractions(const std::vector<CoolPropDbl> &mass_fractions){throw NotImplementedError("Mass composition has not been implemented.");};
57  void set_volu_fractions(const std::vector<CoolPropDbl> &volu_fractions){throw NotImplementedError("Volume composition has not been implemented.");};
58  const std::vector<CoolPropDbl> & get_mole_fractions(void){ return this->mole_fractions; };
59 
60  const double get_fluid_constant(std::size_t i, parameters param) const{
61  switch(param){
62  case iP_critical:
63  return cubic->get_pc()[i];
64  case iT_reducing:
65  case iT_critical:
66  return cubic->get_Tc()[i];
67  case iacentric_factor: return cubic->get_acentric()[i];
68  case imolar_mass: return components[i].molemass;
69  case iT_triple: return HelmholtzEOSMixtureBackend::get_components()[i].EOS().sat_min_liquid.T; // From the base class data structure
70  case iP_triple: return HelmholtzEOSMixtureBackend::get_components()[i].EOS().sat_min_liquid.p; // From the base class data structure
71  case irhomolar_reducing:
72  case irhomolar_critical:
73  return components[i].rhomolarc;
74  default:
75  throw ValueError(format("I don't know what to do with this fluid constant: %s", get_parameter_information(param,"short").c_str()));
76  }
77  }
78 
80  CoolPropDbl calc_gas_constant(void){ return cubic->get_R_u(); };
82  SimpleState calc_reducing_state_nocache(const std::vector<CoolPropDbl> & mole_fractions)
83  {
84  SimpleState reducing;
85  reducing.T = cubic->get_Tr();
86  reducing.rhomolar = cubic->get_rhor();
87  return reducing;
88  };
89  CoolPropDbl calc_reduced_density(void) { return _rhomolar/get_cubic()->get_rhor(); };
90  CoolPropDbl calc_reciprocal_reduced_temperature(void) { return get_cubic()->get_Tr()/_T; };
91  std::vector<double> spinodal_densities();
92 
93  CoolPropDbl calc_T_critical(void){
95  return cubic->get_Tc()[0];
96  }
97  else{
99  }
100  };
101  CoolPropDbl calc_p_critical(void){
103  return cubic->get_pc()[0];
104  }
105  else{
107  }
108  };
109  CoolPropDbl calc_acentric_factor(void)
110  {
112  return cubic->get_acentric()[0];
113  }
114  else{
115  throw ValueError("acentric factor cannot be calculated for mixtures");
116  }
117  }
118  CoolPropDbl calc_rhomolar_critical(void){
120  // Curve fit from all the pure fluids in CoolProp (thanks to recommendation of A. Kazakov)
121  double v_c_Lmol = 2.14107171795*(cubic->get_Tc()[0]/cubic->get_pc()[0]*1000)+0.00773144012514; // [L/mol]
122  return 1/(v_c_Lmol/1000.0);
123  }
124  else{
126  }
127  };
128 
131  void get_linear_reducing_parameters(double &rhomolar, double &T);
132 
134  void get_critical_point_starting_values(double &delta0, double &tau0);
135 
137  void get_critical_point_search_radii(double &R_delta, double &R_tau);
138 
140  bool get_critical_is_terminated(double &delta, double &tau);
141 
142  CoolPropDbl calc_alphar_deriv_nocache(const int nTau, const int nDelta, const std::vector<CoolPropDbl> & mole_fractions, const CoolPropDbl &tau, const CoolPropDbl &delta);
143 
145  CoolPropDbl calc_pressure_nocache(CoolPropDbl T, CoolPropDbl rhomolar);
146 
148  virtual void update_DmolarT();
149 
150  virtual void update(CoolProp::input_pairs input_pair, double value1, double value2);
151 
174  void rho_Tp_cubic(CoolPropDbl T, CoolPropDbl p, int &Nsolns, double &rho0, double &rho1, double &rho2);
175 
177  CoolPropDbl solver_rho_Tp_SRK(CoolPropDbl T, CoolPropDbl p, phases phase){
178  return solver_rho_Tp(T, p);
179  };
185  CoolPropDbl solver_rho_Tp(CoolPropDbl T, CoolPropDbl p, CoolPropDbl rho_guess = -1);
186 
187  CoolPropDbl solver_rho_Tp_global(CoolPropDbl T, CoolPropDbl p, CoolPropDbl rhomax);
188 
191  TPD_state.reset(get_copy());
192  };
193 
195  void saturation(CoolProp::input_pairs inputs);
196 
197  CoolPropDbl calc_molar_mass(void);
198 
199  void set_binary_interaction_double(const std::size_t i1, const std::size_t i2, const std::string &parameter, const double value);
200  double get_binary_interaction_double(const std::size_t i1, const std::size_t i2, const std::string &parameter);
201 
202  void set_binary_interaction_double(const std::string &CAS1, const std::string &CAS2, const std::string &parameter, const double value){throw ValueError("set_binary_interaction_double not defined for AbstractCubic not defined for CAS #"); }
203  double get_binary_interaction_double(const std::string &CAS1, const std::string &CAS2, const std::string &parameter){throw ValueError("get_binary_interaction_double not defined for AbstractCubic not defined for CAS #"); };
204 
205  // Return a 1-1 copy of this class
206  virtual HelmholtzEOSMixtureBackend *get_copy(bool generate_SatL_and_SatV = true) = 0;
207 
208  // Copy the entire kij matrix from another instance in one shot
209  void copy_k(AbstractCubicBackend *donor);
210 
211  //
212  void copy_all_alpha_functions(AbstractCubicBackend *donor);
213 
216 
217  // Set the cubic alpha function's constants:
218  void set_cubic_alpha_C(const size_t i, const std::string &parameter, const double c1, const double c2, const double c3);
219 
220  // Set fluid parameter (currently the volume translation parameter)
221  void set_fluid_parameter_double(const size_t i, const std::string &parameter, const double value);
222 
223  // Get fluid parameter (currently the volume translation parameter)
224  double get_fluid_parameter_double(const size_t i, const std::string &parameter);
225 
226 };
227 
228 
230 
231 public:
232  SRKBackend(const std::vector<double> &Tc,
233  const std::vector<double> &pc,
234  const std::vector<double> &acentric,
235  double R_u,
236  bool generate_SatL_and_SatV = true) {
237  cubic.reset(new SRK(Tc, pc, acentric, R_u));
238  setup(generate_SatL_and_SatV);
239  };
240  SRKBackend(double Tc,
241  double pc,
242  double acentric,
243  double R_u,
244  bool generate_SatL_and_SatV = true) {
245  cubic.reset(new SRK(Tc, pc, acentric, R_u));
246  setup(generate_SatL_and_SatV);
247  }
248  SRKBackend(const std::vector<std::string> fluid_identifiers,
249  const double R_u = get_config_double(R_U_CODATA),
250  bool generate_SatL_and_SatV = true){
251  std::vector<double> Tc, pc, acentric;
252  N = fluid_identifiers.size();
253  components.resize(N);
254  for (std::size_t i = 0; i < fluid_identifiers.size(); ++i){
255  components[i] = CubicLibrary::get_cubic_values(fluid_identifiers[i]);
256  Tc.push_back(components[i].Tc);
257  pc.push_back(components[i].pc);
258  acentric.push_back(components[i].acentric);
259  }
260  cubic.reset(new SRK(Tc, pc, acentric, R_u));
261  setup(generate_SatL_and_SatV);
262  }
263  HelmholtzEOSMixtureBackend *get_copy(bool generate_SatL_and_SatV = true){
264  AbstractCubicBackend *ACB = new SRKBackend(cubic->get_Tc(),cubic->get_pc(),cubic->get_acentric(),cubic->get_R_u(),generate_SatL_and_SatV);
265  ACB->copy_internals(*this);
266  return static_cast<HelmholtzEOSMixtureBackend *>(ACB);
267  }
268  std::string backend_name(void) { return get_backend_string(SRK_BACKEND); }
269 };
270 
272 
273 public:
274  PengRobinsonBackend(){}; // Default constructor (make sure you know what you are doing)
275  PengRobinsonBackend(const std::vector<double> &Tc,
276  const std::vector<double> &pc,
277  const std::vector<double> &acentric,
278  double R_u,
279  bool generate_SatL_and_SatV = true) {
280  cubic.reset(new PengRobinson(Tc, pc, acentric, R_u));
281  setup(generate_SatL_and_SatV);
282  };
283  PengRobinsonBackend(double Tc,
284  double pc,
285  double acentric,
286  double R_u,
287  bool generate_SatL_and_SatV = true) {
288  cubic.reset(new PengRobinson(Tc, pc, acentric, R_u));
289  setup(generate_SatL_and_SatV);
290  };
291  PengRobinsonBackend(const std::vector<std::string> fluid_identifiers,
292  const double R_u = get_config_double(R_U_CODATA),
293  bool generate_SatL_and_SatV = true){
294  std::vector<double> Tc, pc, acentric;
295  N = fluid_identifiers.size();
296  components.resize(N);
297  for (std::size_t i = 0; i < fluid_identifiers.size(); ++i){
298  components[i] = CubicLibrary::get_cubic_values(fluid_identifiers[i]);
299  Tc.push_back(components[i].Tc);
300  pc.push_back(components[i].pc);
301  acentric.push_back(components[i].acentric);
302  }
303  cubic.reset(new PengRobinson(Tc, pc, acentric, R_u));
304  setup(generate_SatL_and_SatV);
305  };
306  HelmholtzEOSMixtureBackend * get_copy(bool generate_SatL_and_SatV = true){
307  AbstractCubicBackend * ACB = new PengRobinsonBackend(cubic->get_Tc(),cubic->get_pc(),cubic->get_acentric(),cubic->get_R_u(),generate_SatL_and_SatV);
308  ACB->copy_internals(*this);
309  return static_cast<HelmholtzEOSMixtureBackend *>(ACB);
310  }
311  std::string backend_name(void) { return get_backend_string(PR_BACKEND); }
312 };
313 
319 {
320 
321 protected:
323 public:
324  CubicResidualHelmholtz(){ ACB = NULL; };
325  CubicResidualHelmholtz(AbstractCubicBackend * ACB) : ACB(ACB) {};
326 
327  // copy assignment
329  {
330  ACB = other.ACB;
331  return *this;
332  }
333 
335  virtual HelmholtzDerivatives all(HelmholtzEOSMixtureBackend &HEOS, const std::vector<CoolPropDbl> &mole_fractions, double tau, double delta, bool cache_values = false)
336  {
338  std::vector<double> z = std::vector<double>(mole_fractions.begin(), mole_fractions.end());
339  shared_ptr<AbstractCubic> &cubic = ACB->get_cubic();
340  a.alphar = cubic->alphar(tau, delta, z, 0, 0);
341  a.dalphar_dtau = cubic->alphar(tau, delta, z, 1, 0);
342  a.dalphar_ddelta = cubic->alphar(tau, delta, z, 0, 1);
343  a.d2alphar_dtau2 = cubic->alphar(tau, delta, z, 2, 0);
344  a.d2alphar_ddelta_dtau = cubic->alphar(tau, delta, z, 1, 1);
345  a.d2alphar_ddelta2 = cubic->alphar(tau, delta, z, 0, 2);
346  a.d3alphar_dtau3 = cubic->alphar(tau, delta, z, 3, 0);
347  a.d3alphar_ddelta_dtau2 = cubic->alphar(tau, delta, z, 2, 1);
348  a.d3alphar_ddelta2_dtau = cubic->alphar(tau, delta, z, 1, 2);
349  a.d3alphar_ddelta3 = cubic->alphar(tau, delta, z, 0, 3);
350  a.d4alphar_dtau4 = cubic->alphar(tau, delta, z, 4, 0);
351  a.d4alphar_ddelta_dtau3 = cubic->alphar(tau, delta, z, 3, 1);
352  a.d4alphar_ddelta2_dtau2 = cubic->alphar(tau, delta, z, 2, 2);
353  a.d4alphar_ddelta3_dtau = cubic->alphar(tau, delta, z, 1, 3);
354  a.d4alphar_ddelta4 = cubic->alphar(tau, delta, z, 0, 4);
355  return a;
356  }
357  virtual CoolPropDbl dalphar_dxi(HelmholtzEOSMixtureBackend &HEOS, std::size_t i, x_N_dependency_flag xN_flag){
358  return ACB->get_cubic()->d_alphar_dxi(HEOS.tau(), HEOS.delta(), HEOS.get_mole_fractions_doubleref(), 0, 0, i, xN_flag==XN_INDEPENDENT);
359  }
360  virtual CoolPropDbl d2alphar_dxi_dTau(HelmholtzEOSMixtureBackend &HEOS, std::size_t i, x_N_dependency_flag xN_flag){
361  return ACB->get_cubic()->d_alphar_dxi(HEOS.tau(), HEOS.delta(), HEOS.get_mole_fractions_doubleref(), 1, 0, i, xN_flag==XN_INDEPENDENT);
362  }
363  virtual CoolPropDbl d2alphar_dxi_dDelta(HelmholtzEOSMixtureBackend &HEOS, std::size_t i, x_N_dependency_flag xN_flag){
364  return ACB->get_cubic()->d_alphar_dxi(HEOS.tau(), HEOS.delta(), HEOS.get_mole_fractions_doubleref(), 0, 1, i, xN_flag==XN_INDEPENDENT);
365  }
366  virtual CoolPropDbl d3alphar_dxi_dTau2(HelmholtzEOSMixtureBackend &HEOS, std::size_t i, x_N_dependency_flag xN_flag){
367  return ACB->get_cubic()->d_alphar_dxi(HEOS.tau(), HEOS.delta(), HEOS.get_mole_fractions_doubleref(), 2, 0, i, xN_flag==XN_INDEPENDENT);
368  }
369  virtual CoolPropDbl d3alphar_dxi_dDelta_dTau(HelmholtzEOSMixtureBackend &HEOS, std::size_t i, x_N_dependency_flag xN_flag){
370  return ACB->get_cubic()->d_alphar_dxi(HEOS.tau(), HEOS.delta(), HEOS.get_mole_fractions_doubleref(), 1, 1, i, xN_flag==XN_INDEPENDENT);
371  }
372  virtual CoolPropDbl d3alphar_dxi_dDelta2(HelmholtzEOSMixtureBackend &HEOS, std::size_t i, x_N_dependency_flag xN_flag){
373  return ACB->get_cubic()->d_alphar_dxi(HEOS.tau(), HEOS.delta(), HEOS.get_mole_fractions_doubleref(), 0, 2, i, xN_flag==XN_INDEPENDENT);
374  }
375 
376  virtual CoolPropDbl d2alphardxidxj(HelmholtzEOSMixtureBackend &HEOS, std::size_t i, std::size_t j, x_N_dependency_flag xN_flag){
377  return ACB->get_cubic()->d2_alphar_dxidxj(HEOS.tau(), HEOS.delta(), HEOS.get_mole_fractions_doubleref(), 0, 0, i, j, xN_flag==XN_INDEPENDENT);
378  }
379  virtual CoolPropDbl d3alphar_dxi_dxj_dTau(HelmholtzEOSMixtureBackend &HEOS, std::size_t i, std::size_t j, x_N_dependency_flag xN_flag){
380  return ACB->get_cubic()->d2_alphar_dxidxj(HEOS.tau(), HEOS.delta(), HEOS.get_mole_fractions_doubleref(), 1, 0, i, j, xN_flag==XN_INDEPENDENT);
381  }
382  virtual CoolPropDbl d3alphar_dxi_dxj_dDelta(HelmholtzEOSMixtureBackend &HEOS, std::size_t i, std::size_t j, x_N_dependency_flag xN_flag){
383  return ACB->get_cubic()->d2_alphar_dxidxj(HEOS.tau(), HEOS.delta(), HEOS.get_mole_fractions_doubleref(), 0, 1, i, j, xN_flag==XN_INDEPENDENT);
384  }
385 
386  virtual CoolPropDbl d4alphar_dxi_dTau3(HelmholtzEOSMixtureBackend &HEOS, std::size_t i, x_N_dependency_flag xN_flag){
387  return ACB->get_cubic()->d_alphar_dxi(HEOS.tau(), HEOS.delta(), HEOS.get_mole_fractions_doubleref(), 3, 0, i, xN_flag==XN_INDEPENDENT);
388  }
389  virtual CoolPropDbl d4alphar_dxi_dDelta2_dTau(HelmholtzEOSMixtureBackend &HEOS, std::size_t i, x_N_dependency_flag xN_flag){
390  return ACB->get_cubic()->d_alphar_dxi(HEOS.tau(), HEOS.delta(), HEOS.get_mole_fractions_doubleref(), 1, 2, i, xN_flag==XN_INDEPENDENT);
391  }
392  virtual CoolPropDbl d4alphar_dxi_dDelta_dTau2(HelmholtzEOSMixtureBackend &HEOS, std::size_t i, x_N_dependency_flag xN_flag){
393  return ACB->get_cubic()->d_alphar_dxi(HEOS.tau(), HEOS.delta(), HEOS.get_mole_fractions_doubleref(), 2, 1, i, xN_flag==XN_INDEPENDENT);
394  }
395  virtual CoolPropDbl d4alphar_dxi_dDelta3(HelmholtzEOSMixtureBackend &HEOS, std::size_t i, x_N_dependency_flag xN_flag){
396  return ACB->get_cubic()->d_alphar_dxi(HEOS.tau(), HEOS.delta(), HEOS.get_mole_fractions_doubleref(), 0, 3, i, xN_flag==XN_INDEPENDENT);
397  }
398  virtual CoolPropDbl d4alphar_dxi_dxj_dTau2(HelmholtzEOSMixtureBackend &HEOS, std::size_t i, std::size_t j, x_N_dependency_flag xN_flag){
399  return ACB->get_cubic()->d2_alphar_dxidxj(HEOS.tau(), HEOS.delta(), HEOS.get_mole_fractions_doubleref(), 2, 0, i, j, xN_flag==XN_INDEPENDENT);
400  }
401  virtual CoolPropDbl d4alphar_dxi_dxj_dDelta_dTau(HelmholtzEOSMixtureBackend &HEOS, std::size_t i, std::size_t j, x_N_dependency_flag xN_flag){
402  return ACB->get_cubic()->d2_alphar_dxidxj(HEOS.tau(), HEOS.delta(), HEOS.get_mole_fractions_doubleref(), 1, 1, i, j, xN_flag==XN_INDEPENDENT);
403  }
404  virtual CoolPropDbl d4alphar_dxi_dxj_dDelta2(HelmholtzEOSMixtureBackend &HEOS, std::size_t i, std::size_t j, x_N_dependency_flag xN_flag){
405  return ACB->get_cubic()->d2_alphar_dxidxj(HEOS.tau(), HEOS.delta(), HEOS.get_mole_fractions_doubleref(), 0, 2, i, j, xN_flag==XN_INDEPENDENT);
406  }
407  virtual CoolPropDbl d3alphardxidxjdxk(HelmholtzEOSMixtureBackend &HEOS, std::size_t i, std::size_t j, std::size_t k, x_N_dependency_flag xN_flag){
408  return ACB->get_cubic()->d3_alphar_dxidxjdxk(HEOS.tau(), HEOS.delta(), HEOS.get_mole_fractions_doubleref(), 0, 0, i, j, k, xN_flag==XN_INDEPENDENT);
409  }
410  virtual CoolPropDbl d4alphar_dxi_dxj_dxk_dTau(HelmholtzEOSMixtureBackend &HEOS, std::size_t i, std::size_t j, std::size_t k, x_N_dependency_flag xN_flag){
411  return ACB->get_cubic()->d3_alphar_dxidxjdxk(HEOS.tau(), HEOS.delta(), HEOS.get_mole_fractions_doubleref(), 1, 0, i, j, k, xN_flag==XN_INDEPENDENT);
412  }
413  virtual CoolPropDbl d4alphar_dxi_dxj_dxk_dDelta(HelmholtzEOSMixtureBackend &HEOS, std::size_t i, std::size_t j, std::size_t k, x_N_dependency_flag xN_flag){
414  return ACB->get_cubic()->d3_alphar_dxidxjdxk(HEOS.tau(), HEOS.delta(), HEOS.get_mole_fractions_doubleref(), 0, 1, i, j, k, xN_flag==XN_INDEPENDENT);
415  }
416 };
417 
418 } /* namespace CoolProp */
419 #endif /* CUBICBACKEND_H_ */
double T(void)
Return the temperature in K.
Definition: AbstractState.h:700
void set_binary_interaction_double(const std::size_t i1, const std::size_t i2, const std::string &parameter, const double value)
Set binary mixture floating point parameter.
Definition: CubicBackend.cpp:521
void get_critical_point_starting_values(double &delta0, double &tau0)
Get the the starting values for the critical point evaluation routines.
Definition: CubicBackend.cpp:135
CoolPropDbl calc_gas_constant(void)
Calculate the gas constant in J/mol/K.
Definition: CubicBackend.h:80
double rhomolar(void)
Return the molar density in mol/m^3.
Definition: AbstractState.h:702
std::string backend_name(void)
Get a string representation of the backend - for instance "HelmholtzEOSMixtureBackend" for the core m...
Definition: CubicBackend.h:268
const std::vector< CoolPropDbl > & get_mole_fractions(void)
Get the mole fractions of the fluid.
Definition: CubicBackend.h:58
void get_linear_reducing_parameters(double &rhomolar, double &T)
Get linear mole fraction weighting of the critical molar volumes and temperatures these are used in t...
Definition: CubicBackend.cpp:97
std::vector< CoolPropDbl > mole_fractions
The bulk mole fractions of the mixture.
Definition: HelmholtzEOSMixtureBackend.h:49
void set_binary_interaction_double(const std::string &CAS1, const std::string &CAS2, const std::string &parameter, const double value)
Set binary mixture floating point parameter (EXPERT USE ONLY!!!)
Definition: CubicBackend.h:202
double delta(void)
Return the reduced density ( )
Definition: AbstractState.cpp:509
CoolPropDbl calc_T_critical(void)
Using this backend, get the critical point temperature in K.
Definition: CubicBackend.h:93
Definition: CubicBackend.h:271
CoolPropDbl calc_reciprocal_reduced_temperature(void)
Using this backend, calculate the reciprocal reduced temperature (Tc/T)
Definition: CubicBackend.h:90
virtual CoolPropDbl calc_T_critical(void)
Using this backend, get the critical point temperature in K.
Definition: HelmholtzEOSMixtureBackend.cpp:1049
Temperature at the critical point.
Definition: DataStructures.h:59
Molar density used for the critical point.
Definition: DataStructures.h:57
void set_fluid_parameter_double(const size_t i, const std::string &parameter, const double value)
Set fluid parameter (currently the volume translation parameter for cubic)
Definition: CubicBackend.cpp:588
double get_config_double(configuration_keys key)
Return the value of a double configuration key.
Definition: Configuration.cpp:92
virtual void update(CoolProp::input_pairs input_pair, double value1, double value2)
The standard update function.
Definition: CubicBackend.cpp:231
phases
These are constants for the phases of the fluid.
Definition: DataStructures.h:158
phases phase(void)
Get the phase of the state.
Definition: AbstractState.h:616
Pressure at the critical point.
Definition: DataStructures.h:62
std::string backend_name(void)
Get a string representation of the backend - for instance "HelmholtzEOSMixtureBackend" for the core m...
Definition: CubicBackend.h:311
double get_fluid_parameter_double(const size_t i, const std::string &parameter)
Double fluid parameter (currently the volume translation parameter for cubic)
Definition: CubicBackend.cpp:609
virtual CoolPropDbl calc_rhomolar_critical(void)
Using this backend, get the critical point molar density in mol/m^3.
Definition: HelmholtzEOSMixtureBackend.cpp:1081
Temperature at the reducing state.
Definition: DataStructures.h:58
std::size_t N
Number of components.
Definition: HelmholtzEOSMixtureBackend.h:55
CoolPropDbl calc_molar_mass(void)
Using this backend, calculate the molar mass in kg/mol.
Definition: CubicBackend.cpp:511
double get_binary_interaction_double(const std::string &CAS1, const std::string &CAS2, const std::string &parameter)
Get binary mixture double value (EXPERT USE ONLY!!!)
Definition: CubicBackend.h:203
void set_cubic_alpha_C(const size_t i, const std::string &parameter, const double c1, const double c2, const double c3)
Set the cubic alpha function&#39;s constants:
Definition: CubicBackend.cpp:572
std::string get_parameter_information(int key, const std::string &info)
Return information about the parameter.
Definition: DataStructures.cpp:173
CoolPropDbl calc_p_critical(void)
Using this backend, get the critical point pressure in Pa.
Definition: CubicBackend.h:101
CoolPropDbl solver_rho_Tp(CoolPropDbl T, CoolPropDbl p, CoolPropDbl rho_guess=-1)
/brief Solve for rho = f(T,p)
Definition: CubicBackend.cpp:438
Definition: GeneralizedCubic.h:541
CoolPropDbl calc_rhomolar_critical(void)
Using this backend, get the critical point molar density in mol/m^3.
Definition: CubicBackend.h:118
const double get_fluid_constant(std::size_t i, parameters param) const
Get a constant for one of the fluids forming this mixture.
Definition: CubicBackend.h:60
bool get_critical_is_terminated(double &delta, double &tau)
Checking function to see if we should stop the tracing of the critical contour.
Definition: CubicBackend.cpp:124
virtual void update_DmolarT()
Update the state for DT inputs if phase is imposed. Otherwise delegate to base class.
Definition: CubicBackend.cpp:162
input_pairs
These are input pairs that can be used for the update function (in each pair, input keys are sorted a...
Definition: DataStructures.h:216
CoolPropDbl solver_rho_Tp_SRK(CoolPropDbl T, CoolPropDbl p, phases phase)
In this class, we are already doing cubic evaluation, just delegate to our function.
Definition: CubicBackend.h:177
Definition: Exceptions.h:26
This class implements all the derivatives of the Helmholtz energy (as well as composition derivatives...
Definition: CubicBackend.h:318
SimpleState calc_reducing_state_nocache(const std::vector< CoolPropDbl > &mole_fractions)
Get the reducing state to be used.
Definition: CubicBackend.h:82
std::vector< CubicLibrary::CubicsValues > components
The components that are in use.
Definition: CubicBackend.h:35
Definition: CubicBackend.h:32
shared_ptr< HelmholtzEOSMixtureBackend > TPD_state
A temporary state used for calculations of the tangent-plane-distance.
Definition: HelmholtzEOSMixtureBackend.h:29
Triple point temperature.
Definition: DataStructures.h:64
double tau(void)
Return the reciprocal of the reduced temperature ( )
Definition: AbstractState.cpp:505
Molar mass.
Definition: DataStructures.h:54
shared_ptr< AbstractCubic > & get_cubic()
Get a reference to the shared pointer managing the generalized cubic class.
Definition: CubicBackend.h:48
Molar density used for the reducing state.
Definition: DataStructures.h:56
Acentric factor.
Definition: DataStructures.h:55
std::vector< std::string > calc_fluid_names(void)
Using this backend, get a vector of fluid names.
Definition: CubicBackend.cpp:88
virtual HelmholtzDerivatives all(HelmholtzEOSMixtureBackend &HEOS, const std::vector< CoolPropDbl > &mole_fractions, double tau, double delta, bool cache_values=false)
All the derivatives of the residual Helmholtz energy w.r.t. tau and delta that do not involve composi...
Definition: CubicBackend.h:335
void update_TPD_state()
Update the state used to calculate the tangent-plane-distance.
Definition: CubicBackend.h:190
void copy_internals(AbstractCubicBackend &donor)
Copy the internals from another class into this one (kij, alpha functions, cp0 functions, etc.)
Definition: CubicBackend.cpp:557
Definition: Helmholtz.h:46
double p(void)
Return the pressure in Pa.
Definition: AbstractState.h:706
void saturation(CoolProp::input_pairs inputs)
Cubic backend flashes for PQ, and QT.
Definition: CubicBackend.cpp:366
x_N is an independent variable, and not calculated by
Definition: ReducingFunctions.h:18
double _rhomolar
Bulk values.
Definition: AbstractState.h:100
Definition: GeneralizedCubic.h:569
CoolPropDbl calc_pressure_nocache(CoolPropDbl T, CoolPropDbl rhomolar)
Calculate the pressure in most computationally efficient manner.
Definition: CubicBackend.cpp:156
Definition: HelmholtzEOSMixtureBackend.h:22
Triple point pressure.
Definition: DataStructures.h:65
void set_alpha_from_components()
Set the alpha function based on the alpha function defined in the components vector;.
Definition: CubicBackend.cpp:49
void setup(bool generate_SatL_and_SatV=true)
Set the pointer to the residual helmholtz class, etc.
Definition: CubicBackend.cpp:6
void set_alpha0_from_components()
Set the non-dimensionalized Helmholtz energy based on the fluids defined in the components vector...
Definition: CubicBackend.cpp:72
virtual CoolPropDbl calc_p_critical(void)
Using this backend, get the critical point pressure in Pa.
Definition: HelmholtzEOSMixtureBackend.cpp:1065
Definition: CubicBackend.h:229
void rho_Tp_cubic(CoolPropDbl T, CoolPropDbl p, int &Nsolns, double &rho0, double &rho1, double &rho2)
Use the cubic EOS to solve for density.
Definition: CubicBackend.cpp:268
x_N_dependency_flag
Definition: ReducingFunctions.h:18
bool is_pure_or_pseudopure
A flag for whether the substance is a pure or pseudo-pure fluid (true) or a mixture (false) ...
Definition: HelmholtzEOSMixtureBackend.h:48
void get_critical_point_search_radii(double &R_delta, double &R_tau)
Get the search radius in delta and tau for the tracer, scaled appropriately for cubic.
Definition: CubicBackend.cpp:112
This file contains flash routines in which the state is unknown, and a solver of some kind must be us...
Definition: AbstractState.h:19
double get_binary_interaction_double(const std::size_t i1, const std::size_t i2, const std::string &parameter)
Get binary mixture double value.
Definition: CubicBackend.cpp:532
CoolPropDbl calc_reduced_density(void)
Using this backend, calculate the reduced density (rho/rhoc)
Definition: CubicBackend.h:89
parameters
Define some constants that will be used throughout These are constants for the input and output para...
Definition: DataStructures.h:49
CoolPropDbl calc_acentric_factor(void)
Using this backend, calculate the acentric factor.
Definition: CubicBackend.h:109
This class contains the two primary contributions to the residual Helmholtz energy - a corresponding ...
Definition: HelmholtzEOSMixtureBackend.h:667
Definition: DataStructures.h:16