Exemple #1
0
 def change_prod_con(self,
                     areas,
                     prod,
                     con,
                     pf,
                     tol=4,
                     row=None,
                     column=None):
     """Wrapper function to change load and production
     Args:
         areas: area number
         prod: production
         con: consumption
         pf: power factor
         tol: tolerance for round
         row: which row to write to
         column: which column to write to
     """
     psspy.bsys(sid=0, numarea=1, areas=[areas])
     psspy.scal_2(0, 0, 0, [0, 1, 1, 1, 0], [
         con, prod, 0.0, 0.0, 0.0, 0.0,
         round(con * math.tan(math.acos(pf)), tol)
     ])
     if self.to_excel:
         self.sheet.cell(row=row, column=column).value = prod
         self.sheet.cell(row=row, column=column + 1).value = con
Exemple #2
0
    def select_channel(self, signal_list):
        psspy.delete_all_plot_channels()

        for i in signal_list.keys():
            bus_list = signal_list.get(i)[0]
            if bus_list:
                psspy.bsys(sid=i, numbus=len(bus_list), buses=bus_list)
            variable_list = signal_list.get(i)[1]
            for variable in variable_list:
                f = None
                if variable == 'STATE':
                    f = psspy.state_channel
                elif variable == 'VAR':
                    f = psspy.var_channel

                if f is not None:
                    for j in bus_list:
                        f(status=[-1, j], ident=variable + str(j))
                else:
                    list_ = [
                        -1, -1, -1, 1,
                        map_Signal2Channel.get(variable), 1
                    ]
                    if bus_list:
                        psspy.chsb(i, 0, list_)
                    else:
                        psspy.chsb(0, 1, list_)
        psspy.strt(0, self.out_file)
Exemple #3
0
def getMeasurements(response_buses):
    psspy.bsys(sid=1, numbus=len(response_buses), buses=response_buses)
    ierr, bus_voltage = psspy.abusreal(1, 1, ['PU'])
    bus_voltage = bus_voltage[0]
    ierr, bus_angle = psspy.abusreal(1, 1, ['ANGLE'])
    bus_angle = bus_angle[0]
    return bus_voltage, bus_angle
Exemple #4
0
def one_bus_subsys(sid, bus_id):
    """Function to create a subsys consisting of one bus.
        Input:
            sid: The id of the subsystem
            bus_id: The number of the bus
    """

    psspy.bsys(sid, 0, [0.0, 0.0], 0, [], 1, [bus_id], 0, [], 0, [])
Exemple #5
0
def change_load(load_bus, percentage):
    psspy.bsys(0, 0, [0.0, 0.0], 0, [], len(load_bus), load_bus, 0, [], 0, [])
    psspy.scal(sid=0,
               all=0,
               apiopt=0,
               status1=2,
               status3=1,
               status4=1,
               scalval1=percentage)
Exemple #6
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]
Exemple #7
0
 def _setPEVOutputPower(self, power, bus):
     """Sets the PEV power for a specified bus"""
     psspy.bsys(0, 0, [345., 345.], 3, [1, 2, 3], 1, [bus], 1, [2], 0, [])
     psspy.scal_2(0, 0, 0, [psspy._i, 1, 0, 0, 0],
                  [power, 0.0, 0.0, -.0, 0.0, -.0, 1.0])
     psspy.scal_2(0, 0, 1, [psspy._i, 1, 0, 0, 0],
                  [power, 0.0, 0.0, -.0, 0.0, -.0, 1.0])
     psspy.scal_2(0, 0, 2, [psspy._i, 1, 0, 0, 0],
                  [power, 0.0, 0.0, -.0, 0.0, -.0, 1.0])
