BioSTEAMDevelopmentGroup / Bioindustrial-Park

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

Consultation about Flash #87

Closed zasddsgg closed 9 months ago

zasddsgg commented 9 months ago

Hello, when I call Flash, the returned result is a little strange, could I consult you why this happened? Thanks for your help. Wish you a good day.

For the following code:

import biosteam as bst bst.nbtutorial() from biosteam import settings from biosteam import units from biosteam import Stream, settings settings.set_thermo(['Water', 'CO2', 'Ethanol']) feed = Stream('feed', CO2=300, Water=1000, Ethanol=500, P=450000) H1 = units.HXutility('H1', feed, T=150+273.15) F1 = units.Flash('F1', H1-0, outs=('vapor', ''), P=450000, T=150+273.15)

D_sys = bst.main_flowsheet.create_system('D_sys') D_sys.simulate() D_sys.diagram('thorough', format='png') F1.Hnet

The outlet stream has vaporized, but why is F1.Hnet negative, i.e. heat release? Shouldn't vaporization absorb heat?

For the following code:

import biosteam as bst bst.nbtutorial() from biosteam import settings from biosteam import units from biosteam import Stream, settings settings.set_thermo(['Water', 'CO2', 'Ethanol']) feed = Stream('feed', CO2=300, Water=1000, Ethanol=500, P=4500000) H1 = units.HXutility('H1', feed, T=260+273.15, rigorous=True) F1 = units.Flash('F1', H1-0, outs=('vapor', ''), P=4500000, Q=0) hps = settings.get_heating_agent('high_pressure_steam') hps.T = 600 D_sys = bst.main_flowsheet.create_system('D_sys') D_sys.simulate() D_sys.diagram('thorough', format='png') F1

The heat exchanger has performed the gas-liquid balance, and Flash was set zero heat duty and zero pressure drop, but why the Flash outlet flow temperature was reduced, and why the gas state flow became liquid state flow after Flash? Shouldn't Flash naturally separate the gas and liquid phase of the inlet stream and the temperature of the outlet stream remains unchanged (same as inlet temperature)? For example, I tried to set Flash to the same temperature and pressure as the inlet stream, after running, Flash will naturally separate the gas and liquid phase of the inlet stream, the Hnet of Flash is 0 and no phase transition occurs, which seems to be reasonable.

For the following code: import biosteam as bst bst.nbtutorial() from biosteam import settings from biosteam import units from biosteam import Stream, settings settings.set_thermo(['Water', 'CO2', 'Ethanol']) feed = Stream('feed', CO2=300, Water=1000, Ethanol=500, P=4500000) H1 = units.HXutility('H1', feed, T=100+273.15, rigorous=True) F1 = units.Flash('F1', H1-0, outs=('vapor', ''), P=4500000, Q=0)

hps = settings.get_heating_agent('high_pressure_steam') hps.T = 600

D_sys = bst.main_flowsheet.create_system('D_sys') D_sys.simulate() D_sys.diagram('thorough', format='png') F1

After the gas-liquid balance of the heat exchanger is performed, the Flash inlet has a gas phase and a liquid phase, and the 0 pressure drop and 0 heat duty are set in Flash. But why does the Flash outlet flow all become gas phase flow? And why the Flash outlet flow temperature rises? Shouldn't Flash naturally separate the gas and liquid phase of the inlet stream and the temperature of the outlet stream remains unchanged (same as inlet temperature)? For example, I tried to set Flash to the same temperature and pressure as the inlet stream, after running, Flash will naturally separate the gas and liquid phase of the inlet stream, the Hnet of Flash is 0 and no phase transition occurs, which seems to be reasonable.

yoelcortes commented 9 months ago

@zasddsgg,

I do not get a negative number for your first code chunk (I get 0), the temperature does not change, and there is no liquid. Also, I get normal vapor and liquid flows in the second chunk. Please make the following edits to your post for further help:

  1. Start code block with ```python and end with ``` (https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks)
  2. Clearly show return value of the code (the code must print this if I run it).
  3. Clearly show expected result (what should have been printed).
  4. Remove lines that do not affect code: mainly diagram and nbtutorial.
  5. Note the biosteam and thermosteam version

Thanks!

zasddsgg commented 9 months ago

