Skip to content

Commit

Permalink
fixed pm shunt conversion 🐛
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Schaefer committed Oct 8, 2019
1 parent 361feed commit 3e33caf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
3 changes: 2 additions & 1 deletion pandapower/opf/pm_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,10 @@ def ppc_to_pm(net, ppci):
pm["load"][str(load_idx)] = {"pd": pd, "qd": qd, "load_bus": idx,
"status": True, "index": load_idx}
load_idx += 1
# if bs or gs != 0. -> shunt element at this bus
bs = row[BS]
gs = row[GS]
if pq_mismatch:
if not np.allclose(bs, 0.) or not np.allclose(gs, 0.):
pm["shunt"][str(shunt_idx)] = {"gs": gs, "bs": bs, "shunt_bus": idx,
"status": True, "index": shunt_idx}
shunt_idx += 1
Expand Down
16 changes: 12 additions & 4 deletions pandapower/test/opf/test_powermodels.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,22 @@
# and Energy System Technology (IEE), Kassel. All rights reserved.

import copy
import json
import os
from functools import partial

import numpy as np
import pandas as pd
import pytest
from pandapower.pd2ppc import _pd2ppc

import pandapower as pp
import pandapower.networks as nw
from pandapower.opf.pm_conversion import _read_results_to_net
from pandapower.pd2ppc import _pd2ppc
from pandapower.test.consistency_checks import consistency_checks
from pandapower.test.toolbox import add_grid_connection, create_test_line
from pandapower.toolbox import convert_pp_to_pm
from pandapower.opf.pm_conversion import _read_results_to_net
from pandapower.test.opf.test_basic import simple_opf_test_net
import json

try:
from julia import Main
Expand Down Expand Up @@ -451,8 +452,8 @@ def assert_pf(net):
va_pp = copy.copy(net.res_bus.va_degree)
vm_pp = copy.copy(net.res_bus.vm_pu)

assert np.allclose(va_pm, va_pp)
assert np.allclose(vm_pm, vm_pp)
assert np.allclose(va_pm, va_pp)


@pytest.mark.skipif(julia_installed == False, reason="requires julia installation")
Expand All @@ -464,6 +465,13 @@ def test_pm_ac_powerflow_simple():
# assert_pf(net)


@pytest.mark.skipif(julia_installed == False, reason="requires julia installation")
def test_pm_ac_powerflow_shunt():
net = nw.simple_four_bus_system()
pp.create_shunt(net, 2, q_mvar=-0.5)
net.trafo.loc[0, "shift_degree"] = 0.
assert_pf(net)


def test_pp_to_pm_conversion(net_3w_trafo_opf):
# tests if the conversion to power models works
Expand Down

0 comments on commit 3e33caf

Please sign in to comment.