def scale_gen(MW_change, list_redispatched_gen):

    # Define a new subsystem (call it nbr 3) --all gen that will be redispatched
    psspy.bsys(1, 0, [0.0, 0.0], 0, [], len(list_redispatched_gen),
               list_redispatched_gen, 0, [], 0, [])
    psspy.scal_2(1, 0, 1, [0, 0, 0, 0, 0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
    psspy.scal_2(0, 1, 2, [_i, 3, 1, 4, 0],
                 [0.0, MW_change, 0.0, 0.0, 0.0, 0.0, 0.95])

    return
 def _setPEVTotalOutputPower(self,power):
     """Set the pevs total output power. The individual PEV power is proportional to the P at that bus"""
     #PEVs needs to be defined with owner number 2
     total_power = sum(pev._P for pev in self._simulation._power_system_object._pevs)
     for pev in self._simulation._power_system_object._pevs:
         p_to_set = pev._P/total_power*power
         psspy.bsys(0,0,[ 345., 345.],3,[1,2,3],1,[pev._bus],1,[2],0,[])
         psspy.scal_2(0,0,0,[psspy._i,1,0,0,0],[p_to_set,0.0,0.0,-.0,0.0,-.0, 1.0])
         psspy.scal_2(0,0,1,[psspy._i,1,0,0,0],[p_to_set,0.0,0.0,-.0,0.0,-.0, 1.0])
         psspy.scal_2(0,0,2,[psspy._i,1,0,0,0],[p_to_set,0.0,0.0,-.0,0.0,-.0, 1.0])
Exemple #10
0
def convertLoads(load_representation=[0.0, 100.0, 0.0, 100.0]):
    #group all the buses into a common subsystem, when they don't belong to the same area
    #owner number 2 is reserved for AEV loads
    psspy.bsys(0, 0, [345., 345.], 3, [1, 2, 3], 0, [], 1, [1], 0, [])
    #then convert the subsystem of buses
    #init conversion = 1
    psspy.conl(0, 0, 1, [0, 0], load_representation)
    #do conversion = 2
    psspy.conl(0, 0, 2, [0, 0], load_representation)
    #clean up = 3
    psspy.conl(0, 0, 3, [0, 0], load_representation)
Exemple #11
0
def get_shunt_voltage(bus_num):
    psspy.bsys(sid=1, numbus=1, buses=bus_num[0])
    ierr, shunt_Pamplin_voltage = psspy.abusreal(1, 1, ['PU'])
    shunt_Pamplin_voltage = shunt_Pamplin_voltage[0][0]

    psspy.bsys(sid=1, numbus=1, buses=bus_num[1])
    ierr, shunt_Crewe_voltage = psspy.abusreal(1, 1, ['PU'])
    shunt_Crewe_voltage = shunt_Crewe_voltage[0][0]

    shunt_bus_voltage = [shunt_Pamplin_voltage, shunt_Crewe_voltage]
    return shunt_bus_voltage
Exemple #12
0
def set_load_increment_percentage(bus_num, percentage):
    load_bus_num = get_load_bus(bus_num)
    psspy.bsys(0, 0, [0.0, 0.0], 0, [], len(load_bus_num), load_bus_num, 0, [],
               0, [])
    psspy.scal(sid=0,
               all=0,
               apiopt=0,
               status1=2,
               status3=1,
               status4=1,
               scalval1=percentage)
Exemple #13
0
 def _setPEVTotalOutputPower(self, power):
     """Set the pevs total output power. The individual PEV power is proportional to the P at that bus"""
     #PEVs needs to be defined with owner number 2
     total_power = sum(
         pev._P for pev in self._simulation._power_system_object._pevs)
     for pev in self._simulation._power_system_object._pevs:
         p_to_set = pev._P / total_power * power
         psspy.bsys(0, 0, [345., 345.], 3, [1, 2, 3], 1, [pev._bus], 1, [2],
                    0, [])
         psspy.scal_2(0, 0, 0, [psspy._i, 1, 0, 0, 0],
                      [p_to_set, 0.0, 0.0, -.0, 0.0, -.0, 1.0])
         psspy.scal_2(0, 0, 1, [psspy._i, 1, 0, 0, 0],
                      [p_to_set, 0.0, 0.0, -.0, 0.0, -.0, 1.0])
         psspy.scal_2(0, 0, 2, [psspy._i, 1, 0, 0, 0],
                      [p_to_set, 0.0, 0.0, -.0, 0.0, -.0, 1.0])
Exemple #14
0
def findFixedShunt(bus):

    psspy.bsys(sid = 1,numbus = len(bus), buses = bus)
    ierr,bus_fixedshunt = psspy.afxshuntcplx(1,1,['SHUNTACT'])
    bus_fixedshunt = bus_fixedshunt[0]
    # bus_fixedshunt = [x*1j for x in bus_fixedshunt]

    ierr,busNumber = psspy.afxshuntint(1,1,['NUMBER'])
    busNumber = busNumber[0]

    FixedShunt = {}
    for i in range(0,len(busNumber)):
        FixedShunt[busNumber[i]] = bus_fixedshunt[i]

    return FixedShunt
Exemple #15
0
def findAllBusType(bus_num):
    psspy.bsys(sid=1, numbus=len(bus_num), buses=bus_num)
    ierr,bus_type = psspy.abusint(1,1,'type')
    bus_type = bus_type[0]
    pq = []
    pv = []
    slackBus = []
    for index,bus in enumerate(bus_num):
        if bus_type[index] == 1:
            pq.append(bus)
        elif bus_type[index] == 2:
            pv.append(bus)
        elif bus_type[index] == 3:
            slackBus.append(bus)
    return pq,pv,slackBus
 def _increaseLoadAtBuses(self,load_buses,percent_change):
     #define the bus subsystem
     psspy.bsys(1,0,[0.0,0.0],0,[],len(load_buses),load_buses,1,[1],0,[])
     #prepare the load increase
     #in first array
     #1st zero = include all buses in the subsystem both interruptible and uninterrupted 
     #5th zero = loads of all types (1,2 and 3) 
     psspy.scal_2(1,0,1,[0,0,0,0,0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0])
     #increase the loads
     #in first array
     #2nd number = percent change
     #3rd number = ignore machine limits
     #4th number = increase the reactive load equally (in percents)
     #in second array 
     #1st number load increase
     _i = psspy.getdefaultint()
     psspy.scal_2(0,0,2,[_i,2,0,3,0],[ percent_change,0.0,0.0,0.0,0.0,0.0,0.0])
Exemple #17
0
def reduceModel(zonebuses):
    # Reduce the model
    psspy.bsys(sid=1, numbus=len(zonebuses), buses=zonebuses)
    psspy.gnet(sid=1, all=0)
    psspy.island()
    psspy.fdns(options=[1, 0, 1, 1, 1, 0, 0, 0])
    psspy.eeqv(sid=1, all=0, status=[0, 0, 0, 0, 1, 0], dval1=0)
    psspy.island()
    ierr = psspy.fdns(options=[1, 0, 1, 1, 1, 0, 0, 0])
    ival = psspy.solved()
    reducedModelName = "reduced"
    print "ival equal to "
    print ival
    if ival == 0:
        psspy.save(reducedModelName)
    else:
        return None
    return reducedModelName
Exemple #18
0
def getGenReactivePowerMin(busNumber):
    psspy.bsys(sid=0, numbus=len(busNumber), buses=busNumber)
    ierr,reactivePowerMin = psspy.agenbusreal(0,1,'QMIN')
    return reactivePowerMin[0]
Exemple #19
0
def getGenReactivePowerOutput(busNumber):
    psspy.bsys(sid=0, numbus=len(busNumber), buses=busNumber)
    ierr,reactivePowerOutput = psspy.agenbusreal(0,1,'QGEN')
    return reactivePowerOutput[0]
 def _setPEVOutputPower(self,power,bus):
     """Sets the PEV power for a specified bus"""
     psspy.bsys(0,0,[ 345., 345.],3,[1,2,3],1,[bus],1,[2],0,[])
     psspy.scal_2(0,0,0,[psspy._i,1,0,0,0],[power,0.0,0.0,-.0,0.0,-.0, 1.0])
     psspy.scal_2(0,0,1,[psspy._i,1,0,0,0],[power,0.0,0.0,-.0,0.0,-.0, 1.0])
     psspy.scal_2(0,0,2,[psspy._i,1,0,0,0],[power,0.0,0.0,-.0,0.0,-.0, 1.0])
Exemple #21
0
def findBusesArea(buses):
    psspy.bsys(sid=1, numbus=len(buses), buses=buses)
    ierr,buses_area = psspy.abusint(1, 1, ['AREA'])
    buses_area = buses_area[0]
    return buses_area
Exemple #22
0
            record_inspected_bus_current = []
            record_inspected_bus_line_bus_info = []
            inspected_bus_number = 64

            # silent the output
            output = StringIO.StringIO()
            with silence(output):

                # pick the bus in Dominion Area 345 is the index of Dominion
                psspy.case(savecase)
                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]

                # Choose the proper case
                current_percentage = (1 + percent_set[index]) * 100
                level = math.ceil(current_percentage / 5)
                case_percent = level * 5
                case_name_constant = "IEEE_118_%s.sav"
                current_CASE = case_name_constant % case_percent
                psspy.case(current_CASE)
    case_name_constant = "IEEE_118_%s.sav"
    PSSE_CASE = case_name_constant % current_percentage
    psspy.case(PSSE_CASE)

    # silent the output
    output = StringIO.StringIO()
    with silence(output):

        #pick the bus in Dominion Area 345 is the index of Dominion
        psspy.case(savecase)
        # psspy.bsys(0,0,[ 0.2, 999.],1,[],0,[],0,[],0,[])
        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:
Exemple #24
0
def LoadIncreaseMW(load_bus, percentage):
    psspy.bsys(0, 0, [0.0, 0.0], 0, [], len(load_bus), load_bus, 0, [], 0, [])
    ierr, allBusLoad = psspy.aloadcplx(0, 1, ['MVAACT'])
    allBusLoad = allBusLoad[0]
    BusLoadReal = np.real(allBusLoad)
    return np.sum(BusLoadReal) * percentage / 100
                                 [r"""P Injection""", r"""Q Injection"""])
    ierr = psspy.machine_array_channel([6, 2, 500], r"""1""",
                                       r"""Pelec Inverter""")
    ierr = psspy.machine_array_channel([7, 3, 500], r"""1""",
                                       r"""Qelec Inverter""")

    [ierr, var_ppc_conp] = psspy.mdlind(500, '1', 'EXC', 'CON')
    [ierr, var_ppc_setp] = psspy.mdlind(500, '1', 'EXC', 'VAR')
    [ierr, var_ppc_mode] = psspy.mdlind(500, '1', 'EXC', 'ICON')
    [ierr, var_inv1_con] = psspy.mdlind(500, '1', 'GEN', 'CON')
    [ierr, var_inv1_var] = psspy.mdlind(500, '1', 'GEN', 'VAR')
    [ierr, var_inv1_mod] = psspy.mdlind(500, '1', 'GEN', 'ICON')

    # convert load , do not change
    psspy.cong(0)
    psspy.bsys(0, 0, [0.0, 500.], 1, [7], 0, [], 0, [], 0, [])
    psspy.bsys(0, 0, [0.0, 500.], 1, [7], 0, [], 0, [], 0, [])
    psspy.conl(0, 0, 1, [0, 0], [91.27, 19.36, -126.88, 188.43])
    psspy.conl(0, 0, 2, [0, 0], [91.27, 19.36, -126.88, 188.43])
    psspy.bsys(1, 0, [0.0, 0.0], 0, [], 6,
               [37600, 37601, 37602, 37580, 37584, 38588], 0, [], 0, [])
    psspy.conl(1, 0, 2, [0, 0], [52.75, 58.13, 5.97, 95.52])
    psspy.bsys(1, 0, [0.0, 0.0], 0, [], 1, [21790], 0, [], 0, [])
    psspy.conl(1, 0, 2, [0, 0], [86.63, 25.19, -378.97, 347.97])
    psspy.bsys(1, 0, [0.0, 0.0], 0, [], 1, [45082], 0, [], 0, [])
    psspy.conl(1, 0, 2, [0, 0], [51.36, 59.32, -228.04, 254.01])
    psspy.bsys(1, 0, [0.0, 0.0], 0, [], 9,
               [40320, 40340, 40350, 40970, 40980, 40990, 41050, 41071, 41120],
               0, [], 0, [])
    psspy.conl(1, 0, 2, [0, 0], [100.0, 0.0, 0.0, 100.0])
    psspy.conl(0, 1, 2, [0, 0], [100.0, 0.0, -306.02, 303.0])
        prtr = 13.49*i[1]*100/(2*50*1000.0) 
        prlo = i[1]*0.5/50.0
        x.add_row([i[0],i[1],i[2],i[3],diff,prtr,round(diff*prtr/100.0,4),prlo,round(diff*prlo/100.0,4)])
        tott = tott+(diff*prtr/100.0)
        totl = totl+(diff*prlo/100.0)
    x.add_row(['','','','','','Total',round(tott,4),'Total',round(totl,4)])
    mystr = x.get_string()
    return mystr
    
