0001 function t_varGen_case39(quiet)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 if nargin < 1
0014 quiet = 0;
0015 end
0016 define_constants;
0017
0018 mpc = loadcase('case39');
0019
0020
0021 dir_all = [eye(39);ones(1,39)];
0022 dir_var_gen_all = [zeros(9,1) eye(9);0 ones(1,9)];
0023 dir_var_gen_all(:,[1 2]) = dir_var_gen_all(:,[2 1]);
0024 idx_nonzero_loads = mpc.bus(:,PD) > 0;
0025
0026 nb_dir_load = size(dir_all,1);
0027 nb_dir_gen = size(dir_var_gen_all,1);
0028
0029 t0 = 'case39: ';
0030
0031 num_tests = nb_dir_load*nb_dir_gen;
0032 t_begin(num_tests, quiet);
0033 for i = 1:nb_dir_load
0034 dir_load = dir_all(i,:)';
0035 dir_load(~idx_nonzero_loads)=0;
0036 for j = 1:nb_dir_gen
0037 if sum(dir_load) == 0 || dir_load(31) ~= 0
0038
0039
0040 t = sprintf('%s All load zeros',t0);
0041 t_skip(1, t);
0042 else
0043 dir_var_gen = dir_var_gen_all(j,:)';
0044 idx_var_gen = find(dir_var_gen);
0045 dir_var_gen = dir_var_gen(idx_var_gen);
0046
0047 gen_load_dir = [dir_load;dir_var_gen];
0048 dir_load = dir_load/norm(gen_load_dir);
0049 dir_var_gen = dir_var_gen/norm(gen_load_dir);
0050
0051 results_with_gens = maxloadlim(mpc,dir_load,'verbose',0,'idx_var_gen',idx_var_gen,'dir_var_gen',dir_var_gen);
0052
0053
0054 mpc2 = mpc;
0055 mpc2.gen(:,PG) = results_with_gens.gen(:,PG);
0056 dir_load2 = dir_load/norm(dir_load);
0057
0058 results_without_gens = maxloadlim(mpc2,dir_load2,'verbose',0);
0059
0060 mll_with_gen = results_with_gens.bus(:,PD);
0061 mll_without_gen = results_without_gens.bus(:,PD);
0062
0063 t = sprintf('%sLOAD: %s GEN: %s',t0,mat2str(dir_load),mat2str(dir_var_gen));
0064 if i == 20 && j == 1
0065 t_skip(1, sprintf('%s - KNOWN MISMATCH: (%.2f, %.2f)', t, mll_with_gen(20), mll_without_gen(20)));
0066 else
0067 ok = t_is(mll_with_gen,mll_without_gen,0,t);
0068 end
0069 end
0070 end
0071 end
0072 t_end