Skip to content

Commit

Permalink
merge dev into features/#21-import-connect-genos
Browse files Browse the repository at this point in the history
  • Loading branch information
nesnoj committed Oct 9, 2017
1 parent 986ce6d commit 8f90a1c
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 27 deletions.
2 changes: 1 addition & 1 deletion doc/eDisGo_UML.graphml
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ length: float</y:AttributeLabel>
add_edge()
nodes_from_line()
nodes_by_attribute()
graph_edges()
lines()
</y:MethodLabel>
</y:UML>
</y:UMLClassNode>
Expand Down
6 changes: 3 additions & 3 deletions edisgo/data/import_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,13 +671,13 @@ def _validate_ding0_mv_grid_import(grid, ding0_grid):
not _.grid.grid_district.lv_load_area.is_aggregated)])

# Check number of lines outside aggregated LA
# edges_w_la = grid.graph.graph_edges()
# edges_w_la = grid.graph.lines()
# data_integrity['line']['edisgo'] = len([_ for _ in edges_w_la
# if not (_['adj_nodes'][0] == grid.station or
# _['adj_nodes'][1] == grid.station) and
# _['line']._length > .5])
# data_integrity['line']['ding0'] = len(
# [_ for _ in ding0_grid.graph_edges()
# [_ for _ in ding0_grid.lines()
# if not _['branch'].connects_aggregated])

# raise an error if data does not match
Expand Down Expand Up @@ -753,7 +753,7 @@ def _validate_ding0_lv_grid_import(grids, ding0_grid, lv_grid_mapping):

# Check number of lines outside aggregated LA
data_integrity[grid]['line']['edisgo'] = len(
list(grid.graph.graph_edges()))
list(grid.graph.lines()))
data_integrity[grid]['line']['ding0'] = len(
[_ for _ in lv_grid_mapping[grid].graph_edges()
if not _['branch'].connects_aggregated])
Expand Down
32 changes: 13 additions & 19 deletions edisgo/flex_opt/check_tech_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,15 @@ def mv_line_load(network):

crit_lines = {}

load_factor_mv_line = float(network.config['grid_expansion'][
'load_factor_mv_line'])
load_factor_mv_line = network.scenario.parameters.load_factor_mv_line

# ToDo: Add getter for i_res
for line in list(network.mv_grid.graph.graph_edges()):
for line in list(network.mv_grid.graph.lines()):
i_line_max = line['line'].type['I_max_th'] * \
load_factor_mv_line * line['line'].quantity
try:
# check if maximum current from power flow analysis exceeds
# allowed maximum current
i_line_pfa = max(network.results._i_res[repr(line['line'])])
i_line_pfa = max(network.results.i_res[repr(line['line'])])
if i_line_pfa > i_line_max:
crit_lines[line['line']] = i_line_pfa / i_line_max
except KeyError:
Expand Down Expand Up @@ -83,18 +81,16 @@ def lv_line_load(network):

crit_lines = {}

load_factor_lv_line = float(network.config['grid_expansion'][
'load_factor_lv_line'])
load_factor_lv_line = network.scenario.parameters.load_factor_lv_line

# ToDo: Add getter for i_res
for lv_grid in network.mv_grid.lv_grids:
for line in list(lv_grid.graph.graph_edges()):
for line in list(lv_grid.graph.lines()):
i_line_max = line['line'].type['I_max_th'] * \
load_factor_lv_line * line['line'].quantity
try:
# check if maximum current from power flow analysis exceeds
# allowed maximum current
i_line_pfa = max(network.results._i_res[repr(line['line'])])
i_line_pfa = max(network.results.i_res[repr(line['line'])])
if i_line_pfa > i_line_max:
crit_lines[line['line']] = i_line_pfa / i_line_max
except KeyError:
Expand Down Expand Up @@ -138,14 +134,14 @@ def mv_lv_station_load(network):

crit_stations = {}

load_factor_mv_lv_transformer = float(network.config['grid_expansion'][
'load_factor_mv_lv_transformer'])
load_factor_mv_lv_transformer = \
network.scenario.parameters.load_factor_mv_lv_transformer

for lv_grid in network.mv_grid.lv_grids:
station = lv_grid.station
# maximum allowed apparent power of station
s_station_max = sum([_.type.S_nom for _ in station.transformers]) * \
load_factor_mv_lv_transformer
s_station_max = (sum([_.type.S_nom for _ in station.transformers]) *
load_factor_mv_lv_transformer)
try:
# check if maximum allowed apparent power of station exceeds
# apparent power from power flow analysis
Expand Down Expand Up @@ -190,8 +186,7 @@ def mv_voltage_deviation(network):
crit_nodes = {}

# load max. voltage deviation
mv_max_v_deviation = float(
network.config['grid_expansion']['mv_max_v_deviation'])
mv_max_v_deviation = network.scenario.parameters.mv_max_v_deviation

v_mag_pu_pfa = network.results.v_res(nodes=network.mv_grid.graph.nodes(),
level='mv')
Expand All @@ -212,7 +207,7 @@ def mv_voltage_deviation(network):
len(crit_nodes[network.mv_grid])))
else:
crit_nodes = None
logger.debug('==> {} No voltage issues in MV grid.')
logger.debug('==> No voltage issues in MV grid.')

return crit_nodes

Expand Down Expand Up @@ -241,8 +236,7 @@ def lv_voltage_deviation(network):
crit_nodes = {}

# load max. voltage deviation
lv_max_v_deviation = float(
network.config['grid_expansion']['lv_max_v_deviation'])
lv_max_v_deviation = network.scenario.parameters.lv_max_v_deviation

for lv_grid in network.mv_grid.lv_grids:
v_mag_pu_pfa = network.results.v_res(nodes=lv_grid.graph.nodes(),
Expand Down
4 changes: 2 additions & 2 deletions edisgo/grid/grids.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def lines_by_attribute(self, attr_val, attr='type'):

return lines

def graph_edges(self):
def lines(self):
""" Returns a generator for iterating over graph edges
The edge of a graph is described by the two adjacent node and the branch
Expand All @@ -240,7 +240,7 @@ def graph_edges(self):
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)
edge attribute ('branch' is ugraph_edgessed 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
Expand Down
4 changes: 2 additions & 2 deletions edisgo/tools/pypsa_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def mv_to_pypsa(network):
generators = network.mv_grid.graph.nodes_by_attribute('generator')
loads = network.mv_grid.graph.nodes_by_attribute('load')
branch_tees = network.mv_grid.graph.nodes_by_attribute('branch_tee')
lines = network.mv_grid.graph.graph_edges()
lines = network.mv_grid.graph.lines()
lv_stations = network.mv_grid.graph.nodes_by_attribute('lv_station')
mv_stations = network.mv_grid.graph.nodes_by_attribute('mv_station')

Expand Down Expand Up @@ -394,7 +394,7 @@ def lv_to_pypsa(network):
generators.extend(lv_grid.graph.nodes_by_attribute('generator'))
loads.extend(lv_grid.graph.nodes_by_attribute('load'))
branch_tees.extend(lv_grid.graph.nodes_by_attribute('branch_tee'))
lines.extend(lv_grid.graph.graph_edges())
lines.extend(lv_grid.graph.lines())
lv_stations.extend(lv_grid.graph.nodes_by_attribute('lv_station'))

omega = 2 * pi * 50
Expand Down

0 comments on commit 8f90a1c

Please sign in to comment.