Skip to content

Commit

Permalink
merge dev into features/#21-import-connect-genos, part II
Browse files Browse the repository at this point in the history
  • Loading branch information
nesnoj committed Sep 11, 2017
2 parents 854a7db + 08438fc commit 0c82684
Show file tree
Hide file tree
Showing 12 changed files with 1,028 additions and 320 deletions.
8 changes: 4 additions & 4 deletions doc/api/edisgo.data.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
edisgo.data package
===================
edisgo\.data package
====================

Submodules
----------

edisgo.data.import_data module
------------------------------
edisgo\.data\.import\_data module
---------------------------------

.. automodule:: edisgo.data.import_data
:members:
Expand Down
46 changes: 46 additions & 0 deletions doc/api/edisgo.flex_opt.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
edisgo\.flex\_opt package
=========================

Submodules
----------

edisgo\.flex\_opt\.check\_tech\_constraints module
--------------------------------------------------

.. automodule:: edisgo.flex_opt.check_tech_constraints
:members:
:undoc-members:
:show-inheritance:

edisgo\.flex\_opt\.costs module
-------------------------------

.. automodule:: edisgo.flex_opt.costs
:members:
:undoc-members:
:show-inheritance:

edisgo\.flex\_opt\.reinforce\_grid module
-----------------------------------------

.. automodule:: edisgo.flex_opt.reinforce_grid
:members:
:undoc-members:
:show-inheritance:

edisgo\.flex\_opt\.reinforce\_measures module
---------------------------------------------

.. automodule:: edisgo.flex_opt.reinforce_measures
:members:
:undoc-members:
:show-inheritance:


Module contents
---------------

.. automodule:: edisgo.flex_opt
:members:
:undoc-members:
:show-inheritance:
16 changes: 8 additions & 8 deletions doc/api/edisgo.grid.rst
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
edisgo.grid package
===================
edisgo\.grid package
====================

Submodules
----------

edisgo.grid.components module
-----------------------------
edisgo\.grid\.components module
-------------------------------

.. automodule:: edisgo.grid.components
:members:
:undoc-members:
:show-inheritance:

edisgo.grid.grids module
------------------------
edisgo\.grid\.grids module
--------------------------

.. automodule:: edisgo.grid.grids
:members:
:undoc-members:
:show-inheritance:

edisgo.grid.network module
--------------------------
edisgo\.grid\.network module
----------------------------

.. automodule:: edisgo.grid.network
:members:
Expand Down
1 change: 1 addition & 0 deletions doc/api/edisgo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Subpackages
.. toctree::

edisgo.data
edisgo.flex_opt
edisgo.grid
edisgo.tools

Expand Down
30 changes: 30 additions & 0 deletions doc/api/edisgo.tools.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
edisgo\.tools package
=====================

Submodules
----------

edisgo\.tools\.config module
----------------------------

.. automodule:: edisgo.tools.config
:members:
:undoc-members:
:show-inheritance:

edisgo\.tools\.pypsa\_io module
-------------------------------

.. automodule:: edisgo.tools.pypsa_io
:members:
:undoc-members:
:show-inheritance:


Module contents
---------------

.. automodule:: edisgo.tools
:members:
:undoc-members:
:show-inheritance:
4 changes: 3 additions & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,4 +355,6 @@ def __getattr__(cls, name):
intersphinx_mapping = {'python': ('https://docs.python.org/3', None)}

# Numbered figures
numfig = True
numfig = True

autodoc_member_order = 'bysource'
6 changes: 3 additions & 3 deletions doc/units_table.csv
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Variable;Symbol;Unit;Comment
Current;I;A;
Length;l;km;
Active Power;P;kW;
Reactive Power;Q;kvar;
Apparent Power;S;kVA;
Active Power;P;kW;In PyPSA representation (:attr:`~.grid.network.Network.pypsa`) MW are used
Reactive Power;Q;kvar;In PyPSA representation (:attr:`~.grid.network.Network.pypsa`) MVar are used
Apparent Power;S;kVA;In PyPSA representation (:attr:`~.grid.network.Network.pypsa`) MVA are used
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;
Expand Down
42 changes: 21 additions & 21 deletions edisgo/data/import_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from ding0.core.structure.regions import LVLoadAreaCentreDing0

from ..grid.components import Load, Generator, MVDisconnectingPoint, BranchTee,\
Station, Line, Transformer
MVStation, Line, Transformer, LVStation
from ..grid.grids import MVGrid, LVGrid

from egoio.db_tables import model_draft, supply
Expand Down Expand Up @@ -126,7 +126,7 @@ def _build_lv_grid(ding0_grid, network):
network=network)

