edisgo.flex_opt package

Submodules

edisgo.flex_opt.check_tech_constraints module

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

Checks for over-loading issues in MV grid.

Parameters:network (Network) –
Returns:Dataframe containing over-loaded MV lines, their maximum relative over-loading and the corresponding time step. Index of the dataframe are the over-loaded lines of type Line. Columns are ‘max_rel_overload’ containing the maximum relative over-loading as float and ‘time_index’ containing the corresponding time step the over-loading occured in as pandas.Timestamp.
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(network)[source]

Checks for over-loading issues in LV grids.

Parameters:network (Network) –
Returns:Dataframe containing over-loaded LV lines, their maximum relative over-loading and the corresponding time step. Index of the dataframe are the over-loaded lines of type Line. Columns are ‘max_rel_overload’ containing the maximum relative over-loading as float and ‘time_index’ containing the corresponding time step the over-loading occured in as pandas.Timestamp.
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.hv_mv_station_load(network)[source]

Checks for over-loading of HV/MV station.

Parameters:network (Network) –
Returns:Dataframe containing over-loaded HV/MV stations, their apparent power at maximal over-loading and the corresponding time step. Index of the dataframe are the over-loaded stations of type MVStation. Columns are ‘s_pfa’ containing the apparent power at maximal over-loading 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(network)[source]

Checks for over-loading of MV/LV stations.

Parameters:network (Network) –
Returns:Dataframe containing over-loaded MV/LV stations, their apparent power at maximal over-loading and the corresponding time step. Index of the dataframe are the over-loaded stations of type LVStation. Columns are ‘s_pfa’ containing the apparent power at maximal over-loading 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(network, voltage_levels='mv_lv')[source]

Checks for voltage stability issues in MV grid.

Parameters:
  • network (Network) –
  • voltage_levels (str) –

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

    • ’mv_lv’ This is the default. The allowed voltage deviation for nodes in the MV grid is the same as for nodes in the LV grid. Further load and feed-in case are not distinguished.
    • ’mv’ Use this to handle allowed voltage deviations in the MV and LV grid differently. Here, load and feed-in case are differentiated as well.
Returns:

Dictionary with MVGrid as key and a pandas.DataFrame with its critical nodes, sorted descending by voltage deviation, as value. Index of the dataframe are all nodes (of type Generator, Load, etc.) with over-voltage issues. Columns are ‘v_mag_pu’ containing the maximum voltage deviation as float and ‘time_index’ containing the corresponding time step the over-voltage 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(network, mode=None, voltage_levels='mv_lv')[source]

Checks for voltage stability issues in LV grids.

Parameters:
  • network (Network) –
  • mode (None or String) – If None voltage at all nodes in LV grid is checked. If mode is set to ‘stations’ only voltage at busbar is checked.
  • voltage_levels (str) –

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

    • ’mv_lv’ This is the default. The allowed voltage deviation for nodes in the MV grid is the same as for nodes in the LV grid. Further load and feed-in case are not distinguished.
    • ’lv’ Use this to handle allowed voltage deviations in the MV and LV grid differently. Here, load and feed-in case are differentiated as well.
Returns:

Dictionary with LVGrid as key and a pandas.DataFrame with its critical nodes, sorted descending by voltage deviation, as value. Index of the dataframe are all nodes (of type Generator, Load, etc.) with over-voltage issues. Columns are ‘v_mag_pu’ containing the maximum voltage deviation as float and ‘time_index’ containing the corresponding time step the over-voltage 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.check_ten_percent_voltage_deviation(network)[source]

Checks if 10% criteria is exceeded.

Parameters:network (Network) –

edisgo.flex_opt.costs module

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

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

edisgo.flex_opt.costs.network
Type:Network
edisgo.flex_opt.costs.without_generator_import

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

Type:Boolean
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 respective object that can either be a Line or a 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 grid expansion was conducted in.
Return type:pandas.DataFrame<dataframe>

