I am sharanya Jaganathan and i am Master student at Tennesse Tech
University.
I am using the matpower code for my project on optimal power flow. I
have a problem in running the optimal power flow.
Nature of problem:
Now my system is 12 bus system so using the same format as yours for
9 bus i have developed the input data but when i run the runopf it
gives me an error with the load case. The error is as per the
attachement.
Please find attached herewith the input data for 12 bus system and
the error when using the command runopf.
since i am using a new 12 bus system hence the name of runofp has
been changed to runopf1 which is what i am created.
Waiting for a favourable response.
Regards,
Sharanya
Error using ==> loadcase
loadcase: syntax error or undefined data matrix(ices) in the file
Error using ==> case12
Too many output arguments.
Error in ==> runopf1 at 45
[baseMVA, bus, gen, branch, areas, gencost] = loadcase(casename);
function [baseMVA, bus, gen, branch, gencost] = case12
%CASE9 Power flow data for 12 bus, 4 generator case.
% Please see 'help caseformat' for details on the case file format.
%
% MATPOWER
% $Id: case9.m,v 1.7 2007/09/17 16:07:48 ray Exp $
%%----- Power Flow Data -----%%
%% system MVA base
baseMVA = 100;
%% bus data
% bus_i type Pd Qd Gs Bs area Vm Va
baseKV zone Vmax Vmin
bus = [
1 1 9.0 4.0 0 0 1 1 0
11 1 1.1 0.9;
2 1 0.0 0.0 0 0 1 1 0
11 1 1.1 0.9;
3 1 1.5 1.2 0 0 0 1 0
11 1 1.1 0.9;
4 1 0.0 0.0 0 0 1 1 0
11 1 1.1 0.9;
5 1 1.2 0.6 0 0 1 1 0
11 1 1.1 0.9;
6 1 1.4 0.9 0 0 1 1 0
11 1 1.1 0.9;
7 1 0.0 0.0 0 0 1 1 0
11 1 1.1 0.9;
8 1 1.1 0.9 0 0 1 1 0
11 1 1.1 0.9;
9 1 0.0 0.0 0 0 1 1 0
11 1 1.1 0.9;
10 1 9.0 4.0 0 0 1 1 0 11 1 1.1 0.9;
11 1 9.0 4.0 0 0 1 1 0 11 1 1.1 0.9;
12 1 8.0 5.0 0 0 1 1 0 11 1 1.1 0.9;
];
%% generator data
% bus Pg Qg Qmax Qmin Vg mBase status Pmax Pmin
gen = [
1 9 4 4 0 1 100 1 9 0;
5 1.2 6 4 0 1 100 1 9 0;
10 9 4 0.6 0 1 100 1 1.2 0;
11 9 4 4 0 1 100 1 9 0;
];
%% branch data
% fbus tbus r x b rateA rateB rateC ratio angle
status
branch = [
1 2 0 0.3 0 30 30 30
0 0 1;
2 3 0.48 0.3 0.0008 100 100 100 0 0
1;
2 5 0.24 0.15 0.0004 14 14 14 0
0 1;
2 6 0.72 0.45 0.001 100 100 100 0 0
1;
3 4 0.64 0.4 0.001 100 100 100
0 0 1;
3 6 0.64 0.4 0.001 100 100 100
0 0 1;
4 6 0.48 0.3 0.0008 100 100 100 0
0 1;
4 9 0.66 0.35 0.0009 40 40 40 0
0 1;
4 10 0 0.3 0 30 30 30 0 0
1;
5 7 0.688 0.43 0.0006 100 100 100 0
0 1;
6 8 0.768 0.48 0 100 100 100
0 0 1;
7 8 0.56 0.35 0.0008 100 100 100
0 0 1;
7 11 0 0.3 0 30 30 30
0 0 1;
8 9 0.768 0.48 0 100 100 100
0 0 1;
9 12 0 0.1 0 90 90 90
0 0 1;
];
%%----- OPF Data -----%%
%% area data
areas = [1 2;];
%% generator cost data
% 1 startup shutdown n x1 y1 ... xn
yn
% 2 startup shutdown n c(n-1) ... c0
gencost = [
2 1500 0 3 0.3 10 120;
2 2000 0 3 0.4 10.2 100;
2 3000 0 3 0.1 9.8 100;
2 4000 0 3 0.2 9.6 300;
];
return;
function [MVAbase, bus, gen, gencost, branch, f, success, et] = ...
runopf1(casename, mpopt, fname, solvedcase)
%RUNOPF Runs an optimal power flow.
%
% [baseMVA, bus, gen, gencost, branch, f, success, et] = ...
% runopf(casename, mpopt, fname, solvedcase)
%
% Runs an optimal power flow and optionally returns the solved
values in
% the data matrices, the objective function value, a flag which is
true if
% the algorithm was successful in finding a solution, and the
elapsed time
% in seconds. All input arguments are optional. If casename is
provided it
% specifies the name of the input data file or struct (see also
'help
% caseformat' and 'help loadcase') containing the opf data. The
default
% value is 'case9'. If the mpopt is provided it overrides the
default
% MATPOWER options vector and can be used to specify the solution
% algorithm and output options among other things (see 'help
mpoption' for
% details). If the 3rd argument is given the pretty printed output
will be
% appended to the file whose name is given in fname. If solvedcase
is
% specified the solved case will be written to a case file in
MATPOWER
% format with the specified name. If solvedcase ends with '.mat'
it saves
% the case as a MAT-file otherwise it saves it as an M-file.
% MATPOWER
% $Id: runopf.m,v 1.8 2005/01/14 17:22:24 ray Exp $
% by Ray Zimmerman, PSERC Cornell
% Copyright (c) 1996-2005 by Power System Engineering Research
Center (PSERC)
% See http://www.pserc.cornell.edu/matpower/ for more info.
%%----- initialize -----
%% default arguments
if nargin < 4
solvedcase = ''; %% don't save solved case
if nargin < 3
fname = ''; %% don't print results to a file
if nargin < 2
mpopt = mpoption; %% use default options
if nargin < 1
casename = 'case12'; %% default data file is 'case9.m'
end
end
end
end
%% read data
[baseMVA, bus, gen, branch, areas, gencost] = loadcase1(casename);
%%----- run the optimal power flow -----
[bus, gen, branch, f, success, info, et] = opf(baseMVA, bus, gen,
branch, ...
areas, gencost, mpopt);
%%----- output results -----
if fname
[fd, msg] = fopen(fname, 'at');
if fd == -1
error(msg);
else
printpf(baseMVA, bus, gen, branch, f, success, et, fd, mpopt);
fclose(fd);
end
end
printpf(baseMVA, bus, gen, branch, f, success, et, 1, mpopt);
%% save solved case
if solvedcase
savecase(solvedcase, baseMVA, bus, gen, branch, areas, gencost);
end
%% this is just to prevent it from printing baseMVA
%% when called with no output arguments
if nargout, MVAbase = baseMVA; end
return;