# Create LV station instances
station = Station(id=ding0_lv_grid._station.id_db,
station = LVStation(id=ding0_lv_grid._station.id_db,
geom=ding0_lv_grid._station.geo_data,
grid=lv_grid,
transformers=[Transformer(
Expand Down Expand Up @@ -272,7 +272,7 @@ def _build_mv_grid(ding0_grid, network):
grid.graph.add_nodes_from(branch_tees.values(), type='branch_tee')

# Create list of LV station instances and add these to grid's graph
stations = {_: Station(id=_.id_db,
stations = {_: LVStation(id=_.id_db,
geom=_.geo_data,
grid=grid,
transformers=[Transformer(
Expand All @@ -292,7 +292,7 @@ def _build_mv_grid(ding0_grid, network):
grid.graph.add_nodes_from(stations.values(), type='lv_station')

# Create HV-MV station add to graph
mv_station = Station(
mv_station = MVStation(
id=ding0_grid.station().id_db,
geom=ding0_grid.station().geo_data,
transformers=[Transformer(
Expand Down Expand Up @@ -551,23 +551,23 @@ def _attach_aggregated(network, grid, aggregated, ding0_grid):
grid=grid)
}
grid.graph.add_edge(grid.station, gen, line, type='line')

load = Load(
geom=grid.station.geom,
consumption=la['load'],
grid=grid,
id='_'.join(['Load_aggregated', repr(grid)]))

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

# connect aggregated load to MV station
line = {'line': Line(
id='line_aggr_load',
type=aggr_line_type,
length=.5,
grid=grid)
}
grid.graph.add_edge(grid.station, load, line, type='line')
for sector, sectoral_load in la['load'].items():
load = Load(
geom=grid.station.geom,
consumption={sector: sectoral_load},
grid=grid,
id='_'.join(['Load_aggregated', sector, repr(grid)]))

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

# connect aggregated load to MV station
line = {'line': Line(
id='_'.join(['line_aggr_load', sector]),
type=aggr_line_type,
length=.5,
grid=grid)
}
grid.graph.add_edge(grid.station, load, line, type='line')


def _validate_ding0_grid_import(mv_grid, ding0_mv_grid, lv_grid_mapping):
Expand Down
58 changes: 40 additions & 18 deletions edisgo/examples/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,48 @@
# pickle.dump(network, open('test_network.pkl', 'wb'))
# network = pickle.load(open('test_network.pkl', 'rb'))

# export to pypsa
# network.analyze(mode='mv')
# Do non-linear power flow analysis with PyPSA (MV+LV)
# network.analyze()

# Print LV station secondary side voltage levels returned by PFA
# print(network.results.v_res(
# network.mv_grid.graph.nodes_by_attribute('lv_station'), 'lv'))

# Print voltage levels for entire LV grid
# for attr in ['lv_station', 'load', 'generator', 'branch_tee']:
# objs = []
# for lv_grid in network.mv_grid.lv_grids:
# objs.extend(lv_grid.graph.nodes_by_attribute(attr))
# print("\n\n\n{}\n".format(attr))
# print(network.results.v_res(
# objs, 'lv'))

# Print voltage level of all nodes
# print(network.results.pfa_v_mag_pu)

# Print apparent power at lines
# print(network.results.s_res([_['line'] for _ in network.mv_grid.graph.graph_edges()]))

# Print voltage levels for all lines
# print(network.results.s_res())

# for now create results object
# ToDo: Werte in DataFrame als List oder Array?
results = Results()
results.pfa_edges = pd.read_csv('Exemplary_PyPSA_line_results.csv',
index_col=0,
converters={'p0': literal_eval,
'q0': literal_eval,
'p1': literal_eval,
'q1': literal_eval})
results.pfa_edges['p0'] = results.pfa_edges['p0'].apply(lambda x: np.array(x))
results.pfa_edges['q0'] = results.pfa_edges['q0'].apply(lambda x: np.array(x))
results.pfa_edges['p1'] = results.pfa_edges['p1'].apply(lambda x: np.array(x))
results.pfa_edges['q1'] = results.pfa_edges['q1'].apply(lambda x: np.array(x))
results.pfa_nodes = pd.read_csv('Exemplary_PyPSA_bus_results.csv', index_col=0,
converters={'v_mag_pu': literal_eval})
results.pfa_nodes['v_mag_pu'] = results.pfa_nodes['v_mag_pu'].apply(
lambda x: np.array(x))
# results = Results()
# results.pfa_edges = pd.read_csv('Exemplary_PyPSA_line_results.csv',
# index_col=0,
# converters={'p0': literal_eval,
# 'q0': literal_eval,
# 'p1': literal_eval,
# 'q1': literal_eval})
# results.pfa_edges['p0'] = results.pfa_edges['p0'].apply(lambda x: np.array(x))
# results.pfa_edges['q0'] = results.pfa_edges['q0'].apply(lambda x: np.array(x))
# results.pfa_edges['p1'] = results.pfa_edges['p1'].apply(lambda x: np.array(x))
# results.pfa_edges['q1'] = results.pfa_edges['q1'].apply(lambda x: np.array(x))
# results.pfa_nodes = pd.read_csv('Exemplary_PyPSA_bus_results.csv', index_col=0,
# converters={'v_mag_pu': literal_eval})
# results.pfa_nodes['v_mag_pu'] = results.pfa_nodes['v_mag_pu'].apply(
# lambda x: np.array(x))

# # MV generators
# gens = network.mv_grid.graph.nodes_by_attribute('generator')
Expand All @@ -56,7 +78,7 @@
# else:
# print("O MWh")

reinforce_grid.reinforce_grid(network, results)
# from

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

0 comments on commit 0c82684

Please sign in to comment.