Skip to content

Commit

Permalink
various small bug fixes, features and temporal work-arounds to get a …
Browse files Browse the repository at this point in the history
…first working example :)
  • Loading branch information
ulfmueller committed Sep 7, 2023
1 parent 1dd37db commit e502572
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 18 deletions.
10 changes: 6 additions & 4 deletions etrago/cluster/electrical.py
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,9 @@ def preprocessing(etrago):
return network_elec, weight, n_clusters, busmap_foreign


def postprocessing(etrago, busmap, busmap_foreign, medoid_idx=None, aggregate_generators_carriers=None):
def postprocessing(etrago, busmap, busmap_foreign, medoid_idx=None,
aggregate_generators_carriers=None,
aggregate_links=True):
"""
Postprocessing function for network clustering.
Expand Down Expand Up @@ -911,9 +913,9 @@ def postprocessing(etrago, busmap, busmap_foreign, medoid_idx=None, aggregate_ge
"y"
].loc[medoid]

clustering.network.links, clustering.network.links_t = group_links(
clustering.network
)
if aggregate_links == True:
clustering.network.links, clustering.network.links_t = group_links(
clustering.network)

return (clustering, busmap)

Expand Down
2 changes: 1 addition & 1 deletion etrago/execute/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def optimize(self):

#self.market_results_to_grid()

#self.grid_optimization()
self.grid_optimization()

else:
print("Method not defined")
Expand Down
13 changes: 9 additions & 4 deletions etrago/execute/grid_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@


def grid_optimization(self):

logger.info("Start building grid optimization model")
add_redispatch_generators(self)


logger.info("Start solving grid optimization model")
self.network.lopf(
solver_name=self.args["solver"],
solver_options=self.args["solver_options"],
Expand Down Expand Up @@ -197,7 +200,7 @@ def add_redispatch_generators(self):
self.network.links_t.p_max_pu.loc[:, links_redispatch + " ramp_up"] = (
(
self.network.links.loc[links_redispatch, "p_nom"]
- (self.network.links_t.p0.loc[:, links_redispatch])
- (self.market_model.links_t.p0.loc[:, links_redispatch])
)
.clip(lower=0.0)
.values
Expand All @@ -218,7 +221,7 @@ def add_redispatch_generators(self):
# Ramp down generators can not feed-in addtional energy
self.network.generators_t.p_max_pu.loc[
:, gens_redispatch + " ramp_down"
] = 0
] = 0.0

# Ramp down can be at maximum as high as the feed-in of the
# (disaggregated) generators in the market model
Expand All @@ -241,14 +244,16 @@ def add_redispatch_generators(self):
)

# Ramp down links can not feed-in addtional energy
self.network.links_t.p_max_pu.loc[:, links_redispatch + " ramp_down"] = 0
self.network.links_t.p_max_pu.loc[:, links_redispatch + " ramp_down"] = 0.0

# Ramp down can be at maximum as high as the feed-in of the
# (disaggregated) links in the market model
self.network.links_t.p_min_pu.loc[:, links_redispatch + " ramp_down"] = (
-(self.market_model.links_t.p0.loc[:, links_redispatch])
).values

# just for the current status2019 scenario a quick fix for buses which do not have a connection
self.network.buses.drop(self.network.buses[self.network.buses.index.isin(['47085', '47086', '37865', '37870'])].index, inplace=True)

def extra_functionality():
return None
18 changes: 9 additions & 9 deletions etrago/execute/market_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def market_optimization(self):
extra_functionality=extra_functionality(),
formulation=self.args["model_formulation"],
)
self.market_model.model.write('/home/ulf/file2.lp')
#self.market_model.model.write('/home/ulf/file2.lp')

def build_market_model(self):
"""Builds market model based on imported network from eTraGo
Expand Down Expand Up @@ -107,10 +107,11 @@ def build_market_model(self):
logger.info("Start market zone specifc clustering")

self.clustering, busmap = postprocessing(
self, busmap, busmap_foreign, medoid_idx, aggregate_generators_carriers=[])
self, busmap, busmap_foreign, medoid_idx,
aggregate_generators_carriers=[], aggregate_links=False)

self.update_busmap(busmap)


net = self.clustering.network
#links_col = net.links.columns
Expand All @@ -133,13 +134,12 @@ def build_market_model(self):
#net.buses.loc[net.buses.carrier == 'AC', 'carrier'] = "DC"

# delete following unconnected CH4 buses. why are they there?
net.buses.drop(net.buses[net.buses.index == '37870'].index, inplace=True)
net.buses.drop(net.buses[net.buses.index == '37865'].index, inplace=True)

self.buses_by_country()
self.geolocation_buses()
self.market_model = net
net.buses.drop(net.buses[net.buses.index.isin(['37865', '37870'])].index, inplace=True)

self.market_model = net

# Todo: buses_by_country() geolocation_buses() apply on market_model does not work because no self.network?!




Expand Down

0 comments on commit e502572

Please sign in to comment.