edisgo.flex_opt package¶
edisgo.flex_opt.charging_strategies module¶
- edisgo.flex_opt.charging_strategies.charging_strategy(edisgo_obj, strategy='dumb', timestamp_share_threshold=0.2, minimum_charging_capacity_factor=0.1)[source]¶
Applies charging strategy to set EV charging time series at charging parks.
See
apply_charging_strategy
for more information.- Parameters
edisgo_obj (
EDisGo
) –strategy (str) – Defines the charging strategy to apply. See strategy parameter
apply_charging_strategy
for more information. Default: ‘dumb’.timestamp_share_threshold (float) – Percental threshold of the time required at a time step for charging the vehicle. See timestamp_share_threshold parameter
apply_charging_strategy
for more information. Default: 0.2.minimum_charging_capacity_factor (float) – Technical minimum charging power of charging points in p.u. used in case of charging strategy ‘reduced’. See minimum_charging_capacity_factor parameter
apply_charging_strategy
for more information. Default: 0.1.
- edisgo.flex_opt.charging_strategies.harmonize_charging_processes_df(df, edisgo_obj, len_ts, timestamp_share_threshold, strategy=None, minimum_charging_capacity_factor=0.1, eta_cp=1.0)[source]¶
Harmonizes the charging processes to prevent differences in the energy demand per charging strategy.
- Parameters
df (pandas.DataFrame) – Charging processes DataFrame.
len_ts (int) – Length of the timeseries.
timestamp_share_threshold (float) – See description in
charging_strategy()
.strategy (str) – See description in
charging_strategy()
.minimum_charging_capacity_factor (float) – See description in
charging_strategy()
. Default: 0.1.eta_cp (float) – Charging point efficiency. Default: 1.0.
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
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
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
- 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
- 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
- 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
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
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
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
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
- 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:
- typestr
Transformer size or cable name
- total_costsfloat
Costs of equipment in kEUR. For lines the line length and number of parallel lines is already included in the total costs.
- quantityint
For transformers quantity is always one, for lines it specifies the number of parallel lines.
- line_lengthfloat
Length of line or in case of parallel lines all lines in km.
- voltage_levelstr {‘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 partlines_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
edisgo.flex_opt.exceptions module¶
- exception edisgo.flex_opt.exceptions.Error[source]¶
Bases:
Exception
Base class for exceptions in this module.
edisgo.flex_opt.heat_pump_operation module¶
- edisgo.flex_opt.heat_pump_operation.operating_strategy(edisgo_obj, strategy='uncontrolled', heat_pump_names=None)[source]¶
Applies operating strategy to set electrical load time series of heat pumps.
See
apply_heat_pump_operating_strategy
for more information.- Parameters
edisgo_obj (
EDisGo
) –strategy (str) – Defines the operating strategy to apply. See strategy parameter in
apply_heat_pump_operating_strategy
for more information. Default: ‘uncontrolled’.heat_pump_names (list(str) or None) – Defines for which heat pumps to apply operating strategy. See heat_pump_names parameter in
apply_heat_pump_operating_strategy
for more information. Default: None.
edisgo.flex_opt.q_control module¶
- edisgo.flex_opt.q_control.get_q_sign_generator(reactive_power_mode)[source]¶
Get the sign of reactive power in generator sign convention.
In the generator sign convention the reactive power is negative in inductive operation (reactive_power_mode is ‘inductive’) and positive in capacitive operation (reactive_power_mode is ‘capacitive’).
- edisgo.flex_opt.q_control.get_q_sign_load(reactive_power_mode)[source]¶
Get the sign of reactive power in load sign convention.
In the load sign convention the reactive power is positive in inductive operation (reactive_power_mode is ‘inductive’) and negative in capacitive operation (reactive_power_mode is ‘capacitive’).
- edisgo.flex_opt.q_control.fixed_cosphi(active_power, q_sign, power_factor)[source]¶
Calculates reactive power for a fixed cosphi operation.
- Parameters
active_power (pandas.DataFrame) – Dataframe with active power time series. Columns of the dataframe are names of the components and index of the dataframe are the time steps reactive power is calculated for.
q_sign (pandas.Series or int) – q_sign defines whether the reactive power is positive or negative and must either be -1 or +1. In case q_sign is given as a series, the index must contain the same component names as given in columns of parameter active_power.
power_factor (pandas.Series or float) – Ratio of real to apparent power. In case power_factor is given as a series, the index must contain the same component names as given in columns of parameter active_power.
- Returns
Dataframe with the same format as the active_power dataframe, containing the reactive power.
- Return type
edisgo.flex_opt.reinforce_grid module¶
- edisgo.flex_opt.reinforce_grid.reinforce_grid(edisgo, timesteps_pfa=None, copy_grid=False, max_while_iterations=20, combined_analysis=False, mode=None, without_generator_import=False)[source]¶
Evaluates network reinforcement needs and performs measures.
This function is the parent function for all network reinforcements.
- Parameters
edisgo (
EDisGo
) – The eDisGo API objecttimesteps_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 (bool) – 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 (bool) – 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.
’lv’ to reinforce LV networks including MV/LV stations.
without_generator_import (bool) – 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.
- 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
- 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
- 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 ofLVGrid
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
- 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
) –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
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
Notes
Reinforce measures:
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.)
Remove old line and install as many parallel standard lines as needed.