Skip to content

Commit

Permalink
Merge pull request #290 from openego/features/refactor_check_tech_con…
Browse files Browse the repository at this point in the history
…straints

Features/refactor check tech constraints
  • Loading branch information
birgits committed Apr 6, 2023
2 parents 4220d97 + 5ef9c88 commit c296887
Show file tree
Hide file tree
Showing 25 changed files with 1,782 additions and 1,151 deletions.
16 changes: 8 additions & 8 deletions doc/features_in_detail.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ Identification of overloading and voltage issues is conducted in
Voltage issues are determined based on allowed voltage deviations set in the config file
:ref:`config_grid_expansion` in section `grid_expansion_allowed_voltage_deviations`. It is possible
to set one allowed voltage deviation that is used for MV and LV or define separate allowed voltage deviations.
Which allowed voltage deviation is used is defined through the parameter *combined_analysis* of :py:func:`~edisgo.flex_opt.reinforce_grid.reinforce_grid`.
By default *combined_analysis* is set to false, resulting in separate voltage limits for MV and LV, as a combined limit
Which allowed voltage deviation is used is defined through the parameter *split_voltage_band* of :py:func:`~edisgo.flex_opt.reinforce_grid.reinforce_grid`.
By default *split_voltage_band* is set to True, resulting in separate voltage limits for MV and LV, as a combined limits
may currently lead to problems if voltage deviation in MV grid is already close to the allowed limit, in which case the remaining allowed voltage deviation in the LV grids is close to zero.

Overloading is determined based on allowed load factors that are also defined in the config file
Expand Down Expand Up @@ -92,8 +92,8 @@ details and implementation.
Check line load
""""""""""""""""""

Exceedance of allowed line load of MV and LV lines is checked in :py:func:`~edisgo.flex_opt.check_tech_constraints.mv_line_load` and
:py:func:`~edisgo.flex_opt.check_tech_constraints.lv_line_load`, respectively.
Exceedance of allowed line load of MV and LV lines is checked in :py:func:`~edisgo.flex_opt.check_tech_constraints.mv_line_overload` and
:py:func:`~edisgo.flex_opt.check_tech_constraints.lv_line_oveload`, respectively.
The functions use the given load factor and the maximum allowed current given by the manufacturer (see *I_max_th* in tables :ref:`lv_cables_table`,
:ref:`mv_cables_table` and :ref:`mv_lines_table`) to calculate the allowed
line load of each LV and MV line. If the line load calculated in the power flow analysis exceeds the allowed line
Expand All @@ -103,8 +103,8 @@ Check line load
Check station load
""""""""""""""""""""

Exceedance of allowed station load of HV/MV and MV/LV stations is checked in :py:func:`~edisgo.flex_opt.check_tech_constraints.hv_mv_station_load` and
:py:func:`~edisgo.flex_opt.check_tech_constraints.mv_lv_station_load`, respectively.
Exceedance of allowed station load of HV/MV and MV/LV stations is checked in :py:func:`~edisgo.flex_opt.check_tech_constraints.hv_mv_station_overload` and
:py:func:`~edisgo.flex_opt.check_tech_constraints.mv_lv_station_overload`, respectively.
The functions use the given load factor and the maximum allowed apparent power given by the manufacturer (see *S_nom* in tables :ref:`lv_transformers_table`,
and :ref:`mv_transformers_table`) to calculate the allowed
apparent power of the stations. If the apparent power calculated in the power flow analysis exceeds the allowed apparent power the station is reinforced
Expand All @@ -113,8 +113,8 @@ Check station load
Check line and station voltage deviation
""""""""""""""""""""""""""""""""""""""""""

Compliance with allowed voltage deviation limits in MV and LV grids is checked in :py:func:`~edisgo.flex_opt.check_tech_constraints.mv_voltage_deviation` and
:py:func:`~edisgo.flex_opt.check_tech_constraints.lv_voltage_deviation`, respectively.
Compliance with allowed voltage deviation limits in MV and LV grids is checked in :py:func:`~edisgo.flex_opt.check_tech_constraints.mv_voltage_issue` and
:py:func:`~edisgo.flex_opt.check_tech_constraints.lv_voltage_issue`, respectively.
The functions check if the voltage deviation at a node calculated in the power flow analysis exceeds the allowed voltage deviation. If it does,
the line is reinforced (see :ref:`grid-expansion-measure-lv-station-voltage-label` or
:ref:`grid-expansion-measure-line-voltage-label`).
Expand Down
1 change: 1 addition & 0 deletions doc/whatsnew/v0-3-0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ Changes
* Added class holding data from overlying grid, such as curtailment requirements and
conventional generator dispatch `#335 <https://github.com/openego/eDisGo/pull/335>`_
* Added integrity check for very short lines `#335 <https://github.com/openego/eDisGo/pull/335>`_
* Refactoring of check_tech_constraints functions `#290 <https://github.com/openego/eDisGo/pull/290>`_
66 changes: 39 additions & 27 deletions edisgo/config/config_grid_expansion_default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,9 @@ lv_line = NAYY 4x1x150

