Skip to content

Commit 643ea21

Browse files
author
cpschau
committed
allow for dynamic ptes capacity and remove cases for ptes as storage unit
1 parent 486ac2b commit 643ea21

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

scripts/pypsa-de/add_district_heating_subnodes.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def add_subnodes(
2828
cop: xr.DataArray,
2929
direct_heat_source_utilisation_profile: xr.DataArray,
3030
head: int = 40,
31+
dynamic_ptes_capacity: bool = False,
3132
) -> None:
3233
"""
3334
Add largest district heating systems subnodes to the network.
@@ -191,12 +192,30 @@ def add_subnodes(
191192
.set_index("Store")
192193
)
193194

194-
# Restrict PTES capacity in subnodes if modeled as store
195-
if stores.carrier.str.contains("pits$").any():
196-
stores.loc[stores.carrier.str.contains("pits$").index, "e_nom_max"] = (
197-
subnode["ptes_pot_mwh"]
195+
# Restrict PTES capacity in subnodes
196+
stores.loc[stores.carrier.str.contains("pits$").index, "e_nom_max"] = subnode[
197+
"ptes_pot_mwh"
198+
]
199+
200+
#
201+
202+
if dynamic_ptes_capacity:
203+
e_max_pu_static = stores.e_max_pu
204+
e_max_pu = (
205+
n.stores_t.e_max_pu[f"{subnode['cluster']} urban central water pits"]
206+
.rename(f"{name} water pits")
207+
.to_frame()
208+
.reindex(columns=stores.index)
209+
.fillna(e_max_pu_static)
198210
)
199-
n.add("Store", stores.index, **stores)
211+
n.add(
212+
"Store",
213+
stores.index,
214+
e_max_pu=e_max_pu,
215+
**stores.drop("e_max_pu", axis=1),
216+
)
217+
else:
218+
n.add("Store", stores.index, **stores)
200219

201220
# Replicate district heating storage units of mother node for subnodes
202221
storage_units = (
@@ -211,30 +230,8 @@ def add_subnodes(
211230
.set_index("StorageUnit")
212231
)
213232

214-
# Restrict PTES capacity in subnodes if modeled as storage unit
215-
if storage_units.carrier.str.contains("pits$").any():
216-
storage_units.loc[
217-
storage_units.carrier.str.contains("pits$"), "p_nom_max"
218-
] = (subnode["ptes_pot_mwh"] / storage_units["max_hours"])
219233
n.add("StorageUnit", storage_units.index, **storage_units)
220234

221-
# restrict PTES capacity in mother nodes
222-
mother_nodes_ptes_pot = subnodes_rest.groupby("cluster").ptes_pot_mwh.sum()
223-
224-
mother_nodes_ptes_pot.index = (
225-
mother_nodes_ptes_pot.index + " urban central water pits"
226-
)
227-
228-
if not n.storage_units.filter(like="urban central water pits", axis=0).empty:
229-
n.storage_units.loc[mother_nodes_ptes_pot.index, "p_nom_max"] = (
230-
mother_nodes_ptes_pot
231-
/ n.storage_units.loc[mother_nodes_ptes_pot.index, "max_hours"]
232-
)
233-
elif not n.stores.filter(like="urban central water pits", axis=0).empty:
234-
n.stores.loc[mother_nodes_ptes_pot.index, "e_nom_max"] = (
235-
mother_nodes_ptes_pot
236-
)
237-
238235
# Replicate district heating generators of mother node for subnodes
239236
generators = (
240237
n.generators.filter(like=f"{subnode['cluster']} urban central", axis=0)
@@ -458,6 +455,9 @@ def extend_heating_distribution(
458455
snakemake.input.direct_heat_source_utilisation_profiles
459456
),
460457
head=snakemake.params.district_heating["subnodes"]["nlargest"],
458+
dynamic_ptes_capacity=snakemake.params.district_heating["ptes"][
459+
"dynamic_capacity"
460+
],
461461
)
462462

463463
if snakemake.wildcards.planning_horizons == str(snakemake.params["baseyear"]):

0 commit comments

Comments
 (0)