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-2016, Power Systems Engineering Research Center (PSERC) 0020 % by Yujia Zhu, PSERC ASU 0021 % 0022 % This file is part of MATPOWER/mx-reduction. 0023 % Covered by the 3-clause BSD License (see LICENSE file for details). 0024 % See https://github.com/MATPOWER/mx-reduction/ for more info. 0025 0026 BoundBus=zeros(size(mpc.bus,1),1); 0027 ExFlag=BoundBus; 0028 ExFlag(ExBus)=1; 0029 0030 for i = 1:size(mpc.branch,1) 0031 m=mpc.branch(i,1); 0032 n=mpc.branch(i,2); 0033 if ExFlag(m)+ExFlag(n)<2 % exclude external branch 0034 if (ExFlag(m)*n+ExFlag(n)*m)~=0 0035 BoundBus(ExFlag(m)*n+ExFlag(n)*m)=1; 0036 end 0037 end 0038 end 0039 BoundBus=find(BoundBus==1); 0040 0041 end