Home > matpower5.1 > psse_convert_xfmr.m

psse_convert_xfmr

PURPOSE ^

PSSE_CONVERT_XFMR Convert transformer data from PSS/E RAW to MATPOWER

SYNOPSIS ^

function [xfmr, bus, warns, bus_name] = psse_convert_xfmr(warns, trans2, trans3, verbose, baseMVA, bus, bus_name)

DESCRIPTION ^

PSSE_CONVERT_XFMR Convert transformer data from PSS/E RAW to MATPOWER
   [XFMR, BUS, WARNINGS] = PSSE_CONVERT_XFMR(WARNINGS, TRANS2, TRANS3, ...
                                   VERBOSE, BASEMVA, BUS)
   [XFMR, BUS, WARNINGS, BUS_NAME] = PSSE_CONVERT_XFMR(WARNINGS, TRANS2, ...
                                   TRANS3, VERBOSE, BASEMVA, BUS, BUS_NAME)

   Convert all transformer data read from a PSS/E RAW data file
   into MATPOWER format. Returns a branch matrix corresponding to
   the transformers and an updated bus matrix, with additional buses
   added for the star points of three winding transformers.

   Inputs:
       WARNINGS :  cell array of strings containing accumulated
                   warning messages
       TRANS2  : matrix of raw two winding transformer data returned
                 by PSSE_READ in data.trans2.num
       TRANS3  : matrix of raw three winding transformer data returned
                 by PSSE_READ in data.trans3.num
       VERBOSE :   1 to display progress info, 0 (default) otherwise
       BASEMVA : system MVA base
       BUS     : MATPOWER bus matrix
       BUS_NAME: (optional) cell array of bus names

   Outputs:
       XFMR    : MATPOWER branch matrix of transformer data
       BUS     : updated MATPOWER bus matrix, with additional buses
                 added for star points of three winding transformers
       WARNINGS :  cell array of strings containing updated accumulated
                   warning messages
       BUS_NAME: (optional) updated cell array of bus names

   See also PSSE_CONVERT.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [xfmr, bus, warns, bus_name] = psse_convert_xfmr(warns, trans2, trans3, verbose, baseMVA, bus, bus_name)
