edisgo.flex_opt package

edisgo.flex_opt.check_tech_constraints module

edisgo.flex_opt.check_tech_constraints.mv_line_load(edisgo_obj)[source]

Checks for over-loading issues in MV network.

Parameters:edisgo_obj (EDisGo) –
Returns:Dataframe containing over-loaded MV lines, their maximum relative over-loading (maximum calculated current over allowed current) and the corresponding time step. Index of the dataframe are the names of the over-loaded lines. Columns are ‘max_rel_overload’ containing the maximum relative over-loading as float, ‘time_index’ containing the corresponding time step the over-loading occured in as pandas.Timestamp, and ‘voltage_level’ specifying the voltage level the line is in (either ‘mv’ or ‘lv’).
Return type:pandas.DataFrame

Notes

Line over-load is determined based on allowed load factors for feed-in and load cases that are defined in the config file ‘config_grid_expansion’ in section ‘grid_expansion_load_factors’.

edisgo.flex_opt.check_tech_constraints.lv_line_load(edisgo_obj)[source]

Checks for over-loading issues in LV network.

Parameters:edisgo_obj (EDisGo) –
Returns:Dataframe containing over-loaded LV lines, their maximum relative over-loading (maximum calculated current over allowed current) and the corresponding time step. Index of the dataframe are the names of the over-loaded lines. Columns are ‘max_rel_overload’ containing the maximum relative over-loading as float, ‘time_index’ containing the corresponding time step the over-loading occured in as pandas.Timestamp, and ‘voltage_level’ specifying the voltage level the line is in (either ‘mv’ or ‘lv’).
Return type:pandas.DataFrame

Notes

Line over-load is determined based on allowed load factors for feed-in and load cases that are defined in the config file ‘config_grid_expansion’ in section ‘grid_expansion_load_factors’.

edisgo.flex_opt.check_tech_constraints.lines_allowed_load(edisgo_obj, voltage_level)[source]

Get allowed maximum current per line per time step

Parameters:
  • edisgo_obj (EDisGo) –
  • voltage_level (str) – Grid level, allowed line load is returned for. Possible options are “mv” or “lv”.
Returns:

Dataframe containing the maximum allowed current per line and time step in kA. Index of the dataframe are all time steps power flow analysis was conducted for of type pandas.Timestamp. Columns are line names of all lines in the specified voltage level.

Return type:

pandas.DataFrame

edisgo.flex_opt.check_tech_constraints.lines_relative_load(edisgo_obj, lines_allowed_load)[source]

Calculates relative line load based on specified allowed line load.

Parameters:
  • edisgo_obj (EDisGo) –
  • lines_allowed_load (pandas.DataFrame) – Dataframe containing the maximum allowed current per line and time step in kA. Index of the dataframe are time steps of type pandas.Timestamp and columns are line names.
Returns:

Dataframe containing the relative line load per line and time step. Index and columns of the dataframe are the same as those of parameter lines_allowed_load.

Return type:

pandas.DataFrame

edisgo.flex_opt.check_tech_constraints.hv_mv_station_load(edisgo_obj)[source]

Checks for over-loading of HV/MV station.

Parameters:edisgo_obj (EDisGo) –
Returns:Dataframe containing over-loaded HV/MV station, their apparent power at maximal over-loading and the corresponding time step. Index of the dataframe is the representative of the MVGrid. Columns are ‘s_missing’ containing the missing apparent power at maximal over-loading in MVA as float and ‘time_index’ containing the corresponding time step the over-loading occured in as pandas.Timestamp.
Return type:pandas.DataFrame

Notes

Over-load is determined based on allowed load factors for feed-in and load cases that are defined in the config file ‘config_grid_expansion’ in section ‘grid_expansion_load_factors’.

edisgo.flex_opt.check_tech_constraints.mv_lv_station_load(edisgo_obj)[source]

Checks for over-loading of MV/LV stations.

