CalebBell / thermo

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

Possible fix #93

Closed andr1976 closed 2 years ago

andr1976 commented 2 years ago

@CalebBell , maybe not the most beutiful fix, but it seems there is an issue with a single root when evaluating the conditional

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "michelsen.py", line 242, in flash
    res = self.PT_flash(T=T,P=P)
  File "michelsen.py", line 272, in PT_flash
    liq = CEOSLiquid(PRMIX, self.eos_kwargs, HeatCapacityGases=self.properties.HeatCapacityGases, T=T, P=P, zs=list(x))
  File "<string>", line 135, in __init__
  File "C:\Users\ANRA\AppData\Local\Programs\Python\Python38\lib\site-packages\thermo\eos_mix.py", line 6971, in __init__
    self.solve(only_l=only_l, only_g=only_g)
  File "C:\Users\ANRA\AppData\Local\Programs\Python\Python38\lib\site-packages\thermo\eos.py", line 1153, in solve
    self.set_from_PT(Vs, only_l=only_l, only_g=only_g)
  File "C:\Users\ANRA\AppData\Local\Programs\Python\Python38\lib\site-packages\thermo\eos.py", line 1215, in set_from_PT
    if good_root_count == 1 or (good_roots[0] == good_roots[1]):
IndexError: list index out of range
CalebBell commented 2 years ago

Hi Anders, What is your standalone reproducible test case that has an issue? Sincerely, Caleb

andr1976 commented 2 years ago

@CalebBell, sorry, for some reason I was setting CEOSGas with zero molefracs, that caused it. I will delete the PR. but maybe some warning or exception if molefrac sum <> 1 or all zero

andr1976 commented 2 years ago

Removing the PR