usnistgov/REFPROP-cmake

refprop10 issue

birdol opened this issue · 10 comments

follow the step ,build is ok,cmd line show me

[100%] Linking Fortran shared library librefprop.so
[100%] Built target refprop

but when i call from python, i got this hint:

unable to load mixture:R410A.MIX

I have already paste the folder: FLUIDS and MIXTURES into usr/local/lib/ with usr/local/lib/librefprop.so

Please show your Python code. You should have a folder containing your librefprop.so, as well as the FLUIDS and MIXTURES folders. Then you give that folder to whatever interface you use.

from __future__ import print_function
# from debug import *
import sys
import platform
import CoolProp.CoolProp as cp
import json
import math

sysstr = platform.system()
if sysstr == "Windows":
    cp.set_config_string(cp.ALTERNATIVE_REFPROP_PATH, 'c:\\Program Files\\REFPROP\\')
else:
    cp.set_config_string(cp.ALTERNATIVE_REFPROP_PATH, '/usr/local/lib/')


def RefPropsSI(R1='物质名称', Y='none', A='none', a='none', B='none', b='none'):
    fldname = R1
    if ((fldname.startswith('R4') or fldname.startswith('R5')) and fldname.endswith(
            '.MIX') == False and fldname != 'R40' and fldname != 'R41'):
        fldname = fldname + '.MIX'

    fldname = 'REFPROP::' + fldname
    if A == 'none':
        result = cp.PropsSI(fldname, Y)  # PropsSI("Water", "Tcrit") #Tcrit
    else:
        result = cp.PropsSI(Y, A, a, B, b, fldname)  # PropsSI("T", "P", 101325, "Q", 0, "Water")
    return result



if __name__ == "__main__":
    print((RefPropsSI("R410A","H","T",273.15+10,"X",0.1)))

result follow


[root@VM_0_13_centos api]# python api2.py
Traceback (most recent call last):
  File "api2.py", line 40, in <module>
    print((RefPropsSI("R410A","H","T",273.15+10,"X",0.1)))
  File "api2.py", line 34, in RefPropsSI
    result = cp.PropsSI(Y, A, a, B, b, fldname)  # PropsSI("T", "P", 101325, "Q", 0, "Water")
  File "CoolProp/CoolProp.pyx", line 347, in CoolProp.CoolProp.PropsSI
  File "CoolProp/CoolProp.pyx", line 427, in CoolProp.CoolProp.PropsSI
  File "CoolProp/CoolProp.pyx", line 314, in CoolProp.CoolProp.__Props_err2
ValueError: Initialize failed for backend: "REFPROP", fluid: "R410A.MIX" fractions "[ 1.0000000000 ]"; error: Unable to load mixture: R410A.MIX : PropsSI("H","T",283.15,"X",0.1,"REFPROP::R410A.MIX")

QUESTION is resolved,maybe it's a bug for this repo。。。

Before resolved ,the Folder structure
centos python3.x

/root/server/refprop/api/api.py
/usr/local/lib/librefprop.so
/usr/local/lib/MIXTURES
/usr/local/lib/FLUIDS

After resolved ,the Folder structure

/root/server/refprop/api/api.py
/usr/local/lib/librefprop.so
/root/server/refprop/api/MIXTURES
/root/server/refprop/api/FLUIDS

and I make a dll file by netcore,it's also need MIXTURES and FLUIDS with it。

So...Is it my error in operation, or That's the way to do it?

Can you turn on the debugging mode with cp.set_debug_level(100)? It might be informative. The first folder setup you propose is how things should work.

python code

# -*- coding: utf-8 -*-
from __future__ import print_function
# from debug import *
import sys
import platform
import CoolProp.CoolProp as cp
import json
import math

sysstr = platform.system()
if sysstr == "Windows":
    cp.set_config_string(cp.ALTERNATIVE_REFPROP_PATH, 'c:\\Program Files\\REFPROP\\')
else:
    cp.set_config_string(cp.ALTERNATIVE_REFPROP_PATH, '/usr/local/lib/')

