Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
yoelcortes committed Feb 23, 2024
2 parents 2560939 + 63f2248 commit 7a7a3b8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions biosteam/_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
20 changes: 20 additions & 0 deletions tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 7a7a3b8

Please sign in to comment.