2023-03-06 08:27:45 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2024-02-19 15:21:48 +00:00
|
|
|
# SPDX-FileCopyrightText: : 2020-2024 The PyPSA-Eur Authors
|
2023-03-06 17:49:23 +00:00
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: MIT
|
2021-07-01 18:09:04 +00:00
|
|
|
"""
|
2023-03-09 11:45:43 +00:00
|
|
|
Build industrial energy demand per model region.
|
2024-06-05 13:02:44 +00:00
|
|
|
|
|
|
|
Inputs
|
|
|
|
------
|
|
|
|
|
2024-09-13 13:37:01 +00:00
|
|
|
- ``resources/industrial_energy_demand_today_base_s_{clusters}.csv``
|
2024-06-05 13:02:44 +00:00
|
|
|
- ``resources/industry_sector_ratios_{planning_horizons}.csv``
|
2024-09-13 13:37:01 +00:00
|
|
|
- ``resources/industrial_production_base_s_{clusters}_{planning_horizons}.csv``
|
2024-06-05 13:02:44 +00:00
|
|
|
|
|
|
|
Outputs
|
|
|
|
-------
|
|
|
|
|
2024-09-13 13:37:01 +00:00
|
|
|
- ``resources/industrial_energy_demand_base_s_{clusters}_{planning_horizons}.csv``
|
2024-06-05 13:02:44 +00:00
|
|
|
|
|
|
|
Description
|
|
|
|
-------
|
|
|
|
This rule aggregates the energy demand of the industrial sectors per model region.
|
|
|
|
For each bus, the following carriers are considered:
|
|
|
|
- electricity
|
|
|
|
- coal
|
|
|
|
- coke
|
|
|
|
- solid biomass
|
|
|
|
- methane
|
|
|
|
- hydrogen
|
|
|
|
- low-temperature heat
|
|
|
|
- naphtha
|
|
|
|
- ammonia
|
|
|
|
- process emission
|
|
|
|
- process emission from feedstock
|
|
|
|
|
|
|
|
which can later be used as values for the industry load.
|
2021-07-01 18:09:04 +00:00
|
|
|
"""
|
2020-10-12 10:20:04 +00:00
|
|
|
|
|
|
|
import pandas as pd
|
2024-02-12 10:53:20 +00:00
|
|
|
from _helpers import set_scenario_config
|
|
|
|
|
2021-07-01 18:09:04 +00:00
|
|
|
if __name__ == "__main__":
|
|
|
|
if "snakemake" not in globals():
|
2023-03-06 18:09:45 +00:00
|
|
|
from _helpers import mock_snakemake
|
2023-03-06 08:27:45 +00:00
|
|
|
|
2021-07-01 18:09:04 +00:00
|
|
|
snakemake = mock_snakemake(
|
|
|
|
"build_industrial_energy_demand_per_node",
|
|
|
|
clusters=48,
|
2022-06-10 12:44:36 +00:00
|
|
|
planning_horizons=2030,
|
2021-07-01 18:09:04 +00:00
|
|
|
)
|
2024-02-12 10:53:20 +00:00
|
|
|
set_scenario_config(snakemake)
|
2023-03-06 08:27:45 +00:00
|
|
|
|
2024-02-14 17:15:18 +00:00
|
|
|
# import ratios
|
2021-07-01 18:09:04 +00:00
|
|
|
fn = snakemake.input.industry_sector_ratios
|
2024-02-14 17:15:18 +00:00
|
|
|
sector_ratios = pd.read_csv(fn, header=[0, 1], index_col=0)
|
2021-07-01 18:09:04 +00:00
|
|
|
|
2024-02-14 17:15:18 +00:00
|
|
|
# material demand per node and industry (Mton/a)
|
2021-07-01 18:09:04 +00:00
|
|
|
fn = snakemake.input.industrial_production_per_node
|
2024-02-14 17:15:18 +00:00
|
|
|
nodal_production = pd.read_csv(fn, index_col=0) / 1e3
|
2021-07-01 18:09:04 +00:00
|
|
|
|
|
|
|
# energy demand today to get current electricity
|
|
|
|
fn = snakemake.input.industrial_energy_demand_per_node_today
|
|
|
|
nodal_today = pd.read_csv(fn, index_col=0)
|
|
|
|
|
2024-02-14 17:15:18 +00:00
|
|
|
nodal_sector_ratios = pd.concat(
|
|
|
|
{node: sector_ratios[node[:2]] for node in nodal_production.index}, axis=1
|
|
|
|
)
|
|
|
|
|
|
|
|
nodal_production_stacked = nodal_production.stack()
|
|
|
|
nodal_production_stacked.index.names = [None, None]
|
2023-03-06 08:27:45 +00:00
|
|
|
|
2024-02-14 17:15:18 +00:00
|
|
|
# final energy consumption per node and industry (TWh/a)
|
|
|
|
nodal_df = (
|
|
|
|
(nodal_sector_ratios.multiply(nodal_production_stacked))
|
|
|
|
.T.groupby(level=0)
|
|
|
|
.sum()
|
2024-02-14 17:31:48 +00:00
|
|
|
)
|
2021-07-01 18:09:04 +00:00
|
|
|
|
|
|
|
rename_sectors = {
|
|
|
|
"elec": "electricity",
|
|
|
|
"biomass": "solid biomass",
|
|
|
|
"heat": "low-temperature heat",
|
|
|
|
}
|
|
|
|
nodal_df.rename(columns=rename_sectors, inplace=True)
|
|
|
|
|
|
|
|
nodal_df["current electricity"] = nodal_today["electricity"]
|
|
|
|
|
|
|
|
nodal_df.index.name = "TWh/a (MtCO2/a)"
|
|
|
|
|
|
|
|
fn = snakemake.output.industrial_energy_demand_per_node
|
|
|
|
nodal_df.to_csv(fn, float_format="%.2f")
|