Closed ksat00 closed 8 months ago
You need to also call the SETREFdll function to ensure you get the reference state you want.
I added an explicit call to SETREFdll in the sample code without having any noticeable effect on the results. To add further details, the issue does not appear as prominent for subcooled liquid state. For the subcooled liquid state example in the code segment below, I am getting much closer results from ctREFPROP and REFPROP GUI. Also want to make it clear that these are running on the same computer with the same REFPROP installation.
import os
from ctREFPROP.ctREFPROP import REFPROPFunctionLibrary
RP = REFPROPFunctionLibrary(os.environ['RPPREFIX'])
RP.SETPATHdll(os.environ['RPPREFIX'])
units = RP.GETENUMdll(0,"SI WITH C").iEnum
setref=RP.SETREFdll("IIR",1,[0],0,0,0,0)
print('REFPROP Version:', RP.RPVersion())
Ref = "R513A" #Refrigerant
setref = RP.SETMIXTUREdll(Ref)
PTemp = 0.370 #Pressure in MPa
TTemp = 9.53 #Temperature in °C
print('Superheated state')
print('Input pressure (MPa):', PTemp, 'Input temperature (°C):', TTemp)
hTemp1 = RP.REFPROP1dll("PT","H",units,0,PTemp,TTemp,[1]) #Using simpler REFPROP1dll interface
print('Specific Enthalpy from REFPROP1dll: ',hTemp1.c)
htemp2 = RP.REFPROPdll('', 'PT', 'H', units,0,0,PTemp,TTemp,[1]) #Using full REFPROPdll interface
print('Specific Enthalpy from REFPROPdll: ', htemp2[1][0])
PTemp = 0.370 #Pressure in MPa
TTemp = 3.00 #Temperature in °C
print('Subcooled Liquid State')
print('Input pressure (MPa):', PTemp, 'Input temperature (°C):', TTemp)
hTemp1 = RP.REFPROP1dll("PT","H",units,0,PTemp,TTemp,[1]) #Using simpler REFPROP1dll interface
print('Specific Enthalpy from REFPROP1dll: ',hTemp1.c)
htemp2 = RP.REFPROPdll('', 'PT', 'H', units,0,0,PTemp,TTemp,[1]) #Using full REFPROPdll interface
print('Specific Enthalpy from REFPROPdll: ', htemp2[1][0])
Please make sure you read the docs related to setting of reference state: https://refprop-docs.readthedocs.io/en/latest/DLL/high_level.html#f/_/REFPROPdll (and then search for SETREF within that block)
I can add that, since this is a mixture, there are two ways to do the reference state (even beyond choosing IIR, etc.). Either the convention can be applied for the mixture as a whole, or it can be applied for each individual component. I think the default for which way to do that may be different between the GUI and the DLL. In the GUI, try going into Options, Reference State, and switch the setting of "Apply Reference State to". I think that might resolve the difference you are seeing.
@ianhbell and @nist-aharvey Thank you for your comments and suggestions on setting the reference state for the mixture. Explicitly setting the reference state to DEFAULT ( setting hOut as 'DEF' while calling REFPROPdll with 'SETREF' as hIn) resolved the issue. With this setting, the values returned by ctREFPROP and GUI are identical for both superheated vapor and subcooled liquid in the above cases.
ctREFPROP is returning a different specific enthalpy value for a pre-defined mixture (R513A) using REFPROP 10 when using pressure and temperature as input compared to using the same inputs through REFPROP GUI or Excel VBA REFPROP interface. The default reference state is the same in all cases (IIR reference state). Excel VBA and REFPROP GUI give the same result.
Details
The example below is trying to calculate and print out the specific enthalpy of R513A at 0.370 MPa pressure and 9.53 °C temperature in a Python application. The value for specific enthalpy returned from ctREFPROP (version 0.10.2 from PyPI) with these inputs is 370.89 kJ/kg.
Sample code
#
Output from the code above
Output from REFPROP 10 GUI using the same inputs
The value for specific enthalpy returned using REFPROP 10 GUI and Excel VBA is 383.55 kJ/kg with these same inputs.
Other Observations
There is no difference in return values for specific enthalpy for a pure fluid such as R134a in the same Python code (while using SETFLUIDSdll instead of SETMIXTUREdll). In the case with the pure fluid, the results are the same from ctREFPROP, REFPROP GUI and Excel VBA REFPROP interfaces. Is there an error in how the above code is using ctREFPROP module for calculating predefined mixture properties?