First time here? We are a friendly community of Power Systems Engineers. Check out the FAQ!
1 | initial version |
# A function to find radial line one of whose bus is only connected this particular branch (consider both non-transformer branches and two-winding transformers)
def findRadialLines(psspy, subSysId, ties):
from collections import Counter
# Find all bus numbers in a given subsystem
allBusArr = psspy.abusint(subSysId, 2, 'NUMBER')
# Consider all the internal and tie branches and all non-transformer branches and two-winding transformers
fromBusIdArr = psspy.abrnint(subSysId, 1, ties, 4, 1, 'FROMNUMBER' )
toBusIdArr = psspy.abrnint(subSysId, 1, ties, 4, 1, 'TONUMBER')
# For each bus number, check if that bus number appears in either a 'fromBus' or 'toBus' list of all the branches in the subsystem
# merge two lists to a big list
fromtoBusList = fromBusIdArr[1][0] + toBusIdArr[1][0]
print fromtoBusList
# define a new list to hold all those buses that only appears in this big list
radialLineBusList = []
for busId, count in Counter(fromtoBusList).most_common():
if count == 1:
radialLineBusList.append(busId)
print radialLineBusList
#now depending on radialLineBusList, find thos radial lines
# for each radialLineConnectedBus, find the branch sorting index (a reference to a fromBusID for a radial line) in the fromBusIdArr first
branchDataIndx_radial = []
for i in range(len(radialLineBusList)):
if (radialLineBusList[i] in fromBusIdArr[1][0]):
branchDataIndx_radial.append(fromBusIdArr[1][0].index(radialLineBusList[i]))
if (radialLineBusList[i] in toBusIdArr[1][0]):
branchDataIndx_radial.append(toBusIdArr[1][0].index(radialLineBusList[i]))
print branchDataIndx_radial
# Now save all the radial lines to two separate lists: one for fromBusId and the other for toBusId
fromBusId_radialLine = []
toBusId_radialLine = []
for i in range(len(branchDataIndx_radial)):
# keep in mind that fromBusIdArr and toBusIdArr are sorted in the same order
fromBusId_radialLine.append(fromBusIdArr[1][0][branchDataIndx_radial[i]])
toBusId_radialLine.append(toBusIdArr[1][0][branchDataIndx_radial[i]])
print fromBusId_radialLine
print toBusId_radialLine
return
2 | No.2 Revision |
# A function to find radial line one of whose bus is only connected this particular branch (consider both non-transformer branches and two-winding transformers)
def findRadialLines(psspy, subSysId, ties):
subSysId):
from collections import Counter
# Find all bus numbers in a given subsystem
allBusArr = psspy.abusint(subSysId, 2, 'NUMBER')
# Consider all the internal and branches (NO subsystem tie branches branches) and all non-transformer branches and two-winding transformers
fromBusIdArr ierr, (fromBusIdArr,) = psspy.abrnint(subSysId, 1, ties, 1, 4, 1, 'FROMNUMBER' )
toBusIdArr 'FROMNUMBER')
ierr, (toBusIdArr,) = psspy.abrnint(subSysId, 1, ties, 1, 4, 1, 'TONUMBER')
#ierr, (cktArr, ) = psspy.abrnchar(subSysId, 1, 1, 4, 1, 'ID') # Can ignore this because if it is a radial line, then it for sure doesn't have a branch in parallel with it, i.e its CKT is always equal to 1
# For each bus number, check if that bus number appears in either a 'fromBus' or 'toBus' list of all the branches in the subsystem
# subsystem
# first merge two lists to a big list
fromtoBusList = fromBusIdArr[1][0] fromBusIdArr + toBusIdArr[1][0]
toBusIdArr
print fromtoBusList
# define a new list to hold all those buses that only appears in this big list
radialLineBusList = []
for busId, count in Counter(fromtoBusList).most_common():
if count == 1:
radialLineBusList.append(busId)
print radialLineBusList
#now # now depending on radialLineBusList, find thos radial lines
# for each radialLineConnectedBus, find the branch sorting index (a reference to a fromBusID for a radial line) in the fromBusIdArr first
branchDataIndx_radial = []
for i in range(len(radialLineBusList)):
if (radialLineBusList[i] in fromBusIdArr[1][0]):
branchDataIndx_radial.append(fromBusIdArr[1][0].index(radialLineBusList[i]))
fromBusIdArr):
branchDataIndx_radial.append(fromBusIdArr.index(radialLineBusList[i]))
if (radialLineBusList[i] in toBusIdArr[1][0]):
branchDataIndx_radial.append(toBusIdArr[1][0].index(radialLineBusList[i]))
print branchDataIndx_radial
toBusIdArr):
branchDataIndx_radial.append(toBusIdArr.index(radialLineBusList[i]))
# Now save all the radial lines to two separate lists: one for fromBusId and the other for toBusId
fromBusId_radialLine = []
toBusId_radialLine = []
for i in range(len(branchDataIndx_radial)):
# keep in mind that fromBusIdArr and toBusIdArr are sorted in the same order
fromBusId_radialLine.append(fromBusIdArr[1][0][branchDataIndx_radial[i]])
toBusId_radialLine.append(toBusIdArr[1][0][branchDataIndx_radial[i]])
print fromBusId_radialLine
print fromBusId_radialLine.append(fromBusIdArr[branchDataIndx_radial[i]])
toBusId_radialLine.append(toBusIdArr[branchDataIndx_radial[i]])
return fromBusId_radialLine, toBusId_radialLine
return