From 2fab731344635644d1240ee6edf7c43a53ba051b Mon Sep 17 00:00:00 2001 From: sarangbhagwat <59667492+sarangbhagwat@users.noreply.github.com> Date: Wed, 21 Feb 2024 15:37:27 -0600 Subject: [PATCH 1/2] minor z_mol fix --- biosteam/_unit.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/biosteam/_unit.py b/biosteam/_unit.py index a20e5b48..b46a03d0 100644 --- a/biosteam/_unit.py +++ b/biosteam/_unit.py @@ -1263,11 +1263,11 @@ def mol_out(self) -> NDArray[float]: @property def z_mol_in(self) -> NDArray[float]: """Molar fractions going in [kmol/hr].""" - return self._mol_in/self.F_mol_in + return self.mol_in/self.F_mol_in @property def z_mol_out(self) -> NDArray[float]: """Molar fractions going in.""" - return self._mol_out/self.F_mol_out + return self.mol_out/self.F_mol_out @property def F_mol_in(self) -> float: From 27e3b56eed31da9ebaf7e2e672d5ce76ea53fe7e Mon Sep 17 00:00:00 2001 From: Yoel Cortes-Pena Date: Wed, 21 Feb 2024 20:37:37 -0600 Subject: [PATCH 2/2] add test for fixed issue --- tests/test_unit.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/test_unit.py b/tests/test_unit.py index b7bf29da..45695e7a 100644 --- a/tests/test_unit.py +++ b/tests/test_unit.py @@ -26,6 +26,25 @@ def __init__(self, *args, **kwargs): # Once unit is in a system, auxiliary units must have an owner assert unit.mixer.owner is unit +def test_unit_convinience_properties(): + class TestUnit(bst.Unit): + _N_ins = 2 + _N_outs = 2 + + def _run(self): + for i, j in zip(self.ins, self.outs): + j.copy_like(i) + + bst.settings.set_thermo(['Water', 'Ethanol'], cache=True) + ins = [bst.Stream(None, Water=1, Ethanol=2), + bst.Stream(None, Water=2, Ethanol=5)] + U = TestUnit(None, ins=ins, outs=(None, None)) + U.run() + assert (U.mol_in == [3, 7]).all() + assert (U.mol_in == U.mol_out).all() + assert (U.z_mol_in == U.z_mol_out).all() + assert (U.z_mol_in == [0.3, 0.7]).all() + def test_unit_inheritance_setup_method(): class NewUnit(bst.Unit): def _setup(self): @@ -382,6 +401,7 @@ def f(): raise RuntimeError('unit simulated') if __name__ == '__main__': test_auxiliary_unit_owners() + test_unit_convinience_properties() test_unit_inheritance_setup_method() test_process_specifications_linear() test_process_specifications_with_recycles()