BioSTEAMDevelopmentGroup / Bioindustrial-Park

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

Consultation about LCA settings in BioSTEAM #110

Closed zasddsgg closed 3 months ago

zasddsgg commented 3 months ago

Hello, if I want to carry out LCA related to the following three environmental impact types: GWP, acidification and eutrophication in BioSTEAM, could I consult you how should I set them in BioSTEAM? There seems to be only GWP settings in the tutorial (https://biosteam.readthedocs.io/en/latest/tutorial/Life_cycle_assessment.html) Besides, for GWP 100yr in GWP = 'GWP 100yr' (https://biosteam.readthedocs.io/en/latest/tutorial/Life_cycle_assessment.html#:~:text=Environmental%20Impacts%20(TRACI)-,GWP%20%3D%20%27GWP%20100yr%27,-bst.settings), does it refer to the GWP obtained by the CML method or the GWP obtained by the Recipe method?

zasddsgg commented 3 months ago

I try to use bst.settings.define_impact_indicator(key='AP', units='kg*SO2e'), but error is reported: UndefinedUnitError: 'SO2e' is not defined in the unit registry.

yoelcortes commented 3 months ago

@zasddsgg,

You can define 'SO2e' programmatically through the unit registry (https://pint.readthedocs.io/en/0.23/advanced/defining.html#programmatically):

from thermosteam import units_of_measure
import biosteam as bst
units_of_measure.ureg.define('SO2e = [SO2e]')
bst.settings.define_impact_indicator(key='AP', units='SO2e')

Or you can skip the units all together (this just means you cannot input CFs in other units like lb*SO2e):

bst.settings.define_impact_indicator(key='AP')

Thanks,

zasddsgg commented 3 months ago

Thank you for your answer. Regarding the definition of environmental impact type units, may I ask you the following questions.

a) If I want to define the unit as kg*CO2e like bst.settings.define_impact_indicator(key=GWP, units='kg*CO2e') in https://biosteam.readthedocs.io/en/latest/tutorial/Life_cycle_assessment.html#:~:text=Environmental%20Impacts%20(TRACI)-,GWP%20%3D%20%27GWP%20100yr%27,-bst.settings, do I do it with the following code:

from thermosteam import units_of_measure
import biosteam as bst
units_of_measure.ureg.define('kg*SO2e = [kg*SO2e]')
bst.settings.define_impact_indicator(key='AP', units='kg*SO2e')

b) For the above code in AP, instead of defining GWP in advance like GWP =' GWP 100yr', bst.settings.define_impact_indicator(key=GWP, units='kg*CO2e'), then pass key=GWP in https://biosteam.readthedocs.io/en/latest/tutorial/Life_cycle_assessment.html#:~:text=Environmental%20Impacts%20(TRACI)-,GWP%20%3D%20%27GWP%20100yr%27,-bst.settings, AP code just pass key='AP', is that OK? Is there any difference from the way GWP (GWP =' GWP 100yr') that is defined in advance? Finally, when calculating the AP of the process, can the AP of a process be calculated directly with the code AP_displacement = sys.get_net_impact(key='AP')/sys.get_mass_flow(stream), i.e., key='AP'? Doesn't it need to pre-define GWP = 'GWP 100yr' like GWP and then pass key=GWP?

c) If I pass the code units_of_measure.ureg.define('kg*Pe = [kg*Pe]'), bst.settings.define_impact_indicator(key='EP', units='kg*Pe') defines EP, and an error is still reported:

DefinitionSyntaxError: Cannot define 'kg*Pe' (<class 'pint.delegates.txt_defparser.plain.UnitDefinition'>): is not a valid unit name (must follow Python identifier rules)
    1,0-1,15 kg*Pe = [kg*Pe]

d) If I want to define three environmental impact types at the same time, can I only repeat the code like this:

units_of_measure.ureg.define('kg*SO2e = [kg*SO2e]')
bst.settings.define_impact_indicator(key='AP', units='kg*SO2e')
GWP = 'GWP 100yr'
bst.settings.define_impact_indicator(key=GWP, units='kg*CO2e')
units_of_measure.ureg.define('kg*Pe = [kg*Pe]')
bst.settings.define_impact_indicator(key='EP', units='kg*Pe')
stream1.set_CF(GWP, value1, basis='kg', units='kg*CO2e')
stream1.set_CF('AP', value2, basis='kg', units='kg*SO2e')
stream1.set_CF('EP', value3, basis='kg', units='kg*Pe')
sys.simulate()
GWP_displacement = sys.get_net_impact(key=GWP) / sys.get_mass_flow(stream)
AP_displacement = sys.get_net_impact(key='AP') / sys.get_mass_flow(stream)
EP_displacement = sys.get_net_impact(key='EP') / sys.get_mass_flow(stream)

e) Besides, for GWP 100yr in GWP = 'GWP 100yr'(https://biosteam.readthedocs.io/en/latest/tutorial/Life_cycle_assessment.html#:~:text=Environmental%20Impacts%20(TRACI)-,GWP%20%3D%20%27GWP%20100yr%27,-bst.settings), does it refer to the GWP obtained by the CML method or the GWP obtained by the Recipe method?

zasddsgg commented 3 months ago

Hello, could I trouble you take some time to look at this last issue. Thanks for your help.

yoelcortes commented 3 months ago

@zasddsgg,

a, c, d) No, please read the Pint documentation link I sent you to understand why that code does not work. Just define SO2e using the code I posted, then you can define your impact indicator in terms of "kg*SO2e":

from thermosteam import units_of_measure
import biosteam as bst
units_of_measure.ureg.define('SO2e = [SO2e]')
bst.settings.define_impact_indicator(key='AP', units='kg*SO2e')

b) It doesn't matter.

zasddsgg commented 3 months ago

Thanks for your advice, I already know how to set it up. Could I ask you if BioSTEAM can set following three environmental impact types (code define_impact_indicator) and CF of multiple streams at the same time? The following code looks a little repetitive. Thanks for your help.

units_of_measure.ureg.define('SO2e = [SO2e]')
bst.settings.define_impact_indicator(key='AP', units='kg*SO2e')
GWP = 'GWP 100yr'
bst.settings.define_impact_indicator(key=GWP, units='kg*CO2e')
units_of_measure.ureg.define('Pe = [Pe]')
bst.settings.define_impact_indicator(key='EP', units='kg*Pe')
stream1.set_CF(GWP, value1, basis='kg', units='kg*CO2e')
stream1.set_CF('AP', value2, basis='kg', units='kg*SO2e')
stream1.set_CF('EP', value3, basis='kg', units='kg*Pe')
sys.simulate()
GWP_displacement = sys.get_net_impact(key=GWP) / sys.get_mass_flow(stream)
AP_displacement = sys.get_net_impact(key='AP') / sys.get_mass_flow(stream)
EP_displacement = sys.get_net_impact(key='EP') / sys.get_mass_flow(stream)
yoelcortes commented 3 months ago

Yeah, that should work. You can have as many indicators as you like.

Thanks,

On Thu, Mar 14, 2024, 8:36 AM zasddsgg @.***> wrote:

Thanks for your advice, I already know how to set it up. Could I ask you if BioSTEAM can set following three environmental impact types (code define_impact_indicator) and CF of multiple streams at the same time? The following code looks a little repetitive. Thanks for your help.

units_of_measure.ureg.define('SO2e = [SO2e]') bst.settings.define_impact_indicator(key='AP', units='kgSO2e') GWP = 'GWP 100yr' bst.settings.define_impact_indicator(key=GWP, units='kgCO2e') units_of_measure.ureg.define('Pe = [Pe]') bst.settings.define_impact_indicator(key='EP', units='kgPe') stream1.set_CF(GWP, value1, basis='kg', units='kgCO2e') stream1.set_CF('AP', value2, basis='kg', units='kgSO2e') stream1.set_CF('EP', value3, basis='kg', units='kgPe') sys.simulate() GWP_displacement = sys.get_net_impact(key=GWP) / sys.get_mass_flow(stream) AP_displacement = sys.get_net_impact(key='AP') / sys.get_mass_flow(stream) EP_displacement = sys.get_net_impact(key='EP') / sys.get_mass_flow(stream)

— Reply to this email directly, view it on GitHub https://github.com/BioSTEAMDevelopmentGroup/Bioindustrial-Park/issues/110#issuecomment-1997478152, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHBJMMMWUXGDX6Z4CRQB4X3YYGRVFAVCNFSM6AAAAABEPO7WM2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOJXGQ3TQMJVGI . You are receiving this because you modified the open/close state.Message ID: <BioSTEAMDevelopmentGroup/Bioindustrial-Park/issues/110/1997478152@ github.com>

zasddsgg commented 3 months ago

I got it. Thanks for your help again.