From 7f3ad792a9a7e36f09ce85c819834d29b247b558 Mon Sep 17 00:00:00 2001 From: Tom Brown Date: Wed, 14 Feb 2024 12:24:58 +0100 Subject: [PATCH] use production to determine today's energy demand for basic chemicals This uniformises how demand for basic chemicals is calculated. We also avoid unnecessary use of ammonia production separately. --- config/config.default.yaml | 3 +- rules/build_sector.smk | 1 - ...ustrial_energy_demand_per_country_today.py | 45 +++++++------------ 3 files changed, 17 insertions(+), 32 deletions(-) diff --git a/config/config.default.yaml b/config/config.default.yaml index 4245d926..79ca890d 100644 --- a/config/config.default.yaml +++ b/config/config.default.yaml @@ -636,8 +636,7 @@ industry: 2040: 0.12 2045: 0.16 2050: 0.20 - basic_chemicals_without_NH3_energy_demand_today: 1138. #TWh/a - basic_chemicals_without_NH3_production_today: 69. #Mt/a + basic_chemicals_without_NH3_production_today: 69. #Mt/a, = 86 Mtethylene-equiv - 17 MtNH3 HVC_production_today: 52. MWh_elec_per_tHVC_mechanical_recycling: 0.547 MWh_elec_per_tHVC_chemical_recycling: 6.9 diff --git a/rules/build_sector.smk b/rules/build_sector.smk index c25c8673..f50432d6 100644 --- a/rules/build_sector.smk +++ b/rules/build_sector.smk @@ -566,7 +566,6 @@ rule build_industrial_energy_demand_per_country_today: industry=config["industry"], input: jrc="data/bundle-sector/jrc-idees-2015", - ammonia_production=RESOURCES + "ammonia_production.csv", industrial_production_per_country=RESOURCES + "industrial_production_per_country.csv", output: diff --git a/scripts/build_industrial_energy_demand_per_country_today.py b/scripts/build_industrial_energy_demand_per_country_today.py index 696921de..65569b55 100644 --- a/scripts/build_industrial_energy_demand_per_country_today.py +++ b/scripts/build_industrial_energy_demand_per_country_today.py @@ -94,51 +94,34 @@ def industrial_energy_demand_per_country(country, year, jrc_dir): return df -def separate_basic_chemicals(demand): - # MtNH3/a - fn = snakemake.input.ammonia_production - ammonia = pd.read_csv(fn, index_col=0)[str(year)] / 1e3 +def separate_basic_chemicals(demand, production): - ammonia = pd.DataFrame({"gas": ammonia * params["MWh_CH4_per_tNH3_SMR"], - "electricity" : ammonia * params["MWh_elec_per_tNH3_SMR"]}).T + ammonia = pd.DataFrame({"hydrogen": production["Ammonia"] * params["MWh_H2_per_tNH3_electrolysis"], + "electricity" : production["Ammonia"] * params["MWh_elec_per_tNH3_electrolysis"]}).T + chlorine = pd.DataFrame({"hydrogen": production["Chlorine"] * params["MWh_H2_per_tCl"], + "electricity" : production["Chlorine"] * params["MWh_elec_per_tCl"]}).T + methanol = pd.DataFrame({"gas": production["Methanol"] * params["MWh_CH4_per_tMeOH"], + "electricity" : production["Methanol"] * params["MWh_elec_per_tMeOH"]}).T demand["Ammonia"] = ammonia.unstack().reindex(index=demand.index, fill_value=0.0) - - demand["Basic chemicals (without ammonia)"] = ( - demand["Basic chemicals"] - demand["Ammonia"] - ) - - demand.drop(columns="Basic chemicals", inplace=True) - - distribution = demand["Basic chemicals (without ammonia)"].groupby(level=0).sum()/params["basic_chemicals_without_NH3_energy_demand_today"] - - chlorine = pd.DataFrame({"hydrogen": distribution * params["chlorine_production_today"] * params["MWh_H2_per_tCl"], - "electricity" : distribution * params["chlorine_production_today"] * params["MWh_elec_per_tCl"]}).T - - methanol = pd.DataFrame({"gas": distribution * params["methanol_production_today"] * params["MWh_CH4_per_tMeOH"], - "electricity" : distribution * params["methanol_production_today"] * params["MWh_elec_per_tMeOH"]}).T - demand["Chlorine"] = chlorine.unstack().reindex(index=demand.index, fill_value=0.0) demand["Methanol"] = methanol.unstack().reindex(index=demand.index, fill_value=0.0) demand["HVC"] = ( - demand["Basic chemicals (without ammonia)"] -demand["Methanol"] - demand["Chlorine"] + demand["Basic chemicals"] - demand["Ammonia"] - demand["Methanol"] - demand["Chlorine"] ) - demand.drop(columns="Basic chemicals (without ammonia)", inplace=True) + demand.drop(columns="Basic chemicals", inplace=True) demand["HVC"].clip(lower=0, inplace=True) return demand -def add_non_eu28_industrial_energy_demand(countries, demand): +def add_non_eu28_industrial_energy_demand(countries, demand, production): non_eu28 = countries.difference(eu28) if non_eu28.empty: return demand - # output in MtMaterial/a - fn = snakemake.input.industrial_production_per_country - production = pd.read_csv(fn, index_col=0) / 1e3 eu28_production = production.loc[countries.intersection(eu28)].sum() eu28_energy = demand.groupby(level=1).sum() @@ -182,9 +165,13 @@ if __name__ == "__main__": demand = industrial_energy_demand(countries.intersection(eu28), year) - demand = separate_basic_chemicals(demand) + # output in MtMaterial/a + production = pd.read_csv(snakemake.input.industrial_production_per_country, + index_col=0) / 1e3 - demand = add_non_eu28_industrial_energy_demand(countries, demand) + demand = separate_basic_chemicals(demand, production) + + demand = add_non_eu28_industrial_energy_demand(countries, demand, production) # for format compatibility demand = demand.stack(dropna=False).unstack(level=[0, 2])