CoolProp 8.0.0
An open-source fluid property and humid air property database
AbstractState.h
Go to the documentation of this file.
1/*
2 * AbstractState.h
3 *
4 * Created on: 21 Dec 2013
5 * Author: jowr
6 */
7
8#ifndef ABSTRACTSTATE_H_
9#define ABSTRACTSTATE_H_
10
12#include "CoolProp/Exceptions.h"
15#include <memory>
16using std::shared_ptr;
17
18namespace CoolProp {
19
23{
24 public:
25 std::vector<double> tau,
28};
29
33{
34 public:
35 double T,
36 p,
42 std::vector<double> x,
43 y;
45 clear();
46 };
47 void clear() {
48 T = _HUGE;
49 p = _HUGE;
50 rhomolar = _HUGE;
51 hmolar = _HUGE;
52 smolar = _HUGE;
53 rhomolar_liq = _HUGE;
54 rhomolar_vap = _HUGE;
55 x.clear(), y.clear();
56 }
57};
58
60
78{
79 protected:
84
86 return (this->_phase == iphase_supercritical || this->_phase == iphase_supercritical_liquid || this->_phase == iphase_supercritical_gas);
87 }
88
90 return (this->_phase == iphase_liquid || this->_phase == iphase_gas || isSupercriticalPhase() || this->_phase == iphase_critical_point);
91 }
92
93 bool isTwoPhase() {
94 return (this->_phase == iphase_twophase);
95 }
96
99
102
105
108
110 double _rhomolar, _T, _p, _Q;
111
113
116
120
123
127
130
132
135
144
147
151
152 // ----------------------------------------
153 // Property accessors to be optionally implemented by the backend
154 // for properties that are not always calculated
155 // ----------------------------------------
158 throw NotImplementedError("calc_hmolar is not implemented for this backend");
159 };
162 throw NotImplementedError("calc_hmolar_residual is not implemented for this backend");
163 };
166 throw NotImplementedError("calc_smolar is not implemented for this backend");
167 };
170 throw NotImplementedError("calc_smolar_residual is not implemented for this backend");
171 };
174 throw NotImplementedError("calc_neff is not implemented for this backend");
175 };
178 throw NotImplementedError("calc_umolar is not implemented for this backend");
179 };
182 throw NotImplementedError("calc_cpmolar is not implemented for this backend");
183 };
186 throw NotImplementedError("calc_cpmolar_idealgas is not implemented for this backend");
187 };
190 throw NotImplementedError("calc_cvmolar is not implemented for this backend");
191 };
194 throw NotImplementedError("calc_gibbsmolar is not implemented for this backend");
195 };
198 throw NotImplementedError("calc_gibbsmolar_residual is not implemented for this backend");
199 };
202 throw NotImplementedError("calc_helmholtzmolar is not implemented for this backend");
203 };
206 throw NotImplementedError("calc_speed_sound is not implemented for this backend");
207 };
210 throw NotImplementedError("calc_isothermal_compressibility is not implemented for this backend");
211 };
214 throw NotImplementedError("calc_isobaric_expansion_coefficient is not implemented for this backend");
215 };
218 throw NotImplementedError("calc_isentropic_expansion_coefficient is not implemented for this backend");
219 };
222 throw NotImplementedError("calc_viscosity is not implemented for this backend");
223 };
226 throw NotImplementedError("calc_conductivity is not implemented for this backend");
227 };
230 throw NotImplementedError("calc_surface_tension is not implemented for this backend");
231 };
234 throw NotImplementedError("calc_molar_mass is not implemented for this backend");
235 };
238 throw NotImplementedError("calc_acentric_factor is not implemented for this backend");
239 };
242 throw NotImplementedError("calc_pressure is not implemented for this backend");
243 };
246 throw NotImplementedError("calc_gas_constant is not implemented for this backend");
247 };
249 virtual CoolPropDbl calc_fugacity_coefficient(std::size_t i) {
250 throw NotImplementedError("calc_fugacity_coefficient is not implemented for this backend");
251 };
253 virtual std::vector<CoolPropDbl> calc_fugacity_coefficients() {
254 throw NotImplementedError("calc_fugacity_coefficients is not implemented for this backend");
255 };
257 virtual CoolPropDbl calc_fugacity(std::size_t i) {
258 throw NotImplementedError("calc_fugacity is not implemented for this backend");
259 };
261 virtual CoolPropDbl calc_chemical_potential(std::size_t i) {
262 throw NotImplementedError("calc_chemical_potential is not implemented for this backend");
263 };
266 throw NotImplementedError("calc_PIP is not implemented for this backend");
267 };
268
271 virtual CoolPropDbl calc_Qmass();
272
275 {
276 double liquid;
277 double vapor;
278 };
279
284
287 virtual void update_Qmass_pair(CoolProp::input_pairs pair, double v1, double v2);
288
289 // Excess properties
291 virtual void calc_excess_properties() {
292 throw NotImplementedError("calc_excess_properties is not implemented for this backend");
293 };
294
295 // Derivatives of residual helmholtz energy
298 throw NotImplementedError("calc_alphar is not implemented for this backend");
299 };
302 throw NotImplementedError("calc_dalphar_dDelta is not implemented for this backend");
303 };
306 throw NotImplementedError("calc_dalphar_dTau is not implemented for this backend");
307 };
310 throw NotImplementedError("calc_d2alphar_dDelta2 is not implemented for this backend");
311 };
314 throw NotImplementedError("calc_d2alphar_dDelta_dTau is not implemented for this backend");
315 };
318 throw NotImplementedError("calc_d2alphar_dTau2 is not implemented for this backend");
319 };
322 throw NotImplementedError("calc_d3alphar_dDelta3 is not implemented for this backend");
323 };
326 throw NotImplementedError("calc_d3alphar_dDelta2_dTau is not implemented for this backend");
327 };
330 throw NotImplementedError("calc_d3alphar_dDelta_dTau2 is not implemented for this backend");
331 };
334 throw NotImplementedError("calc_d3alphar_dTau3 is not implemented for this backend");
335 };
336
339 throw NotImplementedError("calc_d4alphar_dDelta4 is not implemented for this backend");
340 };
343 throw NotImplementedError("calc_d4alphar_dDelta3_dTau is not implemented for this backend");
344 };
347 throw NotImplementedError("calc_d4alphar_dDelta2_dTau2 is not implemented for this backend");
348 };
351 throw NotImplementedError("calc_d4alphar_dDelta_dTau3 is not implemented for this backend");
352 };
355 throw NotImplementedError("calc_d4alphar_dTau4 is not implemented for this backend");
356 };
357
358 // Derivatives of ideal-gas helmholtz energy
361 throw NotImplementedError("calc_alpha0 is not implemented for this backend");
362 };
365 throw NotImplementedError("calc_dalpha0_dDelta is not implemented for this backend");
366 };
369 throw NotImplementedError("calc_dalpha0_dTau is not implemented for this backend");
370 };
373 throw NotImplementedError("calc_d2alpha0_dDelta_dTau is not implemented for this backend");
374 };
377 throw NotImplementedError("calc_d2alpha0_dDelta2 is not implemented for this backend");
378 };
381 throw NotImplementedError("calc_d2alpha0_dTau2 is not implemented for this backend");
382 };
385 throw NotImplementedError("calc_d3alpha0_dDelta3 is not implemented for this backend");
386 };
389 throw NotImplementedError("calc_d3alpha0_dDelta2_dTau is not implemented for this backend");
390 };
393 throw NotImplementedError("calc_d3alpha0_dDelta_dTau2 is not implemented for this backend");
394 };
397 throw NotImplementedError("calc_d3alpha0_dTau3 is not implemented for this backend");
398 };
399
400 virtual void calc_reducing_state() {
401 throw NotImplementedError("calc_reducing_state is not implemented for this backend");
402 };
403
406 throw NotImplementedError("calc_Tmax is not implemented for this backend");
407 };
410 throw NotImplementedError("calc_Tmin is not implemented for this backend");
411 };
414 throw NotImplementedError("calc_pmax is not implemented for this backend");
415 };
416
419 throw NotImplementedError("calc_GWP20 is not implemented for this backend");
420 };
423 throw NotImplementedError("calc_GWP100 is not implemented for this backend");
424 };
427 throw NotImplementedError("calc_GWP500 is not implemented for this backend");
428 };
431 throw NotImplementedError("calc_ODP is not implemented for this backend");
432 };
435 throw NotImplementedError("calc_flame_hazard is not implemented for this backend");
436 };
439 throw NotImplementedError("calc_health_hazard is not implemented for this backend");
440 };
443 throw NotImplementedError("calc_physical_hazard is not implemented for this backend");
444 };
447 throw NotImplementedError("calc_dipole_moment is not implemented for this backend");
448 };
449
453 virtual CoolPropDbl calc_second_partial_deriv(parameters Of1, parameters Wrt1, parameters Constant1, parameters Wrt2, parameters Constant2);
454
457 throw NotImplementedError("calc_reduced_density is not implemented for this backend");
458 };
461 throw NotImplementedError("calc_reciprocal_reduced_temperature is not implemented for this backend");
462 };
463
466 throw NotImplementedError("calc_Bvirial is not implemented for this backend");
467 };
470 throw NotImplementedError("calc_Cvirial is not implemented for this backend");
471 };
474 throw NotImplementedError("calc_dBvirial_dT is not implemented for this backend");
475 };
478 throw NotImplementedError("calc_dCvirial_dT is not implemented for this backend");
479 };
482 throw NotImplementedError("calc_compressibility_factor is not implemented for this backend");
483 };
484
486 virtual std::string calc_name() {
487 throw NotImplementedError("calc_name is not implemented for this backend");
488 };
490 virtual std::string calc_description() {
491 throw NotImplementedError("calc_description is not implemented for this backend");
492 };
493
496 throw NotImplementedError("calc_Ttriple is not implemented for this backend");
497 };
500 throw NotImplementedError("calc_p_triple is not implemented for this backend");
501 };
502
505 throw NotImplementedError("calc_T_critical is not implemented for this backend");
506 };
509 throw NotImplementedError("calc_T_reducing is not implemented for this backend");
510 };
513 throw NotImplementedError("calc_p_critical is not implemented for this backend");
514 };
517 throw NotImplementedError("calc_p_reducing is not implemented for this backend");
518 };
521 throw NotImplementedError("calc_rhomolar_critical is not implemented for this backend");
522 };
525 throw NotImplementedError("calc_rhomass_critical is not implemented for this backend");
526 };
529 throw NotImplementedError("calc_rhomolar_reducing is not implemented for this backend");
530 };
532 virtual void calc_phase_envelope(const std::string& type) {
533 throw NotImplementedError("calc_phase_envelope is not implemented for this backend");
534 };
537 return rhomolar() * molar_mass();
538 }
540 return hmolar() / molar_mass();
541 }
543 return hmolar_excess() / molar_mass();
544 }
546 return smolar() / molar_mass();
547 }
549 return smolar_excess() / molar_mass();
550 }
552 return cpmolar() / molar_mass();
553 }
555 return cp0molar() / molar_mass();
556 }
558 return cvmolar() / molar_mass();
559 }
561 return umolar() / molar_mass();
562 }
564 return umolar_excess() / molar_mass();
565 }
567 return gibbsmolar() / molar_mass();
568 }
570 return gibbsmolar_excess() / molar_mass();
571 }
573 return helmholtzmolar() / molar_mass();
574 }
577 }
579 return volumemolar_excess() / molar_mass();
580 }
581
583 virtual void update_states() {
584 throw NotImplementedError("This backend does not implement update_states function");
585 };
586
587 virtual CoolPropDbl calc_melting_line(int param, int given, CoolPropDbl value) {
588 throw NotImplementedError("This backend does not implement calc_melting_line function");
589 };
590
595 virtual CoolPropDbl calc_saturation_ancillary(parameters param, int Q, parameters given, double value) {
596 throw NotImplementedError("This backend does not implement calc_saturation_ancillary");
597 };
598
600 virtual phases calc_phase() {
601 throw NotImplementedError("This backend does not implement calc_phase function");
602 };
605 throw NotImplementedError("This backend does not implement calc_specify_phase function");
606 };
608 virtual void calc_unspecify_phase() {
609 throw NotImplementedError("This backend does not implement calc_unspecify_phase function");
610 };
612 virtual std::vector<std::string> calc_fluid_names() {
613 throw NotImplementedError("This backend does not implement calc_fluid_names function");
614 };
617 virtual const CoolProp::SimpleState& calc_state(const std::string& state) {
618 throw NotImplementedError("calc_state is not implemented for this backend");
619 };
620
622 throw NotImplementedError("calc_phase_envelope_data is not implemented for this backend");
623 };
624
625 virtual std::vector<CoolPropDbl> calc_mole_fractions_liquid() {
626 throw NotImplementedError("calc_mole_fractions_liquid is not implemented for this backend");
627 };
628 virtual std::vector<CoolPropDbl> calc_mole_fractions_vapor() {
629 throw NotImplementedError("calc_mole_fractions_vapor is not implemented for this backend");
630 };
631 virtual const std::vector<CoolPropDbl> calc_mass_fractions() {
632 throw NotImplementedError("calc_mass_fractions is not implemented for this backend");
633 };
634
637 throw NotImplementedError("calc_fraction_min is not implemented for this backend");
638 };
641 throw NotImplementedError("calc_fraction_max is not implemented for this backend");
642 };
644 throw NotImplementedError("calc_T_freeze is not implemented for this backend");
645 };
646
648 throw NotImplementedError("calc_first_saturation_deriv is not implemented for this backend");
649 };
651 throw NotImplementedError("calc_second_saturation_deriv is not implemented for this backend");
652 };
654 throw NotImplementedError("calc_first_two_phase_deriv is not implemented for this backend");
655 };
657 throw NotImplementedError("calc_second_two_phase_deriv is not implemented for this backend");
658 };
660 throw NotImplementedError("calc_first_two_phase_deriv_splined is not implemented for this backend");
661 };
662
664 throw NotImplementedError("calc_saturated_liquid_keyed_output is not implemented for this backend");
665 };
667 throw NotImplementedError("calc_saturated_vapor_keyed_output is not implemented for this backend");
668 };
669 virtual void calc_ideal_curve(const std::string& type, std::vector<double>& T, std::vector<double>& p) {
670 throw NotImplementedError("calc_ideal_curve is not implemented for this backend");
671 };
672
674 virtual CoolPropDbl calc_T() {
675 return _T;
676 }
679 return _rhomolar;
680 }
681
683 virtual double calc_tangent_plane_distance(const double T, const double p, const std::vector<double>& w, const double rhomolar_guess) {
684 throw NotImplementedError("calc_tangent_plane_distance is not implemented for this backend");
685 };
686
688 virtual void calc_true_critical_point(double& T, double& rho) {
689 throw NotImplementedError("calc_true_critical_point is not implemented for this backend");
690 };
691
692 virtual void calc_conformal_state(const std::string& reference_fluid, CoolPropDbl& T, CoolPropDbl& rhomolar) {
693 throw NotImplementedError("calc_conformal_state is not implemented for this backend");
694 };
695
696 virtual void calc_viscosity_contributions(CoolPropDbl& dilute, CoolPropDbl& initial_density, CoolPropDbl& residual, CoolPropDbl& critical) {
697 throw NotImplementedError("calc_viscosity_contributions is not implemented for this backend");
698 };
699 virtual void calc_conductivity_contributions(CoolPropDbl& dilute, CoolPropDbl& initial_density, CoolPropDbl& residual, CoolPropDbl& critical) {
700 throw NotImplementedError("calc_conductivity_contributions is not implemented for this backend");
701 };
702 virtual std::vector<CriticalState> calc_all_critical_points() {
703 throw NotImplementedError("calc_all_critical_points is not implemented for this backend");
704 };
705 virtual void calc_build_spinodal() {
706 throw NotImplementedError("calc_build_spinodal is not implemented for this backend");
707 };
709 throw NotImplementedError("calc_get_spinodal_data is not implemented for this backend");
710 };
711 virtual void calc_criticality_contour_values(double& L1star, double& M1star) {
712 throw NotImplementedError("calc_criticality_contour_values is not implemented for this backend");
713 };
714
716 virtual void mass_to_molar_inputs(CoolProp::input_pairs& input_pair, CoolPropDbl& value1, CoolPropDbl& value2);
717
719 virtual void calc_change_EOS(const std::size_t i, const std::string& EOS_name) {
720 throw NotImplementedError("calc_change_EOS is not implemented for this backend");
721 };
722
723 public:
725 // Explicit scope: a virtual `clear()` call from the base ctor
726 // would dispatch to this class anyway (derived overrides aren't
727 // active yet), so call it directly to make that intent visible
728 // and silence clang-analyzer-optin.cplusplus.VirtualCall.
730 }
731 virtual ~AbstractState() = default;
732
734
740 static AbstractState* factory(const std::string& backend, const std::string& fluid_names) {
741 return factory(backend, strsplit(fluid_names, '&'));
742 };
743
767 static AbstractState* factory(const std::string& backend, const std::vector<std::string>& fluid_names);
768
771 _T = T;
772 }
773
778 virtual std::string backend_name() = 0;
779
787 virtual std::string build_options_json() const {
788 return "";
789 }
790
791 // The derived classes must implement this function to define whether they use mole fractions (true) or mass fractions (false)
792 virtual bool using_mole_fractions() = 0;
793 virtual bool using_mass_fractions() = 0;
794 virtual bool using_volu_fractions() = 0;
795
796 virtual void set_mole_fractions(const std::vector<CoolPropDbl>& mole_fractions) = 0;
797 virtual void set_mass_fractions(const std::vector<CoolPropDbl>& mass_fractions) = 0;
798 virtual void set_volu_fractions(const std::vector<CoolPropDbl>& mass_fractions) {
799 throw NotImplementedError("Volume composition has not been implemented.");
800 }
801
821 virtual void set_reference_stateS(const std::string& reference_state) {
823 "Setting reference state has not been implemented for this backend. Try using CoolProp::set_reference_stateD instead.");
824 }
825
831 virtual void set_reference_stateD(double T, double rhomolar, double hmolar0, double smolar0) {
833 "Setting reference state has not been implemented for this backend. Try using CoolProp::set_reference_stateD instead.");
834 }
835
836#ifndef COOLPROPDBL_MAPS_TO_DOUBLE
837 void set_mole_fractions(const std::vector<double>& mole_fractions) {
838 set_mole_fractions(std::vector<CoolPropDbl>(mole_fractions.begin(), mole_fractions.end()));
839 };
840 void set_mass_fractions(const std::vector<double>& mass_fractions) {
841 set_mass_fractions(std::vector<CoolPropDbl>(mass_fractions.begin(), mass_fractions.end()));
842 };
843 void set_volu_fractions(const std::vector<double>& volu_fractions) {
844 set_volu_fractions(std::vector<CoolPropDbl>(volu_fractions.begin(), volu_fractions.end()));
845 };
846#endif
847
849 std::vector<CoolPropDbl> mole_fractions_liquid() {
851 };
853 std::vector<double> mole_fractions_liquid_double() {
854 std::vector<CoolPropDbl> x = calc_mole_fractions_liquid();
855 return {x.begin(), x.end()};
856 };
857
859 std::vector<CoolPropDbl> mole_fractions_vapor() {
861 };
863 std::vector<double> mole_fractions_vapor_double() {
864 std::vector<CoolPropDbl> y = calc_mole_fractions_vapor();
865 return {y.begin(), y.end()};
866 };
867
869 virtual const std::vector<CoolPropDbl>& get_mole_fractions() = 0;
871 virtual const std::vector<CoolPropDbl> get_mass_fractions() {
872 return this->calc_mass_fractions();
873 };
874
876 virtual void update(CoolProp::input_pairs input_pair, double Value1, double Value2) = 0;
877
879 virtual void update_QT_pure_superanc(double Q, double T) {
880 throw NotImplementedError("update_QT_pure_superanc is not implemented for this backend");
881 };
882
885 virtual void update_with_guesses(CoolProp::input_pairs input_pair, double Value1, double Value2, const GuessesStructure& guesses) {
886 throw NotImplementedError("update_with_guesses is not implemented for this backend");
887 };
888
920 virtual void fast_evaluate(CoolProp::input_pairs input_pair, const double* val1, const double* val2, std::size_t N_inputs,
921 const CoolProp::parameters* outputs, std::size_t N_outputs, double* out_buffer, std::size_t out_buffer_size,
922 int* status_flags, std::size_t status_flags_size, CoolProp::phases imposed_phase = CoolProp::iphase_not_imposed) {
923 throw NotImplementedError("fast_evaluate is not implemented for this backend");
924 };
925
929 virtual bool available_in_high_level() {
930 return true;
931 }
932
934 virtual std::string fluid_param_string(const std::string&) {
935 throw NotImplementedError("fluid_param_string has not been implemented for this backend");
936 }
937
939 std::vector<std::string> fluid_names();
940
945 virtual const double get_fluid_constant(std::size_t i, parameters param) const {
946 throw NotImplementedError("get_fluid_constant is not implemented for this backend");
947 };
948
950 virtual void set_binary_interaction_double(const std::string& CAS1, const std::string& CAS2, const std::string& parameter, const double value) {
951 throw NotImplementedError("set_binary_interaction_double is not implemented for this backend");
952 };
954 virtual void set_binary_interaction_double(const std::size_t i, const std::size_t j, const std::string& parameter, const double value) {
955 throw NotImplementedError("set_binary_interaction_double is not implemented for this backend");
956 };
958 virtual void set_binary_interaction_string(const std::string& CAS1, const std::string& CAS2, const std::string& parameter,
959 const std::string& value) {
960 throw NotImplementedError("set_binary_interaction_string is not implemented for this backend");
961 };
963 virtual void set_binary_interaction_string(const std::size_t i, const std::size_t j, const std::string& parameter, const std::string& value) {
964 throw NotImplementedError("set_binary_interaction_string is not implemented for this backend");
965 };
967 virtual double get_binary_interaction_double(const std::string& CAS1, const std::string& CAS2, const std::string& parameter) {
968 throw NotImplementedError("get_binary_interaction_double is not implemented for this backend");
969 };
971 virtual double get_binary_interaction_double(const std::size_t i, const std::size_t j, const std::string& parameter) {
972 throw NotImplementedError("get_binary_interaction_double is not implemented for this backend");
973 };
975 virtual std::string get_binary_interaction_string(const std::string& CAS1, const std::string& CAS2, const std::string& parameter) {
976 throw NotImplementedError("get_binary_interaction_string is not implemented for this backend");
977 };
979 virtual void apply_simple_mixing_rule(std::size_t i, std::size_t j, const std::string& model) {
980 throw NotImplementedError("apply_simple_mixing_rule is not implemented for this backend");
981 };
983 virtual void set_cubic_alpha_C(const size_t i, const std::string& parameter, const double c1, const double c2, const double c3) {
984 throw ValueError("set_cubic_alpha_C only defined for cubic backends");
985 };
987 virtual void set_fluid_parameter_double(const size_t i, const std::string& parameter, const double value) {
988 throw ValueError("set_fluid_parameter_double only defined for cubic backends");
989 };
991 virtual double get_fluid_parameter_double(const size_t i, const std::string& parameter) {
992 throw ValueError("get_fluid_parameter_double only defined for cubic backends");
993 };
994
996 virtual bool clear();
998 virtual bool clear_comp_change();
999
1004 return _reducing;
1005 };
1006
1008 const CoolProp::SimpleState& get_state(const std::string& state) {
1009 return calc_state(state);
1010 };
1011
1013 double Tmin();
1015 double Tmax();
1017 double pmax();
1019 double Ttriple();
1020
1023 return calc_phase();
1024 };
1028 };
1032 };
1033
1035 double T_critical();
1037 double p_critical();
1039 double rhomolar_critical();
1041 double rhomass_critical();
1042
1044 std::vector<CriticalState> all_critical_points() {
1045 return calc_all_critical_points();
1046 };
1047
1051 };
1052
1055 return calc_get_spinodal_data();
1056 };
1057
1059 void criticality_contour_values(double& L1star, double& M1star) {
1060 return calc_criticality_contour_values(L1star, M1star);
1061 }
1062
1086 double tangent_plane_distance(const double T, const double p, const std::vector<double>& w, const double rhomolar_guess = -1) {
1087 return calc_tangent_plane_distance(T, p, w, rhomolar_guess);
1088 };
1089
1091 double T_reducing();
1093 double rhomolar_reducing();
1095 double rhomass_reducing();
1096
1098 double p_triple();
1099
1101 std::string name() {
1102 return calc_name();
1103 };
1105 std::string description() {
1106 return calc_description();
1107 };
1108
1110 double dipole_moment() {
1111 return calc_dipole_moment();
1112 }
1113
1114 // ----------------------------------------
1115 // Bulk properties - temperature and density are directly calculated every time
1116 // All other parameters are calculated on an as-needed basis
1117 // ----------------------------------------
1119 double keyed_output(parameters key);
1121 double trivial_keyed_output(parameters key);
1125 };
1129 };
1130
1132 double T() {
1133 return calc_T();
1134 };
1136 double rhomolar() {
1137 return calc_rhomolar();
1138 };
1140 double rhomass() {
1141 return calc_rhomass();
1142 };
1144 double p() {
1145 return _p;
1146 };
1148 double Q() {
1149 return _Q;
1150 };
1152 double Qmass();
1154 double tau();
1156 double delta();
1158 double molar_mass();
1160 double acentric_factor();
1162 double gas_constant();
1164 double Bvirial();
1166 double dBvirial_dT();
1168 double Cvirial();
1170 double dCvirial_dT();
1172 double compressibility_factor();
1174 double hmolar();
1176 double hmolar_residual();
1178 double hmolar_idealgas();
1180 double hmass_idealgas();
1182 double hmass() {
1183 return calc_hmass();
1184 };
1186 double hmolar_excess();
1188 double hmass_excess() {
1189 return calc_hmass_excess();
1190 };
1192 double smolar();
1194 double smolar_residual();
1196 double smolar_idealgas();
1198 double smass_idealgas();
1200 double neff();
1202 double smass() {
1203 return calc_smass();
1204 };
1206 double smolar_excess();
1208 double smass_excess() {
1209 return calc_smass_excess();
1210 };
1212 double umolar();
1214 double umass() {
1215 return calc_umass();
1216 };
1218 double umolar_excess();
1220 double umass_excess() {
1221 return calc_umass_excess();
1222 };
1224 double umolar_idealgas();
1226 double umass_idealgas();
1228 double cpmolar();
1230 double cpmass() {
1231 return calc_cpmass();
1232 };
1234 double cp0molar();
1236 double cp0mass() {
1237 return calc_cp0mass();
1238 };
1240 double cvmolar();
1242 double cvmass() {
1243 return calc_cvmass();
1244 };
1246 double gibbsmolar();
1248 double gibbsmolar_residual();
1250 double gibbsmass() {
1251 return calc_gibbsmass();
1252 };
1254 double gibbsmolar_excess();
1257 return calc_gibbsmass_excess();
1258 };
1260 double helmholtzmolar();
1262 double helmholtzmass() {
1263 return calc_helmholtzmass();
1264 };
1266 double helmholtzmolar_excess();
1270 };
1272 double volumemolar_excess();
1275 return calc_volumemass_excess();
1276 };
1278 double speed_sound();
1286 double fugacity_coefficient(std::size_t i);
1288 std::vector<double> fugacity_coefficients();
1290 double fugacity(std::size_t i);
1292 double chemical_potential(std::size_t i);
1303 double PIP() {
1304 return calc_PIP();
1305 };
1306
1308 void true_critical_point(double& T, double& rho) {
1310 }
1311
1319 void ideal_curve(const std::string& type, std::vector<double>& T, std::vector<double>& p) {
1320 calc_ideal_curve(type, T, p);
1321 };
1322
1323 // ----------------------------------------
1324 // Partial derivatives
1325 // ----------------------------------------
1326
1332 return calc_first_partial_deriv(Of, Wrt, Constant);
1333 };
1334
1359 return calc_second_partial_deriv(Of1, Wrt1, Constant1, Wrt2, Constant2);
1360 };
1361
1384 return calc_first_saturation_deriv(Of1, Wrt1);
1385 };
1386
1405 return calc_second_saturation_deriv(Of1, Wrt1, Wrt2);
1406 };
1407
1428 return calc_first_two_phase_deriv(Of, Wrt, Constant);
1429 };
1430
1447 double second_two_phase_deriv(parameters Of, parameters Wrt1, parameters Constant1, parameters Wrt2, parameters Constant2) {
1448 return calc_second_two_phase_deriv(Of, Wrt1, Constant1, Wrt2, Constant2);
1449 };
1450
1471 double first_two_phase_deriv_splined(parameters Of, parameters Wrt, parameters Constant, double x_end) {
1472 return calc_first_two_phase_deriv_splined(Of, Wrt, Constant, x_end);
1473 };
1474
1475 // ----------------------------------------
1476 // Phase envelope for mixtures
1477 // ----------------------------------------
1478
1484 void build_phase_envelope(const std::string& type = "");
1489 return calc_phase_envelope_data();
1490 };
1491
1492 // ----------------------------------------
1493 // Ancillary equations
1494 // ----------------------------------------
1495
1497 virtual bool has_melting_line() {
1498 return false;
1499 };
1504 double melting_line(int param, int given, double value);
1510 double saturation_ancillary(parameters param, int Q, parameters given, double value);
1511
1512 // ----------------------------------------
1513 // Transport properties
1514 // ----------------------------------------
1516 double viscosity();
1518 void viscosity_contributions(CoolPropDbl& dilute, CoolPropDbl& initial_density, CoolPropDbl& residual, CoolPropDbl& critical) {
1519 calc_viscosity_contributions(dilute, initial_density, residual, critical);
1520 };
1522 double conductivity();
1524 void conductivity_contributions(CoolPropDbl& dilute, CoolPropDbl& initial_density, CoolPropDbl& residual, CoolPropDbl& critical) {
1525 calc_conductivity_contributions(dilute, initial_density, residual, critical);
1526 };
1528 double surface_tension();
1530 double Prandtl() {
1531 return cpmass() * viscosity() / conductivity();
1532 };
1539 void conformal_state(const std::string& reference_fluid, CoolPropDbl& T, CoolPropDbl& rhomolar) {
1540 return calc_conformal_state(reference_fluid, T, rhomolar);
1541 };
1542
1547 void change_EOS(const std::size_t i, const std::string& EOS_name) {
1548 calc_change_EOS(i, EOS_name);
1549 }
1550
1551 // ----------------------------------------
1552 // Helmholtz energy and derivatives
1553 // ----------------------------------------
1556 if (!_alpha0) _alpha0 = calc_alpha0();
1557 return _alpha0;
1558 };
1562 return _dalpha0_dDelta;
1563 };
1567 return _dalpha0_dTau;
1568 };
1572 return _d2alpha0_dDelta2;
1573 };
1577 return _d2alpha0_dDelta_dTau;
1578 };
1582 return _d2alpha0_dTau2;
1583 };
1587 return _d3alpha0_dTau3;
1588 };
1593 };
1598 };
1602 return _d3alpha0_dDelta3;
1603 };
1604
1607 if (!_alphar) _alphar = calc_alphar();
1608 return _alphar;
1609 };
1613 return _dalphar_dDelta;
1614 };
1618 return _dalphar_dTau;
1619 };
1623 return _d2alphar_dDelta2;
1624 };
1628 return _d2alphar_dDelta_dTau;
1629 };
1633 return _d2alphar_dTau2;
1634 };
1638 return _d3alphar_dDelta3;
1639 };
1644 };
1649 };
1653 return _d3alphar_dTau3;
1654 };
1658 return _d4alphar_dDelta4;
1659 };
1664 };
1669 };
1674 };
1678 return _d4alphar_dTau4;
1679 };
1680};
1681
1690{
1691 public:
1692 virtual AbstractState* get_AbstractState(const std::vector<std::string>& fluid_names) = 0;
1693
1702 virtual AbstractState* get_AbstractState(const std::vector<std::string>& fluid_names, const std::string& options_json);
1703
1704 virtual ~AbstractStateGenerator() = default;
1705};
1706
1710void register_backend(const backend_families& bf, const shared_ptr<AbstractStateGenerator>& gen);
1711
1712template <class T>
1714{
1715 public:
1717 register_backend(bf, std::make_shared<T>());
1718 };
1719};
1720
1721} /* namespace CoolProp */
1722#endif /* ABSTRACTSTATE_H_ */