Thanks for your advice. I have modified the poster according to your advice. I use BioSTEAM version 2.37.0, ThermoSTEAM version 0.33.0.

Besides, do I need to add bst.nbtutorial() when building the process? If not, there will be a warning, such as “RuntimeWarning: CO2 has no defined Dortmund groups; functional group interactions are ignored”. When I build other processes, if I don't add bst.nbtutorial(), I also get warning, so should I add bst.nbtutorial() when I build processes?

I have also modified case #86 according to your requirements for convenient reading. I have tried some methods but still failed to solve this error, could I trouble you help to have a look? Thanks for your help. Wish you a good day.

For the following code, I got F1.Hnet: -717360639 and the outlet stream is all gas state, indicating that the inlet stream was vaporized, but vaporization should be an endothermic process, while F1.Hnet is negative, indicating an exothermic process?

import biosteam as bst
from biosteam import settings
from biosteam import units
from biosteam import Stream, settings
settings.set_thermo(['Water', 'CO2', 'Ethanol'])
feed = Stream('feed', CO2=300, Water=1000, Ethanol=500, P=450000)
H1 = units.HXutility('H1', feed, T=150+273.15)
F1 = units.Flash('F1',
           H1-0,
           outs=('vapor', ''),
           P=450000, 
           T=150+273.15) 

D_sys = bst.main_flowsheet.create_system('D_sys')
D_sys.simulate()
print("F1.Hnet: ", F1.Hnet) 
F1.show()

For the following code, after running, the Flash outlet flow temperature was reduced (from inlet 533.15K to outlet 343.31K), and the gas state inlet flow became liquid state outlet flow after Flash. I expect that the phase state of the Flash outlet is same as the inlet stream and the temperature of the outlet stream remains same as inlet temperature, because I set zero heat duty and zero pressure drop in Flash and the heat exchanger has performed the gas-liquid balance.

import biosteam as bst
from biosteam import settings
from biosteam import units
from biosteam import Stream, settings
settings.set_thermo(['Water', 'CO2', 'Ethanol'])
feed = Stream('feed', CO2=300, Water=1000, Ethanol=500, P=4500000)
H1 = units.HXutility('H1', feed, T=260+273.15, rigorous=True)
F1 = units.Flash('F1',
           H1-0,
           outs=('vapor', ''),
           P=4500000, 
           Q=0) 
hps = settings.get_heating_agent('high_pressure_steam')
hps.T = 600
D_sys = bst.main_flowsheet.create_system('D_sys')
D_sys.simulate()
F1.show()

For the following code, after running, the Flash inlet stream has both gas phase and liquid phase, but outlet stream has only gas state, and the Flash outlet flow temperature rises (from inlet 373.15K to outlet 1586K). I expect that the phase state of the Flash outlet is same as the inlet stream and the temperature of the outlet stream remains same as inlet temperature, because I set zero heat duty and zero pressure drop in Flash and the heat exchanger has performed the gas-liquid balance.

import biosteam as bst
from biosteam import settings
from biosteam import units
from biosteam import Stream, settings
settings.set_thermo(['Water', 'CO2', 'Ethanol'])
feed = Stream('feed', CO2=300, Water=1000, Ethanol=500, P=4500000)
H1 = units.HXutility('H1', feed, T=100+273.15, rigorous=True)
F1 = units.Flash('F1',
           H1-0,
           outs=('vapor', ''),
           P=4500000, 
           Q=0) 

hps = settings.get_heating_agent('high_pressure_steam')
hps.T = 600

D_sys = bst.main_flowsheet.create_system('D_sys')
D_sys.simulate()
F1.show()
yoelcortes commented 9 months ago

@zasddsgg,

Maybe it's a bug in that specific biosteam/thermosteam version... In BioSTEAM 2.38.3 and thermosteam 0.38.2, I'm getting the following results:

import biosteam as bst
from biosteam import settings
from biosteam import units
from biosteam import Stream, settings
settings.set_thermo(['Water', 'CO2', 'Ethanol'])
feed = Stream('feed', CO2=300, Water=1000, Ethanol=500, P=450000)
H1 = units.HXutility('H1', feed, T=150+273.15)
F1 = units.Flash('F1',
           H1-0,
           outs=('vapor', ''),
           P=450000, 
           T=150+273.15) 

