Home > matpower5.1 > extras > reduction > MPReduction.m

MPReduction

PURPOSE ^

Function MPReduction does modified Ward reduction to the full system

SYNOPSIS ^

function [mpcreduced,Link,BCIRCr]=MPReduction(mpc,ExBusOrig,Pf_flag)

DESCRIPTION ^

 Function MPReduction does modified Ward reduction to the full system
 model given in the MATPOWER case file (mpc) based the external buses
 (ExBusOrig)defined by the user.

  [mpcreduced,Link,BCIRCr]=MPReduction(mpc,ExBusOrig,Pf_flag)

 INPUT DATA:
   mpc: struct, includes the full model in MATPOWER case format
   ExBusOrig: n*1 vector, include the bus numbers of buses to be
   eliminated
   Pf_flag: scalar, indicate if dc power flow needed to solve (=1) or not
       (=0) in the load redistribution subroutine
   
 OUTPUT DATA:
   mpcreduced: struct, includes the reduced model in MATPOWER case format
   Link: n*2 matrix, includes the generator mapping info, showing how
       external generators are moved: The first column includes generator bus
       numbers in full model and the second column includes generator bus
       nubmers where the external generators are moved to.
   BCIRCr: n*1 vector, includes branch circuit numbers. This vector can be
       used to identify parallel branches and equivalent lines generated by
       the network reduction process. If a branch number is higher than 1 and
       less then it indicate this branch is parallel to one of the branch in
       the full model. If a branch circuit number is 99 then it indicate this
       branch is an equivalent branch.

 Note: The reduction is based on dc assumption which means all resistance,
 reactive power components will be ignored. And the reduced model is only
 good for solving dc power flow or dc opf. If the input full model case
 file includes dclines, it is assumed that no dc terminal is to be
 eliminated, otherwise the function will return error. If Pf_flag = 1
 which means dc power flow need to be solved during the load
 redistribution process, user must make sure that MATPOWER toolbox is
 installed.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [mpcreduced,Link,BCIRCr]=MPReduction(mpc,ExBusOrig,Pf_flag)