print 'Scenario-0 ----------------------------'
with open('output.txt','w') as fout:
    fout.write('Scenario-0\n')
    fout.write('----------\n')

psspy.fnsl()
ierr = psspy.bsys(sid=1, numzone=1, zones=44)
##ierr, loads = psspy.aloadreal(sid=1, flag=1, string='MVAACT')
##print loads
##ierr, gens = psspy.amachreal(sid=1, flag=1, string='PGEN')
##print gens
with silence(open('output.txt','a')):
    scaleLoadGen(1, -30.0, 0.9, -0.0)
with open('output.txt','a') as fout:
    fout.write('\n\n')


psspy.solv()
psspy.fnsl()
psspy.area_2(0,1,1)

with open('output.txt','a') as fout:
def change_load(load_bus,percentage):
    psspy.bsys(0,0,[0.0,0.0],0,[],len(load_bus),load_bus,0,[],0,[])
    psspy.scal(sid = 0,all = 0, apiopt = 0,status1 = 2, status3 = 1, status4 = 1, scalval1 = percentage)
Exemple #28
0
import redirect
import psspy
import dyntools
import csv

planningRaw = 'hls18v1dyn_1219.raw'
psse_log = 'log_planning_multTFLoad.txt'
redirect.psse2py()
psspy.psseinit(buses=80000)
# Silence all psse outputs
psspy.report_output(2, psse_log, [0, 0])
psspy.progress_output(6, psse_log, [0, 0])  #ignored
psspy.alert_output(6, psse_log, [0, 0])  #ignored
psspy.prompt_output(6, psse_log, [0, 0])  #ignored
##############################

