Home > matpower6.0 > extras > se > run_se.m

run_se

PURPOSE ^

RUN_SE Run state estimation.

SYNOPSIS ^

function [baseMVA, bus, gen, branch, success, et, z, z_est, error_sqrsum] =run_se(casename, measure, idx, sigma, type_initialguess, V0)

DESCRIPTION ^

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [baseMVA, bus, gen, branch, success, et, z, z_est, error_sqrsum] = ...
0002     run_se(casename, measure, idx, sigma, type_initialguess, V0)
0003 %RUN_SE  Run state estimation.
0004 %   [INPUT PARAMETERS]
0005 %   measure: measurements
0006 %   idx: measurement indices
0007 %   sigma: measurement variances
0008 %   [OUTPUT PARAMETERS]
0009 %   z: Measurement Vector. In the order of PF, PT, PG, Va, QF, QT, QG, Vm (if
0010 %   applicable), so it has ordered differently from original measurements
0011 %   z_est: Estimated Vector. In the order of PF, PT, PG, Va, QF, QT, QG, Vm
0012 %   (if applicable)
0013 %   error_sqrsum: Weighted sum of error squares
0014 %   created by Rui Bo on 2007/11/12
0015 
0016 %   MATPOWER
0017 %   Copyright (c) 1996-2016, Power Systems Engineering Research Center (PSERC)
0018 %   by Rui Bo
0019 %   and Ray Zimmerman, PSERC Cornell
0020 %
0021 %   This file is part of MATPOWER.
0022 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0023 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0024 
0025 %% define named indices into data matrices
0026 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0027     MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0028     QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0029 
0030 %% read data & convert to internal bus numbering
0031 [baseMVA, bus, gen, branch] = loadcase(casename);
0032 [i2e, bus, gen, branch] = ext2int(bus, gen, branch);
0033 
0034 %% get bus index lists of each type of bus
0035 [ref, pv, pq] = bustypes(bus, gen);
0036 
0037 %% build admittance matrices
0038 [Ybus, Yf, Yt] = makeYbus(baseMVA, bus, branch);
0039 Ybus = full(Ybus);
0040 Yf = full(Yf);
0041 Yt = full(Yt);
0042 
0043 %% prepare initial guess
0044 if nargin < 6
0045     V0 = getV0(bus, gen, type_initialguess);
0046 else
0047     V0 = getV0(bus, gen, type_initialguess, V0);
0048 end
0049 
0050 %% run state estimation
0051 t0 = clock;
0052 [V, success, iterNum, z, z_est, error_sqrsum] = ...
0053     doSE(baseMVA, bus, gen, branch, Ybus, Yf, Yt, V0, ref, pv, pq, measure, idx, sigma);
0054 
0055 % update Pg and Qg using estimated values
0056 if length(idx.idx_zPG) > 0
0057     cnt = length(idx.idx_zPF) + length(idx.idx_zPT);
0058     gen(idx.idx_zPG, PG) = z_est([cnt+1:cnt+length(idx.idx_zPG)]) * baseMVA;
0059 end
0060 if length(idx.idx_zQG) > 0
0061     cnt = length(idx.idx_zPF) + length(idx.idx_zPT) + length(idx.idx_zPG) + ...
0062             length(idx.idx_zVa) + length(idx.idx_zQF) + length(idx.idx_zQT);
0063     gen(idx.idx_zQG, QG) = z_est([cnt+1:cnt+length(idx.idx_zQG)]) * baseMVA;
0064 end
0065 
0066 %% update data matrices with solution, ie, V
0067 % [bus, gen, branch] = updatepfsoln(baseMVA, bus, gen, branch, Ybus, V, ref, pv, pq);
0068 [bus, gen, branch] = pfsoln(baseMVA, bus, gen, branch, Ybus, Yf, Yt, V, ref, pv, pq);
0069 et = etime(clock, t0);
0070 
0071 %%-----  output results  -----
0072 %% convert back to original bus numbering & print results
0073 [bus, gen, branch] = int2ext(i2e, bus, gen, branch);
0074 %% output power flow solution
0075 outputpfsoln(baseMVA, bus, gen, branch, success, et, 1, iterNum);
0076 %% output state estimation solution
0077 outputsesoln(idx, sigma, z, z_est, error_sqrsum);
0078

Generated on Fri 16-Dec-2016 12:45:37 by m2html © 2005