Home > matpower7.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-2019, Power Systems Engineering Research Center (PSERC)
0019 %   by Daniel Molzahn, PSERC U of Wisc, Madison
0020 %   and Ray Zimmerman, PSERC Cornell
0021 %
0022 %   This file is part of MATPOWER/mx-sdp_pf.
0023 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0024 %   See https://github.com/MATPOWER/mx-sdp_pf/ for more info.
0025 
0026 if nargin < 2
0027     mpc     = bus;
0028     bus     = mpc.bus;
0029     branch  = mpc.branch;
0030 end
0031 
0032 %% constants
0033 nb = size(bus, 1);          %% number of buses
0034 nl = size(branch, 1);       %% number of lines
0035 
0036 %% define named indices into bus, branch matrices
0037 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0038     VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0039 [F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, RATE_C, ...
0040     TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST, ...
0041     ANGMIN, ANGMAX, MU_ANGMIN, MU_ANGMAX] = idx_brch;
0042 
0043 %% check that bus numbers are equal to indices to bus (one set of bus numbers)
0044 if any(bus(:, BUS_I) ~= (1:nb)')
0045     error('makeIncidence: buses must be numbered consecutively in bus matrix; use ext2int() to convert to internal ordering')
0046 end
0047 
0048 %% build connection matrices
0049 f = branch(:, F_BUS);                           %% list of "from" buses
0050 t = branch(:, T_BUS);                           %% list of "to" buses
0051 Cf = sparse(1:nl, f, ones(nl, 1), nl, nb);      %% connection matrix for line & from buses
0052 Ct = sparse(1:nl, t, ones(nl, 1), nl, nb);      %% connection matrix for line & to buses
0053 
0054 Ainc = Cf - Ct;

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