| 279 | } |
| 280 | |
| 281 | void PCSAFTLibraryClass::set_binary_interaction_pcsaft(const std::string& CAS1, const std::string& CAS2, const std::string& key, const double value) { |
| 282 | // Find pair |
| 283 | std::vector<std::string> CAS; |
| 284 | CAS.push_back(CAS1); |
| 285 | CAS.push_back(CAS2); |
| 286 | |
| 287 | std::vector<std::string> CASrev; |
| 288 | CASrev.push_back(CAS2); |
| 289 | CASrev.push_back(CAS1); |
| 290 | |
| 291 | if (m_binary_pair_map.find(CAS) != m_binary_pair_map.end()) { |
| 292 | if (get_config_bool(OVERWRITE_BINARY_INTERACTION)) { |
| 293 | std::vector<Dictionary>& v = m_binary_pair_map[CAS]; |
| 294 | if (v[0].has_number(key)) { |
| 295 | v[0].add_number(key, value); |
| 296 | } else { |
| 297 | throw ValueError(format("Could not set the parameter [%s] for the binary pair [%s,%s] - for now this is an error", key.c_str(), |
| 298 | CAS1.c_str(), CAS2.c_str())); |
| 299 | } |
| 300 | } else { |
| 301 | throw ValueError( |
| 302 | format("CAS pair(%s,%s) already in binary interaction map; considering enabling configuration key OVERWRITE_BINARY_INTERACTION", |
| 303 | CAS1.c_str(), CAS2.c_str())); |
| 304 | } |
| 305 | } else if (m_binary_pair_map.find(CASrev) != m_binary_pair_map.end()) { |
| 306 | if (get_config_bool(OVERWRITE_BINARY_INTERACTION)) { |
| 307 | std::vector<Dictionary>& v = m_binary_pair_map[CASrev]; |
| 308 | if (v[0].has_number(key)) { |
| 309 | v[0].add_number(key, value); |
| 310 | } else { |
| 311 | throw ValueError(format("Could not set the parameter [%s] for the binary pair [%s,%s] - for now this is an error", key.c_str(), |
| 312 | CAS1.c_str(), CAS2.c_str())); |
| 313 | } |
| 314 | } else { |
| 315 | throw ValueError( |
| 316 | format("CAS pair(%s,%s) already in binary interaction map; considering enabling configuration key OVERWRITE_BINARY_INTERACTION", |
| 317 | CAS1.c_str(), CAS2.c_str())); |
| 318 | } |
| 319 | } else { |
| 320 | Dictionary dict; |
| 321 | std::vector<std::string> CAS; |
| 322 | CAS.push_back(CAS1); |
| 323 | CAS.push_back(CAS2); |
| 324 | dict.add_number(key, value); |
| 325 | |
| 326 | m_binary_pair_map.insert(std::pair<std::vector<std::string>, std::vector<Dictionary>>(CAS, std::vector<Dictionary>(1, dict))); |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | void PCSAFTLibraryClass::load_from_JSON(const nlohmann::json& doc) { |
| 331 | for (const auto& el : doc) { |
no test coverage detected