BioSTEAMDevelopmentGroup / Bioindustrial-Park

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

Consultation about unit execution sequence #134

Open zasddsgg opened 4 weeks ago

zasddsgg commented 4 weeks ago

Hello, when I execute the following code, it seems that I can not run from the Feedstock unit (U101), resulting in Water1.F_mass is still obtained with the initial mass flow of stream Ethanol instead of with the flow rate of Ethanol calculating through Ethanol.F_mass =Feedstock.F_mass*0.098. If I want to run U101 first, then through Ethanol.F_mass =Feedstock.F_mass*0.098 to get the flow rate of stream Ethanol, and then through Water1.F_mass = Ethanol.F_mass*7 to get the flow rate of stream Water1. Could I ask you how to solve it? Thanks for your help. Wish you a good day. The code is as follows.

import biosteam as bst
from biosteam.units.decorators import cost
from biosteam import units
bst.nbtutorial()
from biorefineries import cellulosic
cs = cellulosic.Biorefinery('corn stover ethanol')
chemicals = cs.chemicals 
bst.settings.set_thermo(chemicals)
bst.main_flowsheet.set_flowsheet('Glucose')

Water1 = bst.Stream(
    ID='Water1',
    price=0.0516, 
    total_flow=8992.8669,
    units='kg/hr',
    Water=1,
)

Glucose = bst.Stream(
    ID='Glucose',
    price=0.0516, 
    total_flow=1,
    units='kg/hr',
    Glucose=1,
)

Feedstock = bst.Stream(
    ID='Feedstock',
    price=0.0516, 
    total_flow=10,
    units='kg/hr',
    Glucose=1,
) 

Ethanol = bst.Stream(
    ID='Ethanol',
    price=0.0516, 
    total_flow=10,
    units='kg/hr',
    Ethanol=1,
)

U101 = cellulosic.units.FeedStockHandling('U101', Feedstock)                    
U101.cost_items['System'].cost = 0.

@cost('Flow rate', 'Mixer', S=136260, units='kg/hr',
      CE=522, cost=6000, n=0.5, BM=1)
class GlucoseMixer(bst.Mixer): pass
M201 = GlucoseMixer('M201', [Ethanol, Glucose])
@M201.add_specification(run=True)
def update_Ethanol():
    Ethanol.F_mass =Feedstock.F_mass*0.098 

M202 = units.Mixer('M202', [U101-0, M201-0])
P201 = units.Pump('P201', M202-0, P=1.5*101325)
H201 = units.HXutility('H201', P201-0, T=50+273.15) 
P202 = units.Pump('P202', H201-0, P=2*101325)
P203 = units.Pump('P203', P202-0, P=2*101325)
@P203.add_specification(run=False)
def adjust_pump_pressure_P203():
    P203._run()
    After_P202 = P202-0
    P203.P = After_P202.P + 0.1*101325
P204 = units.Pump('P204', P203-0, P=1.1*101325)
@P204.add_specification(run=False)
def adjust_pump_pressure_P204():
    P204._run()
    After_P203 = P203-0
    P204.P = After_P203.P + 0.1*101325
P205 = units.Pump('P205', Water1, P=1.1*101325)
@P205.add_specification(run=True)
def update_Water():
    Water1.F_mass = Ethanol.F_mass*7
M203 = units.Mixer('M203', [P205-0])
F201 = units.Flash('F201', M203-0, Q=0, P=101325)
@F201.add_specification(run=False)
def adjust_flash_pressure_F201():
    F201._run()
    F201_inlet = M203-0
    F201.P = F201_inlet.P
M204 = units.Mixer('M204', [F201-1, P204-0])
sys = bst.main_flowsheet.create_system('sys')
sys.simulate()
sys.diagram('thorough', format='png', number=True)
Water1.F_mass

1

zasddsgg commented 4 weeks ago

I tried the other code a few times, sometimes running from unit P205, sometimes running from unit U101, and it looked a little strange.

zasddsgg commented 2 weeks ago

Hello, could I trouble you take some time to look at this problem. Thanks for your help. Wish you a good day.

zasddsgg commented 1 day ago

Hello, could I trouble you take some time to look at this problem? I still can't control the running order of the unit, but it is very important for the accuracy of the result. Thanks for your help.

zasddsgg commented 21 hours ago

@yoelcortes If I want to run U101 and M201 first and then P205, could I ask you what code to call? The current running order affects the accuracy of the results.