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
-
-
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
-
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.
-
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
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
-
-
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: 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
-
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.
-
type
¶ Association to pandas Series. DataFrame with attributes of line/cable.
Type: pandas.DataFrame
-
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
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)
-
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
-
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
-
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
orGeneratorFluctuatingDing0
orLoadDing0
orStationDing0
orCircuitBreakerDing0
orCableDistributorDing0
orMVLoadDing0
.Type: tuple
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.
-
network
¶ Getter for the overarching
NetworkDing0
object.Returns: NetworkDing0
-
-
class
ding0.core.network.
GeneratorDing0
(**kwargs)[source]¶ Bases:
object
Generators (power plants of any kind)
-
name
¶ This is a name that can be given by the user. This defaults to a name automatically generated.
Type: str
-
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_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
-
-
class
ding0.core.network.
GeneratorFluctuatingDing0
(**kwargs)[source]¶ Bases:
ding0.core.network.GeneratorDing0
Generator object for fluctuating renewable energy sources
-
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 byLVGridDing0
.Parameters: - network (
NetworkDing0
) – The overarchingCableDistributorDing0
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
ObjectsType: list
-
loads
[source]¶ List of of
LoadDing0
Objects. These are objects meant to be considered as MV-Level loadsType: list
-
generators
[source]¶ list
ofGeneratorDing0
orGeneratorFluctuatingDing0
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
orMVGridDing0
.Type: NetworkX Graph Objnetworkx.Graph
-
add_generator
(generator)[source]¶ Adds a generator to
_generators
and grid graph if not already existingParameters: generator ( GeneratorDing0
orGeneratorFluctuatingDing0
) – Ding0’s generator object
-
cable_distributors
()[source] Provides access to the cable distributors in the grid.
Returns: list
– List generator ofCableDistributorDing0
objects
-
cable_distributors_count
()[source]¶ Returns the count of cable distributors in grid
Returns: int
– Count of theCableDistributorDing0
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: - node_source (
GeneratorDing0
orGeneratorFluctuatingDing0
orLoadDing0
orStationDing0
orCircuitBreakerDing0
orCableDistributorDing0
orMVLoadDing0
) – source node, member of _graph, ding0 node object - node_target (
GeneratorDing0
orGeneratorFluctuatingDing0
orLoadDing0
orStationDing0
orCircuitBreakerDing0
orCableDistributorDing0
orMVLoadDing0
) – target node, member of _graph, ding0 node object
Returns: list
– List ofBranchDing0
objects- node_source (
-
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: - node_source (
GeneratorDing0
orGeneratorFluctuatingDing0
orLoadDing0
orStationDing0
orCircuitBreakerDing0
orCableDistributorDing0
orMVLoadDing0
) – source node, member of _graph, ding0 node object - node_target (
GeneratorDing0
orGeneratorFluctuatingDing0
orLoadDing0
orStationDing0
orCircuitBreakerDing0
orCableDistributorDing0
orMVLoadDing0
) – target node, member of _graph, ding0 node object - type (
str
) – Specify if nodes or edges should be returned. Default is nodes
Returns: list
– List of ding0 node object i.e.GeneratorDing0
orGeneratorFluctuatingDing0
orLoadDing0
orStationDing0
orCircuitBreakerDing0
orCableDistributorDing0
orMVLoadDing0
- path (shortest path from node_source to) – node_target (list of nodes in _graph)
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.
- node_source (
-
generators
()[source] Returns a generator for iterating over grid’s generators
Returns: list
generator – List ofGeneratorDing0
andGeneratorFluctuatingDing0
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
orGeneratorFluctuatingDing0
orLoadDing0
orStationDing0
orCircuitBreakerDing0
orCableDistributorDing0
orMVLoadDing0
) – 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
orGeneratorFluctuatingDing0
orLoadDing0
orStationDing0
orCircuitBreakerDing0
orCableDistributorDing0
orMVLoadDing0
) – Ding0 node object (member of graph)Returns: list
– List oftuple
objects i.e. List of tuples (node, branch inBranchDing0
)(node , branch_0 ), ..., (node , branch_N ),
node in ding0 is either
GeneratorDing0
orGeneratorFluctuatingDing0
orLoadDing0
orStationDing0
orCircuitBreakerDing0
orCableDistributorDing0
orMVLoadDing0
-
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:
- adj_nodes paired to the Ding0 node object i.e.
GeneratorDing0
orGeneratorFluctuatingDing0
orLoadDing0
orStationDing0
orCircuitBreakerDing0
orCableDistributorDing0
orMVLoadDing0
- branch paried with the Ding0 branch object
BranchDing0
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.
- adj_nodes paired to the Ding0 node object i.e.
-
graph_isolated_nodes
()[source]¶ Finds isolated nodes = nodes with no neighbors (degree zero)
Returns: list
– List of ding0 node objects i.e.GeneratorDing0
orGeneratorFluctuatingDing0
orLoadDing0
orStationDing0
orCircuitBreakerDing0
orCableDistributorDing0
orMVLoadDing0
-
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
orGeneratorFluctuatingDing0
orLoadDing0
orStationDing0
orCircuitBreakerDing0
orCableDistributorDing0
orMVLoadDing0
-
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 ofGeneratorDing0
orGeneratorFluctuatingDing0
orLoadDing0
orStationDing0
orCircuitBreakerDing0
orCableDistributorDing0
orMVLoadDing0
-
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
orGeneratorFluctuatingDing0
orLoadDing0
orStationDing0
orCircuitBreakerDing0
orCableDistributorDing0
orMVLoadDing0
- source node, member of _graph, ding0 node object
- node_target:
GeneratorDing0
orGeneratorFluctuatingDing0
orLoadDing0
orStationDing0
orCircuitBreakerDing0
orCableDistributorDing0
orMVLoadDing0
- target node, member of _graph, ding0 node object
Returns: float
– path length in meters- node_source:
- network (
-
class
ding0.core.network.
LoadDing0
(**kwargs)[source]¶ Bases:
object
Class for modelling a load
-
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
-
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 ofBranchDing0
objects
-
lv_load_areas
()[source]¶ Getter for the LV Load Areas that this Ring covers.
Returns: list
generator – List generator ofLVLoadAreaDing0
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 byLVStationDing0
.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 aMVGridDing0
orMVGridDing0
object - _transformers (
list
of) –TransformerDing0
objects
-
add_transformer
(transformer)[source]¶ Adds a transformer to _transformers if not already existing
Parameters: transformer ( TransformerDing0
) – TheTransformerDing0
object to be added to the currentStationDing0
-
network
¶ Getter for the overarching
NetworkDing0
objectReturns: 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 currentStationDing0
objectNote
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 ofTransformerDing0
objects
- id_db (
-
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.
-
grid
¶ The MV grid that this ring is to be a part of.
Type: MVGridDing0
-
network
¶ Getter for the overarching
NetworkDing0
object.Returns: NetworkDing0
-