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

Method SetFluid

wrappers/Modelica/src/FluidProp_IF.cpp:78–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76}
77
78void TFluidProp::SetFluid(string ModelName, int nComp, string* Comp, double* Conc, string* ErrorMsg) {
79 // _com_util::Convert model name to binary string
80 BSTR BSTR_Model = _com_util::ConvertStringToBSTR(ModelName.c_str());
81
82 long long_nComp = nComp;
83
84 // _com_util::Convert character array Comp via binary strings (BSTR) into an OLE SafeArray
85 SAFEARRAYBOUND sa_bounds_Comp[1];
86 sa_bounds_Comp[0].lLbound = 0;
87 sa_bounds_Comp[0].cElements = 20; //nComp;
88
89 SAFEARRAY FAR* sa_Comp;
90 sa_Comp = SafeArrayCreate(VT_BSTR, 1, sa_bounds_Comp);
91 BSTR BSTR_Comp;
92 for (long i = 0; i < long_nComp; i++) {
93 BSTR_Comp = _com_util::ConvertStringToBSTR(Comp[i].c_str());
94 SafeArrayPutElement(sa_Comp, &i, BSTR_Comp);
95 }
96
97 // _com_util::Convert the double array Conc into an OLE SafeArray
98 SAFEARRAYBOUND sa_bounds_Conc[1];
99 sa_bounds_Conc[0].lLbound = 0;
100 sa_bounds_Conc[0].cElements = 20; //nComp;
101
102 SAFEARRAY FAR* sa_Conc;
103 sa_Conc = SafeArrayCreate(VT_R8, 1, sa_bounds_Conc);
104 for (long i = 0; i < long_nComp; i++)
105 SafeArrayPutElement(sa_Conc, &i, &Conc[i]);
106
107 // Now load the fluid parameters for the model selected.
108 BSTR BSTR_Error;
109 FluidProp_COM->SetFluid(BSTR_Model, long_nComp, &sa_Comp, &sa_Conc, &BSTR_Error);
110
111 // Error handling
112 char* lpszErrorMsg = _com_util::ConvertBSTRToString(BSTR_Error);
113 *ErrorMsg = lpszErrorMsg;
114 delete[] lpszErrorMsg;
115
116 // Destroy the SafeArrays
117 SafeArrayDestroy(sa_Comp);
118 SafeArrayDestroy(sa_Conc);
119
120 SysFreeString(BSTR_Comp);
121 SysFreeString(BSTR_Error);
122 SysFreeString(BSTR_Model);
123}
124
125void TFluidProp::GetFluid(string* ModelName, int* nComp, string* Comp, double* Conc, bool CompInfo) {
126 // When CompInfo is true, the components and their concentrations in the mixture are returned

Callers 1

FluidPropSolverMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected