diff --git a/etrago/cluster/electrical.py b/etrago/cluster/electrical.py index 46619ef8..9ad8dbca 100755 --- a/etrago/cluster/electrical.py +++ b/etrago/cluster/electrical.py @@ -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. @@ -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) diff --git a/etrago/execute/__init__.py b/etrago/execute/__init__.py index 937e3015..a0ea0730 100644 --- a/etrago/execute/__init__.py +++ b/etrago/execute/__init__.py @@ -417,7 +417,7 @@ def optimize(self): #self.market_results_to_grid() - #self.grid_optimization() + self.grid_optimization() else: print("Method not defined") diff --git a/etrago/execute/grid_optimization.py b/etrago/execute/grid_optimization.py index e8bb69f7..db66a104 100644 --- a/etrago/execute/grid_optimization.py +++ b/etrago/execute/grid_optimization.py @@ -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"], @@ -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 @@ -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 @@ -241,7 +244,7 @@ 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 @@ -249,6 +252,8 @@ def add_redispatch_generators(self): -(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 diff --git a/etrago/execute/market_optimization.py b/etrago/execute/market_optimization.py index b5ee5f40..5f30cb21 100644 --- a/etrago/execute/market_optimization.py +++ b/etrago/execute/market_optimization.py @@ -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 @@ -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 @@ -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?! +