usnistgov / REFPROP-wrappers

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

Problems using Python Wrapper with MATLAB #461

Closed Mandre0815 closed 6 months ago

Mandre0815 commented 2 years ago

Description

We are having a few issues with the Python wrapper for MATLAB. We are running version 10.0 (no additional numbers) of REFPROP. We can get calculations to populate once. However, I have to change back to water and switch back to the R410A fluid if I want to run another calculation, or restart MATLAB entirely. Also, we are finding the calculation results outside of the dome (not under) to be incorrect. Is this a known problem? Furthermore, any issues using H and S to call for T?

Code that gives erroneous results

>> RP = py.ctREFPROP.ctREFPROP.REFPROPFunctionLibrary('C:\Program Files (x86)\REFPROP');
>> MASSSI = RP.GETENUMdll(int8(0),'MASS SI').iEnum;
>> iMass = int8(1);
>> iFlag = int8(0);
>> z = {1};
>> r = RP.REFPROPdll('R410A.MIX','HS','T',MASSSI,iMass,iFlag,458.9315423,1.84959625,z);
>> o = double(r.Output);
>> o(1)

The output answer is: 361.3307 K The correct/expected answer: 329.9325453 K

Versions

REFPROP Version: 10 Operating System and Version: Windows 10 Access Method: Python Wrapper for MATLAB

ianhbell commented 2 years ago

Have you tried to set z = {0}?

Also, have you tried to set iFlag to 1 (to enable the saturation splines)?

Mandre0815 commented 2 years ago

I just tried setting those parameters but it still did not work and gave the same answer as before.

On Tue, Jun 7, 2022 at 6:54 PM Ian Bell @.***> wrote:

Have you tried to set z = {0}?

Also, have you tried to set iFlag to 1 (to enable the saturation splines)?

— Reply to this email directly, view it on GitHub https://github.com/usnistgov/REFPROP-wrappers/issues/461#issuecomment-1149249930, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZQ63MCNWDL2JFIXEGLL72LVN7HLBANCNFSM5YEQX3FA . You are receiving this because you authored the thread.Message ID: @.***>

ianhbell commented 2 years ago

I think this might be a reference state problem. It is always recommended to start from a given temperature and pressure, (or other properties that do not have reference state issues), calculate enthalpy and entropy, and then from those back-calculate.

Reference states are particularly tricky for mixtures.

Mandre0815 commented 2 years ago

We tested that by using temperature and pressure to calculate enthalpy (using values that we had already previously obtained) and the output result was slightly higher than our anticipated value. The output answer was: 460.1454 kJ/kg The expected answer was: 458.9315423 kJ/kg Even if these answers are relatively close, we would need to find a different way to calculate the various parameters that are needed and then we would still be unsure whether or not these answers are correct. We are in a state where enthalpy and entropy are what we are starting with. Also, we are not sure we understand what you mean by back-calculations in this case.

On Wed, Jun 8, 2022 at 2:49 PM Ian Bell @.***> wrote:

I think this might be a reference state problem. It is always recommended to start from a given temperature and pressure, (or other properties that do not have reference state issues), calculate enthalpy and entropy, and then from those back-calculate.

Reference states are particularly tricky for mixtures.

— Reply to this email directly, view it on GitHub https://github.com/usnistgov/REFPROP-wrappers/issues/461#issuecomment-1150273242, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZQ63MFVIYG2JG2Y764X6XTVODTLRANCNFSM5YEQX3FA . You are receiving this because you authored the thread.Message ID: @.***>

ianhbell commented 2 years ago

A particular value of enthalpy is only meaningful if the same reference state is used. Are you sure that you have the same reference state for all calculations?

That said, there are known issues with HS inputs; they are among the most challenging pair of inputs because neither is an independent variable of the EOS.