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 Sep 26, 2017
2 parents c4d3a00 + af91fcb commit f579443
Show file tree
Hide file tree
Showing 15 changed files with 988 additions and 395 deletions.
2 changes: 1 addition & 1 deletion doc/units_table.csv
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ Resistance;R;Ohm or Ohm/km;Ohm/km applies to lines
Reactance;X;Ohm or Ohm/km;Ohm/km applies to lines
Voltage;V;kV;
Inductance;L;mH/km;
Capacitance;C;nF/km;
Capacitance;C;µF/km;
57 changes: 57 additions & 0 deletions edisgo/config/config_costs_default.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# This file is part of eDisGo, a python package for distribution grid
# analysis and optimization.
#
# It is developed in the project open_eGo: https://openegoproject.wordpress.com
#
# eDisGo lives at github: https://github.com/openego/edisgo/
# The documentation is available on RTD: http://edisgo.readthedocs.io

# the key refers to column 'name' in equipment files

[costs_lv_cables]

NAYY 4x1x300 = 0
NAYY 4x1x240 = 0
NAYY 4x1x185 = 0
NAYY 4x1x150 = 0
NAYY 4x1x120 = 0
NAYY 4x1x95 = 0
NAYY 4x1x50 = 0
NAYY 4x1x35 = 0

[costs_mv_cables]

NA2XS2Y 3x1x185 RM/25 = 0
NA2XS2Y 3x1x240 RM/25 = 0
NA2XS2Y 3x1x300 RM/25 = 0
NA2XS2Y 3x1x400 RM/35 = 0
NA2XS2Y 3x1x500 RM/35 = 0
NA2XS2Y 3x1x150 RE/25 = 0
NA2XS2Y 3x1x240 = 0
NA2XS(FL)2Y 3x1x300 RM/25 = 0
NA2XS(FL)2Y 3x1x400 RM/35 = 0
NA2XS(FL)2Y 3x1x500 RM/35 = 0

[costs_mv_overhead_lines]

48-AL1/8-ST1A = 0
94-AL1/15-ST1A = 0
122-AL1/20-ST1A = 0

[costs_lv_transformers]

50 kVA = 0
100 kVA = 0
160 kVA = 0
250 kVA = 0
400 kVA = 0
630 kVA = 0
800 kVA = 0
1000 kVA = 0

[costs_mv_transformers]

20 MVA = 0
32 MVA = 0
40 MVA = 0
63 MVA = 0
46 changes: 43 additions & 3 deletions edisgo/config/config_flexopt_default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,57 @@

[grid_expansion]

# standard equipment (column 'name' in equipment files)
# standard equipment
# ==================
# (column 'name' in equipment files)
std_hv_mv_transformer = 40 MVA
std_mv_lv_transformer = 630 kVA
std_mv_line = NA2XS2Y 3x1x185 RM/25
std_lv_line = NAYY 4x1x150

# allowed voltage deviations
mv_max_v_deviation = 0.04
lv_max_v_deviation = 0.04
# ==========================
# COMBINED MV+LV
# --------------
# hv_mv_trafo_offset:
# offset which is set at HV-MV station
# (pos. if op. voltage is increased, neg. if decreased)
hv_mv_trafo_offset = 0.025

# hv_mv_trafo_control_deviation:
# control deviation of HV-MV station
# (always pos. in config; pos. or neg. usage depending on case in edisgo)
hv_mv_trafo_control_deviation = 0.015

# mv_lv_max_v_deviation:
# max. allowed voltage deviation according to DIN EN 50160
# caution: offset and control deviation at HV-MV station must be considered in calculations!
mv_lv_max_v_deviation = 0.10

# MV ONLY
# -------
# mv_load_case_max_v_deviation:
# max. allowed voltage deviation in MV grids (load case)
mv_load_case_max_v_deviation = 0.05

# mv_feedin_case_max_v_deviation:
# max. allowed voltage deviation in MV grids (feedin case)
# according to BDEW
mv_feedin_case_max_v_deviation = 0.02

# LV ONLY
# -------
# lv_feedin_case_max_v_deviation:
# max. allowed voltage deviation in LV grids (load case)
lv_load_case_max_v_deviation = 0.05

# lv_feedin_case_max_v_deviation:
# max. allowed voltage deviation in LV grids (feedin case)
# according to VDE-AR-N 4105
lv_feedin_case_max_v_deviation = 0.03

# load factors
# ============
load_factor_hv_mv_transformer = 1.0
load_factor_mv_lv_transformer = 1.0
load_factor_mv_line = 0.6
Expand Down
13 changes: 13 additions & 0 deletions edisgo/config/config_scenario_default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,16 @@

name = nep2035
#name = ego100

pfac_mv_gen = 0.9
pfac_mv_load = 0.9
pfac_lv_gen = 0.95
pfac_lv_load = 0.95

