CoolProp  4.2.5
An open-source fluid property and humid air property database
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
REFPROP.cpp
Go to the documentation of this file.
1 #if defined(_MSC_VER)
2 #define _CRTDBG_MAP_ALLOC
3 #define _CRT_SECURE_NO_WARNINGS
4 #include <crtdbg.h>
5 #include <sys/stat.h>
6 #else
7 #include <sys/stat.h>
8 #endif
9 
10 #include <string>
11 #include "CoolProp.h"
12 
13 #if defined(__ISWINDOWS__)
14 #include <windows.h>
15 #elif defined(__ISLINUX__)
16 #include <dlfcn.h>
17 #elif defined(__ISAPPLE__)
18 #include <dlfcn.h>
19 #endif
20 
21 #include "REFPROP_lib.h"
22 #include "REFPROP.h"
23 #include "CoolPropTools.h"
24 
25 #include <stdlib.h>
26 #include "string.h"
27 #include <stdio.h>
28 #include <iostream>
29 
30 // Some constants for REFPROP... defined by macros for ease of use
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
36 #define numparams 72
37 #define maxcoefs 50
38 
39 // Check windows
40 #if _WIN32 || _WIN64
41  #if _WIN64
42  #define ENV64BIT
43  #else
44  #define ENV32BIT
45  #endif
46 #endif
47 
48 // Check GCC
49 #if __GNUC__
50  #if __x86_64__ || __ppc64__
51  #define ENV64BIT
52  #else
53  #define ENV32BIT
54  #endif
55 #endif
56 
57 std::vector<double> x(ncmax,0), LoadedREFPROPx(ncmax,0);
58 
59 std::string LoadedREFPROPRef;
60 
61 #if defined(__ISWINDOWS__)
62 HINSTANCE RefpropdllInstance=NULL;
63 #elif defined(__ISLINUX__)
64 void *RefpropdllInstance=NULL;
65 #elif defined(__ISAPPLE__)
66 void *RefpropdllInstance=NULL;
67 #else
68 void *RefpropdllInstance=NULL;
69 #endif
70 
71 // Define functions as pointers and initialise them to NULL
72 // Declare the functions for direct access
151 // SPECGRdll_POINTER SPECGRdll; // not found in library
174 
175 void *getFunctionPointer(char * name)
176 {
177  #if defined(__ISWINDOWS__)
178  return (void *) GetProcAddress(RefpropdllInstance,name);
179  #elif defined(__ISLINUX__)
180  return dlsym(RefpropdllInstance,name);
181  #elif defined(__ISAPPLE__)
182  return dlsym(RefpropdllInstance,name);
183  #else
184  throw NotImplementedError("This function should not be called.");
185  return NULL;
186  #endif
187 }
188 
189 //Moved pointer handling to a function, helps to maintain
190 //an overview and structures OS dependent parts
192 {
193  if (RefpropdllInstance==NULL)
194  {
195  printf("REFPROP is not loaded, make sure you call this function after loading the library.\n");
196  return -_HUGE;
197  }
198  // set the pointers, platform independent
272 // SPECGRdll = (SPECGRdll_POINTER) getFunctionPointer((char *)SPECGRdll_NAME); // not in library
294  return COOLPROP_OK;
295 }
296 
297 
298 
299 static long i;
300 static char hfmix[] = "HMX.BNC";
301 static char hrf[] = "DEF";
302 
303 #if defined(__ISWINDOWS__)
304 char refpropPath[] = "";
305 #elif defined(__ISLINUX__)
306 char refpropPath[] = "/opt/refprop";
307 #elif defined(__ISAPPLE__)
308 char refpropPath[] = "/opt/refprop";
309 #else
310 char refpropPath[] = "";
311 #endif
312 
314 {
315  std::string rpPath (refpropPath);
316  #if defined(__ISWINDOWS__)
317  return rpPath;
318  #elif defined(__ISLINUX__)
319  return rpPath + std::string("/fluids/");
320  #elif defined(__ISAPPLE__)
321  return rpPath + std::string("/fluids/");
322  #else
323  throw NotImplementedError("This function should not be called.");
324  return rpPath;
325  #endif
326 }
328 {
329  // If REFPROP is not loaded
330  if (RefpropdllInstance==NULL)
331  {
332  // Load it
333  #if defined(__ISWINDOWS__)
334  #if defined(ENV64BIT)
335  // 64-bit code here.
336  TCHAR refpropdllstring[100] = TEXT("refprp64.dll");
337  RefpropdllInstance = LoadLibrary(refpropdllstring);
338  #elif defined (ENV32BIT)
339  // 32-bit code here.
340  TCHAR refpropdllstring[100] = TEXT("refprop.dll");
341  RefpropdllInstance = LoadLibrary(refpropdllstring);
342  #else
343  // INCREASE ROBUSTNESS. ALWAYS THROW AN ERROR ON THE ELSE.
344  #error "Must define either ENV32BIT or ENV64BIT"
345  #endif
346 
347 
348  #elif defined(__ISLINUX__)
349  RefpropdllInstance = dlopen ("librefprop.so", RTLD_LAZY);
350  #elif defined(__ISAPPLE__)
351  RefpropdllInstance = dlopen ("librefprop.dylib", RTLD_LAZY);
352  #else
353  throw NotImplementedError("We should not reach this point.");
354  RefpropdllInstance = NULL;
355  #endif
356 
357  if (RefpropdllInstance==NULL)
358  {
359  #if defined(__ISWINDOWS__)
360 // int dw = ::GetLastError();
361 // char lpBuffer[256] = _T("?");
362 // if(dwLastError != 0) {
363 // ::FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, // Has to be a system error
364 // NULL, // No formatter
365 // dw, // Get error message for this int
366 // MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), // Use system language
367 // lpBuffer, // Write output
368 // STR_ELEMS(lpBuffer)-1, // Length of output
369 // NULL);
370 // }
371 // printf(lpBuffer);
372 // printf("\n");
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.");
383  #else
384  throw NotImplementedError("Something is wrong with the platform definition, you should not end up here.");
385  #endif
386  return false;
387  }
388 
389  #if defined(__ISWINDOWS__)
390 
391  // Get data associated with path using the windows libraries,
392  // and if you can (result == 0), the path exists
393  #ifdef __MINGW32__
394  struct stat buf;
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");
397  }
398  #else
399  struct _stat buf;
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");
402  }
403  #endif
404  #endif
405 
407  {
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.");
410  return false;
411  }
412  return true;
413  }
414  return true;
415 }
416 
417 bool set_REFPROP_fluid(std::string Ref, std::vector<double> &x)
418 {
419  long ierr=0;
420  char hf[refpropcharlength*ncmax], herr[errormessagelength+1];
421  std::string sRef, components_joined;
422  std::string RefString;
423  std::string fdPath = get_REFPROP_fluid_path();
424 
425  // Check platform support
427  throw NotImplementedError("You cannot use the REFPROPFluidClass.");
428  }
429 
430  // Load REFPROP if it isn't loaded yet
431  load_REFPROP();
432 
433  // If the name of the refrigerant doesn't match
434  // that of the currently loaded refrigerant
435  if (LoadedREFPROPRef.compare(Ref))
436  {
437  // If the fluid name starts with the string "REFPROP-MIX:"
438  if (Ref.find("REFPROP-MIX:") == 0)
439  {
440  // Keep everything after the "REFPROP-MIX:"
441  components_joined = Ref.substr(12,Ref.size()-12);
442 
443  // Sample sRef is "R32[0.697615]&R125[0.302385]" - this is R410A
444  // Or you could do "R410A.mix" to use the full mixture model for this predefined mixture
445 
446  // Try to process predefined mixtures with .mix or .MIX in the file name
447  if (components_joined.find(".mix") != std::string::npos || components_joined.find(".MIX") != std::string::npos)
448  {
449  char hf[255];
450  char hfiles[10000];
451  char herr[255];
452  double xx[ncmax];
453  strcpy(hf,components_joined.c_str());
454 
455  SETMIXdll(hf, hfmix, hrf,
456  &i, hfiles, xx,
457  &ierr, herr,
458  255,
459  255,
460  3, // lengthofreference
461  10000,
462  255);
463  // c-string needs to be 0-terminated
464  for (unsigned int j = 0; j < 255*ncmax; j++)
465  {
466  if (hfiles[j] == 32) // empty char
467  {
468  hfiles[j] = 0;
469  break;
470  }
471  }
472  // Resize the vector of mole fractions
473  x.resize(i);
474 
475  RefString = std::string(hfiles,strlen(hfiles)+1);
476  for (int j = 0; j < i; j++)
477  {
478  x[j] = xx[j];
479  }
480  }
481  else
482  {
483  // Split the components_joined into the components
484  std::vector<std::string> components_split = strsplit(components_joined,'&');
485 
486  if (components_split.size() == 1)
487  {
488  throw ValueError(format("REFPROP mixture specified composition desired [%s], but only one component found",components_joined.c_str()).c_str());
489  }
490 
491  // Flush out the refrigerant string for REFPROP
492  RefString.clear();
493 
494  // Resize the vector of mole fractions
495  x.resize(components_split.size());
496 
497  for (unsigned int j=0;j<components_split.size();j++)
498  {
499  // Get component name and mole fraction (as strings)
500  std::vector<std::string> comp_fraction = strsplit(components_split[j],'[');
501 
502  if (comp_fraction.size() != 2)
503  {
504  throw ValueError(format("Could not parse name[molefraction] [%s]",components_split[j].c_str()).c_str());
505  }
506 
507  // Build the refrigerant string
508  if (j == 0){
509  RefString = fdPath + comp_fraction[0]+".fld";
510  }
511  else{
512  RefString += "|" + fdPath + comp_fraction[0]+".fld";
513  }
514  // Convert the mole fraction (as string) to a number
515  x[j] = strtod(comp_fraction[1].c_str(),NULL);
516 
517  // Update the number of components
518  i = j+1;
519  }
520  }
521  }
522  // Name starts with REFPROP-
523  else if (Ref.find("REFPROP-") == 0)
524  {
525  // Keep everything after the "REFPROP-"
526  sRef = Ref.substr(8,Ref.size()-8);
527 
528  if (!sRef.compare("Air") || !sRef.compare("R507A") || !sRef.compare("R404A") || !sRef.compare("R410A") || !sRef.compare("R407C") || !sRef.compare("SES36"))
529  {
530  i=1;
531  RefString = fdPath + std::string(sRef)+std::string(".ppf");
532  x[0]=1.0; //Pseudo-Pure fluid
533  }
534  else
535  {
536  i=1;
537  RefString = fdPath + std::string(sRef)+std::string(".fld");
538  x[0]=1.0; //Pure fluid
539  }
540  }
541  else
542  {
543  throw ValueError(format("REFPROP fluid string [%s] is invalid", Ref.c_str()));
544  }
545 
546  ierr=999;
547  // Set path to fluid files
548 // // std::string rpPath (refpropfluidpath);
549 // if (rpPath.length()>0)
550 // {
551 // printf("Setting REFPROP path to: %s\n",rpPath.c_str());
552 // char refproppath[refpropcharlength+1];
553 // strcpy(refproppath,rpPath.c_str());
554 // SETPATHdll(refproppath);
555 // free(refproppath);
556 // }
557 
558  char* hfm = (char*) calloc(refpropcharlength+8, sizeof(char));
559  strcpy(hfm,fdPath.c_str());
560  strcat(hfm,hfmix);
561  strcpy(hf,RefString.c_str());
562 
563  //...Call SETUP to initialize the program
564  SETUPdll(&i, hf, hfm, hrf, &ierr, herr,
567 
568  if (ierr > 0){
569  //...Call SETUP with capital letters
570  for(unsigned int j = 0; j < strlen(hrf); j++)
571  {
572  hrf[j] = toupper(hrf[j]);
573  }
574  for(unsigned int j = 0; j < strlen(hfm); j++)
575  {
576  hfm[j] = toupper(hfm[j]);
577  }
578  for(unsigned int j = 0; j < strlen(hf); j++)
579  {
580  hf[j] = toupper(hf[j]);
581  }
582  SETUPdll(&i, hf, hfm, hrf, &ierr, herr,
585  }
586 
587  if (ierr > 0){
588  //...Call SETUP with lower case letters
589  for(unsigned int j = 0; j < strlen(hrf); j++)
590  {
591  hrf[j] = tolower(hrf[j]);
592  }
593  for(unsigned int j = 0; j < strlen(hfm); j++)
594  {
595  hfm[j] = tolower(hfm[j]);
596  }
597  for(unsigned int j = 0; j < strlen(hf); j++)
598  {
599  hf[j] = tolower(hf[j]);
600  }
601  SETUPdll(&i, hf, hfm, hrf, &ierr, herr,
604  }
605 
606  free (hfm);
607 
608  if (ierr > 0){
609  throw ValueError(format("REFPROP: %s",herr).c_str());
610  return false;
611  }
612  else if (ierr < 0)
613  {
614  set_warning(herr);
615  }
616  //Copy the name of the loaded refrigerant back into the temporary holder
617  LoadedREFPROPRef = std::string(Ref);
618 
619  unsigned int jmax;
620  for (jmax = 0; jmax < ncmax; jmax++)
621  {
622  if (jmax == x.size())
623  {
624  break;
625  }
626  if (x[jmax] < 1e-13)
627  {
628  break;
629  }
630  }
631  x.resize(jmax);
632  LoadedREFPROPx = x;
633  return true;
634  }
635  else
636  {
637  x = LoadedREFPROPx;
638  }
639  return true;
640 }
641 double REFPROP(char Output, char Name1, double Prop1, char Name2, double Prop2, char * Ref)
642 {
643  return REFPROP(std::string(1,Output),std::string(1,Name1),Prop1,std::string(1,Name2),Prop2,std::string(Ref));
644 }
664 double REFPROP(std::string Output, std::string Name1, double Prop1, std::string Name2, double Prop2, std::string Ref)
665 {
666  long iOutput = get_param_index(Output);
667  long iName1 = get_param_index(Name1);
668  long iName2 = get_param_index(Name2);
669 
670  // Return the input if the output is the same as the input
671  if (iOutput == iName1){return Prop1;}
672  if (iOutput == iName2){return Prop2;}
673 
674  // Convert input values to SI
677 
678  // Call REFPROPSI
679  double output_val = REFPROPSI(iOutput, iName1, Prop1, iName2, Prop2, Ref);
680 
681  // Convert back to desired unit system
682  return convert_from_SI_to_unit_system(iOutput,output_val,get_standard_unit_system());
683 
684 }
685 double REFPROPSI(long iOutput, long iName1, double Prop1, long iName2, double Prop2, std::string Ref)
686 {
688  printf("You cannot use REFPROP, returning.");
689  return _HUGE;
690  }
691 
692  long ierr=0;
693  char herr[errormessagelength+1];
694  double xliq[ncmax],xvap[ncmax], dummyv[ncmax], output_val;
695 
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;
699 
700  // First create a pointer to an instance of the library
701  load_REFPROP();
702 
703  set_REFPROP_fluid(Ref, x);
704 
705  strcpy(herr,"Ok");
706 
707  // Return the input if the output is the same as the input
708  if (iOutput == iName1){return Prop1;}
709  if (iOutput == iName2){return Prop2;}
710 
711  // Get the molar mass of the fluid
712  WMOLdll(&(x[0]),&MW);
713  if (iOutput == iTcrit)
714  {
715  // Critical temperature
716  CRITPdll(&(x[0]),&Tcrit,&pcrit,&dcrit,&ierr,herr,255); if (ierr > 0) { throw ValueError(format("%s",herr).c_str()); } else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
717  output_val = Tcrit;
718  }
719  else if (iOutput==iMM)
720  {
721  // mole mass
722  output_val = MW;
723  }
724  else if (iOutput==iPcrit)
725  {
726  // Critical pressure
727  CRITPdll(&(x[0]),&Tcrit,&pcrit,&dcrit,&ierr,herr,255); if (ierr > 0) { throw ValueError(format("%s",herr).c_str()); } else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
728  output_val = pcrit*1000;
729  }
730  else if (iOutput ==iRhocrit)
731  {
732  // Critical density
733  CRITPdll(&(x[0]),&Tcrit,&pcrit,&dcrit,&ierr,herr,255); if (ierr > 0) { throw ValueError(format("%s",herr).c_str()); } else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
734  output_val = dcrit*MW;
735 
736  }
737  else if (iOutput == iTmin)
738  {
739  // Minimum temperature
740  double tmin,tmax,Dmax,pmax;
741  LIMITSdll((char *)"EOS",&(x[0]),&tmin,&tmax,&Dmax,&pmax,255); if (ierr > 0) { throw ValueError(format("%s",herr).c_str()); } else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
742  output_val = tmin;
743  }
744  else if (iOutput == iAccentric)
745  {
746  double wmm,Ttriple,tnbpt,tc,pc,Dc,Zc,acf,dip,Rgas;
747  // Accentric factor
748  if (i>1)
749  {
750  fprintf(stderr,"Error: Accentric factor only defined for pure fluids\n");
751  output_val = _HUGE;
752  }
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());}
754  output_val = acf;
755  }
756  else if (iOutput ==iDipole)
757  {
758  double wmm,Ttriple,tnbpt,tc,pc,Dc,Zc,acf,dip,Rgas;
759  // Dipole moment
760  if (i>1)
761  {
762  fprintf(stderr,"Error: Dipole moment only defined for pure fluids\n");
763  output_val = _HUGE;
764  }
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());}
766  output_val = dip;
767  }
768  else if (iOutput==iTtriple)
769  {
770  long icomp;
771  double wmm,Ttriple,tnbpt,tc,pc,Dc,Zc,acf,dip,Rgas;
772  // Triple point temperature
773  icomp=1;
774  if (i>1)
775  {
776  fprintf(stderr,"Error: Triple point temperature only defined for pure fluids\n");
777  return 200;
778  }
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;
781  }
782  else if (iOutput==iI)
783  {
784  if (iName1==iT){
785  SURFTdll(&Prop1,&dl,&(x[0]),&sigma,&i,herr,errormessagelength); if (ierr > 0) { throw ValueError(format("%s",herr).c_str()); } else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
786  output_val = sigma;
787  }
788  else{
789  std::cout<< "If surface tension is the output, temperature must be the first input" << std::endl;
790  output_val = _HUGE;
791  }
792  }
793 
794  // Inputs that do not involve Saturation calls with quality imposed directly
795  else if (iName1!=iQ && iName2 != iQ)
796  {
797  if ((iName1==iT && iName2 == iP) || (iName2== iT && iName1== iP))
798  {
799  // T in K, P in Pa
800  if (iName1 == iP){ std::swap(Prop1,Prop2); }
801 
802  T = Prop1; p = Prop2/1000.0; // Want p in [kPa]
803 
804  // Use flash routine to find properties
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());}
806  }
807  else if ((iName1==iT && iName2==iD) || (iName2==iT && iName1==iD))
808  {
809  // T in K, D in kg/m^3
810  if (iName2 == iT){
811  std::swap(Prop1,Prop2);
812  }
813  T = Prop1; d = Prop2/MW;
814 
815  // This is the explicit formulation of the EOS
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());}
817  }
818  else if ((iName1==iP && iName2==iH) || (iName2==iP && iName1==iH))
819  {
820  // p in Pa, h in J/kg
821  if (iName2 == iP){
822  std::swap(Prop1,Prop2);
823  }
824  p = Prop1/1000.0; h = Prop2*MW/1000; // Want h in J/mol, want p in kPa
825 
826  // Use flash routine to find properties
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());}
828  }
829  else if ((iName1==iP && iName2==iS) || (iName2==iP && iName1==iS))
830  {
831  // p in Pa, h in J/kg
832  if (iName2 == iP){
833  std::swap(Prop1,Prop2);
834  }
835  p = Prop1/1000.0; s = Prop2*MW/1000.0;
836 
837  // Use flash routine to find properties
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());}
839  }
840  else if ((iName1==iH && iName2==iS) || (iName2==iH && iName1==iS))
841  {
842  // H in kJ/kg, s in J/kg/K
843  if (iName2 == iH){
844  std::swap(Prop1,Prop2);
845  }
846  h = Prop1*MW/1000.0; s = Prop2*MW/1000.0;
847 
848  // Use flash routine to find properties
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());}
850  }
851  else if ((iName1==iP && iName2==iD) || (iName2==iP && iName1==iD))
852  {
853  // p in Pa, rho in kg/m^3
854  if (iName2 == iP){
855  std::swap(Prop1,Prop2);
856  }
857  p = Prop1/1000.0; d = Prop2/MW;
858 
859  // Use flash routine to find properties
860  // from REFPROP: subroutine PDFLSH (p,D,z,t,Dl,Dv,x,y,q,e,h,s,cv,cp,w,ierr,herr)
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());}
862  }
863  else if ((iName1==iS && iName2==iD) || (iName2==iS && iName1==iD))
864  {
865  // s in J/kg/K, rho in kg/m^3
866  if (iName2 == iP){
867  std::swap(Prop1,Prop2);
868  }
869  s = Prop1*MW/1000.0; d = Prop2/MW;
870 
871  // Use flash routine to find properties
872  // from REFPROP: subroutine DSFLSH (D,s,z,t,p,Dl,Dv,x,y,q,e,h,cv,cp,w,ierr,herr)
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());}
874  }
875 
876  // Get the output parameter and convert it to SI units
877  switch (iOutput)
878  {
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;
888  case iQ:
889  output_val = (1/d-1/dl)/(1/dv-1/dl); break;
890  case iV:
891  TRNPRPdll(&T,&d,&(x[0]),&eta,&tcx,&ierr,herr,errormessagelength); if (ierr > 0) { throw ValueError(format("%s",herr).c_str()); } else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
892  output_val = eta/1.0e6; //uPa-s to Pa-s
893  break;
894  case iL:
895  TRNPRPdll(&T,&d,&(x[0]),&eta,&tcx,&ierr,herr,errormessagelength); if (ierr > 0) { throw ValueError(format("%s",herr).c_str()); } else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
896  output_val = tcx;
897  break;
898  default:
899  throw ValueError(format("Output parameter [%d] is invalid for REFPROP fluid in REFPROP.cpp",iOutput).c_str());
900  }
901  }
902  // Now the two-phase inputs, either T-Q or P-Q
903  else if ((iName1==iT && iName2==iQ) || (iName2==iT && iName1==iQ) ||
904  (iName1==iP && iName2==iQ) || (iName2==iP && iName1==iQ)
905  )
906  {
907  if (iName1 == iT || iName2 == iT)
908  {
909  if (iName2 == iT){ std::swap(Prop1,Prop2); }
910 
911  T = Prop1; Q = Prop2;
912 
913  // Saturation Density
914  long ic;
915  ic=1;
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());}
917  ic=2;
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());}
919 
920  p = (pv*Q+pl*(1-Q))*1000; // [Pa]
921  }
922  else
923  {
924  if (iName2 == iP){ std::swap(Prop1,Prop2); }
925 
926  p = Prop1/1000; Q = Prop2; // p should be in kPa for REFPROP
927 
928  // Saturation Density for the liquid
929 
930  long ic = 1;
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());}
932  // Saturation density for the vapor
933  ic = 2;
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());}
935 
936  T = (TV*Q+TL*(1-Q));
937  }
938 
939  if (iOutput == iT)
940  {
941  output_val = (TV*Q+TL*(1-Q));
942  }
943  else if (iOutput==iD)
944  {
945  output_val = 1/(Q/dv+(1-Q)/dl)*MW;
946  }
947  else if (iOutput==iP)
948  {
949  output_val = p;
950  }
951  else if (iOutput==iA)
952  {
953  d=1/(Q/dv+(1-Q)/dl);
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());}
955  output_val = w;
956  }
957  else if (iOutput==iH)
958  {
959  ENTHALdll(&T,&dl,xliq,&hl); if (ierr > 0) { throw ValueError(format("%s",herr).c_str()); } else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
960  ENTHALdll(&T,&dv,xvap,&hv); if (ierr > 0) { throw ValueError(format("%s",herr).c_str()); } else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
961  output_val = (hv*Q+hl*(1-Q))/MW*1000; // kJ/kg to J/kg
962  }
963  else if (iOutput==iS)
964  {
965  ENTROdll(&T,&dl,xliq,&sl); if (ierr > 0) { throw ValueError(format("%s",herr).c_str()); } else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
966  ENTROdll(&T,&dv,xvap,&sv); if (ierr > 0) { throw ValueError(format("%s",herr).c_str()); } else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
967  output_val = (sv*Q+sl*(1-Q))/MW*1000; // kJ/kg-K to J/kg-K
968  }
969  else if (iOutput==iU)
970  {
971  ENTHALdll(&T,&dl,xliq,&hl); if (ierr > 0) { throw ValueError(format("%s",herr).c_str()); } else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
972  ENTHALdll(&T,&dv,xvap,&hv); if (ierr > 0) { throw ValueError(format("%s",herr).c_str()); } else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
973  p=pv*Q+pl*(1-Q);
974  ul=hl-p/dl;
975  uv=hv-p/dv;
976  output_val = (uv*Q+ul*(1-Q))/MW*1000; // kJ/kg to J/kg
977  }
978  else if (iOutput==iC)
979  {
980  d = 1/(Q/dv+(1-Q)/dl);
981  CVCPdll(&T,&d,&(x[0]),&cv,&cp); if (ierr > 0) { throw ValueError(format("%s",herr).c_str()); } else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
982  output_val = cp/MW*1000; // kJ/kg-K to J/kg-K
983  }
984  else if (iOutput==iO)
985  {
986  d = 1/(Q/dv+(1-Q)/dl);
987  CVCPdll(&T,&d,&(x[0]),&cv,&cp); if (ierr > 0) { throw ValueError(format("%s",herr).c_str()); } else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
988  output_val = cv/MW*1000; // kJ/kg-K to J/kg-K
989  }
990  else if (iOutput==iV)
991  {
992  d = 1/(Q/dv+(1-Q)/dl);
993  TRNPRPdll(&T,&d,&(x[0]),&eta,&tcx,&ierr,herr,errormessagelength); if (ierr > 0) { throw ValueError(format("%s",herr).c_str()); } else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
994  output_val = eta/1.0e6; //uPa-s to Pa-s
995  }
996  else if (iOutput==iL)
997  {
998  d = 1/(Q/dv+(1-Q)/dl);
999  TRNPRPdll(&T,&d,&(x[0]),&eta,&tcx,&ierr,herr,errormessagelength); if (ierr > 0) { throw ValueError(format("%s",herr).c_str()); } else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
1000  output_val = tcx;
1001  }
1002  else
1003  {
1004  output_val = _HUGE;
1005  }
1006  }
1007  else
1008  {
1009  output_val = _HUGE;
1010  }
1011 
1012  return output_val;
1013 }
1014 
1015 REFPROPFluidClass::REFPROPFluidClass(std::string FluidName, std::vector<double> xmol)
1016 {
1017 
1018  long ierr,ic;
1019  char herr[errormessagelength+1];
1020  std::vector<double> xliq = xmol, xvap = xmol;
1021  double Tcrit,dcrit,pcrit,MW,Ttriple,tnbpt,acf,Zcrit,dip,Rgas, dummy1, dummy2;
1022 
1023  // Check platform support
1025  throw NotImplementedError("You cannot use the REFPROPFluidClass.");
1026  }
1027 
1028  // Load REFPROP if not already loaded
1029  load_REFPROP();
1030 
1031  // Set the fluid
1032  set_REFPROP_fluid(FluidName, xmol);
1033 
1034  // Copy the molar fractions
1035  this->xmol = xmol;
1036 
1037  // Molar mass
1038  WMOLdll(&(xmol[0]),&MW);
1039  params.molemass = MW;
1040 
1041  // Other parameters
1042  INFOdll(&i,&MW,&Ttriple,&tnbpt,&Tcrit,&pcrit,&dcrit,&Zcrit,&acf,&dip,&Rgas);
1043  crit.T = Tcrit;
1044  crit.rho = dcrit*MW;
1045  crit.p = PressureUnit(pcrit,UNIT_KPA);
1046 
1047  params.accentricfactor = acf;
1048  params.R_u = Rgas; // J/(mol*K)
1049  params.Ttriple = Ttriple;
1050  limits.Tmin = Ttriple;
1051 
1052  ic = xmol.size();
1053  xliq.resize(ic);
1054  xvap.resize(ic);
1055  SATTdll(&(Ttriple),&(xmol[0]),&(ic),&(params.ptriple),&dummy1,&dummy2,&(xliq[0]),&(xvap[0]),&ierr,herr,errormessagelength);
1056 
1057  name.assign(FluidName);
1058  //aliases.push_back(FluidName);
1059  REFPROPname.assign(FluidName);
1060 
1061  // Set the reducing values from the pointer
1062  reduce = *preduce;
1063 }
1064 
1065 bool REFPROPFluidClass::supported = true; // initialise with true
1067  /*
1068  * Here we build the bridge from macro definitions
1069  * into the actual code. This is also going to be
1070  * the central place to handle error messages on
1071  * unsupported platforms.
1072  */
1073 
1074  // Abort check if Refprop has been loaded.
1075  if (RefpropdllInstance!=NULL) return true;
1076 
1077  // Store result of previous check.
1078  if (REFPROPFluidClass::supported) {
1079  // Either Refprop is supported or it is the first check.
1080  std::string rpv(RPVersion_NAME);
1081  if (rpv.compare("NOTAVAILABLE")!=0) {
1082  // Function names were defined in "REFPROP_lib.h",
1083  // This platform theoretically supports Refprop.
1084  if (load_REFPROP()) {
1085  return true;
1086  }
1087  else {
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;
1096  return false;
1097  }
1098  } else {
1099  // No definition of function names, we do not expect
1100  // the Refprop library to be available.
1101  REFPROPFluidClass::supported = false;
1102  return false;
1103  }
1104  } else {
1105  return false;
1106  }
1107  return false;
1108 }
1109 
1110 
1111 
1112 double REFPROPFluidClass::dphir_dDelta(double tau, double delta)
1113 {
1114  double p,T,rho,rhobar;
1115  rho = delta*reduce.rho;
1116  rhobar = rho/params.molemass;
1117  T = reduce.T/tau;
1118 
1119  PRESSdll(&T, &rhobar, &(xmol[0]), &p);
1120  return 1/delta*(p/(rho*R()*T)-1);
1121 }
1122 double REFPROPFluidClass::dphir_dTau(double tau, double delta)
1123 {
1124  double T,rho,rhobar,pr,er,hr,sr,cvr,cpr,Ar,Gr;
1125  rho = delta*reduce.rho;
1126  rhobar = rho/params.molemass;
1127  T = reduce.T/tau;
1128 
1129  RESIDUALdll(&T,&rhobar,&(xmol[0]),&pr,&er,&hr,&sr,&cvr,&cpr,&Ar,&Gr);
1130  return er/(params.R_u*T*tau);
1131 }
1132 double REFPROPFluidClass::d2phi0_dTau2(double tau, double delta)
1133 {
1134  double T,rho,rhobar,p0,e0,h0,s0,cv0,cp0,w0,A0,G0;
1135  rho = delta*reduce.rho;
1136  rhobar = rho/params.molemass;
1137  T = reduce.T/tau;
1138 
1139  THERM0dll(&T,&rhobar,&(xmol[0]),&p0,&e0,&h0,&s0,&cv0,&cp0,&w0,&A0,&G0);
1140  // cv0 is in J/mol-K, so is R_u
1141  return -cv0/(params.R_u*tau*tau);
1142 }
1143 double REFPROPFluidClass::d2phir_dTau2(double tau, double delta)
1144 {
1145  double T,rho,rhobar,pr,er,hr,sr,cvr,cpr,Ar,Gr;
1146  rho = delta*reduce.rho;
1147  rhobar = rho/params.molemass;
1148  T = reduce.T/tau;
1149 
1150  RESIDUALdll(&T,&rhobar,&(xmol[0]),&pr,&er,&hr,&sr,&cvr,&cpr,&Ar,&Gr);
1151  // cvr is in J/mol-K, so is R_u
1152  return -cvr/(params.R_u*tau*tau);
1153 }
1154 
1155 double REFPROPFluidClass::d2phir_dDelta_dTau(double tau, double delta)
1156 {
1157  double T,rho,rhobar,dpdT_constrho;
1158  rho = delta*reduce.rho;
1159  rhobar = rho/params.molemass;
1160  T = reduce.T/tau;
1161 
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));
1164 }
1165 double REFPROPFluidClass::d2phir_dDelta2(double tau, double delta)
1166 {
1167  double T,rho,rhobar,dpdrhobar_constT;
1168  rho = delta*reduce.rho;
1169  rhobar = rho/params.molemass;
1170  T = reduce.T/tau;
1171 
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));
1174 }
1175 double REFPROPFluidClass::phir(double tau, double delta)
1176 {
1177  double T,rho,rhobar,pr,er,hr,sr,cvr,cpr,Ar,Gr;
1178  rho = delta*reduce.rho;
1179  rhobar = rho/params.molemass;
1180  T = reduce.T/tau;
1181 
1182  RESIDUALdll(&T,&rhobar,&(xmol[0]),&pr,&er,&hr,&sr,&cvr,&cpr,&Ar,&Gr);
1183  return tau*this->dphir_dTau(tau,delta)-sr/params.R_u;
1184 }
1185 double REFPROPFluidClass::dphi0_dTau(double tau, double delta)
1186 {
1187  double T,rho,rhobar,p0,e0,h0,s0,cv0,cp0,w0,A0,G0;
1188  rho = delta*reduce.rho;
1189  rhobar = rho/params.molemass;
1190  T = reduce.T/tau;
1191 
1192  THERM0dll(&T,&rhobar,&(xmol[0]),&p0,&e0,&h0,&s0,&cv0,&cp0,&w0,&A0,&G0);
1193  return e0/(R()*T*tau)/params.molemass;
1194 }
1195 double REFPROPFluidClass::phi0(double tau, double delta)
1196 {
1197  double T,rho,rhobar,p0,e0,h0,s0,cv0,cp0,w0,A0,G0;
1198  rho = delta*reduce.rho;
1199  rhobar = rho/params.molemass;
1200  T = reduce.T/tau;
1201 
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;
1204 }
1205 
1206 
1207 
1209 {
1210  double dl = 1, sigma;
1211  long ierr = 0;
1212  char herr[errormessagelength+1];
1213  SURFTdll(&T,&dl,&(xmol[0]),&sigma,&ierr,herr,errormessagelength);
1214  return sigma;
1215 }
1216 double REFPROPFluidClass::viscosity_Trho(double T, double rho)
1217 {
1218  long ierr = 0;
1219  char herr[errormessagelength+1];
1220  double eta,tcx,rhobar = rho/params.molemass;
1221 
1222  TRNPRPdll(&T,&rhobar,&(xmol[0]),&eta,&tcx,&ierr,herr,errormessagelength);
1223  return eta/1e6; //[Pa-s]
1224 }
1225 double REFPROPFluidClass::conductivity_Trho(double T, double rho)
1226 {
1227  long ierr = 0;
1228  char herr[errormessagelength+1];
1229  double eta,tcx,rhobar = rho/params.molemass;
1230 
1231  TRNPRPdll(&T,&rhobar,&(xmol[0]),&eta,&tcx,&ierr,herr,errormessagelength);
1232  return tcx; //[W/m/K]
1233 }
1234 
1235 void REFPROPFluidClass::saturation_T(double T, bool UseLUT, double &psatLout, double &psatVout, double &rhosatLout, double &rhosatVout)
1236 {
1237  long ic,ierr;
1238  char herr[errormessagelength+1];
1239  std::vector<double> xliq = xmol, xvap = xmol;
1240  double dummy;
1241 
1242  ic=1;
1243  SATTdll(&T,&(xmol[0]),&ic,&psatLout,&rhosatLout,&dummy,&(xliq[0]),&(xvap[0]),&ierr,herr,errormessagelength);
1244  ic=2;
1245  SATTdll(&T,&(xmol[0]),&ic,&psatVout,&dummy,&rhosatVout,&(xliq[0]),&(xvap[0]),&ierr,herr,errormessagelength);
1246 
1247  // Unit conversions
1248  rhosatLout *= params.molemass;
1249  rhosatVout *= params.molemass;
1250  psatLout *= 1000; // 1000 to go from kPa to Pa
1251  psatVout *= 1000; // 1000 to go from kPa to Pa
1252 }
1253 void REFPROPFluidClass::saturation_p(double p, bool UseLUT, double &TsatLout, double &TsatVout, double &rhosatLout, double &rhosatVout)
1254 {
1255  long ic,ierr;
1256  char herr[errormessagelength+1];
1257  p /= 1000; // 1000 to go from Pa to kPa
1258 
1259  std::vector<double> xliq = xmol,xvap = xmol;
1260  double dummy;
1261  ic=1;
1262  SATPdll(&p,&(xmol[0]),&ic,&TsatLout,&rhosatLout,&dummy,&(xliq[0]),&(xvap[0]),&ierr,herr,errormessagelength);
1263  ic=2;
1264  SATPdll(&p,&(xmol[0]),&ic,&TsatVout,&dummy,&rhosatVout,&(xliq[0]),&(xvap[0]),&ierr,herr,errormessagelength);
1265  rhosatLout *= params.molemass;
1266  rhosatVout *= params.molemass;
1267 }
1268 void REFPROPFluidClass::temperature_ph(double p, double h, double &Tout, double &rho, double &rhoL, double &rhoV, double &TsatL, double &TsatV, double T0, double rho0)
1269 {
1270  double q,e,s,cv,cp,w,hbar = h*params.molemass, dummy1, dummy2;
1271  long ierr;
1272  char herr[errormessagelength+1];
1273  std::vector<double> xliq = xmol, xvap = xmol;
1274 
1275  p /= 1000; // 1000 to go from Pa to kPa
1276  hbar /= 1000; // 1000 to go from J/kmol to J/mol
1277 
1278  PHFLSHdll(&p,&hbar,&(xmol[0]),&Tout,&rho,&rhoL,&rhoV,&(xliq[0]),&(xvap[0]),&q,&e,&s,&cv,&cp,&w,&ierr,herr,errormessagelength);
1279  rho *= params.molemass;
1280  rhoL *= params.molemass;
1281  rhoV *= params.molemass;
1282 
1283  // If a single-phase solution, yield impossible saturation densities so that the phase will be properly calculated
1284  if (double_equal(rhoL, rhoV)){
1285  rhoL = -2;
1286  rhoV = -1;
1287  }
1288  else{
1289  // *1000 to go from kPa to Pa
1290  this->saturation_p(p*1000,false,TsatL,TsatV,dummy1,dummy2);
1291  }
1292 }
1293 void REFPROPFluidClass::temperature_ps(double p, double s, double &Tout, double &rho, double &rhoL, double &rhoV, double &TsatL, double &TsatV)
1294 {
1295  double q,e,h,cv,cp,w,sbar = s*params.molemass, dummy1,dummy2;
1296  long ierr;
1297  std::vector<double> xliq = xmol, xvap = xmol;
1298  char herr[errormessagelength+1];
1299 
1300  p /= 1000; // 1000 to go from Pa to kPa
1301  sbar /= 1000; // 1000 to go from J/kmol/K to J/mol/K
1302 
1303  PSFLSHdll(&p,&sbar,&(xmol[0]),&Tout,&rho,&rhoL,&rhoV,&(xliq[0]),&(xvap[0]),&q,&e,&h,&cv,&cp,&w,&ierr,herr,errormessagelength);
1304  rho *= params.molemass;
1305  rhoL *= params.molemass;
1306  rhoV *= params.molemass;
1307  // If a single-phase solution, yield impossible saturation densities so that the phase will be properly calculated
1308  if (double_equal(rhoL, rhoV))
1309  {
1310  rhoL = -2;
1311  rhoV = -1;
1312  }
1313  else{
1314  // *1000 to go from kPa to Pa
1315  this->saturation_p(p*1000,false,TsatL,TsatV,dummy1,dummy2);
1316  }
1317 }
1318 void REFPROPFluidClass::temperature_hs(double h, double s, double &Tout, double &rho, double &rhoL, double &rhoV, double &TsatL, double &TsatV)
1319 {
1320  double q,e,cv,cp,w,p,sbar = s*params.molemass, hbar = h*params.molemass, dummy1, dummy2;
1321  long ierr;
1322  std::vector<double> xliq = xmol, xvap = xmol;
1323  char herr[errormessagelength+1];
1324 
1325  hbar /= 1000; // 1000 to go from J/kmol to J/mol
1326  sbar /= 1000; // 1000 to go from J/kmol/K to J/mol/K
1327 
1328  HSFLSHdll(&hbar,&sbar,&(xmol[0]),&Tout,&p,&rho,&rhoL,&rhoV,&(xliq[0]),&(xvap[0]),&q,&e,&cv,&cp,&w,&ierr,herr,errormessagelength);
1329  rho *= params.molemass;
1330  rhoL *= params.molemass;
1331  rhoV *= params.molemass;
1332 
1333  // If a single-phase solution, yield impossible saturation densities so that the phase will be properly calculated
1334  if (double_equal(rhoL, rhoV))
1335  {
1336  rhoL = -2;
1337  rhoV = -1;
1338  }
1339  else{
1340  // *1000 to go from kPa to Pa
1341  this->saturation_p(p*1000,false,TsatL,TsatV,dummy1,dummy2);
1342  }
1343 }
1344 double REFPROPFluidClass::density_Tp(double T, double p)
1345 {
1346  return this->density_Tp(T,p,0); // guess value is neglected
1347 }
1348 double REFPROPFluidClass::density_Tp(double T, double p, double rho_guess)
1349 {
1350  long ierr;
1351  char herr[errormessagelength+1];
1352  p /= 1000; // 1000 to go from Pa to kPa
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);
1356 
1357  return rho*params.molemass;
1358 }
1359 double REFPROPFluidClass::psat(double T)
1360 {
1361  long ierr,ic;
1362  char herr[errormessagelength+1];
1363  std::vector<double> xliq = xmol,xvap = xmol;
1364  double dummy1,dummy2,psatval;
1365 
1366  ic=1;
1367  SATTdll(&T,&(xmol[0]),&ic,&psatval,&dummy1,&dummy2,&(xliq[0]),&(xvap[0]),&ierr,herr,errormessagelength);
1368 
1369  return psatval*1000; // 1000 to go from kPa to Pa
1370 }
1372 {
1373  long ierr,ic;
1374  char herr[errormessagelength+1];
1375  std::vector<double> xliq = xmol,xvap = xmol;
1376  double rhoV,dummy1,psatval;
1377 
1378  ic=2;
1379  SATTdll(&T,&(xmol[0]),&ic,&psatval,&dummy1,&rhoV,&(xliq[0]),&(xvap[0]),&ierr,herr,errormessagelength);
1380  return rhoV*params.molemass;
1381 }
1383 {
1384  long ierr,ic;
1385  char herr[errormessagelength+1];
1386  std::vector<double> xliq = xmol,xvap = xmol;
1387  double rhoL,dummy1,psatval;
1388 
1389  ic=1;
1390  SATTdll(&T,&(xmol[0]),&ic,&psatval,&rhoL, &dummy1,&(xliq[0]),&(xvap[0]),&ierr,herr,errormessagelength);
1391  return rhoL*params.molemass;
1392 }
1393 
1394 
1395 
1396 
1397 /*
1398 !
1399 !
1400 !
1401 ! CATCH TESTS
1402 !
1403 !
1404 !
1405 */
1406 
1407 
1408 
1409 #ifndef DISABLE_CATCH
1410 #include "Catch/catch.hpp"
1411 TEST_CASE("REFPROP Fluid Class Helmholtz derivatives check", "[helmholtz],[fast]")
1412 {
1413  std::vector<double> x(1,1);
1414  REFPROPFluidClass fluid = REFPROPFluidClass("REFPROP-Water",x);
1415  double eps = sqrt(DBL_EPSILON);
1416 
1417  SECTION("dDelta")
1418  {
1419  double ANA = fluid.dphir_dDelta(0.5, 0.5);
1420  double NUM = (fluid.phir(0.5, 0.5+eps) - fluid.phir(0.5,0.5-eps))/(2*eps);
1421  REQUIRE(abs(NUM-ANA) < 1e-6);
1422  }
1423  SECTION("dTau")
1424  {
1425  double ANA = fluid.dphir_dTau(0.5, 0.5);
1426  double NUM = (fluid.phir(0.5+eps, 0.5) - fluid.phir(0.5-eps,0.5))/(2*eps);
1427  REQUIRE(abs(NUM-ANA) < 1e-6);
1428  }
1429  SECTION("dDelta2")
1430  {
1431  double ANA = fluid.d2phir_dDelta2(0.5, 0.5);
1432  double NUM = (fluid.dphir_dDelta(0.5, 0.5+eps) - fluid.dphir_dDelta(0.5,0.5-eps))/(2*eps);
1433  REQUIRE(abs(NUM-ANA) < 1e-6);
1434  }
1435  SECTION("dTau2")
1436  {
1437  double ANA = fluid.d2phir_dTau2(0.5, 0.5);
1438  double NUM = (fluid.dphir_dTau(0.5+eps, 0.5) - fluid.dphir_dTau(0.5-eps,0.5))/(2*eps);
1439  REQUIRE(abs(NUM-ANA) < 1e-6);
1440  }
1441  SECTION("dDeltadTau")
1442  {
1443  double ANA = fluid.d2phir_dDelta_dTau(0.5, 0.5);
1444  double NUM = (fluid.dphir_dTau(0.5, 0.5+eps) - fluid.dphir_dTau(0.5,0.5-eps))/(2*eps);
1445  REQUIRE(abs(NUM-ANA) < 1e-6);
1446  }
1447 }
1448 
1449 TEST_CASE("REFPROP Fluid Class check saturation consistency", "")
1450 {
1451  std::vector<double> x(1,1);
1452  REFPROPFluidClass fluid = REFPROPFluidClass("REFPROP-Water",x);
1453 
1454  SECTION("sat")
1455  {
1456  double T = 313;
1457  double p, T2, psatV, TsatV,rhoL,rhoV;
1458  fluid.saturation_T(T, false, p, psatV, rhoL, rhoV);
1459  fluid.saturation_p(p, false, T2, TsatV, rhoL, rhoV);
1460  REQUIRE(fabs(T2-T) < 1e-5);
1461  }
1462 }
1463 
1464 TEST_CASE("Check fluid names", "[fast]")
1465 {
1467  std::vector<double> x1(1,1), x2(2,0.5);
1468  SECTION("REFPROP-R134")
1469  {
1470  REQUIRE_THROWS(set_REFPROP_fluid("REFPROP-R134",x1));
1471  }
1472  SECTION("REFPROP-R134a")
1473  {
1474  REQUIRE_NOTHROW(set_REFPROP_fluid("REFPROP-R134a",x1));
1475  }
1476  SECTION("REFPROP-MIX:R410.m")
1477  {
1478  REQUIRE_THROWS(set_REFPROP_fluid("REFPROP-MIX:R410.m",x2));
1479  }
1480  SECTION("REFPROP-MIX:R410")
1481  {
1482  REQUIRE_THROWS(set_REFPROP_fluid("REFPROP-MIX:R410",x2));
1483  }
1484  SECTION("REFPROP-MIX:R32[0.5]R125[0.5]")
1485  {
1486  REQUIRE_THROWS(set_REFPROP_fluid("REFPROP-MIX:R32[0.5]R125[0.5]",x2));
1487  }
1488  SECTION("REFPROP-MIX:R32[0,5]R125[0,5]")
1489  {
1490  REQUIRE_THROWS(set_REFPROP_fluid("REFPROP-MIX:R32[0,5]R125[0,5]",x2));
1491  }
1492  SECTION("REFPROP-MIX:R32[A]&R125[B]")
1493  {
1494  REQUIRE_THROWS(set_REFPROP_fluid("REFPROP-MIX:R32[A]R125[B]",x2));
1495  }
1496  SECTION("REFPROP-MIX:R32[0.697614699375863]&R125[0.302385300624138]")
1497  {
1498  REQUIRE_NOTHROW(set_REFPROP_fluid("REFPROP-MIX:R32[0.697614699375863]&R125[0.302385300624138]",x2));
1499  }
1500  SECTION("REFPROP-MIXLR410A.mix")
1501  {
1502  REQUIRE_THROWS(set_REFPROP_fluid("REFPROP-MIXLR410A.mix",x2));
1503  }
1504  }
1505 }
1506 
1507 TEST_CASE("Fluid class for bad fluid", "[fast]")
1508 {
1509  SECTION("REFPROP-R134")
1510  {
1512  REQUIRE_THROWS(REFPROPFluidClass("REFPROP-R134",std::vector<double>(1,1)));
1513  }
1514  }
1515  SECTION("REFPROP-R134a")
1516  {
1518  REQUIRE_NOTHROW(REFPROPFluidClass("REFPROP-R134a",std::vector<double>(1,1)));
1519  }
1520  }
1521 }
1522 
1523 #endif
#define DBDTdll_NAME
Definition: REFPROP_lib.h:476
#define PHFL1dll_NAME
Definition: REFPROP_lib.h:518
CV2PKdll_TYPE * CV2PKdll_POINTER
Definition: REFPROP_lib.h:792
#define RPVersion_NAME
Definition: REFPROP_lib.h:463
#define SETMIXdll_NAME
Definition: REFPROP_lib.h:537
LIMITSdll_TYPE * LIMITSdll_POINTER
Definition: REFPROP_lib.h:828
DDDPdll_POINTER DDDPdll
Definition: REFPROP.cpp:89
#define SUBLTdll_NAME
Definition: REFPROP_lib.h:543
MLTH2Odll_TYPE * MLTH2Odll_POINTER
Definition: REFPROP_lib.h:832
SETMODdll_POINTER SETMODdll
Definition: REFPROP.cpp:148
double conductivity_Trho(double T, double rho)
Definition: REFPROP.cpp:1225
void set_warning(std::string warning)
Definition: CoolProp.cpp:59
#define QMASSdll_NAME
Definition: REFPROP_lib.h:526
std::string LoadedREFPROPRef
Definition: REFPROP.cpp:59
void temperature_hs(double h, double s, double &Tout, double &rhoout, double &rhoLout, double &rhoVout, double &TsatLout, double &TsatVout)
Definition: REFPROP.cpp:1318
#define XMOLEdll_NAME
Definition: REFPROP_lib.h:563
DIELECdll_TYPE * DIELECdll_POINTER
Definition: REFPROP_lib.h:805
GETFIJdll_POINTER GETFIJdll
Definition: REFPROP.cpp:113
#define SURFTdll_NAME
Definition: REFPROP_lib.h:544
TPFL2dll_POINTER TPFL2dll
Definition: REFPROP.cpp:164
#define GERG04dll_NAME
Definition: REFPROP_lib.h:502
TDFLSHdll_POINTER TDFLSHdll
Definition: REFPROP.cpp:156
ENTROdll_TYPE * ENTROdll_POINTER
Definition: REFPROP_lib.h:817
THERMdll_TYPE * THERMdll_POINTER
Definition: REFPROP_lib.h:870
GERG04dll_TYPE * GERG04dll_POINTER
Definition: REFPROP_lib.h:821
void temperature_ps(double p, double s, double &Tout, double &rhoout, double &rhoLout, double &rhoVout, double &TsatLout, double &TsatVout)
Definition: REFPROP.cpp:1293
double phir(double tau, double delta)
Definition: REFPROP.cpp:1175
#define SETUPdll_NAME
Definition: REFPROP_lib.h:540
struct FluidLimits limits
Definition: FluidClass.h:219
#define ENTROdll_NAME
Definition: REFPROP_lib.h:498
#define TDFLSHdll_NAME
Definition: REFPROP_lib.h:546
HSFLSHdll_POINTER HSFLSHdll
Definition: REFPROP.cpp:116
SETPATHdll_TYPE * SETPATHdll_POINTER
Definition: REFPROP_lib.h:783
double phi0(double tau, double delta)
Definition: REFPROP.cpp:1195
#define SURTENdll_NAME
Definition: REFPROP_lib.h:545
double d2phi0_dTau2(double tau, double delta)
Definition: REFPROP.cpp:1132
GETFIJdll_TYPE * GETFIJdll_POINTER
Definition: REFPROP_lib.h:822
DHFL1dll_TYPE * DHFL1dll_POINTER
Definition: REFPROP_lib.h:803
MELTPdll_POINTER MELTPdll
Definition: REFPROP.cpp:121
PressureUnit p
Definition: FluidClass.h:50
#define SATTdll_NAME
Definition: REFPROP_lib.h:534
double d2phir_dDelta2(double tau, double delta)
Definition: REFPROP.cpp:1165
VIRCdll_TYPE * VIRCdll_POINTER
Definition: REFPROP_lib.h:879
DDDTdll_TYPE * DDDTdll_POINTER
Definition: REFPROP_lib.h:799
CV2PKdll_POINTER CV2PKdll
Definition: REFPROP.cpp:83
SETUPdll_TYPE * SETUPdll_POINTER
Definition: REFPROP_lib.h:859
double d2phir_dTau2(double tau, double delta)
Definition: REFPROP.cpp:1143
std::string name
A container to hold the cache for residual Helmholtz derivatives.
Definition: FluidClass.h:151
ABFL2dll_POINTER ABFL2dll
Definition: REFPROP.cpp:76
#define DEFLSHdll_NAME
Definition: REFPROP_lib.h:481
ABFL1dll_TYPE * ABFL1dll_POINTER
Definition: REFPROP_lib.h:784
CVCPKdll_POINTER CVCPKdll
Definition: REFPROP.cpp:84
ESFLSHdll_TYPE * ESFLSHdll_POINTER
Definition: REFPROP_lib.h:818
#define CRITPdll_NAME
Definition: REFPROP_lib.h:471
QMASSdll_TYPE * QMASSdll_POINTER
Definition: REFPROP_lib.h:845
LIMITXdll_TYPE * LIMITXdll_POINTER
Definition: REFPROP_lib.h:829
TSFLSHdll_POINTER TSFLSHdll
Definition: REFPROP.cpp:168
#define DSFLSHdll_NAME
Definition: REFPROP_lib.h:494
PRESSdll_POINTER PRESSdll
Definition: REFPROP.cpp:132
SETPATHdll_POINTER SETPATHdll
Definition: REFPROP.cpp:74
#define DPDDKdll_NAME
Definition: REFPROP_lib.h:489
PDFLSHdll_POINTER PDFLSHdll
Definition: REFPROP.cpp:126
PUREFLDdll_TYPE * PUREFLDdll_POINTER
Definition: REFPROP_lib.h:844
SATPdll_TYPE * SATPdll_POINTER
Definition: REFPROP_lib.h:851
SETAGAdll_TYPE * SETAGAdll_POINTER
Definition: REFPROP_lib.h:854
LIMITXdll_POINTER LIMITXdll
Definition: REFPROP.cpp:120
NAMEdll_POINTER NAMEdll
Definition: REFPROP.cpp:124
PEFLSHdll_POINTER PEFLSHdll
Definition: REFPROP.cpp:127
ESFLSHdll_POINTER ESFLSHdll
Definition: REFPROP.cpp:109
#define SETREFdll_NAME
Definition: REFPROP_lib.h:539
DPTSATKdll_TYPE * DPTSATKdll_POINTER
Definition: REFPROP_lib.h:812
#define GETFIJdll_NAME
Definition: REFPROP_lib.h:503
WMOLdll_POINTER WMOLdll
Definition: REFPROP.cpp:171
DIELECdll_POINTER DIELECdll
Definition: REFPROP.cpp:96
#define COOLPROP_OK
Definition: CoolPropTools.h:62
double rhosatV(double T)
Definition: REFPROP.cpp:1371
SETAGAdll_POINTER SETAGAdll
Definition: REFPROP.cpp:145
TQFLSHdll_POINTER TQFLSHdll
Definition: REFPROP.cpp:166
#define LIMITXdll_NAME
Definition: REFPROP_lib.h:510
DHD1dll_TYPE * DHD1dll_POINTER
Definition: REFPROP_lib.h:801
bool set_REFPROP_fluid(std::string Ref, std::vector< double > &x)
Definition: REFPROP.cpp:417
SETMIXdll_TYPE * SETMIXdll_POINTER
Definition: REFPROP_lib.h:856
#define THERM2dll_NAME
Definition: REFPROP_lib.h:549
double REFPROPSI(long iOutput, long iName1, double Prop1, long iName2, double Prop2, std::string Ref)
Definition: REFPROP.cpp:685
FPVdll_TYPE * FPVdll_POINTER
Definition: REFPROP_lib.h:820
#define PEFLSHdll_NAME
Definition: REFPROP_lib.h:517
#define DDDTdll_NAME
Definition: REFPROP_lib.h:480
PHFL1dll_TYPE * PHFL1dll_POINTER
Definition: REFPROP_lib.h:837
THERM3dll_TYPE * THERM3dll_POINTER
Definition: REFPROP_lib.h:869
DPDTKdll_TYPE * DPDTKdll_POINTER
Definition: REFPROP_lib.h:810
SATEdll_POINTER SATEdll
Definition: REFPROP.cpp:140
#define SATSdll_NAME
Definition: REFPROP_lib.h:533
DSFL1dll_TYPE * DSFL1dll_POINTER
Definition: REFPROP_lib.h:814
std::vector< std::string > strsplit(std::string s, char del)
TPFL2dll_TYPE * TPFL2dll_POINTER
Definition: REFPROP_lib.h:873
CVCPdll_POINTER CVCPdll
Definition: REFPROP.cpp:85
#define LIMITKdll_NAME
Definition: REFPROP_lib.h:508
#define PSFLSHdll_NAME
Definition: REFPROP_lib.h:524
PSFL1dll_TYPE * PSFL1dll_POINTER
Definition: REFPROP_lib.h:842
WMOLdll_TYPE * WMOLdll_POINTER
Definition: REFPROP_lib.h:880
bool double_equal(double a, double b)
DHD1dll_POINTER DHD1dll
Definition: REFPROP.cpp:92
#define DPDTKdll_NAME
Definition: REFPROP_lib.h:491
THERMdll_POINTER THERMdll
Definition: REFPROP.cpp:161
EXPORT_CODE int CONVENTION get_standard_unit_system(void)
LIMITKdll_POINTER LIMITKdll
Definition: REFPROP.cpp:118
#define CP0dll_NAME
Definition: REFPROP_lib.h:470
PUREFLDdll_POINTER PUREFLDdll
Definition: REFPROP.cpp:135
SURFTdll_POINTER SURFTdll
Definition: REFPROP.cpp:154
#define DBL_EPSILON
Definition: Helmholtz.cpp:10
#define CVCPdll_NAME
Definition: REFPROP_lib.h:475
struct CriticalStruct reduce
A pointer to the point that is used to reduce the T and rho for EOS.
Definition: FluidClass.h:222
#define CV2PKdll_NAME
Definition: REFPROP_lib.h:473
SURTENdll_TYPE * SURTENdll_POINTER
Definition: REFPROP_lib.h:864
DHFL2dll_TYPE * DHFL2dll_POINTER
Definition: REFPROP_lib.h:804
#define refpropcharlength
Definition: REFPROP.cpp:31
TEFLSHdll_POINTER TEFLSHdll
Definition: REFPROP.cpp:157
DPTSATKdll_POINTER DPTSATKdll
Definition: REFPROP.cpp:103
THFLSHdll_POINTER THFLSHdll
Definition: REFPROP.cpp:162
SUBLPdll_TYPE * SUBLPdll_POINTER
Definition: REFPROP_lib.h:861
DSFL2dll_TYPE * DSFL2dll_POINTER
Definition: REFPROP_lib.h:815
#define LIMITSdll_NAME
Definition: REFPROP_lib.h:509
SUBLTdll_TYPE * SUBLTdll_POINTER
Definition: REFPROP_lib.h:862
THFLSHdll_TYPE * THFLSHdll_POINTER
Definition: REFPROP_lib.h:871
double dphir_dDelta(double tau, double delta)
Definition: REFPROP.cpp:1112
#define DPTSATKdll_NAME
Definition: REFPROP_lib.h:493
#define TPRHOdll_NAME
Definition: REFPROP_lib.h:555
std::vector< double > LoadedREFPROPx(ncmax, 0)
#define FGCTYdll_NAME
Definition: REFPROP_lib.h:500
#define DIELECdll_NAME
Definition: REFPROP_lib.h:486
#define CCRITdll_NAME
Definition: REFPROP_lib.h:469
PHFLSHdll_TYPE * PHFLSHdll_POINTER
Definition: REFPROP_lib.h:838
#define SETKTVdll_NAME
Definition: REFPROP_lib.h:536
char refpropPath[]
Definition: REFPROP.cpp:310
#define ENTHALdll_NAME
Definition: REFPROP_lib.h:497
std::string format(const char *fmt,...)
XMASSdll_TYPE * XMASSdll_POINTER
Definition: REFPROP_lib.h:881
CSATKdll_POINTER CSATKdll
Definition: REFPROP.cpp:82
PEFLSHdll_TYPE * PEFLSHdll_POINTER
Definition: REFPROP_lib.h:836
MELTPdll_TYPE * MELTPdll_POINTER
Definition: REFPROP_lib.h:830
TEFLSHdll_TYPE * TEFLSHdll_POINTER
Definition: REFPROP_lib.h:866
#define CVCPKdll_NAME
Definition: REFPROP_lib.h:474
TDFLSHdll_TYPE * TDFLSHdll_POINTER
Definition: REFPROP_lib.h:865
double convert_from_SI_to_unit_system(long iInput, double value, int new_system)
Definition: Units.cpp:123
#define HSFLSHdll_NAME
Definition: REFPROP_lib.h:506
MELTTdll_POINTER MELTTdll
Definition: REFPROP.cpp:122
#define ACTVYdll_NAME
Definition: REFPROP_lib.h:467
AGdll_TYPE * AGdll_POINTER
Definition: REFPROP_lib.h:787
#define DOTFILLdll_NAME
Definition: REFPROP_lib.h:487
#define CSATKdll_NAME
Definition: REFPROP_lib.h:472
PQFLSHdll_POINTER PQFLSHdll
Definition: REFPROP.cpp:130
#define VIRBdll_NAME
Definition: REFPROP_lib.h:559
SETKTVdll_TYPE * SETKTVdll_POINTER
Definition: REFPROP_lib.h:855
QMOLEdll_TYPE * QMOLEdll_POINTER
Definition: REFPROP_lib.h:846
struct CriticalStruct * preduce
Definition: FluidClass.h:221
std::string get_REFPROP_fluid_path()
Definition: REFPROP.cpp:313
#define DPDDdll_NAME
Definition: REFPROP_lib.h:490
static bool refpropSupported()
Definition: REFPROP.cpp:1066
THERM0dll_TYPE * THERM0dll_POINTER
Definition: REFPROP_lib.h:867
QMOLEdll_POINTER QMOLEdll
Definition: REFPROP.cpp:137
SETKTVdll_POINTER SETKTVdll
Definition: REFPROP.cpp:146
#define DBFL1dll_NAME
Definition: REFPROP_lib.h:477
RESIDUALdll_TYPE * RESIDUALdll_POINTER
Definition: REFPROP_lib.h:847
RESIDUALdll_POINTER RESIDUALdll
Definition: REFPROP.cpp:138
#define SATEdll_NAME
Definition: REFPROP_lib.h:530
#define PSFL1dll_NAME
Definition: REFPROP_lib.h:523
double surface_tension_T(double T)
Definition: REFPROP.cpp:1208
ENTROdll_POINTER ENTROdll
Definition: REFPROP.cpp:108
DSFLSHdll_POINTER DSFLSHdll
Definition: REFPROP.cpp:104
DBDTdll_TYPE * DBDTdll_POINTER
Definition: REFPROP_lib.h:795
VIRCdll_POINTER VIRCdll
Definition: REFPROP.cpp:170
SATSdll_POINTER SATSdll
Definition: REFPROP.cpp:143
std::vector< double > x(ncmax, 0)
AGdll_POINTER AGdll
Definition: REFPROP.cpp:78
SUBLPdll_POINTER SUBLPdll
Definition: REFPROP.cpp:152
std::string REFPROPname
The name of the fluid.
Definition: FluidClass.h:152
DPDDdll_POINTER DPDDdll
Definition: REFPROP.cpp:100
SETREFdll_TYPE * SETREFdll_POINTER
Definition: REFPROP_lib.h:858
SATHdll_TYPE * SATHdll_POINTER
Definition: REFPROP_lib.h:850
TEST_CASE("REFPROP Fluid Class Helmholtz derivatives check","[helmholtz],[fast]")
Definition: REFPROP.cpp:1411
CCRITdll_TYPE * CCRITdll_POINTER
Definition: REFPROP_lib.h:788
ACTVYdll_POINTER ACTVYdll
Definition: REFPROP.cpp:77
TRNPRPdll_TYPE * TRNPRPdll_POINTER
Definition: REFPROP_lib.h:876
DPDD2dll_POINTER DPDD2dll
Definition: REFPROP.cpp:98
CP0dll_TYPE * CP0dll_POINTER
Definition: REFPROP_lib.h:789
#define MLTH2Odll_NAME
Definition: REFPROP_lib.h:513
THERM3dll_POINTER THERM3dll
Definition: REFPROP.cpp:160
#define lengthofreference
Definition: REFPROP.cpp:33
#define SATHdll_NAME
Definition: REFPROP_lib.h:531
PHFLSHdll_POINTER PHFLSHdll
Definition: REFPROP.cpp:129
double setFunctionPointers()
Definition: REFPROP.cpp:191
#define errormessagelength
Definition: REFPROP.cpp:34
CRITPdll_POINTER CRITPdll
Definition: REFPROP.cpp:81
DDDTdll_POINTER DDDTdll
Definition: REFPROP.cpp:90
#define PRESSdll_NAME
Definition: REFPROP_lib.h:522
THERM0dll_POINTER THERM0dll
Definition: REFPROP.cpp:158
QMASSdll_POINTER QMASSdll
Definition: REFPROP.cpp:136
SATPdll_POINTER SATPdll
Definition: REFPROP.cpp:142
DHFLSHdll_POINTER DHFLSHdll
Definition: REFPROP.cpp:93
double psat(double T)
Definition: REFPROP.cpp:1359
TPFLSHdll_POINTER TPFLSHdll
Definition: REFPROP.cpp:163
DBFL2dll_TYPE * DBFL2dll_POINTER
Definition: REFPROP_lib.h:797
INFOdll_TYPE * INFOdll_POINTER
Definition: REFPROP_lib.h:826
double double *typedef double double *typedef double *typedef double double *typedef double double *typedef RPVersion_TYPE * RPVersion_POINTER
Definition: REFPROP_lib.h:676
#define MELTTdll_NAME
Definition: REFPROP_lib.h:512
GERG04dll_POINTER GERG04dll
Definition: REFPROP.cpp:112
PHFL1dll_POINTER PHFL1dll
Definition: REFPROP.cpp:128
DHFL2dll_POINTER DHFL2dll
Definition: REFPROP.cpp:95
CP0dll_POINTER CP0dll
Definition: REFPROP.cpp:80
SATHdll_POINTER SATHdll
Definition: REFPROP.cpp:141
double dphi0_dTau(double tau, double delta)
Definition: REFPROP.cpp:1185
double d2phir_dDelta_dTau(double tau, double delta)
Definition: REFPROP.cpp:1155
XMASSdll_POINTER XMASSdll
Definition: REFPROP.cpp:172
double R(void)
Definition: REFPROP.h:15
TQFLSHdll_TYPE * TQFLSHdll_POINTER
Definition: REFPROP_lib.h:875
#define PDFLSHdll_NAME
Definition: REFPROP_lib.h:516
#define GIBBSdll_NAME
Definition: REFPROP_lib.h:505
TPRHOdll_TYPE * TPRHOdll_POINTER
Definition: REFPROP_lib.h:874
DBDTdll_POINTER DBDTdll
Definition: REFPROP.cpp:86
params
#define QMOLEdll_NAME
Definition: REFPROP_lib.h:527
#define REQUIRE_THROWS(expr)
Definition: catch.hpp:8054
#define SUBLPdll_NAME
Definition: REFPROP_lib.h:542
DPDTdll_TYPE * DPDTdll_POINTER
Definition: REFPROP_lib.h:811
struct CriticalStruct crit
Definition: FluidClass.h:218
PSFLSHdll_TYPE * PSFLSHdll_POINTER
Definition: REFPROP_lib.h:843
PRESSdll_TYPE * PRESSdll_POINTER
Definition: REFPROP_lib.h:841
#define ESFLSHdll_NAME
Definition: REFPROP_lib.h:499
VIRBdll_TYPE * VIRBdll_POINTER
Definition: REFPROP_lib.h:878
#define AGdll_NAME
Definition: REFPROP_lib.h:468
DBFL1dll_POINTER DBFL1dll
Definition: REFPROP.cpp:87
DEFLSHdll_POINTER DEFLSHdll
Definition: REFPROP.cpp:91
PREOSdll_POINTER PREOSdll
Definition: REFPROP.cpp:131
#define PHFLSHdll_NAME
Definition: REFPROP_lib.h:519
ABFL1dll_POINTER ABFL1dll
Definition: REFPROP.cpp:75
DPDDdll_TYPE * DPDDdll_POINTER
Definition: REFPROP_lib.h:809
SUBLTdll_POINTER SUBLTdll
Definition: REFPROP.cpp:153
#define DHD1dll_NAME
Definition: REFPROP_lib.h:482
GETKTVdll_POINTER GETKTVdll
Definition: REFPROP.cpp:114
GIBBSdll_POINTER GIBBSdll
Definition: REFPROP.cpp:115
MLTH2Odll_POINTER MLTH2Odll
Definition: REFPROP.cpp:123
#define GETKTVdll_NAME
Definition: REFPROP_lib.h:504
#define TSFLSHdll_NAME
Definition: REFPROP_lib.h:558
CSATKdll_TYPE * CSATKdll_POINTER
Definition: REFPROP_lib.h:791
#define SETMODdll_NAME
Definition: REFPROP_lib.h:538
double dphir_dTau(double tau, double delta)
Definition: REFPROP.cpp:1122
REQUIRE(fabs(CPWater.p()-RPWater.p())< 1e-4)
void * getFunctionPointer(char *name)
Definition: REFPROP.cpp:175
#define THERM0dll_NAME
Definition: REFPROP_lib.h:548
SATDdll_POINTER SATDdll
Definition: REFPROP.cpp:139
MELTTdll_TYPE * MELTTdll_POINTER
Definition: REFPROP_lib.h:831
SETUPdll_POINTER SETUPdll
Definition: REFPROP.cpp:150
LIMITSdll_POINTER LIMITSdll
Definition: REFPROP.cpp:119
TPFLSHdll_TYPE * TPFLSHdll_POINTER
Definition: REFPROP_lib.h:872
GETKTVdll_TYPE * GETKTVdll_POINTER
Definition: REFPROP_lib.h:823
#define THERMdll_NAME
Definition: REFPROP_lib.h:551
#define PREOSdll_NAME
Definition: REFPROP_lib.h:521
#define VIRCdll_NAME
Definition: REFPROP_lib.h:560
SURTENdll_POINTER SURTENdll
Definition: REFPROP.cpp:155
void saturation_T(double T, bool UseLUT, double &psatLout, double &psatVout, double &rhosatLout, double &rhosatVout)
Definition: REFPROP.cpp:1235
CVCPKdll_TYPE * CVCPKdll_POINTER
Definition: REFPROP_lib.h:793
#define TRNPRPdll_NAME
Definition: REFPROP_lib.h:557
SETMIXdll_POINTER SETMIXdll
Definition: REFPROP.cpp:147
#define MELTPdll_NAME
Definition: REFPROP_lib.h:511
FGCTYdll_TYPE * FGCTYdll_POINTER
Definition: REFPROP_lib.h:819
SATEdll_TYPE * SATEdll_POINTER
Definition: REFPROP_lib.h:849
#define SATDdll_NAME
Definition: REFPROP_lib.h:529
long get_param_index(std::string param)
Definition: CoolProp.cpp:288
DSFLSHdll_TYPE * DSFLSHdll_POINTER
Definition: REFPROP_lib.h:813
LIMITKdll_TYPE * LIMITKdll_POINTER
Definition: REFPROP_lib.h:827
RPVersion_POINTER RPVersion
Definition: REFPROP.cpp:73
PSFLSHdll_POINTER PSFLSHdll
Definition: REFPROP.cpp:134
#define DPDD2dll_NAME
Definition: REFPROP_lib.h:488
double density_Tp(double T, double p)
Definition: REFPROP.cpp:1344
THERM2dll_POINTER THERM2dll
Definition: REFPROP.cpp:159
ACTVYdll_TYPE * ACTVYdll_POINTER
Definition: REFPROP_lib.h:786
#define TEFLSHdll_NAME
Definition: REFPROP_lib.h:547
#define FPVdll_NAME
Definition: REFPROP_lib.h:501
#define REQUIRE_NOTHROW(expr)
Definition: catch.hpp:8056
INFOdll_POINTER INFOdll
Definition: REFPROP.cpp:117
SURFTdll_TYPE * SURFTdll_POINTER
Definition: REFPROP_lib.h:863
#define DPDTdll_NAME
Definition: REFPROP_lib.h:492
TSFLSHdll_TYPE * TSFLSHdll_POINTER
Definition: REFPROP_lib.h:877
PQFLSHdll_TYPE * PQFLSHdll_POINTER
Definition: REFPROP_lib.h:839
void * RefpropdllInstance
Definition: REFPROP.cpp:68
GIBBSdll_TYPE * GIBBSdll_POINTER
Definition: REFPROP_lib.h:824
#define PDFL1dll_NAME
Definition: REFPROP_lib.h:515
FGCTYdll_POINTER FGCTYdll
Definition: REFPROP.cpp:110
void temperature_ph(double p, double h, double &Tout, double &rhoout, double &rhoLout, double &rhoVout, double &TsatLout, double &TsatVout, double T0, double rho0)
Definition: REFPROP.cpp:1268
#define ncmax
Definition: REFPROP.cpp:35
#define ABFL2dll_NAME
Definition: REFPROP_lib.h:466
SATTdll_TYPE * SATTdll_POINTER
Definition: REFPROP_lib.h:853
DPDTKdll_POINTER DPDTKdll
Definition: REFPROP.cpp:101
CCRITdll_POINTER CCRITdll
Definition: REFPROP.cpp:79
DOTFILLdll_POINTER DOTFILLdll
Definition: REFPROP.cpp:97
double convert_from_unit_system_to_SI(long iInput, double value, int old_system)
Definition: Units.cpp:5
#define WMOLdll_NAME
Definition: REFPROP_lib.h:561
#define TQFLSHdll_NAME
Definition: REFPROP_lib.h:556
#define SECTION(name, description)
Definition: catch.hpp:8088
DPDD2dll_TYPE * DPDD2dll_POINTER
Definition: REFPROP_lib.h:807
bool load_REFPROP()
Definition: REFPROP.cpp:327
#define DBFL2dll_NAME
Definition: REFPROP_lib.h:478
SATTdll_POINTER SATTdll
Definition: REFPROP.cpp:144
DDDPdll_TYPE * DDDPdll_POINTER
Definition: REFPROP_lib.h:798
#define SATPdll_NAME
Definition: REFPROP_lib.h:532
CRITPdll_TYPE * CRITPdll_POINTER
Definition: REFPROP_lib.h:790
XMOLEdll_TYPE * XMOLEdll_POINTER
Definition: REFPROP_lib.h:882
DOTFILLdll_TYPE * DOTFILLdll_POINTER
Definition: REFPROP_lib.h:806
SETREFdll_POINTER SETREFdll
Definition: REFPROP.cpp:149
ENTHALdll_TYPE * ENTHALdll_POINTER
Definition: REFPROP_lib.h:816
#define INFOdll_NAME
Definition: REFPROP_lib.h:507
SATDdll_TYPE * SATDdll_POINTER
Definition: REFPROP_lib.h:848
DHFLSHdll_TYPE * DHFLSHdll_POINTER
Definition: REFPROP_lib.h:802
#define NAMEdll_NAME
Definition: REFPROP_lib.h:514
#define SETAGAdll_NAME
Definition: REFPROP_lib.h:535
XMOLEdll_POINTER XMOLEdll
Definition: REFPROP.cpp:173
DBFL2dll_POINTER DBFL2dll
Definition: REFPROP.cpp:88
#define PUREFLDdll_NAME
Definition: REFPROP_lib.h:525
HSFLSHdll_TYPE * HSFLSHdll_POINTER
Definition: REFPROP_lib.h:825
DSFL2dll_POINTER DSFL2dll
Definition: REFPROP.cpp:106
DPDDKdll_TYPE * DPDDKdll_POINTER
Definition: REFPROP_lib.h:808
SATSdll_TYPE * SATSdll_POINTER
Definition: REFPROP_lib.h:852
SETMODdll_TYPE * SETMODdll_POINTER
Definition: REFPROP_lib.h:857
ABFL2dll_TYPE * ABFL2dll_POINTER
Definition: REFPROP_lib.h:785
ENTHALdll_POINTER ENTHALdll
Definition: REFPROP.cpp:107
void saturation_p(double p, bool UseLUT, double &TsatLout, double &TsatVout, double &rhosatLout, double &rhosatVout)
Definition: REFPROP.cpp:1253
DSFL1dll_POINTER DSFL1dll
Definition: REFPROP.cpp:105
PREOSdll_TYPE * PREOSdll_POINTER
Definition: REFPROP_lib.h:840
double Tmin
Definition: FluidClass.h:54
double rhosatL(double T)
Definition: REFPROP.cpp:1382
#define ABFL1dll_NAME
Definition: REFPROP_lib.h:465
#define PQFLSHdll_NAME
Definition: REFPROP_lib.h:520
DEFLSHdll_TYPE * DEFLSHdll_POINTER
Definition: REFPROP_lib.h:800
TRNPRPdll_POINTER TRNPRPdll
Definition: REFPROP.cpp:167
DBFL1dll_TYPE * DBFL1dll_POINTER
Definition: REFPROP_lib.h:796
PDFLSHdll_TYPE * PDFLSHdll_POINTER
Definition: REFPROP_lib.h:835
#define RESIDUALdll_NAME
Definition: REFPROP_lib.h:528
CVCPdll_TYPE * CVCPdll_POINTER
Definition: REFPROP_lib.h:794
#define DDDPdll_NAME
Definition: REFPROP_lib.h:479
double REFPROP(char Output, char Name1, double Prop1, char Name2, double Prop2, char *Ref)
Definition: REFPROP.cpp:641
FPVdll_POINTER FPVdll
Definition: REFPROP.cpp:111
#define THERM3dll_NAME
Definition: REFPROP_lib.h:550
#define XMASSdll_NAME
Definition: REFPROP_lib.h:562
THERM2dll_TYPE * THERM2dll_POINTER
Definition: REFPROP_lib.h:868
DHFL1dll_POINTER DHFL1dll
Definition: REFPROP.cpp:94
PSFL1dll_POINTER PSFL1dll
Definition: REFPROP.cpp:133
PDFL1dll_TYPE * PDFL1dll_POINTER
Definition: REFPROP_lib.h:834
NAMEdll_TYPE * NAMEdll_POINTER
Definition: REFPROP_lib.h:833
PDFL1dll_POINTER PDFL1dll
Definition: REFPROP.cpp:125
#define DHFLSHdll_NAME
Definition: REFPROP_lib.h:485
double viscosity_Trho(double T, double rho)
Definition: REFPROP.cpp:1216
DPDTdll_POINTER DPDTdll
Definition: REFPROP.cpp:102
#define THFLSHdll_NAME
Definition: REFPROP_lib.h:552
#define TPFLSHdll_NAME
Definition: REFPROP_lib.h:553
VIRBdll_POINTER VIRBdll
Definition: REFPROP.cpp:169
TPRHOdll_POINTER TPRHOdll
Definition: REFPROP.cpp:165
DPDDKdll_POINTER DPDDKdll
Definition: REFPROP.cpp:99