def calcSCR(sizes, ret_params=False): ''' ARGS: sizes : list of sizes of Sync. Conds RETURNS: scr : list of short circuit ratios Calculation: scr=sqrt(3)*i_sym*v_pu*v_kv*_UNIT_FACTOR/pmax _UNIT_FACTOR=1e-3 ''' # params pmax = [] i_sym = [] v_kv = [] v_pu = [] # non-verbose execution with silence(): for idx in range(len(SC_IDS)): psspy.machine_data_2(i=SC_IDS[idx], id='1', intgar=[1, 0, 0, 0, 0, 0], realar=[ 0, 0, 500, -200, 0, 0, sizes[idx], 0, 0.17, 0, 0, 1, 1, 1, 1, 1, 1 ]) # full newton-rafsan psspy.fnsl(options4=1, options5=1, options6=1) # get symmetric 3-phase fault currents all_currents = pssarrays.iecs_currents(all=1, flt3ph=1, optnftrc=2, vfactorc=1.0) # all bus pu voltage _, (__v_pu, ) = psspy.abusreal(sid=-1, string=["PU"]) # all bus kv voltage _, (__v_kv, ) = psspy.abusreal(sid=-1, string=["BASE"]) # get pmax for _id in MACHINE_IDS: _, _pmax = psspy.macdat(ibus=_id, id='1', string='PMAX') # find power of machine pmax.append(_pmax) # get v_pu,v_kv,i_sym for _id in BUS_IDS: v_pu.append(__v_pu[_id - 1]) v_kv.append(__v_kv[_id - 1]) i_sym.append(all_currents.flt3ph[_id - 1].ibsym.real) total_bus = len(pmax) scr = [] _UNIT_FACTOR = 1e-3 #LOG_INFO('Calculating SCR') for idx in range(total_bus): scr.append( math.sqrt(3) * i_sym[idx] * v_pu[idx] * v_kv[idx] * _UNIT_FACTOR / pmax[idx]) if ret_params: return pmax, i_sym, v_kv, v_pu, scr else: return scr
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 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
if LoadScenario=="SimplifiedSystem": file_name="WISF_1.05" # Initialize psspy.case(GridInfoPath+file_name+".sav") # psspy.rstr(GridInfoPath+file_name+".snp") psspy.resq(GridInfoPath + "/" + file_name + ".seq") psspy.dyre_new([1, 1, 1, 1], GridInfoPath + "/" + file_name + ".dyr", "", "", "") psspy.addmodellibrary(HuaweiModelPath+'HWS2000_psse34.dll') psspy.addmodellibrary(HuaweiModelPath+'MOD_GPM_PPC_V13_34.dll') psspy.addmodellibrary(HuaweiModelPath+'MOD_GPM_SB_V7.dll') psspy.plant_chng_3(500,0,_i,[ 1.05,_f]) psspy.plant_chng_3(1000,0,_i,[ 1.047,_f]) psspy.dynamics_solution_param_2([_i,_i,_i,_i,_i,_i,_i,_i],[0.300,_f, 0.001,0.004,_f,_f,_f,_f]) psspy.machine_data_2(500, r"""1""", [_i, _i, _i, _i, _i, _i],[87, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f]) psspy.two_winding_chng_5(700,800,r"""1""",[_i,_i,_i,_i,_i,_i,_i,_i,800,_i,_i,1,_i,_i,_i],[_f,_f,_f, 1.0,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f],[_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f],r"""SS-TF-1""", r"""YNYN0""") psspy.machine_chng_2(500,r"""1""",[_i,_i,_i,_i,_i,_i],[_f,0.0,0,0,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f]) psspy.fnsl([0,0,0,1,0,0,99,0]) # convert load , do not change psspy.cong(0) psspy.bus_frequency_channel([1,1000],r"""System frequency""") ierr=psspy.machine_array_channel([2,4,500],r"""1""",r"""Inverter Terminal Voltage""") ierr=psspy.voltage_channel([3,-1,-1,800],r"""WISF PoC Voltage""") psspy.branch_p_and_q_channel([4,-1,-1,800,900],r"""1""",[r"""P Injection""",r"""Q Injection"""]) psspy.branch_p_and_q_channel([6,-1,-1,500,600],r"""1""",[r"""P Injection""",r"""Q Injection"""]) # ierr=psspy.machine_array_channel([6,2,500],r"""1""",r"""Pelec Inverter""")
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'))
## realar6=15., realar8=132., realar9=150., ## realar20=70., realar21=0.) #JMU1 - JMUPST1 trf #---------------------------------- ### Additional ASP lines ##ierr = psspy.branch_data(44109, 44119, "3", intgar1=1, realar1=0.002781434, ## realar2=0.008661488, realar3=0.001763027) ##ierr = psspy.seq_branch_data(44109, 44119, "3", realar1=0.007021062, ## 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)
## realar6=15., realar8=132., realar9=150., ## realar20=70., realar21=0.) #JMU1 - JMUPST1 trf #---------------------------------- ### Additional ASP lines ##ierr = psspy.branch_data(44109, 44119, "3", intgar1=1, realar1=0.002781434, ## realar2=0.008661488, realar3=0.001763027) ##ierr = psspy.seq_branch_data(44109, 44119, "3", realar1=0.007021062, ## 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)
"") psspy.addmodellibrary(GridInfoPath + 'dsusr.dll') psspy.addmodellibrary(HuaweiModelPath + 'HWH9001_342.dll') psspy.addmodellibrary(HuaweiModelPath + 'PPC_PSSE_ver_13_08_34_2_10082018_AUS.dll') psspy.addmodellibrary(HuaweiModelPath + 'MOD_GPM_SB_V7.dll') psspy.addmodellibrary(GridInfoPath + 'GEWTG34.dll') psspy.addmodellibrary(GridInfoPath + 'SMAPPC_B111_34_IVF111.dll') psspy.addmodellibrary(GridInfoPath + 'SMASC_C135_34_IVF111.dll') [ierr, var_ppc_conp] = psspy.mdlind(101, '1', 'EXC', 'CON') [ierr, var_ppc_setp] = psspy.mdlind(101, '1', 'EXC', 'VAR') [ierr, var_ppc_mode] = psspy.mdlind(101, '1', 'EXC', 'ICON') [ierr, var_inv_con] = psspy.mdlind(101, '1', 'GEN', 'CON') [ierr, var_inv_var] = psspy.mdlind(101, '1', 'GEN', 'VAR') psspy.machine_data_2(101, r"""1""", [_i, _i, _i, _i, _i, _i], [ ActivePowerSetpoint * S, _f, _f, _f, 120, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f ]) # psspy.machine_data_2(101, r"""1""", [_i, _i, _i, _i, _i, _i], # [_f, _f, ReactivePowerSetpoint * S, _f, 120, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f]) # psspy.machine_data_2(101, r"""1""", [_i, _i, _i, _i, _i, _i], # [_f, _f, _f, ReactivePowerSetpoint * S, 120, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, # _f]) psspy.machine_data_2(102, r"""1""", [_i, _i, _i, _i, _i, _i], [ ActivePowerSetpoint * S, _f, _f, _f, 120, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f ]) # psspy.machine_data_2(102, r"""1""", [_i, _i, _i, _i, _i, _i], # [_f, _f, ReactivePowerSetpoint * S, _f, 120, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f]) # psspy.machine_data_2(102, r"""1""", [_i, _i, _i, _i, _i, _i], # [_f, _f, _f, ReactivePowerSetpoint * S, 120, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, # _f])
file_name = "WISF_ADD" # start simulation OutputFilePath = ProgramPath + str(fault_type) + "SimulationOutput4.outx" TimeShift = 0 psspy.case(GridInfoPath + file_name + ".sav") # psspy.rstr(GridInfoPath+file_name+".snp") psspy.resq(GridInfoPath + "/" + file_name + ".seq") psspy.dyre_new([1, 1, 1, 1], GridInfoPath + "/" + file_name + ".dyr", "", "", "") psspy.addmodellibrary(HuaweiModelPath + 'HWS2000_psse34.dll') psspy.addmodellibrary(HuaweiModelPath + 'MOD_GPM_PPC_V13_34.dll') psspy.addmodellibrary(HuaweiModelPath + 'MOD_GPM_SB_V7.dll') psspy.dynamics_solution_param_2([_i, _i, _i, _i, _i, _i, _i, _i], [0.300, _f, 0.001, 0.004, _f, _f, _f, _f]) psspy.machine_data_2( 500, r"""1""", [_i, _i, _i, _i, _i, _i], [90, _f, _f, _f, 96.8, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f]) psspy.fnsl([0, 0, 0, 1, 1, 1, 99, 0]) psspy.bus_frequency_channel([1, 1000], r"""System frequency""") psspy.voltage_channel([2, -1, -1, 500], r"""Inverter Voltage Mag.""") psspy.voltage_channel([3, -1, -1, 800], r"""WISF POC Voltage Mag.""") psspy.branch_p_and_q_channel([4, -1, -1, 800, 900], r"""1""", [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 = psspy.load_data_3(44126, realar1=26.25) #SINDRI ierr = psspy.load_data_3(44127, realar1=32.5) #RAMKANALI ierr = psspy.load_data_3(44128, realar1=38.0) #PATRATU ierr = psspy.load_data_3(44129, realar1=46.5) #NORTH KARANPURA ierr = psspy.load_data_3(44133, realar1=15.0) #PURULIA ierr = psspy.load_data_3(44134, realar1=57.0) #JAMURIA ierr = psspy.load_data_3(44135, realar1=23.5) #KONAR ierr = psspy.load_data_3(44205, realar1=167.35) #DURGAPUR ierr = psspy.load_data_3(44206, realar1=36.0) #DHANBAD ierr = psspy.load_data_3(44207, realar1=70.2) #MTPS ierr = psspy.load_data_3(44208, realar1=93.0) #BURNPUR ierr = psspy.load_data_3(44209, realar1=43.0) #RAMGARH2 ierr = psspy.load_data_3(44217, realar1=186.5) #BORJORA ierr = psspy.load_data_3(44218, realar1=160.8) #PARULIA ierr = psspy.machine_data_2(44004, realar1=180.0) #BTPSG1 ierr = psspy.machine_data_2(44005, realar1=180.0) #BTPSG2 ierr = psspy.machine_data_2(44006, realar1=180.0) #BTPSG3 ierr = psspy.machine_data_2(44008, realar1=180.0) #DTPSG4 ierr = psspy.machine_data_2(44009, realar1=110.0) #DTPSG3 ierr = psspy.machine_data_2(44015, realar1=100.0) #CTPSG1 ierr = psspy.machine_data_2(44016, realar1=100.0) #CTPSG2 ierr = psspy.machine_data_2(44017, realar1=100.0) #CTPSG3 ierr = psspy.machine_data_2(44020, realar1=180.0) #MTPSG1 ierr = psspy.machine_data_2(44021, realar1=180.0) #MTPSG2 ierr = psspy.machine_data_2(44022, realar1=180.0) #MTPSG3 ierr = psspy.machine_data_2(44023, realar1=180.0) #MTPSG4 ierr = psspy.machine_data_2(45201, realar1=0.0) #PARULIAPG ierr = psspy.machine_data_2(45205, realar1=0.0) #MAITHONPG ierr = psspy.bus_data_2(45201, intgar1=1)
psspy.dynamics_solution_param_2([_i, _i, _i, _i, _i, _i, _i, _i], [1.000, _f, 0.001, 0.004, _f, _f, _f, _f]) for i in range(0, len(Branch_Outage_List_Start)): for fault_type in range(1, 5): # re - initialize psspy.read(0, GridInfoPath + LoadScenario + "/" + file_name + ".raw") psspy.resq(GridInfoPath + LoadScenario + "/" + file_name + ".seq") psspy.dyre_new([1, 1, 1, 1], GridInfoPath + LoadScenario + "/" + file_name + ".dyr", "", "", "") psspy.dscn(30531) psspy.dscn(36530) psspy.dscn(37530) psspy.dscn(50030) # add for Clenergy project psspy.machine_data_2(30531, r"""12""", [0, _i, _i, _i, _i, _i], [_f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f]) psspy.machine_data_2(37530, r"""12""", [0, _i, _i, _i, _i, _i], [_f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f]) psspy.machine_data_2(101, r"""1""", [_i, _i, _i, _i, _i, _i], [100, _f, 60, -40, 120, _f, 120, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f]) psspy.machine_data_2(102, r"""1""", [_i, _i, _i, _i, _i, _i], [100, _f, 60, -40, 120, _f,120, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f]) psspy.machine_data_2(103, r"""1""", [_i, _i, _i, _i, _i, _i], [100, _f, 60, -40, 120, _f, 120, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f]) psspy.machine_data_2(104, r"""1""", [_i, _i, _i, _i, _i, _i], [100, _f, 60, -40, 120, _f, 120, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f]) # psspy.machine_data_2(100, r"""1""", [_i, _i, _i, _i, _i, _i], # [_f, _f, 5, _f, 132, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f]) # psspy.machine_data_2(100, r"""1""", [_i, _i, _i, _i, _i, _i], # [_f, _f, _f, 5, 132, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, # _f]) # be careful, partial active power = not enough solar irraidance.
ierr = psspy.load_data_3(44126, realar1=26.25) #SINDRI ierr = psspy.load_data_3(44127, realar1=32.5) #RAMKANALI ierr = psspy.load_data_3(44128, realar1=38.0) #PATRATU ierr = psspy.load_data_3(44129, realar1=46.5) #NORTH KARANPURA ierr = psspy.load_data_3(44133, realar1=15.0) #PURULIA ierr = psspy.load_data_3(44134, realar1=57.0) #JAMURIA ierr = psspy.load_data_3(44135, realar1=23.5) #KONAR ierr = psspy.load_data_3(44205, realar1=167.35) #DURGAPUR ierr = psspy.load_data_3(44206, realar1=36.0) #DHANBAD ierr = psspy.load_data_3(44207, realar1=70.2) #MTPS ierr = psspy.load_data_3(44208, realar1=93.0) #BURNPUR ierr = psspy.load_data_3(44209, realar1=43.0) #RAMGARH2 ierr = psspy.load_data_3(44217, realar1=186.5) #BORJORA ierr = psspy.load_data_3(44218, realar1=160.8) #PARULIA ierr = psspy.machine_data_2(44004, realar1=180.0) #BTPSG1 ierr = psspy.machine_data_2(44005, realar1=180.0) #BTPSG2 ierr = psspy.machine_data_2(44006, realar1=180.0) #BTPSG3 ierr = psspy.machine_data_2(44008, realar1=180.0) #DTPSG4 ierr = psspy.machine_data_2(44009, realar1=110.0) #DTPSG3 ierr = psspy.machine_data_2(44015, realar1=100.0) #CTPSG1 ierr = psspy.machine_data_2(44016, realar1=100.0) #CTPSG2 ierr = psspy.machine_data_2(44017, realar1=100.0) #CTPSG3 ierr = psspy.machine_data_2(44020, realar1=180.0) #MTPSG1 ierr = psspy.machine_data_2(44021, realar1=180.0) #MTPSG2 ierr = psspy.machine_data_2(44022, realar1=180.0) #MTPSG3 ierr = psspy.machine_data_2(44023, realar1=180.0) #MTPSG4 ierr = psspy.machine_data_2(45201, realar1=0.0) #PARULIAPG ierr = psspy.machine_data_2(45205, realar1=0.0) #MAITHONPG ierr = psspy.bus_data_2(45201, intgar1=1)
z_g = [None] * 30 r_g = [None] * 30 x_g = [None] * 30 r_f = [None] * 30 z_f = [None] * 30 x_f = [None] * 30 for test_no in range(0, 30): # re - initialize psspy.case(GridInfoPath + file_name + ".sav") psspy.fdns([1, 0, 0, 1, 1, 1, 0, 0]) psspy.resq(GridInfoPath + file_name + ".seq") psspy.dyre_new([1, 1, 1, 1], GridInfoPath + file_name + ".dyr", "", "", "") psspy.machine_data_2(101, r"""1""", [_i, _i, _i, _i, _i, _i], [ ActivePowerSetpoint[test_no] * S, _f, _f, _f, 100, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f ]) psspy.machine_data_2(101, r"""1""", [_i, _i, _i, _i, _i, _i], [ _f, _f, ReactivePowerSetpoint[test_no] * S, _f, 100, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f ]) psspy.machine_data_2(101, r"""1""", [_i, _i, _i, _i, _i, _i], [ _f, _f, _f, ReactivePowerSetpoint[test_no] * S, 100, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f ]) psspy.dynamics_solution_param_2([_i, _i, _i, _i, _i, _i, _i, _i], [ acc_factor[test_no], _f, 0.001 * step_size[test_no], 0.004, _f, _f, _f, _f ]) ## calculate impedance for POC and fault z_g[test_no] = 1 / SCR_31_60[test_no] # grid impedance
Q_max_setpoint_100 = [0, 20, 20, -26, -26] #(-26,0 minQ), (20,6.8maxQ) Q_max_setpoint_200 = [0, 6.8, 6.8, 0, 0] Q_min_setpoint_100 = [0, -20, 20, -26, -26] Q_min_setpoint_200 = [0, -6.8, 6.8, -0, 0] InverterCapacity_100 = 83.6; # CHANG: sample :change this value according to your suggestion from 5.2.5.1 Reactive Power Capability InverterCapacity_200 = 21.14; # CHANG: sample :change this value according to your suggestion from 5.2.5.1 Reactive Power Capability ###### standard power variation for i in range(0, len(P_setpoint_100)): psspy.read(0, GridInfoPath + file_name + ".raw") ## psspy.dscn(20022) # eliminate negative power output by slack bus, does not need to consider outside NSW. psspy.machine_data_2(100, r"""1""", [_i, _i, _i, _i, _i, _i], [P_setpoint_100[i], 0, Q_max_setpoint_100[i], Q_min_setpoint_100[i], InverterCapacity_100, 0, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f]) psspy.machine_data_2(200, r"""1""", [_i, _i, _i, _i, _i, _i], [P_setpoint_200[i], 0, Q_max_setpoint_200[i], Q_min_setpoint_200[i], InverterCapacity_200, 0, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f]) # psspy.machine_data_2(103.4, r"""1""", [_i, _i, _i, _i, _i, _i], # [P_setpoint[i], 0, Q_max_setpoint[i], Q_min_setpoint[i], InverterCapacity, 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_setpoint[i], 0, Q_max_setpoint[i], Q_min_setpoint[i], InverterCapacity, 0, _f, _f, _f, _f, # _f, _f, _f, _f, _f, _f, _f]) # psspy.machine_data_2(204, r"""1""", [_i, _i, _i, _i, _i, _i], # [P_setpoint[i], 0, Q_max_setpoint[i], Q_min_setpoint[i], InverterCapacity, 0, _f, _f, _f, _f, # _f, _f, _f, _f, _f, _f, _f]) P_set_total= P_setpoint_100[i]+ P_setpoint_200[i] Event_Name.append('Output=' + str(1 * P_set_total) + 'MW' + ' ' + 'No Contingency')
x1 = math.sqrt(z1**2 - r1**2) z0 = 0.13712 * 2 #in pu r0 = z0 / np.sqrt(1 + (x1 / r1)**2) x0 = r0 * (x1 / r1) psspy.seq_two_winding_data_3( busMap['MUCHIPARA3'], busMap['MUCHIPARA2'], "1", #DGP_STR1 (EMCO-11733) intgar1=12, intgar2=2, intgar3=2, realar3=r0, realar4=x0) # Base Generation --------------------------------- psspy.machine_data_2(busMap['BTPSBG1'], realar1=180.) #BTPSB gen1 psspy.machine_data_2(busMap['BTPSBG2'], realar1=180.) #BTPSB gen2 psspy.machine_data_2(busMap['BTPSBG3'], realar1=180.) #BTPSB gen3 psspy.machine_data_2(busMap['DTPSG4'], realar1=180.) #DTPS gen4 psspy.machine_data_2(busMap['DTPSG3'], realar1=98.) #DTPS gen3 psspy.machine_data_2(busMap['BTPSAG1'], intgar1=0) #BKROA gen1 psspy.machine_data_2(busMap['MTPSBG1'], realar1=450.) #MTPSB gen1 psspy.machine_data_2(busMap['MTPSBG2'], realar1=450.) #MTPSB gen2 psspy.machine_data_2(busMap['CTPSG1'], realar1=100.) #CTPS gen1 psspy.machine_data_2(busMap['CTPSG2'], realar1=100.) #CTPS gen2 psspy.machine_data_2(busMap['CTPSG3'], realar1=100.) #CTPS gen3 psspy.machine_data_2(busMap['CTPSG7'], realar1=225.) #CTPS gen7 psspy.machine_data_2(busMap['CTPSG8'], realar1=225.) #CTPS gen8 psspy.machine_data_2(busMap['MTPSG1'], realar1=180.) #MTPS gen1 psspy.machine_data_2(busMap['MTPSG2'], realar1=180.) #MTPS gen2 psspy.machine_data_2(busMap['MTPSG3'], realar1=180.) #MTPS gen3
columns=[ 'ID_Escenario', 'Bus_Number', 'BUS_Name', 'ID_Generador', 'P_MW_simulacion' ]) #Se comprueba si no hay escenario para es id_escenario y la tabla está vacía if not df_escenario.empty: #Cambio de potencia en los generadores for idx, generadores in df_escenario.iterrows(): print(str(generadores['Bus_Number']), str(generadores['ID_Generador']), str(generadores['P_MW_simulacion'])) # filtro = GENERADORES_132_DF.loc[(GENERADORES_132_DF['Bus_Number'] == generadores['Bus_Number']) & (GENERADORES_132_DF['ID_Generador'] == str(generadores['ID_Generador']))] # pot_nueva = filtro['PMAX_MW'][0] * generadores['P_MW_simulacion'] psspy.machine_data_2(generadores['Bus_Number'], str(generadores['ID_Generador']), [psspy.getdefaultint()], [generadores['P_MW_simulacion']]) #Volvemos a simular psspy.fdns([0, 0, 0, 1, 1, 1, 99, 0]) U = psspy.solv() #Se obtienen los valores de corriente y potencias y se guardan en el SQL 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']),
qpoc = Qpoc[caseNum] caseIndex = caseNum%3 if ppoc == poc_p_max: case_id = "_scr" + str(round(scr, 2)) + "_xr" + str(xrratio) + "_P65.0" else: case_id = "_scr" + str(round(scr, 2)) + "_xr" + str(xrratio) + "_P3.25" # Direct conversion of SCR to impedance # The impedance is on MBASE Rsys = math.sqrt(((1.0 / scr) ** 2) / (xrratio ** 2 + 1.0)) # make sure that the division is forced to be a floating point number Xsys = Rsys * xrratio # Convert impedances from MBASE to SBASE for entry in PSS/E Rsys = Rsys * (SBASE / poc_p_max) Xsys = Xsys * (SBASE / poc_p_max) psspy.fnsl([1, 0, 0, 1, 1, 0, 0, 0]) psspy.machine_data_2(bus_gen, '1', realar1 = ppoc) # Update the UUT active power output psspy.machine_data_2(bus_inf, '1', realar8 = 0.0, realar9 = 0.0001) # Update the infinite bus equivalent impedance psspy.seq_machine_data(bus_inf, '1', [0.0, 0.0001, 0.0, 0.0001, _f, _f]) # Update the infinite bus equivalent impedance in sequence info 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
'PPC_PSSE_ver_13_08_34_2_10082018_AUS.dll') psspy.addmodellibrary(HuaweiModelPath + 'MOD_GPM_SB_V7.dll') psspy.dynamics_solution_param_2([_i, _i, _i, _i, _i, _i, _i, _i], [1.000, _f, 0.001, 0.004, _f, _f, _f, _f]) for i in range(0, len(ActivePowerSetpoint)): for j in range(0, len(ReactivePowerSetpoint)): for k in range(0, len(vref)): # re - initialize psspy.read(0, GridInfoPath + LoadScenario + "/" + file_name + ".raw") psspy.resq(GridInfoPath + LoadScenario + "/" + file_name + ".seq") psspy.dyre_new([1, 1, 1, 1], GridInfoPath + LoadScenario + "/" + file_name + ".dyr", "", "", "") psspy.machine_data_2(101, r"""1""", [_i, _i, _i, _i, _i, _i], [ ActivePowerSetpoint[i], _f, _f, _f, 120, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f ]) psspy.machine_data_2(101, r"""1""", [_i, _i, _i, _i, _i, _i], [ _f, _f, ReactivePowerSetpoint[j], _f, 120, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f ]) psspy.machine_data_2(101, r"""1""", [_i, _i, _i, _i, _i, _i], [ _f, _f, _f, ReactivePowerSetpoint[j], 120, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f ]) psspy.machine_data_2(102, r"""1""", [_i, _i, _i, _i, _i, _i], [ ActivePowerSetpoint[i], _f, _f, _f, 120, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f ]) psspy.machine_data_2(102, r"""1""", [_i, _i, _i, _i, _i, _i], [ _f, _f, ReactivePowerSetpoint[j], _f, 120, _f, _f, _f, _f, _f,
ierr = psspy.resq(GridInfoPath + file_name + ".seq") ierr = psspy.dyre_new([1, 1, 1, 1], GridInfoPath + file_name + ".dyr", "", "", "") # psspy.machine_data_2(100,r"""1""",[_i,_i,_i,_i,_i,_i],[_f,_f, 80,_f, 132,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f]) # psspy.machine_data_2(100,r"""1""",[_i,_i,_i,_i,_i,_i],[_f,_f,_f, 80, 132,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f]) psspy.fdns([1, 0, 1, 1, 1, 1, 99, 0]) #psspy.change_plmod_icon(101, r"""1""", r"""GPMPPC""", 4, 3) #psspy.change_plmod_con(101, r"""1""", r"""GPMPPC""", 10, 0.45) psspy.dynamics_solution_param_2([_i, _i, _i, _i, _i, _i, _i, _i], [1.000, _f, 0.001, 0.004, _f, _f, _f, _f]) # discard disturbance psspy.dscn(30531) psspy.dscn(36530) psspy.dscn(37530) psspy.machine_data_2(30531, r"""12""", [0, _i, _i, _i, _i, _i], [_f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f]) psspy.machine_data_2(37530, r"""12""", [0, _i, _i, _i, _i, _i], [_f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f]) psspy.plmod_status(30531, r"""1""", 1, 0) psspy.plmod_status(30531, r"""1""", 6, 0) psspy.plmod_status(30531, r"""1""", 7, 0) psspy.plmod_status(37530, r"""1""", 1, 0) psspy.plmod_status(37530, r"""1""", 6, 0) psspy.plmod_status(37530, r"""1""", 7, 0) # 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])
0, 100, 50, 0 ] # CHANG: change this value according to your suggestion from 5.2.5.1 Reactive Power Capability Q_max_setpoint = [0, 40, 40, 40] # CHANG: sample : change this value according to your suggestion from 5.2.5.1 Reactive Power Capability Q_min_setpoint = [0, -40, -40, -40] # CHANG: sample :change this value according to your suggestion from 5.2.5.1 Reactive Power Capability InverterCapacity = 120 # CHANG: sample :change this value according to your suggestion from 5.2.5.1 Reactive Power Capability ###### standard power variation for i in range(0, len(P_setpoint)): psspy.read(0, GridInfoPath + FileName) ## psspy.dscn(20022) # eliminate negative power output by slack bus, does not need to consider outside NSW. psspy.machine_data_2(101, r"""1""", [_i, _i, _i, _i, _i, _i], [ P_setpoint[i], 0, Q_max_setpoint[i], Q_min_setpoint[i], InverterCapacity, 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_setpoint[i], 0, Q_max_setpoint[i], Q_min_setpoint[i], InverterCapacity, 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_setpoint[i], 0, Q_max_setpoint[i], Q_min_setpoint[i], InverterCapacity, 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_setpoint[i], 0, Q_max_setpoint[i], Q_min_setpoint[i], InverterCapacity, 0, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f ]) Event_Name.append('Output=' + str(4 * P_setpoint[i]) + 'MW' + ' ' + 'No Contingency')
realari17=36.3*0.906/(230*125.51) #MAG2 ) SBS12 = 50.0 #in MVA z1 = 0.15965*(100./SBS12) #in pu Pi2r = 137.196 #in kW r1 = Pi2r/(10*SBS12) #in pu x1 = math.sqrt(z1**2 - r1**2) z0 = 0.13712*2 #in pu r0 = z0/np.sqrt(1+(x1/r1)**2) x0 = r0*(x1/r1) psspy.seq_two_winding_data_3(busMap['MUCHIPARA3'], busMap['MUCHIPARA2'], "1", #DGP_STR1 (EMCO-11733) intgar1=12, intgar2=2, intgar3=2, realar3=r0, realar4=x0) # Base Generation --------------------------------- psspy.machine_data_2(busMap['BTPSBG1'], realar1=180.) #BTPSB gen1 psspy.machine_data_2(busMap['BTPSBG2'], realar1=180.) #BTPSB gen2 psspy.machine_data_2(busMap['BTPSBG3'], realar1=180.) #BTPSB gen3 psspy.machine_data_2(busMap['DTPSG4'], realar1=180.) #DTPS gen4 psspy.machine_data_2(busMap['DTPSG3'], realar1=98.) #DTPS gen3 psspy.machine_data_2(busMap['BTPSAG1'], intgar1=0) #BKROA gen1 psspy.machine_data_2(busMap['MTPSBG1'], realar1=450.) #MTPSB gen1 psspy.machine_data_2(busMap['MTPSBG2'], realar1=450.) #MTPSB gen2 psspy.machine_data_2(busMap['CTPSG1'], realar1=100.) #CTPS gen1 psspy.machine_data_2(busMap['CTPSG2'], realar1=100.) #CTPS gen2 psspy.machine_data_2(busMap['CTPSG3'], realar1=100.) #CTPS gen3 psspy.machine_data_2(busMap['CTPSG7'], realar1=225.) #CTPS gen7 psspy.machine_data_2(busMap['CTPSG8'], realar1=225.) #CTPS gen8 psspy.machine_data_2(busMap['MTPSG1'], realar1=180.) #MTPS gen1 psspy.machine_data_2(busMap['MTPSG2'], realar1=180.) #MTPS gen2 psspy.machine_data_2(busMap['MTPSG3'], realar1=180.) #MTPS gen3
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, _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])
for i in range(0, len(Branch_Outage_List_Start)): for fault_type in range(1, 5): # re - initialize psspy.read(0, GridInfoPath + file_name + ".raw") psspy.dyre_new([1, 1, 1, 1], GridInfoPath + file_name + ".dyr", "", "", "") psspy.resq(GridInfoPath + file_name + ".seq") psspy.dscn(30531) psspy.dscn(36530) psspy.dscn(37530) psspy.dscn(50030) # add for Clenergy project psspy.machine_data_2(30531, r"""12""", [0, _i, _i, _i, _i, _i], [ _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f ]) psspy.machine_data_2(37530, r"""12""", [0, _i, _i, _i, _i, _i], [ _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f ]) psspy.machine_data_2(100, r"""1""", [_i, _i, _i, _i, _i, _i], [ 115, _f, _f, _f, 132, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f ]) psspy.machine_data_2(100, r"""1""", [_i, _i, _i, _i, _i, _i], [ _f, _f, 5, _f, 132, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f ]) psspy.machine_data_2(100, r"""1""", [_i, _i, _i, _i, _i, _i], [ _f, _f, _f, 5, 132, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f ]) # be careful, partial active power = not enough solar irraidance. psspy.fdns([1, 0, 0, 1, 0, 0, 99, 0])