37 m_fluid_names = names;
47 if (generate_SatL_and_SatV) {
48 bool SatLSatV =
false;
57 std::vector<CoolPropDbl> z(1, 1.0);
59 SatL->set_mole_fractions(z);
60 SatV->set_mole_fractions(z);
74 if (components.empty()) {
78 for (std::size_t i = 0; i < N; ++i) {
79 const std::string& alpha_type = components[i].alpha_type;
80 if (alpha_type !=
"default") {
81 const std::vector<double>& c = components[i].alpha_coeffs;
82 shared_ptr<AbstractCubicAlphaFunction> acaf;
83 if (alpha_type ==
"Twu") {
84 acaf.reset(
new TwuAlphaFunction(get_cubic()->a0_ii(i), c[0], c[1], c[2], get_cubic()->get_Tr() / get_cubic()->get_Tc()[i]));
85 }
else if (alpha_type ==
"MathiasCopeman" || alpha_type ==
"Mathias-Copeman") {
89 throw ValueError(
"alpha function is not understood");
91 cubic->set_alpha_function(i, acaf);
98 for (
unsigned int i = 0; i < N; ++i) {
99 summer += mole_fractions[i] * molemass[i];
105 const double value) {
107 if (i < 0 || i >= N) {
108 if (j < 0 || j >= N) {
109 throw ValueError(
format(
"Both indices i [%d] and j [%d] are out of bounds. Must be between 0 and %d.", i, j, N-1));
111 throw ValueError(
format(
"Index i [%d] is out of bounds. Must be between 0 and %d.", i, N-1));
113 }
else if (j < 0 || j >= N) {
114 throw ValueError(
format(
"Index j [%d] is out of bounds. Must be between 0 and %d.", j, N-1));
116 cubic->set_interaction_parameter(i, j, parameter, value);
117 for (std::vector<shared_ptr<HelmholtzEOSMixtureBackend>>::iterator it = linked_states.begin(); it != linked_states.end(); ++it) {
118 (*it)->set_binary_interaction_double(i, j, parameter, value);
123 cubic->set_Q_k(sgi, value);
128 if (i < 0 || i >= N) {
129 if (j < 0 || j >= N) {
130 throw ValueError(
format(
"Both indices i [%d] and j [%d] are out of bounds. Must be between 0 and %d.", i, j, N-1));
132 throw ValueError(
format(
"Index i [%d] is out of bounds. Must be between 0 and %d.", i, N-1));
134 }
else if (j < 0 || j >= N) {
135 throw ValueError(
format(
"Index j [%d] is out of bounds. Must be between 0 and %d.", j, N-1));
137 return cubic->get_interaction_parameter(i, j, parameter);
143 if (UNIFAC_path.empty()) {
144 throw ValueError(
"You must provide the path to the UNIFAC library files as VTPR_UNIFAC_PATH");
146 if (!(UNIFAC_path[UNIFAC_path.size() - 1] ==
'\\' || UNIFAC_path[UNIFAC_path.size() - 1] ==
'/')) {
147 throw ValueError(
"VTPR_UNIFAC_PATH must end with / or \\ character");
149 std::string group_path = UNIFAC_path +
"group_data.json";
151 std::string interaction_path = UNIFAC_path +
"interaction_parameters.json";
153 std::string decomps_path = UNIFAC_path +
"decompositions.json";
155 lib.populate(groups, interaction, decomps);
168 # include <catch2/catch_all.hpp>
174 TEST_CASE(
"VTPR test",
"[VTPR]") {
176 std::vector<double> z(3);
180 VTPR->set_mole_fractions(z);
183 shared_ptr<AbstractCubic> cubic = VTPR->get_cubic();
184 double tau = 0.001, dz = 1e-6;
185 std::vector<double> zp = z, zm = z;
193 double dam_dxi_num = (cubic->am_term(tau, zp, 0) - cubic->am_term(tau, zm, 0)) / (2 * dz);
194 double dam_dxi_ana = cubic->d_am_term_dxi(tau, z, 0, 0,
XN_INDEPENDENT);
195 double diff = dam_dxi_num - dam_dxi_ana;
196 CHECK(std::abs(diff) < 1e-6);