BioSTEAMDevelopmentGroup / thermosteam

BioSTEAM's Premier Thermodynamic Engine
Other
57 stars 12 forks source link

Using Thermosteam and CoolProp in the same environment leads to errors #53

Closed nkawerau closed 2 years ago

nkawerau commented 2 years ago

Describe the bug Running a Thermosteam code in an environment with a clean thermosteam installation (pip install thermosteam) works fine. As soon as I install CoolProp (pip install coolprop) running the same code raises errors.

To Reproduce

import thermosteam as tmo

"""stream definition"""
H2O = tmo.Chemical("H2O")

chemicals = tmo.CompiledChemicals([H2O])
mixture = tmo.Mixture.from_chemicals(chemicals)
thermo = tmo.Thermo(chemicals, mixture, cache=False)

tmo.settings.set_thermo(thermo)

stream = tmo.MultiStream(ID="stream", l=[("H2O", 1)], units="m3/hr")

stream.set_property("T", 20, "degC")
stream.set_property("P", 1, "bar")

viscosity_H2O = stream.mu

print("thermosteam viscosity of H2O:", viscosity_H2O)

Expected behavior thermosteam viscosity of H2O: 0.0010216146329967753

I do not expect the CoolProp installation to affect code execution.

Actual behavior Traceback (most recent call last): File "C:\Users\nkawerau\AppData\Roaming\Python\Python38\site-packages\IPython\core\interactiveshell.py", line 2632, in safe_execfile py3compat.execfile( File "C:\Users\nkawerau\AppData\Roaming\Python\Python38\site-packages\IPython\utils\py3compat.py", line 55, in execfile exec(compiler(f.read(), fname, "exec"), glob, loc) File "C:\Users\nkawerau\Documents\python-scripts\ael-model\thermosteam_testing.py", line 12, in stream = tmo.MultiStream(ID="stream", l=[("H2O", 1)], units="m3/hr") File "C:\Users\nkawerau\Anaconda3\envs\thermosteam_env\lib\site-packages\thermosteam_multi_stream.py", line 224, in init flow._data[:] = material_data File "C:\Users\nkawerau\AppData\Roaming\Python\Python38\site-packages\free_properties_property_array.py", line 184, in setitem i.item().value = v File "C:\Users\nkawerau\Anaconda3\envs\thermosteam_env\lib\site-packages\thermosteam\indexer.py", line 1032, in VolumetricFlowProperty self.mol[self.index] = value / V(*self.TP) / 1000. File "C:\Users\nkawerau\Anaconda3\envs\thermosteam_env\lib\site-packages\thermosteam\thermo\tp_dependent_property.py", line 21, in call return self.TP_dependent_property(T, P) File "C:\Users\nkawerau\Anaconda3\envs\thermosteam_env\lib\site-packages\thermo\utils\tp_dependent_property.py", line 245, in TP_dependent_property raise RuntimeError("%s method '%s' is not valid at T=%s K and P=%s Pa for component with CASRN '%s'" %(self.name, method_P, T, P, self.CASRN)) RuntimeError: Liquid molar volume method 'COOLPROP' is not valid at T=298.15 K and P=101325.0 Pa for component with CASRN '7732-18-5 (H2O)'

Version Python: 3.8.12 Thermosteam: 0.27.18 Thermo: 0.2.13 CoolProp: 6.4.1

yoelcortes commented 2 years ago

Thanks so much for submitting this issue, it should work with the latest version in PyPI (0.27.19) or with the master branch.