示例#1
0
    def readTrafoRatios(self):
        '''
        Reads and stores 2WindingTrafo ratios taking into account the primary side
        '''
        ierr1, [self.twoWTrafoRatio1] = psspy.atrnreal(-1, 1, 1, 2, 1, 'RATIO')
        ierr2, [self.twoWTrafoRatio2] = psspy.atrnreal(-1, 1, 1, 2, 1, 'RATIO2')

        assert (ierr1 == 0) and (ierr2 == 0), 'Error with reading trafo bus numbers'
        return self.twoWTrafoRatio1, self.twoWTrafoRatio2
示例#2
0
    def readTrafoRatios(self):
        '''
        Reads and stores 2WindingTrafo ratios taking into account the primary side
        '''
        ierr1, [self.twoWTrafoRatio1] = psspy.atrnreal(-1, 1, 1, 2, 1, 'RATIO')
        ierr2, [self.twoWTrafoRatio2] = psspy.atrnreal(-1, 1, 1, 2, 1, 'RATIO2')

        assert (ierr1 == 0) and (ierr2 == 0), 'Error with reading trafo bus numbers'
        return self.twoWTrafoRatio1, self.twoWTrafoRatio2
示例#3
0
def get_transformer_ratio(bus_num):
    psspy.bsys(sid=1, numbus=2, buses=bus_num)
    ierr, ratio = psspy.atrnreal(sid=1,
                                 owner=2,
                                 ties=1,
                                 flag=2,
                                 entry=1,
                                 string=['RATIO2'])
    return ratio[0]
# silent the output
output = StringIO.StringIO()
with silence(output):
    psspy.case(r"""C:\Users\niezj\Desktop\16a_Fall\openECA_proj\LocalVoltageControl20161110\Test2\2019SUM_2013Series_Updated_forLocalVoltageControl.sav""")
    savecase = (r"""C:\Users\niezj\Desktop\16a_Fall\openECA_proj\LocalVoltageControl20161110\Test2\2019SUM_2013Series_Updated_forLocalVoltageControl_BenchMark.sav""")
    psspy.save(savecase)
    psspy.case(savecase)

    # determine the ratio and power flow of transformers
    bus_num = [314691,314692]
    psspy.bsys(sid = 1,numbus = 2, buses = bus_num)
    sid = 1
    flag = 2 # 2 = all non-tx branches 4 = all two-winding and non-transformer branches
    entry = 1 #1 = every branch once 2 = every branch from both sides
    ties = 1 # 1 = inside subsystem lines, # 2 = ties only, # 3 = everything
    ierr,ratio = psspy.atrnreal(sid,2,ties,flag,entry,['RATIO2'])

    ratio =ratio[0]
    fromflow = []
    for i in range(0,len(bus_num)):
        k = i + 1
        fromflow.append(brnflo(bus_num[1],bus_num[0],str(k)))

    ReactivePowerDifference = abs(fromflow[0].imag - fromflow[1].imag)
    RealPowerDifference = abs(fromflow[0].real - fromflow[1].real)

    # Scale up the load at certain percentage
    change_load(ScaleLoadAtBuses,percentage)
    load = aloadreal(0,1,'TOTALACT')
    load = load[0]
示例#5
0
    ##print CapSubstationName
    ##print '\n'
    ##print CapControl

    # Load the PSSE save case
    psspy.case(testCaseName)
    savecase = (testCaseName)
    psspy.save(savecase)

    # determine the ratio and power flow of transformers
    psspy.bsys(sid=1, numbus=2, buses=bus_num)
    sid = 1
    flag = 2  # 2 = all non-tx branches 4 = all two-winding and non-transformer branches
    entry = 1  #1 = every branch once 2 = every branch from both sides
    ties = 1  # 1 = inside subsystem lines, # 2 = ties only, # 3 = everything
    ierr, ratio = psspy.atrnreal(sid, 2, ties, flag, entry, ['RATIO2'])
    ratio = ratio[0]
    fromflow = []
    for i in range(0, len(bus_num)):
        k = i + 1
        fromflow.append(brnflo(bus_num[1], bus_num[0], str(k)))

    # Load the PSSE save case
    psspy.case(testCaseName)
    savecase = (testCaseName)
    psspy.save(savecase)

    # determine the ratio and power flow of transformers
    psspy.bsys(sid=1, numbus=2, buses=bus_num)
    sid = 1
    flag = 2  # 2 = all non-tx branches 4 = all two-winding and non-transformer branches
示例#6
0
    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
            }