MCPcopy Create free account
hub / github.com/CoolProp/CoolProp / PCSAFTBackend

Method PCSAFTBackend

src/Backends/PCSAFT/PCSAFTBackend.cpp:57–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55namespace CoolProp {
56
57PCSAFTBackend::PCSAFTBackend(const std::vector<std::string>& component_names, bool generate_SatL_and_SatV)
58 : N(component_names.size()), ion_term(false), polar_term(false), assoc_term(false), water_present(false), water_idx(0) {
59
60 components.resize(N);
61
62 for (unsigned int i = 0; i < N; ++i) {
63 components[i] = PCSAFTLibrary::get_library().get(component_names[i]);
64 // Determining which PC-SAFT terms should be used
65 if (components[i].getZ() != 0) {
66 ion_term = true;
67 }
68 if (components[i].getDipm() != 0) {
69 polar_term = true;
70 }
71 if (components[i].getVolA() != 0) {
72 assoc_term = true;
73 }
74 if (components[i].getCAS() == "7732-18-5") {
75 water_present = true;
76 water_idx = i;
77 }
78 }
79
80 // Set up association scheme
81 if (assoc_term) {
82 set_assoc_matrix();
83 }
84
85 // Set the components and associated flags
86 is_pure_or_pseudopure = (N == 1);
87
88 // loading interaction parameters
89 std::string kij_string;
90 std::string kijT_string;
91 if (is_pure_or_pseudopure) {
92 this->mole_fractions = std::vector<CoolPropDbl>(1, 1);
93 } else {
94 k_ij.resize(N * N, 0.0);
95 k_ijT.resize(N * N, 0.0);
96 for (unsigned int i = 0; i < N; ++i) {
97 for (unsigned int j = 0; j < N; ++j) {
98 if (i != j) {
99 kij_string = PCSAFTLibrary::get_library().get_binary_interaction_pcsaft(components[i].getCAS(), components[j].getCAS(), "kij");
100 kijT_string = PCSAFTLibrary::get_library().get_binary_interaction_pcsaft(components[i].getCAS(), components[j].getCAS(), "kijT");
101 k_ij[i * N + j] = atof(kij_string.c_str());
102 k_ijT[i * N + j] = atof(kijT_string.c_str());
103 }
104 }
105 }
106 }
107
108 if (generate_SatL_and_SatV) {
109 bool SatLSatV = false;
110 // Explicit scope: this runs inside the ctor; derived overrides
111 // of get_copy aren't active yet, so dispatch would resolve to
112 // PCSAFTBackend::get_copy regardless. Make that explicit and
113 // silence clang-analyzer-optin.cplusplus.VirtualCall.
114 SatL.reset(PCSAFTBackend::get_copy(SatLSatV));

Callers

nothing calls this directly

Calls 10

getZMethod · 0.80
getDipmMethod · 0.80
getVolAMethod · 0.80
getCASMethod · 0.80
resetMethod · 0.80
specify_phaseMethod · 0.80
sizeMethod · 0.45
resizeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected