Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions biosteam/wastewater/high_rate/polishing_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,14 @@ def _run(self):

self.growth_rxns(mixed.mol)
self.decomp_rxns.force_reaction(mixed.mol)
biogas.phase = air_in.phase = air_out.phase = 'g'
if self.filter_type == 'aerobic' and mixed.imol['O2'] < 0:
O2 = -mixed.imol['O2']
air_in.imol['O2'] = O2
air_in.imol['N2'] = 0.79/0.21 * O2
mixed.imol['O2'] = 0
else:
air_in.empty()
mixed.split_to(eff, waste, self._isplit.data)

sludge_conc = self._sludge_conc
Expand All @@ -191,15 +199,6 @@ def _run(self):
waste.ivol['Water'] = m_insolubles/sludge_conc
eff.ivol['Water'] += diff

biogas.phase = air_in.phase = air_out.phase = 'g'

if mixed.imol['O2'] < 0:
air_in.imol['O2'] = - mixed.imol['O2']
air_in.imol['N2'] = - 0.79/0.21 * mixed.imol['O2']
mixed.imol['O2'] = 0
else:
air_in.empty()

if self.filter_type == 'anaerobic':
degassing(eff, biogas)
degassing(waste, biogas)
Expand All @@ -211,7 +210,6 @@ def _run(self):
degassing(eff, air_out)
degassing(waste, air_out)
air_out.imol['N2'] += air_in.imol['N2']
air_out.imol['O2'] += air_in.imol['O2']
self._recir_ratio = None

if self.T is not None: biogas.T = eff.T = waste.T = air_out.T = self.T
Expand Down Expand Up @@ -637,4 +635,4 @@ def organic_rm(self):
"""[float] Overall organic (COD) removal rate."""
Qi, Qe = self._inf.F_vol, self.outs[1].F_vol
Si, Se = self.compute_COD(self._inf), self.compute_COD(self.outs[1])
return 1 - Qe*Se/(Qi*Si)
return 1 - Qe*Se/(Qi*Si)
50 changes: 50 additions & 0 deletions tests/test_high_rate_wastewater.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import biosteam as bst
import pytest


def test_aerobic_polishing_filter_satisfies_oxygen_deficit_before_split():
bst.main_flowsheet.clear()
chemicals = bst.Chemicals(['CO2', 'AceticAcid', 'H2O', 'O2', 'N2'])
bst.settings.set_thermo(
bst.wastewater.high_rate.append_wwt_chemicals(chemicals)
)
influent = bst.Stream(
'influent',
AceticAcid=1,
H2O=100,
units='kg/hr',
)
recycle = bst.Stream('recycle')
air = bst.Stream('air', phase='g')
unit = bst.wastewater.high_rate.PolishingFilter(
'PF',
ins=(influent, recycle, air),
outs=('biogas', 'effluent', 'waste', 'air_out'),
filter_type='aerobic',
)

unit.simulate()
assert unit.outs[1].imol['O2'] >= 0
assert unit.outs[2].imol['O2'] >= 0

assert abs(unit.mass_balance_error()) < 1e-6


def test_polishing_filter_rejects_invalid_filter_type():
bst.main_flowsheet.clear()
chemicals = bst.Chemicals(['CO2', 'AceticAcid', 'H2O', 'O2', 'N2'])
bst.settings.set_thermo(
bst.wastewater.high_rate.append_wwt_chemicals(chemicals)
)

with pytest.raises(ValueError, match="filter_type"):
bst.wastewater.high_rate.PolishingFilter(
'PF',
ins=('influent', 'recycle', 'air'),
outs=('biogas', 'effluent', 'waste', 'air_out'),
filter_type='aerobc',
)

if __name__ == '__main__':
test_aerobic_polishing_filter_satisfies_oxygen_deficit_before_split()
test_polishing_filter_rejects_invalid_filter_type()
Loading