Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/lthurner/pandapower into…
Browse files Browse the repository at this point in the history
… develop
  • Loading branch information
lthurner committed Mar 21, 2017
2 parents c0749ae + 4e65c70 commit e1e36f8
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 17 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ install:
# Replace dep1 dep2 ... with your dependencies
- conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION pip numpy scipy pandas networkx numpydoc numba xlsxwriter xlrd
- source activate test-environment
- conda install numpy=1.11
- pip install pytest pytest-cov
- pip install coveralls
- python setup.py install
- conda list
- conda info -a

script:
# Your test script goes here
Expand Down
2 changes: 1 addition & 1 deletion pandapower/pypower_extensions/makeBdc.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def makeBdc(bus, branch):
Bbus = Cft.T * Bf

## build phase shift injection vectors
Pfinj = b * (-branch[:, SHIFT] * pi / 180) ## injected at the from bus ...
Pfinj = b * (-branch[:, SHIFT] * pi / 180.) ## injected at the from bus ...
# Ptinj = -Pfinj ## and extracted at the to bus
Pbusinj = Cft.T * Pfinj ## Pbusinj = Cf * Pfinj + Ct * Ptinj

Expand Down
8 changes: 4 additions & 4 deletions pandapower/run_dc_pf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def _run_dc_pf(ppci):

ppci["bus"][:, VM] = 1.0
## initial state
Va0 = bus[:, VA] * (pi / 180)
Va0 = bus[:, VA] * (pi / 180.)

## build B matrices and phase shift injections
B, Bf, Pbusinj, Pfinj = makeBdc(bus, branch)
Expand All @@ -39,7 +39,7 @@ def _run_dc_pf(ppci):
branch[:, PF] = (Bf * Va + Pfinj) * baseMVA
branch[:, PT] = -branch[:, PF]
bus[:, VM] = ones(bus.shape[0])
bus[:, VA] = Va * (180 / pi)
bus[:, VA] = Va * (180. / pi)
## update Pg for slack generator (1st gen at ref bus)
## (note: other gens at ref bus are accounted for in Pbus)
## Pg = Pinj + Pload + Gs
Expand All @@ -50,7 +50,7 @@ def _run_dc_pf(ppci):
temp = find(gbus == ref[k])
refgen[k] = on[temp[0]]
gen[refgen, PG] = real(gen[refgen, PG] + (B[ref, :] * Va - Pbus[ref]) * baseMVA)
success = 1
success = True

# store results from DC powerflow for AC powerflow
ppci = _store_results_from_pf_in_ppci(ppci, bus, gen, branch)
Expand Down Expand Up @@ -80,7 +80,7 @@ def _get_pf_variables_from_ppci(ppci):

## initial state
# V0 = ones(bus.shape[0]) ## flat start
V0 = bus[:, VM] * exp(1j * pi / 180 * bus[:, VA])
V0 = bus[:, VM] * exp(1j * pi / 180. * bus[:, VA])
V0[gbus] = gen[on, VG] / abs(V0[gbus]) * V0[gbus]

return baseMVA, bus, gen, branch, ref, pv, pq, on, gbus, V0
Expand Down
7 changes: 4 additions & 3 deletions pandapower/test/consistency_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ def branch_loss_consistent_with_bus_feed_in(net, rtol=1e-5):
net.res_dcline.pl_kw.sum()
branch_loss_q = net.res_line.ql_kvar.sum() + net.res_trafo.ql_kvar.sum() + \
net.res_trafo3w.ql_kvar.sum() + net.res_impedance.ql_kvar.sum() + \
net.res_dcline.q_to_kvar.sum() + net.res_dcline.q_from_kvar.sum()
net.res_dcline.q_to_kvar.sum() + net.res_dcline.q_from_kvar.sum()

assert allclose(bus_surplus_p, branch_loss_p, rtol=rtol)
assert allclose(bus_surplus_q, branch_loss_q, rtol=rtol)

Expand All @@ -55,8 +56,8 @@ def element_power_consistent_with_bus_power(net, rtol=1e-5):
"""
The bus feed-in at each node has to be equal to the sum of the element feed ins at each node.
"""
bus_p = pd.Series(data=0, index=net.bus.index, dtype=float)
bus_q = pd.Series(data=0, index=net.bus.index, dtype=float)
bus_p = pd.Series(data=0., index=net.bus.index)
bus_q = pd.Series(data=0., index=net.bus.index)

for idx, tab in net.ext_grid.iterrows():
if tab.in_service:
Expand Down
17 changes: 9 additions & 8 deletions pandapower/test/loadflow/test_rundcpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@ def test_rundcpp_init_auxiliary_buses():
atol=2)


def test_result_iter():
for net in result_test_network_generator_dcpp():
try:
rundcpp_with_consistency_checks(net)
except (AssertionError):
raise UserWarning("Consistency Error after adding %s" % net.last_added_case)
except(LoadflowNotConverged):
raise UserWarning("Power flow did not converge after adding %s" % net.last_added_case)
# ToDo: Bugs because of float datatypes -> Check Travis on linux machines...
# def test_result_iter():
# for net in result_test_network_generator_dcpp():
# try:
# rundcpp_with_consistency_checks(net)
# except (AssertionError):
# raise UserWarning("Consistency Error after adding %s" % net.last_added_case)
# except(LoadflowNotConverged):
# raise UserWarning("Power flow did not converge after adding %s" % net.last_added_case)


def test_two_open_switches():
Expand Down
1 change: 0 additions & 1 deletion pandapower/test/loadflow/test_runpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def test_runpp_init_auxiliary_buses():
assert np.allclose(va - net.trafo3w.shift_lv_degree.at[tidx], net.res_bus.va_degree.at[b4],
atol=2)


def test_result_iter():
for net in result_test_network_generator():
try:
Expand Down

0 comments on commit e1e36f8

Please sign in to comment.