There are MATLAB codes for 3 different methods for solving powerflows in this repository:
1. Gauss Seidel Powerflow Solution -> Fast convergence but not too accurate
2. Newton Raphson Powerflow Solution -> Slow convergence but very accurate
3. Fast Decoupled Powerflow Solution -> Good convergence and good accuracy
To know more about these solutions, you can check out this wikipedia page:
https://en.wikipedia.org/wiki/Power-flow_study
The code for all three methods was used to solve the following powerflow problem:
http://www.mty.itesm.mx/etie/deptos/ie/profesores/jabaez/clases/e00888/flujos_potencia/ejemplo_flujos_uwaterloo.pdf
Enter the Y bus matrix.
A vector with length: #Number of busses. If the voltage magnitutde of the k'th bus is known, insert Known_V[k]=1, else insert Known_V[k]=0.
A vector with length: #Number of busses. If the voltage phase of the k'th bus is known, insert Known_A[k]=1, else insert Known_A[k]=0.
A vector with length: #Number of busses. If the real/active power of the k'th bus is known,insert Known_P[k]=1, else insert Known_P[k]=0.
A vector with length: #Number of busses. If the reactive power of the k'th bus is known, insert Known_Q[k]=1, else insert Known_Q[k]=0.
A vector with length: #Number of busses. If the voltage magnitude of the k'th bus is known and equal to Vk, insert V[k]=Vk, else insert V[k]=initial guess.
A vector with length: #Number of busses. If the voltage phase of the k'th bus is known and equal to Ak, insert A[k]=Ak, else insert A[k]=initial guess.
A vector with length: #Number of busses. If the real/active power of the k'th bus is known and equal to Pk, insert P[k]=Pk, else insert P[k]=initial guess.
A vector with length: #Number of busses. If the reactive power of the k'th bus is known and equal to Qk, insert Q[k]=Qk, else insert Q[k]=initial guess.
Convergence epsilon. Determines the algorithm's stopping condition: If the norm of the mismatch equations is below epsilon, our algorithm has found an accurate enough solution and it will stop.