Open veronica-yyc opened 1 year ago
In the beta (email me at ian.bell@nist.gov to get access), this example yields the correct result:
import os
os.environ['RPPREFIX'] = os.getenv('HOME')+'/REFPROP10beta'
import numpy as np
root = os.getenv('RPPREFIX')
import ctREFPROP.ctREFPROP as ct
RP = ct.REFPROPFunctionLibrary(root)
RP.SETPATHdll(root)
MASS_BASE_SI = RP.GETENUMdll(0, "MASS BASE SI").iEnum
RP.SETFLUIDSdll("PROPANE");
z = [1.0]+[0.0]*19
# Do a saturation call at one 273.15 K, check H and S are equal to the
# default reference state (IIR, h = 200 kJ/kg, s = 1 kJ/kg-K for sat. liquid at 0 C)
r = RP.REFPROPdll("PROPANE", "QT", "H;S", MASS_BASE_SI, 0, 0, 0, 273.15, z)
print(r.Output[0:2], ":::::: (should be 200000, 1000)")
# Now we set the reference state to something else, in this case NBP
# with h,s = 0 at normal boiling point (saturated liquid at 1 atmosphere (101325 Pa))
icomp = 1
RP.SETREFdll("NBP", icomp, z, -1,-1,-1,-1) # -1 are placeholders, not needed, but must be passed
# Confirm that we get the right enthalpy and entropy at the reference state
# They should be 0 and 0 for H and S
r = RP.REFPROPdll("PROPANE", "PQ", "H;S", MASS_BASE_SI, 0,0, 101325, 0, z)
print(r.Output[0:2], ":::::: (should be ~0, ~0)")
# Unset the reference state for propane by selecting a new fluid
RP.SETFLUIDSdll("DECANE");
# This should be back to IIR again
r = RP.REFPROPdll("PROPANE", "QT", "H;S", MASS_BASE_SI, 0, 0, 0, 273.15, z)
print(r.Output[0:2], ":::::: (should be 200000, 1000)")
yielding
array('d', [199999.55654680828, 999.9992602411847]) :::::: (should be 200000, 1000)
array('d', [100355.85901674398, 607.0441737657444]) :::::: (should be ~0, ~0)
array('d', [199999.55654680828, 999.9992602411847]) :::::: (should be 200000, 1000)
Description
Utilizing your linked tutorial (which is lovely) link, I noticed that your Reference states example doesn't return the values expected. I believe the author intends to reset the reference state by resetting the fluid, but the reference state does not get reset as expected. Not sure if this is just an outdated example, or if the programming is behaving as expected.
Steps to Reproduce
Expected behavior: [What you expect to happen]
Actual behavior: [What actually happens]
Versions
REFPROP Version: RP.RPVersion() returns '10.0' Operating System and Version: Windows 10 Access Method:
Additional Information