def add_machine(): psspy.plant_data(busno, intgar1=ireg) psspy.machine_data_2(busno, str(genid), intgar1=int(status), realar1=pgen, realar3=Qlimit, realar4=-Qlimit, realar5=pmax)
def get_mvar(i): """ Changes the voltage set point at the synchronous machine solves the case returns the the new reactive power output of the sync machine. """ psspy.plant_data(busno, realar1=i) ierr = psspy.fnsl() val = psspy.solved() if val == 0: ierr, mvar = psspy.macdat(busno, str(genid), 'Q') return mvar else: return None
def add_new_gen(gen_bus, P_inj, Q_max, Q_min): psspy.bus_data_3(gen_bus, [1, 1, 1, 1], [0.0, 1.0, 0.0, 1.1, 0.9, 1.1, 0.9], "") psspy.bus_chng_3(gen_bus, [2, _i, _i, _i], [_f, _f, _f, _f, _f, _f, _f], _s) psspy.plant_data(gen_bus, 0, [1.0, 100.0]) psspy.machine_data_2(gen_bus, r"""1""", [1, 1, 0, 0, 0, 0], [ 0.0, 0.0, 9999.0, -9999.0, 9999.0, -9999.0, 100.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ]) psspy.machine_chng_2(gen_bus, r"""1""", [_i, _i, _i, _i, _i, 1], [ P_inj, _f, Q_max, Q_min, P_inj, 0.0, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f ]) return
# chang: this is wrong, each cluster has only ~120MVA capacity. I guess the power flow does not converge. overloop = 0 # add this line. Capacitor = 0 # capacitor for temperature in [40, 50]: for terminalv in [0.9, 1.0, 1.1]: if temperature == 50: derate = 0.9 else: derate = 1.0 psspy.plant_data(600, _i, [terminalv, _f]) for P_Gen in numpy.arange(0, S * derate + 0.01, 1): psspy.read(0, GridInfoPath + PowerFlowFileName) #psspy.switched_shunt_chng_3(104, [_i, _i, _i, _i, _i, _i, _i, _i, _i, _i, _i, _i], # [_f, _f, _f, _f, _f, _f, _f, _f, _f, _f, 0, _f], "") #psspy.switched_shunt_chng_3(204, [_i, _i, _i, _i, _i, _i, _i, _i, _i, _i, _i, _i], # [_f, _f, _f, _f, _f, _f, _f, _f, _f, _f, 0, _f], "") Q_Gen = max(-S * 0.6, -math.sqrt(S * S * derate * derate - P_Gen * P_Gen)) psspy.machine_data_2(101, 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(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,
def preprocesado(parametros, info_casos): # se inicia el PSS/E initpss.inicia_psse(print_alert_psse=True) for x in info_casos: try: #se encuentra caso en la carpeta y se carga path_caso_psse = os.path.join(Rutas().ruta_casos, str(x.N_Caso) + '.sav') caso_pss = redpsse.CasoPSSE(filepath=path_caso_psse) caso_pss.load(save_previous=False) #se comprueba si el caso es peninsular o insular consultando las areas areas = redpsse.get_areas() area_numbers = [] for a in areas: area_numbers.append(a.number) 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 except Exception as e: raise StandardError('Error al cargar el caso de referencia: {}'.format(e.message)) try: # Cambio a tipo 2 los buses tipo 1 e incluyo generador con Pgen=0.01 MW # se recupera lista con buses tipo 1 list_bus = redpsse.get_bus_number_used_by_tension_tipo(Umin=Umin, Umax=Umax, tipo=1) for bus_num in list_bus: # se modifica el tipo del bus ierr = psspy.bus_chng_3(bus_num, [2, _i, _i, _i], [_f, _f, _f, _f, _f, _f, _f], _s) # se crea una planta en el bus para poder añadir después el generador ierr = psspy.plant_data(bus_num, _i, [_f, _f]) # se crea el generador con Pgen=0.01 MW intgar = [_i, _i, _i, _i, _i] Pgen = 0.01 # MW Qmin = 0 # MVar Qmax = 0 # MVar realar = [Pgen, _f, Qmin, Qmax, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f] idn = str(11) ierr = psspy.machine_data_2(bus_num, idn, intgar, realar) except Exception as e: raise StandardError('Error al modificar los nudos en el caso de referencia: {}'.format(e.message)) try: # Modificacion del rateA y rateB segun ficheros de entrada #se recupera una lista con ramas list_branches = redpsse.get_branch_list() for branch in list_branches: ibus = branch.from_bus jbus = branch.to_bus ckt= branch.idn #se calculan los nuevos rates A y B de la rama segun parametros de entrada rateA=parametros.Rate_A/100 * branch.rate_a rateB=parametros.Rate_B/100 * branch.rate_a intgar=[_i,_i,_i,_i,_i,_i] realar=[_f,_f,_f,rateA,rateB,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f] #se modifica la rama con los nuevos rates A y B ierr = psspy.branch_data(ibus, jbus, ckt, intgar, realar) except Exception as e: raise StandardError('Error al modificar los rates A y B de las ramas en el caso de referencia: {}'.format(e.message)) #se guarda temporalmente el caso procesado ierr = psspy.save(os.path.join(Rutas().ruta_casos_procesados, str(x.N_Caso) + '_procesado.sav'))
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) 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
# OPEN PSSE _i = psspy.getdefaultint() _f = psspy.getdefaultreal() _s = psspy.getdefaultchar() redirect.psse2py() psspy.psseinit(50000) FileName = f_list[case[test - 1]-1] psspy.case(CasePath + FileName) psspy.resq(CasePath + "Tamworth_SMIB.seq") psspy.addmodellibrary(CasePath + 'SMASC_E161_SMAPPC_E130_342_IVF150.dll') psspy.dyre_new([1, 1, 1, 1], CasePath + "Tamworth_SMIB_E161_E130.dyr", '', '', '') psspy.branch_data(bus_flt, bus_inf, '1', realar1=0, realar2=0.0001) ierr, line_rx = psspy.brndt2(bus_flt, bus_inf, '1', 'RX') psspy.ltap(bus_flt, bus_inf, r"""1""", 0.0001, bus_IDTRF, r"""IDTRF""", _f) psspy.plant_data(bus_inf, realar1=1.0) psspy.purgbrn(bus_IDTRF, bus_flt, r"""1""") psspy.two_winding_data_3(bus_flt, bus_IDTRF, r"""1""", [1, bus_flt, 1, 0, 0, 0, 33, 0, bus_flt, 0, 1, 0, 1, 1, 1], [0.0, 0.0001, 100.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 1.1, 0.9, 1.1, 0.9, 0.0, 0.0, 0.0], r"""IDTRF""") OutputFilePath = FigurePath + '07. Grid Voltage Step Test' + "\\" + 'Test' + str( test+42) + '_' + FileName + '_sFac' + str(acceleration) + '_dT' + str( integration_step) + '_Grid Voltage Step Test.out' # ! Setup Dynamic Simulation parameters psspy.dynamics_solution_param_2([n_iteration, _i, _i, _i, _i, _i, _i, _i], [acceleration, tolerance, integration_step, _f, _f, _f, _f, _f]) psspy.fdns([0, 0, 1, 1, 0, 0, 99, 0]) # convert load , do not change
results.append(min(results12)) results.append(max_voltages(results13)) results.append(min(results13)) results.append(max_voltages(res_66kV)) results.append(min(res_66kV)) results.append(max_voltages(res_WT)) results.append(min(res_WT)) results.append(max_q(q_wt)) results.append(min(q_wt)) results.append(Qstat) results.append(Converged) result_dict[k] = results ################################ Energize####################################################### psspy.plant_data(POI_bus, 0, [V_POI, 100.0]) # Fix WT voltage at 1.00 pu and set at 0 MW, 0 MVAr for i in range(len(WT_num)): psspy.plant_data(WT_bus[i], 0, [1.00, 100.0]) psspy.machine_chng_2( WT_bus[i], r"""1""", [1, _i, _i, _i, _i, _i], [0.0, 0.0, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f]) psspy.fdns([0, 0, 0, 1, 1, 0, 0, 0]) psspy.fdns([0, 0, 0, 1, 1, 0, 0, 0]) # 1 # Reconnect onshore bus HV for i in range(num_groups): psspy.recn(ONSS_HV[i]) # Auto-adjustment of taps is disabled
Tr_ONS_1 = [] Tr_ONS_2 = [] Tr_OFS_1 = [] Tr_OFS_2 = [] Qs_WTs_min = [] # UPDATE_Q_WT Qs_WTs_max = [] # UPDATE_Q_WT Num_Reactors = [] Convergence_test = [] ONS_TF = [] #UPDATE_XFO_LOADING OFS_TF = [] #UPDATE_XFO_LOADING # switch off shunts initially psspy.plant_data(POI_bus,0,[V_POI, 100.0]) for i_sh in range (1,num_shunt+1): psspy.shunt_chng(ons_reac1_bus,str(i_sh),0,[_f,_f]) psspy.shunt_chng(ons_reac2_bus,str(i_sh),0,[_f,_f]) psspy.fdns([1,0,0,1,1,0,0,0]) psspy.fdns([1,0,0,1,1,0,0,0]) psspy.plant_data(statcom1_bus,_i,[Vset_STAT,_f]) psspy.plant_data(statcom2_bus,_i,[Vset_STAT,_f]) # psspy.plant_data(128,_i,[Vset_STAT,_f]) psspy.fdns([1,0,0,1,1,0,0,0]) psspy.fdns([1,0,0,1,1,0,0,0])