Home > matpower5.0 > 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 %   $Id: makeIncidence.m 2272 2014-01-17 14:15:47Z ray $
0019 %   by Daniel Molzahn, PSERC U of Wisc, Madison
0020 %   and Ray Zimmerman, PSERC Cornell
0021 %   Copyright (c) 2013-2014 by Power System Engineering Research Center (PSERC)
0022 %
0023 %   This file is part of MATPOWER.
0024 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0025 %
0026 %   MATPOWER is free software: you can redistribute it and/or modify
0027 %   it under the terms of the GNU General Public License as published
0028 %   by the Free Software Foundation, either version 3 of the License,
0029 %   or (at your option) any later version.
0030 %
0031 %   MATPOWER is distributed in the hope that it will be useful,
0032 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0033 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0034 %   GNU General Public License for more details.
0035 %
0036 %   You should have received a copy of the GNU General Public License
0037 %   along with MATPOWER. If not, see <http://www.gnu.org/licenses/>.
0038 %
0039 %   Additional permission under GNU GPL version 3 section 7
0040 %
0041 %   If you modify MATPOWER, or any covered work, to interface with
0042 %   other modules (such as MATLAB code and MEX-files) available in a
0043 %   MATLAB(R) or comparable environment containing parts covered
0044 %   under other licensing terms, the licensors of MATPOWER grant
0045 %   you additional permission to convey the resulting work.
0046 
0047 if nargin < 2
0048     mpc     = bus;
0049     bus     = mpc.bus;
0050     branch  = mpc.branch;
0051 end
0052 
0053 %% constants
0054 nb = size(bus, 1);          %% number of buses
0055 nl = size(branch, 1);       %% number of lines
0056 
0057 %% define named indices into bus, branch matrices
0058 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0059     VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0060 [F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, RATE_C, ...
0061     TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST, ...
0062     ANGMIN, ANGMAX, MU_ANGMIN, MU_ANGMAX] = idx_brch;
0063 
0064 %% check that bus numbers are equal to indices to bus (one set of bus numbers)
0065 if any(bus(:, BUS_I) ~= (1:nb)')
0066     error('makeIncidence: buses must appear in order by bus number')
0067 end
0068 
0069 %% build connection matrices
0070 f = branch(:, F_BUS);                           %% list of "from" buses
0071 t = branch(:, T_BUS);                           %% list of "to" buses
0072 Cf = sparse(1:nl, f, ones(nl, 1), nl, nb);      %% connection matrix for line & from buses
0073 Ct = sparse(1:nl, t, ones(nl, 1), nl, nb);      %% connection matrix for line & to buses
0074 
0075 Ainc = Cf - Ct;

Generated on Mon 26-Jan-2015 15:21:31 by m2html © 2005