cp.set_debug_level(100)

def RefPropsSI(R1='物质名称', Y='none', A='none', a='none', B='none', b='none'):
    fldname = R1
    if ((fldname.startswith('R4') or fldname.startswith('R5')) and fldname.endswith(
            '.MIX') == False and fldname != 'R40' and fldname != 'R41'):
        fldname = fldname + '.MIX'

    fldname = 'REFPROP::' + fldname
    if A == 'none':
        result = cp.PropsSI(fldname, Y)  # PropsSI("Water", "Tcrit") #Tcrit
    else:
        result = cp.PropsSI(Y, A, a, B, b, fldname)  # PropsSI("T", "P", 101325, "Q", 0, "Water")
    return result



if __name__ == "__main__":
    print((RefPropsSI("R410A","H","T",273.15+10,"P",2600000)))
[root@VM_0_13_centos api]# python api2.py
/io/src/CoolProp.cpp:107: backend extracted. backend: REFPROP. fluid: R410A.MIX
AbstractState::factory(REFPROP,[ R410A.MIX ])
AbstractState::factory backend_library size: 7
/io/src/Backends/REFPROP/REFPROPMixtureBackend.cpp:360: Successfully loaded REFPROP fluid: R410A.MIX
/io/src/Backends/REFPROP/REFPROPMixtureBackend.cpp:286: The current fluid can be reused; /usr/local/lib/mixtures/R410A.MIX and /usr/local/lib/mixtures/R410A.MIX match
/io/src/Backends/REFPROP/REFPROPMixtureBackend.cpp:286: The current fluid can be reused; /usr/local/lib/mixtures/R410A.MIX and /usr/local/lib/mixtures/R410A.MIX match
/io/src/Backends/REFPROP/REFPROPMixtureBackend.cpp:286: The current fluid can be reused; /usr/local/lib/mixtures/R410A.MIX and /usr/local/lib/mixtures/R410A.MIX match
AbstractState: keyed_output called for Hmass
_PropsSI will return 216538
216537.81965

debug info show me: /usr/local/lib/mixtures/R410A.MIX

but, if I rename or delete /root/Server/refprop/api/mixtures,it will not work。

[root@VM_0_13_centos api]# python api2.py
/io/src/CoolProp.cpp:107: backend extracted. backend: REFPROP. fluid: R410A.MIX
AbstractState::factory(REFPROP,[ R410A.MIX ])
AbstractState::factory backend_library size: 7
Initialize failed for backend: "REFPROP", fluid: "R410A.MIX" fractions "[ 1.0000000000 ]"; error: Unable to load mixture: R410A.MIX
Traceback (most recent call last):
  File "api2.py", line 34, in <module>
    print((RefPropsSI("R410A","H","T",273.15+10,"P",2600000)))
  File "api2.py", line 28, in RefPropsSI
    result = cp.PropsSI(Y, A, a, B, b, fldname)  # PropsSI("T", "P", 101325, "Q", 0, "Water")
  File "CoolProp/CoolProp.pyx", line 347, in CoolProp.CoolProp.PropsSI
  File "CoolProp/CoolProp.pyx", line 427, in CoolProp.CoolProp.PropsSI
  File "CoolProp/CoolProp.pyx", line 314, in CoolProp.CoolProp.__Props_err2
ValueError: Initialize failed for backend: "REFPROP", fluid: "R410A.MIX" fractions "[ 1.0000000000 ]"; error: Unable to load mixture: R410A.MIX : PropsSI("H","T",283.15,"P",2600000,"REFPROP::R410A.MIX")

What version of CoolProp? I fixed a bug with the case of the FLUIDS and MIXTURES folders (now I recommend you make both uppercase)

Version: CoolProp-6.4.1-cp36-cp36m-manylinux1_x86_64.whl

and the folder on disk is UPPERCASE,cmdline show lowercase....

Can you try with the development version of CoolProp? The case was fixed here: CoolProp/CoolProp@9e5b4da

emm。。。。 so sorry。。。i donot know how to compile those files....