Home > matpower7.1 > most > lib > t > t_most_mpopf.m

t_most_mpopf

PURPOSE ^

T_MOST_MPOPF Tests of deterministic multiperiod DC OPF problems

SYNOPSIS ^

function t_most_mpopf(quiet)

DESCRIPTION ^

T_MOST_MPOPF  Tests of deterministic multiperiod DC OPF problems

   Cases taken from most_ex5_mpopf.m.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function t_most_mpopf(quiet)
0002 %T_MOST_MPOPF  Tests of deterministic multiperiod DC OPF problems
0003 %
0004 %   Cases taken from most_ex5_mpopf.m.
0005 
0006 %   MOST
0007 %   Copyright (c) 2015-2020, Power Systems Engineering Research Center (PSERC)
0008 %   by Ray Zimmerman, PSERC Cornell
0009 %
0010 %   This file is part of MOST.
0011 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0012 %   See https://github.com/MATPOWER/most for more info.
0013 
0014 if nargin < 1
0015     quiet = 0;      %% verbose by default
0016 end
0017 
0018 ntests = 36;
0019 t_begin(ntests, quiet);
0020 
0021 if quiet
0022     verbose = 0;
0023 else
0024     verbose = 0;
0025 end
0026 % verbose = 2;
0027 
0028 if have_feature('octave')
0029     if have_feature('octave', 'vnum') >= 4
0030         file_in_path_warn_id = 'Octave:data-file-in-path';
0031     else
0032         file_in_path_warn_id = 'Octave:load-file-in-path';
0033     end
0034     s1 = warning('query', file_in_path_warn_id);
0035     warning('off', file_in_path_warn_id);
0036     s = warning('query', 'Octave:nearly-singular-matrix');
0037     warning('off', 'Octave:nearly-singular-matrix');
0038 end
0039 
0040 casefile = 'ex_case3b';
0041 solnfile =  't_most_mpopf_soln';
0042 soln = load(solnfile);
0043 mpopt = mpoption('verbose', verbose);
0044 mpopt = mpoption(mpopt, 'out.gen', 1);
0045 mpopt = mpoption(mpopt, 'model', 'DC');
0046 mpopt = mpoption(mpopt, 'most.solver', 'MIPS');
0047 mpopt = mpoption(mpopt, 'most.dc_model', 1);
0048 % mpopt = mpoption(mpopt, 'opf.violation', 1e-6, 'mips.gradtol', 1e-8, ...
0049 %         'mips.comptol', 1e-8, 'mips.costtol', 1e-8);
0050 if ~verbose
0051     mpopt = mpoption(mpopt, 'out.all', 0);
0052 end
0053 % mpopt = mpoption(mpopt, 'out.all', -1);
0054 
0055 %% load base case file
0056 mpc = loadcase(casefile);
0057 
0058 nb = size(mpc.bus, 1);
0059 nl = size(mpc.branch, 1);
0060 ng = size(mpc.gen, 1);
0061 
0062 xgd = loadxgendata('ex_xgd_ramp', mpc);
0063 [iwind, mpc, xgd] = addwind('ex_wind', mpc, xgd);
0064 profiles = getprofiles('ex_wind_profile_d', iwind);
0065 profiles = getprofiles('ex_load_profile', profiles);
0066 nt = size(profiles(1).values, 1);       % number of periods
0067 
0068 mpc_full = mpc;
0069 xgd_full = xgd;
0070 
0071 %%-----  Multiperiod DC OPF (w/ramp)  -----
0072 t = 'Multiperiod DC OPF w/ramp : ';
0073 mdi = loadmd(mpc, nt, xgd, [], [], profiles);
0074 mdo = most(mdi, mpopt);
0075 % EPg1 = mdo.results.ExpectedDispatch;    % active generation
0076 % Elam1 = mdo.results.GenPrices;          % nodal energy price
0077 t_is(mdo.results.success, 1, 12, [t 'success']);
0078 if verbose
0079     most_summary(mdo);
0080 end
0081 ms = most_summary(mdo);
0082 ex = soln.wramp;
0083 t_is(ms.f, ex.f, 1.8, [t 'f']);
0084 t_is(ms.Pg, ex.Pg, 3.5, [t 'Pg']);
0085 t_is(ms.Rup, ex.Rup, 2.5, [t 'Rup']);
0086 t_is(ms.Rdn, ex.Rdn, 2.5, [t 'Rdn']);
0087 t_is(ms.Pf, ex.Pf, 4, [t 'Pf']);
0088 t_is(ms.u, ex.u, 8, [t 'u']);
0089 t_is(ms.lamP, ex.lamP, 5, [t 'lamP']);
0090 t_is(ms.muF, ex.muF, 5, [t 'muF']);
0091 % wramp = most_summary(mdo);
0092 % keyboard;
0093 
0094 %%-----  Multiperiod DC OPF (w/ramp+wear/tear)  -----
0095 t = 'Multiperiod DC OPF w/ramp+wear/tear : ';
0096 xgd.RampWearCostCoeff(1:3) = 1;
0097 mdi = loadmd(mpc, nt, xgd, [], [], profiles);
0098 mdo = most(mdi, mpopt);
0099 % EPg1 = mdo.results.ExpectedDispatch;    % active generation
0100 % Elam1 = mdo.results.GenPrices;          % nodal energy price
0101 t_is(mdo.results.success, 1, 12, [t 'success']);
0102 if verbose
0103     most_summary(mdo);
0104 end
0105 ms = most_summary(mdo);
0106 ex = soln.wwear;
0107 t_is(ms.f, ex.f+35625, 0.5, [t 'f']);
0108 t_is(ms.Pg, ex.Pg, 2.8, [t 'Pg']);
0109 t_is(ms.Rup, ex.Rup, 2.5, [t 'Rup']);
0110 t_is(ms.Rdn, ex.Rdn, 2.5, [t 'Rdn']);
0111 t_is(ms.Pf, ex.Pf, 3, [t 'Pf']);
0112 t_is(ms.u, ex.u, 8, [t 'u']);
0113 t_is(ms.lamP, ex.lamP, 2.5, [t 'lamP']);
0114 t_is(ms.muF, ex.muF, 2, [t 'muF']);
0115 % wwear = most_summary(mdo);
0116 % keyboard;
0117 
0118 t = 'build model without solving : ';
0119 mpopt = mpoption(mpopt, 'most.build_model', 1, ...
0120                         'most.solve_model', 0, ...
0121                         'most.resolve_new_cost', 0);
0122 mdo = most(mdi, mpopt);
0123 t_ok(isfield(mdo, 'om'), [t '''om'' field']);
0124 t_ok(isfield(mdo, 'QP'), [t '''QP'' field']);
0125 t_ok(~isfield(mdo.QP, 'x'), [t 'no ''QP.x'' field']);
0126 t_ok(~isfield(mdo.QP, 'f'), [t 'no ''QP.f'' field']);
0127 t_ok(~isfield(mdo.QP, 'exitflag'), [t 'no ''QP.exitflag'' field']);
0128 t_ok(~isfield(mdo.QP, 'output'), [t 'no ''QP.output'' field']);
0129 t_ok(isfield(mdo.results, 'SetupTime'), [t '''results.SetupTime'' field']);
0130 t_ok(~isfield(mdo.results, 'success'), [t 'no ''results.success'' field']);
0131 
0132 t = 'solve previously built model : ';
0133 mpopt = mpoption(mpopt, 'most.build_model', 0, ...
0134                         'most.solve_model', 1, ...
0135                         'most.resolve_new_cost', 1);
0136 mdi1 = mdo;
0137 mdo = most(mdi1, mpopt);
0138 t_is(mdo.results.success, 1, 12, [t 'success']);
0139 if verbose
0140     most_summary(mdo);
0141 end
0142 ms = most_summary(mdo);
0143 ex = soln.wwear;
0144 t_is(ms.f, ex.f+35625, 0.5, [t 'f']);
0145 t_is(ms.Pg, ex.Pg, 2.8, [t 'Pg']);
0146 t_is(ms.Rup, ex.Rup, 2.5, [t 'Rup']);
0147 t_is(ms.Rdn, ex.Rdn, 2.5, [t 'Rdn']);
0148 t_is(ms.Pf, ex.Pf, 3, [t 'Pf']);
0149 t_is(ms.u, ex.u, 8, [t 'u']);
0150 t_is(ms.lamP, ex.lamP, 2.5, [t 'lamP']);
0151 t_is(ms.muF, ex.muF, 2, [t 'muF']);
0152 % wwear = most_summary(mdo);
0153 % keyboard;
0154 
0155 t = 'output model is copy of input model';
0156 mdo.om.add_var('test', 10);
0157 t_is(mdo.om.var.N, mdi1.om.var.N+10, 12, t);
0158 
0159 if have_feature('octave')
0160     warning(s1.state, file_in_path_warn_id);
0161     warning(s.state, 'Octave:nearly-singular-matrix');
0162 end
0163 
0164 t_end;
0165 
0166 % save t_most_mpopf_soln wramp wwear

Generated on Fri 09-Oct-2020 11:21:31 by m2html © 2005