Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Value jumps with PSmass_INPUTS #2319

Open
qmichalski opened this issue Nov 24, 2023 · 2 comments
Open

Value jumps with PSmass_INPUTS #2319

qmichalski opened this issue Nov 24, 2023 · 2 comments

Comments

@qmichalski
Copy link

qmichalski commented Nov 24, 2023

Description

I am getting some weird values/behavior with hydrogen.
I'm setting the problem with TP conditions with 293.15 K and 12.8 bar.
Then calling with PSmass_INPUTS and it misbehaves when close to the critical pressure, although we're far from the critical temperature. It either crash during the root finding process with the HEOS or returns odd temperatures with the cubic HEOS.

Steps to Reproduce

Running with
HEOS = CP.AbstractState('HEOS','Hydrogen')
HEOS.update(CP.PT_INPUTS,1280000.0,293.15)
print(HEOS.smass())
HEOS.update(CP.PSmass_INPUTS,1280000.0,HEOS.smass())
print(HEOS.T())

And then

HEOS = CP.AbstractState('BICUBIC&HEOS','Hydrogen')
HEOS.update(CP.PT_INPUTS,1280000.0,293.15)
print(HEOS.smass())
HEOS.update(CP.PSmass_INPUTS,1280000.0,HEOS.smass())
print(HEOS.T())

EDIT: It does the same thing at 293.15K and
1840000.0 Pa
2280000.0 Pa
2440000.0 Pa
2460000.0 Pa

Expected behavior:

I'd expect the same temperature value +- some small tolerance.

Actual behavior:

The output:

42661.31838031734
Traceback (most recent call last):

Cell In[112], line 4
HEOS.update(CP.PSmass_INPUTS,1280000.0,HEOS.smass())

File CoolProp/AbstractState.pyx:102 in CoolProp.CoolProp.AbstractState.update

File CoolProp/AbstractState.pyx:104 in CoolProp.CoolProp.AbstractState.update

ValueError: unable to solve 1phase PY flash with Tmin=33.0479, Tmax=1500 due to error: solver_rho_Tp was unable to find a solution for T= 33.0479, p= 1.28e+06, with guess value 12445.8 with error: The molar density of -46108.837071 mol/m3 is below the minimum of 0.000000 mol/m3

Now when I run this with the bicubic HEOS approximation, the output is

42661.318399796466
111.05883327180031

Versions

CoolProp Version: '6.5.0'
Operating System and Version: macOS BigSUR 11.5.2
Access Method: Accessing via Python (3.8)

Additional Information

I checked via both coolprop and refprop plots of the entropy/pressure with iso temperature, there are no jumps in those regions.
Also when doing the reverse:

HEOS.update(CP.PT_INPUTS,1280000.0,111.0588)
print(HEOS.smass())
29811.642756672805

The entropy value has nothing to do with the one set in the PSmass_INPUTS inputs.

@qmichalski qmichalski changed the title Weird jumps Value jumps with PSmass_INPUTS Nov 24, 2023
@qmichalski
Copy link
Author

qmichalski commented Nov 24, 2023

I have tried a bit more at 293.15 K and it fails with HEOS for values near the critical pressure between 1274900 Pa and 1288200 Pa. Interestingly not all of them. Interestingly not all of them:
The code i ran:

import CoolProp.CoolProp as CP
import numpy as np
import matplotlib.pyplot as plt

HEOS = CP.AbstractState('HEOS','Hydrogen')

T0 = 293.15 # K

step = 0.001e5
Ps = np.arange(10e5,15e5,step)
N = len(Ps)
Ts = np.zeros(N)
Ss = np.zeros(N)
Hs = np.zeros(N)
for i,P in enumerate(Ps):
HEOS.update(CP.PT_INPUTS,P,T0)
try:
HEOS.update(CP.PSmass_INPUTS,HEOS.p(),HEOS.smass())
Ts[i] = HEOS.T()
Ss[i] = HEOS.smass()
Hs[i] = HEOS.hmass()
except:
print(P,'failed')

plt.plot(Ps,Ts,'.')

The output:

image

1274900.0 failed
1275000.0 failed
1275100.0 failed
1275200.0 failed
1275300.0 failed
1275500.0 failed
1275600.0 failed
1275700.0 failed
1275800.0 failed
1275900.0 failed
1276000.0 failed
1276100.0 failed
1276200.0 failed
1276400.0 failed
1276500.0 failed
1276600.0 failed
1276700.0 failed
1276800.0 failed
1277000.0 failed
1277100.0 failed
1277400.0 failed
1277500.0 failed
1277600.0 failed
1277700.0 failed
1277800.0 failed
1277900.0 failed
1278000.0 failed
1278200.0 failed
1278500.0 failed
1278600.0 failed
1278700.0 failed
1278800.0 failed
1278900.0 failed
1279000.0 failed
1279100.0 failed
1279200.0 failed
1279400.0 failed
1279500.0 failed
1279700.0 failed
1279800.0 failed
1280000.0 failed
1280200.0 failed
1280400.0 failed
1280500.0 failed
1280600.0 failed
1280700.0 failed
1281200.0 failed
1281300.0 failed
1281500.0 failed
1281600.0 failed
1281700.0 failed
1282000.0 failed
1282300.0 failed
1282500.0 failed
1282900.0 failed
1283300.0 failed
1283600.0 failed
1283900.0 failed
1284000.0 failed
1284200.0 failed
1284500.0 failed
1284600.0 failed
1284700.0 failed
1285400.0 failed
1285500.0 failed
1285800.0 failed
1285900.0 failed
1286100.0 failed
1286200.0 failed
1286700.0 failed
1287000.0 failed
1287500.0 failed
1287600.0 failed
1287700.0 failed
1287800.0 failed
1287900.0 failed
1288000.0 failed
1288100.0 failed
1288200.0 failed

@ibell
Copy link
Contributor

ibell commented Nov 26, 2023

Weird, did you also try to specify the phase? Perhaps that would help? I agree that you should not be having this problem. I wonder if the problem could be related to the issues identified in this paper: https://link.springer.com/article/10.1007/s10765-023-03261-8 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants