Exemplo n.º 1
0
def add_loads_to_topology(AMB_network):
    Existing_sub_nodes = ld.get_existing_subnodes()
    historical_loads = ld.get_historical_loads()
    Simp_nodes_dict = ld.get_nodes_to_subnodes()
    Simp_nodes_dict["MAN"] = ["MAN2201"]
    Existing_sub_nodes.append("MAN2201")
    nodes_to_index = pd.read_csv(stored_path.main_path + '/data/ABM/ABM_Nodes.csv')
    for i, node in enumerate(AMB_network.names_2_nodes.keys()):
        # print("Load added at node : " + node)
        index = nodes_to_index[nodes_to_index["Node names"] == node]["Node index"].values[0]
        load = Load(node, node, index, type="real_load")
        load.add_load_data(historical_loads, Simp_nodes_dict, Existing_sub_nodes)
        AMB_network.add_load(load)
    return AMB_network
Exemplo n.º 2
0
def launch_model():
    AMB_network = top(network="ABM")
    """
    Create loads on each node
    """
    Existing_sub_nodes = ld.get_existing_subnodes()
    historical_loads = ld.get_historical_loads()
    Simp_nodes_dict = ld.get_nodes_to_subnodes()
    Simp_nodes_dict["MAN"] = ["MAN2201"]
    Existing_sub_nodes.append("MAN2201")
    nodes_to_index = pd.read_csv(stored_path.main_path +
                                 '/data/ABM/ABM_Nodes.csv')
    for i, node in enumerate(AMB_network.names_2_nodes.keys()):
        # print("Load added at node : " + node)
        index = nodes_to_index[nodes_to_index["Node names"] ==
                               node]["Node index"].values[0]
        load = Load(node, node, index, type="real_load")
        load.add_load_data(historical_loads, Simp_nodes_dict,
                           Existing_sub_nodes)
        AMB_network.add_load(load)

    file_path = stored_path.main_path + '/data/generators/generator_adjacency_matrix_dict1.json'
    with open(file_path) as f:
        data = json.loads(f.read())

    number_of_added_generators = 0
    for name_generator in data.keys():
        L_ = data[name_generator]
        try:
            if type(L_[0]) != float:
                if not math.isnan(L_[-2]):
                    if L_[-1] == "Gas" or L_[-1] == "Biogas":
                        add = 35
                    if L_[-1] == "Geothermal":
                        add = 10
                    if L_[-1] == "Coal":
                        add = 50
                    if L_[-1] == "Diesel":
                        add = 150

                    if L_[-1] == 'Hydro':
                        P_min = 0.1 * L_[-2]
                    else:
                        P_min = 0

                    g = Generator(name_generator,
                                  L_[0],
                                  0,
                                  L_[-1],
                                  Pmax=L_[-2],
                                  Pmin=P_min,
                                  marginal_cost=add + np.array(L_[1]))
                    AMB_network.add_generator(g)
                    number_of_added_generators += 1
        except:
            pass

    node_name = "MDN"
    # index = 10
    AMB_network.add_generator(
        Generator("diesel_gen",
                  node_name,
                  0,
                  0,
                  Pmax=200,
                  Pmin=0,
                  marginal_cost=[0, 0]))
    # AMB_network.generators[10]
    """
    get d_t for day 12 and trading period 1
    """
    Horizon_T = 48
    day = 2
    d = []
    for k, node in enumerate(AMB_network.loads.keys()):
        d.append([])
        for j in range(day * 48, day * 48 + Horizon_T):
            d[k].append(
                1 * 1000 *
                AMB_network.loads[node][0].return_d(1 + j // 48, j % 48 + 1))

    # d[1] = d[1]*2
    d = np.array(d)
    # # d[1] = d[1]*10
    #
    # import matplotlib.pyplot as plt
    # plt.plot(sum(d))
    # plt.show()
    #
    # sum(d[:,0])
    # d = np.zeros((d.shape[0], Horizon_T))
    # d = P_min
    """
    Add topology specific characteristics
    """
    n_generator = AMB_network.get_number_of_gen()
    b = np.zeros((n_generator, Horizon_T))
    P_max = np.zeros((n_generator, Horizon_T))
    P_min = np.zeros((n_generator, Horizon_T))
    for node in AMB_network.generators.keys():
        for g in AMB_network.generators[node]:
            for i, j in enumerate(range(day * 48, day * 48 + Horizon_T)):
                if g.name == "diesel_gen":
                    pmax, pmin, a = 500, 0, 200
                else:
                    pmax, pmin, a = LMP.get_P_min_a(g.name, 1 + j // 48,
                                                    j % 48 + 1, g.type)
                P_max[g.index, i] = pmax
                P_min[g.index, i] = pmin if g.type == "Hydro" else 0
                b[g.index, i] = a if a > 0 else np.random.randint(0, 100)

    print("Loading data done")

    list_of_generator = {}
    for node in AMB_network.generators.keys():
        for g in AMB_network.generators[node]:
            list_of_generator[g.index] = g
    new_dict = {}
    for key in sorted(list_of_generator.keys()):
        new_dict[key] = list_of_generator[key]

    H, h = AMB_network.H, AMB_network.h
    Mn = AMB_network.Mn
    save = d[10].copy()
    save_d = d.copy()
    d[10] = save
    d = 1.3 * save_d.copy()
    d[10] = save * 12.1
    cost_of_battery = 200 * 1000 / (2 * 365)
    model = run_program(d,
                        b,
                        P_max,
                        P_min,
                        H,
                        h,
                        Mn,
                        i_battery=None,
                        z_start=1,
                        cost_of_battery=cost_of_battery)

    beta = np.array([[pyo.value(model.beta[t, i]) for i in range(Horizon_T)]
                     for t in range(H.shape[0])])
    save_results(model, i_test=4)

    print("\n___ OBJ ____")
    print(pyo.value(model.obj))
Exemplo n.º 3
0
    import lmpnz.Network.PriceBids.Load.Load as ld
    from lmpnz.Network.PriceBids.Generator.Generator import Generator
    from lmpnz.Network.PriceBids.Load.Load import Load
    from lmpnz.GuillaumeExample import LMP
    import pandas as pd
    import stored_path
    import json
    import math

    AMB_network = top(network="ABM")
    """
    Create loads on each node
    """
    Existing_sub_nodes = ld.get_existing_subnodes()
    historical_loads = ld.get_historical_loads()
    Simp_nodes_dict = ld.get_nodes_to_subnodes()
    Simp_nodes_dict["MAN"] = ["MAN2201"]
    Existing_sub_nodes.append("MAN2201")
    nodes_to_index = pd.read_csv(stored_path.main_path +
                                 '/data/ABM/ABM_Nodes.csv')
    for i, node in enumerate(AMB_network.names_2_nodes.keys()):
        # print("Load added at node : " + node)
        index = nodes_to_index[nodes_to_index["Node names"] ==
                               node]["Node index"].values[0]
        load = Load(node, node, index, type="real_load")
        load.add_load_data(historical_loads, Simp_nodes_dict,
                           Existing_sub_nodes)
        AMB_network.add_load(load)

    file_path = stored_path.main_path + '/data/generators/generator_adjacency_matrix_dict.json'
    with open(file_path) as f: