Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reference state not correctly applied for mixtures #711

Closed
ianhbell opened this issue Dec 16, 2024 · 1 comment
Closed

Reference state not correctly applied for mixtures #711

ianhbell opened this issue Dec 16, 2024 · 1 comment

Comments

@ianhbell
Copy link
Contributor

ianhbell commented Dec 16, 2024

From #710: The setting of reference states does not work correctly when fluid names are passed to the REFPROP function. The reference state is not set. Example:

import os 
import ctREFPROP.ctREFPROP as ct 

root = '/Users/ihb/REFPROP10'
assert(os.path.exists(root))
RP = ct.REFPROPFunctionLibrary(root+'/librefprop.dylib')
RP.SETPATHdll(root)

res = RP.REFPROPdll("", "FLAGS", "SETREF", 0, 0, 2, 0, 0, [])
print(res.ierr, res.herr)
assert(res.ierr == 0)

r0 = RP.REFPROPdll("R32;R125|0.3;0.7", "PS", "H", RP.MOLAR_SI, 0, 0, 10, 110, [])
r1 = RP.REFPROPdll("R32;R125|0.3;0.7", "PS", "H", RP.MOLAR_SI, 0, 0, 10, 110, [])
print('expected value of 23643.99395000000004075 ')
print(r0.Output[0], r1.Output[0], r1.herr, r0.herr)

yielding

expected value of 23643.99395000000004075 
23643.993946887913 -9999990.0 [PSFLSH error 248] Single-phase iteration did not converge for P = 10.0000 MPa and S = 110.000 J/mol-K. 

so the first call is ok, the second one is not. Calling SETREF again in between the calls helps:

import os 
import ctREFPROP.ctREFPROP as ct 

root = '/Users/ihb/REFPROP10'
assert(os.path.exists(root))
RP = ct.REFPROPFunctionLibrary(root+'/librefprop.dylib')
RP.SETPATHdll(root)

res = RP.REFPROPdll("", "FLAGS", "SETREF", 0, 0, 2, 0, 0, [])
print(res.ierr, res.herr)
assert(res.ierr == 0)

r0 = RP.REFPROPdll("R32;R125|0.3;0.7", "PS", "H", RP.MOLAR_SI, 0, 0, 10, 110, [])
res = RP.REFPROPdll("", "FLAGS", "SETREF", 0, 0, 2, 0, 0, [])
r1 = RP.REFPROPdll("R32;R125|0.3;0.7", "PS", "H", RP.MOLAR_SI, 0, 0, 10, 110, [])
print('expected value of 23643.99395000000004075 ')
print(r0.Output[0], r1.Output[0], r1.herr, r0.herr)

yielding the correct answer of

0 
expected value of 23643.99395000000004075 
23643.993946887913 23643.993946887913  

but the second SETREF should not be required because the flag is supposed to stay on:
image

@ianhbell ianhbell added this to the 10.1 milestone Dec 16, 2024
@ianhbell
Copy link
Contributor Author

Breaking up the steps works in all versions:

import os 
import ctREFPROP.ctREFPROP as ct 

root = '/Users/ihb/REFPROP10'
assert(os.path.exists(root))
RP = ct.REFPROPFunctionLibrary(root+'/librefprop.dylib')
RP.SETPATHdll(root)

print(RP.FLAGSdll("SETREF", 999))

z = [0.3, 0.7]
RP.SETFLUIDSdll("R32*R125")
RP.SETREFdll('',2,z,-1,-1,-1,-1)
r0 = RP.REFPROPdll("", "PS", "H", RP.MOLAR_SI, 0, 0, 10, 110, z)
r1 = RP.REFPROPdll("", "PS", "H", RP.MOLAR_SI, 0, 0, 10, 110, z)

print('expected value of 23643.99395000000004075 ')
print(r0.Output[0], r1.Output[0], r1.herr, r0.herr)

yielding

FLAGSdlloutput(kFlag=0, ierr=0, herr='')
expected value of 23643.99395000000004075 
23643.993946887913 23643.993946887913  

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant