Home > matpower5.1 > extras > sdp_pf > makeIncidence.m

makeIncidence

PURPOSE ^

MAKEINCIDENCE Builds the bus incidence matrix.

SYNOPSIS ^

function [Ainc] = makeIncidence(bus, branch)

DESCRIPTION ^

MAKEINCIDENCE   Builds the bus incidence matrix.
   [Ainc] = MAKEINCIDENCE(MPC)
   [Ainc] = MAKEINCIDENCE(BUS, BRANCH)

   Builds the bus incidence matrix. This matrix has size nline by nbus,
   with each row having two nonzero elements: +1 in the entry for the 
   "from" bus of the corresponding line and -1 in the entry for the "to"
   bus of the corresponding line.

   Inputs:
       MPC : MATPOWER case variable with internal indexing.

   Outputs:
       AINC : An nline by nbus size bus incidence matrix.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [Ainc] = makeIncidence(bus, branch)
0002 %MAKEINCIDENCE   Builds the bus incidence matrix.
0003 %   [Ainc] = MAKEINCIDENCE(MPC)
0004 %   [Ainc] = MAKEINCIDENCE(BUS, BRANCH)
0005 %
0006 %   Builds the bus incidence matrix. This matrix has size nline by nbus,
0007 %   with each row having two nonzero elements: +1 in the entry for the
0008 %   "from" bus of the corresponding line and -1 in the entry for the "to"
0009 %   bus of the corresponding line.
0010 %
0011 %   Inputs:
0012 %       MPC : MATPOWER case variable with internal indexing.
0013 %
0014 %   Outputs:
0015 %       AINC : An nline by nbus size bus incidence matrix.
0016 
0017 %   MATPOWER
0018 %   Copyright (c) 2013-2015 by Power System Engineering Research Center (PSERC)
0019 %   by Daniel Molzahn, PSERC U of Wisc, Madison
0020 %   and Ray Zimmerman, PSERC Cornell
0021 %
0022 %   $Id: makeIncidence.m 2644 2015-03-11 19:34:22Z ray $
0023 %
0024 %   This file is part of MATPOWER.
0025 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0026 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0027 
0028 if nargin < 2
0029     mpc     = bus;
0030     bus     = mpc.bus;
0031     branch  = mpc.branch;
0032 end
0033 
0034 %% constants
0035 nb = size(bus, 1);          %% number of buses
0036 nl = size(branch, 1);       %% number of lines
0037 
0038 %% define named indices into bus, branch matrices
0039 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0040     VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0041 [F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, RATE_C, ...
0042     TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST, ...
0043     ANGMIN, ANGMAX, MU_ANGMIN, MU_ANGMAX] = idx_brch;
0044 
0045 %% check that bus numbers are equal to indices to bus (one set of bus numbers)
0046 if any(bus(:, BUS_I) ~= (1:nb)')
0047     error('makeIncidence: buses must appear in order by bus number')
0048 end
0049 
0050 %% build connection matrices
0051 f = branch(:, F_BUS);                           %% list of "from" buses
0052 t = branch(:, T_BUS);                           %% list of "to" buses
0053 Cf = sparse(1:nl, f, ones(nl, 1), nl, nb);      %% connection matrix for line & from buses
0054 Ct = sparse(1:nl, t, ones(nl, 1), nl, nb);      %% connection matrix for line & to buses
0055 
0056 Ainc = Cf - Ct;

Generated on Fri 20-Mar-2015 18:23:34 by m2html © 2005