SOlving power flow using gauss seidel and matlab, HELP

In summary, the conversation discusses a course project that involves solving a powerflow system using Gauss Seidel and Newton Raphson methods. The final code includes equations for each bus, checking for errors, and updating variables until the error reaches a certain threshold. However, there are still issues with complex numbers and the accuracy of the results. The speaker is seeking help to find and resolve their mistakes.
  • #1
O.J.
199
0

Homework Statement



We were asked to do a course project using to solve a powerflow system usign gauss seidel and Newton raphson methods. after writing down the equations at each bus and double checking them this is the final code2. The attempt at a solution
c=1
V1=1
P2=-8
Q2=-2.8
V3=1.05
P3=4.4
P4=0
Q4=0
P5=0
Q5=0
V2=1
V4=1
V5=1
th2=atan (imag(V2)./real(V2))
th3=atan (imag(V3)./real(V3))
th4=atan (imag(V4)./real(V4))
th5=atan (imag(V5)./real(V5))
error = 0.001
errorm = 1

while (errorm > error)

V2new = (1./(2.678-i*28.459))*((8+i*2.8)-((-0.893+i*0.919)*V4+(-1.785+i*19.839)*V5))
error2 = abs(V2new - V2)th3new = acos(real(((11.92*sin(th4)-147.96*cos(th4)) + V2*((-0.89*sin(th4-th2)-9.92*cos(th4-th2))+1.05*(cos (th3)+i*sin (th3))*(-7.46*sin(th4-th3)-99.44*cos(th4-th3))+V4*147.96+V5*(-7.48*sin(th4-th5)-99.44*cos(th4-th5))))/4.19))
error3 = abs(th3new - th3)V4new = (1./(11.92-i*147.96)) * (-1*((-0.89+i*9.92)*V2+(-7.46+i*99.44)*1.05*(cos(th4)+i*sin(th3))+(-3.57+i*39.68)*V5))
error4 = abs(V4new - V4)V5new = (1./(9.09-i*107.86)) * (-1*((-3.74+i*49.72)+V2*(-1.786+i*19.839)++V4*(-3.72+i*39.68)))
error5 = abs(V5new - V5)

V2 = V2new
th3 = th3new
V4 = V4new
V5 = V5new
th2=atan (imag(V2)./real(V2))
th4=atan (imag(V4)./real(V4))
th5=atan (imag(V5)./real(V5))

error_1 = max(error2, error3)
error_2 = max(error4, error5)
errorm = max(error_1, error_2)
c=c+1
end
this is my code. please try it and tell me anything if you notice anything.
 
Physics news on Phys.org
  • #2
ok, I am tracing my output to try to know where my mistakes are. i discovered that my expresion for the error was a mistake, because it only took into account the real part so my new expression is c=1
V1=1
P2=-8
Q2=-2.8
V3=1.05
P3=4.4
P4=0
Q4=0
P5=0
Q5=0
V2=1
V4=1
V5=1
th2=atan (imag(V2)./real(V2))
th3=atan (imag(V3)./real(V3))
th4=atan (imag(V4)./real(V4))
th5=atan (imag(V5)./real(V5))
error = 0.0001
errorm = 1

while (errorm > error)

V2new = (1./(2.678-i*28.459))*((8+i*2.8)-((-0.893+i*0.919)*V4+(-1.785+i*19.839)*V5))
error2 = abs(((real(V2new).^2+imag(V2new).^2)^0.5)-((real(V2).^2+imag(V2).^2).^0.5))th3new = asin(imag(((11.92*sin(th4)-147.96*cos(th4)) + V2*((-0.89*sin(th4-th2)-9.92*cos(th4-th2))+1.05*(cos (th3)+i*sin (th3))*(-7.46*sin(th4-th3)-99.44*cos(th4-th3))+V4*147.96+V5*(-7.48*sin(th4-th5)-99.44*cos(th4-th5))))./4.19))
error3 = abs(th3new-th3)

V4new = (1./(11.92-i*147.96)) * (-1*((-0.89+i*9.92)*V2+(-7.46+i*99.44)*1.05*(cos(th4)+i*sin(th3))+(-3.57+i*39.68)*V5))
error4 = abs(((real(V4new).^2+imag(V4new).^2).^0.5)-((real(V4).^2+imag(V4).^2).^0.5))V5new = (1./(9.09-i*107.86)) * (-1*((-3.74+i*49.72)+V2*(-1.786+i*19.839)+V4*(-3.72+i*39.68)))
error5 = abs(((real(V5new).^2+imag(V5new).^2).^0.5)-((real(V5).^2+imag(V5).^2).^0.5))

V2 = V2new
th3 = th3new
V4 = V4new
V5 = V5new
th2=atan (imag(V2)./real(V2))
th4=atan (imag(V4)./real(V4))
th5=atan (imag(V5)./real(V5))

error_1 = max(error2, error3)
error_2 = max(error4, error5)
errorm = max(error_1, error_2)
c=c+1
end

Im still getting NaN results as errors are growing huge, I traced the output and found where I could be going wrong but I didnt resolve it so far. th3 is coming out as a complex number when it shuold be an angle only. I don't know wat I am doing wrong.. please help
 
  • #3


Hi there,

Thank you for sharing your code with me. It looks like you have made a good attempt at solving the power flow problem using the Gauss-Seidel method and Newton-Raphson method in MATLAB. Your code seems to be structured well and you have included comments to explain the different steps.

One thing I noticed is that you have used the "atan" function to calculate the angle (theta) for each bus. However, the "atan" function only calculates the angle in the first quadrant (between 0 and pi/2). In order to get the correct angle for each bus, you may need to use the "atan2" function, which takes into account the signs of both the real and imaginary parts of the complex number.

Another suggestion would be to use vectorized operations in your code, rather than using a loop. This can improve the efficiency and speed of your code. Additionally, you may want to consider including convergence criteria in your code, such as a maximum number of iterations or a tolerance level for the error.

Overall, your code looks like a good starting point for solving the power flow problem. I would suggest testing it on different power systems and comparing your results with other methods to ensure its accuracy.

I hope this helps and good luck with your project!
 

1. What is power flow and why is it important to solve?

Power flow refers to the flow of electric power within an electrical network. It is important to solve because it helps to ensure that the power system is operating efficiently and reliably, and can also aid in identifying and resolving potential issues or failures within the network.

2. What is the Gauss-Seidel method and how is it used to solve power flow?

The Gauss-Seidel method is an iterative algorithm used to solve a system of linear equations. In power flow analysis, it is used to solve the nonlinear power flow equations by breaking them down into smaller linear equations that can be solved iteratively.

3. How is MATLAB used to solve power flow using the Gauss-Seidel method?

MATLAB is a programming software commonly used in scientific and engineering applications. It can be used to write a code that implements the Gauss-Seidel method to solve the power flow equations. It also has built-in functions and tools for visualizing and analyzing the results.

4. What are the advantages of using the Gauss-Seidel method for power flow analysis?

The Gauss-Seidel method is relatively simple to implement and can handle large and complex systems. It also converges faster than other methods, making it more efficient for solving power flow equations.

5. Are there any limitations to using the Gauss-Seidel method for power flow analysis?

One limitation is that the method may not converge if the system is highly nonlinear or if the initial guesses for the variables are far from the actual values. It also requires a good understanding of the power system and its components to set up the equations correctly.

Back
Top