Beispiel #1
0
def test_replace_gen_sgen():
    net = nw.case9()
    vm_set = [1.03, 1.02]
    net.gen["vm_pu"] = vm_set
    pp.runpp(net)
    assert list(net.res_gen.index.values) == [0, 1]

    # replace_gen_by_sgen
    pp.replace_gen_by_sgen(net)
    assert not net.gen.shape[0]
    assert not net.res_gen.shape[0]
    assert not np.allclose(net.sgen.q_mvar.values, 0)
    assert net.res_gen.shape[0] == 0
    pp.runpp(net)
    assert np.allclose(net.res_bus.loc[net.sgen.bus, "vm_pu"].values, vm_set)

    # replace_sgen_by_gen
    net2 = copy.deepcopy(net)
    pp.replace_sgen_by_gen(net2, [1])
    assert net2.gen.shape[0] == 1
    assert net2.res_gen.shape[0] == 1
    assert net2.gen.shape[0] == 1
    assert net2.res_gen.shape[0] == 1

    pp.replace_sgen_by_gen(net, 1)
    assert pp.nets_equal(net, net2)
Beispiel #2
0
def test_replace_gen_sgen():
    for i in range(2):
        net = nw.case9()
        vm_set = [1.03, 1.02]
        net.gen["vm_pu"] = vm_set
        net.gen["dspf"] = 1
        pp.runpp(net)
        assert list(net.res_gen.index.values) == [0, 1]

        # replace_gen_by_sgen
        if i == 0:
            pp.replace_gen_by_sgen(net)
        elif i == 1:
            pp.replace_gen_by_sgen(net, [0, 1], sgen_indices=[4, 1], cols_to_keep=[
                "max_p_mw"], add_cols_to_keep=["dspf"])  # min_p_mw is not in cols_to_keep
            assert np.allclose(net.sgen.index.values, [4, 1])
            assert np.allclose(net.sgen.dspf.values, 1)
            assert "max_p_mw" in net.sgen.columns
            assert "min_p_mw" not in net.sgen.columns
        assert not net.gen.shape[0]
        assert not net.res_gen.shape[0]
        assert not np.allclose(net.sgen.q_mvar.values, 0)
        assert net.res_gen.shape[0] == 0
        pp.runpp(net)
        assert np.allclose(net.res_bus.loc[net.sgen.bus, "vm_pu"].values, vm_set)

        # replace_sgen_by_gen
        net2 = copy.deepcopy(net)
        if i == 0:
            pp.replace_sgen_by_gen(net2, [1])
        elif i == 1:
            pp.replace_sgen_by_gen(net2, 1, gen_indices=[2], add_cols_to_keep=["dspf"])
            assert np.allclose(net2.gen.index.values, [2])
            assert np.allclose(net2.gen.dspf.values, 1)
        assert net2.gen.shape[0] == 1
        assert net2.res_gen.shape[0] == 1
        assert net2.gen.shape[0] == 1
        assert net2.res_gen.shape[0] == 1

        if i == 0:
            pp.replace_sgen_by_gen(net, 1)
            assert pp.nets_equal(net, net2)
Beispiel #3
0
proj_lib = os.path.join(os.path.join(conda_dir, 'share'), 'proj')
os.environ["PROJ_LIB"] = proj_lib
'''


##############################################################################
time_start = time.process_time()
##############################################################################

# INITIALIZATION OF THE POWER NETWORK

# Call the Great Britain reduced power network from Pandapower
net = pandapower.networks.GBreducednetwork()

# Replace static generators with standard generators
pp.replace_sgen_by_gen(net)
list_ext_grid  = list(net.ext_grid.index)
initial_slack = pp.replace_ext_grid_by_gen(net, list_ext_grid, slack=True) 
    
# Set the maximum loading of each line to 100%   
net.line.loc[:,'max_loading_percent'] = 100
net.trafo.loc[:,'max_loading_percent'] = 100

# Set the min/max power values of each load
net.load.loc[:,'max_p_mw'] = net.load.p_mw
net.load.loc[:,'min_p_mw'] = 0

# Set the min/max power values of each generator
net.gen.loc[:,'max_p_mw'] = net.gen.max_p_mw/1.438
#net.ext_grid.loc[:,'max_p_mw'] = net.ext_grid.max_p_mw/1.438
net.gen.loc[:,'p_mw'] = net.gen.max_p_mw
Beispiel #4
0
import pandapower as pd
import pandapower.networks as pn


'''
net = pd.converter.from_mpc('caset.mat',
                            f_hz=50,
                            casename_mpc_file='caset',
                            validate_conversion=False)
