Fix industrial demand for ammonia when endogenously modelled (#1312)

* Fix industrial demand for ammonia when endogenously modelled

In calculating industrial energy demand today, demand for ammonia must
be resolved into just "ammonia" when endogenously modelled, or into
electricity and hydrogen if not.

* Add release note
This commit is contained in:
Koen van Greevenbroek 2024-09-20 08:54:19 +02:00 committed by GitHub
parent 38f2dc7a75
commit 81da6859ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 26 additions and 15 deletions

View File

@ -75,6 +75,8 @@ Upcoming Release
* Resolved a problem where excluding certain countries from `countries` configuration led to clustering errors. * Resolved a problem where excluding certain countries from `countries` configuration led to clustering errors.
* Bugfix: demand for ammonia was double-counted at current/near-term planning horizons when ``sector['ammonia']`` was set to ``True``.
PyPSA-Eur 0.13.0 (13th September 2024) PyPSA-Eur 0.13.0 (13th September 2024)
====================================== ======================================

View File

@ -716,6 +716,7 @@ rule build_industrial_energy_demand_per_country_today:
params: params:
countries=config_provider("countries"), countries=config_provider("countries"),
industry=config_provider("industry"), industry=config_provider("industry"),
ammonia=config_provider("sector", "ammonia", default=False),
input: input:
transformation_output_coke=resources("transformation_output_coke.csv"), transformation_output_coke=resources("transformation_output_coke.csv"),
jrc="data/jrc-idees-2021", jrc="data/jrc-idees-2021",

View File

@ -133,6 +133,9 @@ def industrial_energy_demand_per_country(country, year, jrc_dir):
df["hydrogen"] = 0.0 df["hydrogen"] = 0.0
if snakemake.params.ammonia:
df["ammonia"] = 0.0
df["other"] = df["all"] - df.loc[df.index != "all"].sum() df["other"] = df["all"] - df.loc[df.index != "all"].sum()
return df return df
@ -153,14 +156,6 @@ def industrial_energy_demand_per_country(country, year, jrc_dir):
def separate_basic_chemicals(demand, production): def separate_basic_chemicals(demand, production):
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( chlorine = pd.DataFrame(
{ {
"hydrogen": production["Chlorine"] * params["MWh_H2_per_tCl"], "hydrogen": production["Chlorine"] * params["MWh_H2_per_tCl"],
@ -174,16 +169,29 @@ def separate_basic_chemicals(demand, production):
} }
).T ).T
demand["Ammonia"] = ammonia.unstack().reindex(index=demand.index, fill_value=0.0)
demand["Chlorine"] = chlorine.unstack().reindex(index=demand.index, fill_value=0.0) 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["Methanol"] = methanol.unstack().reindex(index=demand.index, fill_value=0.0)
demand["HVC"] = ( demand["HVC"] = demand["Basic chemicals"] - demand["Methanol"] - demand["Chlorine"]
demand["Basic chemicals"]
- demand["Ammonia"] # Deal with ammonia separately, depending on whether it is modelled endogenously.
- demand["Methanol"] ammonia_exo = pd.DataFrame(
- demand["Chlorine"] {
) "hydrogen": production["Ammonia"] * params["MWh_H2_per_tNH3_electrolysis"],
"electricity": production["Ammonia"]
* params["MWh_elec_per_tNH3_electrolysis"],
}
).T
if snakemake.params.ammonia:
ammonia = pd.DataFrame(
{"ammonia": production["Ammonia"] * params["MWh_NH3_per_tNH3"]}
).T
else:
ammonia = ammonia_exo
demand["Ammonia"] = ammonia.unstack().reindex(index=demand.index, fill_value=0.0)
demand["HVC"] -= ammonia_exo.unstack().reindex(index=demand.index, fill_value=0.0)
demand.drop(columns="Basic chemicals", inplace=True) demand.drop(columns="Basic chemicals", inplace=True)