Skip to content

Commit

Permalink
Change how reduced_analysis is set
Browse files Browse the repository at this point in the history
  • Loading branch information
birgits committed Oct 22, 2023
1 parent 8c6e57a commit 475a2f3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
12 changes: 7 additions & 5 deletions edisgo/edisgo.py
Original file line number Diff line number Diff line change
Expand Up @@ -1196,6 +1196,7 @@ def _scale_timeseries(pypsa_network_copy, fraction):
def reinforce(
self,
timesteps_pfa: str | pd.DatetimeIndex | pd.Timestamp | None = None,
reduced_analysis: bool = False,
copy_grid: bool = False,
max_while_iterations: int = 20,
split_voltage_band: bool = True,
Expand Down Expand Up @@ -1237,14 +1238,15 @@ def reinforce(
time steps. If your time series already represents the worst-case,
keep the default value of None because finding the worst-case
snapshots takes some time.
* 'reduced_analysis'
Reinforcement is conducted for all time steps at which at least one
branch shows its highest overloading or one bus shows its highest voltage
violation.
* :pandas:`pandas.DatetimeIndex<DatetimeIndex>` or \
:pandas:`pandas.Timestamp<Timestamp>`
Use this option to explicitly choose which time steps to consider.
reduced_analysis : bool
If True, reinforcement is conducted for all time steps at which at least
one branch shows its highest overloading or one bus shows its highest
voltage violation. Time steps to consider are specified through parameter
`timesteps_pfa`. If False, all time steps in parameter `timesteps_pfa`
are used. Default: False.
copy_grid : bool
If True, reinforcement is conducted on a copied grid and discarded.
Default: False.
Expand Down
22 changes: 14 additions & 8 deletions edisgo/flex_opt/reinforce_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
def reinforce_grid(
edisgo: EDisGo,
timesteps_pfa: str | pd.DatetimeIndex | pd.Timestamp | None = None,
reduced_analysis: bool = False,
max_while_iterations: int = 20,
split_voltage_band: bool = True,
mode: str | None = None,
Expand All @@ -47,6 +48,10 @@ def reinforce_grid(
timesteps_pfa specifies for which time steps power flow analysis is
conducted. See parameter `timesteps_pfa` in function :attr:`~.EDisGo.reinforce`
for more information.
reduced_analysis : bool
Specifies, whether to run reinforcement on a subset of time steps that are most
critical. See parameter `reduced_analysis` in function
:attr:`~.EDisGo.reinforce` for more information.
max_while_iterations : int
Maximum number of times each while loop is conducted. Default: 20.
split_voltage_band : bool
Expand Down Expand Up @@ -139,14 +144,6 @@ def reinforce_grid(
snapshots["min_residual_load"],
]
).dropna()
elif isinstance(timesteps_pfa, str) and timesteps_pfa == "reduced_analysis":
timesteps_pfa = get_most_critical_time_steps(
edisgo,
num_steps_loading=kwargs.get("num_steps_loading", None),
num_steps_voltage=kwargs.get("num_steps_voltage", None),
percentage=kwargs.get("percentage", 1.0),
use_troubleshooting_mode=kwargs.get("use_troubleshooting_mode", True),
)
# if timesteps_pfa is not of type datetime or does not contain
# datetimes throw an error
elif not isinstance(timesteps_pfa, datetime.datetime):
Expand All @@ -160,6 +157,15 @@ def reinforce_grid(
f"Input {timesteps_pfa} for timesteps_pfa is not valid."
)

if reduced_analysis:
timesteps_pfa = get_most_critical_time_steps(
edisgo,
timesteps=timesteps_pfa,
num_steps_loading=kwargs.get("num_steps_loading", None),
num_steps_voltage=kwargs.get("num_steps_voltage", None),
percentage=kwargs.get("percentage", 1.0),
use_troubleshooting_mode=kwargs.get("use_troubleshooting_mode", True),
)
iteration_step = 1
lv_grid_id = kwargs.get("lv_grid_id", None)
scale_timeseries = kwargs.get("scale_timeseries", None)
Expand Down

0 comments on commit 475a2f3

Please sign in to comment.