How to use the pandapower.create_switch function in pandapower

To help you get started, we’ve selected a few pandapower examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github e2nIEE / pandapower / pandapower / networks / cigre_networks.py View on Github external
pp.create_load(net_cigre_lv, busR16, p_mw=0.05225, q_mvar=0.017173744, name='Load R16')
    pp.create_load(net_cigre_lv, busR17, p_mw=0.03325, q_mvar=0.010928746, name='Load R17')
    pp.create_load(net_cigre_lv, busR18, p_mw=0.04465, q_mvar=0.014675745, name='Load R18')
    pp.create_load(net_cigre_lv, busI2, p_mw=0.0850, q_mvar=0.052678269, name='Load I2')
    pp.create_load(net_cigre_lv, busC1, p_mw=0.1080, q_mvar=0.052306787, name='Load C1')
    pp.create_load(net_cigre_lv, busC12, p_mw=0.018, q_mvar=0.008717798, name='Load C12')
    pp.create_load(net_cigre_lv, busC13, p_mw=0.018, q_mvar=0.008717798, name='Load C13')
    pp.create_load(net_cigre_lv, busC14, p_mw=0.0225, q_mvar=0.010897247, name='Load C14')
    pp.create_load(net_cigre_lv, busC17, p_mw=0.0225, q_mvar=0.010897247, name='Load C17')
    pp.create_load(net_cigre_lv, busC18, p_mw=0.0072, q_mvar=0.003487119, name='Load C18')
    pp.create_load(net_cigre_lv, busC19, p_mw=0.0144, q_mvar=0.006974238, name='Load C19')
    pp.create_load(net_cigre_lv, busC20, p_mw=0.0072, q_mvar=0.003487119, name='Load C20')

    # Switches
    pp.create_switch(net_cigre_lv, bus0, busR0, et='b', closed=True, type='CB', name='S1')
    pp.create_switch(net_cigre_lv, bus0, busI0, et='b', closed=True, type='CB', name='S2')
    pp.create_switch(net_cigre_lv, bus0, busC0, et='b', closed=True, type='CB', name='S3')

    # Bus geo data
    net_cigre_lv.bus_geodata = read_json(
        """{"x":{"0":0.2,"1":0.2,"2":-1.4583333333,"3":-1.4583333333,"4":-1.4583333333,
        "5":-1.9583333333,"6":-2.7083333333,"7":-2.7083333333,"8":-3.2083333333,"9":-3.2083333333,
        "10":-3.2083333333,"11":-3.7083333333,"12":-0.9583333333,"13":-1.2083333333,
        "14":-1.2083333333,"15":-1.2083333333,"16":-1.2083333333,"17":-2.2083333333,
        "18":-2.7083333333,"19":-3.7083333333,"20":0.2,"21":0.2,"22":0.2,"23":0.2,"24":1.9166666667,
        "25":1.9166666667,"26":1.9166666667,"27":0.5416666667,"28":0.5416666667,"29":-0.2083333333,
        "30":-0.2083333333,"31":-0.2083333333,"32":-0.7083333333,"33":3.2916666667,
        "34":2.7916666667,"35":2.2916666667,"36":3.2916666667,"37":3.7916666667,"38":1.2916666667,
        "39":0.7916666667,"40":1.7916666667,"41":0.7916666667,"42":0.2916666667,"43":-0.7083333333},
        "y":{"0":1.0,"1":1.0,"2":2.0,"3":3.0,"4":4.0,"5":5.0,"6":6.0,"7":7.0,"8":8.0,"9":9.0,
        "10":10.0,"11":11.0,"12":5.0,"13":6.0,"14":7.0,"15":8.0,"16":9.0,"17":8.0,"18":11.0,
        "19":12.0,"20":1.0,"21":2.0,"22":3.0,"23":1.0,"24":2.0,"25":3.0,"26":4.0,"27":5.0,"28":6.0,
github e2nIEE / pandapower / pandapower / networks / cigre_networks.py View on Github external
# Trafos
    trafo0 = pp.create_transformer_from_parameters(net_cigre_mv, bus0, buses[0], sn_mva=25,
                                                   vn_hv_kv=110, vn_lv_kv=20, vscr_percent=0.16,
                                                   vsc_percent=12.00107, pfe_mw=0, i0_percent=0,
                                                   shift_degree=30.0, name='Trafo 0-1')
    trafo1 = pp.create_transformer_from_parameters(net_cigre_mv, bus0, buses[11], sn_mva=25,
                                                   vn_hv_kv=110, vn_lv_kv=20, vscr_percent=0.16,
                                                   vsc_percent=12.00107, pfe_mw=0, i0_percent=0,
                                                   shift_degree=30.0, name='Trafo 0-12')

    # Switches
    # S2
    pp.create_switch(net_cigre_mv, buses[5], line6_7, et='l', closed=True, type='LBS')
    pp.create_switch(net_cigre_mv, buses[6], line6_7, et='l', closed=False, type='LBS', name='S2')
    # S3
    pp.create_switch(net_cigre_mv, buses[3], line4_11, et='l', closed=False, type='LBS', name='S3')
    pp.create_switch(net_cigre_mv, buses[10], line4_11, et='l', closed=True, type='LBS')
    # S1
    pp.create_switch(net_cigre_mv, buses[7], line8_14, et='l', closed=False, type='LBS', name='S1')
    pp.create_switch(net_cigre_mv, buses[13], line8_14, et='l', closed=True, type='LBS')
    # trafos
    pp.create_switch(net_cigre_mv, bus0, trafo0, et='t', closed=True, type='CB')
    pp.create_switch(net_cigre_mv, bus0, trafo1, et='t', closed=True, type='CB')

    # Loads
    # Residential
    pp.create_load_from_cosphi(net_cigre_mv, buses[0], 15.3, 0.98, "ind", name='Load R1')
    pp.create_load_from_cosphi(net_cigre_mv, buses[2], 0.285, 0.97, "ind", name='Load R3')
    pp.create_load_from_cosphi(net_cigre_mv, buses[3], 0.445, 0.97, "ind", name='Load R4')
    pp.create_load_from_cosphi(net_cigre_mv, buses[4], 0.750, 0.97, "ind", name='Load R5')
    pp.create_load_from_cosphi(net_cigre_mv, buses[5], 0.565, 0.97, "ind", name='Load R6')
    pp.create_load_from_cosphi(net_cigre_mv, buses[7], 0.605, 0.97, "ind", name='Load R8')
github e2nIEE / pandapower / pandapower / networks / cigre_networks.py View on Github external
shift_degree=30.0, name='Trafo 0-1')
    trafo1 = pp.create_transformer_from_parameters(net_cigre_mv, bus0, buses[11], sn_mva=25,
                                                   vn_hv_kv=110, vn_lv_kv=20, vscr_percent=0.16,
                                                   vsc_percent=12.00107, pfe_mw=0, i0_percent=0,
                                                   shift_degree=30.0, name='Trafo 0-12')

    # Switches
    # S2
    pp.create_switch(net_cigre_mv, buses[5], line6_7, et='l', closed=True, type='LBS')
    pp.create_switch(net_cigre_mv, buses[6], line6_7, et='l', closed=False, type='LBS', name='S2')
    # S3
    pp.create_switch(net_cigre_mv, buses[3], line4_11, et='l', closed=False, type='LBS', name='S3')
    pp.create_switch(net_cigre_mv, buses[10], line4_11, et='l', closed=True, type='LBS')
    # S1
    pp.create_switch(net_cigre_mv, buses[7], line8_14, et='l', closed=False, type='LBS', name='S1')
    pp.create_switch(net_cigre_mv, buses[13], line8_14, et='l', closed=True, type='LBS')
    # trafos
    pp.create_switch(net_cigre_mv, bus0, trafo0, et='t', closed=True, type='CB')
    pp.create_switch(net_cigre_mv, bus0, trafo1, et='t', closed=True, type='CB')

    # Loads
    # Residential
    pp.create_load_from_cosphi(net_cigre_mv, buses[0], 15.3, 0.98, "ind", name='Load R1')
    pp.create_load_from_cosphi(net_cigre_mv, buses[2], 0.285, 0.97, "ind", name='Load R3')
    pp.create_load_from_cosphi(net_cigre_mv, buses[3], 0.445, 0.97, "ind", name='Load R4')
    pp.create_load_from_cosphi(net_cigre_mv, buses[4], 0.750, 0.97, "ind", name='Load R5')
    pp.create_load_from_cosphi(net_cigre_mv, buses[5], 0.565, 0.97, "ind", name='Load R6')
    pp.create_load_from_cosphi(net_cigre_mv, buses[7], 0.605, 0.97, "ind", name='Load R8')
    pp.create_load_from_cosphi(net_cigre_mv, buses[9], 0.490, 0.97, "ind", name='Load R10')
    pp.create_load_from_cosphi(net_cigre_mv, buses[10], 0.340, 0.97, "ind", name='Load R11')
    pp.create_load_from_cosphi(net_cigre_mv, buses[11], 15.3, 0.98, "ind", name='Load R12')
    pp.create_load_from_cosphi(net_cigre_mv, buses[13], 0.215, 0.97, "ind", name='Load R14')
github e2nIEE / pandapower / pandapower / networks / create_example_simple.py View on Github external
line2 = pp.create_line(net, bus5, bus6, 0.075, std_type="NA2XS2Y 1x240 RM/25 12/20 kV",
                           name="Line 2")
    line3 = pp.create_line(net, bus5, bus7, 0.125, std_type="NA2XS2Y 1x240 RM/25 12/20 kV",
                           name="Line 3")
    line4 = pp.create_line(net, bus5, bus8, 0.175, std_type="NA2XS2Y 1x240 RM/25 12/20 kV",
                           name="Line 4")

    # create switches
    # (Circuit breaker)
    pp.create_switch(net, bus2, bus3, et="b", type="CB")
    pp.create_switch(net, bus4, bus5, et="b", type="CB")
    # (Load break switches)
    pp.create_switch(net, bus5, line2, et="l", type="LBS")
    pp.create_switch(net, bus6, line2, et="l", type="LBS")
    pp.create_switch(net, bus5, line3, et="l", type="LBS")
    pp.create_switch(net, bus7, line3, et="l", type="LBS")
    pp.create_switch(net, bus5, line4, et="l", type="LBS")
    pp.create_switch(net, bus8, line4, et="l", type="LBS")

    # create generator
    pp.create_gen(net, bus6, p_kw=-6000, vm_pu=1.05)

    # create static generator
    pp.create_sgen(net, bus7, p_kw=-2000)

    # Last mit 20MV bei scaling 0.6 ~ 12MV -> Industrie / Verbaucher am MS Netz
    # create load
    pp.create_load(net, bus8, p_kw=20000, q_kvar=4000, scaling=0.6)

    # create shunt
    pp.create_shunt(net, bus3, p_kw=0, q_kvar=-960, name='Shunt')
github e2nIEE / pandapower / pandapower / networks / create_examples.py View on Github external
# Bus-Line switches
    hv_buses = net.bus[(net.bus.vn_kv == 380) | (net.bus.vn_kv == 110)].index
    hv_ls = net.line[(net.line.from_bus.isin(hv_buses)) & (net.line.to_bus.isin(hv_buses))]
    for _, line in hv_ls.iterrows():
        for bus in [line.from_bus, line.to_bus]:
            pp.create_switch(net, bus, line.name, et='l', closed=True, type='LBS',
                             name='Switch %s - %s' % (net.bus.name.at[bus], line['name']))

    # MV
    # Bus-line switches
    mv_buses = net.bus[(net.bus.vn_kv == 10) | (net.bus.vn_kv == 20)].index
    mv_ls = net.line[(net.line.from_bus.isin(mv_buses)) & (net.line.to_bus.isin(mv_buses))]
    for _, line in mv_ls.iterrows():
        for bus in [line.from_bus, line.to_bus]:
            pp.create_switch(net, bus, line.name, et='l', closed=True, type='LBS',
                             name='Switch %s - %s' % (net.bus.name.at[bus], line['name']))

    open_switch_id = net.switch[(net.switch.name == 'Switch Bus MV5 - MV Line5')].index
    net.switch.closed.loc[open_switch_id] = False

    # LV
    # Bus-line switches
    lv_buses = net.bus[net.bus.vn_kv == 0.4].index
    lv_ls = net.line[(net.line.from_bus.isin(lv_buses)) & (net.line.to_bus.isin(lv_buses))]
    for _, line in lv_ls.iterrows():
        for bus in [line.from_bus, line.to_bus]:
            pp.create_switch(net, bus, line.name, et='l', closed=True, type='LBS',
                             name='Switch %s - %s' % (net.bus.name.at[bus], line['name']))

    # Trafoswitches
    # HV
github e2nIEE / pandapower / pandapower / diagnostic.py View on Github external
# checks if loadflow converges when implausible lines or impedances are replaced by switches
    if ("line" in implausible_elements) or ("impedance" in implausible_elements):
        switch_copy = copy.deepcopy(net.switch)
        line_copy = copy.deepcopy(net.line)
        impedance_copy = copy.deepcopy(net.impedance)
        try:
            runpp(net)
        except:
            try:
                for key in implausible_elements:
                    if key == 'xward':
                        continue
                    implausible_idx = implausible_elements[key]
                    net[key].in_service.loc[implausible_idx] = False
                    for idx in implausible_idx:
                        pp.create_switch(net, net[key].from_bus.at[idx], net[key].to_bus.at[idx], et="b")
                runpp(net)
                switch_replacement = True
            except:
                switch_replacement = False
            check_results.append({"loadflow_converges_with_switch_replacement": switch_replacement})
        net.switch = switch_copy
        net.line = line_copy
        net.impedance = impedance_copy
    if implausible_elements:
        return check_results
github e2nIEE / pandapower / pandapower / networks / create_examples.py View on Github external
open_switch_id = net.switch[(net.switch.name == 'Switch Bus MV5 - MV Line5')].index
    net.switch.closed.loc[open_switch_id] = False

    # LV
    # Bus-line switches
    lv_buses = net.bus[net.bus.vn_kv == 0.4].index
    lv_ls = net.line[(net.line.from_bus.isin(lv_buses)) & (net.line.to_bus.isin(lv_buses))]
    for _, line in lv_ls.iterrows():
        for bus in [line.from_bus, line.to_bus]:
            pp.create_switch(net, bus, line.name, et='l', closed=True, type='LBS',
                             name='Switch %s - %s' % (net.bus.name.at[bus], line['name']))

    # Trafoswitches
    # HV
    pp.create_switch(net, pp.get_element_index(net, "bus", 'Bus DB 2'),
                     pp.get_element_index(net, "trafo", 'EHV-HV-Trafo'), et='t', closed=True,
                     type='LBS', name='Switch DB2 - EHV-HV-Trafo')
    pp.create_switch(net, pp.get_element_index(net, "bus", 'Bus SB 1'),
                     pp.get_element_index(net, "trafo", 'EHV-HV-Trafo'), et='t', closed=True,
                     type='LBS', name='Switch SB1 - EHV-HV-Trafo')
    # LV
    pp.create_switch(net, pp.get_element_index(net, "bus", 'Bus MV4'),
                     pp.get_element_index(net, "trafo", 'MV-LV-Trafo'), et='t', closed=True,
                     type='LBS', name='Switch MV4 - MV-LV-Trafo')
    pp.create_switch(net, pp.get_element_index(net, "bus", 'Bus LV0'),
                     pp.get_element_index(net, "trafo", 'MV-LV-Trafo'), et='t', closed=True,
                     type='LBS', name='Switch LV0 - MV-LV-Trafo')

    # --- Powerflow

    # run power flow and generate result tables
github e2nIEE / pandapower / pandapower / networks / create_example_simple.py View on Github external
name="Line 1")
    line2 = pp.create_line(net, bus5, bus6, 0.075, std_type="NA2XS2Y 1x240 RM/25 12/20 kV",
                           name="Line 2")
    line3 = pp.create_line(net, bus5, bus7, 0.125, std_type="NA2XS2Y 1x240 RM/25 12/20 kV",
                           name="Line 3")
    line4 = pp.create_line(net, bus5, bus8, 0.175, std_type="NA2XS2Y 1x240 RM/25 12/20 kV",
                           name="Line 4")

    # create switches
    # (Circuit breaker)
    pp.create_switch(net, bus2, bus3, et="b", type="CB")
    pp.create_switch(net, bus4, bus5, et="b", type="CB")
    # (Load break switches)
    pp.create_switch(net, bus5, line2, et="l", type="LBS")
    pp.create_switch(net, bus6, line2, et="l", type="LBS")
    pp.create_switch(net, bus5, line3, et="l", type="LBS")
    pp.create_switch(net, bus7, line3, et="l", type="LBS")
    pp.create_switch(net, bus5, line4, et="l", type="LBS")
    pp.create_switch(net, bus8, line4, et="l", type="LBS")

    # create generator
    pp.create_gen(net, bus6, p_kw=-6000, vm_pu=1.05)

    # create static generator
    pp.create_sgen(net, bus7, p_kw=-2000)

    # Last mit 20MV bei scaling 0.6 ~ 12MV -> Industrie / Verbaucher am MS Netz
    # create load
    pp.create_load(net, bus8, p_kw=20000, q_kvar=4000, scaling=0.6)

    # create shunt
    pp.create_shunt(net, bus3, p_kw=0, q_kvar=-960, name='Shunt')
github e2nIEE / pandapower / pandapower / networks / cigre_networks.py View on Github external
trafo0 = pp.create_transformer_from_parameters(net_cigre_mv, bus0, buses[0], sn_mva=25,
                                                   vn_hv_kv=110, vn_lv_kv=20, vscr_percent=0.16,
                                                   vsc_percent=12.00107, pfe_mw=0, i0_percent=0,
                                                   shift_degree=30.0, name='Trafo 0-1')
    trafo1 = pp.create_transformer_from_parameters(net_cigre_mv, bus0, buses[11], sn_mva=25,
                                                   vn_hv_kv=110, vn_lv_kv=20, vscr_percent=0.16,
                                                   vsc_percent=12.00107, pfe_mw=0, i0_percent=0,
                                                   shift_degree=30.0, name='Trafo 0-12')

    # Switches
    # S2
    pp.create_switch(net_cigre_mv, buses[5], line6_7, et='l', closed=True, type='LBS')
    pp.create_switch(net_cigre_mv, buses[6], line6_7, et='l', closed=False, type='LBS', name='S2')
    # S3
    pp.create_switch(net_cigre_mv, buses[3], line4_11, et='l', closed=False, type='LBS', name='S3')
    pp.create_switch(net_cigre_mv, buses[10], line4_11, et='l', closed=True, type='LBS')
    # S1
    pp.create_switch(net_cigre_mv, buses[7], line8_14, et='l', closed=False, type='LBS', name='S1')
    pp.create_switch(net_cigre_mv, buses[13], line8_14, et='l', closed=True, type='LBS')
    # trafos
    pp.create_switch(net_cigre_mv, bus0, trafo0, et='t', closed=True, type='CB')
    pp.create_switch(net_cigre_mv, bus0, trafo1, et='t', closed=True, type='CB')

    # Loads
    # Residential
    pp.create_load_from_cosphi(net_cigre_mv, buses[0], 15.3, 0.98, "ind", name='Load R1')
    pp.create_load_from_cosphi(net_cigre_mv, buses[2], 0.285, 0.97, "ind", name='Load R3')
    pp.create_load_from_cosphi(net_cigre_mv, buses[3], 0.445, 0.97, "ind", name='Load R4')
    pp.create_load_from_cosphi(net_cigre_mv, buses[4], 0.750, 0.97, "ind", name='Load R5')
    pp.create_load_from_cosphi(net_cigre_mv, buses[5], 0.565, 0.97, "ind", name='Load R6')
    pp.create_load_from_cosphi(net_cigre_mv, buses[7], 0.605, 0.97, "ind", name='Load R8')
    pp.create_load_from_cosphi(net_cigre_mv, buses[9], 0.490, 0.97, "ind", name='Load R10')
github e2nIEE / pandapower / pandapower / networks / cigre_networks.py View on Github external
vsc_percent=12.00107, pfe_mw=0, i0_percent=0,
                                                   shift_degree=30.0, name='Trafo 0-1')
    trafo1 = pp.create_transformer_from_parameters(net_cigre_mv, bus0, buses[11], sn_mva=25,
                                                   vn_hv_kv=110, vn_lv_kv=20, vscr_percent=0.16,
                                                   vsc_percent=12.00107, pfe_mw=0, i0_percent=0,
                                                   shift_degree=30.0, name='Trafo 0-12')

    # Switches
    # S2
    pp.create_switch(net_cigre_mv, buses[5], line6_7, et='l', closed=True, type='LBS')
    pp.create_switch(net_cigre_mv, buses[6], line6_7, et='l', closed=False, type='LBS', name='S2')
    # S3
    pp.create_switch(net_cigre_mv, buses[3], line4_11, et='l', closed=False, type='LBS', name='S3')
    pp.create_switch(net_cigre_mv, buses[10], line4_11, et='l', closed=True, type='LBS')
    # S1
    pp.create_switch(net_cigre_mv, buses[7], line8_14, et='l', closed=False, type='LBS', name='S1')
    pp.create_switch(net_cigre_mv, buses[13], line8_14, et='l', closed=True, type='LBS')
    # trafos
    pp.create_switch(net_cigre_mv, bus0, trafo0, et='t', closed=True, type='CB')
    pp.create_switch(net_cigre_mv, bus0, trafo1, et='t', closed=True, type='CB')

    # Loads
    # Residential
    pp.create_load_from_cosphi(net_cigre_mv, buses[0], 15.3, 0.98, "ind", name='Load R1')
    pp.create_load_from_cosphi(net_cigre_mv, buses[2], 0.285, 0.97, "ind", name='Load R3')
    pp.create_load_from_cosphi(net_cigre_mv, buses[3], 0.445, 0.97, "ind", name='Load R4')
    pp.create_load_from_cosphi(net_cigre_mv, buses[4], 0.750, 0.97, "ind", name='Load R5')
    pp.create_load_from_cosphi(net_cigre_mv, buses[5], 0.565, 0.97, "ind", name='Load R6')
    pp.create_load_from_cosphi(net_cigre_mv, buses[7], 0.605, 0.97, "ind", name='Load R8')
    pp.create_load_from_cosphi(net_cigre_mv, buses[9], 0.490, 0.97, "ind", name='Load R10')
    pp.create_load_from_cosphi(net_cigre_mv, buses[10], 0.340, 0.97, "ind", name='Load R11')
    pp.create_load_from_cosphi(net_cigre_mv, buses[11], 15.3, 0.98, "ind", name='Load R12')