Skip to content

Commit

Permalink
Fix only use reduced analysis when power flow converges
Browse files Browse the repository at this point in the history
  • Loading branch information
birgits committed Oct 23, 2023
1 parent 44a2203 commit 51b53de
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions edisgo/flex_opt/reinforce_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,7 @@ def reinforce():
edisgo,
timesteps_pfa=selected_timesteps,
scale_timeseries=set_scaling_factor,
use_troubleshooting_mode=troubleshooting_mode,
**kwargs,
)
converged = True
Expand All @@ -720,11 +721,13 @@ def reinforce():
# Get the timesteps from kwargs and then remove it to set it later manually
timesteps_pfa = kwargs.pop("timesteps_pfa", None)
selected_timesteps = timesteps_pfa
troubleshooting_mode_set = kwargs.pop("troubleshooting_mode", True)

# Initial try
logger.info("Run initial reinforcement.")
set_scaling_factor = 1.0
iteration = 0
troubleshooting_mode = False
converged = reinforce()
if converged is False:
logger.info("Initial reinforcement did not succeed.")
Expand Down Expand Up @@ -756,6 +759,7 @@ def reinforce():
"reinforcement."
)
selected_timesteps = converging_timesteps
troubleshooting_mode = troubleshooting_mode_set
reinforce()

# Run reinforcement for time steps that did not converge after initial reinforcement
Expand All @@ -765,6 +769,7 @@ def reinforce():
"reinforcement."
)
selected_timesteps = non_converging_timesteps
troubleshooting_mode = False
converged = reinforce()

if converged:
Expand Down Expand Up @@ -798,6 +803,7 @@ def reinforce():
) + highest_converged_scaling_factor

logger.info(f"Try reinforcement with {set_scaling_factor=} at {iteration=}")
troubleshooting_mode = False
converged = reinforce()
if converged:
logger.info(
Expand All @@ -818,6 +824,7 @@ def reinforce():
if set_scaling_factor != 1:
logger.info("Run final reinforcement.")
selected_timesteps = timesteps_pfa
troubleshooting_mode = False
reinforce()

return edisgo.results
Expand Down

0 comments on commit 51b53de

Please sign in to comment.