0001 function [baseMVA, bus, gen, branch, success, et, z, z_est, error_sqrsum] = ...
0002 run_se(casename, measure, idx, sigma, type_initialguess, V0)
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
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
0031 [baseMVA, bus, gen, branch] = loadcase(casename);
0032 [i2e, bus, gen, branch] = ext2int(bus, gen, branch);
0033
0034
0035 [ref, pv, pq] = bustypes(bus, gen);
0036
0037
0038 [Ybus, Yf, Yt] = makeYbus(baseMVA, bus, branch);
0039 Ybus = full(Ybus);
0040 Yf = full(Yf);
0041 Yt = full(Yt);
0042
0043
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
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
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
0067
0068 [bus, gen, branch] = pfsoln(baseMVA, bus, gen, branch, Ybus, Yf, Yt, V, ref, pv, pq);
0069 et = etime(clock, t0);
0070
0071
0072
0073 [bus, gen, branch] = int2ext(i2e, bus, gen, branch);
0074
0075 outputpfsoln(baseMVA, bus, gen, branch, success, et, 1, iterNum);
0076
0077 outputsesoln(idx, sigma, z, z_est, error_sqrsum);
0078