CalebBell / thermo

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

Error in Psat from thermo.eos_mix - problem identified. #75

Closed blsymens closed 3 years ago

blsymens commented 3 years ago

The omega parameter is not calculated when in case N>1 (no pure component, but mixture). eos_mix.py in Psat-function should be adapted so omega is updated within else statement. I tested and it worked.

eos_mix.py in Psat(self, T, polish) line 887 is missing.

      884    for i in range(self.N):
      885         Pc += Pcs[i]*zs[i]
      886         a += ais[i]*zs[i]
      887         omega += zs[i]*omegas[i]
      888    self.Tc, self.Pc, self.omega = Tc, Pc, omega
      889    self.a = a

Test code:

from thermo.chemical import Chemical
C6 = Chemical('1-hexene')
iC4 = Chemical('isobutane')
from thermo.eos_mix import PRMIX
eos = PRMIX([C6.Tc,iC4.Tc],[C6.Pc,iC4.Pc],[C6.omega,iC4.omega],[0.5,0.5],kijs=[[0,0],[0,0]],T=200,P=200000)
#eos.Psat(0.5*C6.Tc)
eos.PT_surface_special(Tmin=200,Tmax=1000,Pmin=100000,Pmax=10000000,phase_ID_transition=False,show=True,pts=250,pseudo_critical=False)
CalebBell commented 3 years ago

Hi Bavo,

That was an oversight for a function that isn't expected to have any real use. I hope that you do understand that the function doesn't return either the dew pressure or the bubble pressure when there are more than 1 component. For those calculations, which I am almost certain you are looking for, see the API documentation https://thermo.readthedocs.io/thermo.flash.html#thermo.flash.FlashVL and part of the tutorial shows it too: https://thermo.readthedocs.io/tutorial_phases_and_flash.html#flashes-with-pure-compounds

Regardless, the minor fix is out now in thermo 0.2.4 on pypi. The conda package usually takes about a day to release. Thanks for letting me know!

Sincerely, Caleb