Guest User

Untitled

a guest
Jul 20th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. %Find Ybus Admittance Matrix(any number of Bus)
  2. %I am used 3 Bus and , 2 bus ans 3 bus are not connected
  3. clc
  4. clear
  5. % |FromBus|ToBus|Impedance|LineCharging|
  6. d = [ 1 2 .4j -20j ;
  7. 1 3 .25j -50j;
  8. 2 3 0j 0j ; ];
  9. fb = d(:,1); tb = d(:,2);
  10. y = 1./d(:,3);
  11. % solving line Charginding don't used
  12. if length(d)==3
  13. b = y;
  14. else
  15. b = ((1./d(:,4))) + y;
  16. end
  17. nb = max(max(fb,tb));
  18. Y = zeros(nb);
  19. %put the value of diagonal position
  20. Y(nb*(fb-1)+tb)=-y;
  21. Y(nb*(tb-1)+fb)=-y;
  22. %put the value diagonal position
  23. for m=1:nb
  24. Y(m,m)=sum(b(fb==m))+sum(b(tb==m));
  25. end
  26. %infinity problem solve (Inf or -Inf)
  27. for m=1:nb*nb
  28. if(real(Y(m))==Inf|real(Y(m))==-Inf)
  29. Y(m)=0;
  30. end
  31. end
  32.  
  33. Newton Raphson Load Flow solving
  34.  
  35. % Newton Raphson Load Flow solving 3 Bus
  36. clc
  37. clear
  38. %Finf out Ybus Admittance Matrix
  39. % |FromBus|ToBus|Impedance|LineCharging|
  40. d = [ 1 2 0.05j ];
  41. fb = d(:,1); tb = d(:,2);
  42. y = 1./d(:,3);
  43. % solving line Charginding don't used
  44. if length(d)==3
  45. b = y;
  46. else
  47. b = ((1./d(:,4))) + y;
  48. end
  49. nb = max(max(fb,tb));
  50. Y = zeros(nb);
  51. %put the value of diagonal position
  52. Y(nb*(fb-1)+tb)=-y;
  53. Y(nb*(tb-1)+fb)=-y;
  54. %put the value diagonal position
  55. for m=1:nb
  56. Y(m,m)=sum(b(fb==m))+sum(b(tb==m));
  57. end
  58. %infinity problem solve (Inf or -Inf)
  59. for m=1:nb*nb
  60. if(real(Y(m))==Inf|real(Y(m))==-Inf)
  61. Y(m)=0;
  62. end
  63. end
  64. Y_magnitude =abs(Y);
  65.  
  66. Y_theta=angle(Y)
  67. %gavien valu
  68. v1=1.0;theta1=0;pq2=1+0.5j;
  69. p2=-real(pq2);q2=-imag(pq2);
  70. %inatial guess
  71. v2=1;theta2=0;
  72. X=[v2 theta2]';
  73. %
  74. for i=1:200
  75. fp2=Y_magnitude(2,1)*v1*v2*cos(Y_theta(2,1)+theta1-theta2)-p2;
  76. fq2=-Y_magnitude(2,1)*v1*v2*sin(Y_theta(2,1)+theta1-
  77. theta2)+Y_magnitude(2,2)*v2^2-q2;
  78. %jacobian matrix find
  79. j(1,1)=Y_magnitude(2,1)*v1*v2*sin(Y_theta(2,1)+theta1-theta2);
  80. j(1,2)=Y_magnitude(2,1)*v1*cos(Y_theta(2,1)+theta1-theta2);
  81. j(2,1)=Y_magnitude(2,1)*v1*v2*cos(Y_theta(2,1)+theta1-theta2);
  82. j(2,2)=-Y_magnitude(2,1)*v1*sin(Y_theta(2,1)+theta1-
  83. theta2)+2*Y_magnitude(2,2)*v2;
  84. %Newton Raphson applied
  85. X=X-inv(j)*[fq2 fp2]';
  86. theta(i)=X(2);
  87. voltage(i)=X(1);
  88. theta2=X(2);v2=X(1);
  89. end
  90. v2
  91. theta2
Add Comment
Please, Sign In to add comment