Skip to content

Commit

Permalink
improvements to PO simulation
Browse files Browse the repository at this point in the history
  • Loading branch information
yoelcortes committed Aug 1, 2024
1 parent 7151c2f commit 1f0f156
Show file tree
Hide file tree
Showing 15 changed files with 747 additions and 432 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ biosteam/benchmark/simulations/*
*.svg
*.png
*.npy
*.xlsx
.gitignore
.pypirc
dist
Expand Down
34 changes: 28 additions & 6 deletions benchmark/acetic_acid_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,13 @@ def create_acetic_acid_simple_system(alg):
def fresh_solvent_flow_rate():
broth = feed.F_mass
EtAc_recycle = recycle.imass['EthylAcetate']
EtAc_required = broth * solvent_feed_ratio
if EtAc_required < EtAc_recycle:
recycle.F_mass *= EtAc_required / EtAc_recycle
EtAc_recycle = recycle.imass['EthylAcetate']
EtAc_fresh = EtAc_required - EtAc_recycle
solvent.imass['EthylAcetate'] = max(
0, broth * solvent_feed_ratio - EtAc_recycle
0, EtAc_fresh
)

@solvent.material_balance
Expand All @@ -81,7 +86,7 @@ def fresh_solvent_flow_rate():

@register(
'acetic_acid_complex', 'Glacial acetic acid\npurification',
60, [0, 10, 20, 30, 40, 50, 60], 'AcOH\nsep.'
210, [0, 30, 60, 90, 120, 150, 180, 210], 'AcOH\nsep.'
)
def create_acetic_acid_complex_system(alg):
thermo = bst.Thermo(['Water', 'AceticAcid', 'EthylAcetate'], cache=True)
Expand Down Expand Up @@ -154,9 +159,15 @@ def fresh_solvent_flow_rate():
def adjust_fresh_solvent_flow_rate():
broth = acetic_acid_broth.F_mass
EtAc_recycle = solvent_recycle.imass['EthylAcetate']
EtAc_required = broth * solvent_feed_ratio
if EtAc_required < EtAc_recycle:
solvent_recycle.F_mass *= EtAc_required / EtAc_recycle
EtAc_recycle = solvent_recycle.imass['EthylAcetate']
EtAc_fresh = EtAc_required - EtAc_recycle
ethyl_acetate.imass['EthylAcetate'] = max(
0, broth * solvent_feed_ratio - EtAc_recycle
0, EtAc_fresh
)

HX = bst.StageEquilibrium(
'HX_extract',
ins=[extractor.extract],
Expand All @@ -173,11 +184,11 @@ def adjust_fresh_solvent_flow_rate():
reflux=None,
boilup=3,
use_cache=True,
maxiter=10,
)
mixer = bst.Mixer('distillation_recycle', ins=[ED-0, distillate_2])
settler = bst.StageEquilibrium(
'settler',
ins=(ED-0, distillate, distillate_2),
ins=(mixer-0, distillate),
outs=(solvent_recycle, water_rich, ''),
phases=('L', 'l'),
top_chemical='EthylAcetate',
Expand Down Expand Up @@ -231,7 +242,18 @@ def adjust_fresh_solvent_flow_rate():
feed_stages=(1, 2),
reflux=1,
boilup=2,
maxiter=10,
)
return sys

def test_simple_acetic_acid_purification_system():
pass

def test_complex_acetic_acid_purification_system():
po = create_acetic_acid_complex_system('phenomena-oriented')
po.flatten()
po.set_tolerance(mol=1e-3, rmol=1e-3, maxiter=20)
sm = create_acetic_acid_complex_system('sequential modular')
sm.flatten()
sm.set_tolerance(mol=1e-3, rmol=1e-3, maxiter=20)
po.simulate()

23 changes: 19 additions & 4 deletions benchmark/butanol_purification_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def register(*args, **kwargs):

@register(
'butanol_purification', 'Butanol purification',
2, [0.5, 1, 1.5, 2], 'BtOH\nsep.'
4, [0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4], 'BtOH\nsep.'
)
def create_system_butanol_purification(alg):
bst.settings.set_thermo(['Water', 'Butanol'], cache=True)
Expand All @@ -37,12 +37,15 @@ def create_system_butanol_purification(alg):
ins=(feed, water_rich), outs=(distillate_0, 'water'),
x_bot=0.0001, y_top=0.2, k=1.2, Rmin=0.01,
LHK=('Butanol', 'Water'),
partial_condenser=False,
)
# water_distiller.decoupled = True

# Decanter
mixer = bst.Mixer('mixer', ins=(distillate_0, distillate_1))
settler = bst.StageEquilibrium(
'settler',
ins=(distillate_0, distillate_1),
ins=mixer-0,
outs=('butanol_rich', water_rich),
phases=('L', 'l'),
top_chemical='Butanol',
Expand All @@ -53,9 +56,21 @@ def create_system_butanol_purification(alg):
butanol_distiller = bst.BinaryDistillation(
ins=settler-0,
outs=(distillate_1, 'butanol'),
x_bot=0.0001, y_top=0.6, k=1.2, Rmin=0.01,
x_bot=0.0001, y_top=0.6,
k=1.2, Rmin=0.01,
LHK=('Water', 'Butanol'),
partial_condenser=False,
)
# butanol_distiller.decoupled = True

sys = bst.System.from_units(units=[water_distiller, settler, butanol_distiller], algorithm=alg)
sys = bst.System.from_units(units=[water_distiller, mixer, settler, butanol_distiller], algorithm=alg)
return sys

def test_butanol_purification_system():
po = create_system_butanol_purification('phenomena-oriented')
po.flatten()
po.set_tolerance(mol=1e-3, rmol=1e-3, maxiter=20)
sm = create_system_butanol_purification('sequential modular')
sm.flatten()
sm.set_tolerance(mol=1e-3, rmol=1e-3, maxiter=20)
po.simulate()
Loading

0 comments on commit 1f0f156

Please sign in to comment.