Пример #1
0
def get_connectivity(file_name):

    circuit = MultiCircuit()
    circuit.load_file(file_name)
    circuit.compile()

    # form C
    threshold = 1e-5
    m = len(circuit.branches)
    n = len(circuit.buses)
    C = lil_matrix((m, n), dtype=int)
    buses_dict = {bus: i for i, bus in enumerate(circuit.buses)}
    branches_to_keep_idx = list()
    branches_to_remove_idx = list()
    states = np.zeros(m, dtype=int)
    br_idx = [None] * m

    graph = Graph()

    for i in range(len(circuit.branches)):
        # get the from and to bus indices
        f = buses_dict[circuit.branches[i].bus_from]
        t = buses_dict[circuit.branches[i].bus_to]
        graph.add_edge(f, t)
        C[i, f] = 1
        C[i, t] = -1
        br_idx[i] = i
        rx = circuit.branches[i].R + circuit.branches[i].X

        if circuit.branches[i].branch_type == BranchType.Branch:
            branches_to_remove_idx.append(i)
            states[i] = 0
        else:
            branches_to_keep_idx.append(i)
            states[i] = 1

    C = csc_matrix(C)

    return circuit, states, C, C.transpose() * C, graph
Пример #2
0
    """
    Get the indices of the branches connected to the bus j
    :param B: Branch-bus CSC matrix
    :param j: bus index
    :return: list of branches in the bus
    """
    return [B.indices[k] for k in range(B.indptr[j], B.indptr[j + 1])]


if __name__ == '__main__':

    fname = 'D:\\GitHub\\GridCal\\Grids_and_profiles\\grids\\Reduction Model 2.xlsx'

    circuit = MultiCircuit()
    circuit.load_file(fname)
    circuit.compile()

    # form C
    threshold = 1e-5
    m = len(circuit.branches)
    n = len(circuit.buses)
    C = lil_matrix((m, n), dtype=int)
    buses_dict = {bus: i for i, bus in enumerate(circuit.buses)}
    branches_to_keep_idx = list()
    branches_to_remove_idx = list()
    states = np.zeros(m, dtype=int)
    br_idx = [None] * m

    graph = Graph()

    for i in range(len(circuit.branches)):
Пример #3
0
if __name__ == '__main__':
    from GridCal.Engine.calculation_engine import MultiCircuit, PowerFlowOptions, PowerFlow, SolverType
    from matplotlib import pyplot as plt

    grid = MultiCircuit()
    # grid.load_file('lynn5buspq.xlsx')
    # grid.load_file('lynn5buspv.xlsx')
    # grid.load_file('IEEE30.xlsx')
    grid.load_file(
        '/home/santi/Documentos/GitHub/GridCal/Grids_and_profiles/grids/IEEE 14.xlsx'
    )
    # grid.load_file('/home/santi/Documentos/GitHub/GridCal/Grids_and_profiles/grids/IEEE39.xlsx')
    # grid.load_file('/home/santi/Documentos/GitHub/GridCal/Grids_and_profiles/grids/1354 Pegase.xlsx')

    grid.compile()

    circuit = grid.circuits[0]

    print('\nYbus:\n', circuit.power_flow_input.Ybus.todense())
    print('\nSbus:\n', circuit.power_flow_input.Sbus)
    print('\nIbus:\n', circuit.power_flow_input.Ibus)
    print('\nVbus:\n', circuit.power_flow_input.Vbus)
    print('\ntypes:\n', circuit.power_flow_input.types)
    print('\npq:\n', circuit.power_flow_input.pq)
    print('\npv:\n', circuit.power_flow_input.pv)
    print('\nvd:\n', circuit.power_flow_input.ref)

    start_time = time.time()

    # Y, Ys, Ysh, max_coefficient_count, S, voltage_set_points, pq, pv, vd