Hi Ray,
Sure I will take care of it.
Niccolò,
As I don't have 6.02b2 right now, I did a quick check on v5.1, and did see
the issue you brought up. The state estimation results are actually
correctly presented in the last section of the screen output, where you can
see the Pg2=0.3034 pu, Pg3=0.1336 pu. So the gen, load and losses are
balanced. The Pg2 and Pg3 values you see in the 'Generator Data' output
section are actually the default values from the 3-bus case, and appear to
be inbalanced with load. The reason Pg2 and Pg3 values do not get updated in
the 'Generator Data' output section is that, to output the power flow
solution in a nice format, I simply took advantage of the MATPOWER function
'pfsoln' to update bus, gen, branch data structures to match power flow
solution. This function however only updates Pg for the slack bus generator
and not for the rest of the generators (because those are PQ and PV buses
and there is no need to do it).
To clean up the output to avoid such confusion, I have implemented a quick
fix for the issue by updating the Pg and Qg using state estimation results.
The code with the quick fix is attached. I haven't tested it extensively.
Please use it and let me know if you find it useful or if you have
additional questions. I can be reached at [email protected].
Thanks,
Rui
-----Original Message-----
From: Ray Zimmerman
Sent: Monday, December 5, 2016 9:27 AM
To: Rui Bo
Cc: MATPOWER discussion forum
Subject: Re: state estimation: active power not balanced in test cases
Hi Rui and Niccolò,
The state estimation code was contributed by Rui Bo, so I’m not that
familiar with it. Rui, I was wondering if you might be able to address
Niccolò's questions.
Thanks,
Ray
On Dec 1, 2016, at 6:20 PM, Niccolò Citroni <[email protected]>
wrote:
Hallo, I'm new to matpower, using it for my master thesis.
I'm trying to figure out how the se program works, and running the
included test cases I noticed the following:
there is a big unbalance in active power in the network, for example in
the 3 bus case there are more than 380 MW of active power in excess,
considering generation, load, and losses. How is that possible?
Another thing: modifing the load i get different results runnning the se.
Why is that? shouldn't the state estimation be based only on the input
mesurements and the topology of the network? How has the load and
generator power anything to do with the se, when not included in the
mesurements? From what I know the power balance at each node should be a
result of the se, not part of the input data (when not as mesurements of
course).
I hope I've been clear enough.
I'm using version 6.0b2
Thankyou for the help and the program.
Niccolò Citroni
function [baseMVA, bus, gen, branch, success, et, z, z_est, error_sqrsum] =
run_se(casename, measure, idx, sigma, type_initialguess, V0)
%RUN_SE Run state estimation.
% [INPUT PARAMETERS]
% measure: measurements
% idx: measurement indices
% sigma: measurement variances
% [OUTPUT PARAMETERS]
% z: Measurement Vector. In the order of PF, PT, PG, Va, QF, QT, QG, Vm
(if
% applicable), so it has ordered differently from original measurements
% z_est: Estimated Vector. In the order of PF, PT, PG, Va, QF, QT, QG, Vm
% (if applicable)
% error_sqrsum: Weighted sum of error squares
% created by Rui Bo on 2007/11/12
% MATPOWER
% Copyright (c) 1996-2015 by Power System Engineering Research Center
(PSERC)
% by Rui Bo
% and Ray Zimmerman, PSERC Cornell
%
% $Id: run_se.m 2644 2015-03-11 19:34:22Z ray $
%
% This file is part of MATPOWER.
% Covered by the 3-clause BSD License (see LICENSE file for details).
% See http://www.pserc.cornell.edu/matpower/ for more info.
\%% define named indices into bus, gen, branch matrices
[GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
\%% read data & convert to internal bus numbering
[baseMVA, bus, gen, branch] = loadcase(casename);
[i2e, bus, gen, branch] = ext2int(bus, gen, branch);
\%% get bus index lists of each type of bus
[ref, pv, pq] = bustypes(bus, gen);
\%% build admittance matrices
[Ybus, Yf, Yt] = makeYbus(baseMVA, bus, branch);
Ybus = full(Ybus);
Yf = full(Yf);
Yt = full(Yt);
\%% prepare initial guess
if nargin < 6
V0 = getV0(bus, gen, type_initialguess);
else
V0 = getV0(bus, gen, type_initialguess, V0);
end
\%% run state estimation
t0 = clock;
[V, success, iterNum, z, z_est, error_sqrsum] = doSE(baseMVA, bus, gen,
branch, Ybus, Yf, Yt, V0, ref, pv, pq, measure, idx, sigma);
\%% update data matrices with solution, ie, V
% [bus, gen, branch] = updatepfsoln(baseMVA, bus, gen, branch, Ybus, V, ref,
pv, pq);
[bus, gen, branch] = pfsoln(baseMVA, bus, gen, branch, Ybus, Yf, Yt, V, ref,
pv, pq);
% update Pg and Qg using estimated values
if length(idx.idx_zPG)>0
cnt = length(idx.idx_zPF) + length(idx.idx_zPT);
gen(idx.idx_zPG,PG) = z_est([cnt+1:cnt+length(idx.idx_zPG)])*baseMVA;
end
if length(idx.idx_zQG)>0
cnt = length(idx.idx_zPF) + length(idx.idx_zPT) + length(idx.idx_zPG) +
length(idx.idx_zVa) + length(idx.idx_zQF) + length(idx.idx_zQT);
gen(idx.idx_zQG,QG) = z_est([cnt+1:cnt+length(idx.idx_zQG)])*baseMVA;
end
et = etime(clock, t0);
\%%----- output results -----
\%% convert back to original bus numbering & print results
[bus, gen, branch] = int2ext(i2e, bus, gen, branch);
\%% output power flow solution
outputpfsoln(baseMVA, bus, gen, branch, success, et, 1, iterNum);
\%% output state estimation solution
outputsesoln(idx, sigma, z, z_est, error_sqrsum);