Home > matpower7.0 > extras > syngrid > lib > t > t_sgvm_data2mpc.m

t_sgvm_data2mpc

PURPOSE ^

T_SGVM_DATA2MPC Tests for sgvm_data2mpc().

SYNOPSIS ^

function t_sgvm_data2mpc(quiet)

DESCRIPTION ^

T_SGVM_DATA2MPC  Tests for sgvm_data2mpc().

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function t_sgvm_data2mpc(quiet)
0002 %T_SGVM_DATA2MPC  Tests for sgvm_data2mpc().
0003 
0004 if nargin < 1
0005     quiet = 0;
0006 end
0007 
0008 t_begin(11, quiet);
0009 define_constants;
0010 data = sgvm_mpc2data(loadcase('case_ACTIVSg2000'));
0011 [~,topo] = sgvm_mpc2data(loadcase('case118'));
0012 
0013 t = 'default options : ';
0014 mpc = sgvm_data2mpc(data, topo);
0015 t_ok( all(ismember(mpc.branch(:,[BR_R, BR_X, BR_B, RATE_A, TAP, SHIFT]), ...
0016       [data.branch(:,1:3), round(data.branch(:,4)), data.branch(:,5:6)], 'rows')), [t, 'branch']);
0017 t_ok( all(ismember(mpc.gen(:,[QMAX, QMIN, PMAX, PMIN]), data.gen(:,2:end), 'rows')), [t, 'gen']);
0018 t_ok( ~all(ismember(mpc.bus(:,[PD, QD]), data.load, 'rows')), [t, 'load']);
0019 
0020 t = 'node direct : ';
0021 opt = struct('node', 'direct');
0022 mpc = sgvm_data2mpc(data, topo, opt);
0023 t_ok( all(ismember(mpc.branch(:,[BR_R, BR_X, BR_B, RATE_A, TAP, SHIFT]), ...
0024       [data.branch(:,1:3), round(data.branch(:,4)), data.branch(:,5:6)], 'rows')), [t, 'branch']);
0025 t_ok( all(ismember(mpc.gen(:,[QMAX, QMIN, PMAX, PMIN]), data.gen(:,2:end), 'rows')), [t, 'gen']);
0026 t_ok( all(ismember(mpc.bus(:,[PD, QD]), data.load, 'rows')), [t, 'load']);
0027 % test correct generator load pairing
0028 tmpref = zeros(size(data.gen,1),6);
0029 for k = 1:size(data.gen,1)
0030   tmpref(k,:) = [data.gen(k,2:end), data.load(data.gen(k,1),:)];
0031 end
0032 tmp = zeros(size(mpc.gen,1), 6);
0033 for k = 1:size(mpc.gen,1)
0034   tmp(k,:) = [mpc.gen(k,[QMAX, QMIN, PMAX, PMIN]), mpc.bus(mpc.gen(k,GEN_BUS),[PD, QD])];
0035 end
0036 t_ok( all(ismember(tmp, tmpref, 'rows')), [t, 'load + gen'])
0037 
0038 t = 'node direct (no genbus) : ';
0039 opt = struct('node', 'direct', 'usegenbus', 0);
0040 mpc = sgvm_data2mpc(data, topo, opt);
0041 t_ok( all(ismember(mpc.branch(:,[BR_R, BR_X, BR_B, RATE_A, TAP, SHIFT]), ...
0042       [data.branch(:,1:3), round(data.branch(:,4)), data.branch(:,5:6)], 'rows')), [t, 'branch']);
0043 t_ok( all(ismember(mpc.gen(:,[QMAX, QMIN, PMAX, PMIN]), data.gen(:,2:end), 'rows')), [t, 'gen']);
0044 t_ok( all(ismember(mpc.bus(:,[PD, QD]), data.load, 'rows')), [t, 'load']);
0045 % test generator load pairing
0046 tmpref = zeros(size(data.gen,1),6);
0047 for k = 1:size(data.gen,1)
0048   tmpref(k,:) = [data.gen(k,2:end), data.load(data.gen(k,1),:)];
0049 end
0050 tmp = zeros(size(mpc.gen,1), 6);
0051 for k = 1:size(mpc.gen,1)
0052   tmp(k,:) = [mpc.gen(k,[QMAX, QMIN, PMAX, PMIN]), mpc.bus(mpc.gen(k,GEN_BUS),[PD, QD])];
0053 end
0054 t_ok( ~all(ismember(tmp, tmpref, 'rows')), [t, 'load + gen'])
0055 
0056 t_end

Generated on Mon 24-Jun-2019 15:58:45 by m2html © 2005