Closed yoelcortes closed 1 year ago
Hi @joyxyz1994, @yalinli2,
This pull request adds a new product_yield method for reaction objects to be able to get and set the net yield for a specific product by either weight or mol. The tests I added should help explain how it works:
product_yield
import thermosteam as tmo tmo.settings.set_thermo(['H2O', 'H2', 'O2'], cache=True) single_phase_reaction = reaction = tmo.Reaction( '2H2O -> 2H2 + O2', reactant='H2O', correct_atomic_balance=True, X=0.5 ) multi_phase_reaction = reaction = tmo.Reaction( 'H2O,l -> H2,g + O2,g', reactant='H2O', correct_atomic_balance=True, X=0.7 ) # Test product_yield with and without multiple phases assert_allclose(single_phase_reaction.product_yield('O2'), 0.25) assert_allclose(multi_phase_reaction.product_yield('O2'), 0.35) assert_allclose(single_phase_reaction.product_yield('H2'), 0.5) assert_allclose(multi_phase_reaction.product_yield('H2'), 0.7) assert_allclose(single_phase_reaction.product_yield('O2', basis='wt'), 0.44405082796381734) assert_allclose(multi_phase_reaction.product_yield('O2', basis='wt'), 0.6216711591493442) # Test product_yield setter with and without multiple phases single_phase_reaction.product_yield('O2', product_yield=0.1) multi_phase_reaction.product_yield('O2', product_yield=0.1) assert_allclose(single_phase_reaction.product_yield('O2'), 0.1) assert_allclose(multi_phase_reaction.product_yield('O2'), 0.1) single_phase_reaction.product_yield('H2', product_yield=0.1) multi_phase_reaction.product_yield('H2', product_yield=0.1) assert_allclose(single_phase_reaction.product_yield('H2'), 0.1) assert_allclose(multi_phase_reaction.product_yield('H2'), 0.1) single_phase_reaction.product_yield('O2', basis='wt', product_yield=0.1) multi_phase_reaction.product_yield('O2', basis='wt', product_yield=0.1) assert_allclose(single_phase_reaction.product_yield('O2', basis='wt'), 0.1) assert_allclose(multi_phase_reaction.product_yield('O2', basis='wt'), 0.1)
Thanks!
thanks @yoelcortes ! I added more details to the doc - feel free to update if needed, thanks!
Awesome, thanks a bunch!
Hi @joyxyz1994, @yalinli2,
This pull request adds a new
product_yield
method for reaction objects to be able to get and set the net yield for a specific product by either weight or mol. The tests I added should help explain how it works:Thanks!