eelib.data.dataclass.grid_info

Dataclasses for grid information used in eELib.

No testing is added for these functions and methods, as the grid info is quite specific for the use of links and entity infos in the eELib. This dataclass is only in use for the pandapower grid. During the setup of the simulation, the grid info is set up from the pandapower model and the linking in the input json file (via ‘build_from’). Afterwards, the grid info is given to the grid ems to store the configuration/setup

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

Classes

EquipmentInfo

Combines the information about the equipment, that are important to the grid operator. Mainly

GridInformation

Combines the information regarding the equipment of the grid and its topology. In addition to

ComponentTypes

Summarizes the component types for less typos.

Functions

convert_to_list(→ list)

(Helper function) Returns all the entities combined in one list.

retrieve_type(→ str)

(Helper function) Returns a standardized type name.

class EquipmentInfo

Combines the information about the equipment, that are important to the grid operator. Mainly information about the specification of a certain equipment (e.g. the rated apparent power, rated current, etc.) and the information about the links between the equipments.

property sim_id: str

Returns the simulator identifier. It is inferred, that the simulator identifier is the first half of the full identifier.

Returns:

The simulator identifier.

Return type:

str

property e_id: str

Returns the entity identifier of underlying entity.

Returns:

The entity id.

Return type:

str

property full_id: str

Returns the full identifier of the underlying entity.

Returns:

The identifier.

Return type:

str

get_spec(with_name: str) None | Any

Returns the specification with the given name.

Parameters:

with_name (str) – The name of the specification (e.g. “sn_va” for the nominal apparant power).

Returns:

In case the equipment does not have the requested specification None

is returned. In every other case the value of the specification is returned.

Return type:

None | Any

is_linked_to(entity: mosaik.scenario.Entity = None, fid: str = '') bool

Checks, if the equipment is connected to an entity with the given full identifier.

Parameters:
  • entity (Entity) – A component entity.

  • fid (str) – The full identifier of the equipment.

Returns:

If the identifier is found in the list of connected equipment True, otherwise

False.

Return type:

bool

get_connected_hems() EquipmentInfo | None

Returns the connected hems.

Returns:

If a hems is connected its informations are returned. Otherwise None is returned.

Return type:

EquipmentInfo | None

is_connected_to_loadbus() bool

Checks, if the equipment is connected to a loadbus.

Returns:

True, if it is connected to a loadbus.

Return type:

bool

is_connected_to_hems() bool

Checks, if the current component is connected to a hems.

Returns:

Is it connected to a hems?

Return type:

bool

is_stub() bool

Checks, if the current line is a direct connection to a household.

Returns:

For every other element False is returned.

Return type:

bool

is_connected_to_stub() bool

Checks, if the current component is connected to a stub/load line.

Returns:

True, if a stub is found in the list of linked components.

Return type:

bool

get_stub() EquipmentInfo | None

Returns the linked stub.

Returns:

None is returned, in case no stub is connected.

Return type:

EquipmentInfo | None

get_loadbus() EquipmentInfo | None

Returns the connected loadbus.

Returns:

The loadbus or None, if no loadbus is connected.

Return type:

EquipmentInfo | None

get_any_bus() EquipmentInfo | None

Returns the first encountered bus from the list of connected devices.

Returns:

Returns None if no equipment of type bus is connected.

Return type:

EquipmentInfo | None

is_smart_hems() bool

Checks, if the equipment is a smart hems.

Returns:

True for all hems models, that can send flex signals.

Return type:

bool

count_connected_devices_loadbus(generator: bool, loads: bool) int

Counts the directly connected devices to a loadbus.

Parameters:
  • generator (bool) – Count generator devices like pv or bss.

  • loads (bool) – Count load devices like charging station, heatpumps, etc.

Returns:

If this method is called on any other element then a loadbus, zero is returned.

Return type:

int

count_connected_devices(generator: bool, loads: bool) int

Counts the connected devices.

Parameters:
  • generator (bool) – If set to True, counts all generators.

  • loads (bool) – If set to True, counts all loads.

Returns:

The number of connected devices to a bus or a smart hems.

Return type:

int

connect_equipment(equipment_info: EquipmentInfo)

Connects to components.

Parameters:

equipment_info (EquipmentInfo) – A equipment like a line, a heatpump, etc.

static create_from(grid: mosaik.scenario.Entity, components_map: dict) list[EquipmentInfo]

Creates for each grid component an information object. It does not add the information about the connection between equipment.

Parameters:
  • grid (Entity) – The pandapower model entity.

  • components_map (dict) – The components map of the specific model.

Returns:

Either the list with the informations or an empty list, when the

grid entity is not of type ‘Pandapower’.

Return type:

list[EquipmentInfo]

Raises:

ValueError – If it is intended to be created for a grid that is not from pandapower model

static has_ext(component: dict, spec: str) bool

Checks, if the components dictionary contains the given specification in its static field.

Parameters:
  • component (dict) – The dictionary of the component.

  • spec (str) – A specification like ‘sn_va’ for the nominal apparant power of a generator.

Returns:

Returns False, if no static field is found or the component does not have the

specification.

Return type:

bool

static get(spec: str, from_component: dict) Any

Returns the value of the specification spec. It is assumed, that the component dictionary has a field ‘static’. It also is assumed, that ‘static’ contains the ‘spec’ key.

Parameters:
  • spec (str) – A specification like the nominal apparant power ‘sn_va’.

  • from_component (dict) – The dictionary of the component.

Returns:

The value of the specification.

Return type:

Any

class GridInformation

Combines the information regarding the equipment of the grid and its topology. In addition to the information about the grid, the information about which load is represented by a hems is also stored.

property entity_ids: list[str]

Lists all entity identifiers.

Returns:

The entity ids.

Return type:

list[str]

add(info: EquipmentInfo)

Adds information to the grid informations.

Parameters:

info (EquipmentInfo) – The information to add.

remove(info: EquipmentInfo)

Removes the information from the grid information. In case the information is missing, nothing will be done.

Parameters:

info (EquipmentInfo) – The information to remove.

get_info_by(entity_id: str = '', full_id: str = '', type: str = '') EquipmentInfo | None

Retrieves the information with either the given entity_id or the full_id.

Parameters:
  • entity_id (str, optional) – An entity identifier of a grid equipment. Defaults to “”.

  • full_id (str, optional) – A full identifier of a grid equipment. Defaults to “”.

  • type (str, optional) – The equipment type. Defaults to “”.

Returns:

Either the information to the equipment or None if no equipment

matches the given identifier. In case the info’s type is the search criteria the first encountered info with that type is returned.

Return type:

EquipmentInfo | None

filtered_infos(by_type: str) list[EquipmentInfo]

Filters the information by an equipment type.

Parameters:

by_type (str) – An equipment type like “trafo”

Returns:

The filtered equipment informations, that have the given type.

Return type:

list[EquipmentInfo]

contains(equip_type: str) bool

Checks for the existence of a certain equipment.

Parameters:

equip_type (str) – The type of equipment (e.g. trafo, line, etc).

Returns:

Returns True, in case equipment with that type is found.

Return type:

bool

get_eids(of_type: str) list[str]

Returns the entity identifier of all equipment with a certain type.

Parameters:

of_type (str) – The equipment type.

Returns:

A list containing the entity identifiers. If the grid does not contain any

equipment of that type, then an empty list is returned.

Return type:

list[str]

get_connected_hems(of_eid: str = '', of_info: EquipmentInfo = None) EquipmentInfo | None

Searches for the connected hems and returns its informations.

Parameters:
  • of_eid (str, optional) – The entity identifier of an existing . Defaults to “”.

  • of_info (EquipmentInfo, optional) – Information of the entity. Defaults to None.

Raises:

ValueError – If no argument is provided.

Returns:

None is returned, if no hems is connected.

Return type:

EquipmentInfo | None

get_spec(e_id: str, spec: str) float | None

Retrieves the value of the specification from the element with the e_id.

Parameters:
  • e_id (str) – An entitiy identifier of an existing component.

  • spec (str) – The specification to retrieve.

Returns:

None is returned, in case no component with the given e_id is found or the

component does not have that particular specification.

Return type:

float | None

get_smart_hems_list() list[EquipmentInfo]

Returns all smart hems in a list.

Returns:

The list of smart hems.

Return type:

list[EquipmentInfo]

Adds the information about connection between the two equipments. In case there is no information about both equipments, nothing will be done.

Parameters:
  • e_id_1 (str) – The entity identifier of the first equipment.

  • e_id_2 (str) – The entity identifier of the second equipment.

is_equip(with_eid: str, of_type: str) bool

Checks, if the equipment is of a certain type.

Parameters:
  • with_eid (str) – The entity identifier of the equipment.

  • of_type (str) – The type to match against (e.g. trafo, line,…).

Returns:

Matches the equipment type against the provided type.

Return type:

bool

get_equip_count(with_type: str) int

Returns the number of equipment with the same type.

Parameters:

with_type (str) – The equipment type (e.g. trafo, line, etc)

Returns:

The number of equipments of the same type in the grid.

Return type:

int

connect_hems_and_devices(grid_model_config: dict, entities: dict)

Connects the home energy management systems (hems) with their devices.

Parameters:
  • grid_model_config (dict) – A dictionary containing the relation between the hems and the connected loads.

  • entities (dict) – A dictionary containing the all the entities grouped by their type.

static build_from(grid: mosaik.scenario.Entity, components_map: dict) GridInformation

Creates the grid information from the provided grid entity and the components_map.

Parameters:
  • grid (Entity) – The grid model instance, that is providing the entities of the components.

  • components_map (dict) – The dictionary containing the information about the grid components.

Returns:

The informations about the grid components and their connection.

Return type:

GridInformation

class ComponentTypes(*args, **kwds)

Bases: enum.Enum

Summarizes the component types for less typos.

static values() list[str]

Returns the value of each case.

Returns:

The values of each case.

Return type:

list[str]

static grid_comps() list[str]

Summarizes the component types. It excludes the hems as a component.

Returns:

The values of the component types.

Return type:

list[str]

convert_to_list(entities_dict: dict[str, list]) list

(Helper function) Returns all the entities combined in one list.

Parameters:

entities_dict (dict[str, list]) – The configuration dictionary used in the connect_entities_in_grid function.

Returns:

The entities.

Return type:

list

retrieve_type(entity: mosaik.scenario.Entity, entities_dict: dict[str, list]) str

(Helper function) Returns a standardized type name.

Parameters:
  • entity (Entity) – The entity, whose type is determined.

  • entities_dict (dict[str, list]) – The configuration dictionary, that contains the grouped entities.

Returns:

The type name e.g. heatpump, charging_station, etc.

Return type:

str