Home > matpower7.0 > extras > maxloadlim > tests > t_varGen_case9.m

t_varGen_case9

PURPOSE ^

This function tests the implementation of the variable generators in the

SYNOPSIS ^

function t_varGen_case9(quiet)

DESCRIPTION ^

 This function tests the implementation of the variable generators in the
 IEEE 9 bus system

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function t_varGen_case9(quiet)
0002 % This function tests the implementation of the variable generators in the
0003 % IEEE 9 bus system
0004 
0005 %   MATPOWER
0006 %   Copyright (c) 2015-2016, Power Systems Engineering Research Center (PSERC)
0007 %   by Camille Hamon
0008 %
0009 %   This file is part of MATPOWER/mx-maxloadlim.
0010 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0011 %   See https://github.com/MATPOWER/mx-maxloadlim/ for more info.
0012 
0013 if nargin < 1
0014     quiet = 0;
0015 end
0016 define_constants;
0017 % Loading the case
0018 mpc = loadcase('case9');
0019 
0020 % Defining several load increase directions to be tested
0021 dir_all = [0 0 0 0 1 0 0 0 0;
0022     0 0 0 0 0 0 1 0 0;
0023     0 0 0 0 0 0 0 0 1;
0024     0 0 0 0 1 0 1 0 1;
0025     0 0 0 0 1 0 1 0 0;
0026     0 0 0 0 1 0 0 0 1;
0027     0 0 0 0 0 0 1 0 1];
0028 dir_var_gen_all = [0 1 0;
0029     0 0 1;
0030     0 1 1];
0031 idx_nonzero_loads = mpc.bus(:,PD) > 0;
0032 % Number of load increase directions
0033 nb_dir_load = size(dir_all,1);
0034 nb_dir_gen = size(dir_var_gen_all,1);
0035 % Message header
0036 t0 = 'case9: ';
0037 
0038 num_tests = nb_dir_load*nb_dir_gen; % we don't consider the direction with all zeros
0039 t_begin(num_tests, quiet);
0040 for i = 1:nb_dir_load
0041     dir_load = dir_all(i,:)';
0042     dir_load(~idx_nonzero_loads)=0;
0043     for j = 1:nb_dir_gen
0044         dir_var_gen = dir_var_gen_all(j,:)';
0045         idx_var_gen = find(dir_var_gen);
0046         dir_var_gen = dir_var_gen(idx_var_gen);
0047         % Normalizing with respect to both loads and gens
0048         gen_load_dir = [dir_load;dir_var_gen];
0049         dir_load = dir_load/norm(gen_load_dir);
0050         dir_var_gen = dir_var_gen/norm(gen_load_dir);
0051         % Find MLL in the direction of load and gen increase
0052         results_with_gens = maxloadlim(mpc,dir_load,'verbose',0,'idx_var_gen',idx_var_gen,'dir_var_gen',dir_var_gen);
0053         % Set gens to their values in previous results and re-run in
0054         % load space only
0055         mpc2 = mpc;
0056         mpc2.gen(:,PG) = results_with_gens.gen(:,PG);
0057         dir_load2 = dir_load/norm(dir_load);
0058         % Find MLL in the direction of load and gen increase
0059         results_without_gens = maxloadlim(mpc2,dir_load2,'verbose',0);
0060         % Compare the maximum loads
0061         mll_with_gen = results_with_gens.bus(:,PD);
0062         mll_without_gen = results_without_gens.bus(:,PD);
0063         % We compare with a precision of 1MW
0064         t = sprintf('%sLOAD: %s   GEN: %s',t0,mat2str(dir_load),mat2str(dir_var_gen));
0065         t_is(mll_with_gen,mll_without_gen,0,t);
0066     end
0067 end
0068 t_end

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