0001 function t_syngrid_vm(quiet, ntrials)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 if nargin < 2
0012 ntrials = 1;
0013 if nargin < 1
0014 quiet = 0;
0015 end
0016 end
0017
0018 num_tests = 2*3*5*ntrials;
0019 have_ipopt = have_fcn('ipopt');
0020
0021 t_begin(num_tests, quiet);
0022
0023
0024 mpcsmpl = loadcase('case_ACTIVSg2000');
0025 mpctopo = loadcase('case118');
0026
0027
0028 orig_state = warning;
0029 warning('off','all')
0030
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
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
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
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
0071 if all(status == 2)
0072 break
0073 end
0074 end
0075 test_array(r, N, t);
0076 end
0077 end
0078
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
0091 rtmp = rundcpf(r{k}, mpopt);
0092 check.dcpf(k) = rtmp.success;
0093
0094
0095 rtmp = rundcopf(r{k}, mpopt);
0096 check.dcopf(k) = rtmp.success;
0097
0098
0099 rtmp = runpf(r{k}, mpopt);
0100 check.acpf(k) = rtmp.success;
0101
0102
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