usnistgov / REFPROP-issues

A repository solely used for reporting issues with NIST REFPROP
26 stars 13 forks source link

Temperature of water with input P & h #435

Closed JosvantWestende closed 3 years ago

JosvantWestende commented 3 years ago

I am computing the temperature of water with pressure and enthalpy as input. For some conditions, however, I get very strange results with the python wrapper:

composition = ["Water"] z = [1] iMass = 0 # composition input-flag: 0: mole based, 1: mass based RP.SETFLUIDSdll('*'.join(composition)) RP.SATSPLNdll(z) P = 19.5e5 h = 22500. T1 = RP.REFPROPdll('', 'PH', 'T', RP.MASS_BASE_SI, iMass, 0, P, h, z).Output[0] h = 22958. T2 = RP.REFPROPdll('', 'PH', 'T', RP.MASS_BASE_SI, iMass, 0, P, h, z).Output[0] h = 22500. T3 = RP.REFPROPdll('', 'PH', 'T', RP.MASS_BASE_SI, iMass, 0, P, h, z).Output[0]

T1 and T3 give about 278K, but T2 is about 202K (also the density and viscosity are wrongly computed) T3 is computed as a check

running with the Refprop GUI or with the Matlab wrapper does not give these issues. comp = {'WATER' 18.015268}; nc = 1; massfrac = [1]; refpropm('T','P',1950,'H',22958,nc,comp,massfrac,BasePath) --> 278.1500 --> OK refpropm('T','P',1950,'H',22500,nc,comp,massfrac,BasePath) --> 278.0408 --> OK

ianhbell commented 3 years ago

Please provide complete & runnable examples (copy-pastable). What happens if you turn off SATSPLNdll call?

ianhbell commented 3 years ago

I did a sanity check with CoolProp and it gives the answers that you expect:

import CoolProp.CoolProp as CP
P = 19.5e5
for h in [22500, 22958, 22500]:
    print(h, CP.PropsSI('T','P',P,'Hmass',h,'Water'))

yields

22500 278.0408399946095
22958 278.14995827343654
22500 278.0408399946095
JosvantWestende commented 3 years ago

Dear Ian,

Below is my complete python script. Switching on/off SATSPLN does not matter. Setting iMass 0 or 1 also does not matter.

from ctREFPROP.ctREFPROP import REFPROPFunctionLibrary

BasePath = os.environ['RPPREFIX']
RP = REFPROPFunctionLibrary(BasePath)
RP.SETPATHdll(BasePath)

composition = ["Water"]
z = [1]
iMass = 0  # composition input-flag: 0: mole based, 1: mass based
RP.SETFLUIDSdll('*'.join(composition))
RP.SATSPLNdll(z)
print(f"Pc %3.2f bara - Hc %3.2f kJ/kg" %(Pc/1e5, Hc/1e3))
P = 19.5e5
h = 22500.
T1 = RP.REFPROPdll('', 'PH', 'T', RP.MASS_BASE_SI, iMass, 0, P, h, z).Output[0]
h = 22958.
T2 = RP.REFPROPdll('', 'PH', 'T', RP.MASS_BASE_SI, iMass, 0, P, h, z).Output[0]
h = 22500.
T3 = RP.REFPROPdll('', 'PH', 'T', RP.MASS_BASE_SI, iMass, 0, P, h, z).Output[0]
ianhbell commented 3 years ago

I cannot reproduce this behavior. On my side, I have:

import os
from ctREFPROP.ctREFPROP import REFPROPFunctionLibrary
root = os.environ['RPPREFIX']
RP = REFPROPFunctionLibrary(root)
print(RP.RPVersion())
composition = ["Water"]
z = [1]
iMass = 0 # composition input-flag: 0: mole based, 1: mass based
RP.SETFLUIDSdll('*'.join(composition))
RP.SATSPLNdll(z)
P = 19.5e5
h = 22500.
T1 = RP.REFPROPdll('', 'PH', 'T', RP.MASS_BASE_SI, iMass, 0, P, h, z).Output[0]
h = 22958.
T2 = RP.REFPROPdll('', 'PH', 'T', RP.MASS_BASE_SI, iMass, 0, P, h, z).Output[0]
h = 22500.
T3 = RP.REFPROPdll('', 'PH', 'T', RP.MASS_BASE_SI, iMass, 0, P, h, z).Output[0]    
print(T1,T2,T3)

yielding

10.0.0.02
278.0408399949868 278.1499582735628 278.0408399949868
ianhbell commented 3 years ago

What version of REFPROP do you use? Operating system?

JosvantWestende commented 3 years ago

print(RP.RPVersion()) --> 10.0 OS: windows 10

JosvantWestende commented 3 years ago

I have rebooted my computer and hereafter copied the code you used (to be sure there are no typos), but I still get:

10.0 278.0408399949868 202.06249166264436 278.0408399949868

ianhbell commented 3 years ago

So weird. What version of Python? And what version of ctREFPROP?

JosvantWestende commented 3 years ago

Python 3.9.5 (tags/v3.9.5:0a7dcbd, May 3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)] on win32

ctRefprop: 0.9 @.***

ianhbell commented 3 years ago

I very much doubt this is the issue, but can you please update ctREFPROP to 0.10? I'm on python 3.8, let me try with 3.9.

ianhbell commented 3 years ago

Same result on my side with 3.9

JosvantWestende commented 3 years ago

Made new project in Pycharm, installed ctRefprop v 0.10. Copied code. Same wrong results ☹

ianhbell commented 3 years ago

How about outside pycharm, at the command line? Sometimes these IDE can be too helpful, and cause weird issues with shared libraries.

JosvantWestende commented 3 years ago

I tried running in Pycharm as well as in cmd.

Same results for both

ianhbell commented 3 years ago

The only thing I can think is that the difference is 10.0 versus 10.0.0.02

ianhbell commented 3 years ago

Shall we try that tiny bugfix and see if for some reason that makes the difference? You can email me at ian.bell@nist.gov and I'll send the link.

JosvantWestende commented 3 years ago

I did get an alpha and beta version of Eric, some weeks ago. Let me try that first, then.

ianhbell commented 3 years ago

Good, yes please try that

JosvantWestende commented 3 years ago

Alpha version gives: 10.0.0.94 278.0408399949868 278.1499582735628 278.0408399949868

Beta gives: 10.0.0.97 278.0408399949868 278.1499582735628 278.0408399949868

That seems to be the issue. What is the next best step? I don’t know to what extent this alpha and beta version should be used.

ianhbell commented 3 years ago

10.0.0.02 is very stable, there are only a few tiny changes, so I personally always use that version. The alpha and beta are somewhat experimental.

JosvantWestende commented 3 years ago

In that case I would like to get the .02 version.

ianhbell commented 3 years ago

You can email me at ian.bell@nist.gov and I'll send you the link.

ianhbell commented 3 years ago

Fixed by update from 10.0 to 10.0.0.02