ierr = psspy.read(0, planningRaw)

# File:"C:\Users\bikiran_remote\Desktop\report_bus_data.py", generated on MON, MAR 05 2018  19:33, release 33.03.00
for bus in LoadSet:
    ierr = psspy.bsys(1, 0, [0.0, 0.0], 0, [], 1, [int(bus)], 0, [], 0,
                      [])  # PAGE 1373 of API book
    ierr = psspy.lamp(1, 0)  # page 258 of API book
"""
with open(psse_log,'r') as f:
    filecontent = f.read()
    fileLines = filecontent.split('\n')

print fileLines[-1]
"""
    ##    print sys.argv[i]
    ##    print '\n'
    ##print CapControlSign
    ##print '\n'
    ##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)
######input######

# scale up the load


# 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)
Exemple #31
0
def getbus(region):
    region = region - 1
    psspy.bsys(0, 0, [0.6, 345.], 1, [region], 0, [], 0, [], 0, [])
    ierr, busInterestedRegion = psspy.abusint(1, 1, ['number'])
    busInterestedRegion = busInterestedRegion[0]
    return busInterestedRegion
##                             realar2=0.028150285, realar3=0.001087962)
##ierr = psspy.branch_data(44109, 44119, "4", intgar1=1, realar1=0.002781434,
##                         realar2=0.008661488, realar3=0.001763027)
##ierr = psspy.seq_branch_data(44109, 44119, "4", realar1=0.007021062,
##                             realar2=0.028150285, realar3=0.001087962)

