Skip to content

Commit bf23f04

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 3b64f8e commit bf23f04

File tree

3 files changed

+22
-23
lines changed

3 files changed

+22
-23
lines changed

Snakefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ rule prepare_district_heating_subnodes:
388388
def baseyear_value(wildcards):
389389
return config_provider("scenario", "planning_horizons", 0)(wildcards)
390390

391+
391392
rule add_district_heating_subnodes:
392393
params:
393394
district_heating=config_provider("sector", "district_heating"),
@@ -417,7 +418,7 @@ rule add_district_heating_subnodes:
417418
direct_heat_source_utilisation_profiles=resources(
418419
"direct_heat_source_utilisation_profiles_base_s_{clusters}_{planning_horizons}.nc"
419420
),
420-
existing_heating_distribution=lambda w:resources(
421+
existing_heating_distribution=lambda w: resources(
421422
f"existing_heating_distribution_base_s_{{clusters}}_{baseyear_value(w)}.csv"
422423
),
423424
lau_regions="data/lau_regions.zip",

scripts/prepare_sector_network.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3031,9 +3031,7 @@ def add_heat(
30313031
# 1e3 converts from W/m^2 to MW/(1000m^2) = kW/m^2
30323032
solar_thermal = options["solar_cf_correction"] * solar_thermal / 1e3
30333033

3034-
for (
3035-
heat_system
3036-
) in (
3034+
for heat_system in (
30373035
HeatSystem
30383036
): # this loops through all heat systems defined in _entities.HeatSystem
30393037
overdim_factor = options["overdimension_heat_generators"][
@@ -6018,9 +6016,9 @@ def add_enhanced_geothermal(
60186016
* Nyears
60196017
)
60206018

6021-
assert (
6022-
egs_potentials["capital_cost"] > 0
6023-
).all(), "Error in EGS cost, negative values found."
6019+
assert (egs_potentials["capital_cost"] > 0).all(), (
6020+
"Error in EGS cost, negative values found."
6021+
)
60246022

60256023
orc_annuity = calculate_annuity(costs.at["organic rankine cycle", "lifetime"], dr)
60266024
orc_capital_cost = (orc_annuity + FOM / (1 + FOM)) * orc_capex * Nyears

scripts/pypsa-de/add_district_heating_subnodes.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,12 @@
44

55
import os
66
import sys
7+
from typing import Dict, List
78

89
import geopandas as gpd
910
import pandas as pd
1011
import pypsa
1112
import xarray as xr
12-
from typing import Dict, List
13-
14-
import os
15-
import sys
1613

1714
sys.path.append(os.path.join(os.path.dirname(__file__), "..", ".."))
1815

@@ -59,10 +56,12 @@ def add_buses(n: pypsa.Network, subnode: pd.Series, name: str) -> None:
5956
def get_district_heating_loads(n: pypsa.Network):
6057
"""
6158
Get the district heating loads from the network.
59+
6260
Parameters
6361
----------
6462
n : pypsa.Network
6563
The PyPSA network object from which to extract district heating loads.
64+
6665
Returns
6766
-------
6867
float
@@ -71,9 +70,9 @@ def get_district_heating_loads(n: pypsa.Network):
7170
return (
7271
n.snapshot_weightings.generators
7372
@ n.loads_t.p_set.filter(
74-
like=f"urban central heat",
73+
like="urban central heat",
7574
)
76-
).sum() + n.loads.filter(like=f"low-temperature heat for industry", axis=0)[
75+
).sum() + n.loads.filter(like="low-temperature heat for industry", axis=0)[
7776
"p_set"
7877
].sum() * 8760
7978

@@ -178,13 +177,13 @@ def add_loads(
178177
)
179178

180179
# Adjust loads of cluster buses
181-
n.loads_t.p_set.loc[
182-
:, f'{subnode["cluster"]} urban central heat'
183-
] -= urban_central_heat_load
180+
n.loads_t.p_set.loc[:, f"{subnode['cluster']} urban central heat"] -= (
181+
urban_central_heat_load
182+
)
184183

185-
n.loads.loc[
186-
f'{subnode["cluster"]} low-temperature heat for industry', "p_set"
187-
] -= low_temperature_heat_for_industry_load
184+
n.loads.loc[f"{subnode['cluster']} low-temperature heat for industry", "p_set"] -= (
185+
low_temperature_heat_for_industry_load
186+
)
188187

189188
if lost_load > 0:
190189
lost_load_subnode = subnode["yearly_heat_demand_MWh"] - (
@@ -528,6 +527,7 @@ def add_subnodes(
528527
Dictionary mapping heat sources to paths with potential data.
529528
output_path : str
530529
Path to save the subnodes_head GeoDataFrame.
530+
531531
Returns
532532
-------
533533
None
@@ -548,7 +548,7 @@ def add_subnodes(
548548
dh_loads_before = get_district_heating_loads(n)
549549
# Add subnodes to network
550550
for _, subnode in subnodes_head.iterrows():
551-
name = f'{subnode["cluster"]} {subnode["Stadt"]} urban central'
551+
name = f"{subnode['cluster']} {subnode['Stadt']} urban central"
552552

553553
# Add different component types
554554
add_buses(n, subnode, name)
@@ -577,9 +577,9 @@ def add_subnodes(
577577
)
578578
dh_loads_after = get_district_heating_loads(n)
579579
# Check if the total district heating load is preserved
580-
assert (
581-
dh_loads_before == dh_loads_after
582-
), "Total district heating load is not preserved after adding subnodes."
580+
assert dh_loads_before == dh_loads_after, (
581+
"Total district heating load is not preserved after adding subnodes."
582+
)
583583

584584

585585
def extend_heating_distribution(

0 commit comments

Comments
 (0)