BioSTEAMDevelopmentGroup / Bioindustrial-Park

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

Consultation about @unit.add_specification #105

Open zasddsgg opened 3 months ago

zasddsgg commented 3 months ago

Hello, may I ask you some questions about @unit.add_specification? Thanks for your help.

a) If I adjust pressure drop of the unit, are both of the following codes correct? The only difference between the two codes is that the first code first runs unit._run(), then run P0 = min([i.P for i in unit.ins]), Pf = P0 - unit.dP, for i in unit.outs: i.P = Pf, and the second code first runs P0 = min([i.P for i in unit.ins]), Pf = P0 - unit.dP, for i in unit.outs: i.P = Pf, and then runs unit._run(), is it right? Both two codes do not need to add code like unit.run_until(), is it right? It seems first run P0 = min([i.P for i in unit.ins]), Pf = p0-unit. dP, for i in unit.outs: i.P = Pf, then runs unit._run(), that is, the second type of code is more appropriate to adjust the unit pressure drop? Because it seems to reduce the unit outlet pressure first, and then run the unit to get the corresponding flow mass and heat conditions. The two codes are as follows:

unit.dP = 0.04
@unit.add_specification(run=False)
def set_dP():
    unit._run()
    P0 = min([i.P for i in unit.ins])    
    Pf = P0 - unit.dP
    for i in unit.outs: i.P = Pf
unit.dP = 0.04
@unit.add_specification(run=True)
def set_dP():
    P0 = min([i.P for i in unit.ins])    
    Pf = P0 - unit.dP
    for i in unit.outs: i.P = Pf

b) If I want to increase the pressure of the outlet stream of the previous unit (such as H101) through a pump (such as P101, i.e. the pressure of H101 outlet plus 10132.5), and then act as the inlet stream of the later unit (such as F101), could I consult you which of the following two codes is correct? There can be other codes between P101=units.Pump('P101', H101-0, P=101325) and @P101.add_specification(run=True), is it right? Both two codes do not need to add code like unit.run_until(), is it right? The codes are as follows:

H101 = units.HXutility('H101', inlet, T=370)
P101=units.Pump('P101', H101-0, P=101325)
F101 = units.Flash('F101', P101-0, outs=('F101_vapor', 'F101_liquid'), P=10132.5, Q=0)
@P101.add_specification(run=True) 
def adjust_pump_pressure_P101():
    a = H101-0
    P101.P = a.P + 10132.5
H101 = units.HXutility('H101', inlet, T=370)
P101=units.Pump('P101', H101-0, P=101325)
F101 = units.Flash('F101', P101-0, outs=('F101_vapor', 'F101_liquid'), P=10132.5, Q=0)
@P101.add_specification(run=False) 
def adjust_pump_pressure_P101():
    P101.run()
    a = H101-0
    P101.P = a.P + 10132.5

c) In def() in @unit.add_specification, def(), there is no need to add the code unit.run_until(), is it right? If no need to add the code unit.run_until(), how can we ensure that the unit that is @ and the units that after the unit that is @ are rerun after the specification is executed?

d) When using @unit.add_specification, how to select the unit that is @?