コード例 #1
0
def test_merge_asymmetric():
    """Test that merging nets properly handles bus IDs for asymmetric elements
    """
    net1 = nw.ieee_european_lv_asymmetric()
    net2 = nw.ieee_european_lv_asymmetric()
    n_load_busses = len(net1.asymmetric_load.bus.unique())
    n_sgen_busses = len(net1.asymmetric_sgen.bus.unique())
    net3 = pp.merge_nets(net1, net2)
    assert len(net3.asymmetric_load.bus.unique()) == 2 * n_load_busses
    assert len(net3.asymmetric_sgen.bus.unique()) == 2 * n_sgen_busses
コード例 #2
0
def simulate_network(scenario, installations_percent, cooperation_percent,
                     installation_buses, cooperating_buses, individual_buses):
    scenario_name = get_scenario_name(scenario)

    full_dir_path = "data/results/{}/03-simulation/{}_installations/{}_cooperative".format(
        scenario_name, installations_percent, cooperation_percent)

    if os.path.exists(full_dir_path) and SKIP_EXISTING:
        if PRINT_SKIPPING_LINES:
            print("[{}] [{}%] [{}%] Simulating network... [skipping]".format(
                scenario_name, installations_percent, cooperation_percent))
        return False

    print("[{}] [{}%] [{}%] Simulating network...".format(
        scenario_name, installations_percent, cooperation_percent))

    net = ieee_european_lv_asymmetric('on_peak_566')

    for index, _ in net.asymmetric_load.iterrows():
        net.asymmetric_load.in_service.at[index] = False

    pandapower.runpp(net)

    for original_index, row in buses.iterrows():
        load_index = pandapower.create_load(net, bus=row.bus, p_mw=0)
        load_profile_raw = pandas.read_csv(
            "data/source/load_profiles/Load_profile_{}.csv".format(
                original_index + 1),
            sep=",",
            decimal=".")
        load_profile_raw['mult'] = load_profile_raw['mult'].apply(
            convertkWToMW).iloc[::10].reset_index(drop=True)
        load_profile = frame_data.DFData(pandas.DataFrame(load_profile_raw))
        load_controller = ConstControl(net,
                                       element='load',
                                       element_index=load_index,
                                       variable='p_mw',
                                       data_source=load_profile,
                                       profile_name='mult',
                                       recycle=False)

    for original_index, row in installation_buses.iterrows():
        if scenario.get('EV') == True:
            ev_index = pandapower.create_load(net, bus=row.bus, p_mw=0)
            ev_profile_raw = pandas.read_csv(
                "data/source/ev_profiles/EV_home_profiles_{}.csv".format(
                    original_index + 1),
                sep=";",
                decimal=",")
            ev_profile_raw['load'] = ev_profile_raw['load'].apply(
                convert10minkWhTokW).apply(convertkWToMW)
            ev_profile = frame_data.DFData(pandas.DataFrame(ev_profile_raw))
            ev_controller = ConstControl(net,
                                         element='load',
                                         element_index=ev_index,
                                         variable='p_mw',
                                         data_source=ev_profile,
                                         profile_name='load',
                                         recycle=False)

        if scenario.get('PV') == True:
            sgen_index = pandapower.create_sgen(net,
                                                bus=row.bus,
                                                p_mw=0,
                                                sn_mva=0,
                                                type='PV')
            pv_profile_raw = pandas.read_csv("data/source/PVProfile1440.csv",
                                             sep=";",
                                             decimal=".")
            pv_profile_raw['pv_output_power_kw'] = pv_profile_raw[
                'pv_output_power_kw'].apply(
                    convertkWToMW).iloc[::10].reset_index(drop=True)
            pv_profile = frame_data.DFData(pandas.DataFrame(pv_profile_raw))
            sgen_controller = ConstControl(net,
                                           element='sgen',
                                           element_index=sgen_index,
                                           variable='p_mw',
                                           data_source=pv_profile,
                                           profile_name='pv_output_power_kw',
                                           recycle=False)

    for original_index, row in cooperating_buses.iterrows():
        storage_index = pandapower.create_storage(
            net,
            bus=row.bus,
            p_mw=0,
            max_e_mwh=BATTERY_ENERGY_MAX / 1000.0,
            soc_percent=(INITIAL_BATTERY_CHARGE / BATTERY_ENERGY_MAX) * 100.0,
            max_p_mw=RATED_P / 1000.0,
            min_p_mw=-RATED_P / 1000.0)
        storage_profile_raw = pandas.read_csv(
            "data/results/{}/02-collective/{}_installations/{}_cooperation/Storage_profile_{}.csv"
            .format(scenario_name, installations_percent, cooperation_percent,
                    original_index + 1),
            sep=",",
            decimal=".")
        storage_profile_raw['power_kW'] = storage_profile_raw[
            'power_kW'].apply(convertkWToMW).apply(convertStorage)
        storage_profile = frame_data.DFData(
            pandas.DataFrame(storage_profile_raw))
        storage_controller = ConstControl(net,
                                          element='storage',
                                          element_index=storage_index,
                                          variable='p_mw',
                                          data_source=storage_profile,
                                          profile_name='power_kW',
                                          recycle=False)

    for original_index, row in individual_buses.iterrows():
        storage_index = pandapower.create_storage(
            net,
            bus=row.bus,
            p_mw=0,
            max_e_mwh=BATTERY_ENERGY_MAX / 1000.0,
            soc_percent=(INITIAL_BATTERY_CHARGE / BATTERY_ENERGY_MAX) * 100.0,
            max_p_mw=RATED_P / 1000.0,
            min_p_mw=-RATED_P / 1000.0)
        storage_profile_raw = pandas.read_csv(
            "data/results/{}/01-individual/storage-profiles/Storage_profile_{}.csv"
            .format(scenario_name, original_index + 1),
            sep=",",
            decimal=".")
        storage_profile_raw['power_kW'] = storage_profile_raw[
            'power_kW'].apply(convertkWToMW).apply(convertStorage)
        storage_profile = frame_data.DFData(
            pandas.DataFrame(storage_profile_raw))
        storage_controller = ConstControl(net,
                                          element='storage',
                                          element_index=storage_index,
                                          variable='p_mw',
                                          data_source=storage_profile,
                                          profile_name='power_kW',
                                          recycle=False)

    time_steps = range(0, T)

    ow = OutputWriter(net,
                      output_path=full_dir_path,
                      output_file_type=".csv",
                      log_variables=[])

    ow.log_variable("load", "p_mw")
    ow.log_variable("res_bus", "vm_pu", index=buses_nodes)
    ow.log_variable("res_line", "p_to_mw", index=line_nodes)
    ow.log_variable("res_trafo", "vm_lv_pu")
    ow.log_variable("res_trafo", "p_lv_mw")

    if scenario.get('PV') == True:
        ow.log_variable("sgen", "p_mw")

    if cooperating_buses.size > 0 or individual_buses.size > 0:
        ow.log_variable("storage", "p_mw")

    run_timeseries(net, time_steps, continue_on_divergence=True, verbose=False)

    return True
