BioSTEAMDevelopmentGroup / Bioindustrial-Park

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

Consultation about how to perform uncertainty analysis in BioSTEAM #118

Closed zasddsgg closed 1 month ago

zasddsgg commented 2 months ago

Hello, could I ask you some questions about how to perform uncertainty analysis in BioSTEAM. Thanks for your help. Wish you a good day.

a) Running the file 1_uncertainties (https://github.com/BioSTEAMDevelopmentGroup/Bioindustrial-Park/blob/master/biorefineries/lactic/analyses/1_uncertainties.py) directly generates an error: ImportError: cannot import name 'SSCF_flowsheet' from 'biorefineries.lactic' (D:\anaconda\envs\zddd\lib\site-packages\biorefineries\lactic\__init__.py). May I ask you how to solve this problem?

b) I have read the relevant tutorial (https://github.com/BioSTEAMDevelopmentGroup/Bioindustrial-Park/blob/master/biorefineries/lactic/analyses/1_uncertainties.py, https://github.com/BioSTEAMDevelopmentGroup/Bioindustrial-Park/blob/master/biorefineries/lactic/models.py, https://biosteam.readthedocs.io/en/latest/tutorial/Uncertainty_and_sensitivity.html), but I am still not sure how to perform uncertainty analysis and global sensitivity analysis in my own process, may I ask you which codes should I use if I perform uncertainty analysis and global sensitivity analysis in my own process?

zasddsgg commented 2 months ago

Hello, could I trouble you help look at this problem. Now I seem to be unable to check the results of the uncertainty analysis of paper "Sustainable Lactic Acid Production from Lignocellulosic Biomass".

yalinli2 commented 2 months ago

Hello, sorry we've been swamped recently and couldn't get to your questions now, it the module doesn't work most likely it's because it's not compatible with BioSTEAM's recent updates. If you revert to BioSTEAM/Thermosteam's version as indicated in the paper, it should work.


From: zasddsgg @.> Sent: Thursday, April 25, 2024 9:39 PM To: BioSTEAMDevelopmentGroup/Bioindustrial-Park @.> Cc: Subscribed @.***> Subject: Re: [BioSTEAMDevelopmentGroup/Bioindustrial-Park] Consultation about how to perform uncertainty analysis in BioSTEAM (Issue #118)

Hello, could I trouble you help look at this problem. Now I seem to be unable to check the results of the uncertainty analysis of paper "Sustainable Lactic Acid Production from Lignocellulosic Biomass".

— Reply to this email directly, view it on GitHubhttps://github.com/BioSTEAMDevelopmentGroup/Bioindustrial-Park/issues/118#issuecomment-2078534955, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ALV5VLMUIGBISACCO4JJ3HLY7G47LAVCNFSM6AAAAABGX7N6OOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANZYGUZTIOJVGU. You are receiving this because you are subscribed to this thread.Message ID: @.***>

zasddsgg commented 2 months ago

Thank you for your reply. I did not find the introduction of the version in the article. I tried to install biosteam v2.20.21 (https://github.com/BioSTEAMDevelopmentGroup/Bioindustrial-Park/tree/master/biorefineries/lactic#:~:text=Analyses%20(in%20./analyses)%20performed%20for%20the%20paper4%20and%20archived%20results%20(see%20commit%20f56692d)%20were%20generated%20using%20biosteam%20v2.20.21%2C%20thermosteam%20v0.20.26%2C%20and%20dependencies. ), but I got an error “The 'sklearn' PyPI package is deprecated, use 'scikit-learn' rather than 'sklearn' for pip commands. I tried to install biosteam v2.44.1, but still report error “ImportError: cannot import name 'SSCF_flowsheet' from 'biorefineries.lactic' (D:\anaconda\envs\zddd\lib\site-packages\biorefineries\lactic\__init__.py)”.

yalinli2 commented 1 month ago

OK I updated the module a little to be compatible with the new biosteam, but there's no way for us to teach you every single usage of biosteam, you need to understand what each line means so you can make changes as you see fit. We make mistakes and some codes might be confusing, but if you understand what we wanted to do with each line, you can see which ones make sense for your usage and modify the ones that don't work for you.

zasddsgg commented 1 month ago

Thank you for modifying the code. I want to view the detailed excel result of lactic acid by running the code to make sure there is no problem with my own process. For your modified code, I still seem to get an error in code model_dct = lactic.create_model(kind). The error information is as follows.

AttributeError                            Traceback (most recent call last)
Cell In[1], line 200
    197             one_p_df.to_excel(writer, sheet_name='One-parameter')
    198             model.table.to_excel(writer, sheet_name='Raw data')
--> 200 evaluate_uncertainties(kind='SSCF', seed=None, N_simulation=10, sampling_rule='L',
    201                         percentiles = [0, 0.05, 0.25, 0.5, 0.75, 0.95, 1],
    202                         if_plot=True, report_name='1_full_evaluation.xlsx')

Cell In[1], line 39, in evaluate_uncertainties(kind, seed, N_simulation, sampling_rule, percentiles, if_plot, report_name)
     37 simulate_get_MPSP = funcs['simulate_get_MPSP']
     38 simulate_get_MPSP()
---> 39 model_dct = lactic.create_model(kind)
     40 model = model_dct['model']
     42 # =============================================================================
     43 # Evaluate and organize results for Monte Carlo analysis
     44 # =============================================================================
     45 
     46 # Initiate a timer

File D:\anaconda\envs\zddd\lib\site-packages\biorefineries\lactic\models.py:44, in create_model(flowsheet, kind)
     42     lactic_sys = create_system(kind=kind)
     43     flowsheet = lactic_sys.flowsheet
---> 44 else: lactic_sys = flowsheet.system.lactic_sys
     45 lactic_sys.simulate() # need this to initialize some settings
     46 s = flowsheet.stream

AttributeError: 'str' object has no attribute 'system'
yalinli2 commented 1 month ago

Please see my reply in #123, I don't have time to update the analyses codes to be compatible with the new biosteam, so the best approach is to use the new function create_model then simulate

from biorefineries.lactic import create_model
model = create_model(kind='SSCF')