CalebBell / thermo

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

Certain properties missing from nitrogen gas #129

Closed translunar closed 1 year ago

translunar commented 1 year ago

Newb here, so maybe I'm misunderstanding something, but with nitrogen gas, I'm having trouble getting certain properties:

N2 = Chemical("nitrogen", 298, 104000.0)
(Pdb) N2.k
0.02760062516477041
(Pdb) print(N2.mug)
None
(Pdb) Chemical('nitrogen')
<Chemical [nitrogen], T=298.15 K, P=101325 Pa>
(Pdb) N2
<Chemical [nitrogen], T=298.00 K, P=104000 Pa>
(Pdb) Chemical('nitrogen').Pr
(Pdb) N2.Pr
(Pdb) N2.Prg
(Pdb)
❯ pip3 show thermo
Name: thermo
Version: 0.2.23
Summary: Chemical properties component of Chemical Engineering Design Library (ChEDL)
Home-page: https://github.com/CalebBell/thermo
Author: Caleb Bell
Author-email: Caleb.Andrew.Bell@gmail.com
License: MIT
Location: /Users/junowoods/anaconda3/lib/python3.9/site-packages
Requires: chemicals, fluids, pandas, scipy
Required-by:

Is there a workaround or something else I should be doing?

translunar commented 1 year ago

Interestingly, it's also not working for the example given in the docs:

(Pdb) tol = Chemical('toluene')
(Pdb) tol.mug
(Pdb) p tol.kg
0.009393243373039812
CalebBell commented 1 year ago

Hi, The legacy Chemical interface tries to provide the best properties for a chemical. In this case as nitrogen is a well studied library, it is trying to use CoolProp, a high accuracy third party library; since you are missing it no properties are returned for the properties that default to the CoolProp method. If you install it pip install CoolProp, those calculations will work.

Alternatively the new interface allows much greater levels of customization and robustness.

Sincerely, Caleb

translunar commented 1 year ago

Perhaps this is a documentation issue? The README doesn't mention CoolProp as a requirement for this library, and I spent several hours yesterday trying to understand how to do the same thing with the newer interface as is relatively straightforward with Chemical.

Thank you!

CalebBell commented 1 year ago

Hi translunar,

I have now finished a long-term project to remove CoolProp as a default method for any purely temperature-dependent properties. Instead the same quality data is provided through a series of high-accuracy polynomial fits. For pressure-dependent properties (viscosity, thermal conductivity, volume) CoolProp is sometimes still the default but there will always be a backup method used if CoolProp is not available. The situation you ran into should no longer occur as of thermo==0.2.25.

Sincerely, Caleb