コード例 #3
0
# SKIP_EXISTING = False
# PRINT_SKIPPING_LINES = False
# DER_INSTALLATIONS_PERCENT_STEP = 50
# DER_COOPERATION_PERCENT_STEP = 50
# BUS_LIMIT = 5

T = 144
INTERVAL_LENGTH = 1.0 / 6.0  # hours (1/6 hour = 10 minutes)
BATTERY_ENERGY_MAX = 7.7  # kWh
RATED_P = 3.0  # kW
INITIAL_BATTERY_CHARGE = 3.85  # kWh
CHARGE_EFFICIENCY = 0.92
DISCHARGE_EFFICIENCY = 0.92

net_structure = ieee_european_lv_asymmetric('on_peak_566')

buses = pandas.read_csv('data/source/buses.csv', sep=";",
                        decimal=',')[:BUS_LIMIT]
buses_nodes = buses['bus'].tolist()

line_nodes = []

print("Obtaining line indices...")

for _, bus in buses.iterrows():
    for line_index, line in net_structure.line.iterrows():
        if bus.bus == line.to_bus:
            line_nodes.append(line_index)

コード例 #4
0
import pandas as pd
import pandapower as pp
import pandapower.timeseries.data_sources.frame_data as fd
from pandapower.control import ConstControl
from pandapower.networks import ieee_european_lv_asymmetric
from pandapower.timeseries.run_time_series import run_timeseries
from pandapower.timeseries import OutputWriter
import matplotlib.pyplot as plt
import pandapower.control.basic_controller as basic_controller
import numpy

# initialize a network

net = ieee_european_lv_asymmetric('on_peak_566')

# turn off asymmetric loads

for index, _ in net.asymmetric_load.iterrows():
    net.asymmetric_load.in_service.at[index] = False

# power flow run

pp.runpp(net)

# load consumer bus indices

consumer_bus_indices = pd.read_csv('buses.csv', sep=";")

# function of kW to MW convertation