Skip to content

Commit

Permalink
Adding default values for adding new components
Browse files Browse the repository at this point in the history
  • Loading branch information
joda9 committed Jul 22, 2024
1 parent 3dc762b commit 9d0411a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
6 changes: 6 additions & 0 deletions edisgo/config/config_grid_default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ upper_limit_voltage_level_4 = 20.0
# Positioning of disconnecting points: Can be position at location of most
# balanced load or generation. Choose load, generation, loadgen
position = load

[new_components]
# Define the default values for adding new components to the grid

lv_max_voltage_deviation = 0.035
mv_max_voltage_deviation = 0.015
20 changes: 9 additions & 11 deletions edisgo/tools/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,29 +284,27 @@ def select_cable(
Number of necessary parallel cables.
"""
if not max_voltage_drop:
if level == "mv":
max_voltage_drop = edisgo_obj.config._data[
"grid_expansion_allowed_voltage_deviations"
]["mv_max_v_drop"]
elif level == "lv":
max_voltage_drop = edisgo_obj.config._data[
"grid_expansion_allowed_voltage_deviations"
]["lv_max_v_drop"]
cable_count = 1

if level == "mv":
cable_data = edisgo_obj.topology.equipment_data["mv_cables"]
available_cables = cable_data[
cable_data["U_n"] == edisgo_obj.topology.mv_grid.nominal_voltage
]
if not max_voltage_drop:
max_voltage_drop = edisgo_obj.config._data["new_components"][
"mv_max_voltage_deviation"
]
elif level == "lv":
available_cables = edisgo_obj.topology.equipment_data["lv_cables"]
if not max_voltage_drop:
max_voltage_drop = edisgo_obj.config._data["new_components"][
"lv_max_voltage_deviation"
]
else:
raise ValueError(
"Specified voltage level is not valid. Must either be 'mv' or 'lv'."
)

cable_count = 1
suitable_cables = available_cables[
calculate_apparent_power(
available_cables["U_n"], available_cables["I_max_th"], cable_count
Expand Down
2 changes: 1 addition & 1 deletion tests/tools/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def test_select_cable(self):
self.edisgo, "lv", 0.18, 1000
)
assert cable_data.name == "NAYY 4x1x240"
assert num_parallel_cables == 3
assert num_parallel_cables == 5

cable_data, num_parallel_cables = tools.select_cable(
self.edisgo, "lv", 0.18, 1000, max_voltage_drop=0.01, max_cables=100
Expand Down

0 comments on commit 9d0411a

Please sign in to comment.