Skip to content

Commit

Permalink
Revert "Change LV reniforcement"
Browse files Browse the repository at this point in the history
This reverts commit 43552cf.
  • Loading branch information
birgits committed Jan 18, 2024
1 parent 7b7a7e1 commit 74381c3
Showing 1 changed file with 14 additions and 55 deletions.
69 changes: 14 additions & 55 deletions edisgo/flex_opt/reinforce_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ def enhanced_reinforce_grid(
logger.info("Run initial grid reinforcement for single LV grids.")
for lv_grid in list(edisgo_object.topology.mv_grid.lv_grids):
logger.info(f"Check initial convergence for {lv_grid=}.")
ts_converged, ts_not_converged = edisgo_object.analyze(
_, ts_not_converged = edisgo_object.analyze(
mode="lv", raise_not_converged=False, lv_grid_id=lv_grid.id
)
if len(ts_not_converged) > 0:
Expand All @@ -922,32 +922,12 @@ def enhanced_reinforce_grid(
)
try:
logger.info(f"Try initial mode 'lv' reinforcement for {lv_grid=}.")
if len(ts_not_converged) > 0:
# if there are time steps that did not converge, run reinforcement
# first on converged time steps
edisgo_object.reinforce(
mode="lv",
lv_grid_id=lv_grid.id,
catch_convergence_problems=False,
timesteps_pfa=ts_converged,
**kwargs,
)
# run reinforcement again in catch-convergence mode with all time steps
edisgo_object.reinforce(
mode="lv",
lv_grid_id=lv_grid.id,
catch_convergence_problems=True,
**kwargs,
)
else:
# if all time steps converged, run normal reinforcement
edisgo_object.reinforce(
mode="lv",
lv_grid_id=lv_grid.id,
catch_convergence_problems=False,
run_initial_analyze=False,
**kwargs,
)
edisgo_object.reinforce(
mode="lv",
lv_grid_id=lv_grid.id,
catch_convergence_problems=True,
**kwargs,
)
logger.info(f"Initial mode 'lv' reinforcement for {lv_grid} successful.")
except (ValueError, RuntimeError, exceptions.MaximumIterationError):
logger.warning(f"Initial mode 'lv' reinforcement for {lv_grid} failed.")
Expand Down Expand Up @@ -980,7 +960,7 @@ def enhanced_reinforce_grid(

for lv_grid in list(edisgo_object.topology.mv_grid.lv_grids):
logger.info(f"Check convergence for {lv_grid=}.")
ts_converged, ts_not_converged = edisgo_object.analyze(
_, ts_not_converged = edisgo_object.analyze(
mode="lv", raise_not_converged=False, lv_grid_id=lv_grid.id
)
if len(ts_not_converged) > 0:
Expand All @@ -1001,33 +981,12 @@ def enhanced_reinforce_grid(
)
try:
logger.info(f"Try mode 'lv' reinforcement for {lv_grid=}.")
if len(ts_not_converged) > 0:
# if there are time steps that did not converge, run reinforcement
# first on converged time steps
edisgo_object.reinforce(
mode="lv",
lv_grid_id=lv_grid.id,
catch_convergence_problems=False,
timesteps_pfa=ts_converged,
**kwargs,
)
# run reinforcement again in catch-convergence mode with all time
# steps
edisgo_object.reinforce(
mode="lv",
lv_grid_id=lv_grid.id,
catch_convergence_problems=True,
**kwargs,
)
else:
# if all time steps converged, run normal reinforcement
edisgo_object.reinforce(
mode="lv",
lv_grid_id=lv_grid.id,
catch_convergence_problems=False,
run_initial_analyze=False,
**kwargs,
)
edisgo_object.reinforce(
mode="lv",
lv_grid_id=lv_grid.id,
catch_convergence_problems=True,
**kwargs,
)
logger.info(f"Mode 'lv' reinforcement for {lv_grid} successful.")
except (ValueError, RuntimeError, exceptions.MaximumIterationError):
logger.info(f"Mode 'lv' reinforcement for {lv_grid} failed.")
Expand Down

0 comments on commit 74381c3

Please sign in to comment.