-
Notifications
You must be signed in to change notification settings - Fork 43
Paper mill and synthetic aviation fuels #818
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 5 commits
8a89456
746a9f6
4008b14
d296fbf
ff21f60
420eb63
b339be4
64e394f
d67ce47
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| name: H2Integrate_config | ||
| system_summary: This reference paper mill plant is located in Minnesota and for its first pass, it contains paper mill plant | ||
| powered by grid. The system is designed to produce paper at a constant rate throughout the year. | ||
| driver_config: driver_config.yaml | ||
| technology_config: tech_config.yaml | ||
| plant_config: plant_config.yaml |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,184 @@ | ||
| # # -*- coding: utf-8 -*- | ||
| # """ | ||
| # Created on Fri May 15 07:38:06 2026 | ||
|
|
||
| # @author: mkoleva | ||
| # """ | ||
|
|
||
| # import pandas as pd | ||
| # import matplotlib.pyplot as plt | ||
|
|
||
| # # Load Excel file | ||
| # file_path = "Breakdown_costs_per_scenario.xlsx" | ||
| # df = pd.read_excel(file_path, sheet_name="Sheet1", header=None) | ||
|
|
||
| # # Scenario labels — edit however you prefer | ||
| # scenarios = [ | ||
| # "Paper + Pulp", | ||
| # "SAF with H2", | ||
| # "SAF with low-carbon H2", | ||
| # "Paper + Pulp\nSAF with H2", | ||
| # "Paper + Pulp\nSAF with low-carbon H2" | ||
| # ] | ||
|
|
||
| # # Extract cost component names | ||
| # components = df.iloc[3:, 0].values | ||
|
|
||
| # # Build scenario value arrays (sum of appropriate columns) | ||
| # records = {} | ||
| # records["Paper + Pulp"] = df.iloc[3:, [1, 2, 3]].astype(float).sum(axis=1).values | ||
| # records["SAF with H2"] = df.iloc[3:, [3]].astype(float).sum(axis=1).values | ||
| # records["SAF with low-carbon H2"] = df.iloc[3:, [4]].astype(float).sum(axis=1).values | ||
| # records["Paper + Pulp\nSAF with H2"] = df.iloc[3:, [5, 6, 7]].astype(float).sum(axis=1).values | ||
| # records["Paper + Pulp\nSAF with low-carbon H2"] = df.iloc[3:, [8, 9, 10]].astype(float).sum(axis=1).values | ||
|
|
||
| # # Build DataFrame | ||
| # plot_df = pd.DataFrame(records, index=components) | ||
| # plot_df = plot_df[scenarios] # order consistently | ||
|
|
||
| # # Assign custom colors | ||
| # colors = [] | ||
| # for comp in plot_df.index: | ||
| # if "CapEx" in comp: | ||
| # colors.append("navy") | ||
| # elif "OpEx" in comp: | ||
| # colors.append("orange") | ||
| # elif "Feedstock" in comp: | ||
| # colors.append("deepskyblue") | ||
| # elif "Taxes" in comp: | ||
| # colors.append("lightpink") | ||
| # elif "Finances" in comp: | ||
| # colors.append("yellowgreen") | ||
| # else: | ||
| # colors.append(None) # Let matplotlib choose default | ||
|
|
||
| # # Plotting | ||
| # plt.figure(figsize=(10, 6)) | ||
| # bottom = [0] * len(scenarios) | ||
|
|
||
| # for idx, comp in enumerate(plot_df.index): | ||
| # plt.bar( | ||
| # scenarios, | ||
| # plot_df.loc[comp], | ||
| # bottom=bottom, | ||
| # color=colors[idx], | ||
| # label=comp | ||
| # ) | ||
| # bottom = [bottom[i] + plot_df.loc[comp][i] for i in range(len(scenarios))] | ||
|
|
||
| # plt.xlabel("Scenario") | ||
| # plt.ylabel("Cost ($/kg)") | ||
| # plt.title("Cost Breakdown per Scenario") | ||
|
|
||
| # # FORCE horizontal x-axis labels | ||
| # plt.xticks(rotation=0, ha="center") | ||
|
|
||
| # plt.legend() | ||
| # plt.tight_layout() | ||
|
|
||
| # plt.savefig("stacked_cost_breakdown_final.png", dpi=300) | ||
| # plt.show() | ||
|
|
||
| import pandas as pd | ||
| import matplotlib.pyplot as plt | ||
| import numpy as np | ||
| import textwrap | ||
|
|
||
| # ------------------------------------------------------------- | ||
| # LOAD EXCEL | ||
| # ------------------------------------------------------------- | ||
| file_path = "Breakdown_costs_per_scenario.xlsx" | ||
| df = pd.read_excel(file_path, sheet_name="Sheet1", header=None) | ||
|
Comment on lines
+92
to
+93
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like this file depends on an Excel sheet, but this isn't included as part of this PR. Do you mean to add the sheet, or have a different script that produces it? Or maybe just remove this file entirely?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just removing it entirely would be fine. The excel was added to help me do the plots for the E2C NE MN project. |
||
|
|
||
| # ------------------------------------------------------------- | ||
| # READ STRUCTURE | ||
| # ------------------------------------------------------------- | ||
| scenario_row = df.iloc[0, 1:].tolist() | ||
| product_row = df.iloc[1, 1:].tolist() | ||
| components = df.iloc[2:, 0].astype(str).str.strip().tolist() | ||
| values = df.iloc[2:, 1:].astype(float) | ||
|
|
||
| # ------------------------------------------------------------- | ||
| # CLEAN NANS | ||
| # ------------------------------------------------------------- | ||
| valid = [i for i, s in enumerate(scenario_row) if str(s) != "nan"] | ||
| scenario_row = [scenario_row[i] for i in valid] | ||
| product_row = [product_row[i] for i in valid] | ||
| values = values.iloc[:, valid] | ||
|
|
||
| # ------------------------------------------------------------- | ||
| # MULTILINE SCENARIO LABELS (automatic wrapping) | ||
| # ------------------------------------------------------------- | ||
| scenario_row_wrapped = [ | ||
| "\n".join(textwrap.wrap(s, width=18)) for s in scenario_row | ||
| ] | ||
|
|
||
| # ------------------------------------------------------------- | ||
| # BUILD MULTIINDEX | ||
| # ------------------------------------------------------------- | ||
| tuples = list(zip(scenario_row_wrapped, product_row)) | ||
| df_plot = pd.DataFrame(values.values, index=components, columns=pd.MultiIndex.from_tuples(tuples)) | ||
|
|
||
| # ------------------------------------------------------------- | ||
| # FLATTENED PRODUCT LABELS | ||
| # ------------------------------------------------------------- | ||
| flat_products = product_row | ||
|
|
||
| # ------------------------------------------------------------- | ||
| # GROUP POSITIONS FOR SCENARIO LABELS | ||
| # ------------------------------------------------------------- | ||
| scenario_groups = {} | ||
| for idx, scen in enumerate(scenario_row_wrapped): | ||
| scenario_groups.setdefault(scen, []).append(idx) | ||
|
|
||
| x = np.arange(len(flat_products)) | ||
|
|
||
| # ------------------------------------------------------------- | ||
| # COLOR MAP | ||
| # ------------------------------------------------------------- | ||
| color_map = { | ||
| "CapEx ($/kg)": "navy", | ||
| "OpEx ($/kg)": "orange", | ||
| "Feedstock ($/kg)": "deepskyblue", | ||
| "Taxes ($/kg)": "lightpink", | ||
| "Finances ($/kg)": "yellowgreen" | ||
| } | ||
|
|
||
| # ------------------------------------------------------------- | ||
| # PLOT | ||
| # ------------------------------------------------------------- | ||
| plt.figure(figsize=(18, 7)) | ||
|
|
||
| bottom = np.zeros(len(x)) | ||
|
|
||
| for comp in components: | ||
| y = df_plot.loc[comp].values | ||
| plt.bar(x, y, bottom=bottom, color=color_map[comp], label=comp) | ||
| bottom += y | ||
|
|
||
| # ------------------------------------------------------------- | ||
| # X‑AXIS LABELS (PRODUCT LEVEL) | ||
| # ------------------------------------------------------------- | ||
| plt.xticks(x, flat_products, rotation=0, ha="center") | ||
|
|
||
| # ------------------------------------------------------------- | ||
| # Y‑AXIS LABEL | ||
| # ------------------------------------------------------------- | ||
| plt.ylabel("Levelized cost ($/kg)") | ||
|
|
||
| plt.title("Cost Breakdown by Product and Scenario") | ||
|
|
||
| # ------------------------------------------------------------- | ||
| # SCENARIO LABELS (CENTERED ABOVE GROUPS) | ||
| # ------------------------------------------------------------- | ||
| ymin, ymax = plt.ylim() | ||
| for scen, idxs in scenario_groups.items(): | ||
| center = np.mean(idxs) | ||
| plt.text(center, ymax + ymax*0.04, scen, | ||
| ha="center", va="bottom", fontsize=11, fontweight="bold") | ||
|
|
||
| plt.ylim(ymin, ymax * 1.25) | ||
|
|
||
| plt.legend(title="Cost Component", bbox_to_anchor=(1.02, 1), loc="upper left") | ||
| plt.tight_layout() | ||
| plt.show() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| name: driver_config | ||
| description: This analysis runs a paper mill plant and matches other examples in H2Integrate | ||
| general: | ||
| folder_output: outputs | ||
| recorder: | ||
| file: cases.sql | ||
| overwrite_recorder: true | ||
| flag: true | ||
| includes: ['*'] | ||
| excludes: ['*_resource*'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If keeping this file, could you please add a top-level docstring explanation about what it does (i.e. what's plotted, what needs to be run beforehand)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we are removing the excel file, I would suggest we remove this one, too.