Subroutine DefBoundary indentify the boundary buses in the given model mpc based on the list of external buses (ExBus). [BoundBus]=DefBoundary(mpc,ExBus) INPUT DATA: mpc - struct, input system model in MATPOWER format ExBus - 1*n array, includes external bus indices OUTPUT DATA: BoundBus - 1*n array, Boundary bus indices Note: Boundary buses are the retained buses directly connected to external buses.
0001 function [BoundBus]=DefBoundary(mpc,ExBus) 0002 % Subroutine DefBoundary indentify the boundary buses in the given model 0003 % mpc based on the list of external buses (ExBus). 0004 % 0005 % [BoundBus]=DefBoundary(mpc,ExBus) 0006 % 0007 % INPUT DATA: 0008 % mpc - struct, input system model in MATPOWER format 0009 % ExBus - 1*n array, includes external bus indices 0010 % 0011 % OUTPUT DATA: 0012 % BoundBus - 1*n array, Boundary bus indices 0013 % 0014 % Note: 0015 % Boundary buses are the retained buses directly connected to external 0016 % buses. 0017 0018 % MATPOWER 0019 % Copyright (c) 2014-2015 by Power System Engineering Research Center (PSERC) 0020 % by Yujia Zhu, PSERC ASU 0021 % 0022 % $Id: DefBoundary.m 2655 2015-03-18 16:40:32Z 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 BoundBus=zeros(size(mpc.bus,1),1); 0029 ExFlag=BoundBus; 0030 ExFlag(ExBus)=1; 0031 0032 for i = 1:size(mpc.branch,1) 0033 m=mpc.branch(i,1); 0034 n=mpc.branch(i,2); 0035 if ExFlag(m)+ExFlag(n)<2 % exclude external branch 0036 if (ExFlag(m)*n+ExFlag(n)*m)~=0 0037 BoundBus(ExFlag(m)*n+ExFlag(n)*m)=1; 0038 end 0039 end 0040 end 0041 BoundBus=find(BoundBus==1); 0042 0043 end