CoolProp  6.6.0
An open-source fluid property and humid air property database
REFPROPMixtureBackend.h
Go to the documentation of this file.
1 /*
2  * AbstractBackend.h
3  *
4  * Created on: 20 Dec 2013
5  * Author: jowr
6  */
7 
8 #ifndef REFPROPMIXTUREBACKEND_H_
9 #define REFPROPMIXTUREBACKEND_H_
10 
11 #include "AbstractState.h"
12 #include "DataStructures.h"
13 
14 #include <vector>
15 
16 namespace CoolProp {
17 
19 {
20  private:
21  std::string cached_component_string;
22 
23  protected:
24  std::size_t Ncomp;
26 
27  static std::size_t instance_counter;
28  static bool _REFPROP_supported;
29  std::vector<CoolPropDbl> mole_fractions_long_double; // read-only
30  std::vector<double> mole_fractions, mass_fractions;
31  std::vector<double> mole_fractions_liq, mole_fractions_vap;
32  std::vector<std::string> fluid_names;
33 
35  CoolPropDbl call_phixdll(int itau, int idelta);
37  CoolPropDbl call_phi0dll(int itau, int idelta);
38 
39  public:
42  }
43 
46  REFPROPMixtureBackend(const std::vector<std::string>& fluid_names) {
48  };
49 
51  void construct(const std::vector<std::string>& fluid_names);
52 
53  std::string backend_name(void) {
55  }
56  virtual ~REFPROPMixtureBackend();
57 
58  static std::string version();
59 
60  std::vector<std::string> calc_fluid_names() {
61  return fluid_names;
62  };
64 
66  void set_binary_interaction_double(const std::string& CAS1, const std::string& CAS2, const std::string& parameter, const double value);
68  double get_binary_interaction_double(const std::string& CAS1, const std::string& CAS2, const std::string& parameter);
69 
71  std::string get_binary_interaction_string(const std::string& CAS1, const std::string& CAS2, const std::string& parameter);
73  void set_binary_interaction_string(const std::size_t i, const std::size_t j, const std::string& parameter, const std::string& value);
74 
76  void set_binary_interaction_double(const std::size_t i, const std::size_t j, const std::string& parameter, const double value);
78  double get_binary_interaction_double(const std::size_t i, const std::size_t j, const std::string& parameter);
79 
81  int match_CAS(const std::string& CAS);
82 
83  // REFPROP backend uses mole fractions
85  return true;
86  }
88  return false;
89  }
91  return false;
92  }
93 
95  std::string calc_name() {
96  return fluid_param_string("name");
97  }
98 
99  // Get _phase for pure fluids only
101  if (this->Ncomp > 1) {
102  throw NotImplementedError("The REFPROP backend does not implement calc_phase function for mixtures.");
103  } else {
104  return _phase;
105  }
106  };
107 
108  // Utility function to determine the phase from quality value return from REFPROP
109  phases GetRPphase();
110 
115  void calc_specify_phase(phases phase_index) {
116  imposed_phase_index = phase_index;
117  _phase = phase_index;
118  }
123  }
124 
126 
136  void update(CoolProp::input_pairs, double value1, double value2);
137 
141  void update_with_guesses(CoolProp::input_pairs, double value1, double value2, const GuessesStructure& guesses);
142 
144 
145  void check_loaded_fluid(void);
146 
147  void calc_excess_properties();
148 
150  static bool REFPROP_supported(void);
151 
152  std::string fluid_param_string(const std::string& ParamName);
153 
154  CoolPropDbl calc_PIP(void);
155 
157 
159 
162  void set_REFPROP_fluids(const std::vector<std::string>& fluid_names);
163 
165 
168  void set_mole_fractions(const std::vector<CoolPropDbl>& mole_fractions);
169 
171 
174  void set_mass_fractions(const std::vector<CoolPropDbl>& mass_fractions);
175 
176  const std::vector<CoolPropDbl>& get_mole_fractions() {
178  };
179 
180  const std::vector<CoolPropDbl> calc_mass_fractions();
181 
182  void calc_phase_envelope(const std::string& type);
183 
185  return _p / (_rhomolar * gas_constant() * _T);
186  };
187 
189  return PhaseEnvelope;
190  };
191 
192  std::vector<CoolPropDbl> calc_mole_fractions_liquid(void) {
193  return std::vector<CoolPropDbl>(mole_fractions_liq.begin(), mole_fractions_liq.begin() + this->Ncomp);
194  }
195  std::vector<CoolPropDbl> calc_mole_fractions_vapor(void) {
196  return std::vector<CoolPropDbl>(mole_fractions_vap.begin(), mole_fractions_vap.begin() + this->Ncomp);
197  }
198 
200  void check_status();
201 
214 
215  CoolPropDbl calc_fugacity_coefficient(std::size_t i);
216  CoolPropDbl calc_fugacity(std::size_t i);
217  CoolPropDbl calc_chemical_potential(std::size_t i);
218  CoolPropDbl calc_melting_line(int param, int given, CoolPropDbl value);
219  bool has_melting_line();
220  double calc_melt_Tmax();
223  void calc_reducing_state(void);
227  return calc_p_triple();
228  };
235 
237  void calc_true_critical_point(double& T, double& rho);
238 
242 
244  void calc_ideal_curve(const std::string& type, std::vector<double>& T, std::vector<double>& p);
245 
247  void limits(double& Tmin, double& Tmax, double& rhomolarmax, double& pmax);
249  CoolPropDbl calc_pmax(void);
251  CoolPropDbl calc_Tmax(void);
253  CoolPropDbl calc_Tmin(void);
254 
257  return (tau() * calc_dalphar_dTau() - calc_alphar()) * gas_constant();
258  }
259 
262  return call_phixdll(0, 0);
263  };
266  return call_phixdll(0, 1);
267  };
270  return call_phixdll(1, 0);
271  };
274  return call_phixdll(0, 2);
275  };
278  return call_phixdll(1, 1);
279  };
282  return call_phixdll(2, 0);
283  };
286  return call_phixdll(0, 3);
287  };
290  return call_phixdll(1, 2);
291  };
294  return call_phixdll(2, 1);
295  };
298  return call_phixdll(3, 0);
299  };
300 
302  return call_phi0dll(0, 0);
303  };
305  return call_phi0dll(0, 1);
306  };
308  return call_phi0dll(1, 0);
309  };
311  return call_phi0dll(0, 2);
312  };
314  return call_phi0dll(1, 1);
315  };
317  return call_phi0dll(2, 0);
318  };
320  return call_phi0dll(0, 3);
321  };
323  return call_phi0dll(1, 2);
324  };
326  return call_phi0dll(2, 1);
327  };
329  return call_phi0dll(3, 0);
330  };
331 };
332 
333 bool force_load_REFPROP();
334 bool force_unload_REFPROP();
335 void REFPROP_SETREF(char hrf[3], int ixflag, double x0[1], double& h0, double& s0, double& T0, double& p0, int& ierr, char herr[255], int l1, int l2);
336 
337 } /* namespace CoolProp */
338 #endif /* REFPROPMIXTUREBACKEND_H_ */