PSSE_CONVERT_HVDC Convert HVDC data from PSS/E RAW to MATPOWER DCLINE = PSSE_CONVERT_HVDC(DC, BUS) Convert all two terminal HVDC line data read from a PSS/E RAW data file into MATPOWER format. Returns a dcline matrix for inclusion in a MATPOWER case struct. Inputs: DC : matrix of raw two terminal HVDC line data returned by PSSE_READ in data.twodc.num BUS : MATPOWER bus matrix Output: DCLINE : a MATPOWER dcline matrix suitable for inclusion in a MATPOWER case struct. See also PSSE_CONVERT.
0001 function dcline = psse_convert_hvdc(dc, bus) 0002 %PSSE_CONVERT_HVDC Convert HVDC data from PSS/E RAW to MATPOWER 0003 % DCLINE = PSSE_CONVERT_HVDC(DC, BUS) 0004 % 0005 % Convert all two terminal HVDC line data read from a PSS/E 0006 % RAW data file into MATPOWER format. Returns a dcline matrix for 0007 % inclusion in a MATPOWER case struct. 0008 % 0009 % Inputs: 0010 % DC : matrix of raw two terminal HVDC line data returned by 0011 % PSSE_READ in data.twodc.num 0012 % BUS : MATPOWER bus matrix 0013 % 0014 % Output: 0015 % DCLINE : a MATPOWER dcline matrix suitable for inclusion in 0016 % a MATPOWER case struct. 0017 % 0018 % See also PSSE_CONVERT. 0019 0020 % MATPOWER 0021 % Copyright (c) 2014-2016, Power Systems Engineering Research Center (PSERC) 0022 % by Yujia Zhu, PSERC ASU 0023 % and Ray Zimmerman, PSERC Cornell 0024 % Based on mpdcin.m and mpqhvdccal.m, written by: 0025 % Yujia Zhu, Jan 2014, yzhu54@asu.edu. 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 %% define named indices into bus, gen, branch matrices 0032 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ... 0033 VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus; 0034 c = idx_dcline; 0035 0036 nb = size(bus, 1); 0037 ndc = size(dc, 1); 0038 e2i = sparse(bus(:, BUS_I), ones(nb, 1), 1:nb, max(bus(:, BUS_I)), 1); 0039 if ~ndc 0040 dcline = []; 0041 return; 0042 end 0043 0044 %% extract data 0045 MDC = dc(:,2); % Control mode 0046 SETVL = dc(:,4); % depend on control mode: current or power demand 0047 VSCHD = dc(:,5); % scheduled compounded dc voltage 0048 ANMXR = dc(:,15); % nominal maximum rectifier firing angle 0049 ANMNR = dc(:,16); % nominal minimum rectifier firing angle 0050 GAMMX = dc(:,32); % nominal maximum inverter firing angle 0051 GAMMN = dc(:,33); % nominal minimum inverter firing angle 0052 SETVL = abs(SETVL); 0053 % Convert the voltage on rectifier side and inverter side 0054 % The value is calculated as basekV/VSCHD 0055 % basekV is the bus base voltage, VSCHD is the scheduled compounded 0056 % voltage 0057 dcline = zeros(ndc, c.LOSS1); % initiate the hvdc data format 0058 indr = dc(:,13); % rectifier end bus number 0059 indi = dc(:,30); % inverter end bus number 0060 dcind = [indr indi]; 0061 % bus nominal voltage 0062 Vr = bus(e2i(indr), VM); 0063 Vi = bus(e2i(indi), VM); 0064 %% Calculate the real power input at the from end 0065 PMW = zeros(ndc, 1); 0066 for i = 1:ndc 0067 if MDC(i) == 1 0068 PMW(i) = SETVL(i); % SETVL is the desired real power demand 0069 elseif MDC(i) == 2; 0070 PMW(i) = SETVL(i)*VSCHD(i)/1000; % SETVL is the current in amps (need devide 1000 to convert to MW) 0071 else PMW(i) = 0; 0072 end 0073 end 0074 %% calculate reactive power limits 0075 [Qrmin,Qrmax] = psse_convert_hvdc_Qlims(ANMXR,ANMNR,PMW); %% rectifier end 0076 [Qimin,Qimax] = psse_convert_hvdc_Qlims(GAMMX,GAMMN,PMW); %% inverter end 0077 %% calculate the loss coefficient (Only consider the l1) 0078 % l1 = P'.*RDC; 0079 0080 %% conclude all info 0081 status = ones(ndc, 1); 0082 status(MDC==0) = 0; %% set status of blocked HVDC lines to zero 0083 % dcline(:,[1 2 3 4 5 8 9 10 11 12 13 14 15]) = [indr,indi,status,PMW, PMW, Vr, Vi,0.85*PMW, 1.15*PMW, Qrmin, Qrmax, Qimin, Qimax]; 0084 dcline(:, [c.F_BUS c.T_BUS c.BR_STATUS c.PF c.PT c.VF c.VT ... 0085 c.PMIN c.PMAX c.QMINF c.QMAXF c.QMINT c.QMAXT]) = ... 0086 [indr indi status PMW PMW Vr Vi 0.85*PMW 1.15*PMW Qrmin Qrmax Qimin Qimax]; 0087 0088 0089 function [Qmin, Qmax] = psse_convert_hvdc_Qlims(alphamax,alphamin,P) 0090 %PSSE_CONVERT_HVDC_QLIMS calculate HVDC line reactive power limits 0091 % 0092 % [Qmin, Qmax] = psse_convert_hvdc_Qlims(alphamax,alphamin,P) 0093 % 0094 % Inputs: 0095 % alphamax : maximum firing angle 0096 % alphamin : minimum steady-state rectifier firing angle 0097 % P : real power demand 0098 % Outputs: 0099 % Qmin : lower limit of reactive power 0100 % Qmax : upper limit of reactive power 0101 % 0102 % Note: 0103 % This function calculates the reactive power at the rectifier or inverter 0104 % end. It is assumed the maximum overlap angle is 60 degree (see 0105 % Kimbark's book). The maximum reactive power is calculated with the 0106 % power factor: 0107 % pf = acosd(0.5*(cosd(alphamax(i))+cosd(60))), 0108 % where, 60 is the maximum delta angle. 0109 0110 len = length(alphamax); 0111 phi = zeros(size(alphamax)); 0112 Qmin = phi; 0113 Qmax = phi; 0114 for i = 1:len 0115 %% minimum reactive power calculated under assumption of no overlap angle 0116 %% i.e. power factor equals to tan(alpha) 0117 Qmin(i) = P(i)*tand(alphamin(i)); 0118 0119 %% maximum reactive power calculated when overlap angle reaches max 0120 %% value (60 deg). I.e. 0121 %% cos(phi) = 1/2*(cos(alpha)+cos(delta)) 0122 %% Q = P*tan(phi) 0123 phi(i) = acosd(0.5*(cosd(alphamax(i))+cosd(60))); 0124 Qmax(i) = P(i)*tand(phi(i)); 0125 if Qmin(i)<0 0126 Qmin(i) = -Qmin(i); 0127 end 0128 if Qmax(i)<0 0129 Qmax(i) = -Qmax(i); 0130 end 0131 end