#---------------------------------
# CTPS1 generation off
ierr = psspy.machine_data_2(44015, intgar1=0)  #CTPS gen1
ierr = psspy.machine_data_2(44016, intgar1=0)  #CTPS gen2
ierr = psspy.machine_data_2(44017, intgar1=0)  #CTPS gen3
ierr = psspy.load_data_3(44106, realar1=184.5)  #CHANDRAPURA
ierr = psspy.load_data_3(44202, realar1=300.)  #CTPS2

###-------------------------------
ierr = psspy.bsys(sid=1, numzone=1, zones=44)
ierr, all_buses = psspy.abusint(sid=1, string=["NUMBER"], flag=2)
all_buses = all_buses[0]
ierr, in_buses = psspy.abusint(sid=1, string=['NUMBER'], flag=1)
in_buses = in_buses[0]
out_buses = list(set(all_buses) - set(in_buses))
print out_buses
ierr = psspy.bsys(sid=2, numbus=len(out_buses), buses=out_buses)
ierr = psspy.extr(sid=2, all=0, status2=0)

##for i in range(len(out_buses)):
##     psspy.load_data_3(i, intgar1=0)
##
##ierr = psspy.bsys(sid=2, numbus=len(out_buses), buses=out_buses)
##ierr, in_branches = psspy.abrnint(sid=2, string=['FROMNUMBER', 'TONUMBER'],
##                                  flag=1)
Exemple #33
0
   def func_ca():
      # escribe el fichero de definición del subsistema para el caso de comunidades autónomas
      #se obtienen las zonas del estudio y se cuentan
      zonas = []
      zona = sistema.Sistema.split(',')
      for z in zona:
         zonas.append(int(z))

      #se mueven los buses una zona ficticia 99
      #primero es necesario obtener los buses de las zonas de estudio
      bus_list=redpsse.get_bus_number_by_zonas(zonas)
      l = bus_list.__len__()
      psspy.bsys(0, 0, [1, 400], 0, [], l, bus_list, 0, [], 0, [])
      #cambio la zona del subsistema a 99
      psspy.zonm_2(0, 0, [1, 1, 1], 99)
      #se resetea el subsistema
      psspy.bsysdef(0, 0)

      #se obtienen todas las zonas del caso
      zonas_caso = []
      zona_caso = redpsse.get_zonas()
      for zc in zona_caso:
         if zc.number != 99:
            zonas_caso.append(int(zc.number))
      nz=zonas_caso.__len__()

      #se obtienen las areas del caso
      areas = redpsse.get_areas()
      area_numbers=[]
      for x in areas:
         area_numbers.append(x.number)

      #si existe el area 9, se considera caso islas
      if 9 in area_numbers:
         Umin=parametros.U_min_i
         Umax=parametros.U_max_i
      else:
         Umin=parametros.U_min_p
         Umax=parametros.U_max_p


      # Ruta del fichero
      path = os.path.join(Rutas().ruta_casos_procesados, str(caso.N_Caso) + '_' + str(sistema.Nombre) + '.sub')
      Sub = open(path, 'w')
      # Escribimos el fichero
      Sub.write('SUBSYSTEM \'CON_MON\'\n')
      Sub.write('   JOIN GROUP_1\n')
      for area in area_numbers:
         if area not in [6,7,8]:
            Sub.write('      AREA ' + str(area) + '\n')
      Sub.write('      KVRANGE ' + str(Umin) +' '+ str(Umax)+ '\n')
      Sub.write('   END\n')
      Sub.write('END\n')
      Sub.write('SUBSYSTEM \'S.ESTUDIO\'\n')
      Sub.write('ZONE 99\n')
      Sub.write('END\n')
      Sub.write('SUBSYSTEM \'S.OPUESTO\'\n')
      for zonac in zonas_caso:
         Sub.write('ZONE ' + str(zonac) + '\n')
      for i in range(0,nz,1):
         Sub.write('END\n')
      Sub.write('END\n')

      return path
