ding0.core.network package

Submodules

ding0.core.network.cable_distributors module

class ding0.core.network.cable_distributors.LVCableDistributorDing0(**kwargs)[source]

Bases: ding0.core.network.CableDistributorDing0

LV Cable distributor (connection point)

string_id

Description #TODO

branch_no

Description #TODO

load_no

Description #TODO

in_building

Description #TODO

pypsa_bus_id

Returns specific ID for representing bus in pypsa network.

Returns:str – Representative of pypsa bus
class ding0.core.network.cable_distributors.MVCableDistributorDing0(**kwargs)[source]

Bases: ding0.core.network.CableDistributorDing0

MV Cable distributor (connection point)

lv_load_area_group

Description #TODO

pypsa_bus_id

Returns specific ID for representing bus in pypsa network.

Returns:str – Representative of pypsa bus

ding0.core.network.grids module

ding0.core.network.loads module

class ding0.core.network.loads.LVLoadDing0(**kwargs)[source]

Bases: ding0.core.network.LoadDing0

Load in LV grids

Note

Current attributes to fulfill requirements of typified model grids.

pypsa_bus_id

Creates a unique identification for the generator to export to pypsa using the id_db of the mv_grid and the current object

Returns:str
class ding0.core.network.loads.MVLoadDing0(**kwargs)[source]

Bases: ding0.core.network.LoadDing0

Load in MV grids

Note

Currently not used, check later if still required

pypsa_bus_id

Creates a unique identification for the generator to export to pypsa using the id_db of the mv_grid and the current object

Returns:str

ding0.core.network.stations module

class ding0.core.network.stations.LVStationDing0(**kwargs)[source]

Bases: ding0.core.network.StationDing0

Defines a LV station in DINGO

peak_generation

Calculates cumulative peak generation of generators connected to underlying LV grid.

This is done instantaneously using bottom-up approach.

Returns:float – Cumulative peak generation
pypsa_bus0_id

Returns specific ID for representing bus in pypsa network. Representative node at medium voltage side (also used for transformer)

Returns:str – Representative of pypsa bus
pypsa_bus_id

Returns specific ID for representing bus in pypsa network.

Returns:str – Representative of pypsa bus
class ding0.core.network.stations.MVStationDing0(**kwargs)[source]

Bases: ding0.core.network.StationDing0

Defines a MV station in DINGO

peak_generation(mode)[source]

Calculates cumulative peak generation of generators connected to underlying grids

This is done instantaneously using bottom-up approach.

Parameters:mode (str) –

determines which generators are included:

'MV':   Only generation capacities of MV level are considered.

'MVLV': Generation capacities of MV and LV are considered
        (= cumulative generation capacities in entire MVGD).
Returns:float – Cumulative peak generation
pypsa_bus0_id

Returns specific ID for representing bus in pypsa network. Representative node at high voltage side (also used for transformer)

Returns:str – Representative of pypsa bus
pypsa_bus_id

Returns specific ID for representing bus in pypsa network.

Returns:str – Representative of pypsa bus
select_transformers()[source]

Selects appropriate transformers for the HV-MV substation.

The transformers are chosen according to max. of load case and feedin-case considering load factors. The HV-MV transformer with the next higher available nominal apparent power is chosen. If one trafo is not sufficient, multiple trafos are used. Additionally, in a second step an redundant trafo is installed with max. capacity of the selected trafos of the first step according to general planning principles for MV distribution grids (n-1).

Parameters:
  • transformers (dict) – Contains technical information of p hv/mv transformers
  • **kwargs (dict) – Should contain a value behind the key ‘peak_load’

Note

Parametrization of transformers bases on [1].

Potential hv-mv-transformers are chosen according to [2].

References

[1]Deutsche Energie-Agentur GmbH (dena), “dena-Verteilnetzstudie. Ausbau- und Innovationsbedarf der Stromverteilnetze in Deutschland bis 2030.”, 2012
[2]X. Tao, “Automatisierte Grundsatzplanung von Mittelspannungsnetzen”, Dissertation, 2006
set_operation_voltage_level()[source]

