Skip to content

Commit

Permalink
Merge branch 'features/#377-grid-separation' into merge/powermodels_i…
Browse files Browse the repository at this point in the history
…nterface_split_grid
  • Loading branch information
birgits committed May 9, 2023
2 parents 5db78e2 + 9a90942 commit b9d3e9a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
4 changes: 3 additions & 1 deletion edisgo/edisgo.py
Original file line number Diff line number Diff line change
Expand Up @@ -1103,7 +1103,9 @@ def analyze(
--------
tuple(:pandas:`pandas.DatetimeIndex<DatetimeIndex>`,\
:pandas:`pandas.DatetimeIndex<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
--------
Expand Down
34 changes: 30 additions & 4 deletions edisgo/flex_opt/reinforce_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions edisgo/io/pypsa_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b9d3e9a

Please sign in to comment.