'''
net = pn.case24_ieee_rts()
net.load['controllable'] = True
pd.replace_ext_grid_by_gen(net)
pd.replace_sgen_by_gen(net)
net.gen.loc[0, 'slack'] = True
pd.create_bus(net,
              vn_kv=230,
              name='DCnode',
              index=24,
              max_vm_pu=1.05,
              min_vm_pu=0.95)
pd.create_ext_grid(net, bus=24, max_q_mvar=500, min_q_mvar=0, min_p_mw=0, max_p_mw=1000, slack=False)
pd.create_poly_cost(net,
                    element=0,
                    et='gen',
                    cp0_eur=0,
                    cp1_eur_per_mw=0,
                    cp2_eur_per_mw2=0)
pd.create_dcline(net,
                 from_bus=24,
                 to_bus=17,
Beispiel #5
0
def InitialCase():
    '''
    return: pandapower net
    '''
    # Reference Case Based on Case24
    net = pn.case24_ieee_rts()

    # replace
    pp.replace_ext_grid_by_gen(net)
    pp.replace_sgen_by_gen(net)
    # sort the gen
    net.gen = net.gen.sort_values(by=['bus', 'max_p_mw'])
    idx = net.poly_cost.index.to_list()  # idx after sorting
    element = net.poly_cost['element'].to_list()
    net.gen.loc[0, 'slack'] = True

    # modify Gen Parameter according bus order
    for i in range(net.gen.shape[0]):
        net.gen.iloc[i, 10] = Data.PMAX[i]
        net.gen.iloc[i, 11] = Data.PMIN[i]
        net.gen.iloc[i, 12] = Data.QMAX[i]
        net.gen.iloc[i, 13] = Data.QMIN[i]

    # adding a bus for DC line
    pp.create_bus(net,
                  vn_kv=230,
                  name='DCnode',
                  index=24,
                  max_vm_pu=1.05,
                  min_vm_pu=0.95)
    # adding a ext_grid as DC power
    pp.create_ext_grid(net,
                       bus=24,
                       vm_pu=1.05,
                       max_q_mvar=10,
                       min_q_mvar=0,
                       min_p_mw=0,
                       max_p_mw=1000,
                       slack=False)
    # adding cost of ext_grid
    pp.create_poly_cost(net,
                        element=0,
                        et='ext_grid',
                        cp0_eur=0,
                        cp1_eur_per_mw=0,
                        cp2_eur_per_mw2=0)

    # adding DC line
    pp.create_dcline(net,
                     from_bus=24,
                     to_bus=16,
                     p_mw=0,
                     loss_mw=5,
                     loss_percent=5,
                     vm_from_pu=1.05,
                     vm_to_pu=0.95,
                     name='DC1',
                     max_p_mw=400,
                     max_q_from_mvar=0,
                     min_q_from_mvar=0,
                     max_q_to_mvar=0,
                     min_q_to_mvar=0)

    # load
    net.load['controllable'] = True
    # load-sheeding cost and load constraints
    for i in range(net.load.shape[0]):
        net.load.loc[i, 'max_p_mw'] = net.load.loc[i, 'p_mw']
        net.load.loc[i, 'min_p_mw'] = 0
        net.load.loc[i, 'max_q_mvar'] = net.load.loc[i, 'q_mvar']
        net.load.loc[i, 'min_q_mvar'] = 0
        pp.create_poly_cost(net, i, et='load', cp1_eur_per_mw=-500)

    return net, idx, element