Notes

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

edisgo.flex_opt.curtailment module

edisgo.flex_opt.curtailment.voltage_based(feedin, generators, curtailment_timeseries, edisgo, curtailment_key, **kwargs)[source]

Implements curtailment methodology ‘voltage-based’.

The curtailment that has to be met in each time step is allocated depending on the exceedance of the allowed voltage deviation at the nodes of the generators. The higher the exceedance, the higher the curtailment.

The optional parameter voltage_threshold specifies the threshold for the exceedance of the allowed voltage deviation above which a generator is curtailed. By default it is set to zero, meaning that all generators at nodes with voltage deviations that exceed the allowed voltage deviation are curtailed. Generators at nodes where the allowed voltage deviation is not exceeded are not curtailed. In the case that the required curtailment exceeds the weather-dependent availability of all generators with voltage deviations above the specified threshold, the voltage threshold is lowered in steps of 0.01 p.u. until the curtailment target can be met.

Above the threshold, the curtailment is proportional to the exceedance of the allowed voltage deviation. In order to find the linear relation between the curtailment and the voltage difference a linear problem is formulated and solved using the python package pyomo. See documentation for further information.

Parameters:
  • feedin (pandas.DataFrame) – Dataframe holding the feed-in of each generator in kW for the technology (and weather cell) specified in curtailment_key parameter. Index of the dataframe is a pandas.DatetimeIndex. Columns are the representatives of the fluctuating generators.
  • generators (pandas.DataFrame) – Dataframe with all generators of the type (and in weather cell) specified in curtailment_key parameter. See return value of edisgo.grid.tools.get_gen_info() for more information.
  • curtailment_timeseries (pandas.Series) – The curtailment in kW to be distributed amongst the generators in generators parameter. Index of the series is a pandas.DatetimeIndex.
  • edisgo (edisgo.grid.network.EDisGo) –
  • curtailment_key (str or tuple with str) – The technology and weather cell ID if tuple or only the technology if str the curtailment is specified for.
  • voltage_threshold (float) – The node voltage below which no curtailment is assigned to the respective generator if not necessary. Default: 0.0.
  • solver (str) –

    The solver used to optimize the curtailment assigned to the generator. Possible options are:

    • ’cbc’ coin-or branch and cut solver
    • ’glpk’ gnu linear programming kit solver
    • any other available compatible with ‘pyomo’ like ‘gurobi’ or ‘cplex’

    Default: ‘cbc’

edisgo.flex_opt.curtailment.feedin_proportional(feedin, generators, curtailment_timeseries, edisgo, curtailment_key, **kwargs)[source]

Implements curtailment methodology ‘feedin-proportional’.

The curtailment that has to be met in each time step is allocated equally to all generators depending on their share of total feed-in in that time step.

Parameters:
  • feedin (pandas.DataFrame) – Dataframe holding the feed-in of each generator in kW for the technology (and weather cell) specified in curtailment_key parameter. Index of the dataframe is a pandas.DatetimeIndex. Columns are the representatives of the fluctuating generators.
  • generators (pandas.DataFrame) – Dataframe with all generators of the type (and in weather cell) specified in curtailment_key parameter. See return value of edisgo.grid.tools.get_gen_info() for more information.
  • curtailment_timeseries (pandas.Series) – The curtailment in kW to be distributed amongst the generators in generators parameter. Index of the series is a pandas.DatetimeIndex.
  • edisgo (edisgo.grid.network.EDisGo) –
  • curtailment_key (str or tuple with str) – The technology and weather cell ID if tuple or only the technology if str the curtailment is specified for.

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 grid 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_graph=False, max_while_iterations=10, combined_analysis=False)[source]

Evaluates grid reinforcement needs and performs measures.

