]) psspy.machine_data_2(102, 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(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
psspy.machine_chng_2(100, r"""1""", [_i, _i, _i, _i, _i, _i], [ P_Gen_1, Q_Gen_1, Q_Gen_1, Q_Gen_1, S_1, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f ]) psspy.machine_chng_2(200, r"""1""", [_i, _i, _i, _i, _i, _i], [ P_BESS, Q_Gen_BESS, Q_Gen_BESS, Q_Gen_BESS, S_BESS, _f, _f, _f, _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
# Branch Flow Data - Real for j in range(0, len(Power_Flow_Monitor_Start)): ibus = Power_Flow_Monitor_Start[j] jbus = Power_Flow_Monitor_End[j] kbus = Third_Bus_Record[j] # for special three winding tf. circuit_id = Equipment_ID[j] # for special three winding tf. rval1M = 0 rval2M = 0 rval3M = 0 rval4M = 0 rval5M = 0 ierr, rval1M = psspy.brnmsc(ibus, jbus, '1', 'PCTMVA') ierr, rval2M = psspy.brnmsc(ibus, jbus, '2', 'PCTMVA') ierr, rval3M = psspy.brnmsc(ibus, jbus, '3', 'PCTMVA') ierr, rval4M = psspy.brnmsc(ibus, jbus, '4', 'PCTMVA') ierr, rval5M = psspy.wnddat(ibus, jbus, kbus, circuit_id, 'PCTMVA') if rval1M == None: rval1M = 0 if rval2M == None: rval2M = 0 if rval3M == None: rval3M = 0 if rval4M == None: rval4M = 0 if rval5M == None: rval5M = 0 S_Flow_Record[j].append(max([rval1M, rval2M, rval3M, rval4M, rval5M])) rval1 = 0 rval2 = 0 rval3 = 0 rval4 = 0
'Database=' + db_server + ';' 'UID=' + usr_server + ';' 'PWD=' + pwd_server) #'Trusted_Connection=yes;') cursor = conn.cursor() #for lineas in df_lineas132_viesgo.itertuples(): for idx, lineas in df_lineas132_viesgo.iterrows(): # print(lineas) #No entiendo porque con itertuples lineas[0] es un índice. # print(int(lineas['Linea ID'])) # print(type(lineas[0])) # ierr_AMPS, rval_AMPS = psspy.brnmsc(int(lineas[1]),int(lineas[4]), str(lineas[7]), 'AMPS') ierr_AMPS, rval_AMPS = psspy.brnmsc(int(lineas['From Bus Number']), int(lineas['To Bus Number']), str(lineas['Linea ID']), 'AMPS') ierr_P, rval_P = psspy.brnmsc(int(lineas['From Bus Number']), int(lineas['To Bus Number']), str(lineas['Linea ID']), 'P') ierr_Q, rval_Q = psspy.brnmsc(int(lineas['From Bus Number']), int(lineas['To Bus Number']), str(lineas['Linea ID']), 'Q') #ierr_MVA, rval_MVA = psspy.brnmsc(int(lineas['From Bus Number']),int(lineas['To Bus Number']), str(lineas['Linea ID']), 'PCTCPA') rate_MVA_Perc = 0 if int(lineas['Rate1 (MVA)']) is not 0: rate_MVA_Perc = ((math.sqrt(3) * 132000 * rval_AMPS) / 1000000) / int( lineas['Rate1 (MVA)']) * 100 # print(ierr_AMPS,rval_AMPS) # print(ierr_P, rval_P ) # print(ierr_Q, rval_Q )
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) ierr, PpocNOW = psspy.brnmsc(bus_poc, bus_dummy, "1", 'P') ierr, QpocNOW = psspy.brnmsc(bus_poc, bus_dummy, "1", 'Q') print "Line Flow_at_PoC (P) is %s" % PpocNOW print "Line Flow_at_PoC (Q) is %s" % QpocNOW psspy.fdns([0, 0, 1, 1, 0, 0, 99, 0]) if caseIndex == 0: # Qexport at POC is 0 psspy.save(CasePath + 'Case' + ("%03d" % (caseNum+1)) + str(case_id) + '_' + 'Qzero' + '.sav') elif caseIndex == 1: psspy.save(CasePath + 'Case' + ("%03d" % (caseNum+1)) + str(case_id) + '_' + 'Qlag' + '.sav')
psspy.report_output(islct=2, options=[0]) with open('output.txt', 'a') as fout: fout.write('\n\n') flowarr = [['KLYN-MTHNPG L1', 7.6], ['KLYN-MTHNPG L2', 7.6], ['DHN-MTHNPG L1', 45], ['DHN-MTHNPG L2', 45], ['CTPS-DHN L1', 45.6], ['CTPS-DHN L2', 45.6], ['CTPS-KLYN L1', 141.8], ['CTPS-KLYN L2', 141.8], ['MTPS-BRNPR L1', 58.23], ['KLYN-BRNPR L1', 22], ['KLYN-MTPS L1', 55], ['KLYN-MTPS L2', 79.2], ['KLYN-MTPS L3', 79.2], ['PARU-DGPPG L1', 1], ['PARU-DGPPG L2', 1], ['DGPDVC-PARU L1', 16.5], ['DGPDVC-PARU L2', 16.5], ['DTPS-PARU L1', 22], ['DTPS-PARU L2', 22], ['MTPS-DGPDVC L1', 31.45], ['MTPS-DGPDVC L2', 31.45], ['MTPS-DTPS L1', 42], ['MTPS-DTPS L2', 42]] ierr, rval = psspy.brnmsc(44204, 45205, '1', 'MVA') ierr, cmpval1 = psspy.brnflo(44204, 45205, '1') print 'Kalyaneswari - MaithonPG line1 loading in MW & MVar = ', cmpval1 print 'Kalyaneswari - MaithonPG line1 loading in % = ', cmpval1.real * 100.0 / 186.0 flowarr[0].append(cmpval1.real * 100.0 / 186.0) ierr, cmpval2 = psspy.brnflo(44204, 45205, '2') print 'Kalyaneswari - MaithonPG line2 loading in MW & MVar = ', cmpval2 print 'Kalyaneswari - MaithonPG line2 loading in % = ', cmpval2.real * 100.0 / 186.0 flowarr[1].append(cmpval2.real * 100.0 / 186.0) ierr, cmpval3 = psspy.brnflo(44206, 45205, '1') print 'Dhanbad - MaithonPG line1 loading in MW & MVar = ', cmpval3 print 'Dhanbad - MaithonPG line1 loading in % = ', cmpval3.real * 100.0 / 186.0 flowarr[2].append(cmpval3.real * 100.0 / 186.0) ierr, cmpval4 = psspy.brnflo(44206, 45205, '2') print 'Dhanbad - MaithonPG line2 loading in MW & MVar = ', cmpval4 print 'Dhanbad - MaithonPG line2 loading in % = ', cmpval4.real * 100.0 / 186.0
psspy.asys(sid=1,num=1,areas=4) psspy.ties(1,0) psspy.report_output(islct=2, options=[0]) with open('output.txt','a') as fout: fout.write('\n\n') flowarr=[['KLYN-MTHNPG L1',7.6],['KLYN-MTHNPG L2',7.6],['DHN-MTHNPG L1',45],['DHN-MTHNPG L2',45], ['CTPS-DHN L1',45.6],['CTPS-DHN L2',45.6],['CTPS-KLYN L1',141.8],['CTPS-KLYN L2',141.8], ['MTPS-BRNPR L1',58.23],['KLYN-BRNPR L1',22],['KLYN-MTPS L1',55],['KLYN-MTPS L2',79.2], ['KLYN-MTPS L3',79.2],['PARU-DGPPG L1',1],['PARU-DGPPG L2',1],['DGPDVC-PARU L1',16.5], ['DGPDVC-PARU L2',16.5],['DTPS-PARU L1',22],['DTPS-PARU L2',22],['MTPS-DGPDVC L1',31.45], ['MTPS-DGPDVC L2',31.45],['MTPS-DTPS L1',42],['MTPS-DTPS L2',42]] ierr, rval = psspy.brnmsc(44204, 45205, '1', 'MVA') ierr, cmpval1 = psspy.brnflo(44204, 45205, '1') print 'Kalyaneswari - MaithonPG line1 loading in MW & MVar = ', cmpval1 print 'Kalyaneswari - MaithonPG line1 loading in % = ', cmpval1.real*100.0/186.0 flowarr[0].append(cmpval1.real*100.0/186.0) ierr, cmpval2 = psspy.brnflo(44204, 45205, '2') print 'Kalyaneswari - MaithonPG line2 loading in MW & MVar = ', cmpval2 print 'Kalyaneswari - MaithonPG line2 loading in % = ', cmpval2.real*100.0/186.0 flowarr[1].append(cmpval2.real*100.0/186.0) ierr, cmpval3 = psspy.brnflo(44206, 45205, '1') print 'Dhanbad - MaithonPG line1 loading in MW & MVar = ', cmpval3 print 'Dhanbad - MaithonPG line1 loading in % = ', cmpval3.real*100.0/186.0 flowarr[2].append(cmpval3.real*100.0/186.0) ierr, cmpval4 = psspy.brnflo(44206, 45205, '2') print 'Dhanbad - MaithonPG line2 loading in MW & MVar = ', cmpval4 print 'Dhanbad - MaithonPG line2 loading in % = ', cmpval4.real*100.0/186.0
ierr, S = psspy.macdat(POI_bus ,'1','MVA') # ierr, P = psspy.brnmsc(110,109,'1','P') # P_POI.append(abs(P)) # ierr, Q = psspy.brnmsc(110,109,'1','Q') # Q_POI.append(Q) # ierr, S = psspy.brnmsc(110,109,'1','MVA') PF.append(abs((P/S))) fbus = [POI_bus, 10202, 101202, 101102, 101002, 10902, 10802, 10702, 90102, 10302, 10602] tbus = [10102, 101202, 101102, 101002, 10902, 10802, 10702, 90102, 10302, 10602, 10502] br = 0 # Used to check 'AMPS' instead of '%' ierr, I1 = psspy.brnmsc(fbus[br],tbus[br],'1','PCTRTA') ierr, I2 = psspy.brnmsc(tbus[br],fbus[br],'1','PCTRTA') I_land.append(max(I1,I2)) br = 1 ierr, I1 = psspy.brnmsc(fbus[br],tbus[br],'1','PCTRTA') ierr, I2 = psspy.brnmsc(tbus[br],fbus[br],'1','PCTRTA') I_cncr_duct_1.append(max(I1,I2)) br = 2 ierr, I1 = psspy.brnmsc(fbus[br],tbus[br],'1','PCTRTA') ierr, I2 = psspy.brnmsc(tbus[br],fbus[br],'1','PCTRTA') I_onsh_1.append(max(I1,I2)) br = 3 ierr, I1 = psspy.brnmsc(fbus[br],tbus[br],'1','PCTRTA')