# allowed voltage deviations
# ==========================
# relevant for all cases
feed-in_case_lower = 0.9
load_case_upper = 1.1

# COMBINED MV+LV
# --------------
# voltage at HV/MV station's secondary side
# ------------------------------------------
# hv_mv_trafo_offset:
# offset which is set at HV-MV station
# (pos. if op. voltage is increased, neg. if decreased)
Expand All @@ -37,43 +34,58 @@ hv_mv_trafo_offset = 0.0
# (always pos. in config; pos. or neg. usage depending on case in edisgo)
hv_mv_trafo_control_deviation = 0.0

# mv_lv_max_v_deviation:
# max. allowed voltage deviation according to DIN EN 50160
# COMBINED MV+LV
# --------------
# max. allowed voltage rise and drop in case voltage band is not allocated to different
# voltage levels
# (values according to DIN EN 50160)
# caution: offset and control deviation at HV-MV station must be considered in calculations!
mv_lv_feed-in_case_max_v_deviation = 0.1
mv_lv_load_case_max_v_deviation = 0.1
mv_lv_max_v_rise = 0.1
mv_lv_max_v_drop = 0.1

# MV ONLY
# -------
# mv_load_case_max_v_deviation:
# max. allowed voltage deviation in MV grids (load case)
mv_load_case_max_v_deviation = 0.015
# max. allowed voltage rise in MV grids
mv_max_v_rise = 0.05

# mv_feed-in_case_max_v_deviation:
# max. allowed voltage deviation in MV grids (feed-in case)
# according to BDEW
mv_feed-in_case_max_v_deviation = 0.05
# max. allowed voltage drop in MV grids
mv_max_v_drop = 0.015

# LV ONLY
# -------
# max. allowed voltage deviation in LV grids (load case)
lv_load_case_max_v_deviation = 0.065
# max. allowed voltage rise in LV grids
lv_max_v_rise = 0.035

# max. allowed voltage deviation in LV grids (feed-in case)
# according to VDE-AR-N 4105
lv_feed-in_case_max_v_deviation = 0.035
# max. allowed voltage rise over MV/LV stations
mv_lv_station_max_v_rise = 0.015

# max. allowed voltage deviation in MV/LV stations (load case)
mv_lv_station_load_case_max_v_deviation = 0.02
# max. allowed voltage drop in LV grids
# according to VDE-AR-N 4105
lv_max_v_drop = 0.065

# max. allowed voltage deviation in MV/LV stations (feed-in case)
mv_lv_station_feed-in_case_max_v_deviation = 0.015
# max. allowed voltage drop over MV/LV stations
mv_lv_station_max_v_drop = 0.02

[grid_expansion_load_factors]

# load factors
# ============
# These are the load factors to use when grid issues in normal grid operation are checked.
# Load factors for n-1 security are set in section grid_expansion_load_factors_n_minus_one.
mv_load_case_transformer = 1.0
mv_load_case_line = 1.0
mv_feed-in_case_transformer = 1.0
mv_feed-in_case_line = 1.0

lv_load_case_transformer = 1.0
lv_load_case_line = 1.0
lv_feed-in_case_transformer = 1.0
lv_feed-in_case_line = 1.0

[grid_expansion_load_factors_n_minus_one]

# These are the load factors to use when n-1 security is checked. Usually, only the
# MV grid components need to be n-1 secure.
# Source: Rehtanz et. al.: "Verteilnetzstudie für das Land Baden-Württemberg", 2017.

mv_load_case_transformer = 0.5
mv_load_case_line = 0.5
mv_feed-in_case_transformer = 1.0
Expand Down
22 changes: 12 additions & 10 deletions edisgo/edisgo.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from sqlalchemy.engine.base import Engine

