print623

Coursework Task2a: The SOP exchanging active power between two feeders (MATLAB Script)

Nov 15th, 2023 (edited)
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 3.45 KB | Source Code | 0 0
  1. clear
  2. clc
  3.  
  4.  
  5. V1=1.01;
  6.  
  7. ZL12=0.05+1i*0.01; %impedances between bus i,j (pu)
  8. ZL13=0.04;
  9. ZL34=0.01;
  10. Zload3=2.21; % load impedances (pu)
  11. Zload4=2.08+1i*0.52;
  12. PG=0.6; %PV power generation (pu)
  13. Psop=0.8; %A Soft Open Point extracts 0.8 pu of active power from (2) and inject it into (4)
  14.  
  15. YL12=1/ZL12; %admittance = 1/impedance
  16. YL13=1/ZL13;
  17. YL34=1/ZL34;
  18. Yload3=1/Zload3;
  19. Yload4=1/Zload4;
  20.  
  21. Y=[YL12+YL13,-YL12,-YL13,0; %admittance matrix 4*4 (4nodes)
  22. -YL12,YL12,0,0;
  23. -YL13,0,YL13+YL34+Yload3,-YL34;
  24. 0,0,-YL34,YL34+Yload4];
  25.  
  26. G12=real(Y(1,2)); %Real and Imaginary values of each component in admittance matrix Y
  27. B12=imag(Y(1,2));
  28.  
  29. G22=real(Y(2,2));
  30. B22=imag(Y(2,2));
  31.  
  32. G13=real(Y(1,3));
  33. B13=imag(Y(1,3));
  34.  
  35. G33=real(Y(3,3));
  36. B33=imag(Y(3,3));
  37.  
  38. G34=real(Y(3,4));
  39. B34=imag(Y(3,4));
  40.  
  41. G44=real(Y(4,4));
  42. B44=imag(Y(4,4));
  43.  
  44.  
  45. f=@(V2,V3,V4,theta2,theta3,theta4) [V1*V2*(G12*cos(theta2)+B12*sin(theta2))+V2*V2*G22-PG+Psop; V1*V3*(G13*cos(theta3)+B13*sin(theta3))+V3*V3*G33+V3*V4*(G34*cos(theta3-theta4)+B34*sin(theta3-theta4)); V4*V3*(G34*cos(theta4-theta3)+B34*sin(theta4-theta3))+V4*V4*G44-Psop;V2*V1*(G12*sin(theta2)-B12*cos(theta2))-V2*V2*B22; V1*V3*(G13*sin(theta3)-B13*cos(theta3))-V3*V3*B33+V4*V3*(G34*sin(theta3-theta4)-B34*cos(theta3-theta4)); V4*V3*(G34*sin(theta4-theta3)-B34*cos(theta4-theta3))-V4*V4*B44];
  46. %Load flow equation [P2-PG+Psop;P3;P4-Psop;Q2;Q3;Q4]=0 to solve unknown parameters (V2,V3,V4,theta2,theta3,theta4)
  47.  
  48. J=@(V2,V3,V4,theta2,theta3,theta4) [2*V2*G22+V1*(G12*cos(theta2)+B12*sin(theta2)),0,0,V1*V2*(-G12*sin(theta2)+B12*cos(theta2)),0,0;0,2*V3*G33+V1*(G13*cos(theta3)+B13*sin(theta3))+V4*(G34*cos(theta3-theta4)+B34*sin(theta3-theta4)),V3*(G34*cos(theta3-theta4)+B34*sin(theta3-theta4)),0,V3*V1*(-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));0,V4*(G34*cos(theta4-theta3)+B34*sin(theta4-theta3)),2*V4*G44+V3*(G34*cos(theta4-theta3)+B34*sin(theta4-theta3)),0,V4*V3*(G34*sin(theta4-theta3)-B34*cos(theta4-theta3)),V4*V3*(-G34*sin(theta4-theta3)+B34*cos(theta4-theta3));-2*V2*B22+V1*(G12*sin(theta2)-B12*cos(theta2)),0,0,V2*V1*(G12*cos(theta2)+B12*sin(theta2)),0,0;0,-2*V3*B33+V1*(G13*sin(theta3)-B13*cos(theta3))+V4*(G34*sin(theta3-theta4)-B34*cos(theta3-theta4)),V3*(G34*sin(theta3-theta4)-B34*cos(theta3-theta4)),0,V3*V1*(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));0,V4*(G34*sin(theta4-theta3)-B34*cos(theta4-theta3)),-2*V4*B44+V3*(G34*sin(theta4-theta3)-B34*cos(theta4-theta3)),0,V4*V3*(-G34*cos(theta4-theta3)-B34*sin(theta4-theta3)),V4*V3*(G34*cos(theta4-theta3)+B34*sin(theta4-theta3))];
  49.  
  50. fp=@(x) f(x(1),x(2),x(3),x(4),x(5),x(6)); %fp is a function to input the x value in to f function
  51. Jp=@(x) J(x(1),x(2),x(3),x(4),x(5),x(6));
  52.  
  53. x=zeros(3,6); %zero matrix x with 3*6 size
  54. x(1,:)=[1.01;1.01;1.01;0;0;0]; %x(1,:) is an initial value for x
  55. disp(x(1,:));
  56. disp('Error:');
  57. disp(norm(fp(x(1,:))));
  58. for n=2:length(x)
  59.     x(n,:)=x(n-1,:)-((Jp(x(n-1,:))^(-1))*fp(x(n-1,:)))';
  60.     disp(['Iteration',num2str(n)]);
  61.     disp(x(n,:));
  62.     disp('Error:');
  63.     disp(norm(fp(x(n,:))));
  64. end
  65. disp('Solution:');
  66. disp(x(n,:));
  67. disp(['V2 = ',num2str(x(n,1)),' pu']);
  68. disp(['V3 = ',num2str(x(n,2)),' pu']);
  69. disp(['V4 = ',num2str(x(n,3)),' pu']);
  70. disp(['Theta2 = ',num2str(x(n,4)),' rad']);
  71. disp(['Theta3 = ',num2str(x(n,5)),' rad']);
  72. disp(['Theta4 = ',num2str(x(n,6)),' rad']);
Add Comment
Please, Sign In to add comment