| 530 | } |
| 531 | |
| 532 | bool StripPhase(std::string& Name, shared_ptr<AbstractState>& State) |
| 533 | // Parses an imposed phase out of the Input Name string using the "|" delimiter |
| 534 | { |
| 535 | std::vector<std::string> strVec = strsplit(Name, '|'); // Split input key string in to vector containing input key [0] and phase string [1] |
| 536 | if (strVec.size() > 1) { // If there is a phase string (contains "|" character) |
| 537 | // Check for invalid backends for setting phase in PropsSI |
| 538 | const std::string strBackend = State->backend_name(); |
| 539 | if (strBackend == get_backend_string(INCOMP_BACKEND)) |
| 540 | throw ValueError("Cannot set phase on Incompressible Fluid; always liquid phase"); // incompressible fluids are always "liquid". |
| 541 | if (strBackend == get_backend_string(IF97_BACKEND)) |
| 542 | throw ValueError("Can't set phase on IF97 Backend"); // IF97 has to calculate it's own phase region |
| 543 | if (strBackend == get_backend_string(TTSE_BACKEND)) |
| 544 | throw ValueError("Can't set phase on TTSE Backend in PropsSI"); // Shouldn't be calling from High-Level anyway |
| 545 | if (strBackend == get_backend_string(BICUBIC_BACKEND)) |
| 546 | throw ValueError("Can't set phase on BICUBIC Backend in PropsSI"); // Shouldn't be calling from High-Level anyway |
| 547 | if (strBackend == get_backend_string(VTPR_BACKEND)) |
| 548 | throw ValueError("Can't set phase on VTPR Backend in PropsSI"); // VTPR has no phase functions to call |
| 549 | |
| 550 | phases imposed = iphase_not_imposed; // Initialize imposed phase |
| 551 | if (strVec.size() > 2) // If there's more than on phase separator, throw error |
| 552 | { |
| 553 | throw ValueError(format("Invalid phase format: \"%s\"", Name)); |
| 554 | } |
| 555 | // Handle prefixes of iphase_, phase_, or <none> |
| 556 | std::basic_string<char>::iterator str_Iter; |
| 557 | std::string strPhase = strVec[1]; // Create a temp string so we can modify the prefix |
| 558 | if (strPhase.find("iphase_") != strPhase.npos) { |
| 559 | str_Iter = strPhase.erase(strPhase.begin()); |
| 560 | } // Change "iphase_" to "phase_" |
| 561 | if (strPhase.find("phase_") == strPhase.npos) { |
| 562 | strPhase.insert(0, "phase_"); |
| 563 | } // Prefix with "phase_" if missing |
| 564 | // See if phase is a valid phase string, updating imposed while we're at it... |
| 565 | if (!is_valid_phase(strPhase, imposed)) { |
| 566 | throw ValueError(format("Phase string \"%s\" is not a valid phase", strVec[1])); // throw error with original string if not valid |
| 567 | } |
| 568 | // Parsed phase string was valid |
| 569 | Name = strVec[0]; // Update input name to just the key string part |
| 570 | State->specify_phase(imposed); // Update the specified phase on the backend State |
| 571 | return true; // Return true because a valid phase string was found |
| 572 | } |
| 573 | return false; // Return false if there was no phase string on this key. |
| 574 | } |
| 575 | |
| 576 | void _PropsSImulti(const std::vector<std::string>& Outputs, const std::string& Name1, const std::vector<double>& Prop1, const std::string& Name2, |
| 577 | const std::vector<double>& Prop2, const std::string& backend, const std::vector<std::string>& fluids, |
no test coverage detected