usnistgov / REFPROP-wrappers

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

Binary Pairs Mixing Data #540

Closed Alhabeeb86 closed 6 months ago

Alhabeeb86 commented 1 year ago

You know R452A is a mixture of R32 , R125 and R1234yf. When I copy R452A.mix from Refprop10 to Refprop9.1 it worked but Refprop showed me a warning message that " no mixture data are available for one or more binary pairs ...". Thus, I copy HMX.BNC from Refprop10 to 9.1, but the warning still appears. How can I solve this problem? BTY, the interface of MATLAB does not work properly with Refprop10 that is why I have to use Refprop 9.1.

ianhbell commented 1 year ago

The REFPROP 10 HMX.BNC is not backwards compatible with 9.1. Better to update your MATLAB interface to the REFPROP 10 via python. That seems to work quite reliably.

ianhbell commented 1 year ago

https://github.com/usnistgov/REFPROP-wrappers/tree/master/wrappers/MATLAB

Alhabeeb86 commented 1 year ago

Thanks a lot. Now I have Python interface for Matlab using Refprop 10. Is there a simple syntax to calculate a property like refpropm? Because I didn't fully understand this syntax:

MOLSI = RP.GETENUMdll(int8(1),'MOLAR BASE SI').iEnum; iMass = int8(0); % 0: molar fractions; 1: mass fractions iFlag = int8(0); % 0: don't call SATSPLN; 1: call SATSPLN z = {1.0}; % mole fractions, here a pure fluid, so mole fraction of 1.0 r = RP.REFPROPdll('Water','PQ','T',MOLSI,iMass,iFlag,101325,0.0,z)

Alhabeeb86 commented 1 year ago

When I replace water by a mixture, it works just for the first time and when I just repeat the calculation it returns with -9999990?

ianhbell commented 1 year ago

REFPROPdll works much like refpropm. Please read the docs: https://refprop-docs.readthedocs.io/en/latest/DLL/high_level.html#f/_/REFPROPdll

Alhabeeb86 commented 1 year ago

Thanks a lot, but is there a direct syntax to find the output property rather than , for example: 1- r = RP.REFPROPdll('CO2;R32;R1234yf','PQ','T',MOLSI,iMass,iFlag,101325,0.0,z); 2- rr=double(r.Output); 3- T=rr(1); Is there a way to use just one syntax rather than three syntaxes

ianhbell commented 1 year ago

double(RP.REFPROPdll('CO2;R32;R1234yf','PQ','T',MOLSI,iMass,iFlag,101325,0.0,z).Output)(1);

Alhabeeb86 commented 1 year ago

My syntaxes: clear; clc; RP = py.ctREFPROP.ctREFPROP.REFPROPFunctionLibrary('C:\Program Files (x86)\REFPROP'); MOLSI = RP.GETENUMdll(int8(1),'MOLAR BASE SI').iEnum; iMass = int8(1); % 0: molar fractions; 1: mass fractions iFlag = int8(1); % 0: don't call SATSPLN; 1: call SATSPLN z = {0.03 0.215 0.755}; % mole fractions, here a pure fluid, so mole fraction of 1.0 T=double(RP.REFPROPdll('CO2;R32;R1234yf','PQ','T',MOLSI,iMass,iFlag,101325,0.0,z).Output)(1); But the code didn't work the error message was:

RefpropPy Error: File: RefpropPy.m Line: 7 Column: 3 Indexing with parentheses '()' must appear as the last operation of a valid indexing expression.

ianhbell commented 1 year ago

This is a MATLAB problem, not related to REFPROP

Alhabeeb86 commented 1 year ago

Ok. How can I set the output unit like follow: Temperature (K) Pressure (kPa) density (kg/m^3) enthalpy (J/kg) entropy (J/kg k) Thanks

ianhbell commented 1 year ago

You can use custom units (read the docs), but I strongly advise against it. I would recommend you use mass-based SI units, which would be:

RP.MASS_BASE_SI

in your example code. Complete:

clear; clc;
RP = py.ctREFPROP.ctREFPROP.REFPROPFunctionLibrary('C:\Program Files (x86)\REFPROP');
MASSSI = RP.MASS_BASE_SI;
iMass = int8(1); % 0: molar fractions; 1: mass fractions
iFlag = int8(1); % 0: don't call SATSPLN; 1: call SATSPLN
z = {0.03 0.215 0.755}; % mole fractions, here a pure fluid, so mole fraction of 1.0
T=double(RP.REFPROPdll('CO2;R32;R1234yf','PQ','T',MASSSI,iMass,iFlag,101325,0.0,z).Output)(1);