0002 % Function MPReduction does modified Ward reduction to the full system
0003 % model given in the MATPOWER case file (mpc) based the external buses
0004 % (ExBusOrig)defined by the user.
0005 %
0006 %  [mpcreduced,Link,BCIRCr]=MPReduction(mpc,ExBusOrig,Pf_flag)
0007 %
0008 % INPUT DATA:
0009 %   mpc: struct, includes the full model in MATPOWER case format
0010 %   ExBusOrig: n*1 vector, include the bus numbers of buses to be
0011 %   eliminated
0012 %   Pf_flag: scalar, indicate if dc power flow needed to solve (=1) or not
0013 %       (=0) in the load redistribution subroutine
0014 %
0015 % OUTPUT DATA:
0016 %   mpcreduced: struct, includes the reduced model in MATPOWER case format
0017 %   Link: n*2 matrix, includes the generator mapping info, showing how
0018 %       external generators are moved: The first column includes generator bus
0019 %       numbers in full model and the second column includes generator bus
0020 %       nubmers where the external generators are moved to.
0021 %   BCIRCr: n*1 vector, includes branch circuit numbers. This vector can be
0022 %       used to identify parallel branches and equivalent lines generated by
0023 %       the network reduction process. If a branch number is higher than 1 and
0024 %       less then it indicate this branch is parallel to one of the branch in
0025 %       the full model. If a branch circuit number is 99 then it indicate this
0026 %       branch is an equivalent branch.
0027 %
0028 % Note: The reduction is based on dc assumption which means all resistance,
0029 % reactive power components will be ignored. And the reduced model is only
0030 % good for solving dc power flow or dc opf. If the input full model case
0031 % file includes dclines, it is assumed that no dc terminal is to be
0032 % eliminated, otherwise the function will return error. If Pf_flag = 1
0033 % which means dc power flow need to be solved during the load
0034 % redistribution process, user must make sure that MATPOWER toolbox is
0035 % installed.
0036 
0037 %   MATPOWER
0038 %   Copyright (c) 2014-2015 by Power System Engineering Research Center (PSERC)
0039 %   by Yujia Zhu, PSERC ASU
0040 %
0041 %   $Id: MPReduction.m 2655 2015-03-18 16:40:32Z ray $
0042 %
0043 %   This file is part of MATPOWER.
0044 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0045 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0046 
0047 fprintf('%n Reduction process start');
0048 fprintf('%n Preprocess data')';
0049 [mpc,ExBusOrig]=PreProcessData(mpc,ExBusOrig);
0050 dim = size(mpc.bus,1);
0051 %% Modeling
0052 % check if dc terminals are external
0053 if isfield(mpc,'dcline')
0054 tf1 = ismember(mpc.dcline(:,1),ExBusOrig);
0055 tf2 = ismember(mpc.dcline(:,2),ExBusOrig);
0056 if (sum(tf1)+sum(tf2))>0
0057     error('not able to eliminate HVDC line terminals');
0058 end
0059 end
0060 ExBusOrig = ExBusOrig';
0061 if ~isempty(ExBusOrig)
0062 fprintf('\nConvert input data model');
0063 [NFROM,NTO,BraNum,LineB,ShuntB,BCIRC,BusNum,NUMB,SelfB,mpc,ExBus,newbusnum,oldbusnum] = Initiation(mpc,ExBusOrig); % ExBus with internal numbering
0064 %% Create data structure
0065 fprintf('\nCreating Y matrix of input full model');
0066 [CIndx,ERP,DataB]=BuildYMat(NFROM,NTO,BraNum,LineB,BCIRC,BusNum,NUMB,SelfB);
0067 %% Do Reduction
0068 fprintf('\nDo first round reduction eliminating all external buses');
0069 [mpcreduced,BCIRCr,ExBusr] = DoReduction(DataB,ERP,CIndx,ExBus,NUMB,dim,BCIRC,newbusnum,oldbusnum,mpc); % ExBusr with original numbering
0070 %% Generate the second reduction with all retained buses and all generator
0071 %% buses mpcreduced_gen
0072 % Create the ExBus_Gen to create the reduced model with all gens
0073 tf = ismember(ExBus,mpc.gen(:,1));
0074 ExBusGen = ExBus;
0075 ExBusGen(tf==1)=[]; % delete all external buses with generators
0076 tf=ismember(mpc.gen(:,1),ExBus);
0077 fprintf('\n%d external generators are to be placed',length(tf(tf==1)));
0078 if ~isempty(ExBusGen)
0079 fprintf('\nDo second round reduction eliminating all external non-generator buses');
0080 [mpcreduced_gen,BCIRC_gen,ExBusGen] = DoReduction(DataB,ERP,CIndx,ExBusGen,NUMB,dim,BCIRC,newbusnum,oldbusnum,mpc);
0081 else
0082     mpcreduced_gen = mpc;
0083     mpcreduced_gen=MapBus(mpcreduced_gen,newbusnum,oldbusnum);
0084     BCIRC_gen = BCIRC;
0085 end
0086 %% Move Generators
0087 fprintf('\nPlacing External generators');
0088 [NewGenBus,Link]=MoveExGen(mpcreduced_gen,ExBusOrig,ExBusGen,BCIRC_gen,0);
0089 mpcreduced.gen(:,1)=NewGenBus; % move all external generators
0090 %% Do Inverse PowerFlow
0091 fprintf('\nRedistribute loads');
0092 mpc=MapBus(mpc,newbusnum,oldbusnum);
0093 [mpcreduced,BCIRCr]=LoadRedistribution(mpc,mpcreduced,BCIRCr,Pf_flag);
0094 else
0095     mpcreduced = mpc;
0096     warning('No external buses, reduced model is same as full model');
0097 end
0098 %% Delete large reactance equivalent branches
0099 ind=find(abs(mpcreduced.branch(:,4))>=max(mpc.branch(:,4))*10);
0100 mpcreduced.branch(ind,:)=[];
0101 BCIRCr(ind)=[];
0102 %% Print Results
0103 fprintf('\n**********Reduction Summary****************');
0104 fprintf('\n%d buses in reduced model',size(mpcreduced.bus,1));
0105 fprintf('\n%d branches in reduced model, including %d equivalent lines',size(mpcreduced.branch,1),length(BCIRCr(BCIRCr==max(BCIRCr))));
0106 fprintf('\n%d generators in reduced model',size(mpcreduced.gen,1));
0107 if isfield(mpcreduced,'dcline')
0108 fprintf('\n%d HVDC lines in reduced mode,',size(mpcreduced.dcline,1));
0109 end
0110 fprintf('\n**********Generator Placement Results**************');
0111 for i=1:size(Link,1)
0112     if Link(i,2)-Link(i,1)~=0
0113         fprintf('\nExternal generator on bus %d is moved to %d',Link(i,1),Link(i,2));
0114     end
0115 end
0116 fprintf('\n');
0117 
0118 end

Generated on Fri 20-Mar-2015 18:23:34 by m2html © 2005