Home > matpower7.1 > lib > find_islands.m

find_islands

PURPOSE ^

FIND_ISLANDS Finds islands in a network

SYNOPSIS ^

function [groups, isolated] = find_islands(mpc)

DESCRIPTION ^

FIND_ISLANDS  Finds islands in a network
   GROUPS = FIND_ISLANDS(MPC)
   [GROUPS, ISOLATED] = FIND_ISLANDS(MPC)

   Returns the islands in a network. The return value GROUPS
   is a cell array of vectors of the bus indices for each island.
   The second and optional return value ISOLATED is a vector of
   indices of isolated buses that have no connecting branches.

   See also EXTRACT_ISLANDS, CONNECTED_COMPONENTS.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [groups, isolated] = find_islands(mpc)
0002 %FIND_ISLANDS  Finds islands in a network
0003 %   GROUPS = FIND_ISLANDS(MPC)
0004 %   [GROUPS, ISOLATED] = FIND_ISLANDS(MPC)
0005 %
0006 %   Returns the islands in a network. The return value GROUPS
0007 %   is a cell array of vectors of the bus indices for each island.
0008 %   The second and optional return value ISOLATED is a vector of
0009 %   indices of isolated buses that have no connecting branches.
0010 %
0011 %   See also EXTRACT_ISLANDS, CONNECTED_COMPONENTS.
0012 
0013 %   TODO: add handling of DC lines
0014 
0015 %   MATPOWER
0016 %   Copyright (c) 2012-2016, Power Systems Engineering Research Center (PSERC)
0017 %   by Ray Zimmerman, PSERC Cornell
0018 %
0019 %   This file is part of MATPOWER.
0020 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0021 %   See https://matpower.org for more info.
0022 
0023 %% define named indices into data matrices
0024 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0025     VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0026 [F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, RATE_C, ...
0027     TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST, ...
0028     ANGMIN, ANGMAX, MU_ANGMIN, MU_ANGMAX] = idx_brch;
0029 
0030 %% find islands
0031 nb  = size(mpc.bus, 1);     %% number of buses
0032 nl  = size(mpc.branch, 1);  %% number of branches
0033 
0034 e2i = sparse(mpc.bus(:, BUS_I), ones(nb, 1), 1:nb, max(mpc.bus(:, BUS_I)), 1);
0035 C_on = sparse(1:nl, e2i(mpc.branch(:, F_BUS)), -mpc.branch(:, BR_STATUS), nl, nb) + ...
0036        sparse(1:nl, e2i(mpc.branch(:, T_BUS)),  mpc.branch(:, BR_STATUS), nl, nb);
0037 
0038 if nnz(C_on)
0039     [groups, isolated] = connected_components(C_on);
0040 else
0041     groups = [];
0042     isolated = 1:nb;
0043 end

Generated on Fri 09-Oct-2020 11:21:31 by m2html © 2005