CalebBell / thermo

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

BUG: Potential regression for thermal conductivity in pure components in latest update #89

Closed Stefan-Endres closed 2 years ago

Stefan-Endres commented 2 years ago

After updating to the latest version of the thermo package, the Chemical class is missing thermal conductivity for some pure components which were previously present. Potentially related to #52.

Minimal working examples:

Previous behaviour:

$ pip show thermo
Name: thermo
Version: 0.1.40
>>> from thermo.chemical import Chemical
>>> fuel_name = "Ethanol"  # Similar for "Water"
>>> fuel = Chemical(fuel_name, T=303.15)
>>> print(fuel.kg)
0.01164343539939321

After updating:

$ pip show thermo
Name: thermo
Version: 0.2.10  
>>> from thermo.chemical import Chemical
>>> fuel_name = "Ethanol"  # Similar for "Water"
>>> fuel = Chemical(fuel_name, T=303.15)
>>> print(fuel.kg)
None

Accessing other properties still work as expected:

>>> print(fuel.Cp)
2477.71998173878  
>>> print(fuel.alpha)
8.443183815819819e-08

yoelcortes commented 2 years ago

Hi Stefan,

Thanks for reporting this! I believe this is because the previous behavior of chemicals would cycle through methods until one would work. This behavior has been deprecated in favor of extrapolation, which helps keep properties continuous and consistent, but there are still a few issues with this...

The gas thermal conductivity method depends on the gas molar volume method (Vmg). The default method for Vmg is 'EOS', which fails at that temperature and pressure. To fix your issue, you can change the method for Vmg:

>>> from thermo.chemical import Chemical
>>> fuel_name = "Ethanol"  # Similar for "Water"
>>> fuel = Chemical(fuel_name, T=303.15)
>>> fuel.VolumeGas.method_P= 'TSONOPOULOS_EXTENDED'
>>> print(fuel.kg)
0.011656785631933345

@CalebBell, let me know if I missed anything here.

Thanks!

Stefan-Endres commented 2 years ago

Thank you very much for the quick response. Setting the method worked for me.