I understand that your issue is that the bus voltage "V2" is diverging when you run the code. The possible ways this can be resolved are:
- Compute the voltage of both buses, i.e., "V2" and "V3", in the same loop so that the updated value of voltage is used for computation in each iteration. To do so, you can save the voltage ("V") and apparent power ("S") in a vector. This can be done as follows:
for j=2:totalNumberofBuses
YV = YV + ybus(j,k)* V(k);
V(j)=(1/ybus(j,j))*(S(j))/conj(V(j)) - YV);
- Additionally, you can use the accelerating factor with its industry- standard value to multiply the voltage of each bus in each iteration to accelerate convergence. Be careful while choosing the value of the acceleration factor as it may cause divergence of the voltages if wrongly chosen.
Hope this helps to resolve the issue.