Subroutine PreProcess do following tasks to input model: 1. Eliminate all isolated buses 2. Eliminate all out-of-service branches 3. Eliminate all in-service but connected to isolated bus branches 4. Eliminate all HVDC line connected to isolated buses 5. Eliminate all generators on isolated buses 6. Update the list of external bus (ExBus) by eliminating the isolated buses in the list [mpc,ExBus]=PreProcessData(mpc,ExBus) INPUT DATA: mpc: struct, input original full model (MATPOWER case file) ExBus: 1*n array, original list of external buses OUTPUT DATA: mpc: struct, updated model ExBus: 1*n array, updated list of external buses
0001 function [mpc,ExBus]=PreProcessData(mpc,ExBus) 0002 % Subroutine PreProcess do following tasks to input model: 0003 % 1. Eliminate all isolated buses 0004 % 2. Eliminate all out-of-service branches 0005 % 3. Eliminate all in-service but connected to isolated bus branches 0006 % 4. Eliminate all HVDC line connected to isolated buses 0007 % 5. Eliminate all generators on isolated buses 0008 % 6. Update the list of external bus (ExBus) by eliminating the isolated 0009 % buses in the list 0010 % 0011 % [mpc,ExBus]=PreProcessData(mpc,ExBus) 0012 % 0013 % INPUT DATA: 0014 % mpc: struct, input original full model (MATPOWER case file) 0015 % ExBus: 1*n array, original list of external buses 0016 % 0017 % OUTPUT DATA: 0018 % mpc: struct, updated model 0019 % ExBus: 1*n array, updated list of external buses 0020 0021 % MATPOWER 0022 % Copyright (c) 2014-2015 by Power System Engineering Research Center (PSERC) 0023 % by Yujia Zhu, PSERC ASU 0024 % 0025 % $Id: PreProcessData.m 2655 2015-03-18 16:40:32Z ray $ 0026 % 0027 % This file is part of MATPOWER. 0028 % Covered by the 3-clause BSD License (see LICENSE file for details). 0029 % See http://www.pserc.cornell.edu/matpower/ for more info. 0030 0031 mpc.bus = sortrows(mpc.bus,1); 0032 mpc.branch = sortrows(mpc.branch,[1,2]); 0033 numbr=size(mpc.branch,1); 0034 mpc.branch(mpc.branch(:,11)==0,:)=[];% eliminated all out-of-service lines 0035 isobus=mpc.bus(mpc.bus(:,2)==4,1); 0036 fprintf('\nEliminate %d isolated buses',length(isobus)); 0037 tf1=ismember(mpc.branch(:,1),isobus); 0038 tf2=ismember(mpc.branch(:,2),isobus); 0039 mpc.branch(tf1|tf2,:)=[]; % eliminate all branch connected to isolated buses 0040 fprintf('\nEliminate %d branches',numbr-size(mpc.branch,1)); 0041 0042 mpc.bus(mpc.bus(:,2)==4,:)=[]; % eliminate all isolated buses 0043 tfgen=ismember(mpc.gen(:,1),isobus); 0044 mpc.gen(tfgen,:)=[]; % eliminate all generators on isolated buses 0045 fprintf('\nEliminate %d generators',length(tfgen(tfgen==1))); 0046 if isfield (mpc,'gencost') 0047 mpc.gencost(tfgen,:)=[]; 0048 end 0049 ind=ismember(ExBus,isobus); 0050 ExBus(ind)=[]; 0051 if isfield(mpc,'dcline') 0052 tfdc1=ismember(mpc.dcline(:,1),isobus); 0053 tfdc2=ismember(mpc.dcline(:,2),isobus); 0054 mpc.dcline(tfdc1|tfdc2,:)=[]; % eliminate dcline connecting isolated terminal 0055 fprintf('\nEliminate %d dc lines',length(length(find(tfdc1|tfdc2)))); 0056 0057 end 0058 fprintf('\nPreprocessing complete'); 0059 end