Parameters:edisgo_obj (EDisGo) –
Returns:Dataframe containing over-loaded MV/LV stations, their missing apparent power at maximal over-loading and the corresponding time step. Index of the dataframe are the representatives of the grids with over-loaded stations. Columns are ‘s_missing’ containing the missing apparent power at maximal over-loading in MVA as float and ‘time_index’ containing the corresponding time step the over-loading occured in as pandas.Timestamp.
Return type:pandas.DataFrame

Notes

Over-load is determined based on allowed load factors for feed-in and load cases that are defined in the config file ‘config_grid_expansion’ in section ‘grid_expansion_load_factors’.

edisgo.flex_opt.check_tech_constraints.mv_voltage_deviation(edisgo_obj, voltage_levels='mv_lv')[source]

Checks for voltage stability issues in MV network.

Returns buses with voltage issues and their maximum voltage deviation.

Parameters:
  • edisgo_obj (EDisGo) –
  • voltage_levels (str) –

    Specifies which allowed voltage deviations to use. Possible options are:

    • ’mv_lv’ This is the default. The allowed voltage deviations for buses in the MV is the same as for buses in the LV. Further, load and feed-in case are not distinguished.
    • ’mv’ Use this to handle allowed voltage limits in the MV and LV topology differently. In that case, load and feed-in case are differentiated.
Returns:

Dictionary with representative of MVGrid as key and a pandas.DataFrame with voltage deviations from allowed lower or upper voltage limits, sorted descending from highest to lowest voltage deviation, as value. Index of the dataframe are all buses with voltage issues. Columns are ‘v_diff_max’ containing the maximum voltage deviation as float and ‘time_index’ containing the corresponding time step the voltage issue occured in as pandas.Timestamp.

Return type:

dict

Notes

Voltage issues are determined based on allowed voltage deviations defined in the config file ‘config_grid_expansion’ in section ‘grid_expansion_allowed_voltage_deviations’.

edisgo.flex_opt.check_tech_constraints.lv_voltage_deviation(edisgo_obj, mode=None, voltage_levels='mv_lv')[source]

Checks for voltage stability issues in LV networks.

Returns buses with voltage issues and their maximum voltage deviation.

Parameters:
  • edisgo_obj (EDisGo) –
  • mode (None or str) – If None voltage at all buses in LV networks is checked. If mode is set to ‘stations’ only voltage at bus bar is checked. Default: None.
  • voltage_levels (str) –

    Specifies which allowed voltage deviations to use. Possible options are:

    • ’mv_lv’ This is the default. The allowed voltage deviations for buses in the LV is the same as for buses in the MV. Further, load and feed-in case are not distinguished.
    • ’lv’ Use this to handle allowed voltage limits in the MV and LV topology differently. In that case, load and feed-in case are differentiated.
Returns:

Dictionary with representative of LVGrid as key and a pandas.DataFrame with voltage deviations from allowed lower or upper voltage limits, sorted descending from highest to lowest voltage deviation, as value. Index of the dataframe are all buses with voltage issues. Columns are ‘v_diff_max’ containing the maximum voltage deviation as float and ‘time_index’ containing the corresponding time step the voltage issue occured in as pandas.Timestamp.

Return type:

dict

Notes

Voltage issues are determined based on allowed voltage deviations defined in the config file ‘config_grid_expansion’ in section ‘grid_expansion_allowed_voltage_deviations’.

edisgo.flex_opt.check_tech_constraints.voltage_diff(edisgo_obj, buses, v_dev_allowed_upper, v_dev_allowed_lower)[source]

Function to detect under- and overvoltage at buses.

The function returns both under- and overvoltage deviations in p.u. from the allowed lower and upper voltage limit, respectively, in separate dataframes. In case of both under- and overvoltage issues at one bus, only the highest voltage deviation is returned.

Parameters:
  • edisgo_obj (EDisGo) –
  • buses (list(str)) – List of buses to check voltage deviation for.
  • v_dev_allowed_upper (pandas.Series) – Series with time steps (of type pandas.Timestamp) power flow analysis was conducted for and the allowed upper limit of voltage deviation for each time step as float in p.u..
  • v_dev_allowed_lower (pandas.Series) – Series with time steps (of type pandas.Timestamp) power flow analysis was conducted for and the allowed lower limit of voltage deviation for each time step as float in p.u..
