예제 #1
0
def read_voltages(_buses):
    voltages = []
    for bus in _buses:
        ierr, type = psspy.busint(bus, 'TYPE')
        if type < 4:
            ierr, Vtemp = psspy.busdat(bus, 'PU')
        else:
            Vtemp = "None"
        voltages.append(Vtemp)
    return voltages
                _f, _f, _f, _f
            ])
            psspy.machine_data_2(103, r"""1""", [_i, _i, _i, _i, _i, _i], [
                P_Gen, Q_Gen, Q_Gen, Q_Gen, S, 0, _f, _f, _f, _f, _f, _f, _f,
                _f, _f, _f, _f
            ])
            psspy.machine_data_2(104, r"""1""", [_i, _i, _i, _i, _i, _i], [
                P_Gen, Q_Gen, Q_Gen, Q_Gen, S, 0, _f, _f, _f, _f, _f, _f, _f,
                _f, _f, _f, _f
            ])
            psspy.plant_data(600, _i, [terminalv, _f])
            psspy.fdns([1, 0, 1, 1, 1, 1, 99, 0])
            ierr, pval = psspy.brnmsc(
                400, 46660, '1', 'P')  # chang: make sure there is such branch.
            ierr, qval = psspy.brnmsc(400, 46660, '1', 'Q')
            ierr, vval = psspy.busdat(101, 'PU')

            valid_pq = 0
            loop = 0
            while (1):
                if ((math.sqrt(P_Gen**2 + Q_Gen**2) <
                     ((S * min(derate, vval)) + 0.02)) and vval <= 1.1):
                    valid_pq = 1
                    break

                if loop >= 50:
                    valid_pq = 0
                    overloop = overloop + 1  # chang: add this line.
                    break

                if ((math.sqrt(P_Gen**2 + Q_Gen**2) >
예제 #3
0
        rval4 = 0
        rval5 = 0
        ierr, rval1 = psspy.brnmsc(ibus, jbus, '1', 'P')
        ierr, rval2 = psspy.brnmsc(ibus, jbus, '2', 'P')
        ierr, rval3 = psspy.brnmsc(ibus, jbus, '3', 'P')
        ierr, rval4 = psspy.brnmsc(ibus, jbus, '4', 'P')
        ierr, rval5 = psspy.wnddat(ibus, jbus, kbus, circuit_id, 'MVA')
        if rval1 == None: rval1 = 0
        if rval2 == None: rval2 = 0
        if rval3 == None: rval3 = 0
        if rval4 == None: rval4 = 0
        if rval5 == None: rval5 = 0
        P_Flow_Record[j].append(rval1 + rval2 + rval3 + rval4 + rval5)

    for k in range(0, len(Bus_Num)):
        ierr, rval = psspy.busdat(Bus_Num[k], 'KV')
        Voltage_KV_Record[k].append(rval)
        ierr, rval = psspy.busdat(Bus_Num[k], 'PU')
        Voltage_PU_Record[k].append(rval)

    ###### N-1 Contingency
P_setpoint = 100  # CHANG: change this value according to your suggestion from 5.2.5.1 Reactive Power Capability
Q_max_setpoint = 40  # CHANG: change this value according to your suggestion from 5.2.5.1 Reactive Power Capability
Q_min_setpoint = -40  # CHANG: change this value according to your suggestion from 5.2.5.1 Reactive Power Capability

for i in range(0, len(Fault_Equipment_Start)):
    psspy.read(0, GridInfoPath + FileName)
    ##        psspy.dscn(20022)   # eliminate negative generation

    psspy.machine_data_2(101, r"""1""", [_i, _i, _i, _i, _i, _i], [
        P_setpoint, 0, Q_max_setpoint, Q_min_setpoint, InverterCapacity, 0, _f,
예제 #4
0
                _f, _f, _f, _f, _f, _f, _f, _f, _f
            ])
            # psspy.machine_chng_2(200, r"""1""", [_i, _i, _i, _i, _i, _i],  [P_BESS, _f,   _f,    _f,    S_BESS, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f])

            psspy.plant_data_3(SMIB_bus_no, 0, _i, [terminalv, _f])
            # fixed slope decoupled Newton-Raphson power flow calculation, 1_tap, 2_area_interchange, 3_phase_shift, 4_dc_tap, 5_switched shunt,6_flat_start, 7_Var_limit,8__non-divergent solution
            ierr = psspy.fdns([1, 0, 0, 1, 1, 0, 99, 0])

            #brnmsc: return real branch flow values
            ierr, pval = psspy.brnmsc(POC_bus_gen, POC_bus_grid, '1',
                                      'P')  # POC_P_value

            ierr, qval = psspy.brnmsc(POC_bus_gen, POC_bus_grid, '1',
                                      'Q')  # POC_Q_value

            ierr, vval = psspy.busdat(inverter_bus_1,
                                      'PU')  # inverter_terminal_voltage

            valid_pq = 0
            loop = 0
            while (1):
                if ((math.sqrt(P_Gen_1**2 + Q_Gen_1**2) <
                     ((S_1 * min(derate, vval)) + 0.02)) and vval <= 1.15):
                    valid_pq = 1
                    break

                if loop >= 50:
                    valid_pq = 0
                    overloop = overloop + 1  # chang: add this line.
                    break

                if ((math.sqrt(P_Gen_1**2 + Q_Gen_1**2) >
예제 #5
0
        for imach in range(0, len(MachBus)):
            ierr = psspy.plant_chng(MachBus[imach], intgar1=0)

        print(
            '------------------ finished change remote bus for all generators to self (0) ---------'
        )

    print(
        '------------------ Change all switched shunts to continuous control mode ---------'
    )
    ierr, iarray = psspy.aswshint(-1, 4, 'NUMBER')
    ShuntBus = iarray[0]

    if 1:
        for ishunt in range(0, len(ShuntBus)):
            ierr, Vpu = psspy.busdat(ShuntBus[ishunt], 'PU')
            ierr = psspy.switched_shunt_chng_3(ShuntBus[ishunt],
                                               intgar9=2,
                                               realar9=Vpu,
                                               realar10=Vpu)
        print(
            '------------------ finished changing all switched shunts to continuous control mode ---------'
        )

    ierr = psspy.fnsl([0, 0, 0, 1, 1, 0, 0, 0])

    # parse the con file to make sure there is no swing bus generator contingency,
    # and construct a dictionary for the generator contingencies
    print(
        '------------------start checking swing bus in con file -------------------'
    )
예제 #6
0
                '.', '_')) + "', '" + str(lineas['Linea ID']) + "', " + str(
                    rval_AMPS
                ) + ", " + str(rval_P) + ", " + str(rval_Q) + ", " + str(
                    rate_MVA_Perc
                ) + ");"  #str(rval_AMPS*100/lineas['Rate1 (MVA)']) + ");"

#    cursor.execute(instruccion_insert)
#    conn.commit()

#############################################################################
## Recorrer las líneas de 132 kV de la zona Viesgo y obtener la tensión en todos
## los buses
#############################################################################
TENSION_BUSES_132 = []
for idx, lineas in df_lineas132_viesgo.iterrows():
    ierr_orig, rval_orig = psspy.busdat(lineas['From Bus Number'], 'KV')
    ierr_dest, rval_dest = psspy.busdat(lineas['To Bus Number'], 'KV')
    TENSION_BUSES_132.append([
        int(lineas['From Bus Number']),
        str(lineas['Subestacion 1']), ierr_orig, rval_orig
    ])
    TENSION_BUSES_132.append([
        int(lineas['To Bus Number']),
        str(lineas['Subestacion 2']), ierr_dest, rval_dest
    ])
#Se eliminan los valores duplicados
#TENSION_BUSES_132 = list(dict.fromkeys(TENSION_BUSES_132))
#TENSION_BUSES_132 = list(set(TENSION_BUSES_132))
temp = []
[temp.append(x) for x in TENSION_BUSES_132 if x not in temp]
#Se ordena por número de bus
 psspy.branch_data(bus_dummy, bus_inf, '1', realar1 = Rsys, realar2 = Xsys)
 psspy.fdns([1, 0, 1, 1, 0, 0, 99, 0])
 #if caseIndex == 0:# Qexport at POC is 0
 PpocNOW = ppoc*1.01+0.1
 dPpoc = PpocNOW-ppoc
 PgenNOW = ppoc
 while abs(dPpoc) > PQMisMatch_Tol:
     PgenNOW = PgenNOW-dPpoc/P_factor
     QpocNOW = qpoc * 1.01 + 0.1
     dQpoc = QpocNOW - qpoc
     QgenNOW = QgenINImax[caseIndex]
     while abs(dQpoc) > PQMisMatch_Tol:
         QgenNOW = QgenNOW - dQpoc / Q_factor
         psspy.machine_data_2(bus_gen, '1', realar1=PgenNOW, realar2=QgenNOW, realar3=QgenNOW, realar4=QgenNOW)
         psspy.fdns([1, 0, 1, 1, 0, 0, 99, 0])
         ierr, Vinf = psspy.busdat(bus_inf, 'PU')
         ierr, Vpoc = psspy.busdat(bus_poc, 'PU')
         dV_POC = POC_VCtrl_Tgt - Vpoc
         while abs(dV_POC) > Vinf_MisMatch_Tol:
             Vsch = Vinf + dV_POC / V_factor
             psspy.plant_data(bus_inf, realar1=Vsch)  # set the infinite bus scheduled voltage to the estimated voltage for this condition
             psspy.fdns([0, 0, 1, 1, 0, 0, 99, 0])
             ierr, Vinf = psspy.busdat(bus_inf, 'PU')
             ierr, Vpoc = psspy.busdat(bus_poc, 'PU')
             dV_POC = POC_VCtrl_Tgt - Vpoc
         ierr, QpocNOW = psspy.brnmsc(bus_poc, bus_dummy, "1", 'Q')
         dQpoc = QpocNOW-qpoc
     ierr, PpocNOW = psspy.brnmsc(bus_poc, bus_dummy, "1", 'P')
     dPpoc = PpocNOW - ppoc
     print(dPpoc)
 psspy.machine_data_2(bus_gen, '1', realar1=PgenNOW, realar2=QgenNOW, realar3=QgenNOW, realar4=QgenNOW)
예제 #8
0
    # OFS_xfo_loading_update
    xfo_fbus = [10501, 10502]
    xfo_tbus = [10401, 10402]
    br = 0
    ierr, L1 = psspy.brnmsc(xfo_fbus[br],xfo_tbus[br],'1','PCTRTA')
    ierr, L2 = psspy.brnmsc(xfo_fbus[br],xfo_tbus[br],'1','PCTRTA')
    br = 1
    ierr, L3 = psspy.brnmsc(xfo_fbus[br],xfo_tbus[br],'1','PCTRTA')
    ierr, L4 = psspy.brnmsc(xfo_fbus[br],xfo_tbus[br],'1','PCTRTA')
    OFS_TF.append(max(L1,L2,L3,L4))
    
###################################### - TO HERE - ##### #UPDATE_XFO_LOADING ###########################


    ierr, V_bus_OnHV = psspy.busdat(10102 ,'PU')
    ierr, V_bus_OnLV = psspy.busdat(10202 ,'PU')
    # ierr, V_bus110 = psspy.busdat(110 ,'PU')
    V_OnHV.append(V_bus_OnHV)
    V_OnLV.append(V_bus_OnLV)
    # V_110.append(V_bus110)

    # Added Max and min voltages of collector system, and added all ofshore cable buses
    res_voltages_ofs_cab_230kV = read_voltages(buses_ofs_230kV_Cable)
    res_voltages_66kV = read_voltages(buses_66kV)
    res_voltages_p72kV = read_voltages(buses_p72kV)
    res_Qs_WTs = read_mach_Q(buses_p72kV) # UPDATE_Q_WT

    V_ofs_cab_230kV_min.append(min(res_voltages_ofs_cab_230kV))
    V_ofs_cab_230kV_max.append(max(res_voltages_ofs_cab_230kV))
    V_66kV_min.append(min(res_voltages_66kV))