##                             realar2=0.028150285, realar3=0.001087962)
##ierr = psspy.branch_data(44109, 44119, "4", intgar1=1, realar1=0.002781434,
##                         realar2=0.008661488, realar3=0.001763027)
##ierr = psspy.seq_branch_data(44109, 44119, "4", realar1=0.007021062,
##                             realar2=0.028150285, realar3=0.001087962)

#---------------------------------
# CTPS1 generation off
ierr = psspy.machine_data_2(44015, intgar1=0) #CTPS gen1
ierr = psspy.machine_data_2(44016, intgar1=0) #CTPS gen2
ierr = psspy.machine_data_2(44017, intgar1=0) #CTPS gen3
ierr = psspy.load_data_3(44106, realar1=184.5) #CHANDRAPURA
ierr = psspy.load_data_3(44202, realar1=300.) #CTPS2

###-------------------------------
ierr = psspy.bsys(sid=1, numzone=1, zones=44)
ierr, all_buses = psspy.abusint(sid=1, string=["NUMBER"], flag=2)
all_buses = all_buses[0]
ierr, in_buses = psspy.abusint(sid=1, string=['NUMBER'], flag=1)
in_buses = in_buses[0]
out_buses = list(set(all_buses)-set(in_buses))
print out_buses
ierr = psspy.bsys(sid=2, numbus=len(out_buses), buses=out_buses)
ierr = psspy.extr(sid=2, all=0, status2=0)