Returns:

  • pandas.DataFrame – Dataframe with deviations from allowed lower voltage level. Columns of the dataframe are all time steps power flow analysis was conducted for of type pandas.Timestamp; in the index are all buses for which undervoltage was detected. In case of a higher over- than undervoltage deviation for a bus, the bus does not appear in this dataframe, but in the dataframe with overvoltage deviations.
  • pandas.DataFrame – Dataframe with deviations from allowed upper voltage level. Columns of the dataframe are all time steps power flow analysis was conducted for of type pandas.Timestamp; in the index are all buses for which overvoltage was detected. In case of a higher under- than overvoltage deviation for a bus, the bus does not appear in this dataframe, but in the dataframe with undervoltage deviations.

edisgo.flex_opt.check_tech_constraints.check_ten_percent_voltage_deviation(edisgo_obj)[source]

Checks if 10% criteria is exceeded.

Through the 10% criteria it is ensured that voltage is kept between 0.9 and 1.1 p.u.. In case of higher or lower voltages a ValueError is raised.

Parameters:edisgo_obj (EDisGo) –

edisgo.flex_opt.costs module

edisgo.flex_opt.costs.grid_expansion_costs(edisgo_obj, without_generator_import=False)[source]

Calculates topology expansion costs for each reinforced transformer and line in kEUR.

edisgo.flex_opt.costs.edisgo_obj
Type:EDisGo
edisgo.flex_opt.costs.without_generator_import

If True excludes lines that were added in the generator import to connect new generators to the topology from calculation of topology expansion costs. Default: False.

Type:Boolean
edisgo.flex_opt.costs.mode

Specifies topology levels reinforcement was conducted for to only return costs in the considered topology level. Specify

  • None to return costs in MV and LV topology levels. None is the default.
  • ‘mv’ to return costs of MV topology level only, including MV/LV stations. Costs to connect LV generators are excluded as well.
Type:str
Returns:DataFrame containing type and costs plus in the case of lines the line length and number of parallel lines of each reinforced transformer and line. Index of the DataFrame is the name of either line or transformer. Columns are the following:
type: String
Transformer size or cable name
total_costs: float
Costs of equipment in kEUR. For lines the line length and number of parallel lines is already included in the total costs.
quantity: int
For transformers quantity is always one, for lines it specifies the number of parallel lines.
line_length: float
Length of line or in case of parallel lines all lines in km.
voltage_level : str {‘lv’ | ‘mv’ | ‘mv/lv’}
Specifies voltage level the equipment is in.
mv_feeder : Line
First line segment of half-ring used to identify in which feeder the network expansion was conducted in.
Return type:pandas.DataFrame<DataFrame>

Notes

Total network expansion costs can be obtained through self.grid_expansion_costs.total_costs.sum().

edisgo.flex_opt.costs.line_expansion_costs(edisgo_obj, lines_names)[source]

Returns costs for earthworks and per added cable as well as voltage level for chosen lines in edisgo_obj.

Parameters:
  • edisgo_obj (EDisGo) – eDisGo object of which lines of lines_df are part
  • lines_names (list of str) – List of names of evaluated lines
Returns:

costs – Dataframe with names of lines as index and entries for ‘costs_earthworks’, ‘costs_cable’, ‘voltage_level’ for each line

Return type:

pandas.DataFrame

edisgo.flex_opt.exceptions module

exception edisgo.flex_opt.exceptions.Error[source]

Bases: Exception

Base class for exceptions in this module.

exception edisgo.flex_opt.exceptions.MaximumIterationError(message)[source]

Bases: edisgo.flex_opt.exceptions.Error

Exception raised when maximum number of iterations in network reinforcement is exceeded.

message -- explanation of the error
exception edisgo.flex_opt.exceptions.ImpossibleVoltageReduction(message)[source]

Bases: edisgo.flex_opt.exceptions.Error

Exception raised when voltage issue cannot be solved.

message -- explanation of the error

edisgo.flex_opt.reinforce_grid module

