BioSTEAMDevelopmentGroup / Bioindustrial-Park

BioSTEAM's Premier Repository for Biorefinery Models and Results
MIT License
36 stars 17 forks source link

Request for CSTR and Mixer #68

Closed zasddsgg closed 8 months ago

zasddsgg commented 1 year ago

Hello, I built a reactor by inheriting CSTR (code below), but in the utilities of the exported excel report, and nine chilled_water was observed, which seems to mean that there are 9 identical reactors, while in fact I built only one reactor, and as the feed changes, the final number of identical reactors seems to change accordingly, so I don't seem to be able to control the number of reactors during the actual run. I can't find the source code for CSTR in API reference (https://biosteam.readthedocs.io/en/latest/_modules/biosteam/units/cstr.html#CSTR). Could you tell me where I can find the source code of CSTR? For the above 9 reactors, should the utilities of each reactor be multiplied by 9 to obtain the final utilities of the reactor? In addition, why does the cooling medium use chilled water instead of cooling water? If I want to simulate a reactor in which only one reaction (for example, acetate to acetic acid) occurs, could I consult you some suggestions on how to construct the reactor in each of the following scenarios: stirring or not stirring, using chilled water or cooling water as the cooling medium. The code is as follows:

import biosteam as bst
bst.nbtutorial()
from biorefineries import cellulosic
cs = cellulosic.Biorefinery('corn stover ethanol')
chemicals_cs = cs.chemicals 
bst.settings.set_thermo(chemicals_cs)
bst.main_flowsheet.set_flowsheet('acetate conversion') 
class Acetate_conversion(bst.CSTR):
    _N_ins = 1
    _N_outs = 2
    T_default = 25 + 273.15
    P_default = 101325.
    tau_default = 8.

    def _setup(self):
        super()._setup()
        self.acetate_conversion_reaction = bst.Reaction('Acetate -> AceticAcid', 'Acetate', 0.90)

    def _run(self):
        vent, effluent = self.outs
        effluent.mix_from(self.ins, energy_balance=False)
        self.acetate_conversion_reaction(effluent)
        effluent.T = vent.T = self.T
        effluent.P = vent.P = self.P
        vent.phase = 'g'
        vent.empty()
        vent.receive_vent(effluent, energy_balance=False)
Acetate=bst.Stream(
    ID='Acetate',
    Acetate=50.31105,
    Water=10000,
    Glucan=500,
    Sucrose=200.01,
    Xylose=150,
    T=360,
    P=101325)
R202 = Acetate_conversion('R205', Acetate)
Acetate_sys = bst.main_flowsheet.create_system('Acetate_sys')
Acetate_sys.simulate()
Acetate_sys.save_report('Acetate.xlsx')

When calling Mixer, in the user guide (https://biosteam.readthedocs.io/en/latest/tutorial/Gotchas.html), outlet stream pressure seems to be the minimum inlet stream pressure, but I tried the following code. Regardless of whether the inlet stream pressure is equal, the outlet flow pressure always seems to be the atmospheric pressure. If the inlet stream pressure is the same, shouldn't the outlet stream pressure be the inlet stream pressure? If the inlet stream pressure is different, shouldn't the outlet stream pressure be the minimum pressure in the inlet stream pressure? The code is as follows:

S1=bst.Stream(ID='S1', Water=1000, P=111458)
S2=bst.Stream(ID='S2', Water=2000, P=111458)
M1 = bst.units.Mixer('M1', [S1, S2])
M1.simulate()
M1

S3=bst.Stream(ID='S3', Water=1000, P=131458)
S4=bst.Stream(ID='S4', Water=2000, P=111458)
M2 = bst.units.Mixer('M1', [S3, S4])
M2.simulate()
M2

Thanks for your help. Wish you a good day.

yoelcortes commented 1 year ago

@zasddsgg, thanks for your questions and letting me know about the issue with the mixer.

The issue with the mixer has been fixed and tests have been added to make sure the correct behavior is kept:

S1=bst.Stream(ID='S1', Water=1000, P=111458)
S2=bst.Stream(ID='S2', Water=2000, P=111458)
M1 = bst.units.Mixer('M1', [S1, S2])
M1.simulate()
assert M1.outs[0].P ==111458

S3=bst.Stream(ID='S3', Water=1000, P=131458)
S4=bst.Stream(ID='S4', Water=2000, P=111458)
M2 = bst.units.Mixer('M2', [S3, S4])
M2.simulate()
assert M2.outs[0].P ==111458

Note: you'll need to use the master branch of thermosteam for this update.

Regarding your questions on the reactor:

Thanks,

zasddsgg commented 1 year ago

Thank you for your advice and help. There are two ways to build reactor, inherited from PressureVessel, Unit or CSTR, are there any differences between above two ways, such as model results, TEA and LCA results?

yoelcortes commented 8 months ago

Details on how STR and PressureVessel are modeled (which ultimately affect TEA/LCA) are in the documentation.

Thanks,