##for i in range(len(out_buses)):
##     psspy.load_data_3(i, intgar1=0)
##
##ierr = psspy.bsys(sid=2, numbus=len(out_buses), buses=out_buses)
##ierr, in_branches = psspy.abrnint(sid=2, string=['FROMNUMBER', 'TONUMBER'],
##                                  flag=1)
Exemple #35
0
    list_of_area_data.append(area_row)

area_parameters.insert(0, "AREA")

list_of_area_data.insert(0, area_parameters)

#-------Gunnar:
#Get Line ratings and list of buses:
buses, line_rates = get_ratings_and_list_of_buses()

line_rates = line_rates.drop_duplicates()
#Define our buses as subsystem:
num_buses = len(buses)
SID = 8  #Do not use elsewhere (unique)

ierr = psspy.bsys(SID, 0, [0.4, 750.], 0, [], num_buses, buses, 0, [], 0, [])
'''
print(psspy.abuscount(SID,2))
print(psspy.abrncount(SID, 1, 1, 2, 1))
print(psspy.abrncount(SID, 1, 2, 2, 1))
print(psspy.abrncount(SID, 1, 3, 2, 1))
'''

#------//Gunnar

AREAS = []  #List of area numbers
for area in observable_areas:
    AREAS.append(area[1])

#Get all line flows
#----------------------------

