Option Explicit 'An environment variable can be set to specify the locations of the fluid files. This can 'be done under Start/Settings/Control Panel/System/Advanced/Environment Variables. A new 'variable called RPPrefix should be created with a value of "C:\Program Files\REFPROP" (or 'the directory where Refprop is located). The Refprop FAQ page shows pictures of these variables. 'Alternatively: 'Change the following to the location of the fluid files and of the mixture files (those with .MIX). 'If the file REFPROP.DLL is not located in the application workspace, then see note below. 'DO NOT IMPLEMENT BOTH OF THESE METHODS, change either the paths below or modify the environment variables, not both. Private Const FluidsDirectory As String = "fluids\" Private Const MixturesDirectory As String = "mixtures\" '----Usually the files are located here, so comment out the two lines above and use these two: 'Private Const FluidsDirectory As String = "c:\Program Files\REFPROP\fluids\" 'Private Const MixturesDirectory As String = "c:\Program Files\REFPROP\mixtures\" 'REFPROP Excel Functions 'Arguments: (FluidName, InpCode, Units, Prop1, Prop2) 'FluidName = text, fluid must be either in Fluids or Mixtures sub directories. 'InpCode = name and order of Prop1 and Prop2. ' "TP" would mean Prop1 is Temperature, Prop2 is Pressure (need quotes) ' Valid InpCodes: TP,TD,TH,TS,TE,TQ,PD,PH,PS,PE,PQ,DH,DS,DE,HS ' To define saturated liquid or vapor inputs: TLIQ, TVAP, PLIQ, PVAP ' Other: Crit, Trip, TMelt, PMelt, TSubl, PSubl ' ' The word "Optional" appears in the argument listings below to indicate that ' PROP2 is not always required depending on the InpCode argument. ' In some cases, PROP1 is also optional. ' 'Units = "SI", "SI with C" (or just "C"), "Molar SI", "E", "molar E", "cgs", "mks", "Mixed" (need quotes). "SI" is used by default if no input is given. (Unless DefaultUnits changed in VBA code) 'Prop1 = numerical value of the first input property (in the units of the previous line) 'Prop2 = numerical value of the second input property (if required). 'Function Temperature (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function Pressure (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function Density (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function LiquidDensity (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function VaporDensity (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function Volume (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function CompressibilityFactor (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function Energy (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function Enthalpy (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function LiquidEnthalpy (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function VaporEnthalpy (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function Entropy (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function IsochoricHeatCapacity (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function Cv (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function IsobaricHeatCapacity (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function Cp (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function SpecificHeatInput (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function Csat (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function SpeedOfSound (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function Sound (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function dPdrho (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function d2Pdrho2 (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function dPdT (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function dPdTsat (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function drhodT (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function dHdT_D (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function dHdT_P (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function dHdD_T (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function dHdD_P (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function dHdP_T (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function dHdP_D (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function Cstar (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function Quality (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function QualityMole (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function QualityMass (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function LatentHeat (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function HeatOfVaporization (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function HeatOfCombustion (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function GrossHeatingValue (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function NetHeatingValue (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function JouleThomson (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function IsentropicExpansionCoef (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function IsothermalCompressibility (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function VolumeExpansivity (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function AdiabaticCompressibility (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function AdiabaticBulkModulus (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function IsothermalExpansionCoef (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function IsothermalBulkModulus (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function SecondVirial (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function Viscosity (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function KinematicViscosity (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function ThermalConductivity (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function ThermalDiffusivity (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function Prandtl (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function SurfaceTension (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function DielectricConstant (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function MolarMass (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function EOSMax (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function EOSMin (FluidName, InpCode, Units, Prop1, Optional Prop2) 'Function LiquidFluidString (FluidName, Optional InpCode, Optional Units, Optional Prop1, Optional Prop2) 'Function VaporFluidString (FluidName, Optional InpCode, Optional Units, Optional Prop1, Optional Prop2) 'Function FluidString (Nmes, Comps, Optional massmole As String) 'Function PropertyUnits (InpCode, Units) 'In the following, i is the component number in the mixture (where the maximum value of i can be 20) 'Function ComponentName (FluidName, i) 'Function MoleFraction (FluidName, i) 'Function MassFraction (FluidName, i) 'Function LiquidMoleFraction (FluidName, Optional InpCode, Optional Units, Optional Prop1, Optional Prop2, Optional i) 'Function VaporMoleFraction (FluidName, Optional InpCode, Optional Units, Optional Prop1, Optional Prop2, Optional i) 'Function LiquidMassFraction (FluidName, Optional InpCode, Optional Units, Optional Prop1, Optional Prop2, Optional i) 'Function VaporMassFraction (FluidName, Optional InpCode, Optional Units, Optional Prop1, Optional Prop2, Optional i) 'Function Activity (FluidName, Optional InpCode, Optional Units, Optional Prop1, Optional Prop2, Optional i) 'Function ActivityCoefficient (FluidName, Optional InpCode, Optional Units, Optional Prop1, Optional Prop2, Optional i) 'Function ChemicalPotential (FluidName, Optional InpCode, Optional Units, Optional Prop1, Optional Prop2, Optional i) 'Function Fugacity (FluidName, Optional InpCode, Optional Units, Optional Prop1, Optional Prop2, Optional i) 'Function FugacityCoefficient (FluidName, Optional InpCode, Optional Units, Optional Prop1, Optional Prop2, Optional i) 'Function Mole2Mass (FluidName, i, Prop1, Prop2, Optional Prop3, Optional Prop4, Optional Prop5, Optional Prop6, Optional Prop7, Optional Prop8, Optional Prop9, Optional Prop10, Optional Prop11, Optional Prop12, Optional Prop13, Optional Prop14, Optional Prop15, Optional Prop16, Optional Prop17, Optional Prop18, Optional Prop19, Optional Prop20) 'Function Mass2Mole (FluidName, i, Prop1, Prop2, Optional Prop3, Optional Prop4, Optional Prop5, Optional Prop6, Optional Prop7, Optional Prop8, Optional Prop9, Optional Prop10, Optional Prop11, Optional Prop12, Optional Prop13, Optional Prop14, Optional Prop15, Optional Prop16, Optional Prop17, Optional Prop18, Optional Prop19, Optional Prop20) 'The following functions are for Document Reference 'Function WorkBookName 'Function RefpropXLSVersionNumber 'Function RefpropDLLVersionNumber 'Function WhereAreREFPROPfunctions 'Function WhereIsWorkbook 'Function SeeFileLinkSources 'Function SelectedDefaultUnits ' 'In order for Excel to access the REFPROP.DLL file, you will need to do one of the items below: ' - Place your Excel file in the REFPROP directory ' - Change the path and environment variables as described at the top of the "Examples" sheet ' - Below, replace all "REFPROP.DLL" with "C:\Program Files\REFPROP\REFPROP.DLL" (or the subdirectory where REFPROP was installed) ' - Place a copy of REFPROP.DLL in your directory where your Excel files are located (not preferred) Private Const MaxComps As Integer = 20 #If VBA7 Then #If Win64 Then Private Declare PtrSafe Sub SETUPdll Lib "REFPRP64.DLL" (i As Long, ByVal hfld As String, ByVal hfmix As String, ByVal hrf As String, ierr As Long, ByVal herr As String, ln1 As Long, ln2 As Long, ln3 As Long, ln4 As Long) Private Declare PtrSafe Sub SETREFdll Lib "REFPRP64.DLL" (ByVal hrf As String, ixflag As Long, x0 As Double, h0 As Double, s0 As Double, t0 As Double, p0 As Double, ierr As Long, ByVal herr As String, ln1 As Long, ln2 As Long) Private Declare PtrSafe Sub SETMIXdll Lib "REFPRP64.DLL" (ByVal hmxnme As String, ByVal hfmix As String, ByVal hrf As String, ncc As Long, ByVal hfile As String, x As Double, ierr As Long, ByVal herr As String, ln1 As Long, ln2 As Long, ln3 As Long, ln4 As Long, ln5 As Long) Private Declare PtrSafe Sub SETMODdll Lib "REFPRP64.DLL" (i As Long, ByVal htype As String, ByVal hmix As String, ByVal hcomp As String, ierr As Long, ByVal herr As String, ln1 As Long, ln2 As Long, ln3 As Long, ln4 As Long) Private Declare PtrSafe Sub SETPATHdll Lib "REFPRP64.DLL" (ByVal hpath As String, ln As Long) Private Declare PtrSafe Sub GERG04dll Lib "REFPRP64.DLL" (nc As Long, iflag As Long, ierr As Long, ByVal herr As String, ln1 As Long) Private Declare PtrSafe Sub SETKTVdll Lib "REFPRP64.DLL" (icomp As Long, jcomp As Long, ByVal hmodij As String, fij As Double, ByVal hfmix As String, ierr As Long, ByVal herr As String, ln1 As Long, ln2 As Long, ln3 As Long) Private Declare PtrSafe Sub GETKTVdll Lib "REFPRP64.DLL" (icomp As Long, jcomp As Long, ByVal hmodij As String, fij As Double, ByVal hfmix As String, ByVal hfij As String, ByVal hbinp As String, ByVal hmxrul As String, ln1 As Long, ln2 As Long, ln3 As Long, ln4 As Long, ln5 As Long) Private Declare PtrSafe Sub GETFIJdll Lib "REFPRP64.DLL" (ByVal hmodij As String, fij As Double, ByVal hfij As String, ByVal hmxrul As String, ln1 As Long, ln2 As Long, ln3 As Long) Private Declare PtrSafe Sub PREOSdll Lib "REFPRP64.DLL" (i As Long) Private Declare PtrSafe Sub SETAGAdll Lib "REFPRP64.DLL" (ierr As Long, ByVal herr As String, ln1 As Long) Private Declare PtrSafe Sub UNSETAGAdll Lib "REFPRP64.DLL" () Private Declare PtrSafe Sub NAMEdll Lib "REFPRP64.DLL" (icomp As Long, ByVal hnam As String, ByVal hn80 As String, ByVal hcasn As String, ln1 As Long, ln2 As Long, ln3 As Long) Private Declare PtrSafe Sub PUREFLDdll Lib "REFPRP64.DLL" (icomp As Long) Private Declare PtrSafe Sub SETNCdll Lib "REFPRP64.DLL" (ncomp As Long) Private Declare PtrSafe Sub RPVersion Lib "REFPRP64.DLL" (ByVal herr As String, ln As Long) Private Declare PtrSafe Sub CRITPdll Lib "REFPRP64.DLL" (x As Double, tc As Double, pc As Double, dc As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub MAXTdll Lib "REFPRP64.DLL" (x As Double, tm As Double, pm As Double, dm As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub MAXPdll Lib "REFPRP64.DLL" (x As Double, tm As Double, pm As Double, dm As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub REDXdll Lib "REFPRP64.DLL" (x As Double, t As Double, d As Double) Private Declare PtrSafe Sub THERMdll Lib "REFPRP64.DLL" (t As Double, d As Double, x As Double, p As Double, e As Double, h As Double, s As Double, Cv As Double, Cp As Double, w As Double, hjt As Double) Private Declare PtrSafe Sub THERM2dll Lib "REFPRP64.DLL" (t As Double, d As Double, x As Double, p As Double, e As Double, h As Double, s As Double, Cv As Double, Cp As Double, w As Double, z As Double, hjt As Double, aH As Double, g As Double, kappa As Double, beta As Double, dPdD As Double, d2PdD2 As Double, dPdT As Double, dDdT As Double, dDdP As Double, d2PT2 As Double, d2PdTD As Double, spare3 As Double, spare4 As Double) Private Declare PtrSafe Sub THERM3dll Lib "REFPRP64.DLL" (t As Double, d As Double, x As Double, kappa As Double, beta As Double, isenk As Double, kt As Double, betas As Double, bs As Double, kkt As Double, thrott As Double, pi As Double, spht As Double) Private Declare PtrSafe Sub THERM0dll Lib "REFPRP64.DLL" (t As Double, d As Double, x As Double, p As Double, e As Double, h As Double, s As Double, Cv As Double, Cp As Double, w As Double, a As Double, g As Double) Private Declare PtrSafe Sub PRESSdll Lib "REFPRP64.DLL" (t As Double, d As Double, x As Double, p As Double) Private Declare PtrSafe Sub ENTHALdll Lib "REFPRP64.DLL" (t As Double, d As Double, x As Double, h As Double) Private Declare PtrSafe Sub ENTROdll Lib "REFPRP64.DLL" (t As Double, d As Double, x As Double, s As Double) Private Declare PtrSafe Sub CVCPdll Lib "REFPRP64.DLL" (t As Double, d As Double, x As Double, Cv As Double, Cp As Double) Private Declare PtrSafe Sub GIBBSdll Lib "REFPRP64.DLL" (t As Double, d As Double, x As Double, Ar As Double, Gr As Double) Private Declare PtrSafe Sub AGdll Lib "REFPRP64.DLL" (t As Double, d As Double, x As Double, a As Double, g As Double) Private Declare PtrSafe Sub PHIXdll Lib "REFPRP64.DLL" (itau As Long, idel As Long, tau As Double, del As Double, x As Double, PHIX As Double) Private Declare PtrSafe Sub RESIDUALdll Lib "REFPRP64.DLL" (t As Double, d As Double, x As Double, pr As Double, er As Double, hr As Double, sr As Double, cvr As Double, cpr As Double, Ar As Double, Gr As Double) Private Declare PtrSafe Sub CP0dll Lib "REFPRP64.DLL" (t As Double, x As Double, Cp As Double) Private Declare PtrSafe Sub DPDDdll Lib "REFPRP64.DLL" (t As Double, d As Double, x As Double, dPdD As Double) Private Declare PtrSafe Sub DPDD2dll Lib "REFPRP64.DLL" (t As Double, d As Double, x As Double, d2PdD2 As Double) Private Declare PtrSafe Sub DPDTdll Lib "REFPRP64.DLL" (t As Double, d As Double, x As Double, dPdT As Double) Private Declare PtrSafe Sub DDDPdll Lib "REFPRP64.DLL" (t As Double, d As Double, x As Double, dDdP As Double) Private Declare PtrSafe Sub DDDTdll Lib "REFPRP64.DLL" (t As Double, d As Double, x As Double, dDdT As Double) Private Declare PtrSafe Sub DHD1dll Lib "REFPRP64.DLL" (t As Double, d As Double, x As Double, dHdT_D As Double, dHdT_P As Double, dHdD_T As Double, dHdD_P As Double, dHdP_T As Double, dHdP_D As Double) Private Declare PtrSafe Sub VIRBdll Lib "REFPRP64.DLL" (t As Double, x As Double, b As Double) Private Declare PtrSafe Sub VIRCdll Lib "REFPRP64.DLL" (t As Double, x As Double, c As Double) Private Declare PtrSafe Sub VIRBAdll Lib "REFPRP64.DLL" (t As Double, x As Double, b As Double) Private Declare PtrSafe Sub VIRCAdll Lib "REFPRP64.DLL" (t As Double, x As Double, c As Double) Private Declare PtrSafe Sub DBDTdll Lib "REFPRP64.DLL" (t As Double, x As Double, dbt As Double) Private Declare PtrSafe Sub B12dll Lib "REFPRP64.DLL" (t As Double, x As Double, b As Double) Private Declare PtrSafe Sub FGCTYdll Lib "REFPRP64.DLL" (t As Double, d As Double, x As Double, f As Double) Private Declare PtrSafe Sub FGCTY2dll Lib "REFPRP64.DLL" (t As Double, d As Double, x As Double, f As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub FUGCOFdll Lib "REFPRP64.DLL" (t As Double, d As Double, x As Double, f As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub CHEMPOTdll Lib "REFPRP64.DLL" (t As Double, d As Double, x As Double, u As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub ACTVYdll Lib "REFPRP64.DLL" (t As Double, d As Double, x As Double, actv As Double, gamma As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub EXCESSdll Lib "REFPRP64.DLL" (t As Double, p As Double, x As Double, kph As Long, d As Double, vE As Double, ee As Double, hE As Double, sE As Double, aE As Double, gE As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub SATSPLNdll Lib "REFPRP64.DLL" (x As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub SATTPdll Lib "REFPRP64.DLL" (t As Double, p As Double, x As Double, kph As Long, iGuess As Long, d As Double, rhol As Double, rhov As Double, xliq As Double, xvap As Double, q As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub SATTdll Lib "REFPRP64.DLL" (t As Double, x As Double, i As Long, p As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub SATPdll Lib "REFPRP64.DLL" (p As Double, x As Double, i As Long, t As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub SATDdll Lib "REFPRP64.DLL" (d As Double, x As Double, kph As Long, kr As Long, t As Double, p As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub SATHdll Lib "REFPRP64.DLL" (h As Double, x As Double, kph As Long, nroot As Long, k1 As Long, t1 As Double, p1 As Double, d1 As Double, k2 As Long, t2 As Double, p2 As Double, d2 As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub SATEdll Lib "REFPRP64.DLL" (e As Double, x As Double, kph As Long, nroot As Long, k1 As Long, t1 As Double, p1 As Double, d1 As Double, k2 As Long, t2 As Double, p2 As Double, d2 As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub SATSdll Lib "REFPRP64.DLL" (s As Double, x As Double, kph As Long, nroot As Long, k1 As Long, t1 As Double, p1 As Double, d1 As Double, k2 As Long, t2 As Double, p2 As Double, d2 As Double, k3 As Long, t3 As Double, p3 As Double, d3 As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub CV2PKdll Lib "REFPRP64.DLL" (icomp As Long, t As Double, rho As Double, cv2p As Double, Csat As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub CSATKdll Lib "REFPRP64.DLL" (icomp As Long, t As Double, kph As Long, p As Double, rho As Double, Csat As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub DPTSATKdll Lib "REFPRP64.DLL" (icomp As Long, t As Double, kph As Long, p As Double, rho As Double, Csat As Double, dPdTsat As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub PSATKdll Lib "REFPRP64.DLL" (icomp As Long, t As Double, p As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub DLSATKdll Lib "REFPRP64.DLL" (icomp As Long, t As Double, d As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub DVSATKdll Lib "REFPRP64.DLL" (icomp As Long, t As Double, d As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub TSATDdll Lib "REFPRP64.DLL" (d As Double, x As Double, t As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub MELTTdll Lib "REFPRP64.DLL" (t As Double, x As Double, p As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub MLTH2Odll Lib "REFPRP64.DLL" (t As Double, p1 As Double, p2 As Double) Private Declare PtrSafe Sub MELTPdll Lib "REFPRP64.DLL" (p As Double, x As Double, t As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub SUBLTdll Lib "REFPRP64.DLL" (t As Double, x As Double, p As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub SUBLPdll Lib "REFPRP64.DLL" (p As Double, x As Double, t As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub TPRHOdll Lib "REFPRP64.DLL" (t As Double, p As Double, x As Double, j As Long, i As Long, d As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub TPFLSHdll Lib "REFPRP64.DLL" (t As Double, p As Double, x As Double, d As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, e As Double, h As Double, s As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub TDFLSHdll Lib "REFPRP64.DLL" (t As Double, d As Double, x As Double, p As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, e As Double, h As Double, s As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub PDFLSHdll Lib "REFPRP64.DLL" (p As Double, d As Double, x As Double, t As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, e As Double, h As Double, s As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub PHFLSHdll Lib "REFPRP64.DLL" (p As Double, h As Double, x As Double, t As Double, d As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, e As Double, s As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub PSFLSHdll Lib "REFPRP64.DLL" (p As Double, s As Double, x As Double, t As Double, d As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, e As Double, h As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub PEFLSHdll Lib "REFPRP64.DLL" (p As Double, e As Double, x As Double, t As Double, d As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, h As Double, s As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub THFLSHdll Lib "REFPRP64.DLL" (t As Double, h As Double, x As Double, i As Long, p As Double, d As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, e As Double, s As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub TSFLSHdll Lib "REFPRP64.DLL" (t As Double, s As Double, x As Double, i As Long, p As Double, d As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, e As Double, h As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub TEFLSHdll Lib "REFPRP64.DLL" (t As Double, e As Double, x As Double, i As Long, p As Double, d As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, h As Double, s As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub DHFLSHdll Lib "REFPRP64.DLL" (d As Double, h As Double, x As Double, t As Double, p As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, e As Double, s As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub DSFLSHdll Lib "REFPRP64.DLL" (d As Double, s As Double, x As Double, t As Double, p As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, e As Double, h As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub DEFLSHdll Lib "REFPRP64.DLL" (d As Double, e As Double, x As Double, t As Double, p As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, h As Double, s As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub HSFLSHdll Lib "REFPRP64.DLL" (h As Double, s As Double, z As Double, t As Double, p As Double, d As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, e As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub ESFLSHdll Lib "REFPRP64.DLL" (e As Double, s As Double, z As Double, t As Double, p As Double, d As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, h As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub TQFLSHdll Lib "REFPRP64.DLL" (t As Double, q As Double, x As Double, kq As Long, p As Double, d As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, e As Double, h As Double, s As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub PQFLSHdll Lib "REFPRP64.DLL" (p As Double, q As Double, x As Double, kq As Long, t As Double, d As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, e As Double, h As Double, s As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub ABFL1dll Lib "REFPRP64.DLL" (a As Double, b As Double, x As Double, i As Long, ByVal ab As String, dmin As Double, dmax As Double, t As Double, p As Double, d As Double, ierr As Long, ByVal herr As String, ln1 As Long, ln2 As Long) Private Declare PtrSafe Sub ABFL2dll Lib "REFPRP64.DLL" (a As Double, b As Double, x As Double, kq As Long, ksat As Long, ByVal ab As String, tbub As Double, tdew As Double, pbub As Double, pdew As Double, Dlbub As Double, Dvdew As Double, ybub As Double, xdew As Double, t As Double, p As Double, Dl As Double, Dv As Double, x As Double, y As Double, q As Double, ierr As Long, ByVal herr As String, ln As Long, ln2 As Long) Private Declare PtrSafe Sub DBFL1dll Lib "REFPRP64.DLL" (d As Double, b As Double, x As Double, ByVal ab As String, t As Double, p As Double, ierr As Long, ByVal herr As String, ln1 As Long, ln2 As Long) Private Declare PtrSafe Sub DBFL2dll Lib "REFPRP64.DLL" (d As Double, b As Double, x As Double, i As Long, ByVal ab As String, t As Double, p As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, ierr As Long, ByVal herr As String, ln As Long, ln2 As Long) Private Declare PtrSafe Sub DQFL2dll Lib "REFPRP64.DLL" (d As Double, q As Double, x As Double, kq As Long, t As Double, p As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub DSFL1dll Lib "REFPRP64.DLL" (d As Double, s As Double, x As Double, t As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub PDFL1dll Lib "REFPRP64.DLL" (p As Double, d As Double, x As Double, t As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub PHFL1dll Lib "REFPRP64.DLL" (p As Double, h As Double, x As Double, kph As Long, t As Double, d As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub PSFL1dll Lib "REFPRP64.DLL" (p As Double, s As Double, x As Double, kph As Long, t As Double, d As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub TPFL2dll Lib "REFPRP64.DLL" (t As Double, p As Double, x As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub TRNPRPdll Lib "REFPRP64.DLL" (t As Double, d As Double, x As Double, eta As Double, tcx As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub DIELECdll Lib "REFPRP64.DLL" (t As Double, d As Double, x As Double, de As Double) Private Declare PtrSafe Sub SURFTdll Lib "REFPRP64.DLL" (t As Double, d As Double, x As Double, sigma As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub SURTENdll Lib "REFPRP64.DLL" (t As Double, rhol As Double, rhov As Double, xl As Double, xv As Double, sigma As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub HEATdll Lib "REFPRP64.DLL" (t As Double, rho As Double, x As Double, hg As Double, hn As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub CSTARdll Lib "REFPRP64.DLL" (t As Double, p As Double, v As Double, x As Double, cs As Double, ts As Double, Ds As Double, ps As Double, ws As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub FPVdll Lib "REFPRP64.DLL" (t As Double, d As Double, p As Double, x As Double, f As Double) 'Private Declare PtrSafe Sub SPECGRdll Lib "REFPRP64.DLL" (t As Double, d As Double, p As Double, Gr As Double) Private Declare PtrSafe Sub WMOLdll Lib "REFPRP64.DLL" (x As Double, wm As Double) Private Declare PtrSafe Sub XMASSdll Lib "REFPRP64.DLL" (xmol As Double, xkg As Double, wmix As Double) Private Declare PtrSafe Sub XMOLEdll Lib "REFPRP64.DLL" (xkg As Double, xmol As Double, wmix As Double) Private Declare PtrSafe Sub QMASSdll Lib "REFPRP64.DLL" (qmol As Double, xl As Double, xv As Double, qkg As Double, xlkg As Double, xvkg As Double, wliq As Double, wvap As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub QMOLEdll Lib "REFPRP64.DLL" (qkg As Double, xlkg As Double, xvkg As Double, qmol As Double, xl As Double, xv As Double, wliq As Double, wvap As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub INFOdll Lib "REFPRP64.DLL" (icomp As Long, wmm As Double, ttrp As Double, tnbpt As Double, tc As Double, pc As Double, dc As Double, Zc As Double, acf As Double, dip As Double, Rgas As Double) Private Declare PtrSafe Sub LIMITSdll Lib "REFPRP64.DLL" (ByVal htyp As String, x As Double, tmin As Double, tmax As Double, dmax As Double, pmax As Double, ln As Long) Private Declare PtrSafe Sub LIMITXdll Lib "REFPRP64.DLL" (ByVal htyp As String, t As Double, d As Double, p As Double, x As Double, tmin As Double, tmax As Double, dmax As Double, pmax As Double, ierr As Long, ByVal herr As String, ln1 As Long, ln2 As Long) Private Declare PtrSafe Sub LIMITKdll Lib "REFPRP64.DLL" (ByVal htyp As String, icomp As Long, t As Double, d As Double, p As Double, tmin As Double, tmax As Double, dmax As Double, pmax As Double, ierr As Long, ByVal herr As String, ln1 As Long, ln2 As Long) Private Declare PtrSafe Sub ETAK0dll Lib "REFPRP64.DLL" (icomp As Long, t As Double, eta0 As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub ETAK1dll Lib "REFPRP64.DLL" (icomp As Long, t As Double, eta1 As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub ETAKRdll Lib "REFPRP64.DLL" (icomp As Long, t As Double, rho As Double, etar As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub ETAKBdll Lib "REFPRP64.DLL" (icomp As Long, t As Double, rho As Double, etab As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub OMEGAdll Lib "REFPRP64.DLL" (icomp As Long, t As Double, epsk As Double, omg As Double) Private Declare PtrSafe Sub TCXK0dll Lib "REFPRP64.DLL" (icomp As Long, t As Double, tcx0 As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub TCXKBdll Lib "REFPRP64.DLL" (icomp As Long, t As Double, rho As Double, tcxb As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Sub TCXKCdll Lib "REFPRP64.DLL" (icomp As Long, t As Double, rho As Double, tcxc As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare PtrSafe Function SetCurDir Lib "kernel32" Alias "SetCurrentDirectoryA" (ByVal lpPathName As String) As Long #Else Private Declare Sub SETUPdll Lib "REFPROP.DLL" (i As Long, ByVal hfld As String, ByVal hfmix As String, ByVal hrf As String, ierr As Long, ByVal herr As String, ln1 As Long, ln2 As Long, ln3 As Long, ln4 As Long) Private Declare Sub SETREFdll Lib "REFPROP.DLL" (ByVal hrf As String, ixflag As Long, x0 As Double, h0 As Double, s0 As Double, t0 As Double, p0 As Double, ierr As Long, ByVal herr As String, ln1 As Long, ln2 As Long) Private Declare Sub SETMIXdll Lib "REFPROP.DLL" (ByVal hmxnme As String, ByVal hfmix As String, ByVal hrf As String, ncc As Long, ByVal hfile As String, x As Double, ierr As Long, ByVal herr As String, ln1 As Long, ln2 As Long, ln3 As Long, ln4 As Long, ln5 As Long) Private Declare Sub SETMODdll Lib "REFPROP.DLL" (i As Long, ByVal htype As String, ByVal hmix As String, ByVal hcomp As String, ierr As Long, ByVal herr As String, ln1 As Long, ln2 As Long, ln3 As Long, ln4 As Long) Private Declare Sub SETPATHdll Lib "REFPROP.DLL" (ByVal hpath As String, ln As Long) Private Declare Sub GERG04dll Lib "REFPROP.DLL" (nc As Long, iflag As Long, ierr As Long, ByVal herr As String, ln1 As Long) Private Declare Sub SETKTVdll Lib "REFPROP.DLL" (icomp As Long, jcomp As Long, ByVal hmodij As String, fij As Double, ByVal hfmix As String, ierr As Long, ByVal herr As String, ln1 As Long, ln2 As Long, ln3 As Long) Private Declare Sub GETKTVdll Lib "REFPROP.DLL" (icomp As Long, jcomp As Long, ByVal hmodij As String, fij As Double, ByVal hfmix As String, ByVal hfij As String, ByVal hbinp As String, ByVal hmxrul As String, ln1 As Long, ln2 As Long, ln3 As Long, ln4 As Long, ln5 As Long) Private Declare Sub GETFIJdll Lib "REFPROP.DLL" (ByVal hmodij As String, fij As Double, ByVal hfij As String, ByVal hmxrul As String, ln1 As Long, ln2 As Long, ln3 As Long) Private Declare Sub PREOSdll Lib "REFPROP.DLL" (i As Long) Private Declare Sub SETAGAdll Lib "REFPROP.DLL" (ierr As Long, ByVal herr As String, ln1 As Long) Private Declare Sub UNSETAGAdll Lib "REFPROP.DLL" () Private Declare Sub NAMEdll Lib "REFPROP.DLL" (icomp As Long, ByVal hnam As String, ByVal hn80 As String, ByVal hcasn As String, ln1 As Long, ln2 As Long, ln3 As Long) Private Declare Sub PUREFLDdll Lib "REFPROP.DLL" (icomp As Long) Private Declare Sub SETNCdll Lib "REFPROP.DLL" (ncomp As Long) Private Declare Sub RPVersion Lib "REFPROP.DLL" (ByVal herr As String, ln As Long) Private Declare Sub CRITPdll Lib "REFPROP.DLL" (x As Double, tc As Double, pc As Double, dc As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub MAXTdll Lib "REFPROP.DLL" (x As Double, tm As Double, pm As Double, dm As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub MAXPdll Lib "REFPROP.DLL" (x As Double, tm As Double, pm As Double, dm As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub REDXdll Lib "REFPROP.DLL" (x As Double, t As Double, d As Double) Private Declare Sub THERMdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, p As Double, e As Double, h As Double, s As Double, Cv As Double, Cp As Double, w As Double, hjt As Double) Private Declare Sub THERM2dll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, p As Double, e As Double, h As Double, s As Double, Cv As Double, Cp As Double, w As Double, z As Double, hjt As Double, aH As Double, g As Double, kappa As Double, beta As Double, dPdD As Double, d2PdD2 As Double, dPdT As Double, dDdT As Double, dDdP As Double, d2PT2 As Double, d2PdTD As Double, spare3 As Double, spare4 As Double) Private Declare Sub THERM3dll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, kappa As Double, beta As Double, isenk As Double, kt As Double, betas As Double, bs As Double, kkt As Double, thrott As Double, pi As Double, spht As Double) Private Declare Sub THERM0dll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, p As Double, e As Double, h As Double, s As Double, Cv As Double, Cp As Double, w As Double, a As Double, g As Double) Private Declare Sub PRESSdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, p As Double) Private Declare Sub ENTHALdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, h As Double) Private Declare Sub ENTROdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, s As Double) Private Declare Sub CVCPdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, Cv As Double, Cp As Double) Private Declare Sub GIBBSdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, Ar As Double, Gr As Double) Private Declare Sub AGdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, a As Double, g As Double) Private Declare Sub PHIXdll Lib "REFPROP.DLL" (itau As Long, idel As Long, tau As Double, del As Double, x As Double, PHIX As Double) Private Declare Sub RESIDUALdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, pr As Double, er As Double, hr As Double, sr As Double, cvr As Double, cpr As Double, Ar As Double, Gr As Double) Private Declare Sub CP0dll Lib "REFPROP.DLL" (t As Double, x As Double, Cp As Double) Private Declare Sub DPDDdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, dPdD As Double) Private Declare Sub DPDD2dll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, d2PdD2 As Double) Private Declare Sub DPDTdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, dPdT As Double) Private Declare Sub DDDPdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, dDdP As Double) Private Declare Sub DDDTdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, dDdT As Double) Private Declare Sub DHD1dll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, dHdT_D As Double, dHdT_P As Double, dHdD_T As Double, dHdD_P As Double, dHdP_T As Double, dHdP_D As Double) Private Declare Sub VIRBdll Lib "REFPROP.DLL" (t As Double, x As Double, b As Double) Private Declare Sub VIRCdll Lib "REFPROP.DLL" (t As Double, x As Double, c As Double) Private Declare Sub VIRBAdll Lib "REFPROP.DLL" (t As Double, x As Double, b As Double) Private Declare Sub VIRCAdll Lib "REFPROP.DLL" (t As Double, x As Double, c As Double) Private Declare Sub DBDTdll Lib "REFPROP.DLL" (t As Double, x As Double, dbt As Double) Private Declare Sub B12dll Lib "REFPROP.DLL" (t As Double, x As Double, b As Double) Private Declare Sub FGCTYdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, f As Double) Private Declare Sub FGCTY2dll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, f As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub FUGCOFdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, f As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub CHEMPOTdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, u As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub ACTVYdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, actv As Double, gamma As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub EXCESSdll Lib "REFPROP.DLL" (t As Double, p As Double, x As Double, kph As Long, d As Double, vE As Double, ee As Double, hE As Double, sE As Double, aE As Double, gE As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub SATSPLNdll Lib "REFPROP.DLL" (x As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub SATTPdll Lib "REFPROP.DLL" (t As Double, p As Double, x As Double, kph As Long, iGuess As Long, d As Double, rhol As Double, rhov As Double, xliq As Double, xvap As Double, q As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub SATTdll Lib "REFPROP.DLL" (t As Double, x As Double, i As Long, p As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub SATPdll Lib "REFPROP.DLL" (p As Double, x As Double, i As Long, t As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub SATDdll Lib "REFPROP.DLL" (d As Double, x As Double, kph As Long, kr As Long, t As Double, p As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub SATHdll Lib "REFPROP.DLL" (h As Double, x As Double, kph As Long, nroot As Long, k1 As Long, t1 As Double, p1 As Double, d1 As Double, k2 As Long, t2 As Double, p2 As Double, d2 As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub SATEdll Lib "REFPROP.DLL" (e As Double, x As Double, kph As Long, nroot As Long, k1 As Long, t1 As Double, p1 As Double, d1 As Double, k2 As Long, t2 As Double, p2 As Double, d2 As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub SATSdll Lib "REFPROP.DLL" (s As Double, x As Double, kph As Long, nroot As Long, k1 As Long, t1 As Double, p1 As Double, d1 As Double, k2 As Long, t2 As Double, p2 As Double, d2 As Double, k3 As Long, t3 As Double, p3 As Double, d3 As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub CV2PKdll Lib "REFPROP.DLL" (icomp As Long, t As Double, rho As Double, cv2p As Double, Csat As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub CSATKdll Lib "REFPROP.DLL" (icomp As Long, t As Double, kph As Long, p As Double, rho As Double, Csat As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub DPTSATKdll Lib "REFPROP.DLL" (icomp As Long, t As Double, kph As Long, p As Double, rho As Double, Csat As Double, dPdTsat As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub PSATKdll Lib "REFPROP.DLL" (icomp As Long, t As Double, p As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub DLSATKdll Lib "REFPROP.DLL" (icomp As Long, t As Double, d As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub DVSATKdll Lib "REFPROP.DLL" (icomp As Long, t As Double, d As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub TSATDdll Lib "REFPROP.DLL" (d As Double, x As Double, t As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub MELTTdll Lib "REFPROP.DLL" (t As Double, x As Double, p As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub MLTH2Odll Lib "REFPROP.DLL" (t As Double, p1 As Double, p2 As Double) Private Declare Sub MELTPdll Lib "REFPROP.DLL" (p As Double, x As Double, t As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub SUBLTdll Lib "REFPROP.DLL" (t As Double, x As Double, p As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub SUBLPdll Lib "REFPROP.DLL" (p As Double, x As Double, t As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub TPRHOdll Lib "REFPROP.DLL" (t As Double, p As Double, x As Double, j As Long, i As Long, d As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub TPFLSHdll Lib "REFPROP.DLL" (t As Double, p As Double, x As Double, d As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, e As Double, h As Double, s As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub TDFLSHdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, p As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, e As Double, h As Double, s As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub PDFLSHdll Lib "REFPROP.DLL" (p As Double, d As Double, x As Double, t As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, e As Double, h As Double, s As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub PHFLSHdll Lib "REFPROP.DLL" (p As Double, h As Double, x As Double, t As Double, d As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, e As Double, s As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub PSFLSHdll Lib "REFPROP.DLL" (p As Double, s As Double, x As Double, t As Double, d As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, e As Double, h As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub PEFLSHdll Lib "REFPROP.DLL" (p As Double, e As Double, x As Double, t As Double, d As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, h As Double, s As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub THFLSHdll Lib "REFPROP.DLL" (t As Double, h As Double, x As Double, i As Long, p As Double, d As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, e As Double, s As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub TSFLSHdll Lib "REFPROP.DLL" (t As Double, s As Double, x As Double, i As Long, p As Double, d As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, e As Double, h As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub TEFLSHdll Lib "REFPROP.DLL" (t As Double, e As Double, x As Double, i As Long, p As Double, d As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, h As Double, s As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub DHFLSHdll Lib "REFPROP.DLL" (d As Double, h As Double, x As Double, t As Double, p As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, e As Double, s As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub DSFLSHdll Lib "REFPROP.DLL" (d As Double, s As Double, x As Double, t As Double, p As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, e As Double, h As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub DEFLSHdll Lib "REFPROP.DLL" (d As Double, e As Double, x As Double, t As Double, p As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, h As Double, s As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub HSFLSHdll Lib "REFPROP.DLL" (h As Double, s As Double, z As Double, t As Double, p As Double, d As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, e As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub ESFLSHdll Lib "REFPROP.DLL" (e As Double, s As Double, z As Double, t As Double, p As Double, d As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, h As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub TQFLSHdll Lib "REFPROP.DLL" (t As Double, q As Double, x As Double, kq As Long, p As Double, d As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, e As Double, h As Double, s As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub PQFLSHdll Lib "REFPROP.DLL" (p As Double, q As Double, x As Double, kq As Long, t As Double, d As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, e As Double, h As Double, s As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub ABFL1dll Lib "REFPROP.DLL" (a As Double, b As Double, x As Double, i As Long, ByVal ab As String, dmin As Double, dmax As Double, t As Double, p As Double, d As Double, ierr As Long, ByVal herr As String, ln1 As Long, ln2 As Long) Private Declare Sub ABFL2dll Lib "REFPROP.DLL" (a As Double, b As Double, x As Double, kq As Long, ksat As Long, ByVal ab As String, tbub As Double, tdew As Double, pbub As Double, pdew As Double, Dlbub As Double, Dvdew As Double, ybub As Double, xdew As Double, t As Double, p As Double, Dl As Double, Dv As Double, x As Double, y As Double, q As Double, ierr As Long, ByVal herr As String, ln As Long, ln2 As Long) Private Declare Sub DBFL1dll Lib "REFPROP.DLL" (d As Double, b As Double, x As Double, ByVal ab As String, t As Double, p As Double, ierr As Long, ByVal herr As String, ln1 As Long, ln2 As Long) Private Declare Sub DBFL2dll Lib "REFPROP.DLL" (d As Double, b As Double, x As Double, i As Long, ByVal ab As String, t As Double, p As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, ierr As Long, ByVal herr As String, ln As Long, ln2 As Long) Private Declare Sub DQFL2dll Lib "REFPROP.DLL" (d As Double, q As Double, x As Double, kq As Long, t As Double, p As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub DSFL1dll Lib "REFPROP.DLL" (d As Double, s As Double, x As Double, t As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub PDFL1dll Lib "REFPROP.DLL" (p As Double, d As Double, x As Double, t As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub PHFL1dll Lib "REFPROP.DLL" (p As Double, h As Double, x As Double, kph As Long, t As Double, d As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub PSFL1dll Lib "REFPROP.DLL" (p As Double, s As Double, x As Double, kph As Long, t As Double, d As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub TPFL2dll Lib "REFPROP.DLL" (t As Double, p As Double, x As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub TRNPRPdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, eta As Double, tcx As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub DIELECdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, de As Double) Private Declare Sub SURFTdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, sigma As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub SURTENdll Lib "REFPROP.DLL" (t As Double, rhol As Double, rhov As Double, xl As Double, xv As Double, sigma As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub HEATdll Lib "REFPROP.DLL" (t As Double, rho As Double, x As Double, hg As Double, hn As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub CSTARdll Lib "REFPROP.DLL" (t As Double, p As Double, v As Double, x As Double, cs As Double, ts As Double, Ds As Double, ps As Double, ws As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub FPVdll Lib "REFPROP.DLL" (t As Double, d As Double, p As Double, x As Double, f As Double) 'Private Declare Sub SPECGRdll Lib "REFPROP.DLL" (t As Double, d As Double, p As Double, Gr As Double) Private Declare Sub WMOLdll Lib "REFPROP.DLL" (x As Double, wm As Double) Private Declare Sub XMASSdll Lib "REFPROP.DLL" (xmol As Double, xkg As Double, wmix As Double) Private Declare Sub XMOLEdll Lib "REFPROP.DLL" (xkg As Double, xmol As Double, wmix As Double) Private Declare Sub QMASSdll Lib "REFPROP.DLL" (qmol As Double, xl As Double, xv As Double, qkg As Double, xlkg As Double, xvkg As Double, wliq As Double, wvap As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub QMOLEdll Lib "REFPROP.DLL" (qkg As Double, xlkg As Double, xvkg As Double, qmol As Double, xl As Double, xv As Double, wliq As Double, wvap As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub INFOdll Lib "REFPROP.DLL" (icomp As Long, wmm As Double, ttrp As Double, tnbpt As Double, tc As Double, pc As Double, dc As Double, Zc As Double, acf As Double, dip As Double, Rgas As Double) Private Declare Sub LIMITSdll Lib "REFPROP.DLL" (ByVal htyp As String, x As Double, tmin As Double, tmax As Double, dmax As Double, pmax As Double, ln As Long) Private Declare Sub LIMITXdll Lib "REFPROP.DLL" (ByVal htyp As String, t As Double, d As Double, p As Double, x As Double, tmin As Double, tmax As Double, dmax As Double, pmax As Double, ierr As Long, ByVal herr As String, ln1 As Long, ln2 As Long) Private Declare Sub LIMITKdll Lib "REFPROP.DLL" (ByVal htyp As String, icomp As Long, t As Double, d As Double, p As Double, tmin As Double, tmax As Double, dmax As Double, pmax As Double, ierr As Long, ByVal herr As String, ln1 As Long, ln2 As Long) Private Declare Sub ETAK0dll Lib "REFPROP.DLL" (icomp As Long, t As Double, eta0 As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub ETAK1dll Lib "REFPROP.DLL" (icomp As Long, t As Double, eta1 As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub ETAKRdll Lib "REFPROP.DLL" (icomp As Long, t As Double, rho As Double, etar As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub ETAKBdll Lib "REFPROP.DLL" (icomp As Long, t As Double, rho As Double, etab As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub OMEGAdll Lib "REFPROP.DLL" (icomp As Long, t As Double, epsk As Double, omg As Double) Private Declare Sub TCXK0dll Lib "REFPROP.DLL" (icomp As Long, t As Double, tcx0 As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub TCXKBdll Lib "REFPROP.DLL" (icomp As Long, t As Double, rho As Double, tcxb As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub TCXKCdll Lib "REFPROP.DLL" (icomp As Long, t As Double, rho As Double, tcxc As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Function SetCurDir Lib "kernel32" Alias "SetCurrentDirectoryA" (ByVal lpPathName As String) As Long #End If #Else Private Declare Sub SETUPdll Lib "REFPROP.DLL" (i As Long, ByVal hfld As String, ByVal hfmix As String, ByVal hrf As String, ierr As Long, ByVal herr As String, ln1 As Long, ln2 As Long, ln3 As Long, ln4 As Long) Private Declare Sub SETREFdll Lib "REFPROP.DLL" (ByVal hrf As String, ixflag As Long, x0 As Double, h0 As Double, s0 As Double, t0 As Double, p0 As Double, ierr As Long, ByVal herr As String, ln1 As Long, ln2 As Long) Private Declare Sub SETMIXdll Lib "REFPROP.DLL" (ByVal hmxnme As String, ByVal hfmix As String, ByVal hrf As String, ncc As Long, ByVal hfile As String, x As Double, ierr As Long, ByVal herr As String, ln1 As Long, ln2 As Long, ln3 As Long, ln4 As Long, ln5 As Long) Private Declare Sub SETMODdll Lib "REFPROP.DLL" (i As Long, ByVal htype As String, ByVal hmix As String, ByVal hcomp As String, ierr As Long, ByVal herr As String, ln1 As Long, ln2 As Long, ln3 As Long, ln4 As Long) Private Declare Sub SETPATHdll Lib "REFPROP.DLL" (ByVal hpath As String, ln As Long) Private Declare Sub GERG04dll Lib "REFPROP.DLL" (nc As Long, iflag As Long, ierr As Long, ByVal herr As String, ln1 As Long) Private Declare Sub SETKTVdll Lib "REFPROP.DLL" (icomp As Long, jcomp As Long, ByVal hmodij As String, fij As Double, ByVal hfmix As String, ierr As Long, ByVal herr As String, ln1 As Long, ln2 As Long, ln3 As Long) Private Declare Sub GETKTVdll Lib "REFPROP.DLL" (icomp As Long, jcomp As Long, ByVal hmodij As String, fij As Double, ByVal hfmix As String, ByVal hfij As String, ByVal hbinp As String, ByVal hmxrul As String, ln1 As Long, ln2 As Long, ln3 As Long, ln4 As Long, ln5 As Long) Private Declare Sub GETFIJdll Lib "REFPROP.DLL" (ByVal hmodij As String, fij As Double, ByVal hfij As String, ByVal hmxrul As String, ln1 As Long, ln2 As Long, ln3 As Long) Private Declare Sub PREOSdll Lib "REFPROP.DLL" (i As Long) Private Declare Sub SETAGAdll Lib "REFPROP.DLL" (ierr As Long, ByVal herr As String, ln1 As Long) Private Declare Sub UNSETAGAdll Lib "REFPROP.DLL" () Private Declare Sub NAMEdll Lib "REFPROP.DLL" (icomp As Long, ByVal hnam As String, ByVal hn80 As String, ByVal hcasn As String, ln1 As Long, ln2 As Long, ln3 As Long) Private Declare Sub PUREFLDdll Lib "REFPROP.DLL" (icomp As Long) Private Declare Sub SETNCdll Lib "REFPROP.DLL" (ncomp As Long) Private Declare Sub RPVersion Lib "REFPROP.DLL" (ByVal herr As String, ln As Long) Private Declare Sub CRITPdll Lib "REFPROP.DLL" (x As Double, tc As Double, pc As Double, dc As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub MAXTdll Lib "REFPROP.DLL" (x As Double, tm As Double, pm As Double, dm As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub MAXPdll Lib "REFPROP.DLL" (x As Double, tm As Double, pm As Double, dm As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub REDXdll Lib "REFPROP.DLL" (x As Double, t As Double, d As Double) Private Declare Sub THERMdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, p As Double, e As Double, h As Double, s As Double, Cv As Double, Cp As Double, w As Double, hjt As Double) Private Declare Sub THERM2dll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, p As Double, e As Double, h As Double, s As Double, Cv As Double, Cp As Double, w As Double, z As Double, hjt As Double, aH As Double, g As Double, kappa As Double, beta As Double, dPdD As Double, d2PdD2 As Double, dPdT As Double, dDdT As Double, dDdP As Double, d2PT2 As Double, d2PdTD As Double, spare3 As Double, spare4 As Double) Private Declare Sub THERM3dll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, kappa As Double, beta As Double, isenk As Double, kt As Double, betas As Double, bs As Double, kkt As Double, thrott As Double, pi As Double, spht As Double) Private Declare Sub THERM0dll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, p As Double, e As Double, h As Double, s As Double, Cv As Double, Cp As Double, w As Double, a As Double, g As Double) Private Declare Sub PRESSdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, p As Double) Private Declare Sub ENTHALdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, h As Double) Private Declare Sub ENTROdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, s As Double) Private Declare Sub CVCPdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, Cv As Double, Cp As Double) Private Declare Sub GIBBSdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, Ar As Double, Gr As Double) Private Declare Sub AGdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, a As Double, g As Double) Private Declare Sub PHIXdll Lib "REFPROP.DLL" (itau As Long, idel As Long, tau As Double, del As Double, x As Double, PHIX As Double) Private Declare Sub RESIDUALdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, pr As Double, er As Double, hr As Double, sr As Double, cvr As Double, cpr As Double, Ar As Double, Gr As Double) Private Declare Sub CP0dll Lib "REFPROP.DLL" (t As Double, x As Double, Cp As Double) Private Declare Sub DPDDdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, dPdD As Double) Private Declare Sub DPDD2dll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, d2PdD2 As Double) Private Declare Sub DPDTdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, dPdT As Double) Private Declare Sub DDDPdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, dDdP As Double) Private Declare Sub DDDTdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, dDdT As Double) Private Declare Sub DHD1dll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, dHdT_D As Double, dHdT_P As Double, dHdD_T As Double, dHdD_P As Double, dHdP_T As Double, dHdP_D As Double) Private Declare Sub VIRBdll Lib "REFPROP.DLL" (t As Double, x As Double, b As Double) Private Declare Sub VIRCdll Lib "REFPROP.DLL" (t As Double, x As Double, c As Double) Private Declare Sub VIRBAdll Lib "REFPROP.DLL" (t As Double, x As Double, b As Double) Private Declare Sub VIRCAdll Lib "REFPROP.DLL" (t As Double, x As Double, c As Double) Private Declare Sub DBDTdll Lib "REFPROP.DLL" (t As Double, x As Double, dbt As Double) Private Declare Sub B12dll Lib "REFPROP.DLL" (t As Double, x As Double, b As Double) Private Declare Sub FGCTYdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, f As Double) Private Declare Sub FGCTY2dll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, f As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub FUGCOFdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, f As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub CHEMPOTdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, u As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub ACTVYdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, actv As Double, gamma As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub EXCESSdll Lib "REFPROP.DLL" (t As Double, p As Double, x As Double, kph As Long, d As Double, vE As Double, ee As Double, hE As Double, sE As Double, aE As Double, gE As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub SATSPLNdll Lib "REFPROP.DLL" (x As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub SATTPdll Lib "REFPROP.DLL" (t As Double, p As Double, x As Double, kph As Long, iGuess As Long, d As Double, rhol As Double, rhov As Double, xliq As Double, xvap As Double, q As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub SATTdll Lib "REFPROP.DLL" (t As Double, x As Double, i As Long, p As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub SATPdll Lib "REFPROP.DLL" (p As Double, x As Double, i As Long, t As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub SATDdll Lib "REFPROP.DLL" (d As Double, x As Double, kph As Long, kr As Long, t As Double, p As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub SATHdll Lib "REFPROP.DLL" (h As Double, x As Double, kph As Long, nroot As Long, k1 As Long, t1 As Double, p1 As Double, d1 As Double, k2 As Long, t2 As Double, p2 As Double, d2 As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub SATEdll Lib "REFPROP.DLL" (e As Double, x As Double, kph As Long, nroot As Long, k1 As Long, t1 As Double, p1 As Double, d1 As Double, k2 As Long, t2 As Double, p2 As Double, d2 As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub SATSdll Lib "REFPROP.DLL" (s As Double, x As Double, kph As Long, nroot As Long, k1 As Long, t1 As Double, p1 As Double, d1 As Double, k2 As Long, t2 As Double, p2 As Double, d2 As Double, k3 As Long, t3 As Double, p3 As Double, d3 As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub CV2PKdll Lib "REFPROP.DLL" (icomp As Long, t As Double, rho As Double, cv2p As Double, Csat As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub CSATKdll Lib "REFPROP.DLL" (icomp As Long, t As Double, kph As Long, p As Double, rho As Double, Csat As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub DPTSATKdll Lib "REFPROP.DLL" (icomp As Long, t As Double, kph As Long, p As Double, rho As Double, Csat As Double, dPdTsat As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub PSATKdll Lib "REFPROP.DLL" (icomp As Long, t As Double, p As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub DLSATKdll Lib "REFPROP.DLL" (icomp As Long, t As Double, d As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub DVSATKdll Lib "REFPROP.DLL" (icomp As Long, t As Double, d As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub TSATDdll Lib "REFPROP.DLL" (d As Double, x As Double, t As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub MELTTdll Lib "REFPROP.DLL" (t As Double, x As Double, p As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub MLTH2Odll Lib "REFPROP.DLL" (t As Double, p1 As Double, p2 As Double) Private Declare Sub MELTPdll Lib "REFPROP.DLL" (p As Double, x As Double, t As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub SUBLTdll Lib "REFPROP.DLL" (t As Double, x As Double, p As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub SUBLPdll Lib "REFPROP.DLL" (p As Double, x As Double, t As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub TPRHOdll Lib "REFPROP.DLL" (t As Double, p As Double, x As Double, j As Long, i As Long, d As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub TPFLSHdll Lib "REFPROP.DLL" (t As Double, p As Double, x As Double, d As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, e As Double, h As Double, s As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub TDFLSHdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, p As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, e As Double, h As Double, s As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub PDFLSHdll Lib "REFPROP.DLL" (p As Double, d As Double, x As Double, t As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, e As Double, h As Double, s As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub PHFLSHdll Lib "REFPROP.DLL" (p As Double, h As Double, x As Double, t As Double, d As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, e As Double, s As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub PSFLSHdll Lib "REFPROP.DLL" (p As Double, s As Double, x As Double, t As Double, d As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, e As Double, h As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub PEFLSHdll Lib "REFPROP.DLL" (p As Double, e As Double, x As Double, t As Double, d As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, h As Double, s As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub THFLSHdll Lib "REFPROP.DLL" (t As Double, h As Double, x As Double, i As Long, p As Double, d As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, e As Double, s As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub TSFLSHdll Lib "REFPROP.DLL" (t As Double, s As Double, x As Double, i As Long, p As Double, d As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, e As Double, h As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub TEFLSHdll Lib "REFPROP.DLL" (t As Double, e As Double, x As Double, i As Long, p As Double, d As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, h As Double, s As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub DHFLSHdll Lib "REFPROP.DLL" (d As Double, h As Double, x As Double, t As Double, p As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, e As Double, s As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub DSFLSHdll Lib "REFPROP.DLL" (d As Double, s As Double, x As Double, t As Double, p As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, e As Double, h As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub DEFLSHdll Lib "REFPROP.DLL" (d As Double, e As Double, x As Double, t As Double, p As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, h As Double, s As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub HSFLSHdll Lib "REFPROP.DLL" (h As Double, s As Double, z As Double, t As Double, p As Double, d As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, e As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub ESFLSHdll Lib "REFPROP.DLL" (e As Double, s As Double, z As Double, t As Double, p As Double, d As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, h As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub TQFLSHdll Lib "REFPROP.DLL" (t As Double, q As Double, x As Double, kq As Long, p As Double, d As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, e As Double, h As Double, s As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub PQFLSHdll Lib "REFPROP.DLL" (p As Double, q As Double, x As Double, kq As Long, t As Double, d As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, e As Double, h As Double, s As Double, Cv As Double, Cp As Double, w As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub ABFL1dll Lib "REFPROP.DLL" (a As Double, b As Double, x As Double, i As Long, ByVal ab As String, dmin As Double, dmax As Double, t As Double, p As Double, d As Double, ierr As Long, ByVal herr As String, ln1 As Long, ln2 As Long) Private Declare Sub ABFL2dll Lib "REFPROP.DLL" (a As Double, b As Double, x As Double, kq As Long, ksat As Long, ByVal ab As String, tbub As Double, tdew As Double, pbub As Double, pdew As Double, Dlbub As Double, Dvdew As Double, ybub As Double, xdew As Double, t As Double, p As Double, Dl As Double, Dv As Double, x As Double, y As Double, q As Double, ierr As Long, ByVal herr As String, ln As Long, ln2 As Long) Private Declare Sub DBFL1dll Lib "REFPROP.DLL" (d As Double, b As Double, x As Double, ByVal ab As String, t As Double, p As Double, ierr As Long, ByVal herr As String, ln1 As Long, ln2 As Long) Private Declare Sub DBFL2dll Lib "REFPROP.DLL" (d As Double, b As Double, x As Double, i As Long, ByVal ab As String, t As Double, p As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, ierr As Long, ByVal herr As String, ln As Long, ln2 As Long) Private Declare Sub DQFL2dll Lib "REFPROP.DLL" (d As Double, q As Double, x As Double, kq As Long, t As Double, p As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub DSFL1dll Lib "REFPROP.DLL" (d As Double, s As Double, x As Double, t As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub PDFL1dll Lib "REFPROP.DLL" (p As Double, d As Double, x As Double, t As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub PHFL1dll Lib "REFPROP.DLL" (p As Double, h As Double, x As Double, kph As Long, t As Double, d As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub PSFL1dll Lib "REFPROP.DLL" (p As Double, s As Double, x As Double, kph As Long, t As Double, d As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub TPFL2dll Lib "REFPROP.DLL" (t As Double, p As Double, x As Double, Dl As Double, Dv As Double, xliq As Double, xvap As Double, q As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub TRNPRPdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, eta As Double, tcx As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub DIELECdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, de As Double) Private Declare Sub SURFTdll Lib "REFPROP.DLL" (t As Double, d As Double, x As Double, sigma As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub SURTENdll Lib "REFPROP.DLL" (t As Double, rhol As Double, rhov As Double, xl As Double, xv As Double, sigma As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub HEATdll Lib "REFPROP.DLL" (t As Double, rho As Double, x As Double, hg As Double, hn As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub CSTARdll Lib "REFPROP.DLL" (t As Double, p As Double, v As Double, x As Double, cs As Double, ts As Double, Ds As Double, ps As Double, ws As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub FPVdll Lib "REFPROP.DLL" (t As Double, d As Double, p As Double, x As Double, f As Double) 'Private Declare Sub SPECGRdll Lib "REFPROP.DLL" (t As Double, d As Double, p As Double, Gr As Double) Private Declare Sub WMOLdll Lib "REFPROP.DLL" (x As Double, wm As Double) Private Declare Sub XMASSdll Lib "REFPROP.DLL" (xmol As Double, xkg As Double, wmix As Double) Private Declare Sub XMOLEdll Lib "REFPROP.DLL" (xkg As Double, xmol As Double, wmix As Double) Private Declare Sub QMASSdll Lib "REFPROP.DLL" (qmol As Double, xl As Double, xv As Double, qkg As Double, xlkg As Double, xvkg As Double, wliq As Double, wvap As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub QMOLEdll Lib "REFPROP.DLL" (qkg As Double, xlkg As Double, xvkg As Double, qmol As Double, xl As Double, xv As Double, wliq As Double, wvap As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub INFOdll Lib "REFPROP.DLL" (icomp As Long, wmm As Double, ttrp As Double, tnbpt As Double, tc As Double, pc As Double, dc As Double, Zc As Double, acf As Double, dip As Double, Rgas As Double) Private Declare Sub LIMITSdll Lib "REFPROP.DLL" (ByVal htyp As String, x As Double, tmin As Double, tmax As Double, dmax As Double, pmax As Double, ln As Long) Private Declare Sub LIMITXdll Lib "REFPROP.DLL" (ByVal htyp As String, t As Double, d As Double, p As Double, x As Double, tmin As Double, tmax As Double, dmax As Double, pmax As Double, ierr As Long, ByVal herr As String, ln1 As Long, ln2 As Long) Private Declare Sub LIMITKdll Lib "REFPROP.DLL" (ByVal htyp As String, icomp As Long, t As Double, d As Double, p As Double, tmin As Double, tmax As Double, dmax As Double, pmax As Double, ierr As Long, ByVal herr As String, ln1 As Long, ln2 As Long) Private Declare Sub ETAK0dll Lib "REFPROP.DLL" (icomp As Long, t As Double, eta0 As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub ETAK1dll Lib "REFPROP.DLL" (icomp As Long, t As Double, eta1 As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub ETAKRdll Lib "REFPROP.DLL" (icomp As Long, t As Double, rho As Double, etar As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub ETAKBdll Lib "REFPROP.DLL" (icomp As Long, t As Double, rho As Double, etab As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub OMEGAdll Lib "REFPROP.DLL" (icomp As Long, t As Double, epsk As Double, omg As Double) Private Declare Sub TCXK0dll Lib "REFPROP.DLL" (icomp As Long, t As Double, tcx0 As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub TCXKBdll Lib "REFPROP.DLL" (icomp As Long, t As Double, rho As Double, tcxb As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Sub TCXKCdll Lib "REFPROP.DLL" (icomp As Long, t As Double, rho As Double, tcxc As Double, ierr As Long, ByVal herr As String, ln As Long) Private Declare Function SetCurDir Lib "kernel32" Alias "SetCurrentDirectoryA" (ByVal lpPathName As String) As Long #End If 'Used to call REFPROP: Private herr As String * 255, herr2 As String * 255, hfmix As String * 255, hfmix2 As String * 255, hrf As String * 3, htyp As String * 3, hmxnme As String * 255 Private hfld As String * 10000, hfldOld As String * 10000 Private nc As Long, phase As Long, molmass As Long Private x(1 To MaxComps) As Double, xliq(1 To MaxComps) As Double, xvap(1 To MaxComps) As Double, xmm(1 To MaxComps) As Double, xkg(1 To MaxComps) As Double, xmol(1 To MaxComps) As Double, wmix As Double Private ierr As Long, ierr2 As Long, kq As Long, kr As Long Private t As Double, p As Double, d As Double, Dl As Double, Dv As Double, q As Double, wm As Double, tz As Double, pz As Double, dz As Double, dd As Double Private e As Double, h As Double, s As Double, Cvcalc As Double, Cpcalc As Double, w As Double Private tmin As Double, tmax As Double, dmax As Double, pmax As Double Private tc As Double, pc As Double, dc As Double Private tbub As Double, tdew As Double, pbub As Double, pdew As Double, Dlbub As Double, Dvdew As Double, ybub(1 To MaxComps) As Double, xdew(1 To MaxComps) As Double Private eta As Double, tcx As Double, sigma As Double, hjt As Double, de As Double Private wmm As Double, ttrp As Double, tnbpt As Double, Zc As Double, acf As Double, dip As Double, Rgas As Double Private tUnits(10) As String, taUnits(10) As String, pUnits(10) As String, dUnits(10) As String, vUnits(10) As String, hUnits(10) As String, sUnits(10) As String, wUnits(10) As String, visUnits(10) As String, tcxUnits(10) As String, stUnits(10) As String Private tUnits2 As String, taUnits2 As String, pUnits2 As String, dUnits2 As String, vUnits2 As String, hUnits2 As String, sUnits2 As String, wUnits2 As String, visUnits2 As String, tcxUnits2 As String, stUnits2 As String, DefUnit As Integer, DefaultUnits As Integer Private FldOld As String Private z As Double, aHelm As Double, Gibbs As Double, xkappa As Double, beta As Double Private dPdD_T As Double, d2PdD2_rho As Double, dPdT_rho As Double, dDdT_P As Double, dDdP_rho As Double Private d2PT2 As Double, d2PdTD As Double, spare3 As Double, spare4 As Double Private isenk As Double, kt As Double, betas As Double, bs As Double, kkt As Double, thrott As Double, xpi As Double, spht As Double Private nroot As Long, k1 As Long, k2 As Long, k3 As Long, t2 As Double, p2 As Double, d2 As Double, t3 As Double, p3 As Double, d3 As Double Private eta0 As Double, eta1 As Double, etar As Double, etab As Double, epsk As Double, tcx0 As Double, tcxb As Double, tcxc As Double, omg As Double Private Const CtoK As Double = 273.15 'Exact conversion Private Const FtoR As Double = 459.67 'Exact conversion Private Const RtoK As Double = 5 / 9 'Exact conversion Private Const HtoS As Double = 3600 'Exact conversion Private Const ATMtoMPa As Double = 0.101325 'Exact conversion Private Const BARtoMPA As Double = 0.1 'Exact conversion Private Const KGFtoN As Double = 98.0665 / 10 'Exact conversion Private Const INtoM As Double = 0.0254 'Exact conversion Private Const FTtoM As Double = 12 * INtoM 'Exact conversion Private Const LBMtoKG As Double = 0.45359237 'Exact conversion Private Const CALtoJ As Double = 4.184 'Exact conversion (tc) 'private Const CALtoJ As Double = 4.1868 'Exact conversion (IT) (Use this one only with pure water) Private Const MMHGtoMPA As Double = ATMtoMPa / 760 'Exact conversion Private Const INH2OtoMPA As Double = 0.000249082 Private Const BTUtoKJ As Double = CALtoJ * LBMtoKG * RtoK Private Const LBFtoN As Double = LBMtoKG * KGFtoN Private Const IN3toM3 As Double = INtoM * INtoM * INtoM Private Const FT3toM3 As Double = FTtoM * FTtoM * FTtoM Private Const GALLONtoM3 As Double = IN3toM3 * 231 Private Const PSIAtoMPA As Double = LBMtoKG / INtoM / INtoM * KGFtoN / 1000000 Private Const FTLBFtoJ As Double = FTtoM * LBFtoN Private Const HPtoW As Double = 550 * FTLBFtoJ Private Const BTUtoW As Double = BTUtoKJ * 1000 Private Const LBFTtoNM As Double = LBFtoN / FTtoM Private CompFlag As Integer Function Setup(FluidName) Dim a As String, ab As String, FluidNme As String, FlNme As String Dim i As Integer, sum As Double, sc As Integer, ncc As Integer, nc2 As Long Dim Mass As Integer, MixType As Integer Dim hRef As Double, sRef As Double, Tref As Double, pref As Double Dim htype As String * 3, hmix As String * 3, hcomp As String * 60 Dim RPPrefix As String, FluidsPrefix As String, MixturesPrefix As String Dim xtemp(1 To MaxComps) As Double ierr = 0 herr = "" FlNme = FluidName If InStr(FluidName, "error") Then Exit Function If InStr(FluidName, "Inputs are out of range") Then Exit Function If FluidName = FldOld Then Exit Function FldOld = "" Call CheckName(FluidName) RPPrefix = Trim(Environ("RPPrefix")) If Right(RPPrefix, 1) = "\" Then RPPrefix = Left(RPPrefix, Len(RPPrefix) - 1) If RPPrefix = "" Then FluidsPrefix = FluidsDirectory MixturesPrefix = MixturesDirectory Else FluidsPrefix = RPPrefix & "\" & FluidsDirectory MixturesPrefix = RPPrefix & "\" & MixturesDirectory End If hrf = "DEF" hfmix = FluidsPrefix & "hmx.bnc" On Error GoTo ErrorHandler: ChDrive (ThisWorkbook.Path) ChDir (ThisWorkbook.Path) 'ChDrive (Application.ActiveWorkbook.Path) 'ChDir (Application.ActiveWorkbook.Path) On Error GoTo 0 'Use this for UNC drives ' ChDirUNC ThisWorkbook.Path a = "" For i = 1 To MaxComps: xtemp(i) = 0: Next Mass = 0 MixType = 0 If InStr(FluidName, "/") <> 0 And InStr(FluidName, "(") <> 0 Then MixType = 2 If InStr(FluidName, ",") <> 0 Or InStr(FluidName, ";") <> 0 Then MixType = 1 'This section added by J. Newland 9JUL2010 (15MAY2012) to recognize mixed refrigerants If (Left(UCase(FluidName), 2) = "R4" Or Left(UCase(FluidName), 2) = "R5") And InStr(UCase(FluidName), ".MIX") = 0 And MixType = 0 Then FluidName = FluidName & ".MIX" End If 'Set up predefined mixtures (using *.MIX) If InStr(UCase(FluidName), ".MIX") Then hmxnme = MixturesPrefix & FluidName Call SETMIXdll(hmxnme, hfmix, hrf, nc2, hfld, xtemp(1), ierr, herr, 255&, 255&, 3&, 10000&, 255&) ElseIf MixType Then FluidNme = Trim(FluidName) If UCase(Right(FluidNme, 4)) = "MASS" Then Mass = 1: FluidNme = Trim(Left(FluidNme, Len(FluidNme) - 4)) nc2 = 0 If MixType = 1 Then 'Set up user specified mixtures where fluids are separated by "," or ";" If InStr(FluidNme, ";") Then sc = 1 Else sc = 0 Do If sc = 0 Then i = InStr(FluidNme, ",") Else i = InStr(FluidNme, ";") If i = 0 Then i = Len(FluidNme) + 1 nc2 = nc2 + 1 If nc2 > MaxComps Then ierr = 1: herr = Trim2("Too many components"): Exit Function ab = Trim(Left(FluidNme, i - 1)) Call CheckName(ab) If InStr(LCase(ab), ".fld") = 0 Then ab = ab + ".fld" a = a & FluidsPrefix & ab & "|" FluidNme = Mid(FluidNme, i + 1) If sc = 0 Then i = InStr(FluidNme, ",") Else i = InStr(FluidNme, ";") If i = 0 Then i = Len(FluidNme) + 1 xtemp(nc2) = CDbl(Left(FluidNme, i - 1)) FluidNme = Trim(Mid(FluidNme, i + 1)) Loop Until FluidNme = "" ElseIf MixType = 2 Then 'Set up user specified mixtures with "/" as the separator Do i = InStr(FluidNme, "/") If InStr(FluidNme, "(") < i Then i = InStr(FluidNme, "(") If i = 0 Then i = Len(FluidNme) + 1 nc2 = nc2 + 1 If nc2 > MaxComps Then ierr = 1: herr = Trim2("Too many components"): Exit Function ab = Trim(Left(FluidNme, i - 1)) Call CheckName(ab) If InStr(LCase(ab), ".fld") = 0 Then ab = ab + ".fld" a = a & FluidsPrefix & ab & "|" FluidNme = Trim(Mid(FluidNme, i)) If Left(FluidNme, 1) = "/" Then FluidNme = Trim(Mid(FluidNme, 2)) Loop Until Left(FluidNme, 1) = "(" FluidNme = Mid(FluidNme, 2) If Right(FluidNme, 1) = ")" Then FluidNme = Trim(Left(FluidNme, Len(FluidNme) - 1)) ncc = 0 Do i = InStr(FluidNme, "/") If i = 0 Then i = Len(FluidNme) + 1 ncc = ncc + 1 If ncc > MaxComps Then ierr = 1: herr = Trim2("Too many components"): Exit Function xtemp(ncc) = CDbl(Left(FluidNme, i - 1)) FluidNme = Mid(FluidNme, i + 1) Loop Until FluidNme = "" End If 'Common code for mixtures sum = 0 For i = 1 To nc2: sum = sum + xtemp(i): Next If sum <= 0 Then ierr = 1: herr = Trim2("Composition not set"): Exit Function For i = 1 To nc2: xtemp(i) = xtemp(i) / sum: Next hfld = a If nc2 < 1 Then ierr = 1: herr = Trim2("Setup failed"): Exit Function If hfld <> hfldOld Then 'To load the GERG-2004 pure fluid equations of state rather than the defaults 'that come with REFPROP, call the GERG04dll routine with a 1 as the second input. 'Call GERG04dll(nc2, 1&, ierr, herr, 255&) Call SETUPdll(nc2, hfld, hfmix, hrf, ierr, herr, 10000&, 255&, 3&, 255&) If ierr > 0 Then hfld = "" 'To load the AGA8 equation of state, call SETAGA after calling SETUP 'Call SETAGAdll(ierr, herr, 255&) End If 'Set up pure fluids Else nc2 = 1 If InStr(LCase(FluidName), ".fld") = 0 And InStr(LCase(FluidName), ".ppf") = 0 Then FluidName = FluidName + ".fld" If InStr(FluidName, "\") Then hfld = FluidName Else hfld = FluidsPrefix & FluidName End If '...Use call to SETMOD to change the equation of state for any of the '.....pure components from the default (recommended) values. '.....This should only be implemented by an experienced user. 'If InStr(LCase(hfld), "argon") <> 0 And nc2 = 1 Then ' hcomp = "FE1": htype = "EOS": hmix = hcomp ' Call SETMODdll(nc2, htype, hmix, hcomp, ierr, herr, 3&, 3&, 60&, 255&) 'End If Call SETUPdll(nc2, hfld, hfmix, hrf, ierr, herr, 10000&, 255&, 3&, 255&) If ierr > 0 Then hfld = "" End If hfldOld = hfld 'Use call to PREOSdll to change the equation of state to Peng Robinson for all calculations. 'To revert back to the normal REFPROP EOS and models, use: Call PREOSdll(0&) 'Call PREOSdll(2&) If Mass Then For i = 1 To nc2 xkg(i) = xtemp(i) Next Call XMOLEdll(xkg(1), xtemp(1), wmix) End If If ierr <= 0 Then nc = nc2 'If setup was successful, load new values of nc and x() For i = 1 To nc x(i) = xtemp(i) Next Setup = FluidName FldOld = FlNme 'Use the following line to activate the call to SATSPLN, which will set up 'spline curves that represent the saturation states of the mixture, allowing Refprop 'to know the critical point, the saturation state with the maximum temperature, and 'the saturation state with the maximum pressure (all of these for the composition given 'in x). However, this call is slow and is best used in a separate xls file for a 'dedicated mixture. 'Call SATSPLNdll(x(1), ierr, herr, 255) 'Use the following line to calculate enthalpies and entropies on a reference state 'based on the currently defined mixture, or to change to some other reference state. 'The routine does not have to be called, but doing so will cause calculations 'to be the same as those produced from the graphical interface for mixtures. Call SETREFdll(hrf, 2&, x(1), hRef, sRef, Tref, pref, ierr2, herr2, 3&, 255&) Else Setup = Trim2(herr) FldOld = "" End If Exit Function ErrorHandler: Resume Next End Function Sub CheckName(FluidName) Restart: If Left(FluidName, 1) = Chr(34) Then FluidName = Mid(FluidName, 2): GoTo Restart End If If Right(FluidName, 1) = Chr(34) Then FluidName = Left(FluidName, Len(FluidName) - 1): GoTo Restart End If If UCase(FluidName) = "AIR" Then FluidName = "nitrogen;7812;argon;0092;oxygen;2096" If UCase(FluidName) = "CARBON DIOXIDE" Then FluidName = "CO2" If UCase(FluidName) = "CARBON MONOXIDE" Then FluidName = "CO" If UCase(FluidName) = "CARBONYL SULFIDE" Then FluidName = "COS" If UCase(FluidName) = "CYCLOHEXANE" Then FluidName = "CYCLOHEX" If UCase(FluidName) = "CYCLOPROPANE" Then FluidName = "CYCLOPRO" If UCase(FluidName) = "DEUTERIUM" Then FluidName = "D2" If UCase(FluidName) = "HEAVY WATER" Then FluidName = "D2O" If UCase(FluidName) = "HYDROGEN SULFIDE" Then FluidName = "H2S" If UCase(FluidName) = "IBUTANE" Then FluidName = "ISOBUTAN" If UCase(FluidName) = "ISOBUTANE" Then FluidName = "ISOBUTAN" If UCase(FluidName) = "ISOPENTANE" Then FluidName = "IPENTANE" If UCase(FluidName) = "NEOPENTANE" Then FluidName = "NEOPENTN" If UCase(FluidName) = "ISOHEXANE" Then FluidName = "IHEXANE" If UCase(FluidName) = "NITROUS OXIDE" Then FluidName = "N2O" If UCase(FluidName) = "PARAHYDROGEN" Then FluidName = "PARAHYD" If UCase(FluidName) = "PROPYLENE" Then FluidName = "PROPYLEN" If UCase(FluidName) = "SULFUR HEXAFLUORIDE" Then FluidName = "SF6" If UCase(FluidName) = "DIMETHYLETHER" Then FluidName = "DME" If UCase(FluidName) = "BUTENE" Then FluidName = "1BUTENE" If UCase(FluidName) = "ISOBUTENE" Then FluidName = "IBUTENE" If UCase(FluidName) = "CIS-BUTENE" Then FluidName = "C2BUTENE" If UCase(FluidName) = "TRANS-BUTENE" Then FluidName = "T2BUTENE" If UCase(FluidName) = "TRIFLUOROIODOMETHANE" Then FluidName = "CF3I" If UCase(FluidName) = "PERFLUOROBUTANE" Then FluidName = "C4F10" If UCase(FluidName) = "PERFLUOROPENTANE" Then FluidName = "C5F12" If UCase(FluidName) = "NITROGEN TRIFLUORIDE" Then FluidName = "NF3" If UCase(FluidName) = "SULFUR DIOXIDE" Then FluidName = "SO2" If UCase(FluidName) = "SULFUR HEXAFLUORIDE" Then FluidName = "SF6" If UCase(FluidName) = "DODECANE" Then FluidName = "C12" If UCase(FluidName) = "DIMETHYLETHER" Then FluidName = "DME" End Sub Sub CalcSetup(FluidName, InpCode, Units, Prop1, Prop2) If Trim(FluidName) = "" Then herr = Trim2("Invalid inputs"): Exit Sub Call Setup(FluidName) If ierr > 0 Then Exit Sub Call ConvertUnits(InpCode, Units, Prop1, Prop2) If ierr = 1 Then herr = Trim2(herr): Exit Sub herr = "" q = 0: t = 0: p = 0: d = 0: Dl = 0: Dv = 0: e = 0: h = 0: s = 0: Cvcalc = 0: Cpcalc = 0: w = 0 End Sub Sub CalcProp(FluidName, InpCode, ByVal Units, ByVal Prop1, ByVal Prop2) Dim iflag1 As Integer, iflag2 As Integer ThisWorkbook.Activate q = 0: t = 0: p = 0: d = 0: Dl = 0: Dv = 0: e = 0: h = 0: s = 0: Cvcalc = 0: Cpcalc = 0: w = 0 If IsMissing(Prop1) Then iflag1 = 1 If iflag1 = 0 Then If Len(Trim(Prop1)) = 0 Then iflag1 = 2 If iflag1 = 0 Then If CDbl(Prop1) = 0 And Prop1 <> "0" Then ierr = 1: herr = Trim2("Invalid input: ") + Prop1: Exit Sub End If If IsMissing(Prop2) Then iflag2 = 1 If iflag2 = 0 Then If Len(Trim(Prop2)) = 0 Then iflag2 = 2 If iflag2 = 0 Then If CDbl(Prop2) = 0 And Prop2 <> "0" Then ierr = 1: herr = Trim2("Invalid input: ") + Prop2: Exit Sub End If If IsMissing(InpCode) Then InpCode = "" Call CalcSetup(FluidName, InpCode, Units, Prop1, Prop2) If UCase(Left(InpCode, 4)) = "CRIT" Then Call CRITPdll(x(1), t, p, d, ierr, herr, 255&) If ierr = 0 Then Call THERMdll(t, d, x(1), pc, e, h, s, Cvcalc, Cpcalc, w, hjt) Exit Sub ElseIf UCase(Left(InpCode, 7)) = "SATMAXT" Then Call MAXTdll(x(1), t, p, d, ierr, herr, 255&) If ierr = 0 Then Call THERMdll(t, d, x(1), pc, e, h, s, Cvcalc, Cpcalc, w, hjt) Exit Sub ElseIf UCase(Left(InpCode, 7)) = "SATMAXP" Then Call MAXPdll(x(1), t, p, d, ierr, herr, 255&) If ierr = 0 Then Call THERMdll(t, d, x(1), pc, e, h, s, Cvcalc, Cpcalc, w, hjt) Exit Sub ElseIf UCase(Left(InpCode, 4)) = "TRIP" Then If nc <> 1 Then ierr = 1: herr = Trim2("Can only return triple point for a pure fluid"): Exit Sub Call INFOdll(1, wmm, t, tnbpt, tc, pc, dc, Zc, acf, dip, Rgas) Call SATTdll(t, x(1), 1, p, d, Dv, xliq(1), xvap(1), ierr, herr, 255&) If ierr = 0 Then Call THERMdll(t, d, x(1), pc, e, h, s, Cvcalc, Cpcalc, w, hjt) Exit Sub End If If iflag1 Then ierr = 1: herr = Trim2("Inputs are missing"): Exit Sub If ierr > 0 Then Exit Sub If InpCode <> "" Then Call Calc(InpCode, Prop1, Prop2, iflag1, iflag2) End Sub Sub Calc(InputCode, Prop1, Prop2, iflag1, iflag2) Dim a As String, Input1 As String, Input2 As String, InpCode, i As Integer, pp As Double Dim xlkg(1 To MaxComps) As Double, xvkg(1 To MaxComps) As Double, xlj(1 To MaxComps) As Double, xvj(1 To MaxComps) As Double, qmol As Double, wliq As Double, wvap As Double ierr = 0 herr = "" InpCode = Trim(UCase(InputCode)) Input2 = "" Input1 = Left(InpCode, 1) If Len(InpCode) = 2 Then Input2 = Mid(InpCode, 2, 1) If Len(InpCode) = 3 Then a = Right(InpCode, 1) If a = "&" Or a = "<" Or a = ">" Then Input2 = Mid(InpCode, 2, 1) End If If Left(InpCode, 2) = "TP" Or Left(InpCode, 2) = "PT" Then Input2 = Mid(InpCode, 2, 1) If Input1 = "T" Then t = Prop1: If iflag1 >= 1 Then GoTo Error1 If Input1 = "P" Then p = Prop1: If iflag1 >= 1 Then GoTo Error1 If Input1 = "D" Then d = Prop1: If iflag1 >= 1 Then GoTo Error1 If Input1 = "V" And Prop1 <> 0 And Len(InpCode) = 2 Then d = 1 / Prop1: Mid(InpCode, 1, 1) = "D": If iflag1 >= 1 Then GoTo Error1 If Input1 = "E" Then e = Prop1: If iflag1 >= 1 Then GoTo Error1 If Input1 = "H" Then h = Prop1: If iflag1 >= 1 Then GoTo Error1 If Input1 = "S" Then s = Prop1: If iflag1 >= 1 Then GoTo Error1 If Input1 = "Q" Then q = Prop1: If iflag1 >= 1 Then GoTo Error1 If Input2 = "T" Then t = Prop2: If iflag2 >= 1 Then GoTo Error2 If Input2 = "P" Then p = Prop2: If iflag2 >= 1 Then GoTo Error2 If Input2 = "D" Then d = Prop2: If iflag2 >= 1 Then GoTo Error2 If Input2 = "V" And Prop2 <> 0 And Len(InpCode) = 2 Then d = 1 / Prop2: Mid(InpCode, 2, 1) = "D": If iflag2 >= 1 Then GoTo Error2 If Input2 = "E" Then e = Prop2: If iflag2 >= 1 Then GoTo Error2 If Input2 = "H" Then h = Prop2: If iflag2 >= 1 Then GoTo Error2 If Input2 = "S" Then s = Prop2: If iflag2 >= 1 Then GoTo Error2 If Input2 = "Q" Then q = Prop2: If iflag2 >= 1 Then GoTo Error2 phase = 2 If Len(InpCode) > 1 Then If UCase(Mid(InpCode, 2, 1)) = "L" Then phase = 1 For i = 1 To nc xliq(i) = 0: xvap(i) = 0 Next If Left(InpCode, 1) = "T" And t <= 0 Then herr = Trim2("Input temperature is zero"): Exit Sub 'Calculate saturation values given temperature If InpCode = "TL" Or InpCode = "TLIQ" Or InpCode = "TVAP" Then Call SATTdll(t, x(1), phase, p, Dl, Dv, xliq(1), xvap(1), ierr, herr, 255&) If (p = 0 Or Dl = 0) And ierr = 0 Then ierr = 1: herr = Trim2("Inputs are out of range"): Exit Sub d = Dl: q = 0 If phase = 2 Then d = Dv: q = 1 Call THERMdll(t, d, x(1), p, e, h, s, Cvcalc, Cpcalc, w, hjt) 'Calculate saturation values given pressure ElseIf InpCode = "PL" Or InpCode = "PLIQ" Or InpCode = "PVAP" Then Call SATPdll(p, x(1), phase, t, Dl, Dv, xliq(1), xvap(1), ierr, herr, 255&) If (p = 0 Or Dl = 0) And ierr = 0 Then ierr = 1: herr = Trim2("Inputs are out of range"): Exit Sub d = Dl: q = 0 If phase = 2 Then d = Dv: q = 1 Call THERMdll(t, d, x(1), p, e, h, s, Cvcalc, Cpcalc, w, hjt) 'Calculate saturation values given density ElseIf InpCode = "DSAT" Or InpCode = "DL" Or InpCode = "DLIQ" Or InpCode = "DVAP" Then Call SATDdll(d, x(1), 1&, kr, t, p, Dl, Dv, xliq(1), xvap(1), ierr, herr, 255&) Call THERMdll(t, d, x(1), p, e, h, s, Cvcalc, Cpcalc, w, hjt) q = kr - 1 'Calculate properties given the enthalpy along the saturation line ElseIf InpCode = "HSAT" Or InpCode = "HSAT1" Then Call SATHdll(h, x(1), 0&, nroot, k1, t, p, d, k2, t2, p2, d2, ierr, herr, 255&) Call THERMdll(t, d, x(1), p, e, h, s, Cvcalc, Cpcalc, w, hjt) q = k1 - 1 If nroot = 0 Then ierr = 1: herr = Trim2("Inputs are out of range"): Exit Sub 'Calculate properties given the enthalpy along the saturation line for the second possible root ElseIf InpCode = "HSAT2" Then Call SATHdll(h, x(1), 0&, nroot, k2, t2, p2, d2, k1, t, p, d, ierr, herr, 255&) Call THERMdll(t, d, x(1), p, e, h, s, Cvcalc, Cpcalc, w, hjt) q = k1 - 1 If nroot < 2 Then ierr = 1: herr = Trim2("Inputs are out of range or there is no second root"): Exit Sub 'Calculate properties given the entropy along the saturation line ElseIf InpCode = "SSAT" Or InpCode = "SSAT1" Then Call SATSdll(s, x(1), 0&, nroot, k1, t, p, d, k2, t2, p2, d2, k3, t3, p3, d3, ierr, herr, 255&) Call THERMdll(t, d, x(1), p, e, h, s, Cvcalc, Cpcalc, w, hjt) q = k1 - 1 If nroot = 0 Then ierr = 1: herr = Trim2("Inputs are out of range"): Exit Sub 'Calculate properties given the entropy along the saturation line for the second possible root ElseIf InpCode = "SSAT2" Then Call SATSdll(s, x(1), 0&, nroot, k2, t2, p2, d2, k1, t, p, d, k3, t3, p3, d3, ierr, herr, 255&) Call THERMdll(t, d, x(1), p, e, h, s, Cvcalc, Cpcalc, w, hjt) q = k1 - 1 If nroot < 2 Then ierr = 1: herr = Trim2("Inputs are out of range or there is no second root"): Exit Sub 'Calculate properties given the entropy along the saturation line for the third possible root ElseIf InpCode = "SSAT3" Then Call SATSdll(s, x(1), 0&, nroot, k3, t3, p3, d3, k2, t2, p2, d2, k1, t, p, d, ierr, herr, 255&) Call THERMdll(t, d, x(1), p, e, h, s, Cvcalc, Cpcalc, w, hjt) q = k1 - 1 If nroot < 3 Then ierr = 1: herr = Trim2("Inputs are out of range or there is no third root"): Exit Sub ElseIf InpCode = "TPL" Or InpCode = "PTL" Then Call TPRHOdll(t, p, x(1), 1&, 0&, d, ierr, herr, 255&) Dl = d: Dv = d: q = 990 Call THERMdll(t, d, x(1), pp, e, h, s, Cvcalc, Cpcalc, w, hjt) ElseIf InpCode = "TPV" Or InpCode = "PTV" Then Call TPRHOdll(t, p, x(1), 2&, 0&, d, ierr, herr, 255&) Dl = d: Dv = d: q = 990 Call THERMdll(t, d, x(1), pp, e, h, s, Cvcalc, Cpcalc, w, hjt) ElseIf InpCode = "TP" Or InpCode = "PT" Then Call TPFLSHdll(t, p, x(1), d, Dl, Dv, xliq(1), xvap(1), q, e, h, s, Cvcalc, Cpcalc, w, ierr, herr, 255&) If ierr = -16 And nc = 1 Then herr2 = herr 'Point is below triple point, call SATT to see if a sublimation line is available 'and to check if the input p is less than the sublimation pressure. Call SATTdll(t, x(1), 2, pp, Dl, Dv, xliq(1), xvap(1), ierr, herr, 255&) If p < pp And ierr <= 0 Then Call TPRHOdll(t, p, x(1), 2&, 0&, d, ierr, herr, 255&) Else ierr = -16: herr = herr2 End If q = 998 End If ElseIf InpCode = "TD" Or InpCode = "DT" Then Call TDFLSHdll(t, d, x(1), p, Dl, Dv, xliq(1), xvap(1), q, e, h, s, Cvcalc, Cpcalc, w, ierr, herr, 255&) ElseIf InpCode = "TD&" Or InpCode = "DT&" Then 'Do not perform any flash calculation here Call THERMdll(t, d, x(1), p, e, h, s, Cvcalc, Cpcalc, w, hjt) q = 990 ElseIf Left(InpCode, 2) = "TH" Or Left(InpCode, 2) = "HT" Then If InStr(InpCode, "<") Then Call THFLSHdll(t, h, x(1), 1&, p, d, Dl, Dv, xliq(1), xvap(1), q, e, s, Cvcalc, Cpcalc, w, ierr, herr, 255&) Else Call THFLSHdll(t, h, x(1), 2&, p, d, Dl, Dv, xliq(1), xvap(1), q, e, s, Cvcalc, Cpcalc, w, ierr, herr, 255&) End If ElseIf InpCode = "TS" Or InpCode = "ST" Then Call TSFLSHdll(t, s, x(1), 1&, p, d, Dl, Dv, xliq(1), xvap(1), q, e, h, Cvcalc, Cpcalc, w, ierr, herr, 255&) ElseIf InpCode = "TE" Or InpCode = "ET" Then Call TEFLSHdll(t, e, x(1), 2&, p, d, Dl, Dv, xliq(1), xvap(1), q, h, s, Cvcalc, Cpcalc, w, ierr, herr, 255&) ElseIf InpCode = "TQ" Or InpCode = "QT" Then Call TQFLSHdll(t, q, x(1), molmass, p, d, Dl, Dv, xliq(1), xvap(1), e, h, s, Cvcalc, Cpcalc, w, ierr, herr, 255&) If molmass = 2 Then Call XMASSdll(xliq(1), xlkg(1), wmix) Call XMASSdll(xvap(1), xvkg(1), wmix) Call QMOLEdll(q, xlkg(1), xvkg(1), qmol, xlj(1), xvj(1), wliq, wvap, ierr, herr, 255&) q = qmol End If ElseIf InpCode = "PD" Or InpCode = "DP" Then Call PDFLSHdll(p, d, x(1), t, Dl, Dv, xliq(1), xvap(1), q, e, h, s, Cvcalc, Cpcalc, w, ierr, herr, 255&) ElseIf InpCode = "PH" Or InpCode = "HP" Then Call PHFLSHdll(p, h, x(1), t, d, Dl, Dv, xliq(1), xvap(1), q, e, s, Cvcalc, Cpcalc, w, ierr, herr, 255&) ElseIf InpCode = "PS" Or InpCode = "SP" Then Call PSFLSHdll(p, s, x(1), t, d, Dl, Dv, xliq(1), xvap(1), q, e, h, Cvcalc, Cpcalc, w, ierr, herr, 255&) ElseIf InpCode = "PE" Or InpCode = "EP" Then Call PEFLSHdll(p, e, x(1), t, d, Dl, Dv, xliq(1), xvap(1), q, h, s, Cvcalc, Cpcalc, w, ierr, herr, 255&) ElseIf InpCode = "PQ" Or InpCode = "QP" Then Call PQFLSHdll(p, q, x(1), molmass, t, d, Dl, Dv, xliq(1), xvap(1), e, h, s, Cvcalc, Cpcalc, w, ierr, herr, 255&) If molmass = 2 Then Call XMASSdll(xliq(1), xlkg(1), wmix) Call XMASSdll(xvap(1), xvkg(1), wmix) Call QMOLEdll(q, xlkg(1), xvkg(1), qmol, xlj(1), xvj(1), wliq, wvap, ierr, herr, 255&) q = qmol End If ElseIf InpCode = "DH" Or InpCode = "HD" Then Call DHFLSHdll(d, h, x(1), t, p, Dl, Dv, xliq(1), xvap(1), q, e, s, Cvcalc, Cpcalc, w, ierr, herr, 255&) ElseIf InpCode = "DS" Or InpCode = "SD" Then Call DSFLSHdll(d, s, x(1), t, p, Dl, Dv, xliq(1), xvap(1), q, e, h, Cvcalc, Cpcalc, w, ierr, herr, 255&) ElseIf InpCode = "DE" Or InpCode = "ED" Then Call DEFLSHdll(d, e, x(1), t, p, Dl, Dv, xliq(1), xvap(1), q, h, s, Cvcalc, Cpcalc, w, ierr, herr, 255&) ElseIf InpCode = "HS" Or InpCode = "SH" Then Call HSFLSHdll(h, s, x(1), t, p, d, Dl, Dv, xliq(1), xvap(1), q, e, Cvcalc, Cpcalc, w, ierr, herr, 255&) ElseIf InpCode = "TMELT" Then Call MELTTdll(t, x(1), p, ierr, herr, 255&) If ierr = 0 Then Call TPFLSHdll(t, p, x(1), d, Dl, Dv, xliq(1), xvap(1), q, e, h, s, Cvcalc, Cpcalc, w, ierr, herr, 255&) ElseIf InpCode = "PMELT" Then If p = 0 Then ierr = 1: herr = Trim2("Input pressure is zero"): Exit Sub Call MELTPdll(p, x(1), t, ierr, herr, 255&) If ierr = 0 Then Call TPFLSHdll(t, p, x(1), d, Dl, Dv, xliq(1), xvap(1), q, e, h, s, Cvcalc, Cpcalc, w, ierr, herr, 255&) ElseIf InpCode = "TSUBL" Then Call SUBLTdll(t, x(1), p, ierr, herr, 255&) If ierr = 0 And p = 0 Then ierr = 1: herr = Trim2("No sublimation line available") If ierr = 0 Then q = 1 d = p / 8.314472 / t Call TPRHOdll(t, p, x(1), 2&, 1&, d, ierr, herr, 255&) Call THERMdll(t, d, x(1), pp, e, h, s, Cvcalc, Cpcalc, w, hjt) End If ElseIf InpCode = "PSUBL" Then If p = 0 Then ierr = 1: herr = Trim2("Input pressure is zero"): Exit Sub Call SUBLPdll(p, x(1), t, ierr, herr, 255&) If ierr = 0 And t = 0 Then ierr = 1: herr = Trim2("No sublimation line available") If ierr = 0 Then q = 1 d = p / 8.314472 / t Call TPRHOdll(t, p, x(1), 2&, 1&, d, ierr, herr, 255&) Call THERMdll(t, d, x(1), pp, e, h, s, Cvcalc, Cpcalc, w, hjt) End If Else ierr = 1: herr = Trim2("Invalid input code") End If 'This line has been removed because there are valid q's less than 0.000001, is it still needed? 'If (q <= 0.000001 Or q >= 0.999999) And Cvcalc = -9999980 Then Call THERMdll(t, d, x(1), pp, e, h, s, Cvcalc, Cpcalc, w, hjt) Exit Sub Error1: ierr = 1: herr = Trim2("First property missing"): Exit Sub Error2: ierr = 1: herr = Trim2("Second property missing"): Exit Sub End Sub Function Temperature(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) Temperature = ConvertUnits("-T", Units, t, 0) End Function Function Pressure(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) Pressure = ConvertUnits("-P", Units, p, 0) End Function Function Density(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) Density = ConvertUnits("-D", Units, d, 0) End Function Function CompressibilityFactor(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) Call INFOdll(1, wmm, ttrp, tnbpt, tc, pc, dc, Zc, acf, dip, Rgas) If ierr > 0 Then CompressibilityFactor = Trim2(herr): Exit Function CompressibilityFactor = p / d / t / Rgas End Function Function LiquidDensity(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) If ierr > 0 Then LiquidDensity = Trim2(herr): Exit Function If q < 0 Or q > 1 Then LiquidDensity = Trim2("Inputs are single phase") Else CompFlag = 1 LiquidDensity = ConvertUnits("-D", Units, Dl, 0) CompFlag = 0 End If End Function Function VaporDensity(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) If ierr > 0 Then VaporDensity = Trim2(herr): Exit Function If q < 0 Or q > 1 Then VaporDensity = Trim2("Inputs are single phase") Else CompFlag = 2 VaporDensity = ConvertUnits("-D", Units, Dv, 0) CompFlag = 0 End If End Function Function LiquidEnthalpy(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) If ierr > 0 Then LiquidEnthalpy = Trim2(herr): Exit Function If q < 0 Or q > 1 Then 'LiquidEnthalpy = Trim2("Inputs are single phase") Call THERMdll(t, d, x(1), p, e, h, s, Cvcalc, Cpcalc, w, hjt) LiquidEnthalpy = ConvertUnits("-H", Units, h, 0) Else Call THERMdll(t, Dl, xliq(1), p, e, h, s, Cvcalc, Cpcalc, w, hjt) CompFlag = 1 LiquidEnthalpy = ConvertUnits("-H", Units, h, 0) CompFlag = 0 End If End Function Function VaporEnthalpy(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) If ierr > 0 Then VaporEnthalpy = Trim2(herr): Exit Function If q < 0 Or q > 1 Then 'VaporEnthalpy = Trim2("Inputs are single phase") Call THERMdll(t, d, x(1), p, e, h, s, Cvcalc, Cpcalc, w, hjt) VaporEnthalpy = ConvertUnits("-H", Units, h, 0) Else Call THERMdll(t, Dv, xvap(1), p, e, h, s, Cvcalc, Cpcalc, w, hjt) CompFlag = 2 VaporEnthalpy = ConvertUnits("-H", Units, h, 0) CompFlag = 0 End If End Function Function LiquidEntropy(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) If ierr > 0 Then LiquidEntropy = Trim2(herr): Exit Function If q < 0 Or q > 1 Then 'LiquidEntropy = Trim2("Inputs are single phase") Call THERMdll(t, d, x(1), p, e, h, s, Cvcalc, Cpcalc, w, hjt) LiquidEntropy = ConvertUnits("-S", Units, s, 0) Else Call THERMdll(t, Dl, xliq(1), p, e, h, s, Cvcalc, Cpcalc, w, hjt) CompFlag = 1 LiquidEntropy = ConvertUnits("-S", Units, s, 0) CompFlag = 0 End If End Function Function VaporEntropy(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) If ierr > 0 Then VaporEntropy = Trim2(herr): Exit Function If q < 0 Or q > 1 Then 'VaporEntropy = Trim2("Inputs are single phase") Call THERMdll(t, d, x(1), p, e, h, s, Cvcalc, Cpcalc, w, hjt) VaporEntropy = ConvertUnits("-S", Units, s, 0) Else Call THERMdll(t, Dv, xvap(1), p, e, h, s, Cvcalc, Cpcalc, w, hjt) CompFlag = 2 VaporEntropy = ConvertUnits("-S", Units, s, 0) CompFlag = 0 End If End Function Function LiquidCp(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) If ierr > 0 Then LiquidCp = Trim2(herr): Exit Function If q < 0 Or q > 1 Then Call THERMdll(t, d, x(1), p, e, h, s, Cvcalc, Cpcalc, w, hjt) LiquidCp = ConvertUnits("-S", Units, Cpcalc, 0) Else Call THERMdll(t, Dl, xliq(1), p, e, h, s, Cvcalc, Cpcalc, w, hjt) CompFlag = 1 LiquidCp = ConvertUnits("-S", Units, Cpcalc, 0) CompFlag = 0 End If End Function Function VaporCp(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) If ierr > 0 Then VaporCp = Trim2(herr): Exit Function If q < 0 Or q > 1 Then Call THERMdll(t, d, x(1), p, e, h, s, Cvcalc, Cpcalc, w, hjt) VaporCp = ConvertUnits("-S", Units, Cpcalc, 0) Else Call THERMdll(t, Dv, xvap(1), p, e, h, s, Cvcalc, Cpcalc, w, hjt) CompFlag = 2 VaporCp = ConvertUnits("-S", Units, Cpcalc, 0) CompFlag = 0 End If End Function Function Volume(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Dim v As Double Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) Volume = 0 If d <= 0 Then Volume = Trim2("Density is zero"): Exit Function v = 1 / d Volume = ConvertUnits("-V", Units, v, 0) End Function Function Energy(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) Energy = ConvertUnits("-H", Units, e, 0) End Function Function Enthalpy(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) Enthalpy = ConvertUnits("-H", Units, h, 0) End Function Function Entropy(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) Entropy = ConvertUnits("-S", Units, s, 0) End Function Function IsochoricHeatCapacity(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) IsochoricHeatCapacity = ConvertUnits("-S", Units, Cvcalc, 0) End Function Function Cv(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) Cv = ConvertUnits("-S", Units, Cvcalc, 0) End Function Function IsobaricHeatCapacity(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) IsobaricHeatCapacity = ConvertUnits("-S", Units, Cpcalc, 0) End Function Function Cp(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) Cp = ConvertUnits("-S", Units, Cpcalc, 0) End Function Function Csat(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) If nc <> 1 Then Csat = "Csat can only be called for a pure fluid": Exit Function Call CSATKdll(1, t, 1, p, d, Csat, ierr, herr, 255&) Csat = ConvertUnits("-S", Units, Csat, 0) End Function Function SpeedOfSound(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) SpeedOfSound = ConvertUnits("-W", Units, w, 0) End Function Function Sound(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) Sound = ConvertUnits("-W", Units, w, 0) End Function Function LatentHeat(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Dim hl As Double, hv As Double InpCode = Trim(UCase(InpCode)) If Left(InpCode, 1) = "T" Then Call CalcSetup(FluidName, "T", Units, Prop1, Prop2) If ierr > 0 Then LatentHeat = Trim2(herr): Exit Function If nc <> 1 Then LatentHeat = Trim2("Can only be calculated for pure fluids"): Exit Function Call INFOdll(1, wmm, ttrp, tnbpt, tc, pc, dc, Zc, acf, dip, Rgas) t = Prop1 If t <= 0 Then LatentHeat = Trim2("Input temperature is zero"): Exit Function If t > tc Then LatentHeat = Trim2("Temperature is greater than the critical point temperture"): Exit Function Call SATTdll(t, x(1), 1&, p, Dl, Dv, xliq(1), xvap(1), ierr, herr, 255&) If (p = 0 Or Dl = 0) And ierr = 0 Then ierr = 1: LatentHeat = Trim2("Inputs are out of range"): Exit Function ElseIf Left(InpCode, 1) = "P" Then Call CalcSetup(FluidName, "P", Units, Prop1, Prop2) If ierr > 0 Then LatentHeat = Trim2(herr): Exit Function If nc <> 1 Then LatentHeat = Trim2("Can only be calculated for pure fluids"): Exit Function Call INFOdll(1, wmm, ttrp, tnbpt, tc, pc, dc, Zc, acf, dip, Rgas) p = Prop1 If p <= 0 Then LatentHeat = Trim2("Input pressure is zero"): Exit Function If p > pc Then LatentHeat = Trim2("Pressure is greater than the critical point pressure"): Exit Function Call SATPdll(p, x(1), 1&, t, Dl, Dv, xliq(1), xvap(1), ierr, herr, 255&) If (t = 0 Or Dl = 0) And ierr = 0 Then ierr = 1: LatentHeat = Trim2("Inputs are out of range"): Exit Function Else LatentHeat = Trim2("Valid inputs are only 'T' or 'P'"): Exit Function End If If ierr > 0 Then LatentHeat = Trim2(herr): Exit Function Call THERMdll(t, Dl, x(1), p, e, hl, s, Cvcalc, Cpcalc, w, hjt) Call THERMdll(t, Dv, x(1), p, e, hv, s, Cvcalc, Cpcalc, w, hjt) LatentHeat = ConvertUnits("-H", Units, hv - hl, 0) End Function Function HeatOfVaporization(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) HeatOfVaporization = LatentHeat(FluidName, InpCode, Units, Prop1, Prop2) End Function Function HeatOfCombustion(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Dim hg As Double, hn As Double Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) Call HEATdll(t, d, x(1), hg, hn, ierr, herr, 255&) HeatOfCombustion = ConvertUnits("-H", Units, hg, 0) End Function Function GrossHeatingValue(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Dim hg As Double, hn As Double Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) Call HEATdll(t, d, x(1), hg, hn, ierr, herr, 255&) GrossHeatingValue = ConvertUnits("-H", Units, hg, 0) End Function Function NetHeatingValue(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Dim hg As Double, hn As Double Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) Call HEATdll(t, d, x(1), hg, hn, ierr, herr, 255&) NetHeatingValue = ConvertUnits("-H", Units, hn, 0) End Function Function JouleThomson(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) Call THERMdll(t, d, x(1), p, e, h, s, Cvcalc, Cpcalc, w, hjt) JouleThomson = ConvertUnits("-J", Units, hjt, 0) End Function Function IsentropicExpansionCoef(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) Call THERM3dll(t, d, x(1), xkappa, beta, isenk, kt, betas, bs, kkt, thrott, xpi, spht) If ierr > 0 Then IsentropicExpansionCoef = Trim2(herr): Exit Function IsentropicExpansionCoef = isenk End Function Function IsothermalCompressibility(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) Call THERM2dll(t, d, x(1), p, e, h, s, Cvcalc, Cpcalc, w, z, hjt, aHelm, Gibbs, xkappa, beta, dPdD_T, d2PdD2_rho, dPdT_rho, dDdT_P, dDdP_rho, d2PT2, d2PdTD, spare3, spare4) If ierr > 0 Then IsothermalCompressibility = Trim2(herr): Exit Function IsothermalCompressibility = Trim2("Infinite") If d > 1E-20 And Not (xkappa = -9999990 Or xkappa > 1E+15) Then IsothermalCompressibility = 1 / ConvertUnits("-P", Units, 1 / xkappa, 0) End Function Function VolumeExpansivity(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) Call THERM2dll(t, d, x(1), p, e, h, s, Cvcalc, Cpcalc, w, z, hjt, aHelm, Gibbs, xkappa, beta, dPdD_T, d2PdD2_rho, dPdT_rho, dDdT_P, dDdP_rho, d2PT2, d2PdTD, spare3, spare4) If ierr > 0 Then VolumeExpansivity = Trim2(herr): Exit Function VolumeExpansivity = 1 / ConvertUnits("-A", Units, 1 / beta, 0) End Function Function AdiabaticCompressibility(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) Call THERM3dll(t, d, x(1), xkappa, beta, isenk, kt, betas, bs, kkt, thrott, xpi, spht) If ierr > 0 Then AdiabaticCompressibility = Trim2(herr): Exit Function AdiabaticCompressibility = Trim2("Infinite") If d > 1E-20 Then AdiabaticCompressibility = 1 / ConvertUnits("-P", Units, 1 / betas, 0) End Function Function AdiabaticBulkModulus(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) Call THERM3dll(t, d, x(1), xkappa, beta, isenk, kt, betas, bs, kkt, thrott, xpi, spht) AdiabaticBulkModulus = ConvertUnits("-P", Units, bs, 0) End Function Function IsothermalExpansionCoef(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) Call THERM3dll(t, d, x(1), xkappa, beta, isenk, kt, betas, bs, kkt, thrott, xpi, spht) If ierr > 0 Then IsothermalExpansionCoef = Trim2(herr): Exit Function IsothermalExpansionCoef = kt End Function Function IsothermalBulkModulus(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) Call THERM3dll(t, d, x(1), xkappa, beta, isenk, kt, betas, bs, kkt, thrott, xpi, spht) IsothermalBulkModulus = ConvertUnits("-P", Units, kkt, 0) End Function Function SpecificHeatInput(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) Call THERM3dll(t, d, x(1), xkappa, beta, isenk, kt, betas, bs, kkt, thrott, xpi, spht) SpecificHeatInput = ConvertUnits("-H", Units, spht, 0) End Function Function SecondVirial(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Dim b As Double Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) Call VIRBdll(t, x(1), b) SecondVirial = ConvertUnits("-V", Units, b, 0) End Function Function dPdrho(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) Call THERM2dll(t, d, x(1), p, e, h, s, Cvcalc, Cpcalc, w, z, hjt, aHelm, Gibbs, xkappa, beta, dPdD_T, d2PdD2_rho, dPdT_rho, dDdT_P, dDdP_rho, d2PT2, d2PdTD, spare3, spare4) If ierr > 0 Then dPdrho = Trim2(herr): Exit Function dPdrho = ConvertUnits("-P", Units, 1 / ConvertUnits("-D", Units, 1 / dPdD_T, 0), 0) End Function Function d2Pdrho2(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) Call THERM2dll(t, d, x(1), p, e, h, s, Cvcalc, Cpcalc, w, z, hjt, aHelm, Gibbs, xkappa, beta, dPdD_T, d2PdD2_rho, dPdT_rho, dDdT_P, dDdP_rho, d2PT2, d2PdTD, spare3, spare4) If ierr > 0 Then d2Pdrho2 = Trim2(herr): Exit Function d2Pdrho2 = ConvertUnits("-P", Units, 1 / ConvertUnits("-D", Units, ConvertUnits("-D", Units, 1 / d2PdD2_rho, 0), 0), 0) End Function Function dPdT(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) Call THERM2dll(t, d, x(1), p, e, h, s, Cvcalc, Cpcalc, w, z, hjt, aHelm, Gibbs, xkappa, beta, dPdD_T, d2PdD2_rho, dPdT_rho, dDdT_P, dDdP_rho, d2PT2, d2PdTD, spare3, spare4) If ierr > 0 Then dPdT = Trim2(herr): Exit Function dPdT = 0 If dPdT_rho <> 0 Then dPdT = ConvertUnits("-P", Units, 1 / ConvertUnits("-A", Units, 1 / dPdT_rho, 0), 0) End Function Function dPdTsat(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Dim Cst As Double, dPT As Double Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) If nc <> 1 Then dPdTsat = "Functions work only for pure fluids" If ierr > 0 Then dPdTsat = Trim2(herr): Exit Function Call DPTSATKdll(1, t, 1&, p, d, Cst, dPT, ierr, herr, 255&) If ierr > 0 Then dPdTsat = Trim2(herr): Exit Function If dPT = 0 Or ierr > 0 Then dPdTsat = herr: Exit Function dPdTsat = ConvertUnits("-P", Units, 1 / ConvertUnits("-A", Units, 1 / dPT, 0), 0) End Function Function dHdT_D(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Dim dHdT_Dcalc As Double, dHdT_Pcalc As Double, dHdD_Tcalc As Double, dHdD_Pcalc As Double, dHdP_Tcalc As Double, dHdP_Dcalc As Double Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) Call DHD1dll(t, d, x(1), dHdT_Dcalc, dHdT_Pcalc, dHdD_Tcalc, dHdD_Pcalc, dHdP_Tcalc, dHdP_Dcalc) dHdT_D = ConvertUnits("-S", Units, dHdT_Dcalc, 0) End Function Function dHdT_P(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Dim dHdT_Dcalc As Double, dHdT_Pcalc As Double, dHdD_Tcalc As Double, dHdD_Pcalc As Double, dHdP_Tcalc As Double, dHdP_Dcalc As Double Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) Call DHD1dll(t, d, x(1), dHdT_Dcalc, dHdT_Pcalc, dHdD_Tcalc, dHdD_Pcalc, dHdP_Tcalc, dHdP_Dcalc) dHdT_P = ConvertUnits("-S", Units, dHdT_Pcalc, 0) End Function Function dHdD_T(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Dim dHdT_Dcalc As Double, dHdT_Pcalc As Double, dHdD_Tcalc As Double, dHdD_Pcalc As Double, dHdP_Tcalc As Double, dHdP_Dcalc As Double Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) Call DHD1dll(t, d, x(1), dHdT_Dcalc, dHdT_Pcalc, dHdD_Tcalc, dHdD_Pcalc, dHdP_Tcalc, dHdP_Dcalc) If ierr > 0 Then dHdD_T = Trim2(herr): Exit Function dHdD_T = ConvertUnits("-H", Units, 1 / ConvertUnits("-D", Units, 1 / dHdD_Tcalc, 0), 0) End Function Function dHdD_P(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Dim dHdT_Dcalc As Double, dHdT_Pcalc As Double, dHdD_Tcalc As Double, dHdD_Pcalc As Double, dHdP_Tcalc As Double, dHdP_Dcalc As Double Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) Call DHD1dll(t, d, x(1), dHdT_Dcalc, dHdT_Pcalc, dHdD_Tcalc, dHdD_Pcalc, dHdP_Tcalc, dHdP_Dcalc) If ierr > 0 Then dHdD_P = Trim2(herr): Exit Function dHdD_P = ConvertUnits("-H", Units, 1 / ConvertUnits("-D", Units, 1 / dHdD_Pcalc, 0), 0) End Function Function dHdP_T(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Dim dHdT_Dcalc As Double, dHdT_Pcalc As Double, dHdD_Tcalc As Double, dHdD_Pcalc As Double, dHdP_Tcalc As Double, dHdP_Dcalc As Double Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) Call DHD1dll(t, d, x(1), dHdT_Dcalc, dHdT_Pcalc, dHdD_Tcalc, dHdD_Pcalc, dHdP_Tcalc, dHdP_Dcalc) If ierr > 0 Then dHdP_T = Trim2(herr): Exit Function dHdP_T = ConvertUnits("-H", Units, 1 / ConvertUnits("-P", Units, 1 / dHdP_Tcalc, 0), 0) End Function Function dHdP_D(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Dim dHdT_Dcalc As Double, dHdT_Pcalc As Double, dHdD_Tcalc As Double, dHdD_Pcalc As Double, dHdP_Tcalc As Double, dHdP_Dcalc As Double Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) Call DHD1dll(t, d, x(1), dHdT_Dcalc, dHdT_Pcalc, dHdD_Tcalc, dHdD_Pcalc, dHdP_Tcalc, dHdP_Dcalc) If ierr > 0 Then dHdP_D = Trim2(herr): Exit Function dHdP_D = ConvertUnits("-H", Units, 1 / ConvertUnits("-P", Units, 1 / dHdP_Dcalc, 0), 0) End Function Function drhodT(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) Call THERM2dll(t, d, x(1), p, e, h, s, Cvcalc, Cpcalc, w, z, hjt, aHelm, Gibbs, xkappa, beta, dPdD_T, d2PdD2_rho, dPdT_rho, dDdT_P, dDdP_rho, d2PT2, d2PdTD, spare3, spare4) If ierr > 0 Then drhodT = Trim2(herr): Exit Function drhodT = 0 If dDdT_P <> 0 Then drhodT = ConvertUnits("-D", Units, 1 / ConvertUnits("-A", Units, 1 / dDdT_P, 0), 0) End Function Function Cstar(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Dim v As Double, cs As Double, ts As Double, Ds As Double, ps As Double, ws As Double Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) v = 0 On Error GoTo ErrorHandler: Call CSTARdll(t, p, v, x(1), cs, ts, Ds, ps, ws, ierr, herr, 255&) If ierr > 0 Then Cstar = Trim2(herr): Exit Function Cstar = cs Return ErrorHandler: 'Call CCRITdll(t, p, v, x(1), cs, ts, Ds, ps, ws, ierr, herr, 255&) 'Old format Cstar = cs End Function Function Quality(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Dim xlkg(1 To MaxComps) As Double, xvkg(1 To MaxComps) As Double, qkg As Double, wliq As Double, wvap As Double Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) If ierr > 0 Then Quality = Trim2(herr): Exit Function Quality = q If q = 990 Then Quality = Trim2("Not calculated") If q = 998 Or q > 1 Then Quality = Trim2("Superheated vapor") If q = 999 Then Quality = Trim2("Supercritical state (T>Tc, p>pc)") If q < 0 Then Quality = Trim2("Subcooled liquid") If q = -998 Then Quality = Trim2("Subcooled liquid with p>pc") If q > 0 And q < 1 And molmass = 2 Then Call QMASSdll(q, xliq(1), xvap(1), qkg, xlkg(1), xvkg(1), wliq, wvap, ierr, herr, 255&) Quality = qkg End If End Function Function QualityMole(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Dim xlkg(1 To MaxComps) As Double, xvkg(1 To MaxComps) As Double, qkg As Double, wliq As Double, wvap As Double QualityMole = Quality(FluidName, InpCode, Units, Prop1, Prop2) If ierr > 0 Then Exit Function If q > 0 And q < 1 Then QualityMole = q End Function Function QualityMass(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Dim xlkg(1 To MaxComps) As Double, xvkg(1 To MaxComps) As Double, qkg As Double, wliq As Double, wvap As Double QualityMass = Quality(FluidName, InpCode, Units, Prop1, Prop2) If ierr > 0 Then Exit Function If q > 0 And q < 1 Then Call QMASSdll(q, xliq(1), xvap(1), qkg, xlkg(1), xvkg(1), wliq, wvap, ierr, herr, 255&) QualityMass = qkg End If End Function Function LiquidMoleFraction(FluidName, Optional InpCode, Optional Units, Optional Prop1, Optional Prop2, Optional i) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) If ierr > 0 Then LiquidMoleFraction = Trim2(herr): Exit Function If IsMissing(i) Then LiquidMoleFraction = Trim2("Component number is missing"): Exit Function If i < 1 Or i > nc Then LiquidMoleFraction = Trim2("Constituent number out of range"): Exit Function If q < 0 Or q > 1 Then LiquidMoleFraction = x(i) Else LiquidMoleFraction = xliq(i) End If If nc = 1 Then LiquidMoleFraction = Trim2("Not applicable for a pure fluid") End Function Function VaporMoleFraction(FluidName, Optional InpCode, Optional Units, Optional Prop1, Optional Prop2, Optional i) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) If ierr > 0 Then VaporMoleFraction = Trim2(herr): Exit Function If IsMissing(i) Then VaporMoleFraction = Trim2("Component number is missing"): Exit Function If i < 1 Or i > nc Then VaporMoleFraction = Trim2("Constituent number out of range"): Exit Function If q < 0 Or q > 1 Then VaporMoleFraction = x(i) Else VaporMoleFraction = xvap(i) End If If nc = 1 Then VaporMoleFraction = Trim2("Not applicable for a pure fluid") End Function Function LiquidMassFraction(FluidName, Optional InpCode, Optional Units, Optional Prop1, Optional Prop2, Optional i) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) If ierr > 0 Then LiquidMassFraction = Trim2(herr): Exit Function If IsMissing(i) Then LiquidMassFraction = Trim2("Component number is missing"): Exit Function If i < 1 Or i > nc Then LiquidMassFraction = Trim2("Constituent number out of range"): Exit Function If q < 0 Or q > 1 Then Call XMASSdll(x(1), xmm(1), wm) LiquidMassFraction = xmm(i) Else Call XMASSdll(xliq(1), xmm(1), wm) LiquidMassFraction = xmm(i) End If If nc = 1 Then LiquidMassFraction = Trim2("Not applicable for a pure fluid") End Function Function VaporMassFraction(FluidName, Optional InpCode, Optional Units, Optional Prop1, Optional Prop2, Optional i) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) If ierr > 0 Then VaporMassFraction = Trim2(herr): Exit Function If IsMissing(i) Then VaporMassFraction = Trim2("Component number is missing"): Exit Function If i < 1 Or i > nc Then VaporMassFraction = Trim2("Constituent number out of range"): Exit Function If q < 0 Or q > 1 Then Call XMASSdll(x(1), xmm(1), wm) VaporMassFraction = xmm(i) Else Call XMASSdll(xvap(1), xmm(1), wm) VaporMassFraction = xmm(i) End If If nc = 1 Then VaporMassFraction = Trim2("Not applicable for a pure fluid") End Function Function Fugacity(FluidName, Optional InpCode, Optional Units, Optional Prop1, Optional Prop2, Optional i) Dim f(MaxComps) As Double Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) If ierr > 0 Then Fugacity = Trim2(herr): Exit Function If IsMissing(i) Then Fugacity = Trim2("Component number is missing "): Exit Function If i < 1 Or i > nc Then Fugacity = Trim2("Constituent number out of Range "): Exit Function Call FGCTYdll(t, d, x(1), f(1)) Fugacity = ConvertUnits("-P", Units, f(i), 0) End Function Function FugacityCoefficient(FluidName, Optional InpCode, Optional Units, Optional Prop1, Optional Prop2, Optional i) Dim f(MaxComps) As Double Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) If ierr > 0 Then FugacityCoefficient = Trim2(herr): Exit Function If IsMissing(i) Then FugacityCoefficient = Trim2("Component number is missing "): Exit Function If i < 1 Or i > nc Then FugacityCoefficient = Trim2("Constituent number out of Range "): Exit Function Call FUGCOFdll(t, d, x(1), f(1), ierr, herr, 255&) If ierr > 0 Then FugacityCoefficient = Trim2(herr): Exit Function FugacityCoefficient = f(i) End Function Function ChemicalPotential(FluidName, Optional InpCode, Optional Units, Optional Prop1, Optional Prop2, Optional i) Dim f(MaxComps) As Double Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) If ierr > 0 Then ChemicalPotential = Trim2(herr): Exit Function If IsMissing(i) Then ChemicalPotential = Trim2("Component number is missing "): Exit Function If i < 1 Or i > nc Then ChemicalPotential = Trim2("Constituent number out of Range "): Exit Function Call CHEMPOTdll(t, d, x(1), f(1), ierr, herr, 255&) If ierr > 0 Then ChemicalPotential = Trim2(herr): Exit Function ChemicalPotential = ConvertUnits("-H", Units, f(i), 0) End Function Function Activity(FluidName, Optional InpCode, Optional Units, Optional Prop1, Optional Prop2, Optional i) Dim f(MaxComps) As Double, gamma(MaxComps) As Double Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) If ierr > 0 Then Activity = Trim2(herr): Exit Function If IsMissing(i) Then Activity = Trim2("Component number is missing "): Exit Function If i < 1 Or i > nc Then Activity = Trim2("Constituent number out of Range "): Exit Function Call ACTVYdll(t, d, x(1), f(1), gamma(1), ierr, herr, 255&) If ierr > 0 Then Activity = Trim2(herr): Exit Function Activity = f(i) End Function Function ActivityCoefficient(FluidName, Optional InpCode, Optional Units, Optional Prop1, Optional Prop2, Optional i) Dim f(MaxComps) As Double, gamma(MaxComps) As Double Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) If ierr > 0 Then ActivityCoefficient = Trim2(herr): Exit Function If IsMissing(i) Then ActivityCoefficient = Trim2("Component number is missing "): Exit Function If i < 1 Or i > nc Then ActivityCoefficient = Trim2("Constituent number out of Range "): Exit Function Call ACTVYdll(t, d, x(1), f(1), gamma(1), ierr, herr, 255&) If ierr > 0 Then ActivityCoefficient = Trim2(herr): Exit Function ActivityCoefficient = gamma(i) End Function Function Viscosity(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) If ierr > 0 Then Viscosity = Trim2(herr): Exit Function If t = 0 Or d = 0 Then Viscosity = Trim2("Inputs out of range"): Exit Function Call TRNPRPdll(t, d, x(1), eta, tcx, ierr2, herr2, 255&) If q > 0 And q < 1 Then eta = -9999999 Viscosity = ConvertUnits("-U", Units, eta, 0) If eta = 0 Then Viscosity = Trim2("Unable to calculate property") End Function Function ThermalConductivity(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) If ierr > 0 Then ThermalConductivity = Trim2(herr): Exit Function If t = 0 Or d = 0 Then ThermalConductivity = Trim2("Inputs out of range"): Exit Function Call TRNPRPdll(t, d, x(1), eta, tcx, ierr2, herr2, 255&) If q > 0 And q < 1 Then tcx = -9999999 ThermalConductivity = ConvertUnits("-K", Units, tcx, 0) If tcx = 0 Then ThermalConductivity = Trim2("Unable to calculate property") End Function Function KinematicViscosity(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) If ierr > 0 Then KinematicViscosity = Trim2(herr): Exit Function If t = 0 Or d = 0 Then KinematicViscosity = Trim2("Inputs out of range"): Exit Function Call TRNPRPdll(t, d, x(1), eta, tcx, ierr2, herr2, 255&) If eta = 0 Then KinematicViscosity = Trim2("Unable to calculate property"): Exit Function If q > 0 And q < 1 Then eta = -9999999 Else eta = eta / d / wm / 100 'cm^2/s End If KinematicViscosity = ConvertUnits("-I", Units, eta, 0) End Function Function ThermalDiffusivity(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) If ierr > 0 Then ThermalDiffusivity = Trim2(herr): Exit Function If t = 0 Or d = 0 Then ThermalDiffusivity = Trim2("Inputs out of range"): Exit Function Call TRNPRPdll(t, d, x(1), eta, tcx, ierr2, herr2, 255&) If tcx = 0 Then ThermalDiffusivity = Trim2("Unable to calculate property"): Exit Function If q > 0 And q < 1 Then tcx = -9999999 Else Call THERMdll(t, d, x(1), p, e, h, s, Cvcalc, Cpcalc, w, hjt) tcx = tcx / d / Cpcalc * 10 'cm^2/s End If ThermalDiffusivity = ConvertUnits("-I", Units, tcx, 0) End Function Function Prandtl(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) If ierr > 0 Then Prandtl = Trim2(herr): Exit Function If t = 0 Or d = 0 Then Prandtl = Trim2("Inputs out of range"): Exit Function Call TRNPRPdll(t, d, x(1), eta, tcx, ierr2, herr2, 255&) If q > 0 And q < 1 Then Prandtl = Trim2("Undefined"): Exit Function If tcx = 0 Or eta = 0 Then Prandtl = Trim2("Unable to calculate property") Call THERMdll(t, d, x(1), p, e, h, s, Cvcalc, Cpcalc, w, hjt) Call WMOLdll(x(1), wm) Prandtl = eta * Cpcalc / tcx / wm / 1000 End Function Function SurfaceTension(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) If ierr > 0 Then SurfaceTension = Trim2(herr): Exit Function If t = 0 Then SurfaceTension = Trim2("Input temperature is zero"): Exit Function If q >= 0 And q <= 1 Then Call SURFTdll(t, Dl, xliq(1), sigma, ierr2, herr2, 255&) Else Call SURFTdll(t, d, x(1), sigma, ierr2, herr2, 255&) End If SurfaceTension = ConvertUnits("-N", Units, sigma, 0) If sigma = 0 Or ierr2 > 0 Then SurfaceTension = Trim2("Inputs out of range") End Function Function DielectricConstant(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) If ierr > 0 Then DielectricConstant = Trim2(herr): Exit Function If q > 0 And q < 1 Then DielectricConstant = Trim2("Undefined"): Exit Function If t = 0 Then DielectricConstant = Trim2("Inputs out of range"): Exit Function Call DIELECdll(t, d, x(1), de) DielectricConstant = de End Function Function MolarMass(FluidName, Optional InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcSetup(FluidName, "", Units, Prop1, Prop2) If ierr > 0 Then MolarMass = Trim2(herr): Exit Function Call WMOLdll(x(1), wm) MolarMass = wm End Function Function MoleFraction(FluidName, i) Call CalcProp(FluidName, "", "", 0, 0) If ierr > 0 Then MoleFraction = Trim2(herr): Exit Function If IsMissing(i) Then MoleFraction = Trim2("Component number is missing"): Exit Function If i < 1 Or i > nc Then MoleFraction = Trim2("Constituent number out of range"): Exit Function MoleFraction = x(i) If nc = 1 Then MoleFraction = Trim2("Not applicable for a pure fluid") End Function Function MassFraction(FluidName, i) Call CalcProp(FluidName, "", "", 0, 0) If ierr > 0 Then MassFraction = Trim2(herr): Exit Function If IsMissing(i) Then MassFraction = Trim2("Component number is missing"): Exit Function If i < 1 Or i > nc Then MassFraction = Trim2("Constituent number out of range"): Exit Function Call XMASSdll(x(1), xmm(1), wm) MassFraction = xmm(i) If nc = 1 Then MassFraction = Trim2("Not applicable for a pure fluid") End Function Function ComponentName(FluidName, i) Dim a As String, j As Integer, k As Integer Call CalcProp(FluidName, "", "", 0, 0) If ierr > 0 Then ComponentName = Trim2(herr): Exit Function If IsMissing(i) Then ComponentName = Trim2("Component number is missing"): Exit Function If i < 1 Or i > nc Then ComponentName = Trim2("Constituent number out of range"): Exit Function a = hfld If nc > 1 Then For k = 1 To i - 1 j = InStr(a, "|") If j Then a = Mid(a, j + 1) Next j = InStr(a, "|") If j Then a = Left(a, j - 1) End If Do j = InStr(a, "\") If j Then a = Mid(a, j + 1) Loop While j <> 0 j = InStr(a, ".") If j Then a = Left(a, j - 1) ComponentName = a End Function Function LiquidFluidString(FluidName, Optional InpCode, Optional Units, Optional Prop1, Optional Prop2) Dim a As String, i As Integer Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) If ierr > 0 Then LiquidFluidString = Trim2(herr): Exit Function For i = 1 To nc a = a + ";" + ComponentName(FluidName, i) If q < 0 Or q > 1 Then a = a + ";" + Trim(Str(x(i))) Else a = a + ";" + Trim(Str(xliq(i))) End If Next LiquidFluidString = Mid(a, 2) If nc = 1 Then LiquidFluidString = ComponentName(FluidName, i) End Function Function VaporFluidString(FluidName, Optional InpCode, Optional Units, Optional Prop1, Optional Prop2) Dim a As String, i As Integer Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) If ierr > 0 Then VaporFluidString = Trim2(herr): Exit Function For i = 1 To nc a = a + ";" + ComponentName(FluidName, i) If q < 0 Or q > 1 Then a = a + ";" + Trim(Str(x(i))) Else a = a + ";" + Trim(Str(xvap(i))) End If Next VaporFluidString = Mid(a, 2) If nc = 1 Then VaporFluidString = ComponentName(FluidName, i) End Function 'Change molar composition to mass composition 'Prop1 - Prop20 are the molar values for the components in the mixture. 'i specifies which component's mole fraction is returned. If zero, the molar mass is returned Function Mole2Mass(FluidName, i, Prop1, Prop2, Optional Prop3, Optional Prop4, Optional Prop5, Optional Prop6, Optional Prop7, Optional Prop8, Optional Prop9, Optional Prop10, Optional Prop11, Optional Prop12, Optional Prop13, Optional Prop14, Optional Prop15, Optional Prop16, Optional Prop17, Optional Prop18, Optional Prop19, Optional Prop20) Dim j As Integer, xkg2(1 To MaxComps) As Double, xmol2(1 To MaxComps) As Double, wmix2 As Double, sum As Double For j = 1 To MaxComps: xmol2(j) = 0: Next xmol2(1) = Prop1 xmol2(2) = Prop2 If IsMissing(Prop3) = False And IsNumeric(Prop3) = True Then xmol2(3) = Prop3 If IsMissing(Prop4) = False And IsNumeric(Prop4) = True Then xmol2(4) = Prop4 If IsMissing(Prop5) = False And IsNumeric(Prop5) = True Then xmol2(5) = Prop5 If IsMissing(Prop6) = False And IsNumeric(Prop6) = True Then xmol2(6) = Prop6 If IsMissing(Prop7) = False And IsNumeric(Prop7) = True Then xmol2(7) = Prop7 If IsMissing(Prop8) = False And IsNumeric(Prop8) = True Then xmol2(8) = Prop8 If IsMissing(Prop9) = False And IsNumeric(Prop9) = True Then xmol2(9) = Prop9 If IsMissing(Prop10) = False And IsNumeric(Prop10) = True Then xmol2(10) = Prop10 If IsMissing(Prop11) = False And IsNumeric(Prop11) = True Then xmol2(11) = Prop11 If IsMissing(Prop12) = False And IsNumeric(Prop12) = True Then xmol2(12) = Prop12 If IsMissing(Prop13) = False And IsNumeric(Prop13) = True Then xmol2(13) = Prop13 If IsMissing(Prop14) = False And IsNumeric(Prop14) = True Then xmol2(14) = Prop14 If IsMissing(Prop15) = False And IsNumeric(Prop15) = True Then xmol2(15) = Prop15 If IsMissing(Prop16) = False And IsNumeric(Prop16) = True Then xmol2(16) = Prop16 If IsMissing(Prop17) = False And IsNumeric(Prop17) = True Then xmol2(17) = Prop17 If IsMissing(Prop18) = False And IsNumeric(Prop18) = True Then xmol2(18) = Prop18 If IsMissing(Prop19) = False And IsNumeric(Prop19) = True Then xmol2(19) = Prop19 If IsMissing(Prop20) = False And IsNumeric(Prop20) = True Then xmol2(20) = Prop20 Call CalcSetup(FluidName, "", "", 0, 0) If ierr > 0 Then Mole2Mass = Trim2(herr): Exit Function If i < 0 Or i > nc Then Mole2Mass = Trim2("Index out of Range (greater than number of components in mixture)"): Exit Function sum = 0 For j = 1 To nc sum = sum + xmol2(j) Next If Abs(sum - 1) > 0.0001 Then Mole2Mass = Trim2("Composition does not sum to 1"): Exit Function Call XMASSdll(xmol2(1), xkg2(1), wmix2) If i = 0 Then 'Molar mass of mixture Mole2Mass = wmix2 Else 'Mass fraction Mole2Mass = xkg2(i) End If End Function 'Change mass composition to molar composition 'Prop1 - Prop20 are the mass values for the components in the mixture. 'i specifies which component's mass fraction is returned. If zero, the molar mass is returned Function Mass2Mole(FluidName, i, Prop1, Prop2, Optional Prop3, Optional Prop4, Optional Prop5, Optional Prop6, Optional Prop7, Optional Prop8, Optional Prop9, Optional Prop10, Optional Prop11, Optional Prop12, Optional Prop13, Optional Prop14, Optional Prop15, Optional Prop16, Optional Prop17, Optional Prop18, Optional Prop19, Optional Prop20) Dim j As Integer, xkg2(1 To MaxComps) As Double, xmol2(1 To MaxComps) As Double, wmix2 As Double, sum As Double For j = 1 To MaxComps: xkg2(j) = 0: Next xkg2(1) = Prop1 xkg2(2) = Prop2 If IsMissing(Prop3) = False And IsNumeric(Prop3) = True Then xkg2(3) = Prop3 If IsMissing(Prop4) = False And IsNumeric(Prop4) = True Then xkg2(4) = Prop4 If IsMissing(Prop5) = False And IsNumeric(Prop5) = True Then xkg2(5) = Prop5 If IsMissing(Prop6) = False And IsNumeric(Prop6) = True Then xkg2(6) = Prop6 If IsMissing(Prop7) = False And IsNumeric(Prop7) = True Then xkg2(7) = Prop7 If IsMissing(Prop8) = False And IsNumeric(Prop8) = True Then xkg2(8) = Prop8 If IsMissing(Prop9) = False And IsNumeric(Prop9) = True Then xkg2(9) = Prop9 If IsMissing(Prop10) = False And IsNumeric(Prop10) = True Then xkg2(10) = Prop10 If IsMissing(Prop11) = False And IsNumeric(Prop11) = True Then xkg2(11) = Prop11 If IsMissing(Prop12) = False And IsNumeric(Prop12) = True Then xkg2(12) = Prop12 If IsMissing(Prop13) = False And IsNumeric(Prop13) = True Then xkg2(13) = Prop13 If IsMissing(Prop14) = False And IsNumeric(Prop14) = True Then xkg2(14) = Prop14 If IsMissing(Prop15) = False And IsNumeric(Prop15) = True Then xkg2(15) = Prop15 If IsMissing(Prop16) = False And IsNumeric(Prop16) = True Then xkg2(16) = Prop16 If IsMissing(Prop17) = False And IsNumeric(Prop17) = True Then xkg2(17) = Prop17 If IsMissing(Prop18) = False And IsNumeric(Prop18) = True Then xkg2(18) = Prop18 If IsMissing(Prop19) = False And IsNumeric(Prop19) = True Then xkg2(19) = Prop19 If IsMissing(Prop20) = False And IsNumeric(Prop20) = True Then xkg2(20) = Prop20 Call CalcSetup(FluidName, "", "", 0, 0) If ierr > 0 Then Mass2Mole = Trim2(herr): Exit Function If i < 0 Or i > nc Then Mass2Mole = Trim2("Index out of Range (greater than number of components in mixture)"): Exit Function sum = 0 For j = 1 To nc sum = sum + xkg2(j) Next If Abs(sum - 1) > 0.0001 Then Mass2Mole = Trim2("Composition does not sum to 1"): Exit Function Call XMOLEdll(xkg2(1), xmol2(1), wmix2) If i = 0 Then 'Molar mass of mixture Mass2Mole = wmix2 Else 'Mole fraction Mass2Mole = xmol2(i) End If End Function Function EOSMax(FluidName, Optional InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcSetup(FluidName, "", Units, Prop1, Prop2) If nc > 1 Then Call LIMITXdll("EOS", 300#, 0#, 0#, x(1), tmin, tmax, dmax, pmax, ierr2, herr2, 3&, 255&) Else Call LIMITKdll("EOS", 1, 300#, 0#, 0#, tmin, tmax, dmax, pmax, ierr2, herr2, 3&, 255&) End If If IsMissing(InpCode) Then InpCode = "" If InpCode = "P" Or InpCode = "p" Then EOSMax = ConvertUnits("-P", Units, pmax, 0) ElseIf InpCode = "D" Or InpCode = "d" Then EOSMax = ConvertUnits("-D", Units, dmax, 0) Else EOSMax = ConvertUnits("-T", Units, tmax, 0) End If End Function Function EOSMin(FluidName, Optional InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcSetup(FluidName, "", Units, Prop1, Prop2) If nc > 1 Then Call LIMITXdll("EOS", 300#, 0#, 0#, x(1), tmin, tmax, dmax, pmax, ierr2, herr2, 3&, 255&) Else Call LIMITKdll("EOS", 1, 300#, 0#, 0#, tmin, tmax, dmax, pmax, ierr2, herr2, 3&, 255&) End If If IsMissing(InpCode) Then InpCode = "" If InpCode = "P" Or InpCode = "p" Then EOSMin = 0 ElseIf InpCode = "D" Or InpCode = "d" Then EOSMin = 0 Else EOSMin = ConvertUnits("-T", Units, tmin, 0) End If End Function Function ErrorCode(InputCell) ErrorCode = ierr End Function Function ErrorString(InputCell) ErrorString = Trim2(herr) End Function Function Trim2(a) 'All error messages call this routine to add the pound sign (#) to the beginning of the line. 'If you do not want this error code, simply remove the ["#" +] piece below. 'It can also be changed to any other symbol(s) you desire. If Left(a, 1) <> "#" Then Trim2 = "#" + Trim(a) Else Trim2 = Trim(a) End If End Function Function Viscosity_ETAK0(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) If ierr > 0 Then Viscosity_ETAK0 = Trim2(herr): Exit Function If t = 0 Then Viscosity_ETAK0 = Trim2("Inputs out of range"): Exit Function Call ETAK0dll(1&, t, eta0, ierr, herr, 255&) If q > 0 And q < 1 Then eta0 = -9999999 Viscosity_ETAK0 = ConvertUnits("-U", Units, eta0, 0) If eta0 = 0 Then Viscosity_ETAK0 = Trim2("Unable to calculate property") End Function Function Viscosity_ETAK1(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) If ierr > 0 Then Viscosity_ETAK1 = Trim2(herr): Exit Function If t = 0 Then Viscosity_ETAK1 = Trim2("Inputs out of range"): Exit Function Call ETAK1dll(1&, t, eta1, ierr, herr, 255&) If q > 0 And q < 1 Then eta1 = -9999999 Viscosity_ETAK1 = ConvertUnits("-U", Units, eta1, 0) If eta1 = 0 Then Viscosity_ETAK1 = Trim2("Unable to calculate property") End Function Function Viscosity_ETAKR(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) If ierr > 0 Then Viscosity_ETAKR = Trim2(herr): Exit Function If t = 0 Then Viscosity_ETAKR = Trim2("Inputs out of range"): Exit Function Call ETAKRdll(1&, t, d, etar, ierr, herr, 255&) If q > 0 And q < 1 Then etar = -9999999 Viscosity_ETAKR = ConvertUnits("-U", Units, etar, 0) If etar = 0 Then Viscosity_ETAKR = Trim2("Unable to calculate property") End Function Function Viscosity_ETAKB(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) If ierr > 0 Then Viscosity_ETAKB = Trim2(herr): Exit Function If t = 0 Then Viscosity_ETAKB = Trim2("Inputs out of range"): Exit Function Call ETAKBdll(1&, t, d, etab, ierr, herr, 255&) If q > 0 And q < 1 Then etab = -9999999 Viscosity_ETAKB = ConvertUnits("-U", Units, etab, 0) If etab = 0 Then Viscosity_ETAKB = Trim2("Unable to calculate property") End Function Function Transport_Omega(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) If ierr > 0 Then Transport_Omega = Trim2(herr): Exit Function If t = 0 Then Transport_Omega = Trim2("Inputs out of range"): Exit Function 'epsk is not read from the FLD file yet !! epsk = 280.51 Call OMEGAdll(1, t, epsk, omg) If q > 0 And q < 1 Then omg = -9999999 Transport_Omega = ConvertUnits("-U", Units, omg, 0) If omg = 0 Then Transport_Omega = Trim2("Unable to calculate property") End Function Function ThermalConductivity_TCXK0(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) If ierr > 0 Then ThermalConductivity_TCXK0 = Trim2(herr): Exit Function If t = 0 Or d = 0 Then ThermalConductivity_TCXK0 = Trim2("Inputs out of range"): Exit Function Call TCXK0dll(1&, t, tcx0, ierr, herr, 255&) If q > 0 And q < 1 Then tcx0 = -9999999 ThermalConductivity_TCXK0 = ConvertUnits("-K", Units, tcx0, 0) If tcx0 = 0 Then ThermalConductivity_TCXK0 = Trim2("Unable to calculate property") End Function Function ThermalConductivity_TCXKB(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) If ierr > 0 Then ThermalConductivity_TCXKB = Trim2(herr): Exit Function If t = 0 Or d = 0 Then ThermalConductivity_TCXKB = Trim2("Inputs out of range"): Exit Function Call TCXKBdll(1&, t, d, tcxb, ierr, herr, 255&) If q > 0 And q < 1 Then tcxb = -9999999 ThermalConductivity_TCXKB = ConvertUnits("-K", Units, tcxb, 0) If tcxb = 0 Then ThermalConductivity_TCXKB = Trim2("Unable to calculate property") End Function Function ThermalConductivity_TCXKC(FluidName, InpCode, Optional Units, Optional Prop1, Optional Prop2) Call CalcProp(FluidName, InpCode, Units, Prop1, Prop2) If ierr > 0 Then ThermalConductivity_TCXKC = Trim2(herr): Exit Function If t = 0 Or d = 0 Then ThermalConductivity_TCXKC = Trim2("Inputs out of range"): Exit Function Call TCXKCdll(1&, t, d, tcxc, ierr, herr, 255&) If q > 0 And q < 1 Then tcxc = -9999999 ThermalConductivity_TCXKC = ConvertUnits("-K", Units, tcxc, 0) If tcxc = 0 Then ThermalConductivity_TCXKC = Trim2("Unable to calculate property") End Function Function UnitConvert(InputValue, UnitType As String, OldUnits As String, NewUnits As String) 'InputValue is the value to be converted from OldUnits to NewUnits 'UnitType is one of the following letters (one character only in most cases): 'UnitType Unit name SI units ' T Temperature K ' P Pressure Pa ' D Density or specific volume mol/m^3 or kg/m^3 (or m^3/mol or m^3/kg) ' H Enthalpy or specific energy J/mol or J/kg ' S Entropy or heat capacity J/mol-K or J/kg-K ' W Speed of sound m/s ' U Viscosity Pa-s ' K Thermal conductivity W/m-K ' JT Joule Thomson K/Pa ' L Length m ' A Area m^2 ' V Volume m^3 ' M Mass kg ' F Force N ' E Energy J ' Q Power W ' N Surface tension N/m ' Gage pressures can be used by adding "_g" to the unit, e.g., "MPa_g" ' The different inputs for OldUnits and NewUnits can be found scattered in the text below. ' Several examples are given below: ' T=UnitConvert(323.15,"T","K","F") ' P=UnitConvert(1.01325,"P","bar","mmHg") ' V=UnitConvert(1000.,"D","kg/m^3","cm^3/mol") Dim Value As Double, Tpe As String, Unit1 As String, Unit2 As String Dim Drct As Integer, Gage As Integer, Vacm As Integer Dim MolWt As Double, Rgas As Double If Not IsNumeric(InputValue) Then UnitConvert = InputValue: Exit Function If NewUnits = "" Then UnitConvert = InputValue: Exit Function Value = InputValue Tpe = UCase(Trim(UnitType)) Unit1 = UCase(Trim(OldUnits)) Unit2 = UCase(Trim(NewUnits)) Rgas = 8.314472 Call WMOLdll(x(1), wm) If CompFlag = 1 Then Call WMOLdll(xliq(1), wm) If CompFlag = 2 Then Call WMOLdll(xvap(1), wm) MolWt = wm If MolWt = 0 Then MolWt = 1 For Drct = 1 To -1 Step -2 '----------------------------------------------------------------------- ' Temperature Conversion '----------------------------------------------------------------------- If Tpe = "T" Then If Unit1 = "K" Then ElseIf Unit1 = "C" Then Value = Value + Drct * CtoK ElseIf Unit1 = "R" Then Value = Value * RtoK ^ Drct ElseIf Unit1 = "F" Then If Drct = 1 Then 'Value = RtoK * (Value + FtoR) 'Does not give exactly zero at 32 F Value = (Value - 32) * RtoK + CtoK Else 'Value = Value / RtoK - FtoR 'Does not give exactly 32 at 273.15 K Value = (Value - CtoK) / RtoK + 32 End If Else UnitConvert = Trim2("Undefined input unit"): Exit Function End If '----------------------------------------------------------------------- ' Pressure Conversion '----------------------------------------------------------------------- ElseIf Tpe = "P" Then Gage = InStr(Unit1, "GAGE") Vacm = InStr(Unit1, "VACM") If Gage = 0 Then Gage = InStr(Unit1, "_G") If Vacm = 0 Then Vacm = InStr(Unit1, "_V") If Gage <> 0 And Drct = -1 Then Value = Value - ATMtoMPa If Vacm <> 0 And Drct = -1 Then Value = ATMtoMPa - Value If Gage <> 0 Then Unit1 = Trim(Left(Unit1, Gage - 1)) If Vacm <> 0 Then Unit1 = Trim(Left(Unit1, Vacm - 1)) If Unit1 = "PA" Then Value = Value / 1000000 ^ Drct ElseIf Unit1 = "KPA" Then Value = Value / 1000 ^ Drct ElseIf Unit1 = "MPA" Then Value = Value ElseIf Unit1 = "GPA" Then Value = Value * 1000 ^ Drct ElseIf Unit1 = "BAR" Then Value = Value * BARtoMPA ^ Drct ElseIf Unit1 = "KBAR" Then Value = Value * (BARtoMPA * 1000) ^ Drct ElseIf Unit1 = "ATM" Then Value = Value * ATMtoMPa ^ Drct ElseIf Unit1 = "KGF/CM^2" Or Unit1 = "KG/CM^2" Or Unit1 = "ATA" Or Unit1 = "AT" Or Unit1 = "ATMA" Then Value = Value * (KGFtoN / 100) ^ Drct ElseIf Unit1 = "PSI" Or Unit1 = "PSIA" Then Value = Value * PSIAtoMPA ^ Drct ElseIf Unit1 = "PSF" Then Value = Value * (PSIAtoMPA / 144) ^ Drct ElseIf Unit1 = "MMHG" Or Unit1 = "TORR" Then Value = Value * MMHGtoMPA ^ Drct ElseIf Unit1 = "CMHG" Then Value = Value * (MMHGtoMPA * 10) ^ Drct ElseIf Unit1 = "INHG" Then Value = Value * (MMHGtoMPA * INtoM * 1000) ^ Drct ElseIf Unit1 = "INH2O" Then Value = Value * INH2OtoMPA ^ Drct ElseIf Unit1 = "PSIG" Then If Drct = 1 Then Value = PSIAtoMPA * Value + ATMtoMPa Else Value = (Value - ATMtoMPa) / PSIAtoMPA End If Else UnitConvert = Trim2("Undefined input unit"): Exit Function End If If Gage <> 0 And Drct = 1 Then Value = Value + ATMtoMPa If Vacm <> 0 And Drct = 1 Then Value = ATMtoMPa - Value '----------------------------------------------------------------------- ' Density Conversion '----------------------------------------------------------------------- ElseIf Tpe = "D" Then If Value = 0 Then Value = 1E-50 If Unit1 = "MOL/DM^3" Or Unit1 = "MOL/L" Or Unit1 = "KMOL/M^3" Then ElseIf Unit1 = "MOL/CM^3" Or Unit1 = "MOL/CC" Then Value = Value * 1000 ^ Drct ElseIf Unit1 = "MOL/M^3" Then Value = Value / 1000 ^ Drct ElseIf Unit1 = "KG/M^3" Then Value = Value / MolWt ^ Drct ElseIf Unit1 = "KG/DM^3" Or Unit1 = "KG/L" Then Value = Value * (1000 / MolWt) ^ Drct ElseIf Unit1 = "G/DM^3" Or Unit1 = "G/L" Then Value = Value * (1 / MolWt) ^ Drct ElseIf Unit1 = "G/CC" Or Unit1 = "G/CM^3" Or Unit1 = "G/ML" Then Value = Value * (1000 / MolWt) ^ Drct ElseIf Unit1 = "G/DM^3" Then Value = Value * (1 / MolWt) ^ Drct ElseIf Unit1 = "LBM/FT^3" Or Unit1 = "LB/FT^3" Then Value = Value * (LBMtoKG / FT3toM3 / MolWt) ^ Drct ElseIf Unit1 = "LBMOL/FT^3" Then Value = Value * (LBMtoKG / FT3toM3) ^ Drct ElseIf Unit1 = "SLUG/FT^3" Then Value = Value * (LBMtoKG / FT3toM3 / MolWt * KGFtoN / FTtoM) ^ Drct ElseIf Unit1 = "LBMOL/GAL" Then Value = Value * (LBMtoKG / GALLONtoM3) ^ Drct ElseIf Unit1 = "LB/GAL" Or Unit1 = "LBM/GAL" Then Value = Value * (LBMtoKG / GALLONtoM3 / MolWt) ^ Drct '----------------------------------------------------------------------- ' Specific Volume Conversion '----------------------------------------------------------------------- ElseIf Unit1 = "DM^3/MOL" Or Unit1 = "L/MOL" Or Unit1 = "M^3/KMOL" Then Value = 1 / Value ElseIf Unit1 = "CM^3/MOL" Or Unit1 = "CC/MOL" Or Unit1 = "ML/MOL" Then Value = 1000 / Value ElseIf Unit1 = "M^3/MOL" Then Value = 1 / Value / 1000 ElseIf Unit1 = "M^3/KG" Then Value = 1 / Value / MolWt ElseIf Unit1 = "DM^3/KG" Or Unit1 = "L/KG" Then Value = 1000 / Value / MolWt ElseIf Unit1 = "CC/G" Or Unit1 = "CM^3/G" Or Unit1 = "ML/G" Then Value = 1000 / Value / MolWt ElseIf Unit1 = "DM^3/G" Then Value = 1 / Value / MolWt ElseIf Unit1 = "FT^3/LBM" Or Unit1 = "FT^3/LB" Then Value = 1 / Value * (LBMtoKG / FT3toM3 / MolWt) ElseIf Unit1 = "FT^3/LBMOL" Then Value = 1 / Value * (LBMtoKG / FT3toM3) ElseIf Unit1 = "FT^3/SLUG" Then Value = 1 / Value * (LBMtoKG / FT3toM3 / MolWt * KGFtoN / FTtoM) ElseIf Unit1 = "GAL/LBMOL" Then Value = 1 / Value * (LBMtoKG / GALLONtoM3) ElseIf Unit1 = "GAL/LB" Or Unit1 = "GAL/LBM" Then Value = 1 / Value * (LBMtoKG / GALLONtoM3 / MolWt) Else UnitConvert = Trim2("Undefined input unit"): Exit Function End If If Abs(Value) < 1E-30 Then Value = 0 '----------------------------------------------------------------------- ' Specific Energy and Enthalpy Conversions '----------------------------------------------------------------------- ElseIf Tpe = "H" Then If Unit1 = "J/MOL" Or Unit1 = "KJ/KMOL" Then ElseIf Unit1 = "KJ/MOL" Then Value = Value * 1000 ^ Drct ElseIf Unit1 = "MJ/MOL" Then Value = Value * 1000000 ^ Drct ElseIf Unit1 = "KJ/KG" Or Unit1 = "J/G" Then Value = MolWt ^ Drct * Value ElseIf Unit1 = "J/KG" Then Value = (MolWt / 1000) ^ Drct * Value ElseIf Unit1 = "M^2/S^2" Then Value = (MolWt / 1000) ^ Drct * Value ElseIf Unit1 = "FT^2/S^2" Then Value = (MolWt / 1000 * FTtoM ^ 2) ^ Drct * Value ElseIf Unit1 = "CAL/MOL" Or Unit1 = "KCAL/KMOL" Then Value = CALtoJ ^ Drct * Value ElseIf Unit1 = "CAL/G" Or Unit1 = "KCAL/KG" Then Value = (CALtoJ * MolWt) ^ Drct * Value ElseIf Unit1 = "BTU/LBM" Or Unit1 = "BTU/LB" Then Value = (BTUtoKJ / LBMtoKG * MolWt) ^ Drct * Value ElseIf Unit1 = "BTU/LBMOL" Then Value = (BTUtoKJ / LBMtoKG) ^ Drct * Value Else UnitConvert = Trim2("Undefined input unit"): Exit Function End If '----------------------------------------------------------------------- ' Entropy and Heat Capacity Conversions '----------------------------------------------------------------------- ElseIf Tpe = "S" Then If Unit1 = "J/MOL-K" Or Unit1 = "KJ/KMOL-K" Then Value = Value ElseIf Unit1 = "KJ/MOL-K" Then Value = Value * 1000 ^ Drct ElseIf Unit1 = "KJ/KG-K" Or Unit1 = "J/G-K" Then Value = MolWt ^ Drct * Value ElseIf Unit1 = "J/KG-K" Then Value = (MolWt / 1000) ^ Drct * Value ElseIf Unit1 = "BTU/LBM-R" Or Unit1 = "BTU/LB-R" Then Value = (BTUtoKJ / LBMtoKG / RtoK * MolWt) ^ Drct * Value ElseIf Unit1 = "BTU/LBMOL-R" Then Value = (BTUtoKJ / LBMtoKG / RtoK) ^ Drct * Value ElseIf Unit1 = "CAL/G-K" Or Unit1 = "CAL/G-C" Or Unit1 = "KCAL/KG-K" Or Unit1 = "KCAL/KG-C" Then Value = (CALtoJ * MolWt) ^ Drct * Value ElseIf Unit1 = "CAL/MOL-K" Or Unit1 = "CAL/MOL-C" Then Value = CALtoJ ^ Drct * Value ElseIf Unit1 = "FT-LBF/LBMOL-R" Then Value = (FTLBFtoJ / LBMtoKG / RtoK / 1000) ^ Drct * Value ElseIf Unit1 = "CP/R" Then Value = Rgas ^ Drct * Value * 1000 Else UnitConvert = Trim2("Undefined input unit"): Exit Function End If '----------------------------------------------------------------------- ' Speed of Sound Conversion '----------------------------------------------------------------------- ElseIf Tpe = "W" Then If Unit1 = "M/S" Then ElseIf Unit1 = "M^2/S^2" Then Value = Sqr(Value) ElseIf Unit1 = "CM/S" Then Value = Value / 100 ^ Drct ElseIf Unit1 = "KM/H" Then Value = Value * (1000 / HtoS) ^ Drct ElseIf Unit1 = "FT/S" Then Value = Value * FTtoM ^ Drct ElseIf Unit1 = "IN/S" Then Value = Value * INtoM ^ Drct ElseIf Unit1 = "MILE/H" Or Unit1 = "MPH" Then Value = Value * (INtoM * 63360 / HtoS) ^ Drct ElseIf Unit1 = "KNOT" Then Value = Value * 0.5144444444 ^ Drct ElseIf Unit1 = "MACH" Then Value = Value * Sqr(1.4 * 298.15 * 8314.51 / 28.95853816) ^ Drct Else UnitConvert = Trim2("Undefined input unit"): Exit Function End If '----------------------------------------------------------------------- ' Viscosity Conversion '----------------------------------------------------------------------- ElseIf Tpe = "U" Then If Unit1 = "PA-S" Or Unit1 = "KG/M-S" Then ElseIf Unit1 = "MPA-S" Then 'Note: This is milliPa-s, not MPa-s Value = Value / 1000 ^ Drct ElseIf Unit1 = "UPA-S" Then Value = Value / 1000000 ^ Drct ElseIf Unit1 = "G/CM-S" Or Unit1 = "POISE" Then Value = Value / 10 ^ Drct ElseIf Unit1 = "CENTIPOISE" Then Value = Value / 1000 ^ Drct ElseIf Unit1 = "MILLIPOISE" Or Unit1 = "MPOISE" Then Value = Value / 10000 ^ Drct ElseIf Unit1 = "MICROPOISE" Or Unit1 = "UPOISE" Then Value = Value / 10000000 ^ Drct ElseIf Unit1 = "LBM/FT-S" Or Unit1 = "LB/FT-S" Then Value = Value * (LBMtoKG / FTtoM) ^ Drct ElseIf Unit1 = "LBF-S/FT^2" Then Value = Value * (LBFtoN / FTtoM ^ 2) ^ Drct ElseIf Unit1 = "LBM/FT-H" Or Unit1 = "LB/FT-H" Then Value = Value * (LBMtoKG / FTtoM / HtoS) ^ Drct Else UnitConvert = Trim2("Undefined input unit"): Exit Function End If '----------------------------------------------------------------------- ' Thermal Conductivity Conversion '----------------------------------------------------------------------- ElseIf Tpe = "K" Then If Unit1 = "MW/M-K" Then ElseIf Unit1 = "W/M-K" Then Value = Value * 1000 ^ Drct ElseIf Unit1 = "G-CM/S^3-K" Then Value = Value / 100 ^ Drct ElseIf Unit1 = "KG-M/S^3-K" Then Value = Value * 1000 ^ Drct ElseIf Unit1 = "CAL/S-CM-K" Then Value = Value * (CALtoJ * 100000) ^ Drct ElseIf Unit1 = "KCAL/HR-M-K" Then Value = Value * (CALtoJ * 100000 * 1000 / 100 / 3600) ^ Drct ElseIf Unit1 = "LBM-FT/S^3-F" Or Unit1 = "LB-FT/S^3-F" Then Value = Value * (1000 * LBMtoKG * FTtoM / RtoK) ^ Drct ElseIf Unit1 = "LBF/S-F" Then Value = Value * (1000 * LBFtoN / RtoK) ^ Drct ElseIf Unit1 = "BTU/H-FT-F" Then Value = Value * (1000 * BTUtoW / HtoS / FTtoM / RtoK) ^ Drct Else UnitConvert = Trim2("Undefined input unit"): Exit Function End If '----------------------------------------------------------------------- ' Joule-Thomson Conversion '----------------------------------------------------------------------- ElseIf Tpe = "JT" Then If Unit1 = "K/MPA" Or Unit1 = "C/MPA" Then ElseIf Unit1 = "K/KPA" Or Unit1 = "C/KPA" Then Value = Value * 1000 ^ Drct ElseIf Unit1 = "K/PA" Or Unit1 = "C/PA" Then Value = Value * 1000000 ^ Drct ElseIf Unit1 = "C/ATM" Then Value = Value / ATMtoMPa ^ Drct ElseIf Unit1 = "C/BAR" Then Value = Value / BARtoMPA ^ Drct ElseIf Unit1 = "K/PSI" Or Unit1 = "K/PSIA" Then Value = Value / PSIAtoMPA ^ Drct ElseIf Unit1 = "F/PSI" Or Unit1 = "F/PSIA" Or Unit1 = "R/PSIA" Then Value = Value / (PSIAtoMPA / RtoK) ^ Drct Else UnitConvert = Trim2("Undefined input unit"): Exit Function End If '----------------------------------------------------------------------- ' Length Conversion '----------------------------------------------------------------------- ElseIf Tpe = "L" Then If Unit1 = "METER" Or Unit1 = "M" Then ElseIf Unit1 = "DM" Then Value = Value / 10 ^ Drct ElseIf Unit1 = "CM" Then Value = Value / 100 ^ Drct ElseIf Unit1 = "MM" Then Value = Value / 1000 ^ Drct ElseIf Unit1 = "KM" Then Value = Value * 1000 ^ Drct ElseIf Unit1 = "INCH" Or Unit1 = "IN" Then Value = Value * INtoM ^ Drct ElseIf Unit1 = "FOOT" Or Unit1 = "FT" Then Value = Value * FTtoM ^ Drct ElseIf Unit1 = "YARD" Or Unit1 = "YD" Then Value = Value * (INtoM * 36) ^ Drct ElseIf Unit1 = "MILE" Or Unit1 = "MI" Then Value = Value * (INtoM * 63360) ^ Drct ElseIf Unit1 = "LIGHT YEAR" Then Value = Value * 9.46055E+15 ^ Drct ElseIf Unit1 = "ANGSTROM" Then Value = Value / 10000000000# ^ Drct ElseIf Unit1 = "FATHOM" Then Value = Value * (FTtoM * 6) ^ Drct ElseIf Unit1 = "MIL" Then Value = Value * (INtoM / 1000) ^ Drct ElseIf Unit1 = "ROD" Then Value = Value * (INtoM * 16.5 * 12) ^ Drct ElseIf Unit1 = "PARSEC" Then Value = Value * (30837400000000# * 1000) ^ Drct Else UnitConvert = Trim2("Undefined input unit"): Exit Function End If '----------------------------------------------------------------------- ' Area Conversion '----------------------------------------------------------------------- ElseIf Tpe = "A" Then If Unit1 = "METER^2" Or Unit1 = "M^2" Then ElseIf Unit1 = "CM^2" Then Value = Value / 10000 ^ Drct ElseIf Unit1 = "MM^2" Then Value = Value / 1000000 ^ Drct ElseIf Unit1 = "KM^2" Then Value = Value * 1000000 ^ Drct ElseIf Unit1 = "INCH^2" Or Unit1 = "IN^2" Then Value = Value * (INtoM ^ 2) ^ Drct ElseIf Unit1 = "FOOT^2" Or Unit1 = "FT^2" Then Value = Value * (FTtoM ^ 2) ^ Drct ElseIf Unit1 = "YARD^2" Or Unit1 = "YD^2" Then Value = Value * ((INtoM * 36) ^ 2) ^ Drct ElseIf Unit1 = "MILE^2" Or Unit1 = "MI^2" Then Value = Value * ((INtoM * 63360) ^ 2) ^ Drct ElseIf Unit1 = "ACRE" Then Value = Value * ((INtoM * 36) ^ 2 * 4840) ^ Drct ElseIf Unit1 = "BARN" Then Value = Value * 1E-28 ^ Drct ElseIf Unit1 = "HECTARE" Then Value = Value * 10000 ^ Drct Else UnitConvert = Trim2("Undefined input unit"): Exit Function End If '----------------------------------------------------------------------- ' Volume Conversion (Note: not specific volume) '----------------------------------------------------------------------- ElseIf Tpe = "V" Then If Unit1 = "METER^3" Or Unit1 = "M^3" Then ElseIf Unit1 = "CM^3" Then Value = Value / 1000000 ^ Drct ElseIf Unit1 = "LITER" Or Unit1 = "L" Or Unit1 = "DM^3" Then Value = Value / 1000 ^ Drct ElseIf Unit1 = "INCH^3" Or Unit1 = "IN^3" Then Value = Value * IN3toM3 ^ Drct ElseIf Unit1 = "FOOT^3" Or Unit1 = "FT^3" Then Value = Value * (IN3toM3 * 12 ^ 3) ^ Drct ElseIf Unit1 = "YARD^3" Or Unit1 = "YD^3" Then Value = Value * (IN3toM3 * 36 ^ 3) ^ Drct ElseIf Unit1 = "GALLON" Or Unit1 = "GAL" Then Value = Value * GALLONtoM3 ^ Drct ElseIf Unit1 = "QUART" Or Unit1 = "QT" Then Value = Value * (GALLONtoM3 / 4) ^ Drct ElseIf Unit1 = "PINT" Or Unit1 = "PT" Then Value = Value * (GALLONtoM3 / 8) ^ Drct ElseIf Unit1 = "CUP" Then Value = Value * (GALLONtoM3 / 16) ^ Drct ElseIf Unit1 = "OUNCE" Then Value = Value * (GALLONtoM3 / 128) ^ Drct ElseIf Unit1 = "TABLESPOON" Or Unit1 = "TBSP" Then Value = Value * (GALLONtoM3 / 256) ^ Drct ElseIf Unit1 = "TEASPOON" Or Unit1 = "TSP" Then Value = Value * (GALLONtoM3 / 768) ^ Drct ElseIf Unit1 = "CORD" Then Value = Value * (FT3toM3 * 128) ^ Drct ElseIf Unit1 = "BARREL" Then Value = Value * (GALLONtoM3 * 42) ^ Drct ElseIf Unit1 = "BOARD FOOT" Then Value = Value * (IN3toM3 * 144) ^ Drct ElseIf Unit1 = "BUSHEL" Then Value = Value * 0.03523907016688 ^ Drct Else UnitConvert = Trim2("Undefined input unit"): Exit Function End If '----------------------------------------------------------------------- ' Mass Conversion '----------------------------------------------------------------------- ElseIf Tpe = "M" Then If Unit1 = "KG" Then ElseIf Unit1 = "G" Then Value = Value / 1000 ^ Drct ElseIf Unit1 = "MG" Then 'milligram Value = Value / 1000000 ^ Drct ElseIf Unit1 = "LBM" Or Unit1 = "LB" Then Value = Value * LBMtoKG ^ Drct ElseIf Unit1 = "GRAIN" Then Value = Value * (LBMtoKG / 7000) ^ Drct ElseIf Unit1 = "SLUG" Then Value = Value * (KGFtoN * LBMtoKG / FTtoM) ^ Drct ElseIf Unit1 = "TON" Then Value = Value * (LBMtoKG * 2000) ^ Drct ElseIf Unit1 = "TONNE" Then Value = Value * 1000 ^ Drct Else UnitConvert = Trim2("Undefined input unit"): Exit Function End If '----------------------------------------------------------------------- ' Force Conversion '----------------------------------------------------------------------- ElseIf Tpe = "F" Then If Unit1 = "NEWTON" Or Unit1 = "N" Then ElseIf Unit1 = "MN" Then 'milliNewtons Value = Value / 1000 ^ Drct ElseIf Unit1 = "KGF" Then Value = Value * KGFtoN ^ Drct ElseIf Unit1 = "DYNE" Then Value = Value / 100000 ^ Drct ElseIf Unit1 = "LBF" Then Value = Value * LBFtoN ^ Drct ElseIf Unit1 = "POUNDAL" Then Value = Value * (LBMtoKG * FTtoM) ^ Drct ElseIf Unit1 = "OZF" Then Value = Value * (LBFtoN / 16) ^ Drct Else UnitConvert = Trim2("Undefined input unit"): Exit Function End If '----------------------------------------------------------------------- ' Energy Conversion '----------------------------------------------------------------------- ElseIf Tpe = "E" Then If Unit1 = "JOULE" Or Unit1 = "J" Then ElseIf Unit1 = "KJ" Then Value = Value * 1000 ^ Drct ElseIf Unit1 = "MJ" Then Value = Value * 1000000 ^ Drct ElseIf Unit1 = "KW-H" Then Value = Value * (HtoS * 1000) ^ Drct ElseIf Unit1 = "CAL" Then Value = CALtoJ ^ Drct * Value ElseIf Unit1 = "KCAL" Then Value = Value * (CALtoJ * 1000) ^ Drct ElseIf Unit1 = "ERG" Then Value = Value / 10000000 ^ Drct ElseIf Unit1 = "BTU" Then Value = Value * (BTUtoKJ * 1000) ^ Drct ElseIf Unit1 = "FT-LBF" Then Value = Value * FTLBFtoJ ^ Drct Else UnitConvert = Trim2("Undefined input unit"): Exit Function End If '----------------------------------------------------------------------- ' Power Conversion '----------------------------------------------------------------------- ElseIf Tpe = "Q" Then If Unit1 = "WATT" Or Unit1 = "W" Then ElseIf Unit1 = "KWATT" Or Unit1 = "KW" Then Value = Value * 1000 ^ Drct ElseIf Unit1 = "BTU/S" Then Value = Value * BTUtoW ^ Drct ElseIf Unit1 = "BTU/MIN" Then Value = Value * (BTUtoW / 60) ^ Drct ElseIf Unit1 = "BTU/H" Then Value = Value * (BTUtoW / HtoS) ^ Drct ElseIf Unit1 = "CAL/S" Then Value = Value * CALtoJ ^ Drct ElseIf Unit1 = "KCAL/S" Then Value = Value * (CALtoJ * 1000) ^ Drct ElseIf Unit1 = "CAL/MIN" Then Value = Value * (CALtoJ / 60) ^ Drct ElseIf Unit1 = "KCAL/MIN" Then Value = Value * (CALtoJ / 60 * 1000) ^ Drct ElseIf Unit1 = "FT-LBF/S" Then Value = Value * FTLBFtoJ ^ Drct ElseIf Unit1 = "FT-LBF/MIN" Then Value = Value * (FTLBFtoJ / 60) ^ Drct ElseIf Unit1 = "FT-LBF/H" Then Value = Value * (FTLBFtoJ / HtoS) ^ Drct ElseIf Unit1 = "HP" Then Value = Value * HPtoW ^ Drct Else UnitConvert = Trim2("Undefined input unit"): Exit Function End If '----------------------------------------------------------------------- ' Surface Tension Conversion '----------------------------------------------------------------------- ElseIf Tpe = "N" Then If Unit1 = "N/M" Then ElseIf Unit1 = "MN/M" Then Value = Value / 1000 ^ Drct ElseIf Unit1 = "DYNE/CM" Or Unit1 = "DYN/CM" Then Value = Value / 1000 ^ Drct ElseIf Unit1 = "LBF/FT" Then Value = Value * LBFTtoNM ^ Drct Else UnitConvert = Trim2("Undefined input unit"): Exit Function End If End If Unit1 = Unit2 Next Drct UnitConvert = Value End Function Sub SetupUnits(i) 'Warning: If any of these are changed (to make them the default) after the program has run, ' you will need to exit Excel and restart it so that it reinitializes 'REFPROP Units tUnits2 = "K" taUnits2 = "K" pUnits2 = "kPa" dUnits2 = "mol/dm^3" vUnits2 = "dm^3/mol" hUnits2 = "J/mol" sUnits2 = "J/mol-K" wUnits2 = "m/s" visUnits2 = "uPa-s" tcxUnits2 = "W/m-K" stUnits2 = "N/m" 'Default units: (SI) tUnits(0) = "K" taUnits(0) = "K" pUnits(0) = "MPa" dUnits(0) = "kg/m^3" vUnits(0) = "m^3/kg" hUnits(0) = "kJ/kg" sUnits(0) = "kJ/kg-K" wUnits(0) = "m/s" visUnits(0) = "uPa-s" tcxUnits(0) = "mW/m-K" stUnits(0) = "mN/m" 'Default units but with K switched to C (SI with C) (SIwithC) or (C) tUnits(5) = "C" taUnits(5) = "K" pUnits(5) = "MPa" dUnits(5) = "kg/m^3" vUnits(5) = "m^3/kg" hUnits(5) = "kJ/kg" sUnits(5) = "kJ/kg-K" wUnits(5) = "m/s" visUnits(5) = "uPa-s" tcxUnits(5) = "mW/m-K" stUnits(5) = "mN/m" 'Default units on a molar basis (Molar SI) tUnits(6) = "K" taUnits(6) = "K" pUnits(6) = "MPa" dUnits(6) = "mol/dm^3" vUnits(6) = "dm^3/mol" hUnits(6) = "J/mol" sUnits(6) = "J/mol-K" wUnits(6) = "m/s" visUnits(6) = "uPa-s" tcxUnits(6) = "mW/m-K" stUnits(6) = "mN/m" 'mks (mks) tUnits(1) = "K" taUnits(1) = "K" pUnits(1) = "kPa" dUnits(1) = "kg/m^3" vUnits(1) = "m^3/kg" hUnits(1) = "kJ/kg" sUnits(1) = "kJ/kg-K" wUnits(1) = "m/s" visUnits(1) = "uPa-s" tcxUnits(1) = "W/m-K" stUnits(1) = "mN/m" 'cgs (cgs) tUnits(2) = "K" taUnits(2) = "K" pUnits(2) = "MPa" dUnits(2) = "g/cm^3" vUnits(2) = "cm^3/g" hUnits(2) = "J/g" sUnits(2) = "J/g-K" wUnits(2) = "cm/s" visUnits(2) = "uPa-s" tcxUnits(2) = "mW/m-K" stUnits(2) = "dyn/cm" 'English (E) tUnits(3) = "F" 'See comments above taUnits(3) = "R" pUnits(3) = "psia" dUnits(3) = "lbm/ft^3" vUnits(3) = "ft^3/lbm" hUnits(3) = "Btu/lbm" sUnits(3) = "Btu/lbm-R" wUnits(3) = "ft/s" visUnits(3) = "lbm/ft-s" tcxUnits(3) = "Btu/h-ft-F" stUnits(3) = "lbf/ft" 'Molar English (molar E) tUnits(7) = "F" taUnits(7) = "R" pUnits(7) = "psia" dUnits(7) = "lbmol/ft^3" vUnits(7) = "ft^3/lbmol" hUnits(7) = "Btu/lbmol" sUnits(7) = "Btu/lbmol-R" wUnits(7) = "ft/s" visUnits(7) = "lbm/ft-s" tcxUnits(7) = "Btu/h-ft-F" stUnits(7) = "lbf/ft" 'Mixed (Mixed) tUnits(4) = "K" taUnits(4) = "K" pUnits(4) = "psia" dUnits(4) = "g/cm^3" vUnits(4) = "cm^3/g" hUnits(4) = "J/g" sUnits(4) = "J/g-K" wUnits(4) = "m/s" visUnits(4) = "uPa-s" tcxUnits(4) = "mW/m-K" stUnits(4) = "mN/m" 'Mechanical Engineering units (MEUNITS) tUnits(9) = "C" taUnits(9) = "K" pUnits(9) = "bar" dUnits(9) = "g/cm^3" vUnits(9) = "cm^3/g" hUnits(9) = "J/g" sUnits(9) = "J/g-K" wUnits(9) = "cm/s" visUnits(9) = "centipoise" tcxUnits(9) = "mW/m-K" End Sub Function ConvertUnits(InpCode, Units, Prop1, Prop2) Dim i As Integer, at As String, bt As String, tConv As Double If IsMissing(InpCode) Then InpCode = "" If IsMissing(Units) Then Units = "" If IsMissing(Prop1) Then Prop1 = 0 If IsMissing(Prop2) Then Prop2 = 0 If ierr > 0 Or ierr = -16 Then ConvertUnits = Trim2(herr): Exit Function If tUnits2 = "" Then Call SetupUnits(0) 'If Default units are changed, this needs to be called again. Normally it is skipped after the first entry End If 'Change the 0 in the following line to 3 for default English units, 1 for mks, or 2 for cgs, etc. DefaultUnits = 0 i = -1 'Do not change the order of the next block of statements If UCase(Units) = "SI" Then i = 0 'SI If UCase(Units) = "SI WITH C" Or UCase(Units) = "SIWITHC" Then i = 5 'SI with C If UCase(Units) = "C" Then i = 5 'SI with C If Left(UCase(Units), 3) = "MIX" Then i = 4 'Mixed If UCase(Units) = "MOLAR SI" Then i = 6 'Molar SI If UCase(Units) = "MOLARSI" Then i = 6 'Molar SI If UCase(Units) = "MKS" Then i = 1 'mks If UCase(Units) = "CGS" Then i = 2 'cgs If Left(UCase(Units), 1) = "E" Then i = 3 'English If UCase(Units) = "MOLAR E" Then i = 7 'Molar English If UCase(Units) = "MEUNITS" Then i = 9 'Mechanical Engineering units If i = -1 Then If Units = "" Then i = DefaultUnits Else ierr = 1 herr = "Invalid Units" Exit Function End If End If DefUnit = i at = UCase(Left(InpCode, 1)) bt = UCase(Mid(InpCode, 2, 1)) molmass = 1 If InStr(LCase(dUnits(i)), "mol") = 0 Then molmass = 2 If at = "-" Then ConvertUnits = Prop1 If Prop1 >= -9999999 And Prop1 <= -9999900 Then If Prop1 = CLng(Prop1) Then ConvertUnits = Trim2("Undefined") Exit Function End If End If 'If Len(Trim(Prop1)) > 0 Then If bt = "T" Then ConvertUnits = UnitConvert(Prop1, "T", tUnits2, tUnits(i)) If bt = "A" Then ConvertUnits = UnitConvert(Prop1, "T", taUnits2, taUnits(i)) If bt = "P" Then ConvertUnits = UnitConvert(Prop1, "P", pUnits2, pUnits(i)) If bt = "D" Then ConvertUnits = UnitConvert(Prop1, "D", dUnits2, dUnits(i)) If bt = "V" Then ConvertUnits = UnitConvert(Prop1, "D", vUnits2, vUnits(i)) If bt = "H" Or bt = "E" Then ConvertUnits = UnitConvert(Prop1, "H", hUnits2, hUnits(i)) If bt = "S" Then ConvertUnits = UnitConvert(Prop1, "S", sUnits2, sUnits(i)) If bt = "W" Then ConvertUnits = UnitConvert(Prop1, "W", wUnits2, wUnits(i)) If bt = "U" Then ConvertUnits = UnitConvert(Prop1, "U", visUnits2, visUnits(i)) If bt = "K" Then ConvertUnits = UnitConvert(Prop1, "K", tcxUnits2, tcxUnits(i)) If bt = "N" Then ConvertUnits = UnitConvert(Prop1, "N", stUnits2, stUnits(i)) 'End If If bt = "J" Then tConv = 1 If tUnits(i) = "R" Or tUnits(i) = "F" Then tConv = 1 / RtoK ConvertUnits = Prop1 * tConv / UnitConvert(1, "P", "kPa", pUnits(i)) End If If bt = "I" Then 'convert cm^2/s to ft^2/s If i = 3 Or i = 7 Then ConvertUnits = Prop1 * UnitConvert(1, "A", "cm^2", "ft^2") End If End If Else If Len(Trim(Prop1)) > 0 Then If at = "T" Then Prop1 = UnitConvert(Prop1, "T", tUnits(i), tUnits2) If at = "A" Then Prop1 = UnitConvert(Prop1, "T", taUnits(i), taUnits2) If at = "P" Then Prop1 = UnitConvert(Prop1, "P", pUnits(i), pUnits2) If at = "D" Then Prop1 = UnitConvert(Prop1, "D", dUnits(i), dUnits2) If at = "V" Then Prop1 = UnitConvert(Prop1, "D", vUnits(i), vUnits2) If at = "H" Or at = "E" Then Prop1 = UnitConvert(Prop1, "H", hUnits(i), hUnits2) If at = "S" Then Prop1 = UnitConvert(Prop1, "S", sUnits(i), sUnits2) If at = "W" Then Prop1 = UnitConvert(Prop1, "W", wUnits(i), wUnits2) If at = "U" Then Prop1 = UnitConvert(Prop1, "U", visUnits(i), visUnits2) If at = "K" Then Prop1 = UnitConvert(Prop1, "K", tcxUnits(i), tcxUnits2) If at = "N" Then Prop1 = UnitConvert(Prop1, "N", stUnits(i), stUnits2) End If If Len(Trim(Prop2)) > 0 Then If bt = "T" Then Prop2 = UnitConvert(Prop2, "T", tUnits(i), tUnits2) If bt = "A" Then Prop2 = UnitConvert(Prop2, "T", taUnits(i), taUnits2) If bt = "P" Then Prop2 = UnitConvert(Prop2, "P", pUnits(i), pUnits2) If bt = "D" Then Prop2 = UnitConvert(Prop2, "D", dUnits(i), dUnits2) If bt = "V" Then Prop2 = UnitConvert(Prop2, "D", vUnits(i), vUnits2) If bt = "H" Or bt = "E" Then Prop2 = UnitConvert(Prop2, "H", hUnits(i), hUnits2) If bt = "S" Then Prop2 = UnitConvert(Prop2, "S", sUnits(i), sUnits2) If bt = "W" Then Prop2 = UnitConvert(Prop2, "W", wUnits(i), wUnits2) If bt = "U" Then Prop2 = UnitConvert(Prop2, "U", visUnits(i), visUnits2) If bt = "K" Then Prop2 = UnitConvert(Prop2, "K", tcxUnits(i), tcxUnits2) If bt = "N" Then Prop2 = UnitConvert(Prop2, "N", stUnits(i), stUnits2) End If End If End Function Function FluidString(Nmes, Comps, Optional massmole As String) As String Dim a As String, i As Integer, ncalc As Integer, sum As Double ncalc = 0 If Nmes.Count <> Comps.Count Then If Nmes.Count <> Comps.Count + 1 Then FluidString = "Number of fluid names and compositions not the same": Exit Function Else ncalc = 1 'Calculate missing composition (in last spot only) End If End If a = "" sum = 0 For i = 1 To Nmes.Count If Nmes(i) <> "" Then If i = Nmes.Count And ncalc = 1 Then If sum < 0 Or sum > 1 Then FluidString = "Sum must be less than 1 to calculate final composition.": Exit Function a = a & Nmes(i) & ";" & (1 - sum) & ";" 'Compositions must be given in fractions, not percent ElseIf Comps(i) > 0 Then sum = sum + Comps(i) a = a & Nmes(i) & ";" & Comps(i) & ";" End If End If Next Do While Right(a, 1) = ";" a = Left(a, Len(a) - 1) Loop FluidString = a If massmole = "" Or LCase(Left(massmole, 3)) = "mol" Or LCase(Right(massmole, 3)) = "mol" Then FluidString = a Else FluidString = a & " mass" End If End Function Sub ChDirUNC(ByVal sPath As String) If Left(sPath, 2) = "\\" Then 'Change to a UNC Directory Dim lReturn As Long 'Call the API function to set the current directory lReturn = SetCurDir(sPath) 'A zero return value means an error If lReturn = 0 Then Err.Raise vbObjectError + 1, "Error setting path. In Excel, under Tools, Options, General, change your 'Default File Location' to a local directory." Exit Sub End If Else ChDrive sPath ChDir sPath End If End Sub Function WorkBookName() WorkBookName = ThisWorkbook.FullName 'returns Path+Name of this file End Function Function WhereIsWorkbook() WhereIsWorkbook = ActiveWorkbook.FullName 'returns Path+Name of "Present and Active" File. End Function Function WhereAreREFPROPfunctions() WhereAreREFPROPfunctions = "Using REFPROP.xla functions" End Function Function SeeFileLinkSources() SeeFileLinkSources = ActiveWorkbook.LinkSources End Function Function PropertyUnits(InpCode, Units) Dim d1 As Double, d2 As Double, mmunits As String, molunits As String, massunits As String, kvunits As String PropertyUnits = "" ierr = 0 d1 = 1 d2 = 1 Call ConvertUnits("PD", Units, d1, d2) If UCase(InpCode) = "T" Then PropertyUnits = tUnits(DefUnit) If UCase(InpCode) = "P" Then PropertyUnits = pUnits(DefUnit) If UCase(InpCode) = "D" Then PropertyUnits = dUnits(DefUnit) If UCase(InpCode) = "V" Then PropertyUnits = vUnits(DefUnit) If UCase(InpCode) = "H" Then PropertyUnits = hUnits(DefUnit) If UCase(InpCode) = "E" Then PropertyUnits = hUnits(DefUnit) If UCase(InpCode) = "S" Then PropertyUnits = sUnits(DefUnit) If UCase(InpCode) = "W" Then PropertyUnits = wUnits(DefUnit) If UCase(InpCode) = "U" Then PropertyUnits = visUnits(DefUnit) If UCase(InpCode) = "K" Then PropertyUnits = tcxUnits(DefUnit) If UCase(InpCode) = "N" Then PropertyUnits = stUnits(DefUnit) If UCase(InpCode) = "Z" Then PropertyUnits = "-" If UCase(InpCode) = "B" Then PropertyUnits = vUnits(DefUnit) massunits = "g" molunits = "mol" kvunits = "cm^2/s" If Left(dUnits(DefUnit), 2) = "lb" Then massunits = "lbm" molunits = "lbmol" kvunits = "ft^2/s" End If mmunits = molunits If molmass = 2 Then mmunits = massunits If UCase(InpCode) = "TEMPERATURE" Then PropertyUnits = tUnits(DefUnit) If UCase(InpCode) = "PRESSURE" Then PropertyUnits = pUnits(DefUnit) If UCase(InpCode) = "DENSITY" Then PropertyUnits = dUnits(DefUnit) If UCase(InpCode) = "VOLUME" Then PropertyUnits = vUnits(DefUnit) If UCase(InpCode) = "ENTHALPY" Then PropertyUnits = hUnits(DefUnit) If UCase(InpCode) = "ENERGY" Then PropertyUnits = hUnits(DefUnit) If UCase(InpCode) = "ENTROPY" Then PropertyUnits = sUnits(DefUnit) If UCase(InpCode) = "SPEED OF SOUND" Then PropertyUnits = wUnits(DefUnit) If UCase(InpCode) = "SECOND VIRIAL" Then PropertyUnits = vUnits(DefUnit) If UCase(InpCode) = "VISCOSITY" Then PropertyUnits = visUnits(DefUnit) If UCase(InpCode) = "THERMAL CONDUCTIVITY" Then PropertyUnits = tcxUnits(DefUnit) If UCase(InpCode) = "KINEMATIC VISCOSITY" Then PropertyUnits = kvunits If UCase(InpCode) = "THERMAL DIFFUSIVITY" Then PropertyUnits = kvunits If UCase(InpCode) = "SURFACE TENSION" Then PropertyUnits = stUnits(DefUnit) If UCase(InpCode) = "EXPANSIVITY" Then PropertyUnits = "1/" + taUnits(DefUnit) If UCase(InpCode) = "COMPRESSIBILITY" Then PropertyUnits = "1/" + pUnits(DefUnit) If UCase(InpCode) = "JOULE THOMSON" Then PropertyUnits = taUnits(DefUnit) + "/" + pUnits(DefUnit) If UCase(InpCode) = "DPDD" Then PropertyUnits = pUnits(DefUnit) + "/(" + dUnits(DefUnit) + ")" If UCase(InpCode) = "DPDD2" Then PropertyUnits = pUnits(DefUnit) + "/(" + dUnits(DefUnit) + ")^2" If UCase(InpCode) = "DPDT" Then PropertyUnits = pUnits(DefUnit) + "/" + taUnits(DefUnit) If UCase(InpCode) = "DDDT" Then PropertyUnits = "(" + dUnits(DefUnit) + ")/" + taUnits(DefUnit) If UCase(InpCode) = "DHDT" Then PropertyUnits = "(" + hUnits(DefUnit) + ")/" + taUnits(DefUnit) If UCase(InpCode) = "DHDP" Then PropertyUnits = "(" + hUnits(DefUnit) + ")/" + pUnits(DefUnit) If UCase(InpCode) = "DHDD" Then PropertyUnits = "(" + hUnits(DefUnit) + ")/(" + dUnits(DefUnit) + ")" If UCase(InpCode) = "COMPRESSIBILITY FACTOR" Then PropertyUnits = "dimLess" If UCase(InpCode) = "COEFFICIENT" Then PropertyUnits = "dimLess" If UCase(InpCode) = "PRANDTL" Then PropertyUnits = "dimLess" If UCase(InpCode) = "DIELECTRIC CONSTANT" Then PropertyUnits = "dimLess" If UCase(InpCode) = "MOLE FRACTION" Then PropertyUnits = molunits + "/" + molunits If UCase(InpCode) = "MASS FRACTION" Then PropertyUnits = massunits + "/" + massunits If UCase(InpCode) = "MOLAR MASS" Then PropertyUnits = massunits + "/" + molunits 'If UCase(InpCode) = "MOLAR QUALITY" Then PropertyUnits = molunits + "/" + molunits 'If UCase(InpCode) = "MASS QUALITY" Then PropertyUnits = massunits + "/" + massunits If UCase(InpCode) = "MOLAR QUALITY" Then PropertyUnits = "MoleFr.Vaporized" If UCase(InpCode) = "MASS QUALITY" Then PropertyUnits = "MassFr.Vaporized" If UCase(InpCode) = "QUALITY" Then PropertyUnits = "MoleFr.Vaporized" If molmass = 2 Then PropertyUnits = "MassFr.Vaporized" End If If UCase(InpCode) = "FLUID STRING" Then PropertyUnits = "name(i),molefract(i)" End Function Function SelectedDefaultUnits() Dim d1 As Double, d2 As Double, Units As String ierr = 0 d1 = 1 d2 = 1 Call ConvertUnits("PD", Units, d1, d2) If DefaultUnits = 0 Then SelectedDefaultUnits = "SI" If DefaultUnits = 1 Then SelectedDefaultUnits = "MKS" If DefaultUnits = 2 Then SelectedDefaultUnits = "CGS" If DefaultUnits = 3 Then SelectedDefaultUnits = "E" If DefaultUnits = 4 Then SelectedDefaultUnits = "MIXED" If DefaultUnits = 5 Then SelectedDefaultUnits = "SI WITH C" If DefaultUnits = 6 Then SelectedDefaultUnits = "MOLAR SI" If DefaultUnits = 7 Then SelectedDefaultUnits = "MOLAR E" If DefaultUnits = 9 Then SelectedDefaultUnits = "MEUNITS" End Function Function RefpropXLSVersionNumber() RefpropXLSVersionNumber = "9.1" End Function Function RefpropDLLVersionNumber() Dim nc2 As Long nc2 = -1 Call SETUPdll(nc2, hfld, hfmix, hrf, ierr, herr, 10000&, 255&, 3&, 255&) RefpropDLLVersionNumber = ierr / 10000 If ierr = 900 Then RefpropDLLVersionNumber = 9 End Function