##for i in range(len(in_branches[0])): ## psspy.branch_data(in_branches[0][i], in_branches[1][i], intgar1=0) ##ierr, in_trfs = psspy.atrnint(sid=2, string=['FROMNUMBER', 'TONUMBER'], ## flag=1) ##for i in range(len(in_trfs[0])): ## psspy.two_winding_data(in_trfs[0][i], in_trfs[1][i], intgar1=0) ###------------------------ status, scalval = [0,1,4,0], [] ierr, totals, moto = psspy.scal(sid=1, all=0, apiopt=1, status=status, scalval=scalval) scalval = [0.,0.,totals[2],totals[3],totals[4],totals[5],0.98] ierr, totals, moto = psspy.scal(sid=1, all=0, apiopt=2, status=status, scalval=scalval) psspy.solution_parameters_3(intgar2=70) #psspy.fdns() psspy.fnsl((1,0,1,0,0,0,99,1)) 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
###------------------------ status, scalval = [0, 1, 4, 0], [] ierr, totals, moto = psspy.scal(sid=1, all=0, apiopt=1, status=status, scalval=scalval) scalval = [0., 0., totals[2], totals[3], totals[4], totals[5], 0.98] ierr, totals, moto = psspy.scal(sid=1, all=0, apiopt=2, status=status, scalval=scalval) psspy.solution_parameters_3(intgar2=70) #psspy.fdns() psspy.fnsl((1, 0, 1, 0, 0, 0, 99, 1)) 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
os.environ['PATH'] = os.environ['PATH'] + ';' + PSSE_LOCATION import psspy import redirect redirect.psse2py() #-------------------------------- # PSS/E Saved case ##CASE = r"C:\Program Files\PTI\PSSE32\EXAMPLE\DVC_ACTUALR1.sav" CASE = r"C:\Program Files (x86)\PTI\PSSE33\EXAMPLE\DVC_ACTUALR1.sav" psspy.psseinit(8000) psspy.case(CASE) psspy.solution_parameters_3(intgar1=120, intgar2=20) #-------------------------------- # Initialisation # CD as on 31.3.2013 ierr = psspy.load_data_3(44100, realar1=44.6) #BOKARO ierr = psspy.load_data_3(44101, realar1=24.4) #MOSABANI ierr = psspy.load_data_3(44102, realar1=121.8) #BURDWAN ierr = psspy.load_data_3(44103, realar1=41.0) #BELMURI ierr = psspy.load_data_3(44104, realar1=15.0) #HOWRAH ierr = psspy.load_data_3(44105, realar1=17.0) #KHARAGPUR ierr = psspy.load_data_3(44106, realar1=351.0) #CHANDRAPURA ierr = psspy.load_data_3(44107, realar1=10.0) #KOLAGHAT ierr = psspy.load_data_3(44108, realar1=140.0) #JAMSHEDPUR ierr = psspy.load_data_3(44101, realar1=42.2) #DTPS ierr = psspy.load_data_3(44110, realar1=20.0) #BARHI
def QVAnalysis(CASE,ireg,activateplot): busno = 44999 # Fictitious generator bus genid = 1 status = 1 pgen = 0.0 # Fict gen P output Qlimit = 9999.0 # Fict. gen Q limit pmax = 0.0 # Fict gen P limit #-------------------------------- 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 get_genExhausted(pv): """ get the number of gen whose reactive power got exhausted. """ genExhausted = [] GenReactivePowerOutput = getGenReactivePowerOutput(pv) GenReactivePowerMax = getGenReactivePowerMax(pv) GenReactivePowerMin = getGenReactivePowerMin(pv) for i in range(0,len(pv)): if GenReactivePowerOutput[i] == GenReactivePowerMax[i] \ or GenReactivePowerOutput[i] == GenReactivePowerMin[i]: genExhausted.append(pv[i]) return genExhausted psspy.psseinit(12000) psspy.case(CASE) psspy.solution_parameters_3(intgar2=60) # set number of solution iterations. psspy.bus_data_2(busno, intgar1=2, name='TEST') psspy.branch_data(i=busno, j=ireg) all_bus = findAllBuses() pq,pv,slackBus = findAllBusType(all_bus) add_machine() # get gen that exhausted its reactive power genExhausted_old = get_genExhausted(pv) pu = [x for x in np.arange(1.0, 0.2, -0.005)] varlist = [] voltagelist = [] for v in pu: res = get_mvar(v) if res: psspy.save("temp") varlist.append(res) voltagelist.append(v) else: break # get new gen that exhausted its reactive power psspy.case("temp") busGenExhausted = [] genExhausted_new = get_genExhausted(pv) for bus in genExhausted_new: if bus not in genExhausted_old: busGenExhausted.append(bus) QminIndex = np.argmin(varlist) Qmin = varlist[QminIndex] Vmin = voltagelist[QminIndex] if activateplot == 1: plt.plot(voltagelist, varlist, '-o') plt.plot(Vmin,Qmin,'ro') plt.xlabel('PU') plt.ylabel('MVar') plt.grid() return Qmin,Vmin,busGenExhausted
sys.path.append(PSSE_LOCATION) os.environ['PATH'] = os.environ['PATH'] + ';' + PSSE_LOCATION import psspy import redirect redirect.psse2py() #-------------------------------- # PSS/E Saved case ##CASE = r"C:\Program Files\PTI\PSSE32\EXAMPLE\DVC_ACTUALR1.sav" CASE = r"C:\Program Files (x86)\PTI\PSSE33\EXAMPLE\DVC_ACTUALR1.sav" psspy.psseinit(8000) psspy.case(CASE) psspy.solution_parameters_3(intgar1=120, intgar2=20) #-------------------------------- # Initialisation # CD as on 31.3.2013 ierr = psspy.load_data_3(44100, realar1=44.6) #BOKARO ierr = psspy.load_data_3(44101, realar1=24.4) #MOSABANI ierr = psspy.load_data_3(44102, realar1=121.8) #BURDWAN ierr = psspy.load_data_3(44103, realar1=41.0) #BELMURI ierr = psspy.load_data_3(44104, realar1=15.0) #HOWRAH ierr = psspy.load_data_3(44105, realar1=17.0) #KHARAGPUR ierr = psspy.load_data_3(44106, realar1=351.0) #CHANDRAPURA ierr = psspy.load_data_3(44107, realar1=10.0) #KOLAGHAT ierr = psspy.load_data_3(44108, realar1=140.0) #JAMSHEDPUR ierr = psspy.load_data_3(44101, realar1=42.2) #DTPS ierr = psspy.load_data_3(44110, realar1=20.0) #BARHI