Exemplo n.º 1
0
def test_convert_format_for_pp_objects(net_in):
    pp.create_transformer(net_in,
                          net_in.bus.index.values[0],
                          net_in.bus.index.values[1],
                          '0.25 MVA 20/0.4 kV',
                          tap_pos=0)
    c1 = control.ContinuousTapControl(net_in, 0, 1.02)
    c2 = control.DiscreteTapControl(net_in, 0, 1, 1)
    c1.u_set = 0.98
    c2.u_lower = 0.99
    c2.u_upper = 1.1
    # needed to trigger conversion
    net_in.version = "2.1.0"

    net_in.controller.rename(columns={'object': 'controller'}, inplace=True)
    assert 'controller' in net_in.controller.columns

    s = json.dumps(net_in, cls=PPJSONEncoder)
    net1 = pp.from_json_string(s, convert=True)

    assert 'controller' not in net1.controller.columns
    assert 'object' in net1.controller.columns

    obj1 = net1.controller.object.at[0]
    obj2 = net1.controller.object.at[1]

    assert not hasattr(obj1, 'u_set')
    assert not hasattr(obj2, 'u_lower')
    assert not hasattr(obj2, 'u_upper')
    assert obj1.vm_set_pu == 0.98
    assert obj2.vm_lower_pu == 0.99
    assert obj2.vm_upper_pu == 1.1
Exemplo n.º 2
0
def test_new_pp_object_io():
    net = networks.mv_oberrhein()
    ds = DFData(pd.DataFrame(data=np.array([[0, 1, 2], [7, 8, 9]])))
    control.ConstControl(net,
                         'sgen',
                         'p_mw',
                         42,
                         profile_name=0,
                         data_source=ds)
    control.ContinuousTapControl(net, 142, 1)

    obj = net.controller.object.at[0]
    obj.run = pp.runpp

    s = json.dumps(net, cls=PPJSONEncoder)

    net1 = json.loads(s, cls=PPJSONDecoder)

    obj1 = net1.controller.object.at[0]
    obj2 = net1.controller.object.at[1]

    assert isinstance(obj1, control.ConstControl)
    assert isinstance(obj2, control.ContinuousTapControl)
    assert obj1.run is pp.runpp
    assert isinstance(obj1.data_source, DFData)
    assert isinstance(obj1.data_source.df, pd.DataFrame)
Exemplo n.º 3
0
def test_deepcopy_controller():
    net = pp.networks.mv_oberrhein()
    control.ContinuousTapControl(net, 114, 1.01)
    assert net == net.controller.object.iloc[0].net
    net2 = copy.deepcopy(net)
    assert net2 == net2.controller.object.iloc[0].net
    net3 = copy.copy(net)
    assert net3 == net3.controller.object.iloc[0].net
Exemplo n.º 4
0
def test_deepcopy_controller():
    net = pp.networks.mv_oberrhein()
    control.ContinuousTapControl(net, 114, 1.01)
    net2 = copy.deepcopy(net)
    ct1 = net.controller.object.iloc[0]
    ct2 = net2.controller.object.iloc[0]
    assert ct1 != ct2
    assert ct1.equals(ct2)
    ct2.vm_set_pu = 1.02
    assert not ct1.equals(ct2)
def test_continuous_i():
    net = pp.create_empty_network()
    hv = pp.create_bus(net, vn_kv=110.)
    lv = pp.create_bus(net, vn_kv=20)
    t = pp.create_transformer(net, hv, lv, std_type='40 MVA 110/20 kV')
    pp.create_ext_grid(net, hv)
    eps = 0.0005

    c = control.ContinuousTapControl(net, t, 1., tol=eps)

    # a different characteristic for i_lv_ka rather than for p_lv_mw
    characteristic = Characteristic(net, [0.315, 0.55], [0.95, 1.05])
    tc = control.USetTapControl(net,
                                0,
                                characteristic.index,
                                variable='i_lv_ka',
                                tol=eps)

    # create 20kW load
    lid = pp.create_load(net, lv, 20)
    gid = pp.create_sgen(net, lv, 0)
    pp.runpp(net, run_control=True)

    # we expect the tap to converge at upper voltage limit
    assert abs(net.res_bus.vm_pu.at[c.controlled_bus] - 1.05) < eps

    # power sums up to 15kW
    net.sgen.p_mw.at[gid] = 5
    pp.runpp(net, run_control=True)

    # we expect the tap to converge at 1.0 pu
    assert abs(net.res_bus.vm_pu.at[c.controlled_bus] - 1.) < eps

    # generation now cancels load
    net.sgen.p_mw.at[gid] = 10
    pp.runpp(net, run_control=True)

    # we expect the tap to converge at lower voltage limit
    assert abs(net.res_bus.vm_pu.at[c.controlled_bus] - 0.95) < eps

    # testing limits
    # power flowing back
    net.sgen.p_mw.at[gid] = 30
    pp.runpp(net, run_control=True)

    # we expect the tap to converge at lower voltage limit and not drop even lower
    assert abs(net.res_bus.vm_pu.at[c.controlled_bus] - 0.95) < eps

    # excessive load
    net.sgen.p_mw.at[gid] = 0
    net.load.p_mw.at[lid] = 30
    pp.runpp(net, run_control=True)

    # we expect the tap to converge at upper voltage limit and not to go beyond
    assert abs(net.res_bus.vm_pu.at[c.controlled_bus] - 1.05) < eps
Exemplo n.º 6
0
def test_json_different_nets():
    net = networks.mv_oberrhein()
    net2 = networks.simple_four_bus_system()
    control.ContinuousTapControl(net, 114, 1.02)
    net.tuple = (1, "4")
    net.mg = topology.create_nxgraph(net)
    json_string = json.dumps([net, net2], cls=PPJSONEncoder)
    [net_out, net2_out] = json.loads(json_string, cls=PPJSONDecoder)
    assert_net_equal(net_out, net)
    assert_net_equal(net2_out, net2)
    pp.runpp(net_out, run_control=True)
    pp.runpp(net, run_control=True)
    assert_net_equal(net, net_out)
Exemplo n.º 7
0
# Youtube Tutorial https://www.youtube.com/watch?v=yEIsUHyTY04
import pandapower.networks as nw
import pandapower as pp
import pandapower.control as ct

net = nw.mv_oberrhein()
ct.ContinuousTapControl(net, 114, 0.99, 1e-5)
# ct.DiscreteTapControl(net, 114, 0.99, 1.01)
pp.runpp(net, run_control=True)

print(net.trafo.tap_pos)
print(net.res_bus.loc[net.trafo.lv_bus, "vm_pu"])