0002 %PSSE_CONVERT_XFMR Convert transformer data from PSS/E RAW to MATPOWER
0003 %   [XFMR, BUS, WARNINGS] = PSSE_CONVERT_XFMR(WARNINGS, TRANS2, TRANS3, ...
0004 %                                   VERBOSE, BASEMVA, BUS)
0005 %   [XFMR, BUS, WARNINGS, BUS_NAME] = PSSE_CONVERT_XFMR(WARNINGS, TRANS2, ...
0006 %                                   TRANS3, VERBOSE, BASEMVA, BUS, BUS_NAME)
0007 %
0008 %   Convert all transformer data read from a PSS/E RAW data file
0009 %   into MATPOWER format. Returns a branch matrix corresponding to
0010 %   the transformers and an updated bus matrix, with additional buses
0011 %   added for the star points of three winding transformers.
0012 %
0013 %   Inputs:
0014 %       WARNINGS :  cell array of strings containing accumulated
0015 %                   warning messages
0016 %       TRANS2  : matrix of raw two winding transformer data returned
0017 %                 by PSSE_READ in data.trans2.num
0018 %       TRANS3  : matrix of raw three winding transformer data returned
0019 %                 by PSSE_READ in data.trans3.num
0020 %       VERBOSE :   1 to display progress info, 0 (default) otherwise
0021 %       BASEMVA : system MVA base
0022 %       BUS     : MATPOWER bus matrix
0023 %       BUS_NAME: (optional) cell array of bus names
0024 %
0025 %   Outputs:
0026 %       XFMR    : MATPOWER branch matrix of transformer data
0027 %       BUS     : updated MATPOWER bus matrix, with additional buses
0028 %                 added for star points of three winding transformers
0029 %       WARNINGS :  cell array of strings containing updated accumulated
0030 %                   warning messages
0031 %       BUS_NAME: (optional) updated cell array of bus names
0032 %
0033 %   See also PSSE_CONVERT.
0034 
0035 %   MATPOWER
0036 %   Copyright (c) 2014-2015 by Power System Engineering Research Center (PSERC)
0037 %   by Yujia Zhu, PSERC ASU
0038 %   and Ray Zimmerman, PSERC Cornell
0039 %   Based on mptransin.m and mptransficbus.m, written by:
0040 %       Yujia Zhu, Jan 2014, yzhu54@asu.edu.
0041 %
0042 %   $Id: psse_convert_xfmr.m 2644 2015-03-11 19:34:22Z ray $
0043 %
0044 %   This file is part of MATPOWER.
0045 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0046 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0047 
0048 %% define named indices into bus, gen, branch matrices
0049 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0050     VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0051 [F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, RATE_C, ...
0052     TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST, ...
0053     ANGMIN, ANGMAX, MU_ANGMIN, MU_ANGMAX] = idx_brch;
0054 
0055 %% sizes
0056 nb = size(bus, 1);
0057 nt2 = size(trans2, 1);
0058 nt3 = size(trans3, 1);
0059 
0060 %%-----  create fictitious buses for star point of 3 winding transformers  -----
0061 starbus = zeros(nt3, VMIN);     %% initialize additional bus matrix
0062 if nt3 > 0
0063     mb =  max(bus(:, BUS_I));       %% find maximum bus number
0064     b = 10^ceil(log10(mb+1));       %% start new numbers at next order of magnitude
0065     wind1bus = trans3(:,1);         %% winding1 bus number
0066     e2i = sparse(bus(:, BUS_I), ones(nb, 1), 1:nb, max(bus(:, BUS_I)), 1);
0067     starbus(:, BUS_I) = (b+1:b+nt3)';   %% bus numbers follow originals
0068     starbus(:, BUS_TYPE) = PQ;
0069     starbus(trans3(:,12)==0, BUS_TYPE) = NONE;  %% isolated if transformer is off-line
0070     starbus(:, VA) = trans3(:,31);  %% VA = star point voltage angle
0071     starbus(:, VM) = trans3(:,30);  %% VM = star point voltage magnitude (PU)
0072     starbus(:, [BUS_AREA, ZONE]) = bus(e2i(wind1bus), [7,11]); %% wind1 bus area, zone
0073     starbus(:, BASE_KV) = 1;        %% baseKV = 1 kV (RayZ: why?)
0074     starbus(:, VMAX) = 1.1;
0075     starbus(:, VMIN) = 0.9;
0076 end
0077 
0078 %% two winding transformer data
0079 [tf,fbus] = ismember(trans2(:,1), bus(:, BUS_I));      %% I
0080 [tf,tbus] = ismember(trans2(:,2), bus(:, BUS_I));      %% J
0081 %% check for bad bus numbers
0082 k = find(fbus == 0 | tbus == 0);
0083 if ~isempty(k)
0084     warns{end+1} = sprintf('Ignoring %d two-winding transformers with bad bus numbers', length(k));
0085     if verbose
0086         fprintf('WARNING: Ignoring %d two-winding transformers with bad bus numbers', length(k));
0087     end
0088     fbus(k) = [];
0089     tbus(k) = [];
0090     trans2(k, :) = [];
0091     nt2 = nt2 - length(k);
0092 end
0093 Zbs = bus(:, BASE_KV).^2 / baseMVA;     %% system impedance base
0094 if nt2 > 0
0095     cw2 = find(trans2(:,5) == 2);   %% CW = 2
0096     cw3 = find(trans2(:,5) == 3);   %% CW = 3
0097     cw23 = [cw2;cw3];               %% CW = 2 or 3
0098     cz2 = find(trans2(:,6) == 2);   %% CZ = 2
0099     cz3 = find(trans2(:,6) == 3);   %% CZ = 3
0100     cz23 = [cz2;cz3];               %% CZ = 2 or 3
0101 
0102     R = trans2(:,21);
0103     X = trans2(:,22);
0104     Zb = ones(nt2, 1);
0105     Zb(cz23) = trans2(cz23,25).^2 ./ trans2(cz23,23);
0106     R(cz2)  = R(cz2)  .* Zb(cz2)  ./ Zbs(fbus(cz2));
0107     X(cz23) = X(cz23) .* Zb(cz23) ./ Zbs(fbus(cz23));
0108     R(cz3)  = trans2(cz3,25).^2 ./ trans2(cz3,21) ./ Zbs(fbus(cz3));
0109     tap = trans2(:,24) ./ trans2(:,40);
0110     tap(cw23) = tap(cw23) .* bus(tbus(cw23), BASE_KV)./bus(fbus(cw23), BASE_KV);
0111     tap(cw3) = tap(cw3) .* trans2(cw3,25)./trans2(cw3,41);
0112     shift = trans2(:, 26);
0113 end
0114 
0115 %% three winding transformer data
0116 [tf,ind1] = ismember(trans3(:,1), bus(:, BUS_I));
0117 [tf,ind2] = ismember(trans3(:,2), bus(:, BUS_I));
0118 [tf,ind3] = ismember(trans3(:,3), bus(:, BUS_I));
0119 %% check for bad bus numbers
0120 k = find(ind1 == 0 | ind2 == 0 | ind3 == 0);
0121 if ~isempty(k)
0122     warns{end+1} = sprintf('Ignoring %d three-winding transformers with bad bus numbers', length(k));
0123     if verbose
0124         fprintf('WARNING: Ignoring %d three-winding transformers with bad bus numbers', length(k));
0125     end
0126     ind1(k) = [];
0127     ind2(k) = [];
0128     ind3(k) = [];
0129     trans3(k, :) = [];
0130     starbus(k, :) = [];
0131     nt3 = nt3 - length(k);
0132 end
0133 %% Each three winding transformer will be converted into 3 branches:
0134 %% The branches will be in the order of
0135 %% # winding1 -> # winding2
0136 %% # winding2 -> # winding3
0137 %% # winding3 -> # winding1
0138 if nt3 > 0
0139     cw2 = find(trans3(:,5) == 2);   %% CW = 2
0140     cw3 = find(trans3(:,5) == 3);   %% CW = 3
0141     cw23 = [cw2;cw3];               %% CW = 2 or 3
0142     cz2 = find(trans3(:,6) == 2);   %% CZ = 2
0143     cz3 = find(trans3(:,6) == 3);   %% CZ = 3
0144     cz23 = [cz2;cz3];               %% CZ = 2 or 3
0145 
0146     tap1 = trans3(:, 32);   %% off nominal tap ratio of branch 1
0147     tap2 = trans3(:, 48);   %% off nominal tap ratio of branch 2
0148     tap3 = trans3(:, 64);   %% off nominal tap ratio of branch 3
0149     tap1(cw23) = tap1(cw23) ./ bus(ind1(cw23), BASE_KV);
0150     tap2(cw23) = tap2(cw23) ./ bus(ind2(cw23), BASE_KV);
0151     tap3(cw23) = tap3(cw23) ./ bus(ind3(cw23), BASE_KV);
0152     tap1(cw3)  = tap1(cw3)  .* trans3(cw3, 33);
0153     tap2(cw3)  = tap2(cw3)  .* trans3(cw3, 49);
0154     tap3(cw3)  = tap3(cw3)  .* trans3(cw3, 65);
0155     shift1 = trans3(:, 34);
0156     shift2 = trans3(:, 50);
0157     shift3 = trans3(:, 66);
0158 
0159     trans3(cz3, 33) = bus(ind1(cz3), BASE_KV);
0160     trans3(cz3, 49) = bus(ind1(cz3), BASE_KV);
0161     trans3(cz3, 65) = bus(ind1(cz3), BASE_KV);
0162 
0163     R12 = trans3(:, 21);
0164     X12 = trans3(:, 22);
0165     R23 = trans3(:, 24);
0166     X23 = trans3(:, 25);
0167     R31 = trans3(:, 27);
0168     X31 = trans3(:, 28);
0169     Zb1 = trans3(:, 33).^2 ./ trans3(:, 23);
0170     Zb2 = trans3(:, 49).^2 ./ trans3(:, 26);
0171     Zb3 = trans3(:, 65).^2 ./ trans3(:, 29);
0172 
0173     R12(cz2) = R12(cz2) .* Zb1(cz2) ./ Zbs(ind1(cz2));
0174     X12(cz2) = X12(cz2) .* Zb1(cz2) ./ Zbs(ind1(cz2));
0175     R23(cz2) = R23(cz2) .* Zb2(cz2) ./ Zbs(ind2(cz2));
0176     X23(cz2) = X23(cz2) .* Zb2(cz2) ./ Zbs(ind2(cz2));
0177     R31(cz2) = R31(cz2) .* Zb3(cz2) ./ Zbs(ind3(cz2));
0178     X31(cz2) = X31(cz2) .* Zb3(cz2) ./ Zbs(ind3(cz2));
0179 
0180     R12(cz3) = (trans3(cz3,33)*1000) .^ 2 ./ trans3(cz3,21) ./ Zbs(ind1(cz3));
0181     X12(cz3) = trans3(cz3,22) .* Zb1(cz3) ./ Zbs(ind3(cz3));
0182     R23(cz3) = (trans3(cz3,49)*1000) .^ 2 ./ trans3(cz3,24) ./ Zbs(ind2(cz3));
0183     X23(cz3) = trans3(cz3,25) .* Zb2(cz3) ./ Zbs(ind3(cz3));
0184     R31(cz3) = (trans3(cz3,65)*1000) .^ 2 ./ trans3(cz3,27) ./ Zbs(ind3(cz3));
0185     X31(cz3) = trans3(cz3,28) .* Zb3(cz3) ./ Zbs(ind3(cz3));
0186 
0187     R1 = (R12+R31-R23) ./ 2;
0188     R2 = (R12+R23-R31) ./ 2;
0189     R3 = (R31+R23-R12) ./ 2;
0190     X1 = (X12+X31-X23) ./ 2;
0191     X2 = (X12+X23-X31) ./ 2;
0192     X3 = (X31+X23-X12) ./ 2;
0193 end
0194 
0195 %%-----  assemble transformer data into MATPOWER branch format  -----
0196 %%% two winding transformers %%%
0197 xfmr2 = zeros(nt2, ANGMAX);
0198 if nt2 > 0
0199     xfmr2(:, [F_BUS T_BUS]) = trans2(:,[1,2]);
0200     xfmr2(:, [BR_R BR_X TAP SHIFT]) = [R X tap shift];
0201     xfmr2(:, [RATE_A RATE_B RATE_C]) = trans2(:,[27,28,29]);
0202     xfmr2(:, BR_STATUS) = trans2(:,12);
0203     xfmr2(:, ANGMIN) = -360;
0204     xfmr2(:, ANGMAX) = 360;
0205 end
0206 
0207 %%% three winding transformers %%%
0208 xfmr3 = zeros(3*nt3, ANGMAX);
0209 if nt3 > 0
0210     idx1 = (1:3:3*nt3)';        %% indices of winding 1
0211     idx2 = idx1+1;              %% indices of winding 2
0212     idx3 = idx1+2;              %% indices of winding 3
0213     %% bus numbers
0214     xfmr3(idx1, [F_BUS T_BUS]) = [trans3(:,1), starbus(:,1)];
0215     xfmr3(idx2, [F_BUS T_BUS]) = [trans3(:,2), starbus(:,1)];
0216     xfmr3(idx3, [F_BUS T_BUS]) = [trans3(:,3), starbus(:,1)];
0217     %% impedances, tap ratios & phase shifts
0218     xfmr3(idx1, [BR_R BR_X TAP SHIFT]) = [R1 X1 tap1 shift1];
0219     xfmr3(idx2, [BR_R BR_X TAP SHIFT]) = [R2 X2 tap2 shift2];
0220     xfmr3(idx3, [BR_R BR_X TAP SHIFT]) = [R3 X3 tap3 shift3];
0221     %% ratings
0222     xfmr3(idx1, [RATE_A RATE_B RATE_C]) = trans3(:,[35,36,37]);
0223     xfmr3(idx2, [RATE_A RATE_B RATE_C]) = trans3(:,[51,52,53]);
0224     xfmr3(idx3, [RATE_A RATE_B RATE_C]) = trans3(:,[67,68,69]);
0225     xfmr3(:, ANGMIN) = -360;        %% angle limits
0226     xfmr3(:, ANGMAX) =  360;
0227     %% winding status
0228     xfmr3(:, BR_STATUS) = 1;        %% initialize to all in-service
0229     status = trans3(:, 12);
0230     k1 = find(status == 0 | status == 4);   %% winding 1 out-of-service
0231     k2 = find(status == 0 | status == 2);   %% winding 2 out-of-service
0232     k3 = find(status == 0 | status == 3);   %% winding 3 out-of-service
0233     if ~isempty(k1)
0234         xfmr3(idx1(k1), BR_STATUS) = 0;
0235     end
0236     if ~isempty(k2)
0237         xfmr3(idx2(k2), BR_STATUS) = 0;
0238     end
0239     if ~isempty(k3)
0240         xfmr3(idx3(k3), BR_STATUS) = 0;
0241     end
0242 end
0243 
0244 %% combine 2-winding and 3-winding transformer data
0245 xfmr = [xfmr2; xfmr3];
0246 
0247 % %% delete out-of-service windings
0248 % k = find(xfmr(:, BR_STATUS) == 0);
0249 % xfmr(k, :) = [];
0250 % k = find(trans3(:,12) <= 0);
0251 % starbus(k, :) = [];
0252 
0253 %% finish adding the star point bus
0254 bus = [bus; starbus];
0255 if nt3 > 0
0256     warns{end+1} = sprintf('Added buses %d-%d as star-points for 3-winding transformers.', ...
0257         starbus(1, BUS_I), starbus(end, BUS_I));
0258     if verbose
0259         fprintf('Added buses %d-%d as star-points for 3-winding transformers.\n', ...
0260             starbus(1, BUS_I), starbus(end, BUS_I));
0261     end
0262 end
0263 if nargin > 6 && nargout > 3
0264     starbus_name = cell(nt3, 1);
0265     for k = 1:nt3
0266         starbus_name{k} = sprintf('STAR_POINT_XFMR_%d', k);
0267     end
0268     bus_name = [bus_name; starbus_name];
0269 end

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