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

Method fluid_param_string

src/Backends/REFPROP/REFPROPMixtureBackend.cpp:548–595  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

546 }
547}
548std::string REFPROPMixtureBackend::fluid_param_string(const std::string& ParamName) {
549 if (ParamName == "CAS") {
550 // subroutine NAME (icomp,hnam,hn80,hcasn)
551 // c
552 // c provides name information for specified component
553 // c
554 // c input:
555 // c icomp--component number in mixture; 1 for pure fluid
556 // c outputs:
557 // c hnam--component name [character*12]
558 // c hn80--component name--long form [character*80]
559 // c hcasn--CAS (Chemical Abstracts Service) number [character*12]
560 std::vector<std::string> CASvec;
561 for (int icomp = 1L; icomp <= static_cast<int>(fluid_names.size()); ++icomp) {
562 std::array<char, 13> hnam{};
563 std::array<char, 81> hn80{};
564 std::array<char, 13> hcasn{};
565 NAMEdll(&icomp, hnam.data(), hn80.data(), hcasn.data(), 12, 80, 12);
566 hcasn[12] = '\0';
567 std::string casn = hcasn.data();
568 strstrip(casn);
569 CASvec.push_back(casn);
570 }
571 return strjoin(CASvec, "&");
572 } else if (ParamName == "name") {
573 int icomp = 1L;
574 std::array<char, 13> hnam{};
575 std::array<char, 81> hn80{};
576 std::array<char, 13> hcasn{};
577 NAMEdll(&icomp, hnam.data(), hn80.data(), hcasn.data(), 12, 80, 12);
578 hnam[12] = '\0';
579 std::string name = hnam.data();
580 strstrip(name);
581 return name;
582 } else if (ParamName == "long_name") {
583 int icomp = 1L;
584 std::array<char, 13> hnam{};
585 std::array<char, 81> hn80{};
586 std::array<char, 13> hcasn{};
587 NAMEdll(&icomp, hnam.data(), hn80.data(), hcasn.data(), 12, 80, 12);
588 hn80[80] = '\0';
589 std::string n80 = hn80.data();
590 strstrip(n80);
591 return n80;
592 } else {
593 throw ValueError(format("parameter to fluid_param_string is invalid: %s", ParamName.c_str()));
594 }
595};
596int REFPROPMixtureBackend::match_CAS(const std::string& CAS) {
597 for (int icomp = 1L; icomp <= static_cast<int>(fluid_names.size()); ++icomp) {
598 std::array<char, 13> hnam{};

Callers 1

Calls 3

strjoinFunction · 0.85
formatFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected