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

t_cpf_case9

PURPOSE ^

This function tests the maxloadlim extension to the OPF in MATPOWER

SYNOPSIS ^

function t_cpf_case9(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_case9(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('case9');
0019 % Defining several load increase directions to be tested
0020 dir_all = [0 0 0 0 1 0 0 0 0;
0021     0 0 0 0 0 0 1 0 0;
0022     0 0 0 0 0 0 0 0 1;
0023     0 0 0 0 1 0 1 0 1;
0024     0 0 0 0 1 0 1 0 0;
0025     0 0 0 0 1 0 0 0 1;
0026     0 0 0 0 0 0 1 0 1];
0027 % Number of load increase directions
0028 nb_dir = size(dir_all,1);
0029 % Message header
0030 t0 = 'case9: ';
0031 
0032 num_tests = nb_dir; % we don't consider the direction with all zeros
0033 t_begin(num_tests, quiet);
0034 for i = 1:nb_dir
0035     % Preparing the target case for Matpower CPF
0036     dir = dir_all(i,:)';
0037     mpc_target = mpc;
0038     nonzero_loads = mpc_target.bus(:,PD) ~= 0;
0039     Q_P = mpc_target.bus(nonzero_loads,QD)./mpc_target.bus(nonzero_loads,PD);
0040     mpc_target.bus(:,PD) = mpc_target.bus(:,PD)+2*dir*mpc_target.baseMVA;
0041     mpc_target.bus(nonzero_loads,QD) = Q_P.*mpc_target.bus(nonzero_loads,PD);
0042     % Run the CPF with matpower
0043     [results,~] = runcpf(mpc,mpc_target,mpoption('out.all',0,'verbose',0));
0044     % Extract the maximum loads
0045     max_loads_cpf = results.bus(:,PD);
0046     % Solve the maximum loadability limit without considering
0047     % reactive power limits
0048     results_mll = maxloadlim(mpc,dir,'use_qlim',0,'verbose',0);
0049     % Extract the maximum loads
0050     max_loads_mll = results_mll.bus(:,PD);
0051     % We compare with a precision of 1MW
0052     t = sprintf('%sdirection: %s',t0,mat2str(dir));
0053     t_is(max_loads_cpf,max_loads_mll,0,t);
0054 end
0055 t_end

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