Documente Academic
Documente Profesional
Documente Cultură
close all
clear maplemex
pause(1)
clear all
pause(1)
clc
pause(1)
j = sqrt(-1);
% USER-DEFINED INPUT
******************************************************
%
************************************************************************
%
************************************************************************
%
************************************************************************
%
************************************************************************
Site Navigation
Curriculum Vitae % ACTION: Define bus characteristics below.
% column #1 = bus #
Smart Electric Power System
% column #2 = bus type ( 1 = slack, 2 = gen/PV, 3
Laboratory (SEPS) = load/PQ )
% column #3 = voltage magnitude (per unit)
OpenFlow Power System Simulation % column #4 = voltage angle (degrees)
Tool (Beta-Version) % ** note that columns 3 and 4 also provide
initial conditions for
Announcements % power flow analysis (they should be filled
Recent Conference Presentations in)
% column #5 = real power injection (per unit)
Recent Journal Papers % column #6 = reactive power injection (per unit)
% column #7 = valid pseudo-measurement ( 0 - no, 1
Pictures and Video - yes ), for state
TV, Radio, and Print % estimation only
1 of 25 08-03-2014 08:39
n-bus Power Flow Solver / State Estimator - Anthony S. Deese, Ph.D.... https://sites.google.com/site/anthonydeesephd/matlab-files/power-syst...
1 2 0.01 1.0 1; %
transmission line
1 5 0.02 0.9 1; %
transmission line
2 5 0.03 0.8 1; %
transmission line
2 3 0.04 0.7 1; %
transmission line
2 4 0.05 0.6 1; %
transmission line
3 4 0.06 0.5 1; %
transmission line
4 5 0.07 0.4 1; %
transmission line
%5 6 0.08 0.3 1; %
transmission line
4 7 0.09 0.2 1; %
transmission line
6 10 0.01 0.1 1; %
transmission line
6 9 0.02 0.2 1; %
transmission line
9 8 0.03 0.3 1; %
transmission line
2 8 0.04 0.4 1; % tie
line (normally-open)
1 10 0.05 0.5 1; %
tie-line (normally-open)
8 10 0.06 0.6 1; ]; %
tie-line (normally-open)
% from to R X mtype
2 of 25 08-03-2014 08:39
n-bus Power Flow Solver / State Estimator - Anthony S. Deese, Ph.D.... https://sites.google.com/site/anthonydeesephd/matlab-files/power-syst...
should be employed.
pf_type = 1; % 0 = full, 1 = dc
% PRE-ANALYSIS
************************************************************
%
************************************************************************
%
************************************************************************
%
************************************************************************
%
************************************************************************
3 of 25 08-03-2014 08:39
n-bus Power Flow Solver / State Estimator - Anthony S. Deese, Ph.D.... https://sites.google.com/site/anthonydeesephd/matlab-files/power-syst...
for k1 = 1:max(bus(:,1))
for k2 = 1:max(bus(:,1))
4 of 25 08-03-2014 08:39
n-bus Power Flow Solver / State Estimator - Anthony S. Deese, Ph.D.... https://sites.google.com/site/anthonydeesephd/matlab-files/power-syst...
for k2 = 1:size(bus,1)
angleYbus(k1,k2,2) =
angle(double(Ybus(k1,k2,2)));
magYbus(k1,k2,2) =
abs(double(Ybus(k1,k2,2)));
end
end
fbus = line(k1,1);
tbus = line(k1,2);
zline = line(k1,3) + j*line(k1,4);
yline = 1/zline;
Gik(fbus,tbus,2) = real(yline);
Bik(fbus,tbus,2) = imag(yline);
Gik(tbus,fbus,2) = real(yline);
Bik(tbus,fbus,2) = imag(yline);
end
% ACTION: Otherwise...
else
% ACTION: Otherwise...
else
5 of 25 08-03-2014 08:39
n-bus Power Flow Solver / State Estimator - Anthony S. Deese, Ph.D.... https://sites.google.com/site/anthonydeesephd/matlab-files/power-syst...
dcJMag(row-missing_rows_Mag,col-
missing_cols_Mag) = imag(Ybus(row,col,2));
end
end
end
end
% ACTION: Otherwise...
else
% ACTION: Otherwise...
else
end
end
end
end
6 of 25 08-03-2014 08:39
n-bus Power Flow Solver / State Estimator - Anthony S. Deese, Ph.D.... https://sites.google.com/site/anthonydeesephd/matlab-files/power-syst...
if k1 < size(bus,1)
if bus(k1,1) == bus(k1+1,1)
end
7 of 25 08-03-2014 08:39
n-bus Power Flow Solver / State Estimator - Anthony S. Deese, Ph.D.... https://sites.google.com/site/anthonydeesephd/matlab-files/power-syst...
end
end
end
end
8 of 25 08-03-2014 08:39
n-bus Power Flow Solver / State Estimator - Anthony S. Deese, Ph.D.... https://sites.google.com/site/anthonydeesephd/matlab-files/power-syst...
else
state(k2,4) = 0;
end
end
end
end
end
end
9 of 25 08-03-2014 08:39
n-bus Power Flow Solver / State Estimator - Anthony S. Deese, Ph.D.... https://sites.google.com/site/anthonydeesephd/matlab-files/power-syst...
end
end
end
end
J(:,:,1) =
jacobian(constPowerFlow(:,1),state(:,3));
10 of 25 08-03-2014 08:39
n-bus Power Flow Solver / State Estimator - Anthony S. Deese, Ph.D.... https://sites.google.com/site/anthonydeesephd/matlab-files/power-syst...
mismatch = 9999;
J_record(:,:,k1) = J(:,:,2);
constPowerFlow(:,2) = subs(
constPowerFlow(:,1), V(:,2),
double( V(:,3) ));
constPowerFlow(:,2) = subs(
constPowerFlow(:,2), theta(:,2),
double( theta(:,3) ));
constPowerFlow(:,2) = subs(
constPowerFlow(:,2), magYbus(:,:,1),
double( magYbus(:,:,2) ));
constPowerFlow(:,2) = subs(
constPowerFlow(:,2), angleYbus(:,:,1),
double( angleYbus(:,:,2) ));
constPowerFlow(:,2) = subs(
constPowerFlow(:,2), Pinj(:,2),
double( Pinj(:,3) ));
constPowerFlow(:,2) = subs(
constPowerFlow(:,2), Qinj(:,2),
double( Qinj(:,3) ));
11 of 25 08-03-2014 08:39
n-bus Power Flow Solver / State Estimator - Anthony S. Deese, Ph.D.... https://sites.google.com/site/anthonydeesephd/matlab-files/power-syst...
if pf_type == 0
elseif pf_type == 1
updated_state(n_gen+n_load+1:n_gen+2*n_load) =
-double(inv_dcJMag) * [
double(constPowerFlow(n_gen+n_load+1:n_gen+2*n_load,2))
./ double(state(n_gen+n_load+1:n_gen+2*n_load,4)) ] +
double(state(n_gen+n_load+1:n_gen+2*n_load,4));
else
if state(k2,1) == theta(k3,1)
theta(k3,3) =
updated_state(k2);
end
end
elseif state(k2,2) == 1
for k3 = 1:size(V,1)
if state(k2,1) == V(k3,1)
V(k3,3) = updated_state(k2);
end
end
end
end
end
12 of 25 08-03-2014 08:39
n-bus Power Flow Solver / State Estimator - Anthony S. Deese, Ph.D.... https://sites.google.com/site/anthonydeesephd/matlab-files/power-syst...
% POST-ANALYSIS
***********************************************************
%
************************************************************************
%
************************************************************************
%
************************************************************************
%
************************************************************************
end
13 of 25 08-03-2014 08:39
n-bus Power Flow Solver / State Estimator - Anthony S. Deese, Ph.D.... https://sites.google.com/site/anthonydeesephd/matlab-files/power-syst...
if sum( abs(mismatchP))+sum(abs(mismatchQ)
) > 10*power_flow_threshold
14 of 25 08-03-2014 08:39
n-bus Power Flow Solver / State Estimator - Anthony S. Deese, Ph.D.... https://sites.google.com/site/anthonydeesephd/matlab-files/power-syst...
end
end
end
15 of 25 08-03-2014 08:39
n-bus Power Flow Solver / State Estimator - Anthony S. Deese, Ph.D.... https://sites.google.com/site/anthonydeesephd/matlab-files/power-syst...
16 of 25 08-03-2014 08:39
n-bus Power Flow Solver / State Estimator - Anthony S. Deese, Ph.D.... https://sites.google.com/site/anthonydeesephd/matlab-files/power-syst...
end
end
end
clc
disp('Output of power flow analysis is shown
below (in per unit and radians)...')
power_flow_variables = transpose(state(:,3))
power_flow_values =
double(transpose(state(:,4)))
17 of 25 08-03-2014 08:39
n-bus Power Flow Solver / State Estimator - Anthony S. Deese, Ph.D.... https://sites.google.com/site/anthonydeesephd/matlab-files/power-syst...
if mod(k1-1,9) == 0
if state(k1,2) == 0
ylabel(sprintf('theta #%g
(deg)',double(state(k1,1))))
elseif state(k1,2) == 1
ylabel(sprintf('vmag #%g
(pu)',double(state(k1,1))))
end
end
end
break;
end
measPik(k2,4) =
sym(sprintf('measPik%g%g',fbus,tbus));
measQik(k2,4) =
sym(sprintf('measQik%g%g',fbus,tbus));
18 of 25 08-03-2014 08:39
n-bus Power Flow Solver / State Estimator - Anthony S. Deese, Ph.D.... https://sites.google.com/site/anthonydeesephd/matlab-files/power-syst...
measPik(k2,4) =
sym(sprintf('measPik%g%g',tbus,fbus));
measQik(k2,4) =
sym(sprintf('measQik%g%g',tbus,fbus));
measQik(k2,4) =
sym(sprintf('measQik%g%g',fbus,tbus));
measQik(k2+1,4) =
sym(sprintf('measQik%g%g',tbus,fbus));
measPik(k2,5) = [ mline(k1,6) ];
measQik(k2,5) = [ mline(k1,7) ];
measPik(k2+1,5) = [ mline(k1,8) ];
measQik(k2+1,5) = [ mline(k1,9) ];
19 of 25 08-03-2014 08:39
n-bus Power Flow Solver / State Estimator - Anthony S. Deese, Ph.D.... https://sites.google.com/site/anthonydeesephd/matlab-files/power-syst...
20 of 25 08-03-2014 08:39
n-bus Power Flow Solver / State Estimator - Anthony S. Deese, Ph.D.... https://sites.google.com/site/anthonydeesephd/matlab-files/power-syst...
end
end
21 of 25 08-03-2014 08:39
n-bus Power Flow Solver / State Estimator - Anthony S. Deese, Ph.D.... https://sites.google.com/site/anthonydeesephd/matlab-files/power-syst...
Gik(fbus,tbus,1)*cos(theta(fbus,2) - theta(tbus,2)) +
Bik(fbus,tbus,1)*sin(theta(fbus,2) - theta(tbus,2)) ]
);
functQik(k2,1) = [ -V(fbus,2)^2 *
Bik(fbus,tbus,1) ] - ( V(fbus,2)*V(tbus,2)*[
Gik(fbus,tbus,1)*sin(theta(fbus,2) - theta(tbus,2)) -
Bik(fbus,tbus,1)*cos(theta(fbus,2) - theta(tbus,2)) ]
);
functPik(k2+1,1) = [ V(tbus,2)^2 *
Gik(tbus,fbus,1) ] - ( V(tbus,2)*V(fbus,2)*[
Gik(tbus,fbus,1)*cos(theta(tbus,2) - theta(fbus,2)) +
Bik(tbus,fbus,1)*sin(theta(tbus,2) - theta(fbus,2)) ]
);
functQik(k2+1,1) = [ -V(tbus,2)^2 *
Bik(tbus,fbus,1) ] - ( V(tbus,2)*V(fbus,2)*[
Gik(tbus,fbus,1)*sin(theta(tbus,2) - theta(fbus,2)) -
Bik(tbus,fbus,1)*cos(theta(tbus,2) - theta(fbus,2)) ]
);
constPik(k2,1) = measPik(k2,4) -
functPik(k2,1);
constQik(k2,1) = measQik(k2,4) -
functQik(k2,1);
constPik(k2+1,1) = measPik(k2,4) -
functPik(k2,1);
constQik(k2+1,1) = measQik(k2,4) -
functQik(k2,1);
k2 = k2+2;
end
end
end
end
22 of 25 08-03-2014 08:39
n-bus Power Flow Solver / State Estimator - Anthony S. Deese, Ph.D.... https://sites.google.com/site/anthonydeesephd/matlab-files/power-syst...
k3 = 1;
end
end
H(:,:,1) =
jacobian(constStateEstimation(:,1),state(:,3));
23 of 25 08-03-2014 08:39
n-bus Power Flow Solver / State Estimator - Anthony S. Deese, Ph.D.... https://sites.google.com/site/anthonydeesephd/matlab-files/power-syst...
ESTIMATION -----------------
% e.g. flat start (1 < 0)
constStateEstimation(:,2) = subs(
constStateEstimation(:,1), V(:,2),
double( V(:,3) ));
constStateEstimation(:,2) = subs(
constStateEstimation(:,2), theta(:,2),
double( theta(:,3) ));
constStateEstimation(:,2) = subs(
constStateEstimation(:,2), Gik(:,:,1),
double( Gik(:,:,2) ));
constStateEstimation(:,2) = subs(
constStateEstimation(:,2), Bik(:,:,1),
double( Bik(:,:,2) ));
constStateEstimation(:,2) = subs(
constStateEstimation(:,2), magYbus(:,:,1),
double( magYbus(:,:,2) ));
constStateEstimation(:,2) = subs(
constStateEstimation(:,2), angleYbus(:,:,1),
double( angleYbus(:,:,2) ));
constStateEstimation(:,2) = subs(
constStateEstimation(:,2), measPik(:,4),
double( measPik(:,5) ));
constStateEstimation(:,2) = subs(
constStateEstimation(:,2), measQik(:,4),
double( measQik(:,5) ));
constStateEstimation(:,2) = subs(
constStateEstimation(:,2), pseudomeasPi(:,2),
double( pseudomeasPi(:,3) ));
constStateEstimation(:,2) = subs(
constStateEstimation(:,2), pseudomeasQi(:,2),
double( pseudomeasQi(:,3) ));
updated_state = -[ inv(
double(transpose(H(:,:,2))*H(:,:,2))
)*transpose(H(:,:,2))] * constStateEstimation(:,2) +
state(:,4);
matrix_record(:,:,k1) = [ inv(
double(transpose(H(:,:,2))*H(:,:,2))
)*transpose(H(:,:,2))];
constStateEstimation_record(:,k1) =
constStateEstimation(:,2);
state_record(:,k1) = state(:,4);
mismatch_record(k1) = mismatch;
24 of 25 08-03-2014 08:39
n-bus Power Flow Solver / State Estimator - Anthony S. Deese, Ph.D.... https://sites.google.com/site/anthonydeesephd/matlab-files/power-syst...
updated_state(k2);
end
end
elseif state(k2,2) == 1
for k3 = 1:size(V,1)
if state(k2,1) == V(k3,1)
V(k3,3) = updated_state(k2);
end
end
end
end
if state(k1,2) == 0
ylabel(sprintf('theta #%g
(deg)',double(state(k1,1))))
elseif state(k1,2) == 1
ylabel(sprintf('vmag #%g
(pu)',double(state(k1,1))))
end
end
Sign in | Recent Site Activity | Report Abuse | Print Page | Remove Access | Powered By Google Sites
25 of 25 08-03-2014 08:39