edisgo.flex_opt.reinforce_grid.reinforce_grid(edisgo, timesteps_pfa=None, copy_grid=False, max_while_iterations=10, combined_analysis=False, mode=None)[source]

Evaluates network reinforcement needs and performs measures.

This function is the parent function for all network reinforcements.

Parameters:
  • edisgo (EDisGo) – The eDisGo API object
  • timesteps_pfa (str or pandas.DatetimeIndex or pandas.Timestamp) –

    timesteps_pfa specifies for which time steps power flow analysis is conducted and therefore which time steps to consider when checking for over-loading and over-voltage issues. It defaults to None in which case all timesteps in timeseries.timeindex (see TimeSeries) are used. Possible options are:

    • None Time steps in timeseries.timeindex (see TimeSeries) are used.
    • ’snapshot_analysis’ Reinforcement is conducted for two worst-case snapshots. See edisgo.tools.tools.select_worstcase_snapshots() for further explanation on how worst-case snapshots are chosen. Note: If you have large time series choosing this option will save calculation time since power flow analysis is only conducted for two 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.
    • pandas.DatetimeIndex or pandas.Timestamp Use this option to explicitly choose which time steps to consider.
  • copy_grid (Boolean) – If True reinforcement is conducted on a copied grid and discarded. Default: False.
  • max_while_iterations (int) – Maximum number of times each while loop is conducted.
  • combined_analysis (Boolean) – If True allowed voltage deviations for combined analysis of MV and LV topology are used. If False different allowed voltage deviations for MV and LV are used. See also config section grid_expansion_allowed_voltage_deviations. If mode is set to ‘mv’ combined_analysis should be False. Default: False.
  • mode (str) –

    Determines network levels reinforcement is conducted for. Specify

    • None to reinforce MV and LV network levels. None is the default.
    • ’mv’ to reinforce MV network level only, neglecting MV/LV stations, and LV network topology. LV load and generation is aggregated per LV network and directly connected to the primary side of the respective MV/LV station.
    • ’mvlv’ to reinforce MV network level only, including MV/LV stations, and neglecting LV network topology. LV load and generation is aggregated per LV network and directly connected to the secondary side of the respective MV/LV station.
Returns:

Returns the Results object holding network expansion costs, equipment changes, etc.

Return type:

Results

Notes

See Features in detail for more information on how network reinforcement is conducted.

edisgo.flex_opt.reinforce_measures module

edisgo.flex_opt.reinforce_measures.reinforce_mv_lv_station_overloading(edisgo_obj, critical_stations)[source]

Reinforce MV/LV substations due to overloading issues.

In a first step a parallel transformer of the same kind is installed. If this is not sufficient as many standard transformers as needed are installed.

Parameters:
  • edisgo_obj (EDisGo) –
  • critical_stations (pandas.DataFrame) – Dataframe containing over-loaded MV/LV stations, their missing apparent power at maximal over-loading and the corresponding time step. Index of the dataframe are the representatives of the grids with over-loaded stations. Columns are ‘s_missing’ containing the missing apparent power at maximal over-loading in MVA as float and ‘time_index’ containing the corresponding time step the over-loading occured in as pandas.Timestamp.
Returns:

Dictionary with added and removed transformers in the form:

{'added': {'Grid_1': ['transformer_reinforced_1',
                      ...,
                      'transformer_reinforced_x'],
           'Grid_10': ['transformer_reinforced_10']
           },
 'removed': {'Grid_1': ['transformer_1']}
}

Return type:

dict

edisgo.flex_opt.reinforce_measures.reinforce_hv_mv_station_overloading(edisgo_obj, critical_stations)[source]

Reinforce HV/MV station due to overloading issues.

In a first step a parallel transformer of the same kind is installed. If this is not sufficient as many standard transformers as needed are installed.

Parameters:
  • edisgo_obj (EDisGo) –
  • critical_stations (pandas:pandas.DataFrame<DataFrame>) – Dataframe containing over-loaded HV/MV stations, their missing apparent power at maximal over-loading and the corresponding time step. Index of the dataframe are the representatives of the grids with over-loaded stations. Columns are ‘s_missing’ containing the missing apparent power at maximal over-loading in MVA as float and ‘time_index’ containing the corresponding time step the over-loading occured in as pandas.Timestamp.