# scale factors describe actual power to nominal power ratio of generators and loads
# follows values provided by "dena-Verteilnetzstudie. Ausbau- und
# Innovationsbedarf der Stromverteilnetze in Deutschland bis 2030", .p. 98
scale_factor_mv_load = 0.15
scale_factor_lv_load = 0.1
scale_factor_feedin_pv = 0.85
scale_factor_feedin_other = 1
76 changes: 43 additions & 33 deletions edisgo/data/import_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def _build_lv_grid(ding0_grid, network):
grid_district={
'geom': ding0_lv_grid.grid_district.geo_data,
'population': ding0_lv_grid.grid_district.population},
voltage_nom=ding0_lv_grid.v_level,
voltage_nom=ding0_lv_grid.v_level / 1e3,
network=network)

station = {repr(_):_
Expand Down Expand Up @@ -160,7 +160,10 @@ def _build_lv_grid(ding0_grid, network):

# Create list of branch tee instances and add these to grid's graph
branch_tees = {
_: BranchTee(id=_.id_db, geom=_.geo_data, grid=lv_grid)
_: BranchTee(id=_.id_db,
geom=_.geo_data,
grid=lv_grid,
in_building=_.in_building)
for _ in ding0_lv_grid._cable_distributors}
lv_grid.graph.add_nodes_from(branch_tees.values(),
type='branch_tee')
Expand All @@ -182,7 +185,8 @@ def _build_lv_grid(ding0_grid, network):
{'line': Line(
id=_['branch'].id_db,
type=_['branch'].type,
length=_['branch'].length,
length=_['branch'].length / 1e3,
kind=_['branch'].kind,
grid=lv_grid)
})
for _ in edges]
Expand Down Expand Up @@ -238,7 +242,8 @@ def _build_mv_grid(ding0_grid, network):
aggregated, aggr_stations, dingo_import_data = _determine_aggregated_nodes(la_centers)
network.dingo_import_data = dingo_import_data
else:
aggregated = aggr_stations = []
aggregated = {}
aggr_stations = []

