teqp 0.22.0
Loading...
Searching...
No Matches
association_types.hpp
Go to the documentation of this file.
1#pragma once
2#include "teqp/constants.hpp"
3
4namespace teqp {
5namespace association{
6
8
9inline auto get_association_classes(const std::string& s) {
10 if (s == "1A") { return association_classes::a1A; }
11 else if (s == "2B") { return association_classes::a2B; }
12 else if (s == "2B") { return association_classes::a2B; }
13 else if (s == "3B") { return association_classes::a3B; }
14 else if (s == "4C") { return association_classes::a4C; }
15 else {
16 throw std::invalid_argument("bad association flag: " + s);
17 }
18}
19
20enum class radial_dists { CS, KG };
21
22inline auto get_radial_dist(const std::string& s) {
23 if (s == "CS") { return radial_dists::CS; }
24 else if (s == "KG") { return radial_dists::KG; }
25 else {
26 throw std::invalid_argument("bad radial_dist flag: " + s);
27 }
28}
29
31
32inline auto get_Delta_rule(const std::string& s) {
33 if (s == "CR1") { return Delta_rules::CR1; }
34 else if (s == "Dufal") { return Delta_rules::Dufal; }
35 else {
36 throw std::invalid_argument("bad Delta_rule flag: " + s);
37 }
38}
39
46
47struct DufalData{
48 // Parameters coming from the non-associating part, one per component
49 Eigen::ArrayXd sigma_m, epsilon_Jmol, lambda_r;
50 Eigen::ArrayXXd kmat;
51
52 // Parameters from the associating part, one per component
53 Eigen::ArrayXd epsilon_HB_Jmol, K_HB_m3;
54
56
58 std::size_t N = sigma_m.size();
59 SIGMA3ij_m3.resize(N,N);
60 EPSILONOVERKij_K.resize(N,N);
61 LAMBDA_Rij.resize(N,N);
62 EPSILONOVERK_HBij_K.resize(N,N);
63 KHBij_m3.resize(N,N);
64
65 for (auto i = 0U; i < N; ++i){
66 for (auto j = 0U; j < N; ++j){
67 SIGMA3ij_m3(i,j) = POW3((sigma_m[i] + sigma_m[j])/2.0);
69 LAMBDA_Rij(i, j) = 3 + sqrt((lambda_r[i]-3)*(lambda_r[j]-3));
71 KHBij_m3(i,j) = POW3((cbrt(K_HB_m3[i]) + cbrt(K_HB_m3[j]))/2.0); // Published erratum in Dufal: https://doi.org/10.1080/00268976.2017.1402604
72 }
73 }
74 }
75};
76
77
78}
79}
auto get_Delta_rule(const std::string &s)
auto get_association_classes(const std::string &s)
auto get_radial_dist(const std::string &s)
const double R_CODATA2017
molar gas constant from CODATA 2017: https://doi.org/10.1103/RevModPhys.84.1527
Definition constants.hpp:10
auto POW3(const A &x)
Eigen::ArrayXd b_m3mol
The covolume b, in m^3/mol, one per component.
Eigen::ArrayXd epsilon_Jmol
The association energy of each molecule, in J/mol, one per component.
Eigen::ArrayXd beta
The volume factor, dimensionless, one per component.
Eigen::ArrayXXd kmat
Matrix of k_{ij} values.