From 9d0411a53f3d51174d18dbe7299311041001c365 Mon Sep 17 00:00:00 2001 From: joda9 Date: Mon, 22 Jul 2024 13:29:23 +0200 Subject: [PATCH] Adding default values for adding new components --- edisgo/config/config_grid_default.cfg | 6 ++++++ edisgo/tools/tools.py | 20 +++++++++----------- tests/tools/test_tools.py | 2 +- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/edisgo/config/config_grid_default.cfg b/edisgo/config/config_grid_default.cfg index f48c68d8f..7cab549de 100644 --- a/edisgo/config/config_grid_default.cfg +++ b/edisgo/config/config_grid_default.cfg @@ -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 diff --git a/edisgo/tools/tools.py b/edisgo/tools/tools.py index 3d462f184..e37ba3fa2 100644 --- a/edisgo/tools/tools.py +++ b/edisgo/tools/tools.py @@ -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 diff --git a/tests/tools/test_tools.py b/tests/tools/test_tools.py index d2baaf222..996f70b95 100644 --- a/tests/tools/test_tools.py +++ b/tests/tools/test_tools.py @@ -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