Skip to content

Commit ebdca40

Browse files
AndreasHD11pre-commit-ci[bot]tgilon
authored
feat: add imports to h2 MM supply benchmark (#604)
* feat: add imports to h2 MM supply benchmark * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update scripts/sb/clean_tyndp_output_benchmark.py Co-authored-by: Thomas Gilon <thomas.gilon@openenergytransition.org> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Prepare v0.6.1 (#603) * doc: prepare release v0.6.1 * doc: bump version * [github-actions.ci] Update locked envs * fix: fix typo * doc: update figures to v0.6.1 --------- Co-authored-by: tgilon <22521851+tgilon@users.noreply.github.com> * added PR to rst and readme * [github-actions.ci] Update locked envs * added review changes * [github-actions.ci] Update locked envs * restore pixi lock and envs to master * Update doc/release_notes.rst Co-authored-by: Thomas Gilon <thomas.gilon@openenergytransition.org> --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Thomas Gilon <thomas.gilon@openenergytransition.org> Co-authored-by: tgilon <22521851+tgilon@users.noreply.github.com>
1 parent a4c1b10 commit ebdca40

4 files changed

Lines changed: 62 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ While multiple TYNDP features are already introduced to the Open-TYNDP model, th
7575
|:------------------------------------------------------:|:-------------------------------------------------------------------------------------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:------:|
7676
| **Visualizations and workflow automation** | Automated workflow | ||
7777
| | TYNDP plotting routines | [#443](https://github.com/open-energy-transition/open-tyndp/pull/443) | 🔨 |
78-
| **Automated tests and benchmarks** | Automated benchmarking routine | [#73](https://github.com/open-energy-transition/open-tyndp/pull/73), [#117](https://github.com/open-energy-transition/open-tyndp/pull/117), [#281](https://github.com/open-energy-transition/open-tyndp/pull/281), [#467](https://github.com/open-energy-transition/open-tyndp/pull/467), [#543](https://github.com/open-energy-transition/open-tyndp/pull/543), [#574](https://github.com/open-energy-transition/open-tyndp/pull/574), [#607](https://github.com/open-energy-transition/open-tyndp/pull/607), [#615](https://github.com/open-energy-transition/open-tyndp/pull/615) | ✅ |
78+
| **Automated tests and benchmarks** | Automated benchmarking routine | [#73](https://github.com/open-energy-transition/open-tyndp/pull/73), [#117](https://github.com/open-energy-transition/open-tyndp/pull/117), [#281](https://github.com/open-energy-transition/open-tyndp/pull/281), [#467](https://github.com/open-energy-transition/open-tyndp/pull/467), [#543](https://github.com/open-energy-transition/open-tyndp/pull/543), [#574](https://github.com/open-energy-transition/open-tyndp/pull/574), [#607](https://github.com/open-energy-transition/open-tyndp/pull/607), [#615](https://github.com/open-energy-transition/open-tyndp/pull/615), [#604](https://github.com/open-energy-transition/open-tyndp/pull/604) | ✅ |
7979
| **TYNDP modelling features** | Perfect foresight optimization | ||
8080
| | Security of Supply (SoS) loop | ||
8181
| **Existing infrastructure and associated parameters** | Electricity reference grid | [#18](https://github.com/open-energy-transition/open-tyndp/pull/18), [#340](https://github.com/open-energy-transition/open-tyndp/pull/340), [#489](https://github.com/open-energy-transition/open-tyndp/pull/489), [#496](https://github.com/open-energy-transition/open-tyndp/pull/496), [#527](https://github.com/open-energy-transition/open-tyndp/pull/527) ||

doc/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ While multiple TYNDP features are already introduced to the Open-TYNDP model, th
173173
- 🔨
174174
* - **Automated tests and benchmarks**
175175
- Automated benchmarking routine
176-
- `#73 <https://github.com/open-energy-transition/open-tyndp/pull/73>`__, `#117 <https://github.com/open-energy-transition/open-tyndp/pull/117>`__, `#281 <https://github.com/open-energy-transition/open-tyndp/pull/281>`__, `#467 <https://github.com/open-energy-transition/open-tyndp/pull/467>`__, `#543 <https://github.com/open-energy-transition/open-tyndp/pull/543>`__, `#574 <https://github.com/open-energy-transition/open-tyndp/pull/574>`__, `#607 <https://github.com/open-energy-transition/open-tyndp/pull/607>`__, `#615 <https://github.com/open-energy-transition/open-tyndp/pull/615>`__
176+
- `#73 <https://github.com/open-energy-transition/open-tyndp/pull/73>`__, `#117 <https://github.com/open-energy-transition/open-tyndp/pull/117>`__, `#281 <https://github.com/open-energy-transition/open-tyndp/pull/281>`__, `#467 <https://github.com/open-energy-transition/open-tyndp/pull/467>`__, `#543 <https://github.com/open-energy-transition/open-tyndp/pull/543>`__, `#574 <https://github.com/open-energy-transition/open-tyndp/pull/574>`__, `#607 <https://github.com/open-energy-transition/open-tyndp/pull/607>`__, `#615 <https://github.com/open-energy-transition/open-tyndp/pull/615>`__, `#604 <https://github.com/open-energy-transition/open-tyndp/pull/604>`__
177177
- ✅
178178
* - **TYNDP modelling features**
179179
- Perfect foresight optimization

doc/release_notes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ Upcoming Open-TYNDP Release
2525

2626
* Disable OCGT as an extendable carrier and add load shedding for H2 and AC (https://github.com/open-energy-transition/open-tyndp/pull/547).
2727

28+
* Add imports to H2 MM supply benchmark (https://github.com/open-energy-transition/open-tyndp/pull/604).
29+
2830
* Add separate solver option for CBA MSV extraction (`cba.msv_extraction.solving`) and move CBA solve logs to `results/cba/logs/` (https://github.com/open-energy-transition/open-tyndp/pull/627).
2931

3032
**Bugfixes and Compatibility**

scripts/sb/clean_tyndp_output_benchmark.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,58 @@ def clean_MM_data_for_benchmarking(
498498
return MM_data
499499

500500

501+
def clean_h2_imports_for_benchmarking(
502+
crossborder_h2: pd.DataFrame,
503+
eu27: list[str],
504+
) -> pd.DataFrame:
505+
"""
506+
Extracts H2 imports from external nodes/buses for hydrogen supply benchmarking.
507+
508+
Filters crossborder H2 exchanges where bus0 starts with "X"
509+
and maps them to benchmark carriers:
510+
- XAmmonia: "ammonia imports"
511+
- Other X-nodes (eg. XDZ): "imports (renewable & low carbon)"
512+
513+
Parameters
514+
----------
515+
crossborder_h2 : pd.DataFrame
516+
H2 crossborder data from load_crossborder_sheet(), with row index
517+
[avg, bus0, bus1, max, min, sum] and border names as columns.
518+
eu27 : list[str]
519+
List of EU27 country codes (2-letter ISO).
520+
521+
Returns
522+
-------
523+
pd.DataFrame
524+
dataFrame with columns [carrier, bus, unit, table, value] for each importing country and an EU27 aggregated row.
525+
"""
526+
df = (
527+
crossborder_h2.loc[["bus0", "bus1", "sum"]]
528+
.rename(index={"bus0": "carrier", "bus1": "bus", "sum": "value"})
529+
.T.query("carrier.str.startswith('X', na=False)")
530+
.assign(
531+
carrier=lambda x: np.where(
532+
x.carrier == "XAmmonia",
533+
"ammonia imports",
534+
"imports (renewable & low carbon)",
535+
),
536+
unit=crossborder_h2.loc["sum", "unit"],
537+
bus=lambda df: df.bus + " H2",
538+
table="hydrogen_supply",
539+
)
540+
.reset_index(drop=True)
541+
)
542+
543+
df_eu27 = (
544+
df[df["bus"].str.extract(r"^(?:IB)?(.{2})")[0].isin(eu27)]
545+
.groupby("carrier")["value"]
546+
.sum()
547+
.reset_index()
548+
.assign(bus="EU27", unit="MWh", table="hydrogen_supply")
549+
)
550+
return pd.concat([df, df_eu27], ignore_index=True)
551+
552+
501553
def clean_crossborder_for_benchmarking(df: pd.DataFrame) -> pd.DataFrame:
502554
"""
503555
Clean crossborder data for benchmarking purposes.
@@ -609,6 +661,12 @@ def assign_meta_data(df, planning_horizon, scenario):
609661

610662
MM_data = pd.concat([MM_data, clean_crossborder_for_benchmarking(crossborder_agg)])
611663

664+
# concatenate crossborder H2 imports to MM data for benchmarking
665+
MM_data = pd.concat(
666+
[MM_data, clean_h2_imports_for_benchmarking(crossborder["H2"], eu27)],
667+
ignore_index=True,
668+
)
669+
612670
# load h2 demand time series
613671
logger.info("Processing hourly H2 demand tables")
614672
snapshots = get_snapshots(

0 commit comments

Comments
 (0)