D_sys = bst.main_flowsheet.create_system('D_sys')
D_sys.simulate()
print("F1.Hnet: ", F1.Hnet) 
F1.show()
F1.Hnet:  51045860.925071836
Flash: F1
ins...
[0] s1  from  HXutility-H1
    phase: 'l', T: 423.15 K, P: 450000 Pa
    flow (kmol/hr): Water    1e+03
                    CO2      300
                    Ethanol  500
outs...
[0] vapor  
    phase: 'g', T: 423.15 K, P: 450000 Pa
    flow (kmol/hr): Water    1e+03
                    CO2      300
                    Ethanol  500
[1] s2  
    phase: 'l', T: 423.15 K, P: 450000 Pa
    flow: 0
import biosteam as bst
from biosteam import settings
from biosteam import units
from biosteam import Stream, settings
settings.set_thermo(['Water', 'CO2', 'Ethanol'])
feed = Stream('feed', CO2=300, Water=1000, Ethanol=500, P=4500000)
H1 = units.HXutility('H1', feed, T=260+273.15, rigorous=True)
F1 = units.Flash('F1',
           H1-0,
           outs=('vapor', ''),
           P=4500000, 
           Q=0) 
hps = settings.get_heating_agent('high_pressure_steam')
hps.T = 600
D_sys = bst.main_flowsheet.create_system('D_sys')
D_sys.simulate()
F1.show()
Flash: F1
ins...
[0] s3  from  HXutility-H1
    phases: ('g', 'l'), T: 533.15 K, P: 4.5e+06 Pa
    flow (kmol/hr): (g) Water    1e+03
                        CO2      300
                        Ethanol  500
outs...
[0] vapor  
    phase: 'g', T: 533.15 K, P: 4.5e+06 Pa
    flow (kmol/hr): Water    1e+03
                    CO2      300
                    Ethanol  500
[1] s4  
    phase: 'l', T: 533.15 K, P: 4.5e+06 Pa
    flow: 0
import biosteam as bst
from biosteam import settings
from biosteam import units
from biosteam import Stream, settings
settings.set_thermo(['Water', 'CO2', 'Ethanol'])
feed = Stream('feed', CO2=300, Water=1000, Ethanol=500, P=4500000)
H1 = units.HXutility('H1', feed, T=100+273.15, rigorous=True)
F1 = units.Flash('F1',
           H1-0,
           outs=('vapor', ''),
           P=4500000, 
           Q=0) 

hps = settings.get_heating_agent('high_pressure_steam')
hps.T = 600

D_sys = bst.main_flowsheet.create_system('D_sys')
D_sys.simulate()
F1.show()
Flash: F1
ins...
[0] s5  from  HXutility-H1
    phases: ('g', 'l'), T: 373.15 K, P: 4.5e+06 Pa
    flow (kmol/hr): (g) Water    3.46
                        CO2      191
                        Ethanol  4.78
                    (l) Water    997
                        CO2      109
                        Ethanol  495
outs...
[0] vapor  
    phase: 'g', T: 373.15 K, P: 4.5e+06 Pa
    flow (kmol/hr): Water    3.46
                    CO2      191
                    Ethanol  4.78
[1] s6  
    phase: 'l', T: 373.15 K, P: 4.5e+06 Pa
    flow (kmol/hr): Water    997
                    CO2      109
                    Ethanol  495

Could you pip install biosteam==2.38.3 and see if the issue is resolved? Thanks,

zasddsgg commented 9 months ago

Thanks for your advice. I update BioSTEAM version, and above three code chunks are normal.

But the error in case #86 still occurred, even with an updated version of BioSTEAM, could I trouble you help to have a look at case #86? I have edited the poster for convenient reading.

Besides, do I need to add bst.nbtutorial() when building the process? If not, there will be a warning, such as “RuntimeWarning: CO2 has no defined Dortmund groups; functional group interactions are ignored”. When I build other processes, if I don't add bst.nbtutorial(), I also get warning, so should I add bst.nbtutorial() when I build processes?

Thanks for your help. Wish you a good day.

yoelcortes commented 9 months ago

@zasddsgg.

nbtutorial sets preferences for the notebooks in the documentation and filters warnings; it has no effect on your results: https://github.com/BioSTEAMDevelopmentGroup/biosteam/blob/master/biosteam/__init__.py

Thanks,