0001 function t_sgvm_add_shunts(quiet)
0002
0003
0004 if nargin < 1
0005 quiet = 0;
0006 end
0007
0008
0009 if have_fcn('octave')
0010 if have_fcn('octave', 'vnum') >= 4
0011 file_in_path_warn_id = 'Octave:data-file-in-path';
0012 else
0013 file_in_path_warn_id = 'Octave:load-file-in-path';
0014 end
0015 s1 = warning('query', file_in_path_warn_id);
0016 warning('off', file_in_path_warn_id);
0017 end
0018
0019 t_begin(7, quiet);
0020
0021 define_constants;
0022
0023 mpc = loadcase('case_ACTIVSg200');
0024 e2i = sparse(mpc.bus(:,BUS_I), 1, 1:200);
0025 mpc.bus(:,BUS_I) = e2i(mpc.bus(:,BUS_I));
0026 mpc.branch(:, [F_BUS, T_BUS]) = e2i(mpc.branch(:, [F_BUS, T_BUS]));
0027 mpc.gen(:,GEN_BUS) = e2i(mpc.gen(:,GEN_BUS));
0028 mpc.bus(:, BS) = 0;
0029 mpc.bus(:,VMAX) = 1.03;
0030 mpc.bus(:,VMIN) = 0.97;
0031
0032 opt = sgvm_shuntsopts();
0033
0034 t = 'default run : ';
0035 [out, bsh] = sgvm_add_shunts(mpc);
0036 tmp = load('t_sgvm_shunts_default_run.mat');
0037 t_is(bsh, tmp.bsh, 4, [t, 'bsh'])
0038 t_ok(min(abs(bsh(bsh~=0))) >= opt.tmag, [t, 'min abs(bsh)'])
0039 t_ok(min(out.bus(:,VM)) >= 0.95 + opt.shift_in, [t, 'VMIN'])
0040 t_ok(max(out.bus(:,VM)) <= 1.05 - opt.shift_in, [t, 'VMAX'])
0041
0042 t = 'altered options : ';
0043 opt = struct('shift_in', opt.shift_in+0.005, 'tmag', min(abs(bsh(bsh~=0))) + 0.1);
0044 [out, bsh] = sgvm_add_shunts(mpc, [], opt);
0045 t_ok(min(abs(bsh(bsh~=0))) >= opt.tmag, [t, 'min abs(bsh)'])
0046 t_ok(min(out.bus(:,VM)) >= 0.95 + opt.shift_in, [t, 'VMIN'])
0047 t_ok(max(out.bus(:,VM)) <= 1.05 - opt.shift_in, [t, 'VMAX'])
0048
0049 t_end
0050
0051
0052 if have_fcn('octave')
0053 warning(s1.state, file_in_path_warn_id);
0054 end