CoolProp
HelmholtzEOSMixtureBackend.h
1 
2 #ifndef HELMHOLTZEOSMIXTUREBACKEND_H_
3 #define HELMHOLTZEOSMIXTUREBACKEND_H_
4 
5 #include "AbstractState.h"
6 #include "CoolPropFluid.h"
7 #include "ReducingFunctions.h"
8 #include "ExcessHEFunction.h"
9 #include "Solvers.h"
10 #include "PhaseEnvelope.h"
11 #include "DataStructures.h"
12 #include "Configuration.h"
13 
14 #include <vector>
15 
16 namespace CoolProp {
17 
18 class FlashRoutines;
19 
20 class ResidualHelmholtz;
21 
23 
24 protected:
25  void pre_update(CoolProp::input_pairs &input_pair, CoolPropDbl &value1, CoolPropDbl &value2 );
26  void post_update(bool optional_checks = true);
27  std::vector<shared_ptr<HelmholtzEOSMixtureBackend> > linked_states;
28  shared_ptr<HelmholtzEOSMixtureBackend> transient_pure_state;
29  shared_ptr<HelmholtzEOSMixtureBackend> TPD_state;
30  shared_ptr<HelmholtzEOSMixtureBackend> critical_state;
31  virtual void add_TPD_state(){
33  if (TPD_state.get() == NULL){ bool sat_states = false; TPD_state.reset(get_copy(sat_states)); linked_states.push_back(TPD_state);
34  }
35  };
37  virtual void add_critical_state(){
38  if (critical_state.get() == NULL){ bool sat_states = true; critical_state.reset(get_copy(sat_states)); linked_states.push_back(critical_state);
39  }
40  };
42  virtual void add_transient_pure_state(){
43  if (transient_pure_state.get() == NULL){ bool sat_states = true; transient_pure_state.reset(get_copy(sat_states)); linked_states.push_back(transient_pure_state);
44  }
45  };
46 
47  std::vector<CoolPropFluid> components;
49  std::vector<CoolPropDbl> mole_fractions;
50  std::vector<double> mole_fractions_double;
51  std::vector<CoolPropDbl> K,
52  lnK;
53 
54  SimpleState _crit;
55  std::size_t N;
56 
58  std::vector<CoolProp::CriticalState> _calc_all_critical_points(bool find_critical_points = true);
59 
60  static void set_fluid_enthalpy_entropy_offset(CoolPropFluid& component, double delta_a1, double delta_a2, const std::string &ref);
61 
62 public:
64  HelmholtzEOSMixtureBackend(const std::vector<CoolPropFluid> &components, bool generate_SatL_and_SatV = true);
65  HelmholtzEOSMixtureBackend(const std::vector<std::string> &component_names, bool generate_SatL_and_SatV = true);
66  virtual HelmholtzEOSMixtureBackend * get_copy(bool generate_SatL_and_SatV = true);
67 
68  // Copy over the reducing and departure terms to all linked states (recursively)
69  void sync_linked_states(const HelmholtzEOSMixtureBackend * const);
70 
71  virtual ~HelmholtzEOSMixtureBackend(){};
72  std::string backend_name(void) { return get_backend_string(HEOS_BACKEND_MIX); }
73  shared_ptr<ReducingFunction> Reducing;
74  shared_ptr<ResidualHelmholtz> residual_helmholtz;
75  PhaseEnvelopeData PhaseEnvelope;
76  SimpleState hsat_max;
77  SsatSimpleState ssat_max;
78  SpinodalData spinodal_values;
79 
80  bool clear(){
81  // Clear the locally cached values for the derivatives of the Helmholtz energy
82  // in each component
83  for (std::vector<CoolPropFluid>::iterator it = components.begin(); it != components.end(); ++it){
84  (*it).EOS().alphar.clear();
85  (*it).EOS().alpha0.clear();
86  }
87  return AbstractState::clear();
88  };
89 
90  friend class FlashRoutines; // Allows the static methods in the FlashRoutines class to have access to all the protected members and methods of this class
91  friend class TransportRoutines; // Allows the static methods in the TransportRoutines class to have access to all the protected members and methods of this class
92  friend class MixtureDerivatives; // Allows the static methods in the MixtureDerivatives class to have access to all the protected members and methods of this class
93  friend class PhaseEnvelopeRoutines; // Allows the static methods in the PhaseEnvelopeRoutines class to have access to all the protected members and methods of this class
94  friend class MixtureParameters; // Allows the static methods in the MixtureParameters class to have access to all the protected members and methods of this class
95  friend class CorrespondingStatesTerm; // // Allows the methods in the CorrespondingStatesTerm class to have access to all the protected members and methods of this class
96 
97  // Helmholtz EOS backend uses mole fractions
98  bool using_mole_fractions(){return true;}
99  bool using_mass_fractions(){return false;}
100  bool using_volu_fractions(){return false;}
101  bool is_pure(){ return components.size() == 1 && !components[0].EOS().pseudo_pure; }
102  bool has_melting_line(){ return is_pure_or_pseudopure && components[0].ancillaries.melting_line.enabled();};
103  CoolPropDbl calc_melting_line(int param, int given, CoolPropDbl value);
105  std::string fluid_param_string(const std::string &);
106 
108  virtual void set_reference_stateS(const std::string &reference_state);
109 
111  virtual void set_reference_stateD(double T, double rhomolar, double hmolar0, double smolar0);
112 
114  virtual void set_binary_interaction_double(const std::size_t i, const std::size_t j, const std::string &parameter, const double value);
116  virtual double get_binary_interaction_double(const std::size_t i, const std::size_t j, const std::string &parameter);
118  //virtual std::string get_binary_interaction_string(const std::size_t &i, const std::size_t &j, const std::string &parameter);
120  void set_binary_interaction_string(const std::size_t i, const std::size_t j, const std::string &parameter, const std::string & value);
122  void apply_simple_mixing_rule(std::size_t i, std::size_t j, const std::string &model);
123 
124  // Set the cubic alpha function's constants:
125  virtual void set_cubic_alpha_C(const size_t i, const std::string &parameter, const double c1, const double c2, const double c3) { throw ValueError("set_cubic_alpha_C only defined for cubic backends"); };
126 
127  // Set fluid parameter (currently the volume translation parameter for cubic)
128  virtual void set_fluid_parameter_double(const size_t i, const std::string &parameter, const double value) { throw ValueError("set_fluid_parameter_double only defined for cubic backends"); };
129 
130  phases calc_phase(void){return _phase;};
131 
136  void calc_specify_phase(phases phase_index){ imposed_phase_index = phase_index; _phase = phase_index; }
139  void calc_unspecify_phase(){ imposed_phase_index = iphase_not_imposed;}
140  CoolPropDbl calc_saturation_ancillary(parameters param, int Q, parameters given, double value);
141  void calc_ssat_max(void);
142  void calc_hsat_max(void);
143  CoolPropDbl calc_GWP20();
144  CoolPropDbl calc_GWP500();
145  CoolPropDbl calc_GWP100();
146  CoolPropDbl calc_ODP();
147 
148  CoolPropDbl calc_first_saturation_deriv(parameters Of1, parameters Wrt1);
149  CoolPropDbl calc_first_saturation_deriv(parameters Of1, parameters Wrt1, HelmholtzEOSMixtureBackend &SatL, HelmholtzEOSMixtureBackend &SatV);
150  CoolPropDbl calc_second_saturation_deriv(parameters Of1, parameters Wrt1, parameters Wrt2);
151  CoolPropDbl calc_first_two_phase_deriv(parameters Of, parameters Wrt, parameters Constant);
152  CoolPropDbl calc_second_two_phase_deriv(parameters Of, parameters Wrt1, parameters Constant1, parameters Wrt2, parameters Constant2);
153  CoolPropDbl calc_first_two_phase_deriv_splined(parameters Of, parameters Wrt, parameters Constant, CoolPropDbl x_end);
154 
155  CriticalState calc_critical_point(double rho0, double T0);
157  std::vector<CoolProp::CriticalState> calc_all_critical_points(){ bool find_critical_points = true; return _calc_all_critical_points(find_critical_points); };
158 
159  virtual void get_critical_point_starting_values(double &delta0, double &tau0){
160  delta0 = get_config_double(SPINODAL_MINIMUM_DELTA); // The value of delta where we start searching for crossing with Lstar=0 contour
161  tau0 = 0.66; // The value of tau where we start searching at delta=delta0
162  }
164  virtual void get_critical_point_search_radii(double &R_delta, double &R_tau);
166  virtual bool get_critical_is_terminated(double &delta, double &tau){ return delta > 5 || tau > 5; }
167 
169  virtual void calc_build_spinodal();
170 
172  virtual SpinodalData calc_get_spinodal_data(){ return spinodal_values; };
173 
175  void calc_criticality_contour_values(double &L1star, double &M1star);
176 
178  double calc_tangent_plane_distance(const double T, const double p, const std::vector<double> &w, const double rhomolar_guess);
179 
182 
184  void calc_change_EOS(const std::size_t i, const std::string &EOS_name);
185 
186  const CoolProp::SimpleState &calc_state(const std::string &state);
187 
188  virtual const double get_fluid_constant(std::size_t i, parameters param) const{
189  const CoolPropFluid &fld = components[i];
190  switch(param){
191  case iP_critical: return fld.crit.p;
192  case iT_critical: return fld.crit.T;
193  case iT_reducing: return fld.EOS().reduce.T;
194  case irhomolar_reducing: return fld.EOS().reduce.rhomolar;
195  case irhomolar_critical: return fld.crit.rhomolar;
196  case iacentric_factor: return fld.EOS().acentric;
197  case imolar_mass: return fld.EOS().molar_mass;
198  case iT_triple: return fld.EOS().sat_min_liquid.T;
199  case iP_triple: return fld.EOS().sat_min_liquid.p;
200  default:
201  throw ValueError(format("I don't know what to do with this fluid constant: %s", get_parameter_information(param,"short").c_str()));
202  }
203  }
204 
205  const std::vector<CoolPropFluid> &get_components() const {return components;}
206  std::vector<CoolPropFluid> &get_components(){return components;}
207  std::vector<CoolPropDbl> &get_K(){ return K; };
208  std::vector<CoolPropDbl> &get_lnK(){return lnK;};
209  HelmholtzEOSMixtureBackend &get_SatL(){return *SatL;};
210  HelmholtzEOSMixtureBackend &get_SatV(){return *SatV;};
211 
212  std::vector<CoolPropDbl> calc_mole_fractions_liquid(void){return SatL->get_mole_fractions();};
213  std::vector<CoolPropDbl> calc_mole_fractions_vapor(void){return SatV->get_mole_fractions();};
214 
215  const std::vector<CoolPropDbl> calc_mass_fractions(void);
216 
217  const CoolProp::PhaseEnvelopeData &calc_phase_envelope_data(){return PhaseEnvelope;};
218 
220  void calc_conformal_state(const std::string &reference_fluid, CoolPropDbl &T, CoolPropDbl &rhomolar);
221 
222  void resize(std::size_t N);
223  shared_ptr<HelmholtzEOSMixtureBackend> SatL, SatV;
224 
230  virtual void update(CoolProp::input_pairs input_pair, double value1, double value2);
231 
235  void update_with_guesses(CoolProp::input_pairs input_pair, double Value1, double Value2, const GuessesStructure &guesses);
236 
240 
246  void update_TP_guessrho(CoolPropDbl T, CoolPropDbl p, CoolPropDbl rho_guess);
247  void update_DmolarT_direct(CoolPropDbl rhomolar, CoolPropDbl T);
248  void update_HmolarQ_with_guessT(CoolPropDbl hmolar, CoolPropDbl Q, CoolPropDbl Tguess);
249 
255  virtual void set_components(const std::vector<CoolPropFluid> &components, bool generate_SatL_and_SatV = true);
256 
259  void set_mixture_parameters();
260 
265  void set_mole_fractions(const std::vector<CoolPropDbl> &mole_fractions);
266 
267  const std::vector<CoolPropDbl> &get_mole_fractions(){return mole_fractions;};
268  std::vector<CoolPropDbl> &get_mole_fractions_ref(){return mole_fractions;};
269  std::vector<double> & get_mole_fractions_doubleref(void){ return mole_fractions_double; }
270 
271 
276  void set_mass_fractions(const std::vector<CoolPropDbl> &mass_fractions);
277 
278  void calc_ideal_curve(const std::string &type, std::vector<double> &T, std::vector<double> &p);
279 
280  CoolPropDbl calc_molar_mass(void);
281  CoolPropDbl calc_gas_constant(void);
282  CoolPropDbl calc_acentric_factor(void);
283 
284  CoolPropDbl calc_Bvirial(void);
285  CoolPropDbl calc_Cvirial(void);
286  CoolPropDbl calc_dBvirial_dT(void);
287  CoolPropDbl calc_dCvirial_dT(void);
288 
289  CoolPropDbl calc_pressure(void);
290  CoolPropDbl calc_cvmolar(void);
291  CoolPropDbl calc_cpmolar(void);
292  CoolPropDbl calc_gibbsmolar(void);
293  CoolPropDbl calc_gibbsmolar_residual(void) { return gas_constant()*_T*(alphar() + delta()*dalphar_dDelta()); }
294  CoolPropDbl calc_gibbsmolar_nocache(CoolPropDbl T, CoolPropDbl rhomolar);
295 
296  CoolPropDbl calc_helmholtzmolar(void);
297  CoolPropDbl calc_cpmolar_idealgas(void);
298  CoolPropDbl calc_pressure_nocache(CoolPropDbl T, CoolPropDbl rhomolar);
299  CoolPropDbl calc_smolar(void);
300  CoolPropDbl calc_smolar_residual(void) { return gas_constant()*(tau()*dalphar_dTau() - alphar()); }
301  CoolPropDbl calc_smolar_nocache(CoolPropDbl T, CoolPropDbl rhomolar);
302 
303  CoolPropDbl calc_hmolar(void);
304  CoolPropDbl calc_hmolar_residual(void) { return gas_constant()*_T*(tau()*dalphar_dTau() + delta()*dalphar_dDelta()); }
305  CoolPropDbl calc_hmolar_nocache(CoolPropDbl T, CoolPropDbl rhomolar);
306 
307  CoolPropDbl calc_umolar_nocache(CoolPropDbl T, CoolPropDbl rhomolar);
308  CoolPropDbl calc_umolar(void);
309  CoolPropDbl calc_speed_sound(void);
310 
311  void calc_excess_properties();
312 
319  CoolPropDbl calc_phase_identification_parameter(void);
320  CoolPropDbl calc_fugacity(std::size_t i);
321  virtual CoolPropDbl calc_fugacity_coefficient(std::size_t i);
322  CoolPropDbl calc_chemical_potential(std::size_t i);
323 
325  CoolPropDbl calc_flame_hazard(void){ return components[0].environment.FH;};
327  CoolPropDbl calc_health_hazard(void){ return components[0].environment.HH; };
329  CoolPropDbl calc_physical_hazard(void){ return components[0].environment.PH; };
330 
332  CoolPropDbl calc_alphar(void);
334  CoolPropDbl calc_dalphar_dDelta(void);
336  CoolPropDbl calc_dalphar_dTau(void);
338  CoolPropDbl calc_d2alphar_dDelta2(void);
340  CoolPropDbl calc_d2alphar_dDelta_dTau(void);
342  CoolPropDbl calc_d2alphar_dTau2(void);
344  CoolPropDbl calc_d3alphar_dDelta3(void);
346  CoolPropDbl calc_d3alphar_dDelta2_dTau(void);
348  CoolPropDbl calc_d3alphar_dDelta_dTau2(void);
350  CoolPropDbl calc_d3alphar_dTau3(void);
352  CoolPropDbl calc_d4alphar_dDelta4(void);
354  CoolPropDbl calc_d4alphar_dDelta3_dTau(void);
356  CoolPropDbl calc_d4alphar_dDelta2_dTau2(void);
358  CoolPropDbl calc_d4alphar_dDelta_dTau3(void);
360  CoolPropDbl calc_d4alphar_dTau4(void);
361 
362  CoolPropDbl calc_alpha0(void);
363  CoolPropDbl calc_dalpha0_dDelta(void);
364  CoolPropDbl calc_dalpha0_dTau(void);
365  CoolPropDbl calc_d2alpha0_dDelta2(void);
366  CoolPropDbl calc_d2alpha0_dDelta_dTau(void);
367  CoolPropDbl calc_d2alpha0_dTau2(void);
368  CoolPropDbl calc_d3alpha0_dDelta3(void);
369  CoolPropDbl calc_d3alpha0_dDelta2_dTau(void);
370  CoolPropDbl calc_d3alpha0_dDelta_dTau2(void);
371  CoolPropDbl calc_d3alpha0_dTau3(void);
372 
373  CoolPropDbl calc_surface_tension(void);
374  CoolPropDbl calc_viscosity(void);
375  CoolPropDbl calc_viscosity_dilute(void);
376  CoolPropDbl calc_viscosity_background(void);
377  CoolPropDbl calc_viscosity_background(CoolPropDbl eta_dilute, CoolPropDbl &initial_density, CoolPropDbl &residual);
378  CoolPropDbl calc_conductivity(void);
379  CoolPropDbl calc_conductivity_background(void);
380 
386  void calc_viscosity_contributions(CoolPropDbl &dilute, CoolPropDbl &initial_density, CoolPropDbl &residual, CoolPropDbl &critical);
392  void calc_conductivity_contributions(CoolPropDbl &dilute, CoolPropDbl &initial_density, CoolPropDbl &residual, CoolPropDbl &critical);
393 
394  CoolPropDbl calc_saturated_liquid_keyed_output(parameters key);
395  CoolPropDbl calc_saturated_vapor_keyed_output(parameters key);
396 
397  CoolPropDbl calc_Tmin(void);
398  CoolPropDbl calc_Tmax(void);
399  CoolPropDbl calc_pmax(void);
400  CoolPropDbl calc_Ttriple(void);
401  CoolPropDbl calc_p_triple(void);
402  CoolPropDbl calc_pmax_sat(void);
403  CoolPropDbl calc_Tmax_sat(void);
404  void calc_Tmin_sat(CoolPropDbl &Tmin_satL, CoolPropDbl &Tmin_satV);
405  void calc_pmin_sat(CoolPropDbl &pmin_satL, CoolPropDbl &pmin_satV);
406 
407  virtual CoolPropDbl calc_T_critical(void);
408  virtual CoolPropDbl calc_p_critical(void);
409  virtual CoolPropDbl calc_rhomolar_critical(void);
410 
411  CoolPropDbl calc_T_reducing(void){return get_reducing_state().T;};
412  CoolPropDbl calc_rhomolar_reducing(void){return get_reducing_state().rhomolar;};
413  CoolPropDbl calc_p_reducing(void){return get_reducing_state().p;};
414 
415  // Calculate the phase identification parameter of Venkatarathnam et al, Fluid Phase Equilibria
417 
418  std::string calc_name(void);
419  std::vector<std::string> calc_fluid_names(void);
420 
421  void calc_all_alphar_deriv_cache(const std::vector<CoolPropDbl> &mole_fractions, const CoolPropDbl &tau, const CoolPropDbl &delta);
422  virtual CoolPropDbl calc_alphar_deriv_nocache(const int nTau, const int nDelta, const std::vector<CoolPropDbl> & mole_fractions, const CoolPropDbl &tau, const CoolPropDbl &delta);
423 
448  CoolPropDbl calc_alpha0_deriv_nocache(const int nTau, const int nDelta, const std::vector<CoolPropDbl> & mole_fractions, const CoolPropDbl &tau, const CoolPropDbl &delta, const CoolPropDbl &Tr, const CoolPropDbl &rhor);
449 
450  virtual void calc_reducing_state(void);
451  virtual SimpleState calc_reducing_state_nocache(const std::vector<CoolPropDbl> & mole_fractions);
452 
454 
455  void update_states();
456 
457  CoolPropDbl calc_compressibility_factor(void){return 1+delta()*dalphar_dDelta();};
458 
459  void calc_phase_envelope(const std::string &type);
460 
461  CoolPropDbl SRK_covolume();
462 
463 
464  // ***************************************************************
465  // ***************************************************************
466  // ************* PHASE DETERMINATION ROUTINES ******************
467  // ***************************************************************
468  // ***************************************************************
469  void T_phase_determination_pure_or_pseudopure(int other, CoolPropDbl value);
470  void p_phase_determination_pure_or_pseudopure(int other, CoolPropDbl value, bool &saturation_called);
471  void DmolarP_phase_determination();
472 
473 
474  // ***************************************************************
475  // ***************************************************************
476  // ******************* SOLVER ROUTINES *************************
477  // ***************************************************************
478  // ***************************************************************
479 
480  virtual CoolPropDbl solver_rho_Tp(CoolPropDbl T, CoolPropDbl p, CoolPropDbl rho_guess = -1);
481  virtual CoolPropDbl solver_rho_Tp_SRK(CoolPropDbl T, CoolPropDbl p, phases phase);
482  enum StationaryPointReturnFlag {ZERO_STATIONARY_POINTS, ONE_STATIONARY_POINT_FOUND, TWO_STATIONARY_POINTS_FOUND};
483  virtual StationaryPointReturnFlag solver_dpdrho0_Tp(CoolPropDbl T, CoolPropDbl p, CoolPropDbl rhomax, CoolPropDbl&light, CoolPropDbl &heavy);
484  virtual CoolPropDbl solver_rho_Tp_global(CoolPropDbl T, CoolPropDbl p, CoolPropDbl rhomax);
485 };
486 
488 {
489 public:
491  virtual HelmholtzDerivatives all(HelmholtzEOSMixtureBackend &HEOS, double tau, double delta, const std::vector<CoolPropDbl> &x, bool cache_values = false)
492  {
493  HelmholtzDerivatives summer;
494  std::size_t N = x.size();
495  for (std::size_t i = 0; i < N; ++i){
496  HelmholtzDerivatives derivs = HEOS.components[i].EOS().alphar.all(tau, delta, cache_values);
497  summer = summer + derivs*x[i];
498  }
499  return summer;
500  }
501  CoolPropDbl dalphar_dxi(HelmholtzEOSMixtureBackend &HEOS, std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag)
502  {
503  if (xN_flag == XN_INDEPENDENT){
504  return HEOS.components[i].EOS().baser(HEOS.tau(), HEOS.delta());
505  }
506  else if (xN_flag == XN_DEPENDENT){
507  std::size_t N = x.size();
508  if (i == N-1) return 0;
509  return HEOS.components[i].EOS().baser(HEOS.tau(), HEOS.delta()) - HEOS.components[N-1].EOS().baser(HEOS.tau(), HEOS.delta());
510  }
511  else{
512  throw ValueError(format("xN_flag is invalid"));
513  }
514  }
515  CoolPropDbl d2alphar_dxi_dTau(HelmholtzEOSMixtureBackend &HEOS, std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag)
516  {
517  if (xN_flag == XN_INDEPENDENT){
518  return HEOS.components[i].EOS().dalphar_dTau(HEOS._tau, HEOS._delta);
519  }
520  else if (xN_flag == XN_DEPENDENT){
521  std::size_t N = x.size();
522  if (i==N-1) return 0;
523  return HEOS.components[i].EOS().dalphar_dTau(HEOS._tau, HEOS._delta) - HEOS.components[N-1].EOS().dalphar_dTau(HEOS._tau, HEOS._delta);
524  }
525  else{
526  throw ValueError(format("xN_flag is invalid"));
527  }
528  }
529  CoolPropDbl d2alphar_dxi_dDelta(HelmholtzEOSMixtureBackend &HEOS, std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag)
530  {
531  if (xN_flag == XN_INDEPENDENT){
532  return HEOS.components[i].EOS().dalphar_dDelta(HEOS.tau(), HEOS.delta());
533  }
534  else if (xN_flag == XN_DEPENDENT){
535  std::size_t N = x.size();
536  if (i==N-1) return 0;
537  return HEOS.components[i].EOS().dalphar_dDelta(HEOS.tau(), HEOS.delta()) - HEOS.components[N-1].EOS().dalphar_dDelta(HEOS._tau, HEOS._delta);
538  }
539  else{
540  throw ValueError(format("xN_flag is invalid"));
541  }
542  }
543  CoolPropDbl d3alphar_dxi_dDelta2(HelmholtzEOSMixtureBackend &HEOS, std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag)
544  {
545  if (xN_flag == XN_INDEPENDENT){
546  return HEOS.components[i].EOS().d2alphar_dDelta2(HEOS.tau(), HEOS.delta());
547  }
548  else if (xN_flag == XN_DEPENDENT){
549  std::size_t N = x.size();
550  if (i==N-1) return 0;
551  return HEOS.components[i].EOS().d2alphar_dDelta2(HEOS.tau(), HEOS.delta()) - HEOS.components[N-1].EOS().d2alphar_dDelta2(HEOS.tau(), HEOS.delta());
552  }
553  else{
554  throw ValueError(format("xN_flag is invalid"));
555  }
556  }
557  CoolPropDbl d3alphar_dxi_dTau2(HelmholtzEOSMixtureBackend &HEOS, std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag)
558  {
559  if (xN_flag == XN_INDEPENDENT){
560  return HEOS.components[i].EOS().d2alphar_dTau2(HEOS.tau(), HEOS.delta());
561  }
562  else if (xN_flag == XN_DEPENDENT){
563  std::size_t N = x.size();
564  if (i==N-1) return 0;
565  return HEOS.components[i].EOS().d2alphar_dTau2(HEOS.tau(), HEOS.delta()) - HEOS.components[N-1].EOS().d2alphar_dTau2(HEOS.tau(), HEOS.delta());
566  }
567  else{
568  throw ValueError(format("xN_flag is invalid"));
569  }
570  }
571  CoolPropDbl d3alphar_dxi_dDelta_dTau(HelmholtzEOSMixtureBackend &HEOS, std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag)
572  {
573  if (xN_flag == XN_INDEPENDENT){
574  return HEOS.components[i].EOS().d2alphar_dDelta_dTau(HEOS.tau(), HEOS.delta());
575  }
576  else if (xN_flag == XN_DEPENDENT){
577  std::size_t N = x.size();
578  if (i==N-1) return 0;
579  return HEOS.components[i].EOS().d2alphar_dDelta_dTau(HEOS.tau(), HEOS.delta()) - HEOS.components[N-1].EOS().d2alphar_dDelta_dTau(HEOS.tau(), HEOS.delta());
580  }
581  else{
582  throw ValueError(format("xN_flag is invalid"));
583  }
584  }
585 
586  CoolPropDbl d2alphardxidxj(HelmholtzEOSMixtureBackend &HEOS, std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, x_N_dependency_flag xN_flag)
587  {
588  if (xN_flag == XN_INDEPENDENT){
589  return 0;
590  }
591  else if (xN_flag == XN_DEPENDENT){
592  return 0;
593  }
594  else{
595  throw ValueError(format("xN_flag is invalid"));
596  }
597  }
598 
599  CoolPropDbl d4alphar_dxi_dDelta3(HelmholtzEOSMixtureBackend &HEOS, std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag)
600  {
601  if (xN_flag == XN_INDEPENDENT){
602  return HEOS.components[i].EOS().d3alphar_dDelta3(HEOS.tau(), HEOS.delta());
603  }
604  else{
605  throw ValueError(format("xN_flag is invalid"));
606  }
607  }
608  CoolPropDbl d4alphar_dxi_dTau3(HelmholtzEOSMixtureBackend &HEOS, std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag)
609  {
610  if (xN_flag == XN_INDEPENDENT){
611  return HEOS.components[i].EOS().d3alphar_dTau3(HEOS.tau(), HEOS.delta());
612  }
613  else{
614  throw ValueError(format("xN_flag is invalid"));
615  }
616  }
617  CoolPropDbl d4alphar_dxi_dDelta_dTau2(HelmholtzEOSMixtureBackend &HEOS, std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag)
618  {
619  if (xN_flag == XN_INDEPENDENT){
620  return HEOS.components[i].EOS().d3alphar_dDelta_dTau2(HEOS.tau(), HEOS.delta());
621  }
622  else{
623  throw ValueError(format("xN_flag is invalid"));
624  }
625  }
626  CoolPropDbl d4alphar_dxi_dDelta2_dTau(HelmholtzEOSMixtureBackend &HEOS, std::vector<CoolPropDbl> &x, std::size_t i, x_N_dependency_flag xN_flag)
627  {
628  if (xN_flag == XN_INDEPENDENT){
629  return HEOS.components[i].EOS().d3alphar_dDelta2_dTau(HEOS.tau(), HEOS.delta());
630  }
631  else{
632  throw ValueError(format("xN_flag is invalid"));
633  }
634  }
635 
636  CoolPropDbl d3alphardxidxjdxk(HelmholtzEOSMixtureBackend &HEOS, std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, std::size_t k, x_N_dependency_flag xN_flag)
637  {
638  return 0;
639  }
640  CoolPropDbl d3alphar_dxi_dxj_dDelta(HelmholtzEOSMixtureBackend &HEOS, std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, x_N_dependency_flag xN_flag)
641  {
642  return 0;
643  }
644  CoolPropDbl d3alphar_dxi_dxj_dTau(HelmholtzEOSMixtureBackend &HEOS, std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, x_N_dependency_flag xN_flag)
645  {
646  return 0;
647  }
648  CoolPropDbl d4alphar_dxi_dxj_dDelta2(HelmholtzEOSMixtureBackend &HEOS, std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, x_N_dependency_flag xN_flag)
649  {
650  return 0;
651  }
652  CoolPropDbl d4alphar_dxi_dxj_dDelta_dTau(HelmholtzEOSMixtureBackend &HEOS, std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, x_N_dependency_flag xN_flag)
653  {
654  return 0;
655  }
656  CoolPropDbl d4alphar_dxi_dxj_dTau2(HelmholtzEOSMixtureBackend &HEOS, std::vector<CoolPropDbl> &x, std::size_t i, std::size_t j, x_N_dependency_flag xN_flag)
657  {
658  return 0;
659  }
660 };
661 
668 {
669 public:
670  ExcessTerm Excess;
672 
673  ResidualHelmholtz() {} ;
674  ResidualHelmholtz(const ExcessTerm &E, const CorrespondingStatesTerm &C) :Excess(E), CS(C) {} ;
675 
676  ResidualHelmholtz copy(){
677  return ResidualHelmholtz(Excess.copy(), CS);
678  }
679  ResidualHelmholtz *copy_ptr(){
680  return new ResidualHelmholtz(Excess.copy(), CS);
681  }
682 
683 
684  virtual HelmholtzDerivatives all(HelmholtzEOSMixtureBackend &HEOS, const std::vector<CoolPropDbl> &mole_fractions, double tau, double delta, bool cache_values = false)
685  {
686  HelmholtzDerivatives a = CS.all(HEOS, tau, delta, mole_fractions, cache_values) + Excess.all(tau, delta, mole_fractions, cache_values);
687  a.delta_x_dalphar_ddelta = delta*a.dalphar_ddelta;
688  a.tau_x_dalphar_dtau = tau*a.dalphar_dtau;
689 
690  a.delta2_x_d2alphar_ddelta2 = POW2(delta)*a.d2alphar_ddelta2;
691  a.deltatau_x_d2alphar_ddelta_dtau = delta*tau*a.d2alphar_ddelta_dtau;
692  a.tau2_x_d2alphar_dtau2 = POW2(tau)*a.d2alphar_dtau2;
693 
694  return a;
695  }
696  virtual CoolPropDbl dalphar_dxi(HelmholtzEOSMixtureBackend &HEOS, std::size_t i, x_N_dependency_flag xN_flag)
697  {
698  std::vector<CoolPropDbl> &mole_fractions = HEOS.get_mole_fractions_ref();
699  return CS.dalphar_dxi(HEOS, mole_fractions, i, xN_flag) + Excess.dalphar_dxi(mole_fractions, i, xN_flag);
700  }
701  virtual CoolPropDbl d2alphardxidxj(HelmholtzEOSMixtureBackend &HEOS, std::size_t i, std::size_t j, x_N_dependency_flag xN_flag)
702  {
703  std::vector<CoolPropDbl> &mole_fractions = HEOS.get_mole_fractions_ref();
704  return CS.d2alphardxidxj(HEOS, mole_fractions, i, j, xN_flag) + Excess.d2alphardxidxj(mole_fractions, i, j, xN_flag);
705  }
706  virtual CoolPropDbl d2alphar_dxi_dTau(HelmholtzEOSMixtureBackend &HEOS, std::size_t i, x_N_dependency_flag xN_flag)
707  {
708  std::vector<CoolPropDbl> &mole_fractions = HEOS.get_mole_fractions_ref();
709  return CS.d2alphar_dxi_dTau(HEOS, mole_fractions, i, xN_flag) + Excess.d2alphar_dxi_dTau(mole_fractions, i, xN_flag);
710  }
711  virtual CoolPropDbl d2alphar_dxi_dDelta(HelmholtzEOSMixtureBackend &HEOS, std::size_t i, x_N_dependency_flag xN_flag)
712  {
713  std::vector<CoolPropDbl> &mole_fractions = HEOS.get_mole_fractions_ref();
714  return CS.d2alphar_dxi_dDelta(HEOS, mole_fractions, i, xN_flag) + Excess.d2alphar_dxi_dDelta(mole_fractions, i, xN_flag);
715  }
716  virtual CoolPropDbl d3alphar_dxi_dTau2(HelmholtzEOSMixtureBackend &HEOS, std::size_t i, x_N_dependency_flag xN_flag)
717  {
718  std::vector<CoolPropDbl> &mole_fractions = HEOS.get_mole_fractions_ref();
719  return CS.d3alphar_dxi_dTau2(HEOS, mole_fractions, i, xN_flag) + Excess.d3alphar_dxi_dTau2(mole_fractions, i, xN_flag);
720  }
721  virtual CoolPropDbl d3alphar_dxi_dDelta_dTau(HelmholtzEOSMixtureBackend &HEOS, std::size_t i, x_N_dependency_flag xN_flag)
722  {
723  std::vector<CoolPropDbl> &mole_fractions = HEOS.get_mole_fractions_ref();
724  return CS.d3alphar_dxi_dDelta_dTau(HEOS, mole_fractions, i, xN_flag) + Excess.d3alphar_dxi_dDelta_dTau(mole_fractions, i, xN_flag);
725  }
726  virtual CoolPropDbl d3alphar_dxi_dDelta2(HelmholtzEOSMixtureBackend &HEOS, std::size_t i, x_N_dependency_flag xN_flag)
727  {
728  std::vector<CoolPropDbl> &mole_fractions = HEOS.get_mole_fractions_ref();
729  return CS.d3alphar_dxi_dDelta2(HEOS, mole_fractions, i, xN_flag) + Excess.d3alphar_dxi_dDelta2(mole_fractions, i, xN_flag);
730  }
731  virtual CoolPropDbl d3alphar_dxi_dxj_dTau(HelmholtzEOSMixtureBackend &HEOS, std::size_t i, std::size_t j, x_N_dependency_flag xN_flag)
732  {
733  std::vector<CoolPropDbl> &mole_fractions = HEOS.get_mole_fractions_ref();
734  return CS.d3alphar_dxi_dxj_dTau(HEOS, mole_fractions, i, j, xN_flag) + Excess.d3alphar_dxi_dxj_dTau(mole_fractions, i, j, xN_flag);
735  }
736  virtual CoolPropDbl d3alphar_dxi_dxj_dDelta(HelmholtzEOSMixtureBackend &HEOS, std::size_t i, std::size_t j, x_N_dependency_flag xN_flag)
737  {
738  std::vector<CoolPropDbl> &mole_fractions = HEOS.get_mole_fractions_ref();
739  return CS.d3alphar_dxi_dxj_dDelta(HEOS, mole_fractions, i, j, xN_flag) + Excess.d3alphar_dxi_dxj_dDelta(mole_fractions, i, j, xN_flag);
740  }
741  virtual CoolPropDbl d3alphardxidxjdxk(HelmholtzEOSMixtureBackend &HEOS, std::size_t i, std::size_t j, std::size_t k, x_N_dependency_flag xN_flag)
742  {
743  std::vector<CoolPropDbl> &mole_fractions = HEOS.get_mole_fractions_ref();
744  return CS.d3alphardxidxjdxk(HEOS, mole_fractions, i, j, k,xN_flag) + Excess.d3alphardxidxjdxk(mole_fractions, i, j, k, xN_flag);
745  }
746 
747  virtual CoolPropDbl d4alphar_dxi_dTau3(HelmholtzEOSMixtureBackend &HEOS, std::size_t i, x_N_dependency_flag xN_flag)
748  {
749  std::vector<CoolPropDbl> &mole_fractions = HEOS.get_mole_fractions_ref();
750  return CS.d4alphar_dxi_dTau3(HEOS, mole_fractions, i, xN_flag) + Excess.d4alphar_dxi_dTau3(mole_fractions, i, xN_flag);
751  }
752  virtual CoolPropDbl d4alphar_dxi_dDelta2_dTau(HelmholtzEOSMixtureBackend &HEOS, std::size_t i, x_N_dependency_flag xN_flag)
753  {
754  std::vector<CoolPropDbl> &mole_fractions = HEOS.get_mole_fractions_ref();
755  return CS.d4alphar_dxi_dDelta2_dTau(HEOS, mole_fractions, i, xN_flag) + Excess.d4alphar_dxi_dDelta2_dTau(mole_fractions, i, xN_flag);
756  }
757  virtual CoolPropDbl d4alphar_dxi_dDelta_dTau2(HelmholtzEOSMixtureBackend &HEOS, std::size_t i, x_N_dependency_flag xN_flag)
758  {
759  std::vector<CoolPropDbl> &mole_fractions = HEOS.get_mole_fractions_ref();
760  return CS.d4alphar_dxi_dDelta_dTau2(HEOS, mole_fractions, i, xN_flag) + Excess.d4alphar_dxi_dDelta_dTau2(mole_fractions, i, xN_flag);
761  }
762  virtual CoolPropDbl d4alphar_dxi_dDelta3(HelmholtzEOSMixtureBackend &HEOS, std::size_t i, x_N_dependency_flag xN_flag)
763  {
764  std::vector<CoolPropDbl> &mole_fractions = HEOS.get_mole_fractions_ref();
765  return CS.d4alphar_dxi_dDelta3(HEOS, mole_fractions, i, xN_flag) + Excess.d4alphar_dxi_dDelta3(mole_fractions, i, xN_flag);
766  }
767  virtual CoolPropDbl d4alphar_dxi_dxj_dTau2(HelmholtzEOSMixtureBackend &HEOS, std::size_t i, std::size_t j, x_N_dependency_flag xN_flag)
768  {
769  std::vector<CoolPropDbl> &mole_fractions = HEOS.get_mole_fractions_ref();
770  return CS.d4alphar_dxi_dxj_dTau2(HEOS, mole_fractions, i, j, xN_flag) + Excess.d4alphar_dxi_dxj_dTau2(mole_fractions, i, j, xN_flag);
771  }
772  virtual CoolPropDbl d4alphar_dxi_dxj_dDelta_dTau(HelmholtzEOSMixtureBackend &HEOS, std::size_t i, std::size_t j, x_N_dependency_flag xN_flag)
773  {
774  std::vector<CoolPropDbl> &mole_fractions = HEOS.get_mole_fractions_ref();
775  return CS.d4alphar_dxi_dxj_dDelta_dTau(HEOS, mole_fractions, i, j, xN_flag) + Excess.d4alphar_dxi_dxj_dDelta_dTau(mole_fractions, i, j, xN_flag);
776  }
777  virtual CoolPropDbl d4alphar_dxi_dxj_dDelta2(HelmholtzEOSMixtureBackend &HEOS, std::size_t i, std::size_t j, x_N_dependency_flag xN_flag)
778  {
779  std::vector<CoolPropDbl> &mole_fractions = HEOS.get_mole_fractions_ref();
780  return CS.d4alphar_dxi_dxj_dDelta2(HEOS, mole_fractions, i, j, xN_flag) + Excess.d4alphar_dxi_dxj_dDelta2(mole_fractions, i, j, xN_flag);
781  }
782  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)
783  {
784  return 0;
785  }
786  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)
787  {
788  return 0;
789  }
790 };
791 
792 } /* namespace CoolProp */
793 #endif /* HELMHOLTZEOSMIXTUREBACKEND_H_ */
double T(void)
Return the temperature in K.
Definition: AbstractState.h:700
phases imposed_phase_index
If the phase is imposed, the imposed phase index.
Definition: AbstractState.h:76
CoolPropDbl calc_d2alphar_dTau2(void)
Using this backend, calculate the residual Helmholtz energy term (dimensionless) ...
Definition: HelmholtzEOSMixtureBackend.cpp:3135
CoolPropDbl calc_gibbsmolar_residual(void)
Using this backend, calculate the residual molar Gibbs function in J/mol.
Definition: HelmholtzEOSMixtureBackend.h:293
CoolPropDbl dalphar_dDelta(void)
Return the term .
Definition: AbstractState.h:1099
double gas_constant(void)
Return the mole-fraction weighted gas constant in J/mol/K.
Definition: AbstractState.cpp:651
virtual const double get_fluid_constant(std::size_t i, parameters param) const
Get a constant for one of the fluids forming this mixture.
Definition: HelmholtzEOSMixtureBackend.h:188
std::string fluid_param_string(const std::string &)
Return a string from the backend for the mixture/fluid.
Definition: HelmholtzEOSMixtureBackend.cpp:213
CoolPropDbl calc_PIP(void)
Using this backend, calculate the phase identification parameter (PIP)
Definition: HelmholtzEOSMixtureBackend.h:416
Definition: PhaseEnvelopeRoutines.h:8
void update_with_guesses(CoolProp::input_pairs input_pair, double Value1, double Value2, const GuessesStructure &guesses)
Update the state using guess values.
Definition: HelmholtzEOSMixtureBackend.cpp:1362
void calc_viscosity_contributions(CoolPropDbl &dilute, CoolPropDbl &initial_density, CoolPropDbl &residual, CoolPropDbl &critical)
Calculate each of the contributions to the viscosity.
Definition: HelmholtzEOSMixtureBackend.cpp:697
CoolPropDbl calc_d4alphar_dTau4(void)
Using this backend, calculate the residual Helmholtz energy term (dimensionless) ...
Definition: HelmholtzEOSMixtureBackend.cpp:3191
void calc_conductivity_contributions(CoolPropDbl &dilute, CoolPropDbl &initial_density, CoolPropDbl &residual, CoolPropDbl &critical)
Calculate each of the contributions to the conductivity.
Definition: HelmholtzEOSMixtureBackend.cpp:783
double rhomolar(void)
Return the molar density in mol/m^3.
Definition: AbstractState.h:702
CoolPropDbl first_partial_deriv(parameters Of, parameters Wrt, parameters Constant)
The first partial derivative in homogeneous phases.
Definition: AbstractState.h:839
void calc_excess_properties()
Using this backend, calculate and cache the excess properties.
Definition: HelmholtzEOSMixtureBackend.cpp:2899
CoolPropDbl calc_hmolar(void)
Using this backend, calculate the molar enthalpy in J/mol.
Definition: HelmholtzEOSMixtureBackend.cpp:2626
std::vector< CoolPropDbl > mole_fractions
The bulk mole fractions of the mixture.
Definition: HelmholtzEOSMixtureBackend.h:49
virtual void add_transient_pure_state()
Update the state class used to calculate the critical point(s)
Definition: HelmholtzEOSMixtureBackend.h:42
CoolPropDbl calc_pmax(void)
Using this backend, calculate the maximum pressure in Pa.
Definition: HelmholtzEOSMixtureBackend.cpp:1183
std::vector< CoolPropDbl > lnK
The natural logarithms of the K factors of the components.
Definition: HelmholtzEOSMixtureBackend.h:51
CoolPropDbl calc_d2alpha0_dDelta2(void)
Using this backend, calculate the ideal-gas Helmholtz energy term (dimensionless) ...
Definition: HelmholtzEOSMixtureBackend.cpp:3212
double delta(void)
Return the reduced density ( )
Definition: AbstractState.cpp:509
CoolPropDbl calc_conductivity(void)
Using this backend, calculate the thermal conductivity in W/m/K.
Definition: HelmholtzEOSMixtureBackend.cpp:893
CoolPropDbl calc_d4alphar_dDelta4(void)
Using this backend, calculate the residual Helmholtz energy term (dimensionless) ...
Definition: HelmholtzEOSMixtureBackend.cpp:3171
CoolPropDbl calc_p_triple(void)
Using this backend, get the triple point pressure in Pa.
Definition: HelmholtzEOSMixtureBackend.cpp:946
CoolPropDbl calc_helmholtzmolar(void)
Using this backend, calculate the molar Helmholtz energy in J/mol.
Definition: HelmholtzEOSMixtureBackend.cpp:2921
std::string calc_name(void)
Using this backend, get the name of the fluid.
Definition: HelmholtzEOSMixtureBackend.cpp:954
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
CoolPropDbl calc_dalphar_dDelta(void)
Using this backend, calculate the residual Helmholtz energy term (dimensionless) ...
Definition: HelmholtzEOSMixtureBackend.cpp:3125
CoolPropDbl calc_health_hazard(void)
Using this backend, calculate the health hazard.
Definition: HelmholtzEOSMixtureBackend.h:327
CoolPropDbl calc_phase_identification_parameter(void)
The phase identification parameter of Venkatarathnam et al., FPE, 2011.
Definition: HelmholtzEOSMixtureBackend.cpp:2968
CoolPropDbl calc_Tmin(void)
Using this backend, calculate the minimum temperature in K.
Definition: HelmholtzEOSMixtureBackend.cpp:1174
double get_config_double(configuration_keys key)
Return the value of a double configuration key.
Definition: Configuration.cpp:92
virtual bool clear()
Clear all the cached values.
Definition: AbstractState.cpp:187
Definition: DataStructures.h:26
CoolPropDbl calc_dCvirial_dT(void)
Using this backend, calculate the derivative dC/dT.
Definition: HelmholtzEOSMixtureBackend.cpp:1424
phases
These are constants for the phases of the fluid.
Definition: DataStructures.h:158
virtual void add_TPD_state()
Update the state class used to calculate the tangent-plane-distance.
Definition: HelmholtzEOSMixtureBackend.h:32
virtual void update(CoolProp::input_pairs input_pair, double value1, double value2)
The standard update function.
Definition: HelmholtzEOSMixtureBackend.cpp:1281
std::vector< CoolProp::CriticalState > _calc_all_critical_points(bool find_critical_points=true)
This overload is protected because it doesn&#39;t follow the base class definition, since this function i...
Definition: HelmholtzEOSMixtureBackend.cpp:3801
phases phase(void)
Get the phase of the state.
Definition: AbstractState.h:616
Pressure at the critical point.
Definition: DataStructures.h:62
CoolPropDbl calc_dalphar_dTau(void)
Using this backend, calculate the residual Helmholtz energy term (dimensionless) ...
Definition: HelmholtzEOSMixtureBackend.cpp:3130
virtual CoolPropDbl calc_rhomolar_critical(void)
Using this backend, get the critical point molar density in mol/m^3.
Definition: HelmholtzEOSMixtureBackend.cpp:1081
phases calc_phase(void)
Using this backend, calculate the phase.
Definition: HelmholtzEOSMixtureBackend.h:130
void set_mole_fractions(const std::vector< CoolPropDbl > &mole_fractions)
Set the mole fractions.
Definition: HelmholtzEOSMixtureBackend.cpp:123
CoolPropDbl calc_d2alpha0_dTau2(void)
Using this backend, calculate the ideal-gas Helmholtz energy term (dimensionless) ...
Definition: HelmholtzEOSMixtureBackend.cpp:3222
void apply_simple_mixing_rule(std::size_t i, std::size_t j, const std::string &model)
Apply a simple mixing rule.
Definition: HelmholtzEOSMixtureBackend.cpp:281
Temperature at the reducing state.
Definition: DataStructures.h:58
std::size_t N
Number of components.
Definition: HelmholtzEOSMixtureBackend.h:55
CoolPropDbl calc_d3alphar_dDelta2_dTau(void)
Using this backend, calculate the residual Helmholtz energy term (dimensionless) ...
Definition: HelmholtzEOSMixtureBackend.cpp:3155
CoolPropDbl calc_d3alpha0_dTau3(void)
Using this backend, calculate the ideal-gas Helmholtz energy term (dimensionless) ...
Definition: HelmholtzEOSMixtureBackend.cpp:3242
void calc_specify_phase(phases phase_index)
Specify the phase - this phase will always be used in calculations.
Definition: HelmholtzEOSMixtureBackend.h:136
virtual StationaryPointReturnFlag solver_dpdrho0_Tp(CoolPropDbl T, CoolPropDbl p, CoolPropDbl rhomax, CoolPropDbl &light, CoolPropDbl &heavy)
Definition: HelmholtzEOSMixtureBackend.cpp:2184
const CoolProp::SimpleState & get_reducing_state()
Get the state that is used in the equation of state or mixture model to reduce the state...
Definition: HelmholtzEOSMixtureBackend.h:453
CoolPropDbl calc_rhomolar_reducing(void)
Using this backend, get the reducing point molar density in mol/m^3.
Definition: HelmholtzEOSMixtureBackend.h:412
CoolPropDbl calc_cvmolar(void)
Using this backend, calculate the molar constant-volume specific heat in J/mol/K. ...
Definition: HelmholtzEOSMixtureBackend.cpp:2769
virtual 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: HelmholtzEOSMixtureBackend.h:128
bool has_melting_line()
Return true if the fluid has a melting line - default is false, but can be re-implemented by derived ...
Definition: HelmholtzEOSMixtureBackend.h:102
CoolPropDbl calc_T_reducing(void)
Using this backend, get the reducing point temperature in K.
Definition: HelmholtzEOSMixtureBackend.h:411
virtual CoolPropDbl calc_fugacity_coefficient(std::size_t i)
Using this backend, calculate the fugacity coefficient (dimensionless)
Definition: HelmholtzEOSMixtureBackend.cpp:2949
SimpleState sat_min_liquid
The saturated liquid state at the minimum saturation temperature.
Definition: CoolPropFluid.h:357
CoolPropDbl calc_d3alpha0_dDelta3(void)
Using this backend, calculate the ideal-gas Helmholtz energy term (dimensionless) ...
Definition: HelmholtzEOSMixtureBackend.cpp:3227
x_N is an dependent variable, calculated by
Definition: ReducingFunctions.h:19
CoolPropDbl calc_fugacity(std::size_t i)
Using this backend, calculate the fugacity in Pa.
Definition: HelmholtzEOSMixtureBackend.cpp:2954
The mother of all state classes.
Definition: AbstractState.h:70
virtual double get_binary_interaction_double(const std::size_t i, const std::size_t j, const std::string &parameter)
Get binary mixture double value.
Definition: HelmholtzEOSMixtureBackend.cpp:317
CoolPropDbl calc_dalpha0_dDelta(void)
Using this backend, calculate the ideal-gas Helmholtz energy term (dimensionless) ...
Definition: HelmholtzEOSMixtureBackend.cpp:3202
std::vector< std::string > calc_fluid_names(void)
Using this backend, get a vector of fluid names.
Definition: HelmholtzEOSMixtureBackend.cpp:996
Definition: ExcessHEFunction.h:177
CoolPropDbl calc_saturation_ancillary(parameters param, int Q, parameters given, double value)
Definition: HelmholtzEOSMixtureBackend.cpp:506
virtual void calc_build_spinodal()
Build the spinodal curve.
Definition: HelmholtzEOSMixtureBackend.cpp:3871
CoolPropDbl calc_compressibility_factor(void)
Using this backend, calculate the compressibility factor Z .
Definition: HelmholtzEOSMixtureBackend.h:457
A modified class for the state point at the maximum saturation entropy on the vapor curve...
Definition: DataStructures.h:34
std::string get_parameter_information(int key, const std::string &info)
Return information about the parameter.
Definition: DataStructures.cpp:173
A thermophysical property provider for critical and reducing values as well as derivatives of Helmhol...
Definition: CoolPropFluid.h:476
CoolPropDbl calc_d3alphar_dDelta_dTau2(void)
Using this backend, calculate the residual Helmholtz energy term (dimensionless) ...
Definition: HelmholtzEOSMixtureBackend.cpp:3160
void calc_criticality_contour_values(double &L1star, double &M1star)
Calculate the values and .
Definition: HelmholtzEOSMixtureBackend.cpp:3790
CoolPropDbl calc_dalpha0_dTau(void)
Using this backend, calculate the ideal-gas Helmholtz energy term (dimensionless) ...
Definition: HelmholtzEOSMixtureBackend.cpp:3207
shared_ptr< HelmholtzEOSMixtureBackend > transient_pure_state
A temporary state used for calculations of pure fluid properties.
Definition: HelmholtzEOSMixtureBackend.h:28
void calc_change_EOS(const std::size_t i, const std::string &EOS_name)
Change the equation of state for one component.
Definition: HelmholtzEOSMixtureBackend.cpp:344
CoolPropDbl calc_smolar(void)
Using this backend, calculate the molar entropy in J/mol/K.
Definition: HelmholtzEOSMixtureBackend.cpp:2681
CoolPropDbl calc_Cvirial(void)
Using this backend, calculate the third virial coefficient.
Definition: HelmholtzEOSMixtureBackend.cpp:1420
CoolPropDbl calc_alpha0_deriv_nocache(const int nTau, const int nDelta, const std::vector< CoolPropDbl > &mole_fractions, const CoolPropDbl &tau, const CoolPropDbl &delta, const CoolPropDbl &Tr, const CoolPropDbl &rhor)
Take derivatives of the ideal-gas part of the Helmholtz energy, don&#39;t use any cached values...
Definition: HelmholtzEOSMixtureBackend.cpp:3022
CoolPropDbl calc_acentric_factor(void)
Using this backend, calculate the acentric factor.
Definition: HelmholtzEOSMixtureBackend.cpp:468
This structure holds values obtained while tracing the spinodal curve (most often in the process of f...
Definition: AbstractState.h:23
A data structure to hold the data for a phase envelope.
Definition: PhaseEnvelope.h:14
CoolPropDbl calc_d4alphar_dDelta_dTau3(void)
Using this backend, calculate the residual Helmholtz energy term (dimensionless) ...
Definition: HelmholtzEOSMixtureBackend.cpp:3186
const std::vector< CoolPropDbl > & get_mole_fractions()
Get the mole fractions of the fluid.
Definition: HelmholtzEOSMixtureBackend.h:267
Definition: MixtureParameters.h:48
virtual 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: HelmholtzEOSMixtureBackend.h:125
CoolPropDbl calc_d4alphar_dDelta3_dTau(void)
Using this backend, calculate the residual Helmholtz energy term (dimensionless) ...
Definition: HelmholtzEOSMixtureBackend.cpp:3176
void update_internal(HelmholtzEOSMixtureBackend &HEOS)
Update all the internal variables for a state by copying from another state.
Definition: HelmholtzEOSMixtureBackend.cpp:1233
virtual HelmholtzDerivatives all(HelmholtzEOSMixtureBackend &HEOS, double tau, double delta, const std::vector< CoolPropDbl > &x, bool cache_values=false)
Calculate all the derivatives that do not involve any composition derivatives.
Definition: HelmholtzEOSMixtureBackend.h:491
CoolPropDbl calc_GWP500()
Using this backend, calculate the 500-year global warming potential (GWP)
Definition: HelmholtzEOSMixtureBackend.cpp:1038
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 calc_cpmolar_idealgas(void)
Using this backend, calculate the ideal gas molar constant-pressure specific heat in J/mol/K...
Definition: HelmholtzEOSMixtureBackend.cpp:2804
const EquationOfState & EOS() const
Get a reference to the equation of state.
Definition: CoolPropFluid.h:484
CoolPropDbl calc_d2alphar_dDelta2(void)
Using this backend, calculate the residual Helmholtz energy term (dimensionless) ...
Definition: HelmholtzEOSMixtureBackend.cpp:3145
CoolPropDbl calc_gas_constant(void)
Using this backend, calculate the universal gas constant in J/mol/K.
Definition: HelmholtzEOSMixtureBackend.cpp:477
void set_binary_interaction_string(const std::size_t i, const std::size_t j, const std::string &parameter, const std::string &value)
Set a binary interaction string.
Definition: HelmholtzEOSMixtureBackend.cpp:330
Definition: Exceptions.h:26
CoolPropDbl calc_d3alphar_dDelta3(void)
Using this backend, calculate the residual Helmholtz energy term (dimensionless) ...
Definition: HelmholtzEOSMixtureBackend.cpp:3150
virtual void get_critical_point_search_radii(double &R_delta, double &R_tau)
Get the search radius in delta and tau for the tracer.
Definition: HelmholtzEOSMixtureBackend.cpp:3798
virtual SpinodalData calc_get_spinodal_data()
Get the data from the spinodal curve.
Definition: HelmholtzEOSMixtureBackend.h:172
double molar_mass
The molar mass in kg/mol (note NOT kg/kmol)
Definition: CoolPropFluid.h:365
std::vector< shared_ptr< HelmholtzEOSMixtureBackend > > linked_states
States that are linked to this one, and should be updated (BIP, reference state, etc.)
Definition: HelmholtzEOSMixtureBackend.h:27
CoolPropDbl calc_surface_tension(void)
Using this backend, calculate the surface tension in N/m.
Definition: HelmholtzEOSMixtureBackend.cpp:578
double Q(void)
Return the vapor quality (mol/mol); Q = 0 for saturated liquid.
Definition: AbstractState.h:708
CoolPropDbl calc_p_reducing(void)
Using this backend, get the reducing point pressure in Pa.
Definition: HelmholtzEOSMixtureBackend.h:413
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
SimpleState reduce
Reducing state used for the EOS (usually, but not always, the critical point)
Definition: CoolPropFluid.h:357
double acentric
The acentric factor .
Definition: CoolPropFluid.h:365
CoolPropDbl calc_alphar(void)
Using this backend, calculate the residual Helmholtz energy term (dimensionless) ...
Definition: HelmholtzEOSMixtureBackend.cpp:3120
CoolPropDbl calc_Tmax(void)
Using this backend, calculate the maximum temperature in K.
Definition: HelmholtzEOSMixtureBackend.cpp:1165
virtual void set_reference_stateD(double T, double rhomolar, double hmolar0, double smolar0)
Set the reference state based on a thermodynamic state point specified by temperature and molar densi...
Definition: HelmholtzEOSMixtureBackend.cpp:3956
void update_TP_guessrho(CoolPropDbl T, CoolPropDbl p, CoolPropDbl rho_guess)
Update with TP and a guess for rho.
Definition: HelmholtzEOSMixtureBackend.cpp:1246
virtual bool get_critical_is_terminated(double &delta, double &tau)
Checking function to see if we should stop the tracing of the critical contour.
Definition: HelmholtzEOSMixtureBackend.h:166
CoolPropDbl calc_smolar_residual(void)
Using this backend, calculate the residual molar entropy in J/mol/K.
Definition: HelmholtzEOSMixtureBackend.h:300
double calc_tangent_plane_distance(const double T, const double p, const std::vector< double > &w, const double rhomolar_guess)
Calculate tangent plane distance for given trial composition w.
Definition: HelmholtzEOSMixtureBackend.cpp:3851
Molar density used for the reducing state.
Definition: DataStructures.h:56
virtual HelmholtzDerivatives all(const CoolPropDbl tau, const CoolPropDbl delta, const std::vector< CoolPropDbl > &mole_fractions, bool cache_values=false)
Calculate all the derivatives that do not involve any composition derivatives.
Definition: ExcessHEFunction.h:235
Acentric factor.
Definition: DataStructures.h:55
shared_ptr< HelmholtzEOSMixtureBackend > critical_state
A temporary state used for calculations of the critical point(s)
Definition: HelmholtzEOSMixtureBackend.h:30
Mole-based density.
Definition: DataStructures.h:80
CoolPropDbl calc_GWP20()
Using this backend, calculate the 20-year global warming potential (GWP)
Definition: HelmholtzEOSMixtureBackend.cpp:1016
CoolPropDbl calc_gibbsmolar(void)
Using this backend, calculate the molar Gibbs function in J/mol.
Definition: HelmholtzEOSMixtureBackend.cpp:2870
CoolPropDbl calc_ODP()
Using this backend, calculate the ozone depletion potential (ODP)
Definition: HelmholtzEOSMixtureBackend.cpp:1005
CriticalState calc_critical_point(double rho0, double T0)
Definition: HelmholtzEOSMixtureBackend.cpp:3516
CoolPropDbl calc_umolar(void)
Using this backend, calculate the molar internal energy in J/mol.
Definition: HelmholtzEOSMixtureBackend.cpp:2733
CoolPropDbl calc_Bvirial(void)
Using this backend, calculate the second virial coefficient.
Definition: HelmholtzEOSMixtureBackend.cpp:1410
CoolPropDbl calc_d3alpha0_dDelta_dTau2(void)
Using this backend, calculate the ideal-gas Helmholtz energy term (dimensionless) ...
Definition: HelmholtzEOSMixtureBackend.cpp:3237
CoolPropDbl calc_hmolar_residual(void)
Using this backend, calculate the residual molar enthalpy in J/mol.
Definition: HelmholtzEOSMixtureBackend.h:304
CoolPropDbl calc_flame_hazard(void)
Using this backend, calculate the flame hazard.
Definition: HelmholtzEOSMixtureBackend.h:325
virtual void set_binary_interaction_double(const std::size_t i, const std::size_t j, const std::string &parameter, const double value)
Set binary mixture floating point parameter.
Definition: HelmholtzEOSMixtureBackend.cpp:303
bool clear()
Clear all the cached values.
Definition: HelmholtzEOSMixtureBackend.h:80
std::vector< CoolProp::CriticalState > calc_all_critical_points()
An overload to make the compiler (clang in this case) happy.
Definition: HelmholtzEOSMixtureBackend.h:157
Definition: Helmholtz.h:46
double p(void)
Return the pressure in Pa.
Definition: AbstractState.h:706
Pressure.
Definition: DataStructures.h:74
void calc_unspecify_phase()
Unspecify the phase - the phase is no longer imposed, different solvers can do as they like...
Definition: HelmholtzEOSMixtureBackend.h:139
virtual void calc_reducing_state(void)
Definition: HelmholtzEOSMixtureBackend.cpp:2985
std::vector< double > mole_fractions_double
A copy of the bulk mole fractions of the mixture stored as doubles.
Definition: HelmholtzEOSMixtureBackend.h:50
double hmolar(void)
Return the molar enthalpy in J/mol.
Definition: AbstractState.cpp:555
phases _phase
The key for the phase from CoolProp::phases enum.
Definition: AbstractState.h:75
Definition: HelmholtzEOSMixtureBackend.h:487
x_N is an independent variable, and not calculated by
Definition: ReducingFunctions.h:18
virtual void set_components(const std::vector< CoolPropFluid > &components, bool generate_SatL_and_SatV=true)
Set the components of the mixture.
Definition: HelmholtzEOSMixtureBackend.cpp:92
CoolPropDbl second_partial_deriv(parameters Of1, parameters Wrt1, parameters Constant1, parameters Wrt2, parameters Constant2)
The second partial derivative in homogeneous phases.
Definition: AbstractState.h:864
void recalculate_singlephase_phase()
Calculate the phase once the state is fully calculated but you aren&#39;t sure if it is liquid or gas or ...
Definition: HelmholtzEOSMixtureBackend.cpp:188
CoolPropDbl calc_d3alpha0_dDelta2_dTau(void)
Using this backend, calculate the ideal-gas Helmholtz energy term (dimensionless) ...
Definition: HelmholtzEOSMixtureBackend.cpp:3232
SimpleState crit
The state at the critical point.
Definition: CoolPropFluid.h:503
This simple class holds the values for guesses for use in some solvers that have the ability to use g...
Definition: AbstractState.h:32
Definition: TransportRoutines.h:8
CoolPropDbl calc_d4alphar_dDelta2_dTau2(void)
Using this backend, calculate the residual Helmholtz energy term (dimensionless) ...
Definition: HelmholtzEOSMixtureBackend.cpp:3181
CoolPropDbl calc_Ttriple(void)
Using this backend, get the triple point temperature in K.
Definition: HelmholtzEOSMixtureBackend.cpp:938
CoolPropDbl alphar(void)
Return the term .
Definition: AbstractState.h:1094
Definition: HelmholtzEOSMixtureBackend.h:22
Triple point pressure.
Definition: DataStructures.h:65
CoolPropDbl calc_d2alphar_dDelta_dTau(void)
Using this backend, calculate the residual Helmholtz energy term (dimensionless) ...
Definition: HelmholtzEOSMixtureBackend.cpp:3140
CoolPropDbl calc_speed_sound(void)
Using this backend, calculate the speed of sound in m/s.
Definition: HelmholtzEOSMixtureBackend.cpp:2817
void set_mass_fractions(const std::vector< CoolPropDbl > &mass_fractions)
Set the mass fractions.
Definition: HelmholtzEOSMixtureBackend.cpp:155
void calc_phase_envelope(const std::string &type)
Using this backend, construct the phase envelope, the variable type describes the type of phase envel...
Definition: HelmholtzEOSMixtureBackend.cpp:395
CoolPropDbl calc_alpha0(void)
Using this backend, calculate the ideal-gas Helmholtz energy term (dimensionless) ...
Definition: HelmholtzEOSMixtureBackend.cpp:3197
virtual CoolPropDbl calc_p_critical(void)
Using this backend, get the critical point pressure in Pa.
Definition: HelmholtzEOSMixtureBackend.cpp:1065
void calc_conformal_state(const std::string &reference_fluid, CoolPropDbl &T, CoolPropDbl &rhomolar)
Calculate the conformal state (unity shape factors starting point if T < 0 and rhomolar < 0) ...
Definition: HelmholtzEOSMixtureBackend.cpp:913
virtual void add_critical_state()
Update the state class used to calculate the critical point(s)
Definition: HelmholtzEOSMixtureBackend.h:37
CoolPropDbl calc_chemical_potential(std::size_t i)
Using this backend, calculate the chemical potential in J/mol.
Definition: HelmholtzEOSMixtureBackend.cpp:2959
This class is a friend class of HelmholtzEOSMixtureBackend, therefore the static methods contained in...
Definition: FlashRoutines.h:28
std::vector< CoolPropDbl > K
The K factors for the components.
Definition: HelmholtzEOSMixtureBackend.h:51
CoolPropDbl calc_d2alpha0_dDelta_dTau(void)
Using this backend, calculate the ideal-gas Helmholtz energy term (dimensionless) ...
Definition: HelmholtzEOSMixtureBackend.cpp:3217
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
This file contains flash routines in which the state is unknown, and a solver of some kind must be us...
Definition: AbstractState.h:19
CoolPropDbl calc_d3alphar_dTau3(void)
Using this backend, calculate the residual Helmholtz energy term (dimensionless) ...
Definition: HelmholtzEOSMixtureBackend.cpp:3165
void update_states()
Update the states after having changed the reference state for enthalpy and entropy.
Definition: HelmholtzEOSMixtureBackend.cpp:409
std::string backend_name(void)
Get a string representation of the backend - for instance "HelmholtzEOSMixtureBackend" for the core m...
Definition: HelmholtzEOSMixtureBackend.h:72
CoolPropDbl dalphar_dTau(void)
Return the term .
Definition: AbstractState.h:1104
CoolPropDbl calc_GWP100()
Using this backend, calculate the 100-year global warming potential (GWP)
Definition: HelmholtzEOSMixtureBackend.cpp:1027
CoolPropDbl calc_viscosity(void)
Using this backend, calculate the viscosity in Pa-s.
Definition: HelmholtzEOSMixtureBackend.cpp:677
const CoolProp::SimpleState & calc_state(const std::string &state)
Using this backend, calculate a phase given by the state string.
Definition: HelmholtzEOSMixtureBackend.cpp:430
parameters
Define some constants that will be used throughout These are constants for the input and output para...
Definition: DataStructures.h:49
std::vector< CoolPropFluid > components
The components that are in use.
Definition: HelmholtzEOSMixtureBackend.h:45
Temperature.
Definition: DataStructures.h:73
CoolPropDbl calc_pressure(void)
Using this backend, calculate the pressure in Pa.
Definition: HelmholtzEOSMixtureBackend.cpp:2590
CoolPropDbl calc_cpmolar(void)
Using this backend, calculate the molar constant-pressure specific heat in J/mol/K.
Definition: HelmholtzEOSMixtureBackend.cpp:2785
CoolPropDbl calc_molar_mass(void)
Using this backend, calculate the molar mass in kg/mol.
Definition: HelmholtzEOSMixtureBackend.cpp:497
CoolPropDbl calc_physical_hazard(void)
Using this backend, calculate the physical hazard.
Definition: HelmholtzEOSMixtureBackend.h:329
This class contains the two primary contributions to the residual Helmholtz energy - a corresponding ...
Definition: HelmholtzEOSMixtureBackend.h:667
CoolPropDbl calc_dBvirial_dT(void)
Using this backend, calculate the derivative dB/dT.
Definition: HelmholtzEOSMixtureBackend.cpp:1414
virtual void set_reference_stateS(const std::string &reference_state)
brief Set the reference state based on a string representation
Definition: HelmholtzEOSMixtureBackend.cpp:3878
This class is a friend class of HelmholtzEOSMixtureBackend, therefore the static methods contained in...
Definition: MixtureDerivatives.h:33
void set_mixture_parameters()
Set the mixture parameters - binary pair reducing functions, departure functions, F_ij...
Definition: HelmholtzEOSMixtureBackend.cpp:404
Definition: DataStructures.h:16