adria_junyent

Example code Load Flow using Newton Raphson Matlab

Oct 21st, 2019
1,917
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 2.10 KB | None | 0 0
  1. clear
  2. clc
  3.  
  4. V1=1.01;
  5.  
  6. ZL12=0.02+i*0.01;
  7. ZL23=0.03+i*0.01;
  8. Zload2=9.8+i*1.96;
  9. Sload3=0.2+i*0.05;
  10.  
  11. YL12=1/ZL12;
  12. YL23=1/ZL23;
  13. Yload2=1/Zload2;
  14. Pload3=real(Sload3);
  15. Qload3=imag(Sload3);
  16.  
  17. Y=[YL12,-YL12,0;
  18. -YL12,YL12+YL23+Yload2,-YL23;
  19. 0,-YL23,YL23];
  20.  
  21. G12=real(Y(1,2));
  22. B12=imag(Y(1,2));
  23.  
  24. G22=real(Y(2,2));
  25. B22=imag(Y(2,2));
  26.  
  27. G23=real(Y(2,3));
  28. B23=imag(Y(2,3));
  29.  
  30. G33=real(Y(3,3));
  31. B33=imag(Y(3,3));
  32.  
  33. f=@(V2,V3,theta2,theta3) [V1*V2*(G12*cos(theta2)+B12*sin(theta2))+V2*V2*G22+V2*V3*(G23*cos(theta2-theta3)+B23*sin(theta2-theta3)); V2*V3*(G23*cos(theta3-theta2)+B23*sin(theta3-theta2))+V3*V3*G33+Pload3; V1*V2*(G12*sin(theta2)-B12*cos(theta2))-V2*V2*B22+V2*V3*(G23*sin(theta2-theta3)-B23*cos(theta2-theta3)); V2*V3*(G23*sin(theta3-theta2)-B23*cos(theta3-theta2))-V3*V3*B33+Qload3];
  34.  
  35. J=@(V2,V3,theta2,theta3) [V1*(G12*cos(theta2)+B12*sin(theta2))+2*V2*G22+V3*(G23*cos(theta2-theta3)+B23*sin(theta2-theta3)),V2*(G23*cos(theta2-theta3)+B23*sin(theta2-theta3)),V1*V2*(-G12*sin(theta2)+B12*cos(theta2))+V2*V2*(-G23*sin(theta2-theta3)+B23*cos(theta2-theta3)),V2*V3*(G23*sin(theta2-theta3)-B23*cos(theta2-theta3));V3*(G23*cos(theta3-theta2)+B23*sin(theta3-theta2)),V2*(G23*cos(theta3-theta2)+B23*sin(theta3-theta2))+2*V3*G33,V2*V3*(G23*sin(theta3-theta2)-B23*cos(theta3-theta2)),V2*V3*(-G23*sin(theta3-theta2)+B23*cos(theta3-theta2));V2*(G12*sin(theta2)-B12*cos(theta2))-2*V2*B22+V3*(G23*sin(theta2-theta3)-B23*cos(theta2-theta3)),V2*V3*(G23*sin(theta2-theta3)-B23*cos(theta2-theta3)),V1*V2*(G12*cos(theta2)+B12*sin(theta2))+V2*V3*(G23*cos(theta2-theta3)+B23*sin(theta2-theta3)),V2*V3*(-G23*cos(theta2-theta3)-B23*sin(theta2-theta3));V3*(G23*sin(theta3-theta2)-B23*cos(theta3-theta2)),V2*(G23*sin(theta3-theta2)-B23*cos(theta3-theta2))-2*V3*B33,V2*V3*(-G23*cos(theta3-theta2)-B23*sin(theta3-theta2)),V2*V3*(G23*cos(theta3-theta2)+B23*sin(theta3-theta2))];
  36.  
  37. fp=@(x) f(x(1),x(2),x(3),x(4));
  38. Jp=@(x) J(x(1),x(2),x(3),x(4));
  39.  
  40. x=zeros(3,4);
  41. x(1,:)=[1.01,1.01,0,0];
  42. disp(norm(fp(x(1,:))));
  43. for n=2:length(x)
  44.     x(n,:)=x(n-1,:)-((Jp(x(n-1,:))^(-1))*fp(x(n-1,:)))';
  45.     disp(norm(fp(x(n,:))));
  46. end
  47. disp('Solution:');
  48. disp(x(n,:));
Advertisement
Add Comment
Please, Sign In to add comment