コード例 #1
0
ファイル: readRaw.py プロジェクト: aihill/Raw2Record
 def readMachines(self):
     '''
     Reads and stores bus numbers where generators are connected
     '''
     ierr, [self.machineBusNumbers] = psspy.amachint(-1, 4, 'NUMBER')
     ierr, [self.machineIDs] = psspy.amachchar(-1, 4, 'ID')
     assert ierr == 0, 'Error with reading generator bus numbers'
     return self.machineBusNumbers, self.machineIDs
コード例 #2
0
ファイル: readRaw.py プロジェクト: SmarTS-Lab/Raw2Record
 def readMachines(self):
     '''
     Reads and stores bus numbers where generators are connected
     '''
     ierr, [self.machineBusNumbers] = psspy.amachint(-1, 4, 'NUMBER')
     ierr, [self.machineIDs] = psspy.amachchar(-1, 4, 'ID')
     assert ierr == 0, 'Error with reading generator bus numbers'
     return self.machineBusNumbers, self.machineIDs
コード例 #3
0
ファイル: readraw.py プロジェクト: espenfb/SmartTS_Lab
    def read_raw(self):
        ''' Read the raw file.'''

        # Read bus numbers
        ierr, bus_numbers = psspy.abusint(-1, 2, 'NUMBER')

        assert ierr == 0, 'Error with reading bus numbers'

        # Reads voltage levels at buses stored in self.busNumbers
        ierr, voltage_levels = psspy.abusreal(-1, 2, 'PU')

        assert ierr == 0, 'Error reading voltage levels'

        # Reads voltage levels at buses stored in self.busNumbers
        ierr, voltage_angles = psspy.abusreal(-1, 2, 'ANGLED')

        assert ierr == 0, 'Error reading voltage angles'

        # Creates a Python dictionary containing bus numbers as keys and associates
        # a dictionary with voltage and angle to each of the keys
        for bus, voltage, angle in zip(bus_numbers[0], voltage_levels[0],
                                       voltage_angles[0]):
            self.buses[bus] = {'voltage': voltage, 'angle': angle}

        # Reads and stores bus numbers where generators are connected
        ierr, [machine_bus_numbers] = psspy.amachint(-1, 4, 'NUMBER')
        ierr, [machine_ids] = psspy.amachchar(-1, 4, 'ID')
        assert ierr == 0, 'Error reading generator bus numbers'

        # Reads and stores active and reactive powers of each generator
        ierr1, [machine_power_p] = psspy.amachreal(-1, 4, 'PGEN')
        ierr2, [machine_power_q] = psspy.amachreal(-1, 4, 'QGEN')

        assert ierr1 == 0 and ierr2 == 0, 'Error with reading active and reactive powers'

        # Creates a Python dictionary containing keys in form of
        # "BUSNUMBER_MACHINEID" and associates a dictionary with active and
        # reactive powers to each of the keys
        for k in range(0, len(machine_ids)):
            self.machines[(str(machine_bus_numbers[k]) + '_' +
                           machine_ids[k][:-1])] = {
                               'bus': machine_bus_numbers[k],
                               'P': machine_power_p[k],
                               'Q': machine_power_q[k]
                           }

        # Reads and stores bus numbers where loads are connected
        ierr, [load_bus_numbers] = psspy.aloadint(-1, 4, 'NUMBER')
        ierr, [load_ids] = psspy.aloadchar(-1, 4, 'ID')
        assert ierr == 0, 'Error reading load bus numbers'

        # Reads and stores active and reactive powers of each load
        ierr1, [load] = psspy.aloadcplx(-1, 4, 'TOTALACT')
        load_power_p = []
        load_power_q = []
        for cplxload in load:
            load_power_p.append(cplxload.real)
            load_power_q.append(cplxload.imag)

        assert ierr1 == 0, 'Error with reading active and reactive powers'

        # Creates a Python dictionary containing keys in form of
        # "BUSNUMBER_LOADID" and associates a dictionary with active and
        # reactive powers to each of the keys

        for load, bus, active, reactive in zip(load_ids, load_bus_numbers,
                                               load_power_p, load_power_q):
            self.loads[(str(bus) + '_' + load[:-1])] = {
                'bus': bus,
                'P': active,
                'Q': reactive
            }

        # Reads and stores bus numbers where 2WindingTrafos are connected
        ierr1, [two_w_trafo_from] = psspy.atrnint(-1, 1, 1, 2, 1, 'FROMNUMBER')
        ierr2, [two_w_trafo_to] = psspy.atrnint(-1, 1, 1, 2, 1, 'TONUMBER')

        assert ierr1 == 0 and ierr2 == 0, 'Error reading trafo bus numbers'

        # Reads and stores 2WindingTrafo ratios taking into account the primary side
        ierr1, [two_w_trafo_ratio1] = psspy.atrnreal(-1, 1, 1, 2, 1, 'RATIO')
        ierr2, [two_w_trafo_ratio2] = psspy.atrnreal(-1, 1, 1, 2, 1, 'RATIO2')

        assert ierr1 == 0 and ierr2 == 0, 'Error reading trafo bus numbers'

        # Creates a Python dictionary containing keys in form of
        # "BUSNUMBER_LOADID" and associates a dictionary with active and
        # reactive powers to each of the keys
        for f_bus, to_bus, ratio1, ratio2 in zip(two_w_trafo_from,
                                                 two_w_trafo_to,
                                                 two_w_trafo_ratio1,
                                                 two_w_trafo_ratio2):
            self.trafos[(str(f_bus) + '_' + str(to_bus))] = {
                'fromBus': f_bus,
                'toBus': to_bus,
                't1': ratio1,
                't2': ratio2
            }
コード例 #4
0
        # scan the inl file to make sure the Pmax and Pmin element for each record is not 0.0, or equal
        # creat new inl file if there is any Pmax = Pmin
        # PSS/E ACCC function will not dispatch generators if Pmax = Pmin

        print(
            '------------------start checking Pmax Pmin in inl file -------------------'
        )

        ierr, iarray = psspy.amachint(-1, 4, 'NUMBER')
        vgenbusnotmp = iarray[
            0]  # this array has all the generator's bus number, including both in-service and out-service
        ierr, iarray = psspy.amachint(-1, 4, 'STATUS')
        vgenstatustmp = iarray[
            0]  # this array has all the generator's status: in-service (1) and out-service (0)
        ierr, carray = psspy.amachchar(-1, 4, 'ID')
        vgenidtmp = carray[0]  # this array has all the generator's ID, string
        ierr, rarray = psspy.amachreal(-1, 4, 'PMAX')
        vgenpmaxtmp = rarray[
            0]  # this array has all the generator's Active power output P, MW
        ierr, rarray = psspy.amachreal(-1, 4, 'PMIN')
        vgenpmintmp = rarray[
            0]  # this array has all the generator's Reactive power output Q, MVar

        geninfotmp = zip(vgenpmaxtmp, vgenpmintmp)
        genbusdicttmp = {}
        for igentmp in range(0, len(vgenbusnotmp)):
            genbusdicttmp.update({vgenbusnotmp[igentmp]: geninfotmp[igentmp]})

        #shutil.copyfile (fileINL, fileINL[:-4]+'_org.inl') #first keep a copy of the original inl file
        fileINLorg = fileINL[:-4] + '_org.inl'
コード例 #5
0
with silence(output):

    psspy.psseinit(80000)  # initialize PSS\E in python
    savecase = 'ieee118bus_PSSEcorrected_rq.sav'
    psspy.case(savecase)

    # find all the buses
    psspy.bsys(0, 0, [0.0, 0.0], 1, [1], 0, [], 0, [], 0, [])
    ierr, all_bus = psspy.abusint(0, 1, ['number'])
    bus_num = all_bus[0]

    #List of all machines
    psspy.bsys(sid=1, numbus=len(bus_num), buses=bus_num)
    ierr, machine_bus = psspy.amachint(1, 1, ['NUMBER'])
    machine_bus = machine_bus[0]
    ierr, machine_id = psspy.amachchar(1, 1, ['ID'])
    machine_id = machine_id[0]

    #List of all load
    psspy.bsys(sid=1, numbus=len(bus_num), buses=bus_num)
    ierr, load_bus = psspy.alodbusint(1, 1, ['NUMBER'])
    load_bus = load_bus[0]
    ierr, load_id = psspy.aloadchar(1, 1, ['ID'])
    load_id = load_id[0]

    #List of branches
    ierr, internal_linesfbtb = psspy.abrnint(sid=1,
                                             ties=1,
                                             flag=1,
                                             string=['FROMNUMBER', 'TONUMBER'])
    ierr, internal_linesid = psspy.abrnchar(sid=1,
コード例 #6
0
    psspy.psseinit(80000)             # initialize PSS\E in python
    savecase = 'IEEE 57 bus.sav'
    psspy.case(savecase)


    # find all the buses
    psspy.bsys(0,0,[0.0,0.0],1,[1],0,[],0,[],0,[])
    ierr,all_bus = psspy.abusint(0,1,['number'])
    bus_num = all_bus[0]

    #List of all machines
    psspy.bsys(sid = 1,numbus = len(bus_num), buses = bus_num)
    ierr,machine_bus = psspy.amachint(1,1,['NUMBER'])
    machine_bus = machine_bus[0]
    ierr,machine_id =  psspy.amachchar(1,1,['ID'])
    machine_id = machine_id[0]

    #List of all Gen
    psspy.bsys(sid = 1,numbus = len(bus_num), buses = bus_num)
    ierr,gen_bus = psspy.agenbusint(1,1,['NUMBER'])
    gen_bus = gen_bus[0]

    #List of all load
    psspy.bsys(sid = 1,numbus = len(bus_num), buses = bus_num)
    ierr,load_bus = psspy.alodbusint(1,1,['NUMBER'])
    load_bus = load_bus[0]
    ierr,load_id =  psspy.aloadchar(1,1,['ID'])
    load_id = load_id[0]

    #List of branches