Skip to content

Commit

Permalink
Merge branch 'dev' into features/market-simulation
Browse files Browse the repository at this point in the history
  • Loading branch information
ulfmueller committed Dec 1, 2023
2 parents 30f3882 + 68920de commit 18fddb1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 12 deletions.
24 changes: 12 additions & 12 deletions etrago/cluster/electrical.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,18 @@ def postprocessing(etrago, busmap, busmap_foreign, medoid_idx=None,
line_strategies=strategies_lines(),
)

# Drop nan values after clustering
clustering.network.links.min_up_time.fillna(0, inplace=True)
clustering.network.links.min_down_time.fillna(0, inplace=True)
clustering.network.links.up_time_before.fillna(0, inplace=True)
clustering.network.links.down_time_before.fillna(0, inplace=True)
# Drop nan values in timeseries after clustering
for c in clustering.network.iterate_components():
for pnl in c.attrs[
(c.attrs.status == "Output") & (c.attrs.varying)
].index:
c.pnl[pnl] = pd.DataFrame(index=clustering.network.snapshots)

if method == "kmedoids-dijkstra":
for i in clustering.network.buses[
clustering.network.buses.carrier == "AC"
Expand Down Expand Up @@ -1053,18 +1065,6 @@ def run_spatial_clustering(self):
# which sets slack bus(es).
set_control_strategies(self.network)

# Drop nan values after clustering
self.network.links.min_up_time.fillna(0, inplace=True)
self.network.links.min_down_time.fillna(0, inplace=True)
self.network.links.up_time_before.fillna(0, inplace=True)
self.network.links.down_time_before.fillna(0, inplace=True)
# Drop nan values in timeseries after clustering
for c in self.network.iterate_components():
for pnl in c.attrs[
(c.attrs.status == "Output") & (c.attrs.varying)
].index:
c.pnl[pnl] = pd.DataFrame(index=self.network.snapshots)

logger.info(
"Network clustered to {} buses with ".format(
self.args["network_clustering"]["n_clusters_AC"]
Expand Down
21 changes: 21 additions & 0 deletions etrago/tools/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -2884,7 +2884,28 @@ def manual_fixes_datamodel(etrago):
] = 25

# Set r value if missing
if not etrago.network.lines.loc[etrago.network.lines.r == 0, "r"].empty:
logger.info(
f"""
There are {len(
etrago.network.lines.loc[etrago.network.lines.r == 0, "r"]
)} lines without a resistance (r) in the data model.
The resistance of these lines will be automatically set to 0.0001.
"""
)

etrago.network.lines.loc[etrago.network.lines.r == 0, "r"] = 0.0001

if not etrago.network.transformers.loc[
etrago.network.transformers.r == 0, "r"
].empty:
logger.info(
f"""There are {len(etrago.network.transformers.loc[
etrago.network.transformers.r == 0, "r"]
)} trafos without a resistance (r) in the data model.
The resistance of these trafos will be automatically set to 0.0001.
"""
)
etrago.network.transformers.loc[
etrago.network.transformers.r == 0, "r"
] = 0.0001
Expand Down

0 comments on commit 18fddb1

Please sign in to comment.