First time here? We are a friendly community of Power Systems Engineers. Check out the FAQ!
1 | initial version |
I'm trying to create a transmission line circuit contingency generator that will outage all series elements of a line. I'm having a hard time making it past the third series element. Any help is appreciated.
def GetNextBus():
NextBusArray=[]
NextCktArray=[]
ierr = psspy.inibrn(int(x),2)
text_file.write('CONTINGENCY %s\n' %(StartBus))
while ierr==0:
ierr, NextBus, NextCkt = psspy.nxtbrn(int(x))
if ierr == 0:
NextBusArray.append(str(NextBus))
NextCktArray.append(str(NextCkt))
NextBusArray2 = NextBusArray
text_file.write('DISCONNECT BRANCH FROM BUS %s TO BUS %s CKT %s\n' %(x, NextBus, NextCkt))
# for index, k in enumerate(NextBusArray2):
# if k not in BUSES2:
# GetNextBus()
# else:
# text_file.write('DISCONNECT BRANCH FROM BUS %s TO BUS %s CKT %s\n' %(StartBus, x, ickt))
text_file.write('END\n')
#
#
for i in BUSES2:
Temp1 = []
tobuses=[]
ckts = []
StartBus = str(i)
ierr = psspy.inibrn(int(StartBus),2)
while ierr==0:
ierr, jbus, ickt = psspy.nxtbrn(int(StartBus))
if ierr == 0:
tobuses.append(str(jbus))
ckts.append(str(ickt))
Temp1 = tobuses
for index, x in enumerate(Temp1):
if x not in BUSES2:
GetNextBus()
else:
text_file.write('CONTINGENCY %s\n' %(StartBus))
text_file.write('DISCONNECT BRANCH FROM BUS %s TO BUS %s CKT %s\n' %(StartBus, x, ickt))
text_file.write('END\n')
text_file.close()