edisgo.opf package

edisgo.opf.run_mp_opf module

edisgo.opf.run_mp_opf.convert(o)[source]

Helper function for json dump, as int64 cannot be dumped.

edisgo.opf.run_mp_opf.bus_names_to_ints(pypsa_network, bus_names)[source]

This remaps a list of eDisGo bus names from Strings to Integers.

Integer indices are needed for the optimization. The result uses one-based indexing, as it gets passed on to Julia directly.

Parameters
  • pypsa_network

  • bus_names (list(str)) – List of bus names to be remapped to indices.

Returns

List of one-based bus indices.

Return type

list(int)

edisgo.opf.run_mp_opf.run_mp_opf(edisgo_network, timesteps=None, storage_series=[], **kwargs)[source]
Parameters
  • edisgo_network

  • timesteps (pandas.DatetimeIndex<DatetimeIndex> or pandas.Timestamp<Timestamp>) –

  • **kwargs – “scenario” : “nep” # objective function “objective”: “nep”, # chosen relaxation “relaxation”: “none”, # upper bound on network expansion “max_exp”: 10, # number of time steps considered in optimization “time_horizon”: 2, # length of time step in hours “time_elapsed”: 1.0, # storage units are considered “storage_units”: False, # positioning of storage units, if empty list, all buses are potential positions # of storage units and # capacity is optimized “storage_buses”: [], # total storage capacity in the network “total_storage_capacity”: 0.0, # Requirements for curtailment in every time step is considered “storage_series”: [], # Time series for storage operation required by upper grid layer “curtailment_requirement”: False, # List of total curtailment for each time step, len(list)== “time_horizon” “curtailment_requirement_series”: [], # An overall allowance of curtailment is considered “curtailment_allowance”: False, # Maximal allowed curtailment over entire time horizon, # DEFAULT: “3percent”=> 3% of total RES generation in time horizon may be # curtailed, else: Float “curtailment_total”: “3percent”, “results_path”: “opf_solutions” # path to where OPF results are stored

edisgo.opf.timeseries_reduction module

edisgo.opf.timeseries_reduction.get_steps_curtailment(edisgo_obj, percentage=0.5)[source]

Get the time steps with the most critical violations for curtailment optimization.

Parameters
  • edisgo_obj (EDisGo) – The eDisGo API object

  • percentage (float) – The percentage of most critical time steps to select

Returns

the reduced time index for modeling curtailment

Return type

pandas.DatetimeIndex

edisgo.opf.timeseries_reduction.get_steps_storage(edisgo_obj, window=5)[source]

Get the most critical time steps from series for storage problems.

Parameters
  • edisgo_obj (EDisGo) – The eDisGo API object

  • window (int) – The additional hours to include before and after each critical time step.

Returns

the reduced time index for modeling storage

Return type

pandas.DatetimeIndex

edisgo.opf.timeseries_reduction.get_linked_steps(cluster_params, num_steps=24, keep_steps=[])[source]

Use provided data to identify representative time steps and create mapping Dict that can be passed to optimization

Parameters
  • cluster_params (pandas.DataFrame) – Time series containing the parameters to be considered for distance between points.

  • num_steps (int) – The number of representative time steps to be selected.

  • keep_steps (Iterable of the same type as cluster_params.index) – Time steps to retain with full resolution, regardless of clustering result.

Returns

Dictionary where each represented time step is a key and its representative time step is a value.

Return type

dict

edisgo.opf.results package

edisgo.opf.results.opf_expand_network.expand_network(edisgo, tolerance=1e-06)[source]

Apply network expansion factors that were obtained by optimization to eDisGo MVGrid

Parameters
  • edisgo (EDisGo) –

  • tolerance (float) – The acceptable margin with which an expansion factor can deviate from the nearest Integer before it gets rounded up

edisgo.opf.results.opf_expand_network.grid_expansion_costs(opf_results, tolerance=1e-06)[source]

Calculates grid expansion costs from OPF.

As grid expansion is conducted continuously number of expanded lines is determined by simply rounding up (including some tolerance).

Parameters
  • opf_results (OPFResults class) –

  • tolerance (float) –