Returns:

Dictionary with added and removed transformers in the form:

{'added': {'Grid_1': ['transformer_reinforced_1',
                      ...,
                      'transformer_reinforced_x'],
           'Grid_10': ['transformer_reinforced_10']
           },
 'removed': {'Grid_1': ['transformer_1']}
}

Return type:

dict

edisgo.flex_opt.reinforce_measures.reinforce_mv_lv_station_voltage_issues(edisgo_obj, critical_stations)[source]

Reinforce MV/LV substations due to voltage issues.

A parallel standard transformer is installed.

Parameters:
  • edisgo_obj (EDisGo) –
  • critical_stations (dict) – Dictionary with representative of LVGrid as key and a pandas.DataFrame with station’s voltage deviation from allowed lower or upper voltage limit as value. Index of the dataframe is the station with voltage issues. Columns are ‘v_diff_max’ containing the maximum voltage deviation as float and ‘time_index’ containing the corresponding time step the voltage issue occured in as pandas.Timestamp.
Returns:

Dictionary with added transformers in the form:

{'added': {'Grid_1': ['transformer_reinforced_1',
                      ...,
                      'transformer_reinforced_x'],
           'Grid_10': ['transformer_reinforced_10']
           }
}

Return type:

dict

edisgo.flex_opt.reinforce_measures.reinforce_lines_voltage_issues(edisgo_obj, grid, crit_nodes)[source]

Reinforce lines in MV and LV topology due to voltage issues.

Parameters:
  • edisgo_obj (EDisGo) –
  • grid (MVGrid or LVGrid) –
  • crit_nodes (pandas.DataFrame) – Dataframe with all nodes with voltage issues in the grid and their maximal deviations from allowed lower or upper voltage limits sorted descending from highest to lowest voltage deviation (it is not distinguished between over- or undervoltage). Columns of the dataframe are ‘v_diff_max’ containing the maximum absolute voltage deviation as float and ‘time_index’ containing the corresponding time step the voltage issue occured in as pandas.Timestamp. Index of the dataframe are the names of all buses with voltage issues.
Returns:

Dictionary with name of lines as keys and the corresponding number of lines added as values.

Return type:

dict

Notes

Reinforce measures:

1. Disconnect line at 2/3 of the length between station and critical node farthest away from the station and install new standard line 2. Install parallel standard line

In LV grids only lines outside buildings are reinforced; loads and generators in buildings cannot be directly connected to the MV/LV station.

In MV grids lines can only be disconnected at LV stations because they have switch disconnectors needed to operate the lines as half rings (loads in MV would be suitable as well because they have a switch bay (Schaltfeld) but loads in dingo are only connected to MV busbar). If there is no suitable LV station the generator is directly connected to the MV busbar. There is no need for a switch disconnector in that case because generators don’t need to be n-1 safe.

edisgo.flex_opt.reinforce_measures.reinforce_lines_overloading(edisgo_obj, crit_lines)[source]

Reinforce lines in MV and LV topology due to overloading.

Parameters:
  • edisgo_obj (EDisGo) –
  • crit_lines (pandas.DataFrame) – Dataframe containing over-loaded lines, their maximum relative over-loading (maximum calculated current over allowed current) and the corresponding time step. Index of the dataframe are the names of the over-loaded lines. Columns are ‘max_rel_overload’ containing the maximum relative over-loading as float, ‘time_index’ containing the corresponding time step the over-loading occured in as pandas.Timestamp, and ‘voltage_level’ specifying the voltage level the line is in (either ‘mv’ or ‘lv’).
Returns:

Dictionary with name of lines as keys and the corresponding number of lines added as values.

Return type:

dict

Notes

Reinforce measures:

  1. Install parallel line of the same type as the existing line (Only if line is a cable, not an overhead line. Otherwise a standard equipment cable is installed right away.)
  2. Remove old line and install as many parallel standard lines as needed.