This function is the parent function for all grid 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_graph (Boolean) – If True reinforcement is conducted on a copied graph 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 grid are used. If False different allowed voltage deviations for MV and LV are used. See also config section grid_expansion_allowed_voltage_deviations. Default: False.
Returns:

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

Return type:

Results

Notes

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

edisgo.flex_opt.reinforce_measures module

edisgo.flex_opt.reinforce_measures.extend_distribution_substation_overloading(network, 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:
  • network (Network) –
  • critical_stations (pandas.DataFrame) – Dataframe containing over-loaded MV/LV stations, their apparent power at maximal over-loading and the corresponding time step. Index of the dataframe are the over-loaded stations of type LVStation. Columns are ‘s_pfa’ containing the apparent power at maximal over-loading as float and ‘time_index’ containing the corresponding time step the over-loading occured in as pandas.Timestamp. See mv_lv_station_load() for more information.
Returns:

Dictionary with lists of added and removed transformers.

Return type:

dict

edisgo.flex_opt.reinforce_measures.extend_distribution_substation_overvoltage(network, critical_stations)[source]

Reinforce MV/LV substations due to voltage issues.

A parallel standard transformer is installed.

Parameters:
  • network (Network) –
  • critical_stations (dict) – Dictionary with LVGrid as key and a pandas.DataFrame with its critical station and maximum voltage deviation as value. Index of the dataframe is the LVStation with over-voltage issues. Columns are ‘v_mag_pu’ containing the maximum voltage deviation as float and ‘time_index’ containing the corresponding time step the over-voltage occured in as pandas.Timestamp.
Returns:

Return type:

Dictionary with lists of added transformers.

edisgo.flex_opt.reinforce_measures.extend_substation_overloading(network, 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:
  • network (Network) –
  • critical_stations (pandas:pandas.DataFrame<dataframe>) – Dataframe containing over-loaded HV/MV stations, their apparent power at maximal over-loading and the corresponding time step. Index of the dataframe are the over-loaded stations of type MVStation. Columns are ‘s_pfa’ containing the apparent power at maximal over-loading as float and ‘time_index’ containing the corresponding time step the over-loading occured in as pandas.Timestamp. See hv_mv_station_load() for more information.
Returns:

Return type:

Dictionary with lists of added and removed transformers.

edisgo.flex_opt.reinforce_measures.reinforce_branches_overvoltage(network, grid, crit_nodes)[source]

Reinforce MV and LV grid due to voltage issues.

Parameters:
  • network (Network) –
  • grid (MVGrid or LVGrid) –
  • crit_nodes (pandas.DataFrame) – Dataframe with critical nodes, sorted descending by voltage deviation. Index of the dataframe are nodes (of type Generator, Load, etc.) with over-voltage issues. Columns are ‘v_mag_pu’ containing the maximum voltage deviation as float and ‘time_index’ containing the corresponding time step the over-voltage occured in as pandas.Timestamp.
Returns:

  • Dictionary with Line and the number of lines
  • added.

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 LVStations 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_branches_overloading(network, crit_lines)[source]

Reinforce MV or LV grid due to overloading.

Parameters:
  • network (Network) –
  • crit_lines (pandas.DataFrame) – Dataframe containing over-loaded lines, their maximum relative over-loading and the corresponding time step. Index of the dataframe are the over-loaded lines of type Line. Columns are ‘max_rel_overload’ containing the maximum relative over-loading as float and ‘time_index’ containing the corresponding time step the over-loading occured in as pandas.Timestamp.
Returns:

  • Dictionary with Line and the number of Lines
  • added.

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.

edisgo.flex_opt.storage_integration module

edisgo.flex_opt.storage_integration.storage_at_hvmv_substation(mv_grid, parameters, mode=None)[source]

Place storage at HV/MV substation bus bar.

Parameters:
  • mv_grid (MVGrid) – MV grid instance
  • parameters (dict) – Dictionary with storage parameters. Must at least contain ‘nominal_power’. See StorageControl for more information.
  • mode (str, optional) – Operational mode. See StorageControl for possible options and more information. Default: None.
Returns:

Created storage instance and newly added line to connect storage.

Return type:

Storage, Line

edisgo.flex_opt.storage_integration.set_up_storage(node, parameters, voltage_level=None, operational_mode=None)[source]

Sets up a storage instance.

Parameters:
  • node (Station or BranchTee) – Node the storage will be connected to.
  • parameters (dict, optional) – Dictionary with storage parameters. Must at least contain ‘nominal_power’. See StorageControl for more information.
  • voltage_level (str, optional) – This parameter only needs to be provided if node is of type LVStation. In that case voltage_level defines which side of the LV station the storage is connected to. Valid options are ‘lv’ and ‘mv’. Default: None.
  • operational_mode (str, optional) – Operational mode. See StorageControl for possible options and more information. Default: None.
edisgo.flex_opt.storage_integration.connect_storage(storage, node)[source]

Connects storage to the given node.

The storage is connected by a cable The cable the storage is connected with is selected to be able to carry the storages nominal power and equal amount of reactive power. No load factor is considered.

Parameters:
  • storage (Storage) – Storage instance to be integrated into the grid.
  • node (Station or BranchTee) – Node the storage will be connected to.
Returns:

Newly added line to connect storage.

Return type:

Line

edisgo.flex_opt.storage_operation module

edisgo.flex_opt.storage_operation.fifty_fifty(network, storage, feedin_threshold=0.5)[source]

Operational mode where the storage operation depends on actual power by generators. If cumulative generation exceeds 50% of nominal power, the storage is charged. Otherwise, the storage is discharged. The time series for active power is written into the storage.

Parameters:
  • network (Network) –
  • storage (Storage) – Storage instance for which to generate time series.
  • feedin_threshold (float) – Ratio of generation to installed power specifying when to charge or discharge the storage. If feed-in threshold is e.g. 0.5 the storage will be charged when the total generation is 50% of the installed generator capacity and discharged when it is below.

edisgo.flex_opt.storage_positioning module

edisgo.flex_opt.storage_positioning.one_storage_per_feeder(edisgo, storage_timeseries, storage_nominal_power=None, **kwargs)[source]

Allocates the given storage capacity to multiple smaller storages.

For each feeder with load or voltage issues it is checked if integrating a storage will reduce peaks in the feeder, starting with the feeder with the highest theoretical grid expansion costs. A heuristic approach is used to estimate storage sizing and siting while storage operation is carried over from the given storage operation.

Parameters:
  • edisgo (EDisGo) –
  • storage_timeseries (pandas.DataFrame) – Total active and reactive power time series that will be allocated to the smaller storages in feeders with load or voltage issues. Columns of the dataframe are ‘p’ containing active power time series in kW and ‘q’ containing the reactive power time series in kvar. Index is a pandas.DatetimeIndex.
  • storage_nominal_power (float or None) – Nominal power in kW that will be allocated to the smaller storages in feeders with load or voltage issues. If no nominal power is provided the maximum active power given in storage_timeseries is used. Default: None.
  • debug (Boolean, optional) – If dedug is True a dataframe with storage size and path to storage of all installed and possibly discarded storages is saved to a csv file and a plot with all storage positions is created and saved, both to the current working directory with filename storage_results_{MVgrid_id}. Default: False.
  • check_costs_reduction (Boolean or str, optional) –

    This parameter specifies when and whether it should be checked if a storage reduced grid expansion costs or not. It can be used as a safety check but can be quite time consuming. Possible options are:

    • ’each_feeder’ Costs reduction is checked for each feeder. If the storage did not reduce grid expansion costs it is discarded.
    • ’once’ Costs reduction is checked after the total storage capacity is allocated to the feeders. If the storages did not reduce grid expansion costs they are all discarded.
    • False Costs reduction is never checked.

    Default: False.

Module contents