Here's what I did:
- Find All buses
- Find In-Service buses
- Calculate Out-of-service buses using steps 1,2
- Create subsystem of out-of-service buses
- Find all in-service branches attached to subsystem
To test it, I created a system with 4 InService buses, 4 out-of-service buses, and a branch between every bus pair.
1. Find all buses
I'm abusing the basekv filter below just to select all buses.
# 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]
2. Find in-service buses
# Find in-service buses
ierr, in_service_buses = psspy.abusint(sid=sid, string=["NUMBER"], flag=1)
in_service_buses = in_service_buses[0]
3. Calculate out-of-service buses
Steps 1-3 are just to find the out-of-service buses. It seems like a lot of work, but I couldn't find a better way.
# Find not in-service buses
out_service_buses = list(set(all_buses) - set(in_service_buses))
4. Subsystem with only out-of-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)
5. InService Branches on subsystem
# Find in-service, non-transformer branches
ierr, branches = psspy.abrnint(sid=sid, string=["FROMNUMBER", "TONUMBER"],
flag=1, ties=3)
6. Check your work
# 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])
And you should get something like:
There's a problem with branch from 1 to 10
There's a problem with branch from 1 to 11
There's a problem with branch from 1 to 12
There's a problem with branch from 2 to 10
<snip>
looks good