14 #ifndef CUBICBACKEND_H_
15 #define CUBICBACKEND_H_
30 class CubicResidualHelmholtz;
35 shared_ptr<AbstractCubic>
cubic;
39 void setup(
bool generate_SatL_and_SatV =
true);
77 return cubic->get_pc()[i];
80 return cubic->get_Tc()[i];
82 return cubic->get_acentric()[i];
103 return cubic->get_R_u();
108 reducing.
T =
cubic->get_Tr();
122 return cubic->get_Tc()[0];
129 return cubic->get_pc()[0];
136 return cubic->get_acentric()[0];
138 throw ValueError(
"acentric factor cannot be calculated for mixtures");
144 double v_c_Lmol = 2.14107171795 * (
cubic->get_Tc()[0] /
cubic->get_pc()[0] * 1000) + 0.00773144012514;
145 return 1 / (v_c_Lmol / 1000.0);
226 throw ValueError(
"set_binary_interaction_double not defined for AbstractCubic not defined for CAS #");
229 throw ValueError(
"get_binary_interaction_double not defined for AbstractCubic not defined for CAS #");
245 void set_cubic_alpha_C(
const size_t i,
const std::string& parameter,
const double c1,
const double c2,
const double c3);
258 SRKBackend(
const std::vector<double>& Tc,
const std::vector<double>& pc,
const std::vector<double>& acentric,
double R_u,
259 bool generate_SatL_and_SatV =
true) {
260 cubic.reset(
new SRK(Tc, pc, acentric, R_u));
261 setup(generate_SatL_and_SatV);
263 SRKBackend(
double Tc,
double pc,
double acentric,
double R_u,
bool generate_SatL_and_SatV =
true) {
264 cubic.reset(
new SRK(Tc, pc, acentric, R_u));
265 setup(generate_SatL_and_SatV);
268 bool generate_SatL_and_SatV =
true) {
269 std::vector<double> Tc, pc, acentric;
270 N = fluid_identifiers.size();
272 for (std::size_t i = 0; i < fluid_identifiers.size(); ++i) {
278 cubic.reset(
new SRK(Tc, pc, acentric, R_u));
279 setup(generate_SatL_and_SatV);
296 PengRobinsonBackend(
const std::vector<double>& Tc,
const std::vector<double>& pc,
const std::vector<double>& acentric,
double R_u,
297 bool generate_SatL_and_SatV =
true) {
299 setup(generate_SatL_and_SatV);
301 PengRobinsonBackend(
double Tc,
double pc,
double acentric,
double R_u,
bool generate_SatL_and_SatV =
true) {
303 setup(generate_SatL_and_SatV);
306 bool generate_SatL_and_SatV =
true) {
307 std::vector<double> Tc, pc, acentric;
308 N = fluid_identifiers.size();
310 for (std::size_t i = 0; i < fluid_identifiers.size(); ++i) {
317 setup(generate_SatL_and_SatV);
354 bool cache_values =
false) {
356 std::vector<double> z = std::vector<double>(mole_fractions.begin(), mole_fractions.end());
358 a.alphar = cubic->alphar(tau, delta, z, 0, 0);
359 a.dalphar_dtau = cubic->alphar(tau, delta, z, 1, 0);
360 a.dalphar_ddelta = cubic->alphar(tau, delta, z, 0, 1);
361 a.d2alphar_dtau2 = cubic->alphar(tau, delta, z, 2, 0);
362 a.d2alphar_ddelta_dtau = cubic->alphar(tau, delta, z, 1, 1);
363 a.d2alphar_ddelta2 = cubic->alphar(tau, delta, z, 0, 2);
364 a.d3alphar_dtau3 = cubic->alphar(tau, delta, z, 3, 0);
365 a.d3alphar_ddelta_dtau2 = cubic->alphar(tau, delta, z, 2, 1);
366 a.d3alphar_ddelta2_dtau = cubic->alphar(tau, delta, z, 1, 2);
367 a.d3alphar_ddelta3 = cubic->alphar(tau, delta, z, 0, 3);
368 a.d4alphar_dtau4 = cubic->alphar(tau, delta, z, 4, 0);
369 a.d4alphar_ddelta_dtau3 = cubic->alphar(tau, delta, z, 3, 1);
370 a.d4alphar_ddelta2_dtau2 = cubic->alphar(tau, delta, z, 2, 2);
371 a.d4alphar_ddelta3_dtau = cubic->alphar(tau, delta, z, 1, 3);
372 a.d4alphar_ddelta4 = cubic->alphar(tau, delta, z, 0, 4);