usnistgov / REFPROP-wrappers

Wrappers around NIST REFPROP for languages such as Python, MATLAB, etc.
193 stars 127 forks source link

ABFLSHdll in python #561

Closed coderlover-lang closed 1 year ago

coderlover-lang commented 1 year ago

I'm having some problems calling ABFLSHdll using Python, hope you can help

Description

You can see that I have proportioned a mixture whose components are butane and ethylene respectively. The ratio is 0.6230: 0.3770. I hope to calculate their Liquid density of equilibrium at Q = 0.0895 and the air pressure at P = 113.1 (kPa). phase and Vapor density of equilibrium phase, in the refprop software, I got the results I hoped for, as shown below:

b0b7c4fa0f86d539f3cbc2b50887860

I got Liquid density of equilibrium phase = 646.4373, which is reasonable

But when I try to call in Python using

import os
os.environ['RPPREFIX'] = r'C:/Program Files/REFPROP v10'
from ctREFPROP.ctREFPROP import REFPROPFunctionLibrary

import glob

import pandas

import numpy as np
RP_single = REFPROPFunctionLibrary(os.environ['RPPREFIX'])
RP_single.SETPATHdll(os.environ['RPPREFIX'])
RP_mix = REFPROPFunctionLibrary(os.environ['RPPREFIX'])
RP_mix.SETPATHdll(os.environ['RPPREFIX'])

P7, T7 = (113.1, 184.15)
Ref1='butane'     
Ref2='ethylene'   
P8 = P7 
Z_1 = 0.6230 
Z_2 = 1 - Z_1 
Z = [Z_1, Z_2]
xe = 0.0895
RP_mix.ABFLSHdll("PQ", P8, xe, Z, 1) 

I received Dl=13.493390361545368, Dv=0.0715316355030999, maybe I should change the last parameter iFlag, but I have traveled all the paremeter as possible , I didm't receive the same output as in refprop;

Steps to Reproduce

Actual behavior: [What actually happens]

Versions

REFPROP Version: [v10.0.0.0]
Operating System and Version: [windows 10]
Access Method: [How you are accessing REFPROP ( Python)]

Additional Information

ianhbell commented 1 year ago

Some notes: the way DLL work on windows, RP_mix and RP_single point to the same object.

For mixtures, you should specify Qmass or Qmolar for the vapor quality explictly, so in your case, your inputs should be PQMASS. See also: https://refprop-docs.readthedocs.io/en/latest/DLL/high_level.html