BioSTEAMDevelopmentGroup / Bioindustrial-Park

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

Add LCA calculations and options for feedstock switching #56

Closed yalinli2 closed 1 year ago

yalinli2 commented 1 year ago

Hi @yoelcortes , some updates on what @emilypl2 @daltonwstewart and I will be working on:

  1. For Dalton's work we'd like to have a biorefinery for different types of sorghum: in addition to the sweet sorghum/sweet-based oil sorghum in the oilcane biorefineries, we also want grain sorghum and grain-based oil sorghum. So I'd like to refactor the corn biorefinery to add in LCA and the option for the users to choose different types of feedstocks.
  2. For Emily's work, there likely will be different biorefineries involved, but the cornstover biorefinery will be the first one. Similarly, we'd like to add in LCA and the options for different types of feedstocks.

Adding the LCA will be relatively straightforward, but an easier way to create different system configurations with different feedstocks could be helpful. Since I imagine in the future we might run feedstocks with similar but slightly different biorefinery configurations/parameter settings.

So I'm currently thinking of creating a Feedstock class to store some feedstock-specific inputs like composition, characterization factors, and include it as an input into the create_system function. I'll convert this draft PR into a formal one when I'm more or less done and ask you to review.

Dalton and Emily - I'm using thermosteam@master and biosteam@boiler (actually the qsdsan branch, but I'll keep it more or less at the same pace as the boiler branch), the boiler branch might get merged in in the next couple of days, when it's merged, I'll switch back to the master branch of biosteam.

Feel free to leave any suggestions here in the mean time, thanks all!

yoelcortes commented 1 year ago

OK! Thanks for the early heads up. The main suggestion I have right now is to split the equipment performance data from scripts as external files (which are loaded based through some function given the feedstock name). Regarding loading feedstock compositions/characterization factors/prices, you might look into thermosteam.ThermoData objects to load files from yaml/json files. It may not be quite what your looking for, but might give you some ideas.

I'd also like to add a Biorefinery class for the corn module (similar to cane and cornstove), but still keep the load method available. I also plan on removing the autoloading (the module level __getattr__ method), which causes debugging issues with imports. I should get those done before next year.

Good luck!

daltonwstewart commented 1 year ago

Hi @yalinli2

Thanks for getting this started! I just wanted to let you know that I believe the outputs of the grain sorghum biorefinery (DDGS, crude oil) will also have slightly different compositions than those from the corn biorefinery, in case you want to work on a way to modify those compositions right now too.

Happy to discuss further!

yalinli2 commented 1 year ago

@yoelcortes , thanks for the suggestion! I'll keep yaml/json in mind when doing this.

@daltonwstewart , thanks for letting me know about the output differences, can you make a list of the differences between these two biorefineries (material composition, configuration, unit operation conversion efficiency, etc.) so I can have a better idea while making the updates?

I'm spending the majority of my time on QSDsan this week, so this may need to wait a few days, but should be done in next 1-2 weeks.

yalinli2 commented 1 year ago

Hi @daltonwstewart I just updated the corn module and add the initial script to adjust the biorefinery settings/parameters, I put some placeholder lines to adjust stream prices, set characterization factors, TEA parameters (e.g., operating days), you can see how they can be adjusted in the grain_sorghum.py

to check some quick results:

# The original corn module
>>> from biorefineries import corn as cn
>>> cn.load()
>>> tea = cn.TEA
>>> tea.IRR = 0.1
>>> print(tea.operating_days)
>>> print(tea.solve_price(cn.ethanol))
330.0
0.5089318810193999
Stream: DDGS from <DDGSHandling: MH612>
 phase: 'l', T: 343.15 K, P: 101325 Pa
 composition (%): Water             10
                  Ash               5.47
                  Yeast             2.52
                  CaO               0.0399
                  TriOlein          7.47
                  H2SO4             0.333
                  Fiber             41.7
                  SolubleProtein    13.3
                  InsolubleProtein  19.2
                  ----------------  1.18e+04 kg/hr

# With some modification for grain sorghum
# I changed feedstock composition based on the data you collected
# I also changed feedstock price and operating days just to show they can be changed,
# but those are fake numbers
>>> from biorefineries.sorghum import grain_sorghum as gs
>>> gs.load()
>>> tea = gs.TEA
>>> tea.IRR = 0.1
>>> print(tea.operating_days)
>>> print(tea.solve_price(gs.ethanol))
>>> gs.DDGS.show('cwt100')
222.0
0.696726936539402
Stream: DDGS from <DDGSHandling: MH612>
 phase: 'l', T: 343.15 K, P: 101325 Pa
 composition (%): Water             10
                  Ash               9.19
                  Yeast             3.68
                  CaO               0.0544
                  TriOlein          10.2
                  H2SO4             0.453
                  Fiber             9.3
                  SolubleProtein    28.6
                  InsolubleProtein  28.6
                  ----------------  9.02e+03 kg/hr

If it looks good to you, you can start updating the numbers - let me know if there are additional parameters you'd like to change, thanks!

yalinli2 commented 1 year ago

And btw, changes to the corn module (to accommodate more flexible biorefinery parameter settings) did not appear to change the results, i.e., I got the same results by using either master branch or this feedstock branch, let me know if you notice any inconsistency, thanks!

>>> from biorefineries import corn as cn
>>> cn.load()
>>> tea = cn.TEA
>>> tea.IRR = 0.1
>>> print(tea.solve_price(cn.ethanol))
yoelcortes commented 1 year ago

@yalinli2, these changes all look great. Did you mean to leave this branch as a draft? I'd be happy to merge if it is ready.

yalinli2 commented 1 year ago

hey @yoelcortes thanks for checking in, yes I meant to have it as a draft now because I have only updated the corn module but not cornstover - I was initially planning to get things done in Jan but many unexpected things happened, so here we are šŸ¤·

things are getting to an end now so hopefully I'll have more time and have this finished soon. but I'll start teaching next week, worst case scenario, I'll allocate time for it during the spring break (in ~ a month)

kind of similar thing for the wwt module, we are reviewing the proof now so the paper should be out in the next 1-2 weeks, afterwards I'll try to find time to have the new wwt module in biosteam, hopefully by the end of March

thanks & sorry about the delays!

yalinli2 commented 1 year ago

@daltonwstewart can't remember where we left on the grain sorghum biorefinery, but I noticed that the settings haven't been updated, can you put actual values there?

@emilypl2 similarly for miscanthus, I made some simple modifications for you to update the settings related to miscanthus, can you start collecting/updating the relevant values?

we can talk about those in our meetings, thanks!

yalinli2 commented 1 year ago

@emilypl2 miscanthus lactic acid biorefinery is also done!