Closed nkawerau closed 2 years ago
Hi! Thanks for posting this issue. I adjusted the ranked methods in thermosteam to use CoolProp only if its the only method available (please update or pull master branch). Note that coolprop uses equations of state, so having water as a gas at STP will lead to errors.
With the new update, you can get your code working by add this line:
chemicals.H2O.mu.g.method_P = None # Before any calculations
Then you should get the following:
MultiStream: s1
phases: ('g', 'l'), T: 298.15 K, P: 100000 Pa
flow (kg/hr): (g) H2 1
H2O 0.292
(l) H2O 6.71
KOH 3
thermosteam_testing specific enthalpy: 64797.7223270309
thermosteam_testing specific volume: 1.1554499145757928
thermosteam_testing density: 0.8654637361474349
thermosteam_testing specific entropy: 8936.728801346717
thermosteam_testing viscosity: 0.002062542267450246
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
Expected behavior no runtime error
Actual behavior MultiStream: s1 phases: ('g', 'l'), T: 298.15 K, P: 100000 Pa flow (kg/hr): (g) H2 1 H2O 0.292 (l) H2O 6.71 KOH 3 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 102, in
viscosity_fluid = stream.mu #[Pa/s]
File "C:\Users\nkawerau\Anaconda3\envs\tespy_thermosteam_env\lib\site-packages\thermosteam_multi_stream.py", line 534, in mu
self._property_cache['mu'] = mu = self.mixture.xmu(self._imol.iter_composition(), self._thermal_condition)
File "C:\Users\nkawerau\Anaconda3\envs\tespy_thermosteam_env\lib\site-packages\thermosteam\mixture\mixture.py", line 368, in xmu
return sum([self.mu(phase, mol, T, P) for phase, mol in phase_mol])
File "C:\Users\nkawerau\Anaconda3\envs\tespy_thermosteam_env\lib\site-packages\thermosteam\mixture\mixture.py", line 368, in
return sum([self.mu(phase, mol, T, P) for phase, mol in phase_mol])
File "C:\Users\nkawerau\Anaconda3\envs\tespy_thermosteam_env\lib\site-packages\thermosteam\base\phase_handle.py", line 84, in call
return getattr(self, phase)(z, T, P)
File "C:\Users\nkawerau\Anaconda3\envs\tespy_thermosteam_env\lib\site-packages\thermosteam\mixture\ideal_mixture_model.py", line 56, in call
return sum([j i(T, P) for i, j in zip(self.models, mol) if j])
File "C:\Users\nkawerau\Anaconda3\envs\tespy_thermosteam_env\lib\site-packages\thermosteam\mixture\ideal_mixture_model.py", line 56, in
return sum([j * i(T, P) for i, j in zip(self.models, mol) if j])
File "C:\Users\nkawerau\Anaconda3\envs\tespy_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\AppData\Roaming\Python\Python38\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: Gas viscosity method 'COOLPROP' is not valid at T=298.15 K and P=99999.99999999999 Pa for component with CASRN '7732-18-5'
Version Python: 3.8.12 Thermosteam: 0.27.19 Thermo: 0.2.13 CoolProp: 6.4.1