Advertisement
adria_junyent

Example code Load Flow using fsolve Matlab

Oct 21st, 2019
1,128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.93 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. fp=@(x) f(x(1),x(2),x(3),x(4));
  36.  
  37. [x, fval, info] = fsolve (fp, [1.01;1.01;0;0]);
  38.  
  39. disp(x);
  40.  
  41. V2=x(1);
  42. V3=x(2);
  43. theta2=x(3);
  44. theta3=x(4);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement