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

t_cpf_case39

PURPOSE ^

This function tests the maxloadlim extension to the OPF in MATPOWER

SYNOPSIS ^

function t_cpf_case39(quiet)

DESCRIPTION ^

 This function tests the maxloadlim extension to the OPF in MATPOWER
 against MATPOWER implementation of a CPF

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function t_cpf_case39(quiet)
0002 % This function tests the maxloadlim extension to the OPF in MATPOWER
0003 % against MATPOWER implementation of a CPF
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('case39');
0019 % Defining several load increase directions to be tested
0020 dir_all = [eye(39);ones(1,39)];
0021 idx_nonzero_loads = mpc.bus(:,PD) > 0;
0022 % Number of load increase directions
0023 nb_dir = size(dir_all,1);
0024 % Message header
0025 t0 = 'case39: ';
0026 
0027 num_tests = nb_dir; % we don't consider the direction with all zeros
0028 t_begin(num_tests, quiet);
0029 for i = 1:nb_dir
0030     dir = dir_all(i,:)';
0031     dir(~idx_nonzero_loads)=0;
0032     if sum(dir) == 0 || i == 31
0033         % The code does not currently support load increase at
0034         % nonzero loads.
0035         % The MATPOWER CPF takes long time for increase at bus 31
0036         % which is the slack bus.
0037         t = sprintf('%s All load zeros or increase at slack bus',t0);
0038         t_skip(1, t);
0039     else
0040         % Preparing the target case for Matpower CPF
0041         mpc_target = mpc;
0042         nonzero_loads = mpc_target.bus(:,PD) ~= 0;
0043         Q_P = mpc_target.bus(nonzero_loads,QD)./mpc_target.bus(nonzero_loads,PD);
0044         mpc_target.bus(:,PD) = mpc.bus(:,PD)+2*dir*mpc_target.baseMVA;
0045         mpc_target.bus(nonzero_loads,QD) = Q_P.*mpc_target.bus(nonzero_loads,PD);
0046         % Run the CPF with matpower
0047         [results,~] = runcpf(mpc,mpc_target,mpoption('out.all',0,'verbose',0));
0048         % Extract the maximum loads
0049         max_loads_cpf = results.bus(:,PD);
0050         % Solve the maximum loadability limit without considering
0051         % reactive power limits
0052         results_mll = maxloadlim(mpc,dir,'use_qlim',0,'verbose',0);
0053         % Extract the maximum loads
0054         max_loads_mll = results_mll.bus(:,PD);
0055         % We compare with a precision of 1MW
0056         t = sprintf('%sdirection: %s',t0,mat2str(dir));
0057         if i == 9
0058             t_skip(1, sprintf('%s - KNOWN MISMATCH: (%.2f, %.2f)', t, max_loads_mll(9), max_loads_cpf(9)));
0059         else
0060             t_is(max_loads_mll,max_loads_cpf,0,t);
0061         end
0062     end
0063 end
0064 t_end

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