Home > matpower7.0 > lib > t > t_totcost.m

t_totcost

PURPOSE ^

T_TOTCOST Tests for code in TOTCOST.

SYNOPSIS ^

function t_totcost(quiet)

DESCRIPTION ^

T_TOTCOST  Tests for code in TOTCOST.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function t_totcost(quiet)
0002 %T_TOTCOST  Tests for code in TOTCOST.
0003 
0004 %   MATPOWER
0005 %   Copyright (c) 2010-2016, Power Systems Engineering Research Center (PSERC)
0006 %   by Ray Zimmerman, PSERC Cornell
0007 %
0008 %   This file is part of MATPOWER.
0009 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0010 %   See https://matpower.org for more info.
0011 
0012 if nargin < 1
0013     quiet = 0;
0014 end
0015 
0016 n_tests = 22;
0017 
0018 t_begin(n_tests, quiet);
0019 
0020 %% define named indices into data matrices
0021 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0022     MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0023     QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0024 [PW_LINEAR, POLYNOMIAL, MODEL, STARTUP, SHUTDOWN, NCOST, COST] = idx_cost;
0025 
0026 %% generator cost data
0027 %    1    startup    shutdown    n    x1    y1    ...    xn    yn
0028 %    2    startup    shutdown    n    c(n-1)    ...    c0
0029 gencost = [
0030     2    0    0    3    0.01    0.1    1    0    0    0    0    0;
0031     2    0    0    5    0.0006    0.005    0.04    0.3    2    0    0    0;
0032     1    0    0    4    0    0    10    200    20    600    30    1200;
0033     1    0    0    4    -30    -2400    -20    -1800    -10    -1000    0    0;
0034 ];
0035 
0036 t = 'totcost - quadratic';
0037 t_is(totcost(gencost, [0;0;0;0]), [1;2;0;0], 8, t);
0038 t_is(totcost(gencost, [1;0;0;0]), [1.11;2;0;0], 8, t);
0039 t_is(totcost(gencost, [2;0;0;0]), [1.24;2;0;0], 8, t);
0040 
0041 t = 'totcost - 4th order polynomial';
0042 t_is(totcost(gencost, [0;0;0;0]), [1;2;     0;0], 8, t);
0043 t_is(totcost(gencost, [0;1;0;0]), [1;2.3456;0;0], 8, t);
0044 t_is(totcost(gencost, [0;2;0;0]), [1;2.8096;0;0], 8, t);
0045 
0046 t = 'totcost - pwl (gen)';
0047 t_is(totcost(gencost, [0;0;-10;0 ]), [1;2;-200;0], 8, t);
0048 t_is(totcost(gencost, [0;0;5;0 ]),   [1;2;100;0], 8, t);
0049 t_is(totcost(gencost, [0;0;10;0]),   [1;2;200;0], 8, t);
0050 t_is(totcost(gencost, [0;0;15;0]),   [1;2;400;0], 8, t);
0051 t_is(totcost(gencost, [0;0;20;0]),   [1;2;600;0], 8, t);
0052 t_is(totcost(gencost, [0;0;25;0]),   [1;2;900;0], 8, t);
0053 t_is(totcost(gencost, [0;0;30;0]),   [1;2;1200;0], 8, t);
0054 t_is(totcost(gencost, [0;0;35;0]),   [1;2;1500;0], 8, t);
0055 
0056 t = 'totcost - pwl (load)';
0057 t_is(totcost(gencost, [0;0;0;10 ]), [1;2;0;1000], 8, t);
0058 t_is(totcost(gencost, [0;0;0;-5 ]), [1;2;0;-500], 8, t);
0059 t_is(totcost(gencost, [0;0;0;-10]), [1;2;0;-1000], 8, t);
0060 t_is(totcost(gencost, [0;0;0;-15]), [1;2;0;-1400], 8, t);
0061 t_is(totcost(gencost, [0;0;0;-20]), [1;2;0;-1800], 8, t);
0062 t_is(totcost(gencost, [0;0;0;-25]), [1;2;0;-2100], 8, t);
0063 t_is(totcost(gencost, [0;0;0;-30]), [1;2;0;-2400], 8, t);
0064 t_is(totcost(gencost, [0;0;0;-35]), [1;2;0;-2700], 8, t);
0065 
0066 t_end;

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