不好意思,这是程序后面部分:
RHOMOLL,double* X, double& DRHODT);
void (__stdcall *FGCTYdll)(double& TK, double& RHOMOLL,double* X, double& FUGACITY);// The following ifdef block is the standard way of creating macros which make exporting
void (__stdcall *LIMITXdll)(char* htyp,double& TinK,double& rhoin_Mol,double& PinkPa, double* X, double& TminK, double& TmaxK, double& rhomaxMol,double& PmaxkPa, long& ierr,char* herr,long lnhtyp,long lnherr);
void (__stdcall *SETKTVdll)(long& icomp, long& jcomp, char* hmodij,double& fij,char* hfmix,long& ierr,char* herr,long Lengthhmodij,long Lengthhfmix,long LengthHERR);
void (__stdcall *GETKTVdll)(long& icomp, long& jcomp,char* hmodij,double& fij,char* hfmix,char* hfij,char* hbinp,char* hmxrul,long ln1,long ln2,long ln3,long ln4,long ln5);
void (__stdcall *GETFIJdll)(char* hmodij,char* fij,char* hfij,char* hmxrul,long ln1,long ln2,long ln3);
//#pragma argsused
#includeint main(int argc, char* argv[])
{
// First create a pointer to an instance of the library
// Then have windows load the library.
HINSTANCE RefpropdllInstance;
RefpropdllInstance = LoadLibrary("Refprop.dll");
// Then get pointers to the actual functions.
SETUPdll = (fp_SETUPDLLTYPE) GetProcAddress(RefpropdllInstance,"SETUPdll");
INFOdll = (fp_INFOdllTYPE) GetProcAddress(RefpropdllInstance,"INFOdll");
SATTdll = (fp_SATdllTYPE) GetProcAddress(RefpropdllInstance,"SATTdll");
SATPdll = (fp_SATdllTYPE) GetProcAddress(RefpropdllInstance,"SATPdll");
ENTROdll = (fp_ENTROENTHALdllTYPE) GetProcAddress(RefpropdllInstance,"ENTROdll");
ENTHALdll = (fp_ENTROENTHALdllTYPE) GetProcAddress(RefpropdllInstance,"ENTHALdll");
TDFLSHdll = (fp_TDPFLSHdllTYPE) GetProcAddress(RefpropdllInstance,"TDFLSHdll");
TPFLSHdll = (fp_TDPFLSHdllTYPE) GetProcAddress(RefpropdllInstance,"TPFLSHdll");
PDFLSHdll = (fp_TDPFLSHdllTYPE) GetProcAddress(RefpropdllInstance,"PDFLSHdll");
DSFLSHdll = (fp_DEHSFLSHdllTYPE)GetProcAddress(RefpropdllInstance,"DSFLSHdll");
DEFLSHdll = (fp_DEHSFLSHdllTYPE)GetProcAddress(RefpropdllInstance,"DEFLSHdll");
PEFLSHdll = (fp_DEHSFLSHdllTYPE)GetProcAddress(RefpropdllInstance,"PEFLSHdll");
DHFLSHdll = (fp_DEHSFLSHdllTYPE)GetProcAddress(RefpropdllInstance,"DHFLSHdll");
PHFLSHdll = (fp_DEHSFLSHdllTYPE)GetProcAddress(RefpropdllInstance,"PHFLSHdll");
PSFLSHdll = (fp_DEHSFLSHdllTYPE)GetProcAddress(RefpropdllInstance,"PSFLSHdll");
THFLSHdll = (fp_TQHFLSHdllTYPE)GetProcAddress(RefpropdllInstance,"THFLSHdll");
PQFLSHdll = (fp_TQHFLSHdllTYPE)GetProcAddress(RefpropdllInstance,"PQFLSHdll");
TQFLSHdll = (fp_TQHFLSHdllTYPE)GetProcAddress(RefpropdllInstance,"TQFLSHdll");
XMASSdll = (fp_MASSMOLEFRACTIONdllTYPE)GetProcAddress(RefpropdllInstance,"XMASSdll");
XMOLEdll = (fp_MASSMOLEFRACTIONdllTYPE)GetProcAddress(RefpropdllInstance,"XMOLEdll");
CRITPdll = (fp_CRITPdllTYPE)GetProcAddress(RefpropdllInstance,"CRITPdll");
PSFL1dll = (fp_PSFL1dllTYPE)GetProcAddress(RefpropdllInstance,"PSFL1dll");
TPRHOdll = (fp_TPRHOdllTYPE)GetProcAddress(RefpropdllInstance,"TPRHOdll");
PRESSdll = (fp_PRESSdllTYPE)GetProcAddress(RefpropdllInstance,"PRESSdll");
GIBBSdll = (fp_GIBBSdllTYPE)GetProcAddress(RefpropdllInstance,"GIBBSdll");
CVCPdll = (fp_CVCPdllTYPE)GetProcAddress(RefpropdllInstance,"CVCPdll");
THERMdll = (fp_THERMdllTYPE)GetProcAddress(RefpropdllInstance,"THERMdll");
THERM2dll = (fp_THERM2dllTYPE)GetProcAddress(RefpropdllInstance,"THERM2dll");
TRNPRPdll = (fp_TRNPRPdllTYPE)GetProcAddress(RefpropdllInstance,"TRNPRPdll");
DHDTdll = (fp_2IVdllTYPE)GetProcAddress(RefpropdllInstance,"DHDTdll");
DPDDdll = (fp_2IVdllTYPE)GetProcAddress(RefpropdllInstance,"DPDDdll");
DPDD2dll = (fp_2IVdllTYPE)GetProcAddress(RefpropdllInstance,"DPDD2dll");
DPDTdll = (fp_2IVdllTYPE)GetProcAddress(RefpropdllInstance,"DPDTdll");
DDDPdll = (fp_2IVdllTYPE)GetProcAddress(RefpropdllInstance,"DDDPdll");
DDDTdll = (fp_2IVdllTYPE)GetProcAddress(RefpropdllInstance,"DDDTdll");
FGCTYdll = (fp_2IVdllTYPE)GetProcAddress(RefpropdllInstance,"FGCTYdll");
LIMITXdll = (fp_LIMITXdllTYPE)GetProcAddress(RefpropdllInstance,"LIMITXdll");
SETKTVdll = (fp_SETKTVdllTYPE)GetProcAddress(RefpropdllInstance,"SETKTVdll");
GETKTVdll = (fp_GETKTVdllTYPE)GetProcAddress(RefpropdllInstance,"GETKTVdll");
GETFIJdll = (fp_GETFIJdllTYPE)GetProcAddress(RefpropdllInstance,"GETFIJdll");
// Now use the functions.
// Refprop variables that need to be defined
//
// nc = Number of components in the mixture
// x[NumberOfComponentsInMixtures] = Mole fraction of each component
// ierr = An integer flag defining an error
// HFILES[] = a character array defining the fluids in a mixture
// HRF[] = a character array denoting the reference state
// HERR[] = a character array for storing a string - Error message
// HFMIX[] a character array defining the path to the mixture file
double x[compsize]={0};
long nc,ierr;
char HFILES[refpropfluidpathlength+1], HRF[lengthofreference+1],
HERR[errormessagelength+1],HFMIX[refpropcharlength+1];
nc = 1;
x[0] = 1.0;
// Set HFILES to the path of the R134a.fld file. Terminate with '\0'
// Set HFMIX to the path of the HMX.BNC file. Terminate with '\0'
// Set HRF to a reference...DEF in this case. Terminate with '\0'
// Set HERR to a default error..."ok" for now. Terminate with '\0'
strcpy(HFILES,"F:\\refprop7\\Fluids\\R134a.fld\0");
strcpy(HFMIX,"F:\\refprop7\\Fluids\\HMX.BNC\0");
strcpy(HRF,"DEF\0");
strcpy(HERR,"Ok\0");
// Note, the directory will likely be different on other machines
// Call SETUPdll to initialize global variables in Refprop
SETUPdll(nc, HFILES, HFMIX, HRF, ierr, HERR,
refpropfluidpathlength,refpropcharlength,
lengthofreference,errormessagelength);
printf("%ld\n",ierr);
// Create variables that are to be
// (a) Used to call the SATPdll function
// (b) Returned by the SATPdll function
double XLIQ[compsize]={0.0};
double XVAP[compsize]={0.0};
// Some values...
double PkPa,TK,RHOF,RHOG;
long KPH;
KPH = 2; // Vapor
PkPa = 101.325;
SATPdll(PkPa,x,KPH,TK,RHOF,RHOG,XLIQ,XVAP,ierr,HERR,errormessagelength);
printf("%f,%f,%f,%ld\n",RHOF,RHOG,TK,ierr);
// Answers from the Refprop interface program, to check results
// Tsat(101.325) = 247.08 K
// rhof = 13.493. mol/m^3
// rhog = 0.051533 mol/m^3
// Now try a mixture...say R410a
nc = 2;
x[0] = 0.69762;
x[1] = 0.30238;
// Set HFILES to the mixture of R32 and R125. Terminate with '\0'
strcpy(HFILES,"F:\\refprop7\\fluids\\R32.fld|F:\\refprop7\\fluids\\R125.fld\0");
strcpy(HFMIX,"F:\\Refprop7\\Fluids\\HMX.BNC\0");
strcpy(HRF,"DEF\0");
strcpy(HERR,"Ok\0");
SETUPdll(nc, HFILES, HFMIX, HRF, ierr, HERR,
refpropfluidpathlength,refpropcharlength,
lengthofreference,errormessagelength);
printf("%ld\n",ierr);
KPH = 2; // Vapor
PkPa = 101.325;
SATPdll(PkPa,x,KPH,TK,RHOF,RHOG,XLIQ,XVAP,ierr,HERR,errormessagelength);
printf("%f,%f,%f,%ld\n",RHOF,RHOG,TK,ierr);
// For vapor (KPH = 2)
// Tsat(101.325) = 221.74 K
// rhof = 18.594 mol/m^3
// rhog = 0.057501 mol/m^3
return 0;
FreeLibrary(RefpropdllInstance);
}
[Last edited by wanglin628 on 2009-4-22 at 20:32]