psspy.solution_parameters_2(intgar1=150)
psspy.fdns(option1=0, #tap adjustment disabled
           option2=0, #area interchange disables
           option3=0, #phase shift option disabled
           option4=0, #dc tap adjustment option disabled
           option5=0, #switched shunt adjustment option disabled
           )
psspy.fnsl()
psspy.inibus(0)
#ierr = psspy.pout(sid=1, all=0)
#n = psspy.totbus()

ierr = psspy.bsys(sid=1, numzone=1, zones=44)
businfo = subsystem_info('bus', ['NUMBER', 'BASE', 'NAME'], sid=-1)
#print businfo
mybuslst = subsystem_info('bus', ['NUMBER', 'BASE', 'NAME'], sid=1)
#print mybuslst
mygeninfo = subsystem_info('mach', ['NUMBER', 'PGEN', 'NAME'], sid=1)
#print mygeninfo
myloadinfo = subsystem_info('load', ['NUMBER', 'MVAACT', 'NAME'], sid=1)
#print myloadinfo
branchinfo = subsystem_info('brn', ['FROMNUMBER', 'TONUMBER', 'MVA', 'P'], sid=1)
#print branchinfo
trfinfo = subsystem_info('trn', ['FROMNUMBER', 'TONUMBER', 'MVA', 'P'], sid=1)
#print trfinfo

fig = plt.figure()
ax = fig.add_subplot(111)
Exemple #37
0
    ##i in range(len(sys.argv)):
    ##    print sys.argv[i]
    ##    print '\n'
    ##print CapControlSign
    ##print '\n'
    ##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)
Exemple #38
0
def change_gen(gen_bus, increment):
    psspy.bsys(0, 0, [0.0, 0.0], 0, [], len(gen_bus), gen_bus, 0, [], 0, [])
    psspy.scal(sid=0, all=0, apiopt=0, status1=3, scalval2=increment)
Exemple #39
0
msg='Please enter the path/file.ext for the first case (.raw or .sav) file:'
while not os.path.isfile(case1_file):
    case1_file=input(msg)
    msg="Sorry, I can't find " + case1_file + ".  Try again."

msg='Please enter the path/file.ext for the second saved case (.sav) file:'
while not  os.path.isfile(case2_file):
    case2_file=input(msg)
    msg="Sorry, I can't find " + case1_file + ".  Try again."

#open a case
psspy.case(r"""C:\temp\sum16idctr1p4_v32.sav""")

# define a susbsytem to compare
# bsys() batch defines a bus subsystem 
ierr =psspy.bsys(0,0,[ 0.2, 999.],19,area_list,0,[],0,[],0,[])
if ierr != 0:
    print('Error defining subsystem.')

#Initialize
SID = 0      # subsystem identifier, 0 by default\
All = 0      # 1 = all busses; 0 = busses in subsystem\
APIOpt = 1   # 1 = inititalize, 2 = run comparison, 3 = done (cleanup)
Status = [0,0,0,0],   # List of 4 items.  see help['psspy.diff']
Thrsh = [0.0,0.0,0.0]  # thrsh1: difference threshold (default = 0)
#                      thrsh2: voltage or tap ratio threshold (default = 0)
#                      thrsh3: angle threshold (default = 0)
CFile = case1_file     # PSS/e case file
ierr,seqflg = psspy.diff(SID,All,APIOut,Status,Thrsh,case1_file)

#Run comparisons
    try:
        sys.stdout = file_object
        yield
    finally:
        sys.stdout = old_stdout

output = StringIO.StringIO()
with silence(output):

    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]
######input######

# scale up the load


# silent the output
output = StringIO.StringIO()
with silence(output):
    psspy.case(r"""C:\Users\niezj\Desktop\16a_Fall\openECA_proj\LocalVoltageControl20161110\Test4\2019SUM_2013Series_Updated_forLocalVoltageControl.sav""")
    savecase = (r"""C:\Users\niezj\Desktop\16a_Fall\openECA_proj\LocalVoltageControl20161110\Test4\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)