Ask Your Question
1

PSSE transmission line series elements

asked 2024-09-12 13:59:18 -0500

SDA gravatar image

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()
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2024-09-15 09:33:28 -0500

jconto gravatar image

A simple algorithm: for every branch connected to a bus in list BUSES2, write a "branch off" contingency:

path = <path to case>
psspy.case(path+'\\savnw.sav')
ctgfile = path + '\\P2.con'
BUSES2 = [154, 153, 203]

def GetBranches(x):
    tobusArray=[]
    CktArray=[]
    ierr = psspy.inibrn(x,2)
    while ierr==0:
        ierr, NextBus, NextCkt = psspy.nxtbrn(x) 
        if ierr == 0:
            tobusArray.append(NextBus)
            CktArray.append(str(NextCkt))
    return tobusArray, CktArray
#_________________________________________________________   
temp1 = []
text_file = open(ctgfile,'w')
for StartBus in BUSES2:
    temp1.append(StartBus)
    tobuses=[]
    ckts = []
    tobuses,ckts = GetBranches(StartBus)
    print('Branches off bus ',StartBus)
    print(tobuses, ckts)
    for i in range(len(tobuses)):
        jbus = tobuses[i]
        ickt = ckts[i]
        if jbus in temp1:continue   # already branch processed!
        # write ctg txt
        text_file.write('CONTINGENCY Branch_%s-%s-%s\n' %(StartBus, jbus, ickt))
        text_file.write('DISCONNECT BRANCH FROM BUS %s TO BUS %s CKT %s\n' %(StartBus, jbus, ickt))
        text_file.write('END\n')         
text_file.close()
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Question Tools

Stats

Asked: 2024-09-12 13:59:18 -0500

Seen: 119 times

Last updated: Sep 15