Two-bus Gauss-Zeidel method to calculate the voltage at the receiving bus from the active and reactive power and the sending-bus voltage. Usage: gaussZeidel(P, Q, V1, Z) where P and Q is the active and reactive powers, V1 is the sending (swinging)-bus voltage, and Z is the impedance between them, returning the receiving-bus voltage.
# Gauss-Zeidel Method # (c) 2020 @RR_Inyo def conj(z): return z.real-1j*z.imag def gaussZeidel(P, Q, V1, Z): S_bar=P-1j*Q Y22=1/Z Y21=-1/Z V2=V1+0*1j epsilon=0.001 Nmax=100 i=0 while True: V2_new=1/Y22*(S_bar/conj(V2)-Y21*V1) i=i+1 if abs(V2_new-V2)<epsilon: return V2_new if i>Nmax: return None V2=V2_new