diff --git a/edisgo/edisgo.py b/edisgo/edisgo.py index 846465f81..83c6c8049 100755 --- a/edisgo/edisgo.py +++ b/edisgo/edisgo.py @@ -1103,7 +1103,9 @@ def analyze( -------- tuple(:pandas:`pandas.DatetimeIndex`,\ :pandas:`pandas.DatetimeIndex`) - Returns the time steps for which power flow analysis did not converge. + First index contains time steps for which power flow analysis did converge. + Second index contains time steps for which power flow analysis did not + converge. References -------- diff --git a/edisgo/flex_opt/reinforce_grid.py b/edisgo/flex_opt/reinforce_grid.py index 25dfdebb4..c5f17ea74 100644 --- a/edisgo/flex_opt/reinforce_grid.py +++ b/edisgo/flex_opt/reinforce_grid.py @@ -819,11 +819,18 @@ def enhanced_reinforce_grid( :func:`edisgo.flex_opt.reinforce_grid.catch_convergence_reinforce_grid` is not sufficient. - After first grid reinforcement for all voltage levels at once fails, reinforcement - is first conducted for the MV level only, afterwards for the MV level including - MV/LV stations and at last each LV grid separately. Beforehand the separation of - highly overloaded LV grids can be done by setting 'separate_lv_grids' to True. See + In a first step, if `separate_lv_grids` is set to True, LV grids with a large load, + specified through parameter `separation_threshold`, are split, so that part of the + load is served by a separate MV/LV station. See :func:`~.flex_opt.reinforce_grid.run_separate_lv_grids` for more information. + Afterwards it is tried to run the grid reinforcement for all voltage levels at once. + If this fails, reinforcement is first conducted for the MV level only, afterwards + for the MV level including MV/LV stations and at last for each LV grid separately. + For each LV grid is it checked, if all time steps converge in the power flow + analysis. If this is not the case, the grid is split. Afterwards it is tried to + be reinforced. If this fails and `activate_cost_results_disturbing_mode` + parameter is set to True, further measures are taken. See parameter documentation + for more information. Parameters ---------- @@ -897,6 +904,25 @@ def enhanced_reinforce_grid( logger.info("Mode 'mvlv' reinforcement failed.") for lv_grid in list(edisgo_obj.topology.mv_grid.lv_grids): + logger.info(f"Check convergence for {lv_grid=}.") + _, ts_not_converged = edisgo_obj.analyze( + mode="lv", raise_not_converged=False, lv_grid_id=lv_grid.id + ) + if len(ts_not_converged) > 0: + logger.info( + f"Not all time steps converged in power flow analysis for " + f"{lv_grid=}. It is therefore tried to be split.") + transformers_changes, lines_changes = separate_lv_grid( + edisgo_obj, lv_grid + ) + if len(lines_changes) > 0: + _add_lines_changes_to_equipment_changes( + edisgo_obj, lines_changes, 1 + ) + if len(transformers_changes) > 0: + _add_transformer_changes_to_equipment_changes( + edisgo_obj, transformers_changes, 1, "added" + ) try: logger.info(f"Try mode 'lv' reinforcement for {lv_grid=}.") edisgo_obj.reinforce( diff --git a/edisgo/io/pypsa_io.py b/edisgo/io/pypsa_io.py index d89dbd79c..a3f6497a8 100755 --- a/edisgo/io/pypsa_io.py +++ b/edisgo/io/pypsa_io.py @@ -195,9 +195,9 @@ def _set_slack(grid): pypsa_network.mode = "lv" lv_grid_id = kwargs.get("lv_grid_id", None) - if not lv_grid_id: + if lv_grid_id is None: raise ValueError( - "For exporting LV grids, ID or name of LV grid has to be provided" + "For exporting LV grids, ID or name of LV grid has to be provided " "using parameter `lv_grid_id`." ) grid_object = edisgo_object.topology.get_lv_grid(lv_grid_id)