BioSTEAMDevelopmentGroup / thermosteam

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

Cache is (still) broken #71

Closed BenPortner closed 1 year ago

BenPortner commented 1 year ago

Commit https://github.com/BioSTEAMDevelopmentGroup/thermosteam/commit/81ba05ed68e4891072415a5634dcf18da126b94a breaks method biosteam.units._compressor.PolytropicCompressor._hundseid:

import biosteam as bst
bst.settings.set_thermo(["H2"])
feed = bst.Stream(H2=1, T=25 + 273.15, P=20e5, phase='g')
K = bst.units.PolytropicCompressor(ins=feed, P=350e5, eta=1.0, method="hundseid")
K.simulate()
print(K.power_utility.rate) # expected: 3.59 actual: 157.00

Since the custom caching seems to be quite complex: Have you considered Python's native @lru_cache decorator?

yoelcortes commented 1 year ago

@BenPortner, the code is working on my end:

>>> import biosteam as bst
>>> bst.settings.set_thermo(["H2"])
>>> feed = bst.Stream(H2=1, T=25 + 273.15, P=20e5, phase='g')
>>> K = bst.units.PolytropicCompressor(ins=feed, P=350e5, eta=1.0, method="hundseid")
>>> K.simulate()
>>> print(K.power_utility.rate) 
156.99854330297322

I updated the thermosteam repo but forgot to update the thermosteam submodule in biosteam. So I think you might have just pulled biosteam and not thermosteam. To pull thermosteam specifically (regardless of whether the thermosteam submodule is up to date), you can go within the thermosteam folder and git pull origin master.

Thanks,

BenPortner commented 1 year ago

@yoelcortes 157 is the wrong result.

yoelcortes commented 1 year ago

@BenPortner, got it. I introduced a different bug in my last commit. It is fixed now with a new test to make sure it doesn't repeat.

Thanks!