# Create list of load instances and add these to grid's graph
loads = {_: Load(
Expand Down Expand Up @@ -269,7 +274,10 @@ def _build_mv_grid(ding0_grid, network):
type='disconnection_point')

# Create list of branch tee instances and add these to grid's graph
branch_tees = {_: BranchTee(id=_.id_db, geom=_.geo_data, grid=grid)
branch_tees = {_: BranchTee(id=_.id_db,
geom=_.geo_data,
grid=grid,
in_building=False)
for _ in ding0_grid._cable_distributors}
grid.graph.add_nodes_from(branch_tees.values(), type='branch_tee')

Expand All @@ -288,7 +296,7 @@ def _build_mv_grid(ding0_grid, network):
geom=_.geo_data,
voltage_op=t.v_level,
type=pd.Series(dict(
S=t.s_max_a, X=t.x, R=t.r))
S_nom=t.s_max_a, X=t.x, R=t.r))
) for (count, t) in enumerate(_.transformers(), 1)])
for _ in ding0_grid._graph.nodes()
if isinstance(_, LVStationDing0) and _ not in aggr_stations}
Expand Down Expand Up @@ -326,7 +334,7 @@ def _build_mv_grid(ding0_grid, network):
{'line': Line(
id=_['branch'].id_db,
type=_['branch'].type,
length=_['branch'].length,
length=_['branch'].length / 1e3,
grid=grid)
})
for _ in ding0_grid.graph_edges()
Expand Down Expand Up @@ -403,20 +411,20 @@ def aggregate_generators(gen, aggr):
-------
"""

if gen.v_level not in aggr['generation']:
aggr['generation'][gen.v_level] = {}
if gen.subtype not in aggr['generation'][gen.v_level]:
aggr['generation'][gen.v_level].update(
{gen.subtype:
{'ids': [gen.id_db],
'capacity': gen.capacity,
'type': gen.type
}
}
)
if gen.type not in aggr['generation'][gen.v_level]:
aggr['generation'][gen.v_level][gen.type] = {}
if gen.subtype not in aggr['generation'][gen.v_level][gen.type]:
aggr['generation'][gen.v_level][gen.type].update(
{gen.subtype: {'ids': [gen.id_db],
'capacity': gen.capacity}})
else:
aggr['generation'][gen.v_level][gen.subtype]['ids'].append(gen.id_db)
aggr['generation'][gen.v_level][gen.subtype]['capacity'] += gen.capacity
aggr['generation'][gen.v_level][gen.type][gen.subtype][
'ids'].append(gen.id_db)
aggr['generation'][gen.v_level][gen.type][gen.subtype][
'capacity'] += gen.capacity

return aggr

Expand Down Expand Up @@ -451,9 +459,10 @@ def aggregate_loads(la_center, aggr):

return aggr

aggregated = []
aggregated = {}
aggr_stations = []

# TODO: The variable generation_aggr is further used -> delete this code
generation_aggr = {}
for la in la_centers[0].grid.grid_district._lv_load_areas:
for lvgd in la._lv_grid_districts:
Expand Down Expand Up @@ -498,7 +507,7 @@ def aggregate_loads(la_center, aggr):
aggr_stations.append(_.lv_grid.station())

# add elements to lists
aggregated.append(aggr)
aggregated.update({repr(la_center): aggr})


return aggregated, aggr_stations, dingo_import_data
Expand Down Expand Up @@ -526,19 +535,20 @@ def _attach_aggregated(network, grid, aggregated, ding0_grid):
aggr_line_type = ding0_grid.network._static_data['MV_cables'].iloc[
ding0_grid.network._static_data['MV_cables']['I_max_th'].idxmax()]

for la in aggregated:
for la_id, la in aggregated.items():
# add aggregated generators
for v_level, val in la['generation'].items():
for subtype, val2 in val.items():
gen = Generator(
id='agg_' + '_'.join(str(_) for _ in val2['ids']),
nominal_capacity=val2['capacity'],
type=val2['type'],
subtype=subtype,
geom=grid.station.geom,
grid=grid,
v_level=4)
grid.graph.add_node(gen, type='generator')
for type, val2 in val.items():
for subtype, val3 in val2.items():
gen = Generator(
id='agg_' + '_'.join([la_id] + [str(_) for _ in val3['ids']]),
nominal_capacity=val3['capacity'],
type=type,
subtype=subtype,
geom=grid.station.geom,
grid=grid,
v_level=4)
grid.graph.add_node(gen, type='generator')

# backup reference of geno to LV geno list (save geno
# where the former LV genos are aggregated in)
Expand All @@ -562,13 +572,13 @@ def _attach_aggregated(network, grid, aggregated, ding0_grid):
geom=grid.station.geom,
consumption={sector: sectoral_load},
grid=grid,
id='_'.join(['Load_aggregated', sector, repr(grid)]))
id='_'.join(['Load_aggregated', sector, repr(grid), la_id]))

grid.graph.add_node(load, type='load')

# connect aggregated load to MV station
line = {'line': Line(
id='_'.join(['line_aggr_load', sector]),
id='_'.join(['line_aggr_load', sector, la_id]),
type=aggr_line_type,
length=.5,
grid=grid)
Expand Down
2 changes: 1 addition & 1 deletion edisgo/equipment/equipment-parameters_LV_transformers.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name,s_nom,R,X
name,S_nom,R,X
#-,kVA,Ohm,Ohm
# Source 100..1000 kVar transformers: Torsten Werth; Netzberechnung mit Erzeugungsprofilen --
# Grundlagen, Berechnung, Anwendung; Springer; 2016
Expand Down
2 changes: 1 addition & 1 deletion edisgo/equipment/equipment-parameters_MV_transformers.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name,s_nom,R,X
name,S_nom,R,X
#-,kVA,Ohm,Ohm
20 MVA,20000,0,0
32 MVA,32000,0,0
Expand Down
33 changes: 26 additions & 7 deletions edisgo/examples/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,42 @@
import os
import pickle

import logging
logging.basicConfig(filename='example.log',
format='%(asctime)s %(message)s',
datefmt='%m/%d/%Y %I:%M:%S %p',
level=logging.INFO)
logger = logging.getLogger('edisgo')
logger.setLevel(logging.DEBUG)

timeseries = TimeSeries()
scenario = Scenario(timeseries=timeseries)
scenario = Scenario(timeseries=timeseries,
power_flow='worst-case')

import_network = False

if import_network:
network = Network.import_from_ding0(
os.path.join('data', 'ding0_grids_example.pkl'),
os.path.join('data', 'ding0_grids__76.pkl'),
id='Test grid',
scenario=scenario
)
# Do non-linear power flow analysis with PyPSA
network.analyze()
network.pypsa = None
pickle.dump(network, open('test_network.pkl', 'wb'))
network.pypsa.export_to_csv_folder('data/pypsa_export')
#network.pypsa = None
#pickle.dump(network, open('test_network.pkl', 'wb'))
else:
network = pickle.load(open('test_network.pkl', 'rb'))
network = None #pickle.load(open('test_network.pkl', 'rb'))

# from pypsa import Network as PyPSANetwork
# pypsa_network = PyPSANetwork(csv_folder_name='data/pypsa_export_80_stations')
# # q unterscheidet sich
# b1 = pypsa_network.transformers_t['q0']
# b2 = network.pypsa.transformers_t['q0']
# b3 = b1 - b2
# b1 = pypsa_network.loads_t['q_set']
# b2 = network.pypsa.loads_t['q_set']

# # Print LV station secondary side voltage levels returned by PFA
# print(network.results.v_res(
Expand Down Expand Up @@ -77,12 +96,12 @@
# print("O MWh")

reinforce_grid.reinforce_grid(network)
#print(network.results.grid_expansion_costs)

# liste aller lv grids
# [_ for _ in network.mv_grid.lv_grids]

# nx.draw_spectral(list(network.mv_grid.lv_grids)[0].graph)

# ToDo: feedin und load case auswahl
# ToDo: Möglichkeit MV und LV getrennt zu rechnen
# ToDo: Abbruchkriterium einführen - Anzahl paralleler lines

Loading

0 comments on commit f579443

Please sign in to comment.