Returns

Grid expansion costs determined by OPF

Return type

float

edisgo.opf.results.opf_expand_network.integrate_storage_units(edisgo, min_storage_size=0.3, timeseries=True, as_load=False)[source]

Integrates storage units from OPF into edisgo grid topology.

Storage units that are too small to be connected to the MV grid or that are not used (time series contains only zeros) are discarded.

Parameters
  • edisgo (EDisGo object) –

  • min_storage_size (float) – Minimal storage size in MW needed to connect storage unit to MV grid. Smaller storage units are ignored.

  • timeseries (bool) – If True time series is added to component.

  • as_load (bool) – If True, storage is added as load to the edisgo topology. This is temporarily needed as the OPF cannot handle storage units from edisgo yet. This way, storage units with fixed position and time series can be considered in OPF.

Returns

First return value contains the names of the added storage units and the second return value the capacity of storage units that were too small to connect to the MV grid or not used.

Return type

list(str), float

edisgo.opf.results.opf_expand_network.get_curtailment_per_node(edisgo, curtailment_ts=None, tolerance=0.001)[source]

Gets curtailed power per node.

As LV generators are aggregated at the corresponding LV station curtailment is not determined per generator but per node.

This function also checks if curtailment requirements were met by OPF in case the curtailment requirement time series is provided.

Parameters
  • edisgo (EDisGo object) –

  • curtailment_ts (pd.Series) – Series with curtailment requirement per time step. Only needs to be provided if you want to check if requirement was met.

  • tolerance (float) – Tolerance for checking if curtailment requirement and curtailed power are equal.

Returns

DataFrame with curtailed power in MW per node. Column names correspond to nodes and index to time steps calculated.

Return type

pd.DataFrame

edisgo.opf.results.opf_expand_network.get_load_curtailment_per_node(edisgo, tolerance=0.001)[source]

Gets curtailed load per node.

Parameters
  • edisgo (EDisGo object) –

  • tolerance (float) – Tolerance for checking if curtailment requirement and curtailed power are equal.

Returns

DataFrame with curtailed power in MW per node. Column names correspond to nodes and index to time steps calculated.

Return type

pd.DataFrame

edisgo.opf.results.opf_expand_network.integrate_curtailment_as_load(edisgo, curtailment_per_node)[source]

Adds load curtailed power per node as load

This is done because curtailment results from OPF are not given per generator but per node (as LV generators are aggregated per LV grid).

Parameters
  • edisgo

  • curtailment_per_node

Returns

edisgo.opf.results.opf_result_class.read_from_json(edisgo_obj, path, mode='mv')[source]

Read optimization results from json file.

This reads the optimization results directly from a JSON result file without carrying out the optimization process.

Parameters
  • edisgo_obj (EDisGo) – An edisgo object with the same topology that the optimization was run on.

  • path (str) – Path to the optimization result JSON file.

  • mode (str) – Voltage level, currently only supports “mv”

class edisgo.opf.results.opf_result_class.LineVariables[source]

Bases: object

class edisgo.opf.results.opf_result_class.BusVariables[source]

Bases: object

class edisgo.opf.results.opf_result_class.GeneratorVariables[source]

Bases: object

class edisgo.opf.results.opf_result_class.LoadVariables[source]

Bases: object

class edisgo.opf.results.opf_result_class.StorageVariables[source]

Bases: object

class edisgo.opf.results.opf_result_class.OPFResults[source]

Bases: object

set_solution(solution_name, pypsa_net)[source]
read_solution_file(solution_name)[source]
dump_solution_file(solution_name=[])[source]
set_solution_to_results(pypsa_net)[source]
set_line_variables(pypsa_net)[source]
set_bus_variables(pypsa_net)[source]
set_gen_variables(pypsa_net)[source]
set_load_variables(pypsa_net)[source]
set_strg_variables(pypsa_net)[source]

edisgo.opf.util package

edisgo.opf.util.plot_solutions.plot_line_expansion(edisgo_obj, timesteps)[source]
edisgo.opf.util.scenario_settings.opf_settings()[source]