CalebBell / thermo

Thermodynamics and Phase Equilibrium component of Chemical Engineering Design Library (ChEDL)
MIT License
594 stars 114 forks source link

AttributeError: 'PR' object has no attribute 'S_dep_g' #117

Closed BenPortner closed 1 year ago

BenPortner commented 1 year ago

Dear @CalebBell,

@yoelcortes sent me (related to this issue) 😃 To determine the power of a compressor, I am trying to calculate the entropy of hydrogen at 350 bar. However, for some reason it fails:

from thermo.eos import PR
PR(T=298.15, P=20e5, Tc=33.2, Pc=1296960.0, omega=-0.22).S_dep_g # this works
PR(T=298.15, P=350e5, Tc=33.2, Pc=1296960.0, omega=-0.22).S_dep_g # AttributeError: 'PR' object has no attribute 'S_dep_g' 

I am working with thermo version 0.2.21. Any idea what I am doing wrong?

Thank you. Ben

CalebBell commented 1 year ago

Hi Ben!

What is happening here is that at sufficiently high pressures, hydrogen is becoming liquid-like. For pure components, there are two cases:

The Peng-Robinson equation of state itself doesn't know the difference between a gas and a liquid, it just knows that there can be one or two solutions. It is easy to say one is gas and the other is liquid when there are two solutions, but when there is only one, the method described here is used.

Sincerely, Caleb