Home > matpower5.0 > t > t_printpf.m

t_printpf

PURPOSE ^

T_PRINTPF Tests for PRINTPF.

SYNOPSIS ^

function t_printpf(quiet)

DESCRIPTION ^

T_PRINTPF  Tests for PRINTPF.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function t_printpf(quiet)
0002 %T_PRINTPF  Tests for PRINTPF.
0003 
0004 %   MATPOWER
0005 %   $Id: t_printpf.m 2495 2014-12-17 18:55:41Z ray $
0006 %   by Ray Zimmerman, PSERC Cornell
0007 %   Copyright (c) 2014 by Power System Engineering Research Center (PSERC)
0008 %
0009 %   This file is part of MATPOWER.
0010 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0011 %
0012 %   MATPOWER is free software: you can redistribute it and/or modify
0013 %   it under the terms of the GNU General Public License as published
0014 %   by the Free Software Foundation, either version 3 of the License,
0015 %   or (at your option) any later version.
0016 %
0017 %   MATPOWER is distributed in the hope that it will be useful,
0018 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0019 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0020 %   GNU General Public License for more details.
0021 %
0022 %   You should have received a copy of the GNU General Public License
0023 %   along with MATPOWER. If not, see <http://www.gnu.org/licenses/>.
0024 %
0025 %   Additional permission under GNU GPL version 3 section 7
0026 %
0027 %   If you modify MATPOWER, or any covered work, to interface with
0028 %   other modules (such as MATLAB code and MEX-files) available in a
0029 %   MATLAB(R) or comparable environment containing parts covered
0030 %   under other licensing terms, the licensors of MATPOWER grant
0031 %   you additional permission to convey the resulting work.
0032 
0033 if nargin < 1
0034     quiet = 0;
0035 end
0036 
0037 num_tests = 2;
0038 
0039 t_begin(num_tests, quiet);
0040 
0041 [F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, RATE_C, ...
0042     TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST, ...
0043     ANGMIN, ANGMAX, MU_ANGMIN, MU_ANGMAX] = idx_brch;
0044 
0045 casefile = 't_auction_case';
0046 if quiet
0047     verbose = 0;
0048 else
0049     verbose = 0;
0050 end
0051 if have_fcn('octave')
0052     s1 = warning('query', 'Octave:load-file-in-path');
0053     warning('off', 'Octave:load-file-in-path');
0054 end
0055 s2 = warning('query', 'MATLAB:singularMatrix');
0056 warning('off', 'MATLAB:singularMatrix');
0057 
0058 t = 'printpf : ';
0059 mpopt = mpoption('opf.violation', 1e-6, 'mips.gradtol', 1e-8, ...
0060         'mips.comptol', 1e-8, 'mips.costtol', 1e-9);
0061 mpopt = mpoption(mpopt, 'out.all', 0, 'verbose', verbose);
0062 mpopt = mpoption(mpopt, 'out.sys_sum', 1);
0063 mpopt = mpoption(mpopt, 'out.area_sum', 1);
0064 mpopt = mpoption(mpopt, 'out.bus', 1);
0065 mpopt = mpoption(mpopt, 'out.branch', 1);
0066 mpopt = mpoption(mpopt, 'out.gen', 1);
0067 mpopt = mpoption(mpopt, 'out.lim.all', 2);
0068 mpopt = mpoption(mpopt, 'opf.ac.solver', 'MIPS');
0069 mpopt = mpoption(mpopt, 'opf.dc.solver', 'MIPS');
0070 
0071 %% load case
0072 mpc = loadcase(casefile);
0073 mpc.gencost(1:5, 1:7) = ones(5, 1) * [2 0 0 3 0.1 45 0];
0074 mpc.branch(18, RATE_A) = 25;
0075 
0076 %% set up file names
0077 [pathstr, name, ext] = fileparts(which('t_printpf'));
0078 
0079 fnameac = 'pretty_print_acopf.txt';
0080 fnamedc = 'pretty_print_dcopf.txt';
0081 fname = 'pretty_print';
0082 rn = fix(1e9*rand);
0083 tmpfnameac = sprintf('%s_acopf_%d.txt', fname, rn);
0084 tmpfnamedc = sprintf('%s_dcopf_%d.txt', fname, rn);
0085 
0086 r = runopf(mpc, mpopt, tmpfnameac);
0087 got = fileread(tmpfnameac);
0088 if size(got, 1) ~= 1    %% transpose if needed for Octave 3.4
0089     got = got';
0090 end
0091 got = strrep(got, char([13 10]), char(10));             %% Win to Unix EOL chars
0092 got = regexprep(got, 'Converged in (.*) seconds', 'Converged in 0.00 seconds');
0093 got = strrep(got, ' -0.0 ', '  0.0 ');
0094 got = strrep(got, sprintf(' -0.0\n'), sprintf('  0.0\n'));
0095 got = strrep(got, ' -0.00 ', '  0.00 ');
0096 got = strrep(got, sprintf(' -0.00\n'), sprintf('  0.00\n'));
0097 got = strrep(got, ' -0.000 ', '  0.000 ');
0098 got = strrep(got, ' -0.000*', '  0.000*');
0099 expected = fileread(fnameac);
0100 expected = strrep(expected, char([13 10]), char(10));   %% Win to Unix EOL chars
0101 if size(expected, 1) ~= 1   %% transpose if needed for Octave 3.4
0102     expected = expected';
0103 end
0104 t_ok(strcmp(got, expected), [t 'standard AC OPF']);
0105 delete(tmpfnameac);
0106 
0107 r = rundcopf(mpc, mpopt, tmpfnamedc);
0108 got = fileread(tmpfnamedc);
0109 if size(got, 1) ~= 1    %% transpose if needed for Octave 3.4
0110     got = got';
0111 end
0112 got = strrep(got, char([13 10]), char(10));             %% Win to Unix EOL chars
0113 got = regexprep(got, 'Converged in (.*) seconds', 'Converged in 0.00 seconds');
0114 got = strrep(got, ' -0.0 ', '  0.0 ');
0115 got = strrep(got, sprintf(' -0.0\n'), sprintf('  0.0\n'));
0116 got = strrep(got, ' -0.00 ', '  0.00 ');
0117 got = strrep(got, sprintf(' -0.00\n'), sprintf('  0.00\n'));
0118 got = strrep(got, ' -0.000 ', '  0.000 ');
0119 got = strrep(got, ' -0.000*', '  0.000*');
0120 got = strrep(got, '51.66 $/MWh @ bus 12', '51.66 $/MWh @ bus 13');
0121 got = strrep(got, '51.66 $/MWh @ bus 16', '51.66 $/MWh @ bus 13');
0122 got = strrep(got, '51.66 $/MWh @ bus 17', '51.66 $/MWh @ bus 13');
0123 got = strrep(got, '53.05 $/MWh @ bus 18', '53.05 $/MWh @ bus 15');
0124 got = strrep(got, '53.05 $/MWh @ bus 19', '53.05 $/MWh @ bus 15');
0125 got = strrep(got, '53.05 $/MWh @ bus 20', '53.05 $/MWh @ bus 15');
0126 expected = fileread(fnamedc);
0127 expected = strrep(expected, char([13 10]), char(10));   %% Win to Unix EOL chars
0128 if size(expected, 1) ~= 1   %% transpose if needed for Octave 3.4
0129     expected = expected';
0130 end
0131 t_ok(strcmp(got, expected), [t 'standard DC OPF']);
0132 delete(tmpfnamedc);
0133 
0134 if have_fcn('octave')
0135     warning(s1.state, 'Octave:load-file-in-path');
0136 end
0137 warning(s2.state, 'MATLAB:singularMatrix');
0138 
0139 t_end;

Generated on Mon 26-Jan-2015 15:21:31 by m2html © 2005