Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I've done something that could help with this. I wanted to export portions of a subtransmission system from one model to use in another model.

I used a recursive DFS method to find buses of a similar or lower voltage level to the POI, stopping at any normally open branches or step-up transformers. I'm quite sure you could adapt this code to fit your needs.

def getBusList(POIs, bus_list):
    for POI in POIs:
        bus_list.append(POI) #add bus to list
        ierr, POI_voltage = psspy.busdat(POI,'BASE') #get source base kV

        n = 0 #for tracking branch the search is on

        #initialize and find first branch from source bus
        ierr = psspy.inibrn(POI, 2)
        ierr, jbus, kbus, ickt = psspy.nxtbrn3(POI)

        while ierr == 0:

            #necessary type conversions
            jbus = int(jbus)
            kbus = int(kbus)
            ickt = str(ickt)

            #search jbus for further branches
            ierr, status = psspy.brnint(POI,jbus,ickt,'STATUS')
            #stop at NOs and don't get duplicate buses
            if (status != 0) & (jbus not in bus_list):
                ierr, branch_voltage = psspy.busdat(jbus,'BASE')
                if POI_voltage >= branch_voltage: #don't go to higher voltage branches
                    getBusList([jbus], bus_list)

            # if there's a 3-winding transformer, search kbus for further branches
            if (kbus != 0) & (kbus not in bus_list):
                ierr, status = psspy.brnint(POI,kbus,ickt,'STATUS')
                #stop at NOs and don't get duplicate buses
                if (status != 0) & (kbus not in bus_list):
                    ierr, branch_voltage = psspy.busdat(kbus,'BASE')
                    if source_voltage >= branch_voltage: #don't go to higher voltage branches
                        getBusList([kbus], bus_list)