Advertisement
hannah_hannah123

01819229

Nov 11th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 4.06 KB | None | 0 0
  1.  
  2. clear
  3. clc
  4.  
  5. % Fixed voltage magnitude at the slack bus
  6. V1=1.01;
  7.  
  8. Pg=0;
  9. PSOP=0;
  10. % Load parameters of the two feeder system (p.u.)
  11. ZL12=0.05+i*0.01;
  12. ZL13=0.04;
  13. ZL34=0.01;
  14. Zload3=2.21;
  15. Zload4=2.08+i*0.52;
  16.  
  17. % Admittance calculation
  18. YL12=1/ZL12;
  19. YL13=1/ZL13;
  20. YL34=1/ZL34;
  21. Yload3=1/Zload3;
  22. Yload4=1/Zload4;
  23.  
  24. % Admittane matrix
  25. Y=[YL12+YL13,-YL12,-YL13,0;
  26. -YL12,YL12,0,0;
  27. -YL13,0,YL13+YL34+Yload3,-YL34;
  28. 0,0,-YL34,YL34+Yload4];
  29.  
  30. % Obtaining real part of the complex number for Y matrix
  31. G11=real(Y(1,1));
  32. % Obtaining imaginary part of the complex number for Y matrix
  33. B11=imag(Y(1,1));
  34.  
  35. G12=real(Y(1,2));
  36. B12=imag(Y(1,2));
  37.  
  38. G13=real(Y(1,3));
  39. B13=imag(Y(1,3));
  40.  
  41. G22=real(Y(2,2));
  42. B22=imag(Y(2,2));
  43.  
  44. G33=real(Y(3,3));
  45. B33=imag(Y(3,3));
  46.  
  47. G34=real(Y(3,4));
  48. B34=imag(Y(3,4));
  49.  
  50. G44=real(Y(4,4));
  51. B44=imag(Y(4,4));
  52.  
  53. PSOPArray = [];
  54. for PSOP = 0:0.01:1
  55.    
  56.     % PSOP has been added for Q2a to extract 0.8 pu of active power from (2) to (4)
  57.     % PSOP not added for Q1a
  58.     % 6 unknowns variables - V2, V3, V4, theta2, theta3 and theta 4 are
  59.     % calculated below by creating the function
  60. f=@(V2,V3,V4,theta2,theta3,theta4) [V1*V2*(G12*cos(theta2)+B12*sin(theta2))+V2*V2*G22 + PSOP;
  61.     V1*V3*(G13*cos(theta3)+B13*sin(theta3))+V3*V3*G33+V3*V4*(G34*cos(theta3-theta4)+B34*sin(theta3-theta4));
  62.     % PSOP not added for Q1a
  63.     % PSOP has been subtracted for Q2a to extract 0.8 pu of active power from (2) to (4)
  64.     V4*V4*G44+V3*V4*(G34*cos(theta4-theta3)+B34*sin(theta4-theta3))- PSOP;
  65.     V1*V2*(G12*sin(theta2)-B12*cos(theta2))-V2*V2*B22;    
  66.     V1*V3*(G13*sin(theta3)-B13*cos(theta3))-V3*V3*B33+V3*V4*(G34*sin(theta3-theta4)-B34*cos(theta3-theta4));
  67.     -V4*V4*B44+V3*V4*(G34*sin(theta4-theta3)-B34*cos(theta4-theta3))];
  68.     % derivative of the defined function to build Jacabian, J.
  69.  
  70. J=@(V2,V3,V4,theta2,theta3,theta4) [V1*(G12*cos(theta2)+B12*sin(theta2))+2*V2*G22, 0, 0, V1*V2*(-G12*sin(theta2)+B12*cos(theta2)), 0, 0;
  71.     0, V1*(G13*cos(theta3)+B13*sin(theta3))+2*V3*G33+V4*(G34*cos(theta3-theta4)+B34*sin(theta3-theta4)), V3*(G34*cos(theta3-theta4)+B34*sin(theta3-theta4)), 0, V1*V3*(-G13*sin(theta3)+B13*cos(theta3))+V3*V4*(-G34*sin(theta3-theta4)+B34*cos(theta3-theta4)), V3*V4*(G34*sin(theta3-theta4)-B34*cos(theta3-theta4));
  72.     0, V4*(G34*cos(theta4-theta3)+B34*sin(theta4-theta3)), V3*(G34*cos(theta4-theta3)+B34*sin(theta4-theta3))+2*V4*G44, 0, V3*V4*(G34*sin(theta4-theta3)-B34*cos(theta4-theta3)), V3*V4*(-G34*sin(theta4-theta3)+B34*cos(theta4-theta3));
  73.     V1*(G12*sin(theta2)-B12*cos(theta2))-2*V2*B22, 0, 0, V1*V2*(G12*cos(theta2)+B12*sin(theta2)),0,0;
  74.     0, V1*(G13*sin(theta3)-B13*cos(theta3))-2*V3*B33+V4*(G34*sin(theta3-theta4)-B34*cos(theta3-theta4)), V3*(G34*sin(theta3-theta4)-B34*cos(theta3-theta4)), 0, V1*V3*(G13*cos(theta3)+B13*sin(theta3))+V3*V4*(G34*cos(theta3-theta4)+B34*sin(theta3-theta4)), V3*V4*(-G34*cos(theta3-theta4)-B34*sin(theta3-theta4));
  75.     0, V4*(G34*sin(theta4-theta3)-B34*cos(theta4-theta3)), -2*V4*B44+V3*(G34*sin(theta4-theta3)-B34*cos(theta4-theta3)), 0, V3*V4*(-G34*cos(theta4-theta3)-B34*sin(theta4-theta3)), V3*V4*(G34*cos(theta4-theta3)+B34*sin(theta4-theta3))];
  76.  
  77. fp=@(x) f(x(1),x(2),x(3),x(4),x(5),x(6));
  78. Jp=@(x) J(x(1),x(2),x(3),x(4),x(5),x(6));
  79. % Newton-Raphson
  80. x=zeros(6,6);
  81. x(1,:)=[1.01,1.01,1.01,0,0,0];
  82. disp(norm(fp(x(1,:))));
  83. for n=2:length(x)
  84.     x(n,:)=x(n-1,:)-((Jp(x(n-1,:))^(-1))*fp(x(n-1,:)))';
  85.     disp(norm(fp(x(n,:))));
  86. end
  87. disp('Solution:');
  88. disp(x(n,:));
  89.  
  90. PSOPArray = [PSOPArray [x(n,1); x(n,2) ; x(n,3)]];
  91.  
  92. end
  93. clf
  94. hold on
  95.  
  96. plot(0:0.01:1,PSOPArray')
  97.  
  98. figure(1)
  99. hold on
  100. % plot graph of Voltages against PSOP for Q2d
  101. disp('Intersection 1:');
  102. P = InterX([0:0.01:1;PSOPArray(1,:)],[0:0.01:1;PSOPArray(2,:)])
  103. plot(P(1),P(2),'ko');
  104. disp('Intersection 2:');
  105. P = InterX([0:0.01:1;PSOPArray(1,:)],[0:0.01:1;PSOPArray(3,:)])
  106. plot(P(1),P(2),'bo');
  107. disp('Intersection 3:');
  108. P = InterX([0:0.01:1;PSOPArray(2,:)],[0:0.01:1;PSOPArray(3,:)])
  109. plot(P(1),P(2),'ro');
  110.  
  111.  
  112. hold off
  113.  
  114. xlabel ('PSOP (p.u.)')
  115. ylabel ('Voltage (p.u.)')
  116. title ('Voltages against PSOP range')
  117. legend("V2","V3","V4")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement