2 #define _CRT_SECURE_NO_WARNINGS
7 #if defined(__ISWINDOWS__)
10 #if !defined(__powerpc__)
14 #include <sys/types.h>
30 #include <sys/types.h>
37 #if defined(__powerpc__)
38 #define CLOCKS_PER_SEC 1000
48 #if defined(__ISLINUX__)
50 home = getenv(
"HOME");
51 return std::string(home);
52 #elif defined(__ISAPPLE__)
54 home = getenv(
"HOME");
56 struct passwd* pwd = getpwuid(getuid());
65 return std::string(home);
66 #elif defined(__ISWINDOWS__)
67 char * pUSERPROFILE = getenv(
"USERPROFILE");
68 if (pUSERPROFILE != NULL) {
69 return std::string(pUSERPROFILE);
71 char * pHOMEDRIVE = getenv(
"HOMEDRIVE");
72 char * pHOMEPATH = getenv(
"HOMEPATH");
73 if (pHOMEDRIVE != NULL && pHOMEPATH != NULL) {
74 return std::string(pHOMEDRIVE) + std::string(pHOMEPATH);
76 return std::string(
"");
85 const static double Ainv[16][16] = {
86 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
87 { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
88 {-3, 3, 0, 0, -2, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
89 { 2, -2, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
90 { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0},
91 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0},
92 { 0, 0, 0, 0, 0, 0, 0, 0, -3, 3, 0, 0, -2, -1, 0, 0},
93 { 0, 0, 0, 0, 0, 0, 0, 0, 2, -2, 0, 0, 1, 1, 0, 0},
94 {-3, 0, 3, 0, 0, 0, 0, 0, -2, 0, -1, 0, 0, 0, 0, 0},
95 { 0, 0, 0, 0, -3, 0, 3, 0, 0, 0, 0, 0, -2, 0, -1, 0},
96 { 9, -9, -9, 9, 6, 3, -6, -3, 6, -6, 3, -3, 4, 2, 2, 1},
97 {-6, 6, 6, -6, -3, -3, 3, 3, -4, 4, -2, 2, -2, -2, -1, -1},
98 { 2, 0, -2, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0},
99 { 0, 0, 0, 0, 2, 0, -2, 0, 0, 0, 0, 0, 1, 0, 1, 0},
100 {-6, 6, 6, -6, -4, -2, 4, 2, -3, 3, -3, 3, -2, -1, -2, -1},
101 { 4, -4, -4, 4, 2, 2, -2, -2, 2, -2, 2, -2, 1, 1, 1, 1}
105 return (r > 0.0) ? floor(r + 0.5) : ceil(r - 0.5);
111 for (
unsigned int i = 0; i < 16; i++)
114 for (
unsigned int j = 0; j < 16; j++)
116 sum += Ainv[i][j]*(*x)[j];
135 #if defined(__ISWINDOWS__)
142 srand((
unsigned int)time(NULL));
176 s.resize(Nh, std::vector<double>(Np, _HUGE));
177 dsdh.resize(Nh, std::vector<double>(Np, _HUGE));
178 dsdp.resize(Nh, std::vector<double>(Np, _HUGE));
179 d2sdh2.resize(Nh, std::vector<double>(Np, _HUGE));
180 d2sdp2.resize(Nh, std::vector<double>(Np, _HUGE));
181 d2sdhdp.resize(Nh, std::vector<double>(Np, _HUGE));
183 T.resize(Nh, std::vector<double>(Np, _HUGE));
184 dTdh.resize(Nh, std::vector<double>(Np, _HUGE));
185 dTdp.resize(Nh, std::vector<double>(Np, _HUGE));
186 d2Tdh2.resize(Nh, std::vector<double>(Np, _HUGE));
187 d2Tdp2.resize(Nh, std::vector<double>(Np, _HUGE));
188 d2Tdhdp.resize(Nh, std::vector<double>(Np, _HUGE));
190 rho.resize(Nh, std::vector<double>(Np, _HUGE));
191 drhodh.resize(Nh, std::vector<double>(Np, _HUGE));
192 drhodp.resize(Nh, std::vector<double>(Np, _HUGE));
193 d2rhodh2.resize(Nh, std::vector<double>(Np, _HUGE));
194 d2rhodp2.resize(Nh, std::vector<double>(Np, _HUGE));
195 d2rhodhdp.resize(Nh, std::vector<double>(Np, _HUGE));
209 for(
unsigned int i = 0; i <
Nh; i++){
221 s_Trho.resize(NT, std::vector<double>(Nrho, _HUGE));
222 dsdT_Trho.resize(NT, std::vector<double>(Nrho, _HUGE));
223 dsdrho_Trho.resize(NT, std::vector<double>(Nrho, _HUGE));
224 d2sdT2_Trho.resize(NT, std::vector<double>(Nrho, _HUGE));
228 p_Trho.resize(NT, std::vector<double>(Nrho, _HUGE));
229 dpdT_Trho.resize(NT, std::vector<double>(Nrho, _HUGE));
230 dpdrho_Trho.resize(NT, std::vector<double>(Nrho, _HUGE));
231 d2pdT2_Trho.resize(NT, std::vector<double>(Nrho, _HUGE));
235 h_Trho.resize(NT, std::vector<double>(Nrho, _HUGE));
236 dhdT_Trho.resize(NT, std::vector<double>(Nrho, _HUGE));
237 dhdrho_Trho.resize(NT, std::vector<double>(Nrho, _HUGE));
238 d2hdT2_Trho.resize(NT, std::vector<double>(Nrho, _HUGE));
242 k_Trho.resize(NT, std::vector<double>(Nrho, _HUGE));
243 dkdT_Trho.resize(NT, std::vector<double>(Nrho, _HUGE));
244 dkdrho_Trho.resize(NT, std::vector<double>(Nrho, _HUGE));
245 d2kdT2_Trho.resize(NT, std::vector<double>(Nrho, _HUGE));
249 mu_Trho.resize(NT, std::vector<double>(Nrho, _HUGE));
250 dmudT_Trho.resize(NT, std::vector<double>(Nrho, _HUGE));
251 dmudrho_Trho.resize(NT, std::vector<double>(Nrho, _HUGE));
252 d2mudT2_Trho.resize(NT, std::vector<double>(Nrho, _HUGE));
330 *i += 1; *j += 1;
return;
334 *i -= 1; *j -= 1;
return;
338 *j -= 1; *i += 1;
return;
342 *j += 1; *i -= 1;
return;
375 *i += 1; *j += 1;
return;
379 *i -= 1; *j -= 1;
return;
383 *j -= 1; *i += 1;
return;
387 *j += 1; *i -= 1;
return;
458 std::string
join(std::vector<std::string> strings,
char delim)
460 std::string output = strings[0];
461 for (
unsigned int i = 1; i < strings.size(); i++)
463 output +=
format(
"%c%s",delim,strings[i].c_str());
471 pFile = fopen(fName.c_str(),
"wb");
474 for (
unsigned int i = 0; i <
Nh; i++)
476 fwrite(&(((*A)[i])[0]),
sizeof(
double),
Np,pFile);
485 pFile = fopen(fName.c_str(),
"rb");
488 for (
unsigned int i = 0; i <
Nh; i++)
493 fread(&(((*A)[i])[0]),
sizeof(
double),
Np,pFile);
502 pFile = fopen(fName.c_str(),
"wb");
505 fwrite((
const char *)&(*A).front(),
sizeof(double),(*A).size(),pFile);
512 pFile = fopen(fName.c_str(),
"rb");
515 fread(&((*vec)[0]),
sizeof(
double), N, pFile);
521 #if defined(__ISWINDOWS__) // Defined for 32-bit and 64-bit windows
525 if ( _stat( path.c_str(), &buf) == 0)
529 #elif defined(__ISLINUX__) || defined(__ISAPPLE__)
538 if(lstat(path.c_str(),&st) == 0) {
539 if(S_ISDIR(st.st_mode))
return true;
540 if(S_ISREG(st.st_mode))
return true;
557 std::vector<std::string> pathsplit =
strsplit(file_path,
'/');
558 std::string path = pathsplit[0];
559 if (pathsplit.size()>0)
561 for (
unsigned int i = 0; i < pathsplit.size(); i++)
566 #if defined(_UNICODE)
567 CreateDirectoryA((LPCSTR)path.c_str(),NULL);
569 CreateDirectory((LPCSTR)path.c_str(),NULL);
572 #if defined(__powerpc__)
574 mkdir(path.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
578 if (i < pathsplit.size()-1)
579 path +=
format(
"/%s",pathsplit[i+1].c_str());
595 for (
unsigned int i = 0; i<root_path.length(); i++)
597 if (root_path[i] ==
'\\') root_path[i] =
'/';
600 if (root_path[root_path.size()-1] ==
'/')
601 root_path = std::string(root_path,0,root_path.size()-1);
614 #if defined(__ISWINDOWS__)
615 std::vector<std::string> lines =
strsplit(info,
'\r');
617 std::vector<std::string> lines =
strsplit(info,
'\n');
620 for (
unsigned int i = 0; i< lines.size(); i++) {
623 std::vector<std::string> line =
strsplit(lines[i],
':');
624 if (line.size() == 1)
627 if (line[0].find(
"Fluid")!= std::string::npos){
629 else if (line[0].find(
"hmin")!= std::string::npos) {
630 hmin = strtod(line[1].c_str(),NULL);}
631 else if (line[0].find(
"hmax")!= std::string::npos) {
632 hmax = strtod(line[1].c_str(),NULL);}
633 else if (line[0].find(
"pmin")!= std::string::npos) {
634 pmin = strtod(line[1].c_str(),NULL);}
635 else if (line[0].find(
"pmax")!= std::string::npos) {
636 pmax = strtod(line[1].c_str(),NULL);}
637 else if (line[0].find(
"Np")!= std::string::npos) {
638 Np = (int)strtol(line[1].c_str(),NULL,0);}
639 else if (line[0].find(
"Nh")!= std::string::npos) {
640 Nh = (int)strtol(line[1].c_str(),NULL,0);}
641 else if (line[0].find(
"Tmin")!= std::string::npos) {
642 Tmin = strtod(line[1].c_str(),NULL);}
643 else if (line[0].find(
"Tmax")!= std::string::npos) {
644 Tmax = strtod(line[1].c_str(),NULL);}
645 else if (line[0].find(
"rhomin")!= std::string::npos) {
646 rhomin = strtod(line[1].c_str(),NULL);}
647 else if (line[0].find(
"rhomax")!= std::string::npos) {
648 rhomax = strtod(line[1].c_str(),NULL);}
649 else if (line[0].find(
"NT")!= std::string::npos) {
650 NT = (int)strtol(line[1].c_str(),NULL,0);}
651 else if (line[0].find(
"Nrho")!= std::string::npos) {
652 Nrho = (int)strtol(line[1].c_str(),NULL,0);}
653 else if (line[0].find(
"TTSERev")!= std::string::npos) {
654 TTSERev = (int)strtol(line[1].c_str(),NULL,0);}
660 && Nh == (
int)this->Nh
661 && Np == (int)this->Np
667 &&
Nrho == this->Nrho
730 this->
pratio = pow(pmax/pmin,1/((
double)Np-1));
748 for (
unsigned int i = 0; i<root_path.length(); i++)
750 if (root_path[i] ==
'\\') root_path[i] =
'/';
753 if (root_path[root_path.size()-1] ==
'/')
754 root_path = std::string(root_path,0,root_path.size()-1);
762 std::string header = std::string(
"Data for the TTSE method\nDO NOT CHANGE ANY OF THESE PARAMETERS FOR ANY REASON!\n\n");
764 header +=
format(
"TTSERev:%d\nFluid:%s\npmin:%23.19g\npmax:%23.19g\nNp:%25d\nhmin:%23.19g\nhmax:%23.19g\nNh:%25d\nTmin:%23.19g\nTmax:%23.19g\nNT:%25d\nrhomin:%23.19g\nrhomax:%23.19g\nNrho:%25d\n",
TTSEREV,
pFluid->
get_name().c_str(),
pmin,
pmax,
Np,
hmin,
hmax,
Nh,
Tmin,
Tmax,
NT,
rhomin,
rhomax,
Nrho);
771 fp = fopen((root_path+std::string(
"Info_ph.txt")).c_str(),
"w");
772 fprintf(fp,
"%s",header.c_str());
831 std::cout <<
"write time: " << (double)(t2-t1)/CLOCKS_PER_SEC << std::endl;
836 bool SinglePhase =
false;
848 double dh = (hmax -
hmin)/(
Nh - 1);
849 pratio = pow(pmax/pmin,1/((
double)
Np-1));
854 for (
unsigned int i = 0; i<
Nh; i++)
856 double hval = hmin + i*dh;
858 for (
unsigned int j = 0; j<
Np; j++)
860 double pval = pmin*pow(
pratio,(
int)j);
867 if (SatL == NULL || SatV == NULL){
870 SinglePhase = (hval < CPS.
hL() || hval > CPS.
hV());
887 double T0=-1,rho0=-1,
T,
rho,rhoL,rhoV,TsatL,TsatV;
893 if (T0 > 0 && rho0 > 0)
905 double hsatLTTSE,hsatVTTSE;
906 if (SatL == NULL || SatV == NULL){
909 hsatLTTSE = CPS.
hL();
910 hsatVTTSE = CPS.
hV();
918 if (fabs(hval-hsatLTTSE)<10)
927 else if (fabs(hval-hsatVTTSE)<10)
945 double cp = CPS.
cp();
952 this->rho[i][j] =
rho;
988 catch(std::exception &)
997 this->
T[i][j] = _HUGE;
1004 this->
rho[i][j] = _HUGE;
1021 this->
T[i][j] = _HUGE;
1028 this->
rho[i][j] = _HUGE;
1040 double elap = (double)(t2-t1)/CLOCKS_PER_SEC;
1041 std::cout << elap <<
" to build single phase table with p,h" << std::endl;
1053 bool SinglePhase =
false;
1055 if (Tmin < 0 && Tmax < 0 && rhomin < 0 && rhomax < 0)
1062 for (
unsigned int i = 0; i<
Nh; i++)
1064 for (
unsigned int j = 0; j<
Np; j++)
1095 double dT = (Tmax -
Tmin)/((
double)
NT - 1);
1100 for (
unsigned int i = 0; i<
NT; i++)
1102 double Tval = Tmin + i*dT;
1104 for (
unsigned int j = 0; j<
Nrho; j++)
1106 double rhoval = rhomin*pow(
rhoratio,(
int)j);
1113 if (SatL == NULL || SatV == NULL){
1116 SinglePhase = (rhoval < CPS.
rhoV() || rhoval > CPS.
rhoL());
1160 double deltaT = 1e-3, deltarho = 1e-4;
1162 if (deltarho > rhoval)
1163 deltarho = rhoval/100;
1167 double muplusrho =
IPropsSI(
iV,
iT,Tval,
iD,rhoval+deltarho,iFluid);
1168 double muminusrho =
IPropsSI(
iV,
iT,Tval,
iD,rhoval-deltarho,iFluid);
1171 double muplusT_plusrho =
IPropsSI(
iV,
iT,Tval+deltaT,
iD,rhoval+deltarho,iFluid);
1172 double muplusT_minusrho =
IPropsSI(
iV,
iT,Tval+deltaT,
iD,rhoval-deltarho,iFluid);
1173 double muminusT_plusrho =
IPropsSI(
iV,
iT,Tval-deltaT,
iD,rhoval+deltarho,iFluid);
1174 double muminusT_minusrho =
IPropsSI(
iV,
iT,Tval-deltaT,
iD,rhoval-deltarho,iFluid);
1177 dmudT_Trho[i][j] = (-muminusT + muplusT)/(2*deltaT);
1178 dmudrho_Trho[i][j] = (-muminusrho + muplusrho)/(2*deltarho);
1179 d2mudT2_Trho[i][j] = (muminusT - 2*muval + muplusT)/(deltaT*deltaT);
1180 d2mudrho2_Trho[i][j] = (muminusrho - 2*muval + muplusrho)/(deltarho*deltarho);
1181 d2mudTdrho_Trho[i][j] = (muplusT_plusrho - muplusT_minusrho - muminusT_plusrho + muminusT_minusrho)/(2*deltaT*deltarho);
1185 double kplusrho =
IPropsSI(
iL,
iT,Tval,
iD,rhoval+deltarho,iFluid);
1186 double kminusrho =
IPropsSI(
iL,
iT,Tval,
iD,rhoval-deltarho,iFluid);
1189 double kplusT_plusrho =
IPropsSI(
iL,
iT,Tval+deltaT,
iD,rhoval+deltarho,iFluid);
1190 double kplusT_minusrho =
IPropsSI(
iL,
iT,Tval+deltaT,
iD,rhoval-deltarho,iFluid);
1191 double kminusT_plusrho =
IPropsSI(
iL,
iT,Tval-deltaT,
iD,rhoval+deltarho,iFluid);
1192 double kminusT_minusrho =
IPropsSI(
iL,
iT,Tval-deltaT,
iD,rhoval-deltarho,iFluid);
1195 dkdT_Trho[i][j] = (-kminusT + kplusT)/(2*deltaT);
1196 dkdrho_Trho[i][j] = (-kminusrho + kplusrho)/(2*deltarho);
1197 d2kdT2_Trho[i][j] = (kminusT - 2*kval + kplusT)/(deltaT*deltaT);
1198 d2kdrho2_Trho[i][j] = (kminusrho - 2*kval + kplusrho)/(deltarho*deltarho);
1199 d2kdTdrho_Trho[i][j] = (kplusT_plusrho - kplusT_minusrho - kminusT_plusrho + kminusT_minusrho)/(2*deltaT*deltarho);
1242 double elap = (double)(t2-t1)/CLOCKS_PER_SEC;
1243 std::cout << elap <<
" to build single phase table for T,rho" << std::endl;
1255 for (
unsigned int i = 0; i <
NT; i++)
1257 for (
unsigned int j = 0; j <
Nrho; j++)
1259 if (i < NT-1 && j < Nrho-1)
1273 for (
unsigned int i = 0; i <
Nh; i++)
1275 for (
unsigned int j = 0; j <
Np; j++)
1277 if (i < Nh-1 && j < Np-1)
1347 for (
unsigned int j = 0; j <
Np; j++)
1353 for (
unsigned int i = 0; i <
Nh; i++)
1363 for (
int i = Nh-1; i > 0; i--)
1382 throw ValueError(
"SatL and SatV must be provided");
1401 fp = fopen(fName,
"w");
1402 for (
int j =
Np-1; j>=0; j--)
1404 for (
unsigned int i = 0; i<
Nh; i++)
1430 for (
unsigned int i = 0; i < N; i++)
1432 double p1 = ((double)rand()/(double)RAND_MAX)*(
pmax-
pmin)+
pmin;
1433 double h1 = ((double)rand()/(double)RAND_MAX)*(
hmax-
hmin)+
hmin;
1436 double sEOS = CPS.
s();
1437 double cpEOS = CPS.
cp();
1438 double TEOS = CPS.
T();
1439 double rhoEOS = CPS.
rho();
1452 (*EOSv)[i] = sEOS;
break;
1454 (*EOSv)[i] = TEOS;
break;
1456 (*EOSv)[i] = cpEOS;
break;
1458 (*EOSv)[i] = rhoEOS;
break;
1463 std::cout <<
format(
"%g %g %g %g %g (h,p,EOS,TTSE,diff)\n",h1,p1,(*EOSv)[i],(*TTSE)[i],(*EOSv)[i]-(*TTSE)[i]).c_str();
1472 for (
unsigned int i = 0; i < N; i++)
1474 double p1 = ((double)rand()/(double)RAND_MAX)*(
pmax-
pmin)+
pmin;
1475 double h1 = ((double)rand()/(double)RAND_MAX)*(
hmax-
hmin)+
hmin;
1484 return (
double)(t2-t1)/CLOCKS_PER_SEC/(
double)N*1e6;
1491 throw ValueError(
format(
"Input to TTSE [p = %0.16g, h = %0.16g] is out of range",p,h));
1510 double deltap = p-this->p[j];
1511 double deltah = h-this->h[i];
1516 return s[i][j]+deltah*
dsdh[i][j]+deltap*
dsdp[i][j]+0.5*deltah*deltah*
d2sdh2[i][j]+0.5*deltap*deltap*
d2sdp2[i][j]+deltap*deltah*
d2sdhdp[i][j];
break;
1518 return T[i][j]+deltah*
dTdh[i][j]+deltap*
dTdp[i][j]+0.5*deltah*deltah*
d2Tdh2[i][j]+0.5*deltap*deltap*
d2Tdp2[i][j]+deltap*deltah*
d2Tdhdp[i][j];
break;
1522 throw ValueError(
format(
"Output key value [%d] to evaluate is invalid",iParam));
1530 throw ValueError(
format(
"Input to TTSE [T = %0.16g, logrho = %0.16g] is out of range",Tval,logrhoval));
1536 if (Tval < this->
T_Trho[*i])
1552 throw ValueError(
format(
"Input to TTSE [p = %0.16g, h = %0.16g] is out of range",pval,hval));
1558 if (hval < this->
h[*i])
1572 std::vector<double> *alpha = NULL;
1573 std::vector< std::vector<double> > *f = NULL, *dfdp = NULL, *dfdh = NULL, *d2fdhdp = NULL;
1616 double dhdx = (
h[i+1]-
h[i]);
1617 double dpdy = (
p[j+1]-
p[j]);
1634 z_bicubic[12] = (*d2fdhdp)[i][j]*dpdy*dhdx;
1635 z_bicubic[13] = (*d2fdhdp)[i+1][j]*dpdy*dhdx;
1636 z_bicubic[14] = (*d2fdhdp)[i][j+1]*dpdy*dhdx;
1637 z_bicubic[15] = (*d2fdhdp)[i+1][j+1]*dpdy*dhdx;
1663 std::vector<double> *alpha = NULL;
1664 std::vector< std::vector<double> > *f = NULL, *dfdT = NULL, *dfdrho = NULL, *d2fdTdrho = NULL;
1744 z_bicubic[9] = (*dfdrho)[i+1][j]*drhody;
1745 z_bicubic[10] = (*dfdrho)[i][j+1]*drhody;
1746 z_bicubic[11] = (*dfdrho)[i+1][j+1]*drhody;
1748 z_bicubic[12] = (*d2fdTdrho)[i][j]*drhody*dTdx;
1749 z_bicubic[13] = (*d2fdTdrho)[i+1][j]*drhody*dTdx;
1750 z_bicubic[14] = (*d2fdTdrho)[i][j+1]*drhody*dTdx;
1751 z_bicubic[15] = (*d2fdTdrho)[i+1][j+1]*drhody*dTdx;
1827 std::vector<double> *alpha = NULL;
1833 double dhdx = (
h[i+1]-
h[i]);
1834 double dpdy = (
p[j+1]-
p[j]);
1835 double x = (hval-
h[i])/dhdx;
1836 double y = (pval-
p[j])/dpdy;
1841 double x_0 = 1, x_1 =
x, x_2 = x*
x, x_3 = x*x*
x;
1842 double y_0 = 1, y_1 = y, y_2 = y*y, y_3 = y*y*y;
1846 summer = (*alpha)[0+0*4]*x_0*y_0+(*alpha)[0+1*4]*x_0*y_1+(*alpha)[0+2*4]*x_0*y_2+(*alpha)[0+3*4]*x_0*y_3
1847 +(*alpha)[1+0*4]*x_1*y_0+(*alpha)[1+1*4]*x_1*y_1+(*alpha)[1+2*4]*x_1*y_2+(*alpha)[1+3*4]*x_1*y_3
1848 +(*alpha)[2+0*4]*x_2*y_0+(*alpha)[2+1*4]*x_2*y_1+(*alpha)[2+2*4]*x_2*y_2+(*alpha)[2+3*4]*x_2*y_3
1849 +(*alpha)[3+0*4]*x_3*y_0+(*alpha)[3+1*4]*x_3*y_1+(*alpha)[3+2*4]*x_3*y_2+(*alpha)[3+3*4]*x_3*y_3;
1855 std::vector<double> *alpha = NULL;
1861 double dhdx = (this->h[i+1]-this->h[i]);
1862 double dpdy = (this->p[j+1]-this->p[j]);
1863 double x = (h-this->h[i])/dhdx;
1864 double y = (p-this->p[j])/dpdy;
1869 double x_0 = 1, x_1 =
x, x_2 = x*
x, x_3 = x*x*
x;
1870 double y_0 = 1, y_1 = y, y_2 = y*y, y_3 = y*y*y;
1876 double dsummer_dx = +(*alpha)[1+0*4]*1*x_0*y_0+(*alpha)[1+1*4]*1*x_0*y_1+(*alpha)[1+2*4]*1*x_0*y_2+(*alpha)[1+3*4]*1*x_0*y_3
1877 +(*alpha)[2+0*4]*2*x_1*y_0+(*alpha)[2+1*4]*2*x_1*y_1+(*alpha)[2+2*4]*2*x_1*y_2+(*alpha)[2+3*4]*2*x_1*y_3
1878 +(*alpha)[3+0*4]*3*x_2*y_0+(*alpha)[3+1*4]*3*x_2*y_1+(*alpha)[3+2*4]*3*x_2*y_2+(*alpha)[3+3*4]*3*x_2*y_3;
1879 return dsummer_dx/dhdx;
1881 else if (iWRT ==
iP)
1884 double dsummer_dy = (*alpha)[0+1*4]*1*x_0*y_0+(*alpha)[0+2*4]*2*x_0*y_1+(*alpha)[0+3*4]*3*x_0*y_2
1885 +(*alpha)[1+1*4]*1*x_1*y_0+(*alpha)[1+2*4]*2*x_1*y_1+(*alpha)[1+3*4]*3*x_1*y_2
1886 +(*alpha)[2+1*4]*1*x_2*y_0+(*alpha)[2+2*4]*2*x_2*y_1+(*alpha)[2+3*4]*3*x_2*y_2
1887 +(*alpha)[3+1*4]*1*x_3*y_0+(*alpha)[3+2*4]*2*x_3*y_1+(*alpha)[3+3*4]*3*x_3*y_2;
1888 return dsummer_dy/dpdy;
1901 std::vector<double> *alpha = NULL;
1909 double x = (Tval-
T_Trho[i])/dTdx;
1910 double y = (rhoval-
rho_Trho[j])/drhody;
1915 double x_0 = 1, x_1 =
x, x_2 = x*
x, x_3 = x*x*
x;
1916 double y_0 = 1, y_1 = y, y_2 = y*y, y_3 = y*y*y;
1920 summer = (*alpha)[0+0*4]*x_0*y_0+(*alpha)[0+1*4]*x_0*y_1+(*alpha)[0+2*4]*x_0*y_2+(*alpha)[0+3*4]*x_0*y_3
1921 +(*alpha)[1+0*4]*x_1*y_0+(*alpha)[1+1*4]*x_1*y_1+(*alpha)[1+2*4]*x_1*y_2+(*alpha)[1+3*4]*x_1*y_3
1922 +(*alpha)[2+0*4]*x_2*y_0+(*alpha)[2+1*4]*x_2*y_1+(*alpha)[2+2*4]*x_2*y_2+(*alpha)[2+3*4]*x_2*y_3
1923 +(*alpha)[3+0*4]*x_3*y_0+(*alpha)[3+1*4]*x_3*y_1+(*alpha)[3+2*4]*x_3*y_2+(*alpha)[3+3*4]*x_3*y_3;
1930 return ((x>=x1 && x <= x2) || (x>=x2 && x <= x1));
1936 int L,R,M,i,j,phase;
1937 double p,
TL,
TV,
DL,
DV,
SL,
SV, HL, HV, Q, ValV, ValL;
1938 std::vector<std::vector<double> > *mat;
1964 L = 0; R =
Nh-1; M = (L+R)/2;
1966 if (
isbetween((*mat)[M][j],(*mat)[R][j],Other)){
1967 L=M; M=(L+R)/2;
continue;
1970 R=M; M=(L+R)/2;
continue;
1996 L =
IV[j]+1; R =
Nh - 1; M = (L+R)/2;
2006 L = 0; R =
IL[j]-1; M = (L+R)/2;
2018 return HV*Q + (1-Q)*HL;
2028 if (
isbetween((*mat)[M][j],(*mat)[R][j],Other))
2030 L=M; M=(L+R)/2;
continue;
2034 R=M; M=(L+R)/2;
continue;
2064 double y = (p-this->p[j])/(this->p[j+1]-this->p[j]);
2065 double y_0 = 1, y_1 = y, y_2 = y*y, y_3 = y*y*y;
2068 std::vector<double> *alpha = NULL;
2073 double a = (*alpha)[3+0*4]*y_0+(*alpha)[3+1*4]*y_1+(*alpha)[3+2*4]*y_2+(*alpha)[3+3*4]*y_3;
2074 double b = (*alpha)[2+0*4]*y_0+(*alpha)[2+1*4]*y_1+(*alpha)[2+2*4]*y_2+(*alpha)[2+3*4]*y_3;
2075 double c = (*alpha)[1+0*4]*y_0+(*alpha)[1+1*4]*y_1+(*alpha)[1+2*4]*y_2+(*alpha)[1+3*4]*y_3;
2076 double d = (*alpha)[0+0*4]*y_0+(*alpha)[0+1*4]*y_1+(*alpha)[0+2*4]*y_2+(*alpha)[0+3*4]*y_3 - Other;
2086 else if ( 0 <= x0 && x0 <= 1){
2089 else if ( 0 <= x1 && x1 <= 1){
2092 else if ( 0 <= x2 && x2 <= 1){
2097 throw ValueError(
"Multiple solutions found for cubic in TTSE-BICUBIC-P+Other");
2099 return x*(this->
h[i+1]-this->
h[i])+this->
h[i];
2102 else if (iInput1 ==
iH)
2104 throw ValueError(
"Sorry enthalpy and something else other than p is not valid for TTSE");
2109 throw ValueError(
"Neither enthalpy nor pressure provided as the first parameter");
2128 return (buf <= i && i <= (
int)
Np-(buf+1) && buf <= (
int)j && j <= (int)
Nh-(buf+1));
2151 return (buf <= i && i <= (
int)
NT-(buf+1) && buf <= (
int)j && j <= (int)
Nrho-(buf+1));
2165 if (!(buf <= j && j <= (
int)
Np-(buf+1) )) {
2171 { high = this->
T[
Nh-(buf+1)][j]; low = this->
T[buf][j]; }
2172 else if(iOther ==
iS)
2173 { high = this->
s[
Nh-(buf+1)][j]; low = this->
s[buf][j]; }
2174 else if(iOther ==
iD)
2175 { low = this->
rho[
Nh-(buf+1)][j]; high = this->
rho[buf][j]; }
2178 throw ValueError(
"Your input pair was not valid. Please supply either (P,T), (P,S) or (P,D) as inputs.");
2183 {
return !(low>Other || Other>high); }
2196 double p,dh1,dh2,a,b,c;
2197 std::vector<std::vector<double> > *mat;
2217 double deltap = p-this->p[j];
2225 if ( (iOther ==
iT && Other < 1.1*this->
T[
Np-1][j] && Other > this->
T[
Np-1][j])
2226 || (iOther ==
iS && Other < this->
s[
Np-1][j]+0.1 && Other > this->
s[
Np-1][j])
2227 || (iOther ==
iD && Other > 0.85*this->
rho[
Np-1][j] && Other < this->
rho[
Np-1][j])
2236 L = 0; R =
Nh-1; M = (L+R)/2;
2238 if (
isbetween((*mat)[M][j],(*mat)[R][j],Other)){
2239 L=M; M=(L+R)/2;
continue;
2242 R=M; M=(L+R)/2;
continue;
2246 if (fabs((*mat)[L][j]-Other)<fabs((*mat)[R][j]-Other)){
2265 if ( (iOther ==
iT && Other < this->
T[
IV[j]+1][j])
2266 || (iOther ==
iS && Other < this->
s[
IV[j]+1][j])
2267 || (iOther ==
iD && Other > this->
rho[
IV[j]+1][j])
2274 else if ( (iOther ==
iT && Other < 1.1*this->
T[
Np-1][j] && Other > this->
T[
Np-1][j])
2275 || (iOther ==
iS && Other < this->
s[
Np-1][j]+0.1 && Other > this->
s[
Np-1][j])
2276 || (iOther ==
iD && Other > 0.85*this->
rho[
Np-1][j] && Other < this->
rho[
Np-1][j])
2288 if (Other > this->
T[
Nh-1][j])
2289 throw ValueError(
format(
"Input T [%g] is greater than max T [%g] at LUT pressure [%g]",Other,this->
T[
Np-1][j],this->p[j]));
2292 if (Other < this->
rho[
Nh-1][j])
2293 throw ValueError(
format(
"Input rho [%g] is less than minimum rho [%g] at LUT pressure [%g]",Other,this->
rho[
Np-1][j],this->p[j]));
2296 if (Other > this->
s[
Nh-1][j])
2297 throw ValueError(
format(
"Input s [%g] is greater than max s [%g] at LUT pressure [%g]",Other,this->
s[
Np-1][j],this->p[j]));
2301 L =
IV[j]+1; R =
Np-1; M = (L+R)/2;
2304 if (
isbetween((*mat)[M][j],(*mat)[R][j],Other))
2306 L=M; M=(L+R)/2;
continue;
2310 R=M; M=(L+R)/2;
continue;
2314 if (fabs((*mat)[L][j]-Other)<fabs((*mat)[R][j]-Other))
2331 throw ValueError(
format(
"Your inputs [%g,%g] do not yield a valid TTSE node",Input1,Other));
2335 else if ( (iOther ==
iT && Other < SatL->
evaluate(
iT,p))
2344 if ( (iOther ==
iT && Other > this->
T[
IL[j]-1][j])
2345 || (iOther ==
iS && Other > this->
s[
IL[j]-1][j])
2346 || (iOther ==
iD && Other < this->
rho[
IL[j]-1][j])
2356 if (Other < this->
T[0][j])
2357 throw ValueError(
format(
"Input T [%g] is less than min T [%g] at LUT pressure [%g]",Other,this->
T[0][j],this->p[j]));
2360 if (Other > this->
rho[0][j])
2361 throw ValueError(
format(
"Input rho [%g] is greater than max rho [%g] at LUT pressure [%g]",Other,this->
rho[0][j],this->p[j]));
2364 if (Other < this->
s[0][j])
2365 throw ValueError(
format(
"Input s [%g] is less than min s [%g] at LUT pressure [%g]",Other,this->
s[0][j],this->p[j]));
2369 L = 0; R =
IL[j]-1; M = (L+R)/2;
2373 if (
isbetween((*mat)[M][j],(*mat)[R][j],Other))
2375 L=M; M=(L+R)/2;
continue;
2379 R=M; M=(L+R)/2;
continue;
2383 if (fabs((*mat)[L][j]-Other)<fabs((*mat)[R][j]-Other))
2405 c =
T[i][j]-Other+deltap*
dTdp[i][j]+0.5*deltap*deltap*
d2Tdp2[i][j];
2410 c =
s[i][j]-Other+deltap*
dsdp[i][j]+0.5*deltap*deltap*
d2sdp2[i][j];
2419 dh1 = (-b+sqrt(b*b-4*a*c))/(2*a);
2420 dh2 = (-b-sqrt(b*b-4*a*c))/(2*a);
2422 double hspacing = (
hmax-
hmin)/((
double)
Nh-1);
2424 if (fabs(dh1) < 10*hspacing && !(fabs(dh2) < 10*hspacing) )
2425 return dh1+this->
h[i];
2426 else if (fabs(dh2) < 10*hspacing && !(fabs(dh1) < 10*hspacing) )
2427 return dh2+this->h[i];
2430 if (fabs(dh1)<fabs(dh2))
2431 return dh1+this->h[i];
2433 return dh2+this->h[i];
2437 else if (iInput1 ==
iH)
2439 throw ValueError(
"Sorry enthalpy and something else other than p is not valid for TTSE");
2444 throw ValueError(
"Neither enthalpy nor pressure provided as the first parameter");
2452 throw ValueError(
format(
"Input to TTSE [T = %0.16g, rho = %0.16g] is out of range",T,rho));
2471 double deltaT = T - this->
T_Trho[i];
2472 double deltarho = rho - this->
rho_Trho[j];
2487 throw ValueError(
format(
"Output key value [%d] to evaluate is invalid",iOutput));
2496 throw ValueError(
format(
"Input to TTSE deriv [p = %0.16g, h = %0.16g] is out of range",p,h));
2516 double deltah = h-this->h[i];
2517 double deltap = p-this->p[j];
2522 if (iOF ==
iT && iWRT ==
iH && iCONSTANT ==
iP)
2527 else if (iOF ==
iS && iWRT ==
iH && iCONSTANT ==
iP)
2532 else if (iOF ==
iD && iWRT ==
iH && iCONSTANT ==
iP)
2539 else if (iOF ==
iT && iWRT ==
iP && iCONSTANT ==
iH)
2544 else if (iOF ==
iS && iWRT ==
iP && iCONSTANT ==
iH)
2549 else if (iOF ==
iD && iWRT ==
iP && iCONSTANT ==
iH)
2555 throw ValueError(
format(
"Your inputs [%d,%d,%d,%g,%g] are invalid to evaluate_first_derivative",iOF,iWRT,iCONSTANT,p,h));
2569 srand((
unsigned int)time(NULL));
2598 this->
pratio = pow(pmax/pmin,1/((
double)
N-1));
2605 for (
unsigned int i = 0; i <
N-1; i++)
2609 logp[i] = log(
p[i]);
2636 other->
p[i] = this->
p[i];
2637 other->
logp[i] = log(this->
p[i]);
2640 other->
T[i] = CPS.
T();
2643 other->
h[i] = (other->
Q>0.5) ? CPS.
hV() : CPS.
hL();
2646 other->
s[i] = (other->
Q>0.5) ? CPS.
sV() : CPS.
sL();
2649 other->
rho[i] = (other->
Q>0.5) ? CPS.
rhoV() : CPS.
rhoL();
2659 logp[N-1] = log(
p[N-1]);
2677 other->
p[N-1] = CPS.
p();
2678 other->
logp[N-1] = log(
p[N-1]);
2679 other->
T[N-1] = CPS.
T();
2682 other->
h[N-1] = CPS.
h();
2685 other->
s[N-1] = CPS.
s();
2688 other->
rho[N-1] = CPS.
rho();
2695 std::cout << double(t2-t1)/CLOCKS_PER_SEC <<
" to build both two phase tables" << std::endl;
2696 return double(t2-t1)/CLOCKS_PER_SEC;
2701 double logp = log(p);
2710 if (i == (
int)
N || i == (int)
N-1 ) i =
N-2;
2712 if (i<0 || i>(
int)
N-1)
2719 double y1, yc, dydp1;
2723 y1 =
s[i]; yc =
s[i+1]; dydp1 =
dsdp[i];
break;
2725 y1 =
T[i]; yc =
T[i+1]; dydp1 =
dTdp[i];
break;
2727 y1 =
h[i]; yc =
h[i+1]; dydp1 =
dhdp[i];
break;
2739 double X = this->p[i+1] -
p;
2740 double Y1 = y1 - yc;
2741 double X1 = this->p[i+1] - this->p[i];
2742 double dYdX1 = -dydp1;
2743 double n = Y1/(dYdX1*X1);
2744 double a = Y1/pow(X1,1/n);
2745 double Y = a*pow(X,1.0/n);
2754 double x1 = this->logp[i];
2755 double x2 = this->logp[i+1];
2756 double t = (logp-x1)/(x2-x1);
2758 double y1, y2, k1, k2;
2762 y1 = this->
s[i]; y2 = this->
s[i+1]; k1 = this->p[i]*this->
dsdp[i]; k2 = this->p[i+1]*this->dsdp[i+1];
break;
2764 y1 = this->
T[i]; y2 = this->
T[i+1]; k1 = this->p[i]*this->
dTdp[i]; k2 = this->p[i+1]*this->dTdp[i+1];
break;
2766 y1 = this->
h[i]; y2 = this->
h[i+1]; k1 = this->p[i]*this->
dhdp[i]; k2 = this->p[i+1]*this->dhdp[i+1];
break;
2770 y1 = this->
logrho[i]; y2 = this->
logrho[i+1]; k1 = this->p[i]/this->
rho[i]*this->
drhodp[i]; k2 = this->p[i+1]/this->
rho[i+1]*this->drhodp[i+1];
break;
2775 double a = k1*(x2-x1)-(y2-y1);
2776 double b = -k2*(x2-x1)+(y2-y1);
2777 double y = (1-t)*y1+t*y2+t*(1-t)*(a*(1-t)+b*t);
2789 double logp_spacing;
2791 logp_spacing = this->
logp[2]-this->
logp[1];
2794 L = 0; R =
N - 2; M = (L+R)/2;
2804 double t = (T-this->T[L])/(this->T[L+1]-this->T[L]);
2805 double x1 = this->T[L];
2806 double x2 = this->T[L+1];
2807 double y1 = this->logp[L];
2808 double y2 = this->logp[L+1];
2810 double k1 = 1/this->
p[L]/this->
dTdp[L];
2811 double k2 = 1/this->
p[L+1]/this->
dTdp[L+1];
2812 double a = k1*(x2-x1)-(y2-y1);
2813 double b = -k2*(x2-x1)+(y2-y1);
2814 double logp = (1-t)*y1+t*y2+t*(1-t)*(a*(1-t)+b*t);
2821 if (T > this->T[M]){
2822 L=M; M=(L+R)/2;
continue;
2825 R=M; M=(L+R)/2;
continue;
2832 double t = (T-this->T[L])/(this->T[R]-this->T[L]);
2833 double x1 = this->T[L];
2834 double x2 = this->T[R];
2835 double y1 = this->logp[L];
2836 double y2 = this->logp[R];
2838 double k1 = 1/this->
p[L]/this->
dTdp[L];
2839 double k2 = 1/this->
p[R]/this->
dTdp[R];
2840 double a = k1*(x2-x1)-(y2-y1);
2841 double b = -k2*(x2-x1)+(y2-y1);
2842 double logp = (1-t)*y1+t*y2+t*(1-t)*(a*(1-t)+b*t);
2849 double logp = log(p);
2854 if (i == (
int)
N) i =
N-1;
2856 if (i<0 || i>(
int)
N-1)
2861 double pi = this->p[i];
2886 throw ValueError(
format(
"Cannot use the key [%d] provided in evaluate_sat_derivative",iParam));
2894 for (
unsigned int i = 0; i <
N; i++)
2896 double p1 = ((double)rand()/(double)RAND_MAX)*(
pmax-
pmin)+
pmin;
2902 return (
double)(t2-t1)/CLOCKS_PER_SEC/(
double)N*1e6;
2915 for (
unsigned int i = 0; i <
N; i++)
2917 double p1 = ((double)rand()/(double)RAND_MAX)*(
pmax-
pmin)+
pmin;
2920 double hEOS = CPS.
h();
2921 double sEOS = CPS.
s();
2922 double TEOS = CPS.
T();
2923 double rhoEOS = CPS.
rho();
2935 (*EOSv)[i] = sEOS;
break;
2937 (*EOSv)[i] = TEOS;
break;
2939 (*EOSv)[i] = hEOS;
break;
2941 (*EOSv)[i] = rhoEOS;
break;
2946 std::cout <<
format(
"%g %g %g %g TTSE (p,EOS,TTSE, diff)\n",p1,(*EOSv)[i],(*TTSE)[i],((*EOSv)[i]-(*TTSE)[i])).c_str();
std::vector< std::vector< double > > d2Tdhdp
std::vector< double > dTdp
double drhodp_along_sat_vapor(void)
std::vector< std::vector< double > > s
void make_dirs(std::string file_path)
std::vector< double > d2hdp2
void nearest_neighbor_ph(int i, int j, double *T0, double *rho0)
std::vector< std::vector< double > > d2sdh2
std::vector< double > * bicubic_cell_coeffs_Trho(long iParam, int i, int j)
void nearest_good_neighbor_Trho_interpolate(int *i, int *j)
std::vector< double > rho
double interpolate_bicubic_ph(long iParam, double p, double logp, double h)
bool match_pair(long iI1, long iI2, long I1, long I2)
void nearest_good_neighbor_Trho(int *i, int *j)
double evaluate(long iParam, double p, double logp, double h)
bool isbetween(double x1, double x2, double x)
virtual void temperature_ph(double p, double h, double &Tout, double &rhoout, double &rhoL, double &rhoV, double &TsatLout, double &TsatVout, double T0=-1, double rho0=-1)
long get_Fluid_index(std::string FluidName)
std::vector< std::vector< double > > d2sdTdrho_Trho
double build(double pmin, double pmax, TTSETwoPhaseTableClass *other=NULL)
std::vector< std::vector< double > > h_Trho
struct FluidLimits limits
std::vector< double > dhdp
double dhdp_along_sat_vapor(void)
double dsdrho_constT(void)
double check_randomly(long iParam, unsigned int N, std::vector< double > *p, std::vector< double > *EOSv, std::vector< double > *TTSE)
std::vector< std::vector< double > > dhdrho_Trho
void nearest_good_neighbor_ph_interpolate(int *i, int *j)
double d2sdrho2_constT(void)
double d2rhodp2_along_sat_liquid(void)
std::vector< double > dsdp
std::vector< std::vector< double > > rho
std::vector< std::vector< double > > T
double d2hdp2_along_sat_vapor(void)
std::vector< double > d2Tdp2
std::vector< std::vector< double > > p_Trho
BiCubicCellsContainerClass bicubic_cells
void update(long iInput1, double Value1, long iInput2, double Value2, double T0=-1, double rho0=-1)
double d2hdp2_along_sat_liquid(void)
std::string get_home_dir(void)
double bicubic_evaluate_one_other_input(long iInput1, double Input1, long iOther, double Other)
double dhdrho_constp(void)
std::vector< std::vector< double > > k_Trho
void set_size_Trho(unsigned int NT=100, unsigned int Nrho=100)
Set the sizes of the matrices with Trho as inputs.
std::vector< std::vector< double > > dkdrho_Trho
double d2rhodp2_along_sat_vapor(void)
std::vector< std::vector< double > > dpdT_Trho
TTSETwoPhaseTableClass * SatL
struct CriticalStruct reduce
A pointer to the point that is used to reduce the T and rho for EOS.
double interpolate_bicubic_Trho(long iParam, double T, double rho, double logrho)
std::vector< std::vector< double > > dTdp
std::string get_name()
Returns a std::string with the name of the fluid.
std::vector< std::vector< double > > dmudrho_Trho
void bicubic_cell_coordinates_Trho(double Tval, double rho, double logrhoval, int *i, int *j)
Fluid * pFluid
A pointer to a CoolProp fluid.
std::vector< std::vector< double > > mu_Trho
double evaluate_first_derivative(long iOF, long iWRT, long iCONSTANT, double p, double logp, double h)
TTSETwoPhaseTableClass TTSESatV
Fluid is the abstract base class that is employed by all the other fluids.
void sort_pair(long *iInput1, double *Value1, long *iInput2, double *Value2, long I1, long I2)
void bicubic_cell_coordinates_ph(double hval, double p, double logpval, int *i, int *j)
std::vector< std::vector< double > > dkdT_Trho
std::vector< std::vector< double > > d2rhodp2
std::vector< std::vector< double > > d2sdT2_Trho
std::vector< std::vector< double > > dmudT_Trho
bool within_range(long iInput1, double Input1, long iInput2, double Input2)
See if the inputs are within range.
std::vector< std::vector< BiCubicCellClass > > cells
double dhdrho_constT(void)
std::vector< std::vector< double > > dsdrho_Trho
std::vector< std::vector< double > > dhdT_Trho
double dpdrho_constT(void)
std::vector< std::vector< double > > dsdp
double check_randomly(long iParam, unsigned int N, std::vector< double > *h, std::vector< double > *p, std::vector< double > *EOSv, std::vector< double > *TTSE)
double build_ph(double hmin, double hmax, double pmin, double pmax, TTSETwoPhaseTableClass *SatL=NULL, TTSETwoPhaseTableClass *SatV=NULL)
std::vector< double > x(ncmax, 0)
std::vector< std::vector< double > > drhodh
double dhdp_along_sat_liquid(void)
TTSETwoPhaseTableClass()
Default Instantiator.
void write_dotdrawing_tofile(char fName[])
Write a representation of the ph surface to file with O in each "good" spot and "X" in each "bad" one...
std::string join(std::vector< std::string > strings, char delim)
double drhodT_constp(void)
std::vector< std::vector< double > > s_Trho
struct OtherParameters params
std::vector< std::vector< double > > d2sdrho2_Trho
std::vector< double > alpha_bicubic
std::vector< std::vector< double > > d2Tdh2
std::vector< double > logrho
double d2hdT2_constrho(void)
std::vector< std::vector< double > > d2kdrho2_Trho
bool pathExists(std::string path)
bool within_range_one_other_input(long iInput1, double Input1, long iOther, double Other, int buf)
void update_saturation_boundary_indices()
double dsdp_along_sat_vapor(void)
void set_size(unsigned int N)
std::vector< std::vector< double > > d2pdrho2_Trho
std::vector< double > rho_Trho
double d2Tdp2_along_sat(void)
Second derivative of temperature w.r.t. pressure along saturation curve.
double evaluate(long iParam, double p)
std::vector< std::vector< double > > drhodp
std::vector< std::vector< double > > d2mudTdrho_Trho
double evaluate_T(double T)
void vector_from_file(std::string fName, int N, std::vector< double > *A)
std::vector< double > d2rhodp2
double d2pdrho2_constT(void)
double d2sdT2_constrho(void)
TTSETwoPhaseTableClass * SatV
void write_all_to_file(std::string root_path=std::string())
double d2sdp2_along_sat_vapor(void)
std::vector< std::vector< double > > d2rhodhdp
void update_cell_validity()
double evaluate_randomly(long iParam, unsigned int N)
std::vector< std::vector< double > > d2mudT2_Trho
double d2sdp2_along_sat_liquid(void)
std::vector< std::vector< double > > d2hdrho2_Trho
double evaluate_randomly(long iParam, unsigned int N)
std::vector< std::vector< double > > d2mudrho2_Trho
double build_Trho(double Tmin, double Tmax, double rhomin, double rhomax, TTSETwoPhaseTableClass *SatL, TTSETwoPhaseTableClass *SatV)
std::vector< std::vector< double > > d2Tdp2
bool read_all_from_file(std::string root_path)
double dsdT_constrho(void)
double dhdT_constrho(void)
double bicubic_evaluate_first_derivative_ph(long iOF, long iWRT, long iCONSTANT, double p, double logp, double h)
void set_size_ph(unsigned int Np=100, unsigned int Nh=100)
Set the sizes of the matrices with h,p as inputs.
std::vector< double > d2sdp2
std::vector< std::vector< double > > dsdT_Trho
double dsdp_along_sat_liquid(void)
std::vector< double > z_bicubic
std::vector< double > drhodp
TTSETwoPhaseTableClass TTSESatL
std::vector< std::vector< double > > d2sdhdp
std::vector< double > * bicubic_cell_coeffs_ph(long iParam, int i, int j)
double dpdrho_consth(void)
std::vector< double > logp
double evaluate_sat_derivative(long iParam, double p)
bool enable_writing_tables_to_files
void matrix_to_file(std::string fName, std::vector< std::vector< double > > *A)
std::vector< std::vector< double > > d2kdTdrho_Trho
std::vector< std::vector< double > > d2pdTdrho_Trho
std::vector< std::vector< double > > d2pdT2_Trho
std::vector< std::vector< double > > d2hdT2_Trho
double d2pdT2_constrho(void)
void vector_to_file(std::string fName, std::vector< double > *A)
std::vector< std::vector< double > > dTdh
double d2hdrho2_constT(void)
void nearest_good_neighbor(int *i, int *j)
std::vector< std::vector< double > > dsdh
double dTdp_along_sat(void)
Derivative of temperature w.r.t. pressure along saturation curve.
EXPORT_CODE double CONVENTION IPropsSI(long iOutput, long iName1, double Prop1, long iName2, double Prop2, long iFluid)
TTSESinglePhaseTableClass()
std::vector< std::vector< double > > d2hdTdrho_Trho
std::vector< std::vector< double > > dpdrho_Trho
std::vector< std::vector< double > > d2kdT2_Trho
double evaluate_one_other_input(long iInput1, double Param1, long iOther, double Other)
Evaluate the TTSE using P,S or P,T.
double evaluate_Trho(long iOutput, double T, double rho, double logrho)
double dpdT_constrho(void)
void matrix_vector_product(std::vector< double > *x, std::vector< double > *y)
std::vector< double > T_Trho
std::vector< std::vector< double > > d2sdp2
std::vector< std::vector< double > > d2rhodh2
void matrix_from_file(std::string fName, std::vector< std::vector< double > > *A)
double drhodp_along_sat_liquid(void)