eelib.utils.simulation_setup.helper_create_grid

Helper functions for the generation of new simulations.

Author: elenia@TUBS
Copyright 2024 elenia
This file is part of eELib, which is free software under the terms of the GNU GPL Version 3.

Module Contents

Functions

format_grid(→ pandapower.auxiliary.pandapowerNet)

Applies some general formatting to an existing grid, e.g. setting predefined values, removing

create_grid(→ pandapower.auxiliary.pandapowerNet | None)

Unified generation method to create a grid in different ways. Choose one way of creation:

create_grid_pp_code(→ tuple[str, ...)

Create pandapower grid including saved json file from information about pandapower template.

create_grid_sb_code(→ tuple[str, ...)

Create pandapower grid file from am predefined simbench grid including saved json file from

create_grid_radial_lv(→ tuple[str, ...)

Create pandapower grid file for a radial grid based on the number of loads for each string.

rename_elements(grid)

Renames the busses, loads, lines and transformers in the grid.

rename_buses_of_feeder(→ int)

Rename all buses in one feeder according to the feeder number and starting from one bus.

Attributes

bus_fields

load_fields

ext_grid_fields

trafo_fields

line_fields

grid

bus_fields = "['index', 'vn_kv', 'name', 'in_service', 'geodata']"
load_fields = "['bus', 'name', 'scaling']"
ext_grid_fields = "['bus', 'name', 'in_service']"
trafo_fields = "['hv_bus', 'lv_bus', 'std_type', 'name', 'in_service', 'parallel']"
line_fields = "['from_bus', 'to_bus', 'name', 'in_service', 'length_km', 'std_type', 'parallel']"
grid
format_grid(grid: pandapower.auxiliary.pandapowerNet, keep_profiles: bool = False) pandapower.auxiliary.pandapowerNet

Applies some general formatting to an existing grid, e.g. setting predefined values, removing attributes not used in eElib, …

Parameters:
  • grid (pandapowerNet) – The unformatted grid.

  • keep_profiles (bool) – Some grids ship with profiles, especially load profiles. The assignment is done via grid.load.profile column, while the whole profiles are stored in grid.profiles. This bool drops all profiles from the grid file.

Returns:

The formatted grid.

Return type:

pandapowerNet

create_grid(pp_code: str | None = None, sb_code: str | None = None, loads_at_branches: list | None = None, do_rename_elements: bool = True, plot_grid: bool = True, save_as_json_file: bool = False, keep_profiles: bool = False) pandapower.auxiliary.pandapowerNet | None

Unified generation method to create a grid in different ways. Choose one way of creation: Pandapower: Fill a pp_code. SimBench: Fill an sb_code. Custom radial: Fill loads_at_branches list.

Parameters:
  • pp_code (str | None, optional) – Name of method for pre-defined pandapower grid. (see [method library](https://pandapower.readthedocs.io/en/latest/networks.html))

  • sb_code (str | None, optional) – Code for pre-defined SimBench grid (see [grid code library](https://simbench.de/de/datensaetze/)).

  • loads_at_branches (list | None, optional) – Listing of the number of nodes at each radial string in the grid, so the length of the list defines the number of strings.

  • do_rename_elements (bool) – Whether grid elements should be adequately renamed. Watch out: This will not work for multi-voltage-level grids and those with circular structure, as we go by each feeder for renaming. Defaults to True.

  • plot_grid (bool, optional) – whether to create simple plot of grid. Defaults to False.

  • save_as_json_file (bool, optional) – Whether to save the grid as a file additionaly to returning it.

  • keep_profiles (bool, optional) – Some grids ship with profiles, especially load profiles. The assignment is done via grid.load.profile column, while the whole profiles are stored in grid.profiles. This bool drops all profiles from the grid file.

Raises:

ValueError – If not supplied with input for exactly one way of grid generation: pp_code, sb_code, or loads_at_branches.

Returns:

The grid from the specified source, formatted to eElib standards.

Might be None at first execution when going fully custom.

Return type:

pandapowerNet | None

create_grid_pp_code(pp_code: str = 'create_kerber_landnetz_kabel_1', adjust_comp_names: bool = True) tuple[str, pandapower.auxiliary.pandapowerNet]

Create pandapower grid including saved json file from information about pandapower template.

Parameters:
Returns:

Name and the grid from the predefined Pandapower code.

Return type:

tuple[str, pandapowerNet]

create_grid_sb_code(sb_code: str = '1-LV-rural1--0-sw') tuple[str, pandapower.auxiliary.pandapowerNet]

Create pandapower grid file from am predefined simbench grid including saved json file from information about grid components.

Parameters:

sb_code (str, optional) – Code for pre-defined SimBench grid (see [grid code library](https://simbench.de/de/datensaetze/)).

Raises:

KeyError – If sb_code is not a valid SimBenchCode.

Returns:

Name and the grid from the SimBench code.

Return type:

tuple[str, pandapowerNet]

create_grid_radial_lv(loads_at_branches: list = [6, 2]) tuple[str, pandapower.auxiliary.pandapowerNet]

Create pandapower grid file for a radial grid based on the number of loads for each string.

Parameters:

loads_at_branches (list) – Listing of the number of nodes at each radial string in the grid, so the length of the list defines the number of strings.

Returns:

Name and the radial low voltage grid.

Return type:

tuple[str, pandapowerNet]

rename_elements(grid: pandapower.auxiliary.pandapowerNet)

Renames the busses, loads, lines and transformers in the grid.

Parameters:

grid (pandapowerNet) – A pandapower grid.

rename_buses_of_feeder(grid: pandapower.auxiliary.pandapowerNet, feeder_num: int, starting_bus_idx: int, bus_idx_stop: list[int], counter_feeder: int = 1) int

Rename all buses in one feeder according to the feeder number and starting from one bus.

Parameters:
  • grid (pandapowerNet) – The corresponding pandapower grid

  • feeder_num (int) – the assigned number for this feeder (to name the buses to)

  • starting_bus_idx (int) – The index of the bus that this naming should start with (before going to the next bus etc.)

  • bus_idx_stop (list[int]) – list of bus indices that should not be considered, i.e. the busbar that represents the “limit” for this feeder

  • counter_feeder (int, optional) – Number to assign for the naming of the next bus (if some already set). Defaults to 1.

Returns:

The last number that was assigned for this (sub-)feeder

Return type:

int