from edisgo.flex_opt.charging_strategies import charging_strategy
from edisgo.flex_opt.check_tech_constraints import lines_relative_load
from edisgo.flex_opt.heat_pump_operation import (
operating_strategy as hp_operating_strategy,
)
Expand Down Expand Up @@ -1037,9 +1038,10 @@ def reinforce(
timesteps_pfa: str | pd.DatetimeIndex | pd.Timestamp | None = None,
copy_grid: bool = False,
max_while_iterations: int = 20,
combined_analysis: bool = False,
split_voltage_band: bool = True,
mode: str | None = None,
without_generator_import: bool = False,
n_minus_one: bool = False,
**kwargs,
) -> Results:
"""
Expand Down Expand Up @@ -1086,9 +1088,10 @@ def reinforce(
max_while_iterations=max_while_iterations,
copy_grid=False,
timesteps_pfa=timesteps_pfa,
combined_analysis=combined_analysis,
split_voltage_band=split_voltage_band,
mode="mv",
without_generator_import=without_generator_import,
n_minus_one=n_minus_one,
)

if mode != "mv":
Expand All @@ -1103,9 +1106,10 @@ def reinforce(
max_while_iterations=max_while_iterations,
copy_grid=False,
timesteps_pfa=timesteps_pfa,
combined_analysis=combined_analysis,
split_voltage_band=split_voltage_band,
mode=reinforce_mode,
without_generator_import=without_generator_import,
n_minus_one=n_minus_one,
)

if mode not in ["mv", "lv"]:
Expand All @@ -1118,9 +1122,10 @@ def reinforce(
max_while_iterations=max_while_iterations,
copy_grid=copy_grid,
timesteps_pfa=timesteps_pfa,
combined_analysis=combined_analysis,
split_voltage_band=split_voltage_band,
mode=mode,
without_generator_import=without_generator_import,
n_minus_one=n_minus_one,
)

# add measure to Results object
Expand Down Expand Up @@ -2113,7 +2118,6 @@ def plot_mv_voltages(self, **kwargs):
filename=kwargs.get("filename", None),
grid_district_geom=kwargs.get("grid_district_geom", True),
background_map=kwargs.get("background_map", True),
voltage=self.results.v_res,
limits_cb_nodes=kwargs.get("limits_cb_nodes", None),
xlim=kwargs.get("xlim", None),
ylim=kwargs.get("ylim", None),
Expand Down Expand Up @@ -2147,7 +2151,6 @@ def plot_mv_line_loading(self, **kwargs):
timestep=kwargs.get("timestep", None),
line_color="loading",
node_color=kwargs.get("node_color", None),
line_load=self.results.i_res,
filename=kwargs.get("filename", None),
arrows=kwargs.get("arrows", None),
grid_district_geom=kwargs.get("grid_district_geom", True),
Expand Down Expand Up @@ -2317,15 +2320,14 @@ def histogram_relative_line_load(
else:
lines = self.topology.lines_df

rel_line_loading = tools.calculate_relative_line_load(
self, lines.index, timestep
)
rel_line_loading = lines_relative_load(self, lines.index)

if timestep is None:
timestep = rel_line_loading.index
# check if timesteps is array-like, otherwise convert to list
if not hasattr(timestep, "__len__"):
timestep = [timestep]
rel_line_loading = rel_line_loading.loc[timestep, :]

if title is True:
if len(timestep) == 1:
Expand Down Expand Up @@ -2755,7 +2757,7 @@ def resample_timeseries(
Default: '15min'.
"""
self.timeseries.resample_timeseries(method=method, freq=freq)
self.timeseries.resample(method=method, freq=freq)
self.electromobility.resample(freq=freq)
self.heat_pump.resample_timeseries(method=method, freq=freq)
self.overlying_grid.resample(method=method, freq=freq)
Expand Down
4 changes: 2 additions & 2 deletions edisgo/flex_opt/charging_strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def charging_strategy(
f"to the original frequency of the edisgo time series data."
)

edisgo_obj.timeseries.resample_timeseries(freq=simbev_timedelta)
edisgo_obj.timeseries.resample(freq=simbev_timedelta)

if strategy == "dumb":
# "dumb" charging
Expand Down Expand Up @@ -309,7 +309,7 @@ def charging_strategy(
raise ValueError(f"Strategy {strategy} has not yet been implemented.")

if resample:
edisgo_obj.timeseries.resample_timeseries(freq=edisgo_timedelta)
edisgo_obj.timeseries.resample(freq=edisgo_timedelta)

# set reactive power time series to 0 Mvar
# fmt: off
Expand Down

0 comments on commit c296887

Please sign in to comment.