Skip to content

Instantly share code, notes, and snippets.

@cwebber314
Created March 23, 2012 00:35
Show Gist options
  • Save cwebber314/2165828 to your computer and use it in GitHub Desktop.
Save cwebber314/2165828 to your computer and use it in GitHub Desktop.
Find not Inservice buses attached to InService branches
"""
Find not Inservice buses attached to InService branches
"""
try:
import pssepath #Daniel Hiller's awesome PSSE environment setup module
pssepath.add_pssepath()
import psspy
except:
# Until i get this solved the right way this will have to do
PSSE_LOCATION = r"C:\Program Files\PTI\PSSE32\PSSBIN"
sys.path.append(PSSE_LOCATION)
os.environ['PATH'] = os.environ['PATH'] + os.pathsep + PSSE_LOCATION
import psspy
psspy.psseinit(15000)
import redirect
redirect.psse2py()
# Open testcase
testcase = r'c:\path\to\file.raw'
psspy.readrawversion(0, "32", testcase)
# Find all buses
sid = 1
ierr = psspy.bsys(sid=sid, usekv=1, basekv=[0,1000])
ierr, all_buses = psspy.abusint(sid=sid,
string=["NUMBER"], flag=2)
all_buses = all_buses[0]
# Find in-service buses
ierr, in_service_buses = psspy.abusint(sid=sid, string=["NUMBER"], flag=1)
in_service_buses = in_service_buses[0]
# Find not in-service buses
out_service_buses = list(set(all_buses) - set(in_service_buses))
# Make a subsystem from out-of-service buses
sid = 2
ierr = psspy.bsys(sid=sid, numbus=len(out_service_buses),
buses=out_service_buses)
# Find in-service, non-transformer branches
ierr, branches = psspy.abrnint(sid=sid, string=["FROMNUMBER", "TONUMBER"],
flag=1, ties=3)
# Report
for i in range(len(branches[0])):
print "There's a problem with branch from %s to %s" % (branches[0][i],
branches[1][i])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment