gausszeidel.py

Created by rr-inyo

Created on December 21, 2020

376 Bytes

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

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.