How to select N-level buses from specific bus called"simple bus"
I'd like to get the buses list using the "simple bus", N-level buses from specific bus Is there any API in psspy?
First time here? We are a friendly community of Power Systems Engineers. Check out the FAQ!
I'd like to get the buses list using the "simple bus", N-level buses from specific bus Is there any API in psspy?
Try this one. Thanks to 3phaseee.com
def GetNLevelBusList(savfnames,targetbus,levels):
TIES=3 #1=Interior Subsystem, 2=Subsystem Ties, 3=Both
ENTRY=1 #1=Branch in One Direction, 2=Branch in Both Directions
BFLAG=4 #1=In-Service Branches, 2=All Branches, 3=In-Service Branches and Xfmrs, 4=All Branches and Xfmrs, 5=In-Service Xfmrs, 6=All Xfmrs
OWNER=1 #1=Bus Owner, 2=Branch Owner
XFLAG=1 #1=In-Service 3WXfmrs, 2=All 3WXfmrs
DCTIES=6 #6=Both Ends
for i in xrange(len(savfnames)):
psspy.case(savfnames[i])
berr=psspy.busexs(targetbus)
if berr==1:
print 'TARGET BUS {0:d} DOES NOT EXIST IN CASE{1:d} !! ... EXITING'.format(targetbus,i)
if ConSole: PauseConsole()
raise Exception('TARGET BUS {0:d} DOES NOT EXIST IN CASE{1:d} !!'.format(targetbus,i))
numbuses=1
buslist=[targetbus]
SID = 1
for x in xrange(levels):
ierr=psspy.bsys(SID,0,[],0,[],numbuses,buslist,0,[],0,[])
#UPDATE BRANCH,3W, AND DC DATA FROM PSSPY.SYS RESULTS --------------
berr, barray = psspy.abrnint(SID, OWNER, TIES, BFLAG, ENTRY, ['FROMNUMBER','TONUMBER'])
biderr, barrayid = psspy.abrnchar(SID, OWNER, TIES, BFLAG, ENTRY, ['ID'])
xerr, xarray = psspy.atr3int(SID, OWNER, TIES, XFLAG, ENTRY, ['WIND1NUMBER','WIND2NUMBER','WIND3NUMBER'])
xiderr, xarrayid = psspy.atr3char(SID, OWNER, TIES, XFLAG, ENTRY, ['ID'])
dcerr, dcarray = psspy.a2trmdcconvint(SID, DCTIES, 2, 1, ['FROMNUMBER','TONUMBER'])
dciderr, dcarrayid = psspy.a2trmdcconvchar(SID, DCTIES, 2, 1, ['DCNAME'])
#BUILD NEW BUS LIST FOR NEXT LEVEL ---------------------------------
newbuslist=[]
for j in xrange(len(barray[0])):
newbuslist.append(barray[0][j])
newbuslist.append(barray[1][j])
for k in xrange(len(xarray[0])):
newbuslist.append(xarray[0][k])
newbuslist.append(xarray[1][k])
newbuslist.append(xarray[2][k])
for m in xrange(len(dcarray[0])):
newbuslist.append(dcarray[0][m])
newbuslist.append(dcarray[1][m])
newbuslist=list(set(newbuslist))
buslist=newbuslist
numbuses=len(buslist)
buslist.sort()
return buslist
I do not know of an API command to do this directly outside of an SLD. You could maybe use a loop with the nxtbrn()
or nxtbrn3()
API commands to accomplish this. If you are okay running the code from the PSSE GUI with an SLD open you could do it using the growbuslevels()
API command:
bus_list = list()
psspy.growbuslevels(bus_number, x, y, N_levels)
for component in sliderPy.GetActiveDocument().GetDiagram().GetComponents():
if 'BU' in component.GetMapString():
bus_list.append(int(component.GetMapString().split()[-1]))
If you need to use the bus name you would have to work through all the buses in the case using nxtbus()
and notona()
until you found the bus name you are looking for because most API commands require bus number arguments. PSSE bus names don't have to be unique and multiple buses can exist with the same name so I would caution against this and recommend using bus numbers instead.
Asked: 2017-11-10 07:41:42 -0500
Seen: 1,702 times
Last updated: Nov 12 '17