ierr, all_bus = psspy.abusint(-1, 1, ['NUMBER'])
        bus_num = all_bus[0]

        #Load Bus
        psspy.bsys(sid=1, numbus=len(bus_num), buses=bus_num)
        ierr, load_bus = psspy.alodbusint(1, 1, ['NUMBER'])
        load_bus = load_bus[0]

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

        #change the load and the generation
        percentage = 1 - (current_percentage - 5) / current_percentage
        pssepylib.change_load(load_bus, percentage)
        increment = pssepylib.LoadIncreaseMW(load_bus, percentage)
        pssepylib.change_gen(gen_bus, increment)

        # try:
        #   load_real_sum = sum(load_real)
        # except:
        #   pdb.set_trace()

        # run load flow
        #psspy.case(savecase)
        psspy.fdns()

        # check convergency
        N = psspy.solved()
Exemple #2
0
            change_gen(gen_bus_region[0], loadIncrement_region1)
            change_gen(gen_bus_region[1], loadIncrement_region2)
            change_gen(gen_bus_region[2], loadIncrement_region3)

            savecase = 'ieee118bus_divided_temp.sav'
            psspy.save(savecase)

            # secure or not
            psspy.case(savecase)
            psspy.fnsl()

            # check convergency
            N = psspy.solved()

            [bus_voltage, bus_angle] = powerlib.getMeasurements(response_buses)

            # check voltage violation
            if N == 0:
                # get bus measurements number
                [bus_voltage,
                 bus_angle] = powerlib.getMeasurements(response_buses)
                voltage_violation = 0
                for vol_index in range(0, len(bus_voltage)):
                    if bus_voltage[vol_index] <= 0.844:
                        voltage_violation = 1
                        violation_index = vol_index
                if voltage_violation == 1:
                    secure.append(2)
                    S = 2
                    Vol_violation.append(1)
        ierr,all_bus = psspy.abusint(-1,1,['NUMBER'])
        bus_num = all_bus[0]

        #Load Bus
        psspy.bsys(sid = 1,numbus = len(bus_num), buses = bus_num)
        ierr,load_bus = psspy.alodbusint(1,1,['NUMBER'])
        load_bus = load_bus[0]

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

        #change the load and the generation
        percentage = 1-(current_percentage-5)/current_percentage
        pssepylib.change_load(load_bus, percentage)
        increment = pssepylib.LoadIncreaseMW(load_bus, percentage)
        pssepylib.change_gen(gen_bus, increment)

        # try:
        #   load_real_sum = sum(load_real)
        # except:
        #   pdb.set_trace()

        # run load flow
        #psspy.case(savecase)
        psspy.fdns()

        # check convergency
        N = psspy.solved()