BioSTEAMDevelopmentGroup / thermosteam

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

Bug in copying `ChemicalIndexer` #76

Closed yalinli2 closed 1 year ago

yalinli2 commented 1 year ago

Doing the following will trigger an error:

>>> import biosteam as bst
>>> bst.settings.set_thermo((bst.Chemical('Water'), bst.Chemical('Ethanol')))
>>> s1 = bst.Stream(Water=1)
>>> mass_indexer_copy = s1.mass.copy()
>>> mass_indexer_copy
Screen Shot 2022-09-25 at 1 50 42 PM

I'm using the biosteam/thermosteam on the master branch, just pulled as I opened this issue.

Thanks!

yoelcortes commented 1 year ago

@yalinli2, thanks for posting this! It was a bug in free_properties (the package). I fixed the bug, released a new version, and updated dependencies in thermosteam. The following should work now (don't forget to pip install free_properties==0.3.6):

>>> import biosteam as bst
>>> bst.settings.set_thermo((bst.Chemical('Water'), bst.Chemical('Ethanol')))
>>> s1 = bst.Stream(Water=1)
>>> mass_indexer_copy = s1.mass.copy()
>>> mass_indexer_copy
array([18.015,  0.   ])

Note that a normal array is returned to keep the expected behavior that copies do not alter the original array.

Thanks!

yalinli2 commented 1 year ago

Awesome, thanks Yoel!