Skip to content

Commit

Permalink
Consider voltage drop when selecting suitable cable in connect functions
Browse files Browse the repository at this point in the history
  • Loading branch information
birgits committed Aug 8, 2024
1 parent 2875aa7 commit ec36c0b
Showing 1 changed file with 47 additions and 16 deletions.
63 changes: 47 additions & 16 deletions edisgo/network/topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -1928,7 +1928,13 @@ def connect_to_mv(self, edisgo_object, comp_data, comp_type="generator"):
# avoid very short lines by limiting line length to at least 1m
line_length = max(line_length, 0.001)

line_type, num_parallel = select_cable(edisgo_object, "mv", power)
line_type, num_parallel = select_cable(
edisgo_obj=edisgo_object,
level="mv",
apparent_power=power,
length=line_length,
component_type=comp_type,
)

line_name = self.add_line(
bus0=self.mv_grid.station.index[0],
Expand Down Expand Up @@ -1975,13 +1981,12 @@ def connect_to_mv(self, edisgo_object, comp_data, comp_type="generator"):
for dist_min_obj in conn_objects_min_stack:
# do not allow connection to virtual busses
if "virtual" not in dist_min_obj["repr"]:
line_type, num_parallel = select_cable(edisgo_object, "mv", power)
target_obj_result = self._connect_mv_bus_to_target_object(
edisgo_object=edisgo_object,
bus=self.buses_df.loc[bus, :],
target_obj=dist_min_obj,
line_type=line_type.name,
number_parallel_lines=num_parallel,
comp_type=comp_type,
power=power,
)

if target_obj_result is not None:
Expand Down Expand Up @@ -2448,7 +2453,12 @@ def connect_to_lv_based_on_geolocation(
return comp_name

def _connect_mv_bus_to_target_object(
self, edisgo_object, bus, target_obj, line_type, number_parallel_lines
self,
edisgo_object,
bus,
target_obj,
comp_type,
power,
):
"""
Connects given MV bus to given target object (MV line or bus).
Expand Down Expand Up @@ -2477,11 +2487,12 @@ def _connect_mv_bus_to_target_object(
* shp : :shapely:`Shapely Point object<points>` or \
:shapely:`Shapely Line object<linestrings>`
Geometry of line or bus to connect to.
line_type : str
Line type to use to connect new component with.
number_parallel_lines : int
Number of parallel lines to connect new component with.
comp_type : str
Type of added component. Can be 'generator', 'charging_point', 'heat_pump'
or 'storage_unit'.
Default: 'generator'.
power : float
Nominal power of the new component to be connected.
Returns
-------
Expand Down Expand Up @@ -2598,6 +2609,13 @@ def _connect_mv_bus_to_target_object(
"branch_detour_factor"
],
)
line_type, num_parallel = select_cable(
edisgo_obj=edisgo_object,
level="mv",
apparent_power=power,
length=line_length,
component_type=comp_type,
)
# avoid very short lines by limiting line length to at least 1m
if line_length < 0.001:
line_length = 0.001
Expand All @@ -2606,8 +2624,8 @@ def _connect_mv_bus_to_target_object(
bus1=bus.name,
length=line_length,
kind="cable",
type_info=line_type,
num_parallel=number_parallel_lines,
type_info=line_type.name,
num_parallel=num_parallel,
)
# add line to equipment changes
edisgo_object.results._add_line_to_equipment_changes(
Expand All @@ -2624,7 +2642,7 @@ def _connect_mv_bus_to_target_object(

# bus is the nearest connection point
else:
# add new branch for satellite (station to station)
# add new line between new bus and closest bus
line_length = geo.calc_geo_dist_vincenty(
grid_topology=self,
bus_source=bus.name,
Expand All @@ -2633,6 +2651,13 @@ def _connect_mv_bus_to_target_object(
"branch_detour_factor"
],
)
line_type, num_parallel = select_cable(
edisgo_obj=edisgo_object,
level="mv",
apparent_power=power,
length=line_length,
component_type=comp_type,
)
# avoid very short lines by limiting line length to at least 1m
if line_length < 0.001:
line_length = 0.001
Expand All @@ -2642,8 +2667,8 @@ def _connect_mv_bus_to_target_object(
bus1=bus.name,
length=line_length,
kind="cable",
type_info=line_type,
num_parallel=number_parallel_lines,
type_info=line_type.name,
num_parallel=num_parallel,
)

# add line to equipment changes
Expand Down Expand Up @@ -2721,7 +2746,13 @@ def _connect_to_lv_bus(self, edisgo_object, target_bus, comp_type, comp_data):
line_length = max(line_length, 0.001)

# get suitable line type
line_type, num_parallel = select_cable(edisgo_object, "lv", comp_data["p"])
line_type, num_parallel = select_cable(
edisgo_obj=edisgo_object,
level="lv",
apparent_power=comp_data["p"],
component_type=comp_type,
length=line_length,
)
line_name = self.add_line(
bus0=target_bus,
bus1=b,
Expand Down

0 comments on commit ec36c0b

Please sign in to comment.