Home > matpower7.0 > extras > syngrid > lib > t > t_syngrid_vm.m

t_syngrid_vm

PURPOSE ^

T_SYNGRID_VM Tests for syngrid() variations mode.

SYNOPSIS ^

function t_syngrid_vm(quiet, ntrials)

DESCRIPTION ^

T_SYNGRID_VM  Tests for syngrid() variations mode.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function t_syngrid_vm(quiet, ntrials)
0002 %T_SYNGRID_VM  Tests for syngrid() variations mode.
0003 
0004 %   SynGrid
0005 %   Copyright (c) 2017-2018, Power Systems Engineering Research Center (PSERC)
0006 %   by Ray Zimmerman, PSERC Cornell
0007 %
0008 %   This file is part of SynGrid.
0009 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0010 
0011 if nargin < 2
0012   ntrials = 1;
0013   if nargin < 1
0014       quiet = 0;
0015   end
0016 end
0017 % rng('default')
0018 num_tests = 2*3*5*ntrials;
0019 have_ipopt = have_fcn('ipopt');
0020 
0021 t_begin(num_tests, quiet);
0022 
0023 %% setup
0024 mpcsmpl = loadcase('case_ACTIVSg2000');
0025 mpctopo = loadcase('case118');
0026 
0027 %% disable warnings
0028 orig_state = warning;
0029 warning('off','all')
0030 %% test
0031 for robust = 1:ntrials
0032 for solver = {'MIPS', 'IPOPT'}
0033     if strcmp(solver{:}, 'IPOPT') && ~have_ipopt
0034         t_skip(3*5, 'Ipopt not available');
0035         continue
0036     end
0037     mpopt = mpoption('opf.ac.solver', solver{:});
0038     sgopt = sg_options(struct('mpopt', mpopt, ...
0039                             'vm', struct (...
0040                               'ea', struct('initfill', 1))));
0041 %   sgopt.vm.shunts.verbose = 1;
0042     
0043     t = sprintf('variations mode with nsw topology (solver %s): ', solver{:});
0044     N = 50;
0045     while true
0046         [r, status] = syngrid(N, mpcsmpl, sgopt);
0047         % check that all cases successfully completed.
0048         if all(status == 2)
0049             break
0050         end
0051     end
0052     test_array(r, N, t);
0053     
0054     t = sprintf('variations mode with TOPO as matrix (solver %s): ', solver{:});
0055     [~, topo] = sgvm_mpc2data(mpctopo);
0056     N = length(unique(topo(:)));
0057     while true
0058         [r, status] = syngrid(topo, mpcsmpl, sgopt);
0059         % check that all cases successfully completed.
0060         if all(status == 2)
0061             break
0062         end
0063     end
0064     test_array(r, N, t);
0065     
0066     t = sprintf('variations mode with TOPO as mpc (solver %s): ', solver{:});
0067     N = size(mpctopo.bus, 1);
0068     while true
0069         [r, status] = syngrid(mpctopo, mpcsmpl, sgopt);
0070         % check that all cases successfully completed.
0071         if all(status == 2)
0072             break
0073         end
0074     end
0075     test_array(r, N, t);
0076 end
0077 end
0078 %% re-enable warnings
0079 warning(orig_state);
0080 
0081 t_end;
0082 
0083 function test_array(r, N, t)
0084 t_ok( all(cellfun(@(x) size(x.bus,1) == N, r)), [t 'size']);
0085 mpopt = mpoption('out.all', 0, 'verbose', 0);
0086 fv    = false(length(r), 1);
0087 check = struct('dcpf', fv, 'dfopf', fv, 'acpf', fv, 'acopf', fv);
0088 labels= {'DC PF', 'DC OPF', 'AC PF', 'AC OPF'};
0089 for k = 1:length(r)
0090     % DC PF
0091     rtmp = rundcpf(r{k}, mpopt);
0092     check.dcpf(k) = rtmp.success;
0093 
0094     % DC OPF
0095     rtmp = rundcopf(r{k}, mpopt);
0096     check.dcopf(k) = rtmp.success;
0097 
0098     % AC PF
0099     rtmp = runpf(r{k}, mpopt);
0100     check.acpf(k) = rtmp.success;
0101 
0102     % AC OPF
0103     rtmp = runopf(r{k}, mpopt);
0104     check.acopf(k) = rtmp.success;
0105 end
0106 for k = labels
0107     field = lower(k{:}(~isspace(k{:})));
0108     if strcmp(field, 'dcopf') && ~isempty(strfind(t, 'MIPS')) && ~all(check.(field))
0109         t_skip(1, 'Known Issue: Skipping DC OPF check with SynGrid Solver MIPS.');
0110     else
0111         t_ok( all(check.(field)), [t k{:} ' success']);
0112     end
0113 end

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