This code executes the user function CP_set_mixture_binary_pair_data, which is a wrapper for the CoolProp.set_mixture_binary_pair_data() function, used to set the mixing rule for a specific binary pair.
| 814 | // the CoolProp.set_mixture_binary_pair_data() function, used to set the mixing rule for a |
| 815 | // specific binary pair. |
| 816 | static LRESULT CP_set_mixture_binary_pair_data(LPMCSTRING Msg, // output string (verification message) |
| 817 | LPCMCSTRING CAS1, // First component |
| 818 | LPCMCSTRING CAS2, // Second component |
| 819 | LPCMCSTRING Param, // Parameter Name String to set |
| 820 | LPCCOMPLEXSCALAR Value) // Parameter Value |
| 821 | { |
| 822 | std::string s = Param->str; |
| 823 | s.append(" parameter set."); |
| 824 | |
| 825 | // check that the first scalar argument is real |
| 826 | LRESULT r = CheckRealOrError(Value, 4); |
| 827 | if (r) return r; |
| 828 | |
| 829 | // Invoke the std::string form of get_global_param_string() function, save result to a new string s |
| 830 | try { |
| 831 | CoolProp::set_mixture_binary_pair_data(CAS1->str, CAS2->str, Param->str, Value->real); |
| 832 | } catch (const CoolProp::ValueError& e) { |
| 833 | std::string emsg(e.what()); |
| 834 | CoolProp::set_error_string(emsg); |
| 835 | if (emsg.find("parameter") != std::string::npos) { |
| 836 | return MAKELRESULT(BAD_PARAMETER, 3); |
| 837 | } else if (emsg.find("key") != std::string::npos) { |
| 838 | if (emsg.find(CAS1->str) != std::string::npos) |
| 839 | return MAKELRESULT(BAD_FLUID, 1); |
| 840 | else |
| 841 | return MAKELRESULT(BAD_FLUID, 2); |
| 842 | } else |
| 843 | return MAKELRESULT(UNKNOWN, 1); |
| 844 | } |
| 845 | |
| 846 | // Must use MathcadAllocate(size) so Mathcad can track and release |
| 847 | char* c = AllocMathcadString(s); |
| 848 | // assign the string to the function's output parameter |
| 849 | Msg->str = c; |
| 850 | |
| 851 | // normal return |
| 852 | return 0; |
| 853 | } |
| 854 | |
| 855 | // ******************************************************************************************************** |
| 856 | // Fill out a FUNCTIONINFO structure with the information needed for registering the function with Mathcad |
nothing calls this directly
no test coverage detected