2 #define _CRTDBG_MAP_ALLOC
3 #define _CRT_SECURE_NO_WARNINGS
13 #if defined(__ISWINDOWS__)
15 #elif defined(__ISLINUX__)
17 #elif defined(__ISAPPLE__)
31 #define refpropcharlength 255
32 #define filepathlength 255
33 #define lengthofreference 3
34 #define errormessagelength 255
35 #define ncmax 20 // Note: ncmax is the max number of components
50 #if __x86_64__ || __ppc64__
61 #if defined(__ISWINDOWS__)
63 #elif defined(__ISLINUX__)
65 #elif defined(__ISAPPLE__)
177 #if defined(__ISWINDOWS__)
179 #elif defined(__ISLINUX__)
181 #elif defined(__ISAPPLE__)
195 printf(
"REFPROP is not loaded, make sure you call this function after loading the library.\n");
300 static char hfmix[] =
"HMX.BNC";
301 static char hrf[] =
"DEF";
303 #if defined(__ISWINDOWS__)
305 #elif defined(__ISLINUX__)
307 #elif defined(__ISAPPLE__)
316 #if defined(__ISWINDOWS__)
318 #elif defined(__ISLINUX__)
319 return rpPath + std::string(
"/fluids/");
320 #elif defined(__ISAPPLE__)
321 return rpPath + std::string(
"/fluids/");
333 #if defined(__ISWINDOWS__)
334 #if defined(ENV64BIT)
336 TCHAR refpropdllstring[100] = TEXT(
"refprp64.dll");
338 #elif defined (ENV32BIT)
340 TCHAR refpropdllstring[100] = TEXT(
"refprop.dll");
344 #error "Must define either ENV32BIT or ENV64BIT"
348 #elif defined(__ISLINUX__)
350 #elif defined(__ISAPPLE__)
359 #if defined(__ISWINDOWS__)
373 printf(
"Could not load refprop.dll \n\n");
374 throw AttributeError(
"Could not load refprop.dll, make sure it is in your system search path. In case you run 64bit and you have a REFPROP license, try installing the 64bit DLL from NIST.");
375 #elif defined(__ISLINUX__)
376 fputs (dlerror(), stderr);
377 printf(
"Could not load librefprop.so \n\n");
378 throw AttributeError(
"Could not load librefprop.so, make sure it is in your system search path.");
379 #elif defined(__ISAPPLE__)
380 fputs (dlerror(), stderr);
381 printf(
"Could not load librefprop.dylib \n\n");
382 throw AttributeError(
"Could not load librefprop.dylib, make sure it is in your system search path.");
384 throw NotImplementedError(
"Something is wrong with the platform definition, you should not end up here.");
389 #if defined(__ISWINDOWS__)
395 if ( stat(
"c:\\Program Files\\REFPROP\\fluids", &buf) != 0){
396 throw ValueError(
"REFPROP fluid files must be copied to c:\\Program Files\\REFPROP\\fluids");
400 if ( _stat(
"c:\\Program Files\\REFPROP\\fluids", &buf) != 0){
401 throw ValueError(
"REFPROP fluid files must be copied to c:\\Program Files\\REFPROP\\fluids");
408 printf(
"There was an error setting the REFPROP function pointers, check types and names in header file.\n");
409 throw AttributeError(
"There was an error setting the REFPROP function pointers, check types and names in header file.");
421 std::string sRef, components_joined;
422 std::string RefString;
438 if (Ref.find(
"REFPROP-MIX:") == 0)
441 components_joined = Ref.substr(12,Ref.size()-12);
447 if (components_joined.find(
".mix") != std::string::npos || components_joined.find(
".MIX") != std::string::npos)
453 strcpy(hf,components_joined.c_str());
464 for (
unsigned int j = 0; j < 255*
ncmax; j++)
475 RefString = std::string(hfiles,strlen(hfiles)+1);
476 for (
int j = 0; j < i; j++)
484 std::vector<std::string> components_split =
strsplit(components_joined,
'&');
486 if (components_split.size() == 1)
488 throw ValueError(
format(
"REFPROP mixture specified composition desired [%s], but only one component found",components_joined.c_str()).c_str());
495 x.resize(components_split.size());
497 for (
unsigned int j=0;j<components_split.size();j++)
500 std::vector<std::string> comp_fraction =
strsplit(components_split[j],
'[');
502 if (comp_fraction.size() != 2)
504 throw ValueError(
format(
"Could not parse name[molefraction] [%s]",components_split[j].c_str()).c_str());
509 RefString = fdPath + comp_fraction[0]+
".fld";
512 RefString +=
"|" + fdPath + comp_fraction[0]+
".fld";
515 x[j] = strtod(comp_fraction[1].c_str(),NULL);
523 else if (Ref.find(
"REFPROP-") == 0)
526 sRef = Ref.substr(8,Ref.size()-8);
528 if (!sRef.compare(
"Air") || !sRef.compare(
"R507A") || !sRef.compare(
"R404A") || !sRef.compare(
"R410A") || !sRef.compare(
"R407C") || !sRef.compare(
"SES36"))
531 RefString = fdPath + std::string(sRef)+std::string(
".ppf");
537 RefString = fdPath + std::string(sRef)+std::string(
".fld");
543 throw ValueError(
format(
"REFPROP fluid string [%s] is invalid", Ref.c_str()));
559 strcpy(hfm,fdPath.c_str());
561 strcpy(hf,RefString.c_str());
564 SETUPdll(&i, hf, hfm, hrf, &ierr, herr,
570 for(
unsigned int j = 0; j < strlen(hrf); j++)
572 hrf[j] = toupper(hrf[j]);
574 for(
unsigned int j = 0; j < strlen(hfm); j++)
576 hfm[j] = toupper(hfm[j]);
578 for(
unsigned int j = 0; j < strlen(hf); j++)
580 hf[j] = toupper(hf[j]);
582 SETUPdll(&i, hf, hfm, hrf, &ierr, herr,
589 for(
unsigned int j = 0; j < strlen(hrf); j++)
591 hrf[j] = tolower(hrf[j]);
593 for(
unsigned int j = 0; j < strlen(hfm); j++)
595 hfm[j] = tolower(hfm[j]);
597 for(
unsigned int j = 0; j < strlen(hf); j++)
599 hf[j] = tolower(hf[j]);
601 SETUPdll(&i, hf, hfm, hrf, &ierr, herr,
620 for (jmax = 0; jmax <
ncmax; jmax++)
622 if (jmax == x.size())
641 double REFPROP(
char Output,
char Name1,
double Prop1,
char Name2,
double Prop2,
char * Ref)
643 return REFPROP(std::string(1,Output),std::string(1,Name1),Prop1,std::string(1,Name2),Prop2,std::string(Ref));
664 double REFPROP(std::string Output, std::string Name1,
double Prop1, std::string Name2,
double Prop2, std::string Ref)
671 if (iOutput == iName1){
return Prop1;}
672 if (iOutput == iName2){
return Prop2;}
679 double output_val =
REFPROPSI(iOutput, iName1, Prop1, iName2, Prop2, Ref);
685 double REFPROPSI(
long iOutput,
long iName1,
double Prop1,
long iName2,
double Prop2, std::string Ref)
688 printf(
"You cannot use REFPROP, returning.");
696 double TL, TV, dummy;
697 double T,p=0,d,dl,dv,q,e,h,s,cv,cp,w,MW,hl,hv,sl,sv,ul,
698 uv,pl,pv,hjt,eta,tcx,Q,Tcrit,pcrit,dcrit,sigma;
708 if (iOutput == iName1){
return Prop1;}
709 if (iOutput == iName2){
return Prop2;}
719 else if (iOutput==
iMM)
728 output_val = pcrit*1000;
734 output_val = dcrit*MW;
737 else if (iOutput ==
iTmin)
740 double tmin,tmax,Dmax,pmax;
746 double wmm,Ttriple,tnbpt,tc,pc,Dc,Zc,acf,dip,Rgas;
750 fprintf(stderr,
"Error: Accentric factor only defined for pure fluids\n");
753 INFOdll(&i,&wmm,&Ttriple,&tnbpt,&tc,&pc,&Dc,&Zc,&acf,&dip,&Rgas);
if (ierr > 0) {
throw ValueError(
format(
"%s",herr).c_str()); }
else if (ierr < 0) {
set_warning(
format(
"%s",herr).c_str());}
758 double wmm,Ttriple,tnbpt,tc,pc,Dc,Zc,acf,dip,Rgas;
762 fprintf(stderr,
"Error: Dipole moment only defined for pure fluids\n");
765 INFOdll(&i,&wmm,&Ttriple,&tnbpt,&tc,&pc,&Dc,&Zc,&acf,&dip,&Rgas);
if (ierr > 0) {
throw ValueError(
format(
"%s",herr).c_str()); }
else if (ierr < 0) {
set_warning(
format(
"%s",herr).c_str());}
771 double wmm,Ttriple,tnbpt,tc,pc,Dc,Zc,acf,dip,Rgas;
776 fprintf(stderr,
"Error: Triple point temperature only defined for pure fluids\n");
779 INFOdll(&i,&wmm,&Ttriple,&tnbpt,&tc,&pc,&Dc,&Zc,&acf,&dip,&Rgas);
if (ierr > 0) {
throw ValueError(
format(
"%s",herr).c_str()); }
else if (ierr < 0) {
set_warning(
format(
"%s",herr).c_str());}
780 output_val = Ttriple;
782 else if (iOutput==
iI)
789 std::cout<<
"If surface tension is the output, temperature must be the first input" << std::endl;
795 else if (iName1!=
iQ && iName2 !=
iQ)
797 if ((iName1==
iT && iName2 ==
iP) || (iName2==
iT && iName1==
iP))
800 if (iName1 ==
iP){ std::swap(Prop1,Prop2); }
802 T = Prop1; p = Prop2/1000.0;
805 TPFLSHdll(&T,&p,&(
x[0]),&d,&dl,&dv,xliq,xvap,&q,&e,&h,&s,&cv,&cp,&w,&ierr,herr,
errormessagelength);
if (ierr > 0) {
throw ValueError(
format(
"%s",herr).c_str()); }
else if (ierr < 0) {
set_warning(
format(
"%s",herr).c_str());}
807 else if ((iName1==
iT && iName2==
iD) || (iName2==
iT && iName1==
iD))
811 std::swap(Prop1,Prop2);
813 T = Prop1; d = Prop2/MW;
816 TDFLSHdll(&T,&d,&(
x[0]),&p,&dl,&dv,xliq,xvap,&q,&e,&h,&s,&cv,&cp,&w,&ierr,herr,
errormessagelength);
if (ierr > 0) {
throw ValueError(
format(
"%s",herr).c_str()); }
else if (ierr < 0) {
set_warning(
format(
"%s",herr).c_str());}
818 else if ((iName1==
iP && iName2==
iH) || (iName2==
iP && iName1==
iH))
822 std::swap(Prop1,Prop2);
824 p = Prop1/1000.0; h = Prop2*MW/1000;
827 PHFLSHdll(&p,&h,&(
x[0]),&T,&d,&dl,&dv,xliq,xvap,&q,&e,&s,&cv,&cp,&w,&ierr,herr,
errormessagelength);
if (ierr > 0) {
throw ValueError(
format(
"%s",herr).c_str()); }
else if (ierr < 0) {
set_warning(
format(
"%s",herr).c_str());}
829 else if ((iName1==
iP && iName2==
iS) || (iName2==
iP && iName1==
iS))
833 std::swap(Prop1,Prop2);
835 p = Prop1/1000.0; s = Prop2*MW/1000.0;
838 PSFLSHdll(&p,&s,&(
x[0]),&T,&d,&dl,&dv,xliq,xvap,&q,&e,&h,&cv,&cp,&w,&ierr,herr,
errormessagelength);
if (ierr > 0) {
throw ValueError(
format(
"%s",herr).c_str()); }
else if (ierr < 0) {
set_warning(
format(
"%s",herr).c_str());}
840 else if ((iName1==
iH && iName2==
iS) || (iName2==
iH && iName1==
iS))
844 std::swap(Prop1,Prop2);
846 h = Prop1*MW/1000.0; s = Prop2*MW/1000.0;
849 HSFLSHdll(&h,&s,&(
x[0]),&T,&p,&d,&dl,&dv,xliq,xvap,&q,&e,&cv,&cp,&w,&ierr,herr,
errormessagelength);
if (ierr > 0) {
throw ValueError(
format(
"%s",herr).c_str()); }
else if (ierr < 0) {
set_warning(
format(
"%s",herr).c_str());}
851 else if ((iName1==
iP && iName2==
iD) || (iName2==
iP && iName1==
iD))
855 std::swap(Prop1,Prop2);
857 p = Prop1/1000.0; d = Prop2/MW;
861 PDFLSHdll(&p,&d,&(
x[0]),&T,&dl,&dv,xliq,xvap,&q,&e,&h,&s,&cv,&cp,&w,&ierr,herr,
errormessagelength);
if (ierr > 0) {
throw ValueError(
format(
"%s",herr).c_str()); }
else if (ierr < 0) {
set_warning(
format(
"%s",herr).c_str());}
863 else if ((iName1==
iS && iName2==
iD) || (iName2==
iS && iName1==
iD))
867 std::swap(Prop1,Prop2);
869 s = Prop1*MW/1000.0; d = Prop2/MW;
873 DSFLSHdll(&d,&s,&(
x[0]),&T,&p,&dl,&dv,xliq,xvap,&q,&e,&h,&cv,&cp,&w,&ierr,herr,
errormessagelength);
if (ierr > 0) {
throw ValueError(
format(
"%s",herr).c_str()); }
else if (ierr < 0) {
set_warning(
format(
"%s",herr).c_str());}
879 case iT: output_val = T;
break;
880 case iP: output_val = p*1000;
break;
881 case iH: output_val = h/MW*1000;
break;
882 case iD: output_val = d*MW;
break;
883 case iS: output_val = s/MW*1000;
break;
884 case iU: output_val = e/MW*1000;
break;
885 case iC: output_val = cp/MW*1000;
break;
886 case iO: output_val = cv/MW*1000;
break;
887 case iA: output_val = w;
break;
889 output_val = (1/d-1/dl)/(1/dv-1/dl);
break;
892 output_val = eta/1.0e6;
899 throw ValueError(
format(
"Output parameter [%d] is invalid for REFPROP fluid in REFPROP.cpp",iOutput).c_str());
903 else if ((iName1==
iT && iName2==
iQ) || (iName2==
iT && iName1==
iQ) ||
904 (iName1==
iP && iName2==
iQ) || (iName2==
iP && iName1==
iQ)
907 if (iName1 ==
iT || iName2 ==
iT)
909 if (iName2 ==
iT){ std::swap(Prop1,Prop2); }
911 T = Prop1; Q = Prop2;
916 SATTdll(&T,&(
x[0]),&ic,&pl,&dl,&dummy,xliq,dummyv,&ierr,herr,
errormessagelength);
if (ierr > 0) {
throw ValueError(
format(
"%s",herr).c_str()); }
else if (ierr < 0) {
set_warning(
format(
"%s",herr).c_str());}
918 SATTdll(&T,&(
x[0]),&ic,&pv,&dummy,&dv,dummyv,xvap,&ierr,herr,
errormessagelength);
if (ierr > 0) {
throw ValueError(
format(
"%s",herr).c_str()); }
else if (ierr < 0) {
set_warning(
format(
"%s",herr).c_str());}
920 p = (pv*Q+pl*(1-Q))*1000;
924 if (iName2 ==
iP){ std::swap(Prop1,Prop2); }
926 p = Prop1/1000; Q = Prop2;
931 SATPdll(&p,&(
x[0]),&ic,&TL,&dl,&dummy,xliq,dummyv,&ierr,herr,
errormessagelength);
if (ierr > 0) {
throw ValueError(
format(
"%s",herr).c_str()); }
else if (ierr < 0) {
set_warning(
format(
"%s",herr).c_str());}
934 SATPdll(&p,&(
x[0]),&ic,&TV,&dummy,&dv,dummyv,xvap,&ierr,herr,
errormessagelength);
if (ierr > 0) {
throw ValueError(
format(
"%s",herr).c_str()); }
else if (ierr < 0) {
set_warning(
format(
"%s",herr).c_str());}
941 output_val = (TV*Q+TL*(1-Q));
943 else if (iOutput==
iD)
945 output_val = 1/(Q/dv+(1-Q)/dl)*MW;
947 else if (iOutput==
iP)
951 else if (iOutput==
iA)
954 THERMdll(&T,&d,&(
x[0]),&p,&e,&h,&s,&cv,&cp,&w,&hjt);
if (ierr > 0) {
throw ValueError(
format(
"%s",herr).c_str()); }
else if (ierr < 0) {
set_warning(
format(
"%s",herr).c_str());}
957 else if (iOutput==
iH)
961 output_val = (hv*Q+hl*(1-Q))/MW*1000;
963 else if (iOutput==
iS)
967 output_val = (sv*Q+sl*(1-Q))/MW*1000;
969 else if (iOutput==
iU)
976 output_val = (uv*Q+ul*(1-Q))/MW*1000;
978 else if (iOutput==
iC)
980 d = 1/(Q/dv+(1-Q)/dl);
982 output_val = cp/MW*1000;
984 else if (iOutput==
iO)
986 d = 1/(Q/dv+(1-Q)/dl);
988 output_val = cv/MW*1000;
990 else if (iOutput==
iV)
992 d = 1/(Q/dv+(1-Q)/dl);
994 output_val = eta/1.0e6;
996 else if (iOutput==
iL)
998 d = 1/(Q/dv+(1-Q)/dl);
1020 std::vector<double> xliq = xmol, xvap = xmol;
1021 double Tcrit,dcrit,pcrit,MW,Ttriple,tnbpt,acf,Zcrit,dip,Rgas, dummy1, dummy2;
1042 INFOdll(&i,&MW,&Ttriple,&tnbpt,&Tcrit,&pcrit,&dcrit,&Zcrit,&acf,&dip,&Rgas);
1047 params.accentricfactor = acf;
1049 params.Ttriple = Ttriple;
1055 SATTdll(&(Ttriple),&(xmol[0]),&(ic),&(
params.ptriple),&dummy1,&dummy2,&(xliq[0]),&(xvap[0]),&ierr,herr,
errormessagelength);
1057 name.assign(FluidName);
1065 bool REFPROPFluidClass::supported =
true;
1078 if (REFPROPFluidClass::supported) {
1081 if (rpv.compare(
"NOTAVAILABLE")!=0) {
1088 printf(
"Good news: It is possible to use REFPROP on your system! However, the library \n");
1089 printf(
"could not be loaded. Please make sure that REFPROP is available on your system.\n\n");
1090 printf(
"Neither found in current location nor found in system PATH.\n");
1091 printf(
"If you already obtained a copy of REFPROP from http://www.nist.gov/srd/, \n");
1092 printf(
"add location of REFPROP to the PATH environment variable or your library path.\n\n");
1093 printf(
"In case you do not use Windows, have a look at https://github.com/jowr/librefprop.so \n");
1094 printf(
"to find instructions on how to compile your own version of the REFPROP library.\n\n");
1095 REFPROPFluidClass::supported =
false;
1101 REFPROPFluidClass::supported =
false;
1114 double p,T,rho,rhobar;
1116 rhobar = rho/
params.molemass;
1119 PRESSdll(&T, &rhobar, &(xmol[0]), &p);
1120 return 1/delta*(p/(rho*
R()*T)-1);
1124 double T,rho,rhobar,pr,er,hr,sr,cvr,cpr,Ar,Gr;
1126 rhobar = rho/
params.molemass;
1129 RESIDUALdll(&T,&rhobar,&(xmol[0]),&pr,&er,&hr,&sr,&cvr,&cpr,&Ar,&Gr);
1130 return er/(
params.R_u*T*tau);
1134 double T,rho,rhobar,p0,e0,h0,s0,cv0,cp0,w0,A0,G0;
1136 rhobar = rho/
params.molemass;
1139 THERM0dll(&T,&rhobar,&(xmol[0]),&p0,&e0,&h0,&s0,&cv0,&cp0,&w0,&A0,&G0);
1141 return -cv0/(
params.R_u*tau*tau);
1145 double T,rho,rhobar,pr,er,hr,sr,cvr,cpr,Ar,Gr;
1147 rhobar = rho/
params.molemass;
1150 RESIDUALdll(&T,&rhobar,&(xmol[0]),&pr,&er,&hr,&sr,&cvr,&cpr,&Ar,&Gr);
1152 return -cvr/(
params.R_u*tau*tau);
1157 double T,rho,rhobar,dpdT_constrho;
1159 rhobar = rho/
params.molemass;
1162 DPDTdll(&T, &rhobar, &(xmol[0]), &dpdT_constrho);
1163 return -1/(delta*tau)*(1/(rho*
R())*dpdT_constrho-1-delta*this->
dphir_dDelta(tau,delta));
1167 double T,rho,rhobar,dpdrhobar_constT;
1169 rhobar = rho/
params.molemass;
1172 DPDDdll(&T, &rhobar, &(xmol[0]), &dpdrhobar_constT);
1173 return 1/(delta*delta)*(1/(
params.R_u*T)*dpdrhobar_constT-1-2*delta*this->
dphir_dDelta(tau,delta));
1177 double T,rho,rhobar,pr,er,hr,sr,cvr,cpr,Ar,Gr;
1179 rhobar = rho/
params.molemass;
1182 RESIDUALdll(&T,&rhobar,&(xmol[0]),&pr,&er,&hr,&sr,&cvr,&cpr,&Ar,&Gr);
1187 double T,rho,rhobar,p0,e0,h0,s0,cv0,cp0,w0,A0,G0;
1189 rhobar = rho/
params.molemass;
1192 THERM0dll(&T,&rhobar,&(xmol[0]),&p0,&e0,&h0,&s0,&cv0,&cp0,&w0,&A0,&G0);
1193 return e0/(
R()*T*tau)/
params.molemass;
1197 double T,rho,rhobar,p0,e0,h0,s0,cv0,cp0,w0,A0,G0;
1199 rhobar = rho/
params.molemass;
1202 THERM0dll(&T,&rhobar,&(xmol[0]),&p0,&e0,&h0,&s0,&cv0,&cp0,&w0,&A0,&G0);
1203 return (h0-T*s0)/
params.R_u/T-1;
1210 double dl = 1, sigma;
1220 double eta,tcx,rhobar = rho/
params.molemass;
1229 double eta,tcx,rhobar = rho/
params.molemass;
1239 std::vector<double> xliq = xmol, xvap = xmol;
1243 SATTdll(&T,&(xmol[0]),&ic,&psatLout,&rhosatLout,&dummy,&(xliq[0]),&(xvap[0]),&ierr,herr,
errormessagelength);
1245 SATTdll(&T,&(xmol[0]),&ic,&psatVout,&dummy,&rhosatVout,&(xliq[0]),&(xvap[0]),&ierr,herr,
errormessagelength);
1248 rhosatLout *=
params.molemass;
1249 rhosatVout *=
params.molemass;
1259 std::vector<double> xliq = xmol,xvap = xmol;
1262 SATPdll(&p,&(xmol[0]),&ic,&TsatLout,&rhosatLout,&dummy,&(xliq[0]),&(xvap[0]),&ierr,herr,
errormessagelength);
1264 SATPdll(&p,&(xmol[0]),&ic,&TsatVout,&dummy,&rhosatVout,&(xliq[0]),&(xvap[0]),&ierr,herr,
errormessagelength);
1265 rhosatLout *=
params.molemass;
1266 rhosatVout *=
params.molemass;
1270 double q,e,s,cv,cp,w,hbar = h*
params.molemass, dummy1, dummy2;
1273 std::vector<double> xliq = xmol, xvap = xmol;
1278 PHFLSHdll(&p,&hbar,&(xmol[0]),&Tout,&rho,&rhoL,&rhoV,&(xliq[0]),&(xvap[0]),&q,&e,&s,&cv,&cp,&w,&ierr,herr,
errormessagelength);
1290 this->
saturation_p(p*1000,
false,TsatL,TsatV,dummy1,dummy2);
1295 double q,e,h,cv,cp,w,sbar = s*
params.molemass, dummy1,dummy2;
1297 std::vector<double> xliq = xmol, xvap = xmol;
1303 PSFLSHdll(&p,&sbar,&(xmol[0]),&Tout,&rho,&rhoL,&rhoV,&(xliq[0]),&(xvap[0]),&q,&e,&h,&cv,&cp,&w,&ierr,herr,
errormessagelength);
1315 this->
saturation_p(p*1000,
false,TsatL,TsatV,dummy1,dummy2);
1320 double q,e,cv,cp,w,p,sbar = s*
params.molemass, hbar = h*
params.molemass, dummy1, dummy2;
1322 std::vector<double> xliq = xmol, xvap = xmol;
1328 HSFLSHdll(&hbar,&sbar,&(xmol[0]),&Tout,&p,&rho,&rhoL,&rhoV,&(xliq[0]),&(xvap[0]),&q,&e,&cv,&cp,&w,&ierr,herr,
errormessagelength);
1341 this->
saturation_p(p*1000,
false,TsatL,TsatV,dummy1,dummy2);
1353 std::vector<double> xliq = xmol,xvap = xmol;
1354 double q,e,s,cv,cp,w,h,rho,rhoL,rhoV;
1355 TPFLSHdll(&T,&p,&(xmol[0]),&rho,&rhoL,&rhoV,&(xliq[0]),&(xvap[0]),&q,&e,&h,&s,&cv,&cp,&w,&ierr,herr,
errormessagelength);
1357 return rho*
params.molemass;
1363 std::vector<double> xliq = xmol,xvap = xmol;
1364 double dummy1,dummy2,psatval;
1367 SATTdll(&T,&(xmol[0]),&ic,&psatval,&dummy1,&dummy2,&(xliq[0]),&(xvap[0]),&ierr,herr,
errormessagelength);
1369 return psatval*1000;
1375 std::vector<double> xliq = xmol,xvap = xmol;
1376 double rhoV,dummy1,psatval;
1379 SATTdll(&T,&(xmol[0]),&ic,&psatval,&dummy1,&rhoV,&(xliq[0]),&(xvap[0]),&ierr,herr,
errormessagelength);
1380 return rhoV*
params.molemass;
1386 std::vector<double> xliq = xmol,xvap = xmol;
1387 double rhoL,dummy1,psatval;
1390 SATTdll(&T,&(xmol[0]),&ic,&psatval,&rhoL, &dummy1,&(xliq[0]),&(xvap[0]),&ierr,herr,
errormessagelength);
1391 return rhoL*
params.molemass;
1409 #ifndef DISABLE_CATCH
1411 TEST_CASE(
"REFPROP Fluid Class Helmholtz derivatives check",
"[helmholtz],[fast]")
1413 std::vector<double>
x(1,1);
1420 double NUM = (fluid.
phir(0.5, 0.5+eps) - fluid.
phir(0.5,0.5-eps))/(2*eps);
1426 double NUM = (fluid.
phir(0.5+eps, 0.5) - fluid.
phir(0.5-eps,0.5))/(2*eps);
1449 TEST_CASE(
"REFPROP Fluid Class check saturation consistency",
"")
1451 std::vector<double>
x(1,1);
1457 double p, T2, psatV, TsatV,rhoL,rhoV;
1467 std::vector<double> x1(1,1), x2(2,0.5);
1484 SECTION(
"REFPROP-MIX:R32[0.5]R125[0.5]")
1488 SECTION(
"REFPROP-MIX:R32[0,5]R125[0,5]")
1492 SECTION(
"REFPROP-MIX:R32[A]&R125[B]")
1496 SECTION(
"REFPROP-MIX:R32[0.697614699375863]&R125[0.302385300624138]")
1500 SECTION(
"REFPROP-MIXLR410A.mix")
CV2PKdll_TYPE * CV2PKdll_POINTER
LIMITSdll_TYPE * LIMITSdll_POINTER
MLTH2Odll_TYPE * MLTH2Odll_POINTER
SETMODdll_POINTER SETMODdll
double conductivity_Trho(double T, double rho)
void set_warning(std::string warning)
std::string LoadedREFPROPRef
void temperature_hs(double h, double s, double &Tout, double &rhoout, double &rhoLout, double &rhoVout, double &TsatLout, double &TsatVout)
DIELECdll_TYPE * DIELECdll_POINTER
GETFIJdll_POINTER GETFIJdll
TPFL2dll_POINTER TPFL2dll
TDFLSHdll_POINTER TDFLSHdll
ENTROdll_TYPE * ENTROdll_POINTER
THERMdll_TYPE * THERMdll_POINTER
GERG04dll_TYPE * GERG04dll_POINTER
void temperature_ps(double p, double s, double &Tout, double &rhoout, double &rhoLout, double &rhoVout, double &TsatLout, double &TsatVout)
double phir(double tau, double delta)
struct FluidLimits limits
HSFLSHdll_POINTER HSFLSHdll
SETPATHdll_TYPE * SETPATHdll_POINTER
double phi0(double tau, double delta)
double d2phi0_dTau2(double tau, double delta)
GETFIJdll_TYPE * GETFIJdll_POINTER
DHFL1dll_TYPE * DHFL1dll_POINTER
MELTPdll_POINTER MELTPdll
double d2phir_dDelta2(double tau, double delta)
VIRCdll_TYPE * VIRCdll_POINTER
DDDTdll_TYPE * DDDTdll_POINTER
CV2PKdll_POINTER CV2PKdll
SETUPdll_TYPE * SETUPdll_POINTER
double d2phir_dTau2(double tau, double delta)
std::string name
A container to hold the cache for residual Helmholtz derivatives.
ABFL2dll_POINTER ABFL2dll
ABFL1dll_TYPE * ABFL1dll_POINTER
CVCPKdll_POINTER CVCPKdll
ESFLSHdll_TYPE * ESFLSHdll_POINTER
QMASSdll_TYPE * QMASSdll_POINTER
LIMITXdll_TYPE * LIMITXdll_POINTER
TSFLSHdll_POINTER TSFLSHdll
PRESSdll_POINTER PRESSdll
SETPATHdll_POINTER SETPATHdll
PDFLSHdll_POINTER PDFLSHdll
PUREFLDdll_TYPE * PUREFLDdll_POINTER
SATPdll_TYPE * SATPdll_POINTER
SETAGAdll_TYPE * SETAGAdll_POINTER
LIMITXdll_POINTER LIMITXdll
PEFLSHdll_POINTER PEFLSHdll
ESFLSHdll_POINTER ESFLSHdll
DPTSATKdll_TYPE * DPTSATKdll_POINTER
DIELECdll_POINTER DIELECdll
SETAGAdll_POINTER SETAGAdll
TQFLSHdll_POINTER TQFLSHdll
DHD1dll_TYPE * DHD1dll_POINTER
bool set_REFPROP_fluid(std::string Ref, std::vector< double > &x)
SETMIXdll_TYPE * SETMIXdll_POINTER
double REFPROPSI(long iOutput, long iName1, double Prop1, long iName2, double Prop2, std::string Ref)
FPVdll_TYPE * FPVdll_POINTER
PHFL1dll_TYPE * PHFL1dll_POINTER
THERM3dll_TYPE * THERM3dll_POINTER
DPDTKdll_TYPE * DPDTKdll_POINTER
DSFL1dll_TYPE * DSFL1dll_POINTER
TPFL2dll_TYPE * TPFL2dll_POINTER
PSFL1dll_TYPE * PSFL1dll_POINTER
WMOLdll_TYPE * WMOLdll_POINTER
THERMdll_POINTER THERMdll
EXPORT_CODE int CONVENTION get_standard_unit_system(void)
LIMITKdll_POINTER LIMITKdll
PUREFLDdll_POINTER PUREFLDdll
SURFTdll_POINTER SURFTdll
struct CriticalStruct reduce
A pointer to the point that is used to reduce the T and rho for EOS.
SURTENdll_TYPE * SURTENdll_POINTER
DHFL2dll_TYPE * DHFL2dll_POINTER
#define refpropcharlength
TEFLSHdll_POINTER TEFLSHdll
DPTSATKdll_POINTER DPTSATKdll
THFLSHdll_POINTER THFLSHdll
SUBLPdll_TYPE * SUBLPdll_POINTER
DSFL2dll_TYPE * DSFL2dll_POINTER
SUBLTdll_TYPE * SUBLTdll_POINTER
THFLSHdll_TYPE * THFLSHdll_POINTER
double dphir_dDelta(double tau, double delta)
std::vector< double > LoadedREFPROPx(ncmax, 0)
PHFLSHdll_TYPE * PHFLSHdll_POINTER
XMASSdll_TYPE * XMASSdll_POINTER
CSATKdll_POINTER CSATKdll
PEFLSHdll_TYPE * PEFLSHdll_POINTER
MELTPdll_TYPE * MELTPdll_POINTER
TEFLSHdll_TYPE * TEFLSHdll_POINTER
TDFLSHdll_TYPE * TDFLSHdll_POINTER
double convert_from_SI_to_unit_system(long iInput, double value, int new_system)
MELTTdll_POINTER MELTTdll
AGdll_TYPE * AGdll_POINTER
PQFLSHdll_POINTER PQFLSHdll
SETKTVdll_TYPE * SETKTVdll_POINTER
QMOLEdll_TYPE * QMOLEdll_POINTER
struct CriticalStruct * preduce
std::string get_REFPROP_fluid_path()
static bool refpropSupported()
THERM0dll_TYPE * THERM0dll_POINTER
QMOLEdll_POINTER QMOLEdll
SETKTVdll_POINTER SETKTVdll
RESIDUALdll_TYPE * RESIDUALdll_POINTER
RESIDUALdll_POINTER RESIDUALdll
double surface_tension_T(double T)
ENTROdll_POINTER ENTROdll
DSFLSHdll_POINTER DSFLSHdll
DBDTdll_TYPE * DBDTdll_POINTER
std::vector< double > x(ncmax, 0)
SUBLPdll_POINTER SUBLPdll
std::string REFPROPname
The name of the fluid.
SETREFdll_TYPE * SETREFdll_POINTER
SATHdll_TYPE * SATHdll_POINTER
TEST_CASE("REFPROP Fluid Class Helmholtz derivatives check","[helmholtz],[fast]")
CCRITdll_TYPE * CCRITdll_POINTER
ACTVYdll_POINTER ACTVYdll
TRNPRPdll_TYPE * TRNPRPdll_POINTER
DPDD2dll_POINTER DPDD2dll
CP0dll_TYPE * CP0dll_POINTER
THERM3dll_POINTER THERM3dll
#define lengthofreference
PHFLSHdll_POINTER PHFLSHdll
double setFunctionPointers()
#define errormessagelength
CRITPdll_POINTER CRITPdll
THERM0dll_POINTER THERM0dll
QMASSdll_POINTER QMASSdll
DHFLSHdll_POINTER DHFLSHdll
TPFLSHdll_POINTER TPFLSHdll
DBFL2dll_TYPE * DBFL2dll_POINTER
INFOdll_TYPE * INFOdll_POINTER
double double *typedef double double *typedef double *typedef double double *typedef double double *typedef RPVersion_TYPE * RPVersion_POINTER
GERG04dll_POINTER GERG04dll
PHFL1dll_POINTER PHFL1dll
DHFL2dll_POINTER DHFL2dll
double dphi0_dTau(double tau, double delta)
double d2phir_dDelta_dTau(double tau, double delta)
XMASSdll_POINTER XMASSdll
TQFLSHdll_TYPE * TQFLSHdll_POINTER
TPRHOdll_TYPE * TPRHOdll_POINTER
#define REQUIRE_THROWS(expr)
DPDTdll_TYPE * DPDTdll_POINTER
struct CriticalStruct crit
PSFLSHdll_TYPE * PSFLSHdll_POINTER
PRESSdll_TYPE * PRESSdll_POINTER
VIRBdll_TYPE * VIRBdll_POINTER
DBFL1dll_POINTER DBFL1dll
DEFLSHdll_POINTER DEFLSHdll
PREOSdll_POINTER PREOSdll
ABFL1dll_POINTER ABFL1dll
DPDDdll_TYPE * DPDDdll_POINTER
SUBLTdll_POINTER SUBLTdll
GETKTVdll_POINTER GETKTVdll
GIBBSdll_POINTER GIBBSdll
MLTH2Odll_POINTER MLTH2Odll
CSATKdll_TYPE * CSATKdll_POINTER
double dphir_dTau(double tau, double delta)
REQUIRE(fabs(CPWater.p()-RPWater.p())< 1e-4)
void * getFunctionPointer(char *name)
MELTTdll_TYPE * MELTTdll_POINTER
SETUPdll_POINTER SETUPdll
LIMITSdll_POINTER LIMITSdll
TPFLSHdll_TYPE * TPFLSHdll_POINTER
GETKTVdll_TYPE * GETKTVdll_POINTER
SURTENdll_POINTER SURTENdll
void saturation_T(double T, bool UseLUT, double &psatLout, double &psatVout, double &rhosatLout, double &rhosatVout)
CVCPKdll_TYPE * CVCPKdll_POINTER
SETMIXdll_POINTER SETMIXdll
FGCTYdll_TYPE * FGCTYdll_POINTER
SATEdll_TYPE * SATEdll_POINTER
long get_param_index(std::string param)
DSFLSHdll_TYPE * DSFLSHdll_POINTER
LIMITKdll_TYPE * LIMITKdll_POINTER
RPVersion_POINTER RPVersion
PSFLSHdll_POINTER PSFLSHdll
double density_Tp(double T, double p)
THERM2dll_POINTER THERM2dll
ACTVYdll_TYPE * ACTVYdll_POINTER
#define REQUIRE_NOTHROW(expr)
SURFTdll_TYPE * SURFTdll_POINTER
TSFLSHdll_TYPE * TSFLSHdll_POINTER
PQFLSHdll_TYPE * PQFLSHdll_POINTER
void * RefpropdllInstance
GIBBSdll_TYPE * GIBBSdll_POINTER
FGCTYdll_POINTER FGCTYdll
void temperature_ph(double p, double h, double &Tout, double &rhoout, double &rhoLout, double &rhoVout, double &TsatLout, double &TsatVout, double T0, double rho0)
SATTdll_TYPE * SATTdll_POINTER
DPDTKdll_POINTER DPDTKdll
CCRITdll_POINTER CCRITdll
DOTFILLdll_POINTER DOTFILLdll
double convert_from_unit_system_to_SI(long iInput, double value, int old_system)
#define SECTION(name, description)
DPDD2dll_TYPE * DPDD2dll_POINTER
DDDPdll_TYPE * DDDPdll_POINTER
CRITPdll_TYPE * CRITPdll_POINTER
XMOLEdll_TYPE * XMOLEdll_POINTER
DOTFILLdll_TYPE * DOTFILLdll_POINTER
SETREFdll_POINTER SETREFdll
ENTHALdll_TYPE * ENTHALdll_POINTER
SATDdll_TYPE * SATDdll_POINTER
DHFLSHdll_TYPE * DHFLSHdll_POINTER
XMOLEdll_POINTER XMOLEdll
DBFL2dll_POINTER DBFL2dll
HSFLSHdll_TYPE * HSFLSHdll_POINTER
DSFL2dll_POINTER DSFL2dll
DPDDKdll_TYPE * DPDDKdll_POINTER
SATSdll_TYPE * SATSdll_POINTER
SETMODdll_TYPE * SETMODdll_POINTER
ABFL2dll_TYPE * ABFL2dll_POINTER
ENTHALdll_POINTER ENTHALdll
void saturation_p(double p, bool UseLUT, double &TsatLout, double &TsatVout, double &rhosatLout, double &rhosatVout)
DSFL1dll_POINTER DSFL1dll
PREOSdll_TYPE * PREOSdll_POINTER
DEFLSHdll_TYPE * DEFLSHdll_POINTER
TRNPRPdll_POINTER TRNPRPdll
DBFL1dll_TYPE * DBFL1dll_POINTER
PDFLSHdll_TYPE * PDFLSHdll_POINTER
CVCPdll_TYPE * CVCPdll_POINTER
double REFPROP(char Output, char Name1, double Prop1, char Name2, double Prop2, char *Ref)
THERM2dll_TYPE * THERM2dll_POINTER
DHFL1dll_POINTER DHFL1dll
PSFL1dll_POINTER PSFL1dll
PDFL1dll_TYPE * PDFL1dll_POINTER
NAMEdll_TYPE * NAMEdll_POINTER
PDFL1dll_POINTER PDFL1dll
double viscosity_Trho(double T, double rho)
TPRHOdll_POINTER TPRHOdll
DPDDKdll_POINTER DPDDKdll