You are on page 1of 4

National Polytechnic School

Department of Electrical Energy


IEE6N4 Introduction to Power Systems
Jos Tipantaxi
30/06/2016
Three Bus for Newton Raphson
%% Branch data
x = 0.1*1j;
y = 1/x;
%% Bus data
V1 = 1.0;
th1 = 0;
P2sp = -0.8;
Q2sp = -0.6;
%% Calculate Ybus
Ybus = [y -y;
-y y];
% Obtain conductance and susceptance from Ybus
G = real(Ybus);
B = imag(Ybus);
%% Newton-Raphson
% Settings
tol = 10^-6;
iter = 0;
itermax = 50;
% Initialization
V2 = 0.1;
th2 = 0;
while 1
P2cl = G(2,1)*V1*V2*cos(th2-th1) + B(2,1)*V1*V2*sin(th2th1)+G(2,2)*V2^2;
Q2cl = G(2,1)*V1*V2*sin(th2-th1) - B(2,1)*V1*V2*cos(th2-th1)B(2,2)*V2^2;
DP2 = P2sp - P2cl;
DQ2 = Q2sp - Q2cl;
if abs(DP2) < tol && abs(DP2) < tol
disp('Solution found')
disp('at iteration #')
disp(iter)
break
else
Jac = [-G(2,1)*V1*V2*sin(th2-th1) + B(2,1)*V1*V2*cos(th2-th1),
G(2,1)*V1*cos(th2-th1)+B(2,1)*V1*sin(th2-th1)+2*G(2,2)*V2;

G(2,1)*V2*V1*cos(th2-th1)+B(2,1)*V2*V1*sin(th2-th1),
G(2,1)*V1*sin(th2-th1)-B(2,1)*V1*cos(th2-th1)-2*B(2,2)*V2];
Dx = (Jac^-1)*[DP2; DQ2];
th2 = th2 + Dx(1);
V2 = V2 + Dx(2);
iter = iter + 1;

end
if iter > itermax
disp('Diverged')
break
end
end
disp('Solution')
disp('V2 in volts')
disp(V2)
disp('Theta2 in deg')
disp(th2*180/pi)

IN two bus the result is V2 in volts and Theta2 in deg.

%% Branch data
x1 = 0.01+0.1*1j;
y1 = 1/x1;
x2=0.1*j;
y2 = 1/x2;
c1=0.25*j;
c2=0.25*j;
x3=0.1*j;
y3 = 1/x3;
c4=0.2*j;
%% Bus data
V1 = 1.0;
th1 = 0;
V2 =1.0;
P2sp=0.1;
Q2sp=-0.2;
P3sp = -0.8;
Q3sp = -0.6;
%% Calculate Ybus
Ybus = [y1+y2+c1 -y2 -y1;
-y2 y2+c2+y3 -y3;
-y1 -y3 y3+c4+y1];

% Obtain conductance and susceptance from Y[bus]


G = real(Ybus);
B = imag(Ybus);
%% Newton-Raphson
% Settings
tol = 10^-6;
iter = 0;
itermax = 50;
% Initialization with conditons
th2 = 0;
V3 = 1;
th3 = 0;

%Interaction with while


while 1
P2cl = G(2,1)*V1*V2*cos(th2-th1) + B(2,1)*V1*V2*sin(th2-th1)+
G(2,2)*V2*V2 + G(2,3)*V3*V2*cos(th2-th3) + B(2,3)*V3*V2*sin(th2-th3);
P3cl = G(3,1)*V1*V3*cos(th3-th1) + B(3,1)*V1*V3*sin(th3-th1)+
G(3,2)*V2*V3*cos(th3-th2) + B(3,2)*V3*V2*sin(th3-th2)+ G(3,3)*V3*V3 ;
Q3cl = G(3,1)*V1*V3*sin(th3-th1) - B(3,1)*V1*V3*cos(th3th1)+G(3,2)*V2*V3*sin(th3-th2) - B(3,2)*V2*V3*cos(th3-th2) B(3,3)*V3*V3;
DP2 = P2sp - P2cl;
DP3 = P3sp - P3cl;
DQ3 = Q3sp - Q3cl;
if abs(DP2) < tol && abs(DP2) < tol% comparation absolute value of
delta
disp('Solution found')
disp('at iteration #')
disp(iter)
break
else
Jac = [-G(2,1)*V1*V2*sin(th2-th1) + B(2,1)*V1*V2*cos(th2-th1) G(2,3)*V3*V2*sin(th2-th3) + B(2,3)*V3*V2*cos(th2-th3),
G(2,3)*V3*V2*sin(th2-th3)- B(2,3)*V3*V2*cos(th2-th3),G(2,3)*V2*cos(th2th3) + B(2,3)*V2*sin(th2-th3);
G(3,2)*V2*V3*sin(th3-th2) - B(3,2)*V3*V2*cos(th3-th2),G(3,1)*V1*V3*sin(th3-th1) + B(3,1)*V1*V3*cos(th3-th1)- G(3,2)*V2*V3sin(th3-th2) + B(3,2)*V3*V2*cos(th3-th2),G(3,1)*V1*cos(th3-th1) +
B(3,1)*V1*sin(th3-th1)+ G(3,2)*V2*cos(th3-th2) + B(3,2)*V2*sin(th3-th2)+
2*G(3,3)*V3;
-G(3,2)*V2*V3*cos(th3-th2) - B(3,2)*V2*V3*sin(th3-th2),
G(3,1)*V1*V3*cos(th3-th1) + B(3,1)*V1*V3*sin(th3th1)+G(3,2)*V2*V3*cos(th3-th2) + B(3,2)*V2*V3*sin(th3th2),G(3,1)*V1*sin(th3-th1) - B(3,1)*V1*cos(th3-th1)+G(3,2)*V2*sin(th3th2) - B(3,2)*V2*cos(th3-th2) - 2*B(3,3)*V3];
Dx = (Jac^-1)*[DP2;DP3;DQ3];
th2 = th2 + Dx(1);
th3 = th3 + Dx(2);

V3 = V3 + Dx(3);
iter = iter + 1;

end
if iter > itermax% diverged if is this condition
disp('Diverged')
break
end
end
%Display
disp('Solution')
disp('V3 in volts')
disp(V3)
disp('Theta2 in deg')
disp(th2*180/pi)
disp('Theta3 in deg')
disp(th3*180/pi)

Bibliografa
Notes Doc: Franklin Quilumba.

You might also like