Skip to content

Commit

Permalink
Merge branch 'hybit' into features/extendable_lines_from_nep
Browse files Browse the repository at this point in the history
  • Loading branch information
ClaraBuettner committed Aug 16, 2024
2 parents c8b1a72 + 260a059 commit 0dff150
Show file tree
Hide file tree
Showing 9 changed files with 477 additions and 185 deletions.
17 changes: 17 additions & 0 deletions etrago/analyze/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import tilemapbase

from etrago.execute import import_gen_from_links
from etrago.tools.utilities import find_buses_area

__copyright__ = (
"Flensburg University of Applied Sciences, "
Expand Down Expand Up @@ -2474,6 +2475,8 @@ def plot_grid(
* 'q_flow_max': maximal reactive flows
* 'dlr': energy above nominal capacity
* 'grey': plot all lines and DC links grey colored
* 'interest_area': plot all AC buses inside the interest area larger than buses
outside the interest area
bus_sizes : float, optional
Size of buses. The default is 0.001.
Expand Down Expand Up @@ -2907,6 +2910,20 @@ def plot_grid(
bus_sizes[bus_sizes != "AC"] = 0
bus_sizes[bus_sizes == "AC"] = 1 * bus_scaling
bus_scaling = bus_sizes
elif bus_colors == "interest_area":
bus_scaling = bus_sizes
# only plot AC buses
bus_sizes = pd.Series(
data=network.buses.carrier, index=network.buses.index
)
bus_sizes[bus_sizes != "AC"] = 0
bus_sizes[bus_sizes == "AC"] = 1 * bus_scaling
# only plot buses inside interest area
buses_interest_area = find_buses_area(self, "AC")
buses_outside = [_ for _ in bus_sizes.index if _ not in buses_interest_area]
bus_sizes.loc[buses_outside] = bus_sizes.loc[buses_outside] * 0.3
bus_scaling = bus_sizes
bus_colors = coloring()["AC"]
else:
logger.warning("bus_color {} undefined".format(bus_colors))

Expand Down
40 changes: 24 additions & 16 deletions etrago/appl.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,17 @@
"extra_functionality": {}, # Choose function name or {}
# Spatial Complexity:
"delete_dispensable_ac_buses": True, # bool. Find and delete expendable buses
"interest_area": False, # False, path to shapefile or list of nuts names of the area that is excluded from the clustering. By default the buses inside remain the same, but the parameter "n_cluster_interest_area" inside "network clustering" defines if it should be clustered to a certain number of buses.
"network_clustering_ehv": {
"active": False, # choose if clustering of HV buses to EHV buses is activated
"busmap": False, # False or path to stored busmap
},
"network_clustering": {
"active": True, # choose if clustering is activated
"method": "kmedoids-dijkstra", # choose clustering method: kmeans or kmedoids-dijkstra
"n_clusters_AC": 30, # total number of resulting AC nodes (DE+foreign)
"n_clusters_AC": 30, # total number of resulting AC nodes (DE+foreign-interest_area)
"cluster_foreign_AC": False, # take foreign AC buses into account, True or False
"n_cluster_interest_area": False, # False or number of buses.
"method_gas": "kmedoids-dijkstra", # choose clustering method: kmeans or kmedoids-dijkstra
"n_clusters_gas": 14, # total number of resulting CH4 nodes (DE+foreign)
"cluster_foreign_gas": False, # take foreign CH4 buses into account, True or False
Expand Down Expand Up @@ -383,6 +385,16 @@ def run_etrago(args, json_path):
connected lines are merged. This reduces the spatial complexity without
losing any accuracy.
Default: True.
interest_area: False, list, string
Area of especial interest that will be not clustered, except when
n_cluster_interest_area is provided. It is by default set to false.
When an interest_area is provided, the given value for n_clusters_AC
will mean the total of AC buses outside the area.The area can be
provided in two ways: list of nuts names e.G.
["Cuxhaven", "Bremerhaven", "Bremen"] or a string with a path to a
shape file (.shp).
network_clustering_ehv : dict
Choose if you want to apply an extra high voltage clustering to the
electrical network.
Expand Down Expand Up @@ -414,12 +426,14 @@ def run_etrago(args, json_path):
* "kmeans": considers geographical locations of buses
* "kmedoids-dijkstra": considers electrical distances between
buses
Default: "kmedoids-dijkstra".
* "n_clusters_AC" : int
* "n_clusters_AC" : int, False
Defines total number of resulting AC nodes including DE and foreign
nodes if `cluster_foreign_AC` is set to True, otherwise only DE
nodes.
nodes. When using the interest_area parameter, n_clusters_AC could
be set to False, which means that only the buses inside the
provided area are clustered.
Default: 30.
* "cluster_foreign_AC" : bool
If set to False, the AC buses outside Germany are not clustered
Expand All @@ -428,13 +442,18 @@ def run_etrago(args, json_path):
as well and included in number of clusters specified through
``'n_clusters_AC'``.
Default: False.
* "n_cluster_interest_area": False, int
Number of buses to cluster all the electrical buses in the area
of interest. Method provided in the arg "method" is used. If
it is set to False, the area of interest is not clustered.
Default: False.
* "method_gas" : str
Method used for gas clustering. You can choose between two
clustering methods:
* "kmeans": considers geographical locations of buses
* "kmedoids-dijkstra": considers 'electrical' distances between
buses
Default: "kmedoids-dijkstra".
* "n_clusters_gas" : int
Defines total number of resulting CH4 nodes including DE and
Expand Down Expand Up @@ -694,17 +713,6 @@ def run_etrago(args, json_path):
# skip snapshots
etrago.skip_snapshots()

# Temporary drop DLR as it is currently not working with sclopf
if etrago.args["method"]["type"] != "lopf":
etrago.network.lines_t.s_max_pu = pd.DataFrame(
index=etrago.network.snapshots,
columns=etrago.network.lines.index,
data=1.0,
)

etrago.network.lines.loc[etrago.network.lines.r == 0.0, "r"] = 10

# start linear optimal powerflow calculations
etrago.optimize()

# conduct lopf with full complex timeseries for dispatch disaggregation
Expand Down
2 changes: 2 additions & 0 deletions etrago/args.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"generator_noise": 789456,
"extra_functionality": {},
"delete_dispensable_ac_buses": true,
"interest_area": false,
"network_clustering_ehv": {
"active": false,
"busmap": false
Expand All @@ -70,6 +71,7 @@
"method": "kmedoids-dijkstra",
"n_clusters_AC": 30,
"cluster_foreign_AC": false,
"n_cluster_interest_area": false,
"method_gas": "kmedoids-dijkstra",
"n_clusters_gas": 17,
"cluster_foreign_gas": false,
Expand Down
Loading

0 comments on commit 0dff150

Please sign in to comment.