Closed zasddsgg closed 1 month ago
The module has been updated so the codes under the analyses
directory probably won't work. But if you want to create the uncertainty model, the following should work and you can write your own analysis codes depending on what types of analyses you want to run:
from biorefineries.lactic import create_model
model = create_model(kind='SSCF')
a) model_dct
does not appear to be in the create_model file
, so the following code still does not run (https://github.com/BioSTEAMDevelopmentGroup/Bioindustrial-Park/blob/master/biorefineries/lactic/analyses/1_uncertainties.py#L39-40, https://github.com/BioSTEAMDevelopmentGroup/Bioindustrial-Park/blob/master/biorefineries/lactic/analyses/1_uncertainties.py#L74, https://github.com/BioSTEAMDevelopmentGroup/Bioindustrial-Park/blob/master/biorefineries/lactic/analyses/1_uncertainties.py#L80)
b) Could I consult you what does model_dct['index_TEA'], model_dct['index_IRR'], model_dct['IRRs']
mean?
a. Please create and run the model separate rather than that module, I really don't have time to update the module so that it's compatible with the current biosteam setting. I suggest you try to understand each line of code and write your own ones. b. Those codes were probably used to same the index numbers/column headers to create a prettier output Excel table.
I'm writing my own code now, but I don't understand how much model_dct['index_TEA'], model_dct['index_IRR'], model_dct['IRRs']
should write (looks like a number, in lactic aicd, it is called directly) (https://github.com/BioSTEAMDevelopmentGroup/Bioindustrial-Park/blob/master/biorefineries/lactic/analyses/1_uncertainties.py#L74-L80, https://github.com/BioSTEAMDevelopmentGroup/Bioindustrial-Park/blob/master/biorefineries/lactic/analyses/1_uncertainties.py#L180). And how should I rewrite this (https://github.com/BioSTEAMDevelopmentGroup/Bioindustrial-Park/blob/master/biorefineries/lactic/analyses/1_uncertainties.py#L91-L92).
So when writing code, I don't know how to write the above codes.
Unfortunately, we do not have the bandwidth/time to go over this level of detail in the code. I suggest you read up documentation on Pandas and Chaospy, and go through the code line by line (printing variables as you go) to understand what is going on.
But now when the code runs into model_dct['index_TEA'], model_dct['index_IRR'], model_dct['IRRs'], there are errors, so I have no way of knowing what the code is trying to do, or what these parameters mean. So I don't know how to write my own code for model_dct['index_TEA'], model_dct['index_IRR'], model_dct['IRRs'].
You don't need those codes for your analyses, you can just ignore them.
From: zasddsgg @.> Sent: Monday, May 6, 2024 9:25 PM To: BioSTEAMDevelopmentGroup/Bioindustrial-Park @.> Cc: Yalin @.>; State change @.> Subject: Re: [BioSTEAMDevelopmentGroup/Bioindustrial-Park] Consultation about error for model_dct in lactic acid model (Issue #123)
But now when the code runs into model_dct['index_TEA'], model_dct['index_IRR'], model_dct['IRRs'], there are errors, so I have no way of knowing what the code is trying to do, or what these parameters mean. So I don't know how to write my own code for model_dct['index_TEA'], model_dct['index_IRR'], model_dct['IRRs'].
— Reply to this email directly, view it on GitHubhttps://github.com/BioSTEAMDevelopmentGroup/Bioindustrial-Park/issues/123#issuecomment-2097193222, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ALV5VLIDAU2RIT6VAUVYFWTZBAUQXAVCNFSM6AAAAABG7OHSAKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJXGE4TGMRSGI. You are receiving this because you modified the open/close state.Message ID: @.***>
But this seems to be used in the exported excel results, could I ask you if you have the code of defining model_dct['index_TEA'], model_dct['index_IRR'], model_dct['IRRs']? I can learn the relevant code myself. And then I know how to rewrite it.
I can't find the exact codes now, probably something like index_TEA = len(metrics)
(similar to the ones you asked from the 3HP biorefinery. It's just used to know what is the index of the column headers.
a) I tried to rewrite the original code (https://github.com/BioSTEAMDevelopmentGroup/Bioindustrial-Park/blob/master/biorefineries/lactic/analyses/1_uncertainties.py#L176-L185) into the following code. But an error will be reported. I refer to the HP process code (https://github.com/BioSTEAMDevelopmentGroup/Bioindustrial-Park/blob/master/biorefineries/HP/analyses/models_2015.py#L874, https://github.com/BioSTEAMDevelopmentGroup/Bioindustrial-Park/blob/master/biorefineries/HP/analyses/1_full_evaluation.py#L298-306). The code I rewrote is as follows:
if if_plot:
IRR_plot_indices = [metric.index for metric in model.metrics
if 'IRR' in metric.index[0] and 'MPSP' in metric.index[1]]
IRR_plot_data = IRR_results[IRR_plot_indices].copy()
IRRs = np.linspace(0, 0.4, 41)
IRR_plot_data.columns = IRRs.copy()
IRR_plot_y = IRR_plot_data.sort_index(axis=1)
IRR_plot_y = IRR_plot_y.dropna()
IRR_plot_x = IRRs.copy()
IRR_plot_x.sort()
plot_montecarlo_across_coordinate(IRR_plot_x, IRR_plot_y)
The error information is as follows:
ValueError Traceback (most recent call last)
Cell In[21], line 426
423 one_p_df.to_excel(writer, sheet_name='One-parameter')
424 model.table.to_excel(writer, sheet_name='Raw data')
--> 426 evaluate_uncertainties()
Cell In[21], line 405, in evaluate_uncertainties(seed, N_simulation, sampling_rule, percentiles, if_plot, report_name)
403 IRR_plot_data = IRR_results[IRR_plot_indices].copy()
404 IRRs = np.linspace(0, 0.4, 41)
--> 405 IRR_plot_data.columns = IRRs.copy()
406 IRR_plot_y = IRR_plot_data.sort_index(axis=1)
407 IRR_plot_y = IRR_plot_y.dropna()
File D:\anaconda\envs\zddd\lib\site-packages\pandas\core\generic.py:6218, in NDFrame.__setattr__(self, name, value)
6216 try:
6217 object.__getattribute__(self, name)
-> 6218 return object.__setattr__(self, name, value)
6219 except AttributeError:
6220 pass
File properties.pyx:69, in pandas._libs.properties.AxisProperty.__set__()
File D:\anaconda\envs\zddd\lib\site-packages\pandas\core\generic.py:767, in NDFrame._set_axis(self, axis, labels)
762 """
763 This is called from the cython code when we set the `index` attribute
764 directly, e.g. `series.index = [1, 2, 3]`.
765 """
766 labels = ensure_index(labels)
--> 767 self._mgr.set_axis(axis, labels)
768 self._clear_item_cache()
File D:\anaconda\envs\zddd\lib\site-packages\pandas\core\internals\managers.py:227, in BaseBlockManager.set_axis(self, axis, new_labels)
225 def set_axis(self, axis: AxisInt, new_labels: Index) -> None:
226 # Caller is responsible for ensuring we have an Index object.
--> 227 self._validate_set_axis(axis, new_labels)
228 self.axes[axis] = new_labels
File D:\anaconda\envs\zddd\lib\site-packages\pandas\core\internals\base.py:85, in DataManager._validate_set_axis(self, axis, new_labels)
82 pass
84 elif new_len != old_len:
---> 85 raise ValueError(
86 f"Length mismatch: Expected axis has {old_len} elements, new "
87 f"values have {new_len} elements"
88 )
ValueError: Length mismatch: Expected axis has 0 elements, new values have 41 elements
b) I learned the relevant code in the HP process, but index_TEA = len(metrics) (https://github.com/BioSTEAMDevelopmentGroup/Bioindustrial-Park/blob/master/biorefineries/HP/analyses/models_achieved_improvements.py#L857) and index_IRR = len(metrics) (https://github.com/BioSTEAMDevelopmentGroup/Bioindustrial-Park/blob/master/biorefineries/HP/analyses/models_achieved_improvements.py#L942) in the HP process seem to return the same value, because metrics are the same (https://github.com/BioSTEAMDevelopmentGroup/Bioindustrial-Park/blob/master/biorefineries/HP/analyses/models_achieved_improvements.py#L130-L547).
c) I tried to run the 1_full_evaluation.py file (https://github.com/BioSTEAMDevelopmentGroup/Bioindustrial-Park/blob/master/biorefineries/HP/analyses/1_full_evaluation.py ) of the HP process, but there was an error. It doesn't look like there is HP in biorefineries. Could I ask you how to the run it? The error is as follows:
ModuleNotFoundError Traceback (most recent call last)
Cell In[1], line 44
42 from biosteam.utils import TicToc
43 from biosteam.plots import plot_montecarlo_across_coordinate
---> 44 from biorefineries.HP.system_light_lle_vacuum_distillation import spec, HP_sys, get_AA_MPSP, get_GWP, get_FEC, R301, simulate_and_print
46 # from biorefineries.HP.analyses import models # for the baseline biorefinery
47 # from biorefineries.HP.analyses import models_targeted_improvements as models # for a biorefinery with targeted improvements over the baseline biorefinery
48 from biorefineries.HP.analyses import models_2015 as models # for the biorefinery with achieved fermentation performance improvements
ModuleNotFoundError: No module named 'biorefineries.HP'
c. It runs fine on my end, you probably need to pull from remote.
Could I consult you how to pull from remote, I am running directly 1_full_evaluation.py file in jupyter notebook.
Hello, when I run the code related to lactic acid, I encounter the following error. Could I consult you how to solve this error? Thanks for your help. Wish you a good day.
When I run here (https://github.com/BioSTEAMDevelopmentGroup/Bioindustrial-Park/blob/master/biorefineries/lactic/analyses/1_uncertainties.py#L45-L46), I get
TypeError: 'Model' object is not subscriptable
, I looked at the source code, and the functiondef create_model
seems to return model instead of a dictionary (https://github.com/BioSTEAMDevelopmentGroup/Bioindustrial-Park/blob/master/biorefineries/lactic/models.py#L440), somodel_dct = create_model(kind), model = model_dct['model']
doesn't seem to work?