Set operation voltage level

ding0.core.network.transformers module

Module contents

class ding0.core.network.BranchDing0(**kwargs)[source]

Bases: object

When a network has a set of connections that don’t form into rings but remain as open stubs, these are designated as branches. Typically Branches at the MV level branch out of Rings.

length

Length of line given in m

Type:float
type

Association to pandas Series. DataFrame with attributes of line/cable.

Type:pandas.DataFrame
id_db

id according to database table

Type:int
ring

The associated RingDing0 object

Type:RingDing0
kind

‘line’ or ‘cable’

Type:str
connects_aggregated

A boolean True or False to mark if branch is connecting an aggregated Load Area or not. Defaults to False.

Type::obj`bool`
circuit_breaker

The circuit breaker that opens or closes this Branch.

Type::class:`~.ding0.core.network.CircuitBreakerDing0
critical

This a designation of if the branch is critical or not, defaults to False.

Type:bool

Note

Important: id_db is not set until whole grid is finished (setting at the end).

ADDED FOR NEW LV GRID APPROACH: geometry : shapely.LineString

due to for lv grids the coordinates of nodes and edges are known coordinates are stored as LineString to enable visualisation of the right course of the road.
network

Getter for the overarching NetworkDing0 object.

Returns:NetworkDing0
class ding0.core.network.CableDistributorDing0(**kwargs)[source]

Bases: object

Cable distributor (connection point)

id_db

id according to database table

Type:int
geo_data

The geo-spatial point in the coordinate reference system with the SRID:4326 or epsg:4326, this is the project used by the ellipsoid WGS 84.

Type:Shapely Point object
grid

The MV grid that this ring is to be a part of.

Type:MVGridDing0
network

Getter for the overarching NetworkDing0 object.

Returns:NetworkDing0
class ding0.core.network.CircuitBreakerDing0(**kwargs)[source]

Bases: object

Class for modelling a circuit breaker

id_db

id according to database table

Type:int
geo_data

The geo-spatial point in the coordinate reference system with the SRID:4326 or epsg:4326, this is the project used by the ellipsoid WGS 84.

Type:Shapely Point object
grid

The MV or LV grid that this Load is to be a part of.

Type:GridDing0
branch

The branch to which the Cable Distributor belongs to

Type:BranchDing0
branch_nodes

A tuple containing a pair of ding0 node objects i.e. GeneratorDing0 or GeneratorFluctuatingDing0 or LoadDing0 or StationDing0 or CircuitBreakerDing0 or CableDistributorDing0 or MVLoadDing0.

Type:tuple
status

The open or closed state of the Circuit Breaker.

Type:str, default ‘closed’

Note

Circuit breakers are nodes of a graph, but are NOT connected via an edge. They are associated to a specific branch of a graph (and the branch refers to the circuit breaker via the attribute circuit_breaker) and its two branch_nodes. Via open() and close() the associated branch can be removed from or added to graph.

close()[source]

Close a Circuit Breaker

network

Getter for the overarching NetworkDing0 object.

Returns:NetworkDing0
open()[source]

Open a Circuit Breaker

class ding0.core.network.GeneratorDing0(**kwargs)[source]

Bases: object

Generators (power plants of any kind)

id_db

id according to database table

Type:int
name

This is a name that can be given by the user. This defaults to a name automatically generated.

Type:str
v_level

voltage level

Type:float
geo_data

The geo-spatial point in the coordinate reference system with the SRID:4326 or epsg:4326, this is the project used by the ellipsoid WGS 84.

Type:Shapely Point object
mv_grid

The MV grid that this ring is to be a part of.

Type:MVGridDing0
lv_load_area

The LV Load Area the the generator is a part of.

Type:LVLoadAreaDing0
lv_grid

The LV Grid that the Generator is a part of.

Type:LVGridDing0
capacity

The generator’s rated power output in kilowatts.

Type:float
capacity_factor

The generators capacity factor i.e. the ratio of the average power generated by the generator versus the generator capacity.

Type:float
type

The generator’s type, an option amongst:

  • solar
  • wind
  • geothermal
  • reservoir
  • pumped_storage
  • run_of_river
  • gas
  • biomass
  • coal
  • lignite
  • gas
  • gas_mine
  • oil
  • waste
  • uranium
  • other_non_renewable
Type:str
subtype

The generator’s subtype, an option amongst:

  • solar_roof_mounted
  • solar_ground_mounted
  • wind_onshore
  • wind_offshore
  • hydro
  • geothermal
  • biogas_from_grid
  • biomass
  • biogas
  • biofuel
  • biogas_dry_fermentation
  • gas_mine
  • gas_sewage
  • gas_landfill
  • gas
  • waste_wood
  • wood
Type:str
network

Getter for the overarching NetworkDing0 object.

Returns:NetworkDing0
pypsa_bus_id

Creates a unique identification for the generator to export to pypsa using the id_db of the mv_grid and the current object

Returns:str
class ding0.core.network.GeneratorFluctuatingDing0(**kwargs)[source]

Bases: ding0.core.network.GeneratorDing0

Generator object for fluctuating renewable energy sources

_weather_cell_id

ID of the weather cell used to generate feed-in time series

Type:str
weather_cell_id

Get weather cell ID :returns: str – See class definition for details.

class ding0.core.network.GridDing0(**kwargs)[source]

Bases: object

The fundamental abstract class used to encapsulate the networkx graph and the relevant attributes of a power grid irrespective of voltage level. By design, this class is not expected to be instantiated directly. This class was designed to be inherited by MVGridDing0 or by LVGridDing0.

Parameters:
  • network (NetworkDing0) – The overarching CableDistributorDing0 object that this object is connected to.
  • id_db (str) – id according to database table
  • grid_district (Shapely Polygon object) – class, area that is covered by the lv grid
  • v_level (int) – The integer value of the voltage level of the Grid in kV. Typically, either 10 or 20.
cable_distributors[source]

List of CableDistributorDing0 Objects

Type:list
loads[source]

List of of LoadDing0 Objects. These are objects meant to be considered as MV-Level loads

Type:list
generators[source]

list of GeneratorDing0 or GeneratorFluctuatingDing0 Objects. These are objects meant to be considered as MV-Level Generators.

Type:list
graph

The networkx graph of the network. Initially this is an empty graph which gets populated differently depending upon which child class inherits this class, either LVGridDing0 or MVGridDing0.

Type:NetworkX Graph Objnetworkx.Graph
add_generator(generator)[source]

Adds a generator to _generators and grid graph if not already existing

Parameters:generator (GeneratorDing0 or GeneratorFluctuatingDing0) – Ding0’s generator object
cable_distributors()[source]

Provides access to the cable distributors in the grid.

Returns:list – List generator of CableDistributorDing0 objects
cable_distributors_count()[source]

Returns the count of cable distributors in grid

Returns:int – Count of the CableDistributorDing0 objects
control_generators(capacity_factor)[source]

Sets capacity factor of all generators of a grid.

A capacity factor of 0.6 means that all generators are to provide a capacity of 60% of their nominal power.

Parameters:capacity_factor (float) – Value between 0 and 1.
find_and_union_paths(node_source, nodes_target)[source]

Determines shortest paths from node_source to all nodes in node_target in _graph using find_path().

The branches of all paths are stored in a set - the result is a list of unique branches.

Parameters:
Returns:

list – List of BranchDing0 objects

find_path(node_source, node_target, type='nodes')[source]

Determines shortest path

Determines the shortest path from node_source to node_target in _graph using networkx’ shortest path algorithm.

Parameters:
Returns:

Note

WARNING: The shortest path is calculated using the count of hops, not the actual line lengths! As long as the circuit breakers are open, this works fine since there’s only one path. But if they are closed, there are 2 possible paths. The result is a path which have min. count of hops but might have a longer total path length than the second sone. See networkx’ function shortest_path() function for details on how the path is calculated.

generators()[source]

Returns a generator for iterating over grid’s generators

Returns:list generator – List of GeneratorDing0 and GeneratorFluctuatingDing0 objects
graph

Provide access to the graph

graph_add_node(node_object)[source]

Adds a station or cable distributor object to grid graph if not already existing

Parameters:node_object (GeneratorDing0 or GeneratorFluctuatingDing0 or LoadDing0 or StationDing0 or CircuitBreakerDing0 or CableDistributorDing0 or MVLoadDing0) – The ding0 node object to be added to the graph
graph_branches_from_node(node)[source]

Returns branches that are connected to node

Parameters:node (GeneratorDing0 or GeneratorFluctuatingDing0 or LoadDing0 or StationDing0 or CircuitBreakerDing0 or CableDistributorDing0 or MVLoadDing0) – Ding0 node object (member of graph)
Returns:list – List of tuple objects i.e. List of tuples (node, branch in BranchDing0)
(node , branch_0 ),
...,
(node , branch_N ),

node in ding0 is either GeneratorDing0 or GeneratorFluctuatingDing0 or LoadDing0 or StationDing0 or CircuitBreakerDing0 or CableDistributorDing0 or MVLoadDing0

graph_draw(mode)[source]

Draws grid graph using networkx

This method is for debugging purposes only. Use plot_mv_topology() for advanced plotting.

Parameters:mode (str) – Mode selection ‘MV’ or ‘LV’.

Note

The geo coords (for used crs see database import in class NetworkDing0) are used as positions for drawing but networkx uses cartesian crs. Since no coordinate transformation is performed, the drawn graph representation is falsified!

graph_edges()[source]

Returns a generator for iterating over graph edges

The edge of a graph is described by the two adjacent node and the branch object itself. Whereas the branch object is used to hold all relevant power system parameters.

Returns:dict generator –

Dictionary generator with the keys:

Note

There are generator functions for nodes (Graph.nodes()) and edges (Graph.edges()) in NetworkX but unlike graph nodes, which can be represented by objects, branch objects can only be accessed by using an edge attribute (‘branch’ is used here)

To make access to attributes of the branch objects simpler and more intuitive for the user, this generator yields a dictionary for each edge that contains information about adjacent nodes and the branch object.

Note, the construction of the dictionary highly depends on the structure of the in-going tuple (which is defined by the needs of networkX). If this changes, the code will break.

graph_isolated_nodes()[source]

Finds isolated nodes = nodes with no neighbors (degree zero)

Returns:list – List of ding0 node objects i.e. GeneratorDing0 or GeneratorFluctuatingDing0 or LoadDing0 or StationDing0 or CircuitBreakerDing0 or CableDistributorDing0 or MVLoadDing0
graph_nodes_from_branch(branch)[source]

Returns nodes that are connected by branch i.e. a BranchDing0 object.

Parameters:branch (BranchDing0) –
Returns:tuple – Tuple of node objects in ding0. 2-tuple of Ding0 node objects i.e. GeneratorDing0 or GeneratorFluctuatingDing0 or LoadDing0 or StationDing0 or CircuitBreakerDing0 or CableDistributorDing0 or MVLoadDing0
graph_nodes_sorted()[source]

Returns an sorted list of graph’s nodes. The nodes are arranged based on the name in ascending order.

Returns:list – List of GeneratorDing0 or GeneratorFluctuatingDing0 or LoadDing0 or StationDing0 or CircuitBreakerDing0 or CableDistributorDing0 or MVLoadDing0
graph_path_length(node_source, node_target)[source]

Calculates the absolute distance between node_source and node_target in meters using find_path() and branches’ length attribute.

node_source: GeneratorDing0 or GeneratorFluctuatingDing0 or LoadDing0 or StationDing0 or CircuitBreakerDing0 or CableDistributorDing0 or MVLoadDing0
source node, member of _graph, ding0 node object
node_target: GeneratorDing0 or GeneratorFluctuatingDing0 or LoadDing0 or StationDing0 or CircuitBreakerDing0 or CableDistributorDing0 or MVLoadDing0
target node, member of _graph, ding0 node object
Returns:float – path length in meters
loads()[source]

Returns a generator for iterating over grid’s loads

Returns:list generator – List Generator of LoadDing0 objects
loads_count()[source]

Returns the count of loads in grid

Returns:int – Count of the LoadDing0 objects
class ding0.core.network.LoadDing0(**kwargs)[source]

Bases: object

Class for modelling a load

id_db

id according to database table

Type:int
geo_data

The geo-spatial point in the coordinate reference system with the SRID:4326 or epsg:4326, this is the project used by the ellipsoid WGS 84.

Type:Shapely Point object
grid

The MV or LV grid that this Load is to be a part of.

Type:GridDing0
peak_load

Peak load of the current object

Type:float
building_id

refers to OSM oder eGo^n ID, depending on chosen database

Type:int
network

Getter for the overarching NetworkDing0 object.

Returns:NetworkDing0
class ding0.core.network.RingDing0(**kwargs)[source]

Bases: object

Represents a medium voltage Ring.

Parameters:grid (MVGridDing0) – The MV grid that this ring is to be a part of.
branches()[source]

Getter for the branches in the RingDing0 object.

Returns:list generator – List generator of BranchDing0 objects
lv_load_areas()[source]

Getter for the LV Load Areas that this Ring covers.

Returns:list generator – List generator of LVLoadAreaDing0 objects
network

Getter for the overarching NetworkDing0 object.

Returns:NetworkDing0
class ding0.core.network.StationDing0(**kwargs)[source]

Bases: object

The abstract definition of a substation irrespective of voltage level. This object encapsulates the attributes that can appropriately represent a station in a networkx graph as a node. By design, this class is not expected to be instantiated directly. This class was designed to be inherited by MVStationDing0 or by LVStationDing0.

Parameters:
  • id_db (str) – id according to database table
  • v_level_operation (float) – operation voltage level in kilovolts (kV) at station (the station’s voltage level differs from the nominal voltage level of the grid due to grid losses). It is usually set to a slightly higher value than the nominal voltage, e.g. 104% in MV grids.
  • geo_data (Shapely Point object) – The geo-spatial point in the coordinate reference system with the SRID:4326 or epsg:4326, this is the project used by the ellipsoid WGS 84.
  • grid (GridDing0) – Either a MVGridDing0 or MVGridDing0 object
  • _transformers (list of) – TransformerDing0 objects
add_transformer(transformer)[source]

Adds a transformer to _transformers if not already existing

Parameters:transformer (TransformerDing0) – The TransformerDing0 object to be added to the current StationDing0
network

Getter for the overarching NetworkDing0 object

Returns:NetworkDing0
peak_load

Cumulative peak load of loads connected to underlying MV or LV grid

(taken from MV or LV Grid District -> top-down)

Returns:float – Peak load of the current StationDing0 object

Note

This peak load includes all loads which are located within Grid District: When called from MV station, all loads of all Load Areas are considered (peak load was calculated in MVGridDistrictDing0.add_peak_demand()). When called from LV station, all loads of the LVGridDistrict are considered.

transformers()[source]

Returns a generator for iterating over transformers

Returns:list generator – List generator of TransformerDing0 objects
class ding0.core.network.TransformerDing0(**kwargs)[source]

Bases: object

Transformers are essentially voltage converters, which enable to change between voltage levels based on the usage.

id_db

id according to database table

Type:int
grid

The MV grid that this ring is to be a part of.

Type:MVGridDing0
v_level

voltage level [kV]

Type:float
s_max_a

rated power (long term) [kVA]

Type:float
s_max_b

rated power (short term)

Type:float
s_max_c

rated power (emergency)

Type:float
phase_angle

phase shift angle

Type:float
tap_ratio

off nominal turns ratio

Type:float
network

Getter for the overarching NetworkDing0 object.

Returns:NetworkDing0
z(voltage_level=None)[source]

Calculates the complex impedance in Ohm related to voltage_level. If voltage_level is not inserted, the secondary voltage of the transformer is chosen as a default. :param voltage_level: voltage in [kV] :return: Z_tr in [Ohm]