CoolProp  6.6.1dev
An open-source fluid property and humid air property database
VTPRBackend.h
Go to the documentation of this file.
1 //
2 // VTPRBackend.h
3 // CoolProp
4 //
5 // Created by Ian on 7/17/16.
6 //
7 //
8 
9 #ifndef VTPRBackend_h
10 #define VTPRBackend_h
11 
12 #include "CoolPropTools.h"
13 #include "DataStructures.h"
14 #include "GeneralizedCubic.h"
15 #include "AbstractState.h"
17 #include "Exceptions.h"
18 #include <vector>
19 #include "CubicBackend.h"
20 #include "Configuration.h"
21 #include "UNIFACLibrary.h"
22 #include "UNIFAC.h"
23 #include "VTPRCubic.h"
24 
25 namespace CoolProp {
26 
28 {
29 
30  private:
31  std::vector<double> Tc, pc, omega, molemass, m_ii;
32  double R;
33  std::vector<std::string> m_fluid_names;
34 
35  public:
36  VTPRBackend(const std::vector<std::string> fluid_identifiers, const std::vector<double>& Tc, const std::vector<double>& pc,
37  const std::vector<double>& acentric, double R_u, bool generate_SatL_and_SatV = true) {
39  cubic.reset(new VTPRCubic(Tc, pc, acentric, R_u, lib));
40  setup(fluid_identifiers, generate_SatL_and_SatV);
41  };
42  VTPRBackend(const std::vector<std::string> fluid_identifiers, const double R_u = get_config_double(R_U_CODATA),
43  bool generate_SatL_and_SatV = true) {
44  std::vector<double> Tc, pc, acentric;
45  N = fluid_identifiers.size();
46  components.resize(N);
47  // Extract data from the UNIFAC parameter library
49  for (std::size_t i = 0; i < fluid_identifiers.size(); ++i) {
50  UNIFACLibrary::Component comp = lib.get_component("name", fluid_identifiers[i]);
51  Tc.push_back(comp.Tc); // [K]
52  pc.push_back(comp.pc); // [Pa]
53  acentric.push_back(comp.acentric); // [-]
54  molemass.push_back(comp.molemass); // [kg/mol]
55  }
56  cubic.reset(new VTPRCubic(Tc, pc, acentric, R_u, lib));
57  setup(fluid_identifiers, generate_SatL_and_SatV);
58  };
59 
60  std::string backend_name(void) {
62  }
63 
64  HelmholtzEOSMixtureBackend* get_copy(bool generate_SatL_and_SatV = true) {
66  new VTPRBackend(calc_fluid_names(), cubic->get_Tc(), cubic->get_pc(), cubic->get_acentric(), cubic->get_R_u(), generate_SatL_and_SatV);
67  ACB->copy_k(this);
68  ACB->copy_all_alpha_functions(this);
69  return static_cast<HelmholtzEOSMixtureBackend*>(ACB);
70  }
73 
75  std::vector<std::string> calc_fluid_names(void) {
76  return m_fluid_names;
77  }
78 
80  void setup(const std::vector<std::string>& names, bool generate_SatL_and_SatV = true);
81 
84 
85  void set_mole_fractions(const std::vector<double>& z) {
86  mole_fractions = z;
87  VTPRCubic* _cubic = static_cast<VTPRCubic*>(cubic.get());
88  _cubic->get_unifaq().set_mole_fractions(z);
89  };
90 
93 
95  void set_binary_interaction_double(const std::size_t i, const std::size_t j, const std::string& parameter, const double value);
96 
98  double get_binary_interaction_double(const std::size_t i, const std::size_t j, const std::string& parameter);
99 
100  CoolPropDbl calc_fugacity_coefficient(std::size_t i);
101 
103  void set_Q_k(const size_t sgi, const double value);
104 };
105 
106 }; /* namespace CoolProp */
107 
108 #endif /* VTPRBackend_h */