First time here? We are a friendly community of Power Systems Engineers. Check out the FAQ!
1 | initial version |
Hello Everyone,
i want a code to perform dynamic simulation and calculate FVSI later ... to achieve that i had compile some codes got it from here, but i stuck to complete the code. can you please help me to complete it ..
Much Thanks
*#identify system office and tools function. import os import sys import glob
PSSE_PATH = r'C:\Program Files (x86)\PTI\PSSEUniversity33\PSSBIN'
sys.path.append(PSSE_PATH)
os.environ['PATH'] += ';' + PSSE_PATH
import psspy import redirect redirect.psse2py() psspy.psseinit()
bussystem= r"""C:\Users\user\Desktop\IT\FYP2\Dynamic\shortcourse5bussytem\TEST1.sav""" psspy.case(bussystem)
psspy.fdns([0,0,0,1,1,0,99,0])
psspy.conl(-1,1,1) psspy.conl(-1,1,2,[0,0],[100,0,0,100]) psspy.conl(-1,1,3)
psspy.cong()
psspy.ordr() psspy.fact() psspy.tysl()
psspy.dyre_new(dyrefile="C:\Users\user\Desktop\IT\FYP2\Dynamic\shortcourse5bussytem\daynmictest.dyr")
psspy.chsb(sid=0,all=1, status=[-1,-1,-1,1,13,0])
psspy.chsb(sid=0,all=1, status=[-1,-1,-1,1,1,0])
psspy.chsb(sid=0,all=1, status=[-1,-1,-1,1,16,0])
psspy.snap(sfile="C:\Users\user\Desktop\IT\FYP2\Dynamic\shortcourse5bussytem\daynmictest.snp")
psspy.strt(outfile="C:\Users\user\Desktop\IT\FYP2\Dynamic\shortcourse5bussytem\daynmictest.out") psspy.run(tpause=1)
def array2dict(dictkeys, dictvalues): '''Convert array to dictionary of arrays. psspy.halt()s dictionary as {dictkeys:dictvalues} ''' tmpdict = {} for i in range(len(dictkeys)): tmpdict[dictkeys[i].lower()] = dict_values[i] return tmpdict
def busindexes(busnum, busnumlist): '''Find indexes of a bus in list of buses. psspy.halt()s list with indexes of 'busnum' in 'busnumlist'. ''' busidxes = [] startidx = 0 buscounts = busnumlist.count(busnum) if buscounts: for i in range(buscounts): tmpidx = busnumlist.index(busnum,startidx) busidxes.append(tmpidx) startidx = tmpidx+1 return busidxes
def splitstring_commaspace(tmpstr): '''Split string first at comma and then by space. Example: Input tmpstr = a1 a2, ,a4 a5 ,,,a8,a9 Output strlst = ['a1', 'a2', ' ', 'a4', 'a5', ' ', ' ', 'a8', 'a9'] ''' strlst = [] commalst = tmpstr.split(',') for each in commalst: eachlst = each.split() if eachlst: strlst.extend(eachlst) else: strlst.extend(' ')
return strlst
savfile = 'savnw.sav' print "steadystate30-6-14: %s\n\n"%savfile clnttls = "%6s,%18s,%6s,%18s,%3s,%8s,%8s,%8s,%8s,%8s,%8s,%8s,%8s,%8s,%8s\n"%('FRMBUS','FROMBUSEXNAME','TOBUS','TOBUSEXNAME','CKT','R(pu)','X(pu)','Z(pu)','ZZ','Vs(pu)','VsVs','Pj','Qj','Qj(pu)','FVSI') print clnttls
sid = -1
flagbus = 1 # in-service flagplant = 1 # in-service flagload = 1 # in-service flagswsh = 1 # in-service flagbrn = 1 # in-service ownerbrn = 1 # use bus ownership, ignored if sid is -ve ties_brn = 5 # ignored if sid is -ve
titleline1, titleline2 = psspy.titldt()
istrings = ['number','type','area','zone','owner','dummy'] ierr, idata = psspy.abusint(sid, flag_bus, istrings) if ierr: print '(1) psspy.abusint error = %d' % ierr psspy.halt() ibuses = array2dict(istrings, idata)
rstrings = ['base','pu','kv','angle','angled','mismatch','omismatch'] ierr, rdata = psspy.abusreal(sid, flagbus, rstrings) if ierr: print '(1) psspy.abusreal error = %d' % ierr psspy.halt() rbuses = array2dict(strings, rdata)
xstrings = ['voltage','shuntact','oshuntact','shuntnom','oshuntnom','mismatch','omismatch']
ierr, xdata = psspy.abuscplx(sid, flagbus, xstrings)
if ierr:
print '(1) psspy.abuscplx error = %d' % ierr
psspy.halt()
xbuses = array2dict(xstrings, xdata)
cstrings = ['name','exname'] ierr, cdata = psspy.abuschar(sid, flag_bus, cstrings) if ierr: print '(1) psspy.abuschar error = %d' % ierr psspy.halt() cbuses = array2dict(cstrings, cdata)
ibusesall={};rbusesall={};xbusesall={};cbusesall={}; if sid == -1: ibusesall=ibuses rbusesall=rbuses xbusesall=xbuses cbusesall=cbuses else: ierr, idata = psspy.abusint(-1, flag_bus, istrings) if ierr: print '(2) psspy.abusint error = %d' % ierr psspy.halt() ibusesall = array2dict(istrings, idata)
ierr, rdata = psspy.abusreal(-1, flag_bus, rstrings)
if ierr:
print '(2) psspy.abusreal error = %d' % ierr
psspy.halt()
rbusesall = array2dict(rstrings, rdata)
ierr, xdata = psspy.abuscplx(-1, flag_bus, xstrings)
if ierr:
print '(2) psspy.abuscplx error = %d' % ierr
psspy.halt()
xbusesall = array2dict(xstrings, xdata)
ierr, cdata = psspy.abuschar(-1, flag_bus, cstrings)
if ierr:
print '(2) psspy.abuschar error = %d' % ierr
psspy.halt()
cbusesall = array2dict(cstrings, cdata)
istrings = ['fromnumber','tonumber','status','nmeternumber','owners','own1','own2','own3','own4'] ierr, idata = psspy.abrnint(sid, ownerbrn, tiesbrn, flag_brn,1, istrings) if ierr: print 'psspy.abrnint error = %d' % ierr psspy.halt() ibranch = array2dict(istrings, idata)
rstrings = ['amps','pucur','pctrate','pctratea','pctrateb','pctratec','pctmvarate', 'pctmvaratea','pctmvarateb',#'pctmvaratec', 'fract1','fract2','fract3','fract4','rate','ratea','rateb','ratec', 'p','q','mva','ploss','qloss', 'op','oq','omva','oploss','oqloss' ] ierr, rdata = psspy.abrnreal(sid, ownerbrn, tiesbrn, flagbrn,1, rstrings) if ierr: print 'psspy.abrnreal error = %d' % ierr psspy.halt() rbranch = array2dict(rstrings, rdata)
xstrings = ['rx','pq','pqloss','opq','opqloss'] ierr, xdata = psspy.abrncplx(sid, ownerbrn, tiesbrn, flag_brn,1, xstrings) if ierr: print 'psspy.abrncplx error = %d' % ierr psspy.halt() xbranch = array2dict(xstrings, xdata)
cstrings = ['id','fromname','fromexname','toname','toexname','nmetername','nmeterexname'] ierr, cdata = psspy.abrnchar(sid, ownerbrn, tiesbrn, flag_brn,1, cstrings) if ierr: print 'psspy.abrnchar error = %d' % ierr psspy.halt() cbranch = array2dict(cstrings, cdata)
for i in range(len(ibuses['number'])): bus = ibuses['number'][i]
flowfrombusidxes = busindexes(bus,ibranch['fromnumber'])
for idx in flowfrombusidxes:
b = ibranch['fromnumber'][idx]
fbn = cbranch['fromexname'][idx]
tb = ibranch['tonumber'][idx]
tbn = cbranch['toexname'][idx]
ckt = cbranch['id'][idx]
r = abs(xbranch['rx'][idx].real)
x = xbranch['rx'][idx].imag
frombusidx = busindexes(ibranch['fromnumber'][idx],ibusesall['number'])
vs = rbusesall['pu'][frombusidx[0]]
ps = rbranch['p'][idx]
qs = rbranch['q'][idx]
from math import sqrt
z = sqrt(r*r+x*x)
z2 = pow(z,2)
vs2 = pow(vs,2)
qsj = abs(qs/100)
fvsi= (4*z2*qsj)/(vs2*x)
print "%(b)6d,%(fbn)18s,%(tb)6d,%(tbn)18s,%(ckt)3s,%(r)8.6f,%(x)8.6f,%(z)8.6f,%(z2)8.6f,%(vs)8.4f,%(vs2)8.4f,%(ps)8.2f,%(qs)8.2f,%(qsj)8.2f,%(fvsi)8.4f\n"%vars() *
2 | No.2 Revision |
Hello Everyone,
i want a code to perform dynamic simulation and calculate FVSI later ... to achieve that i had compile some codes got it from here, but i stuck to complete the code. can you please help me to complete it ..
Much Thanks
*#identify system office and tools function.
import os
import sys
import sys.path.append(PSSE_PATH)
psspy.fdns([0,0,0,1,1,0,99,0])
psspy.cong()
psspy.dyre_new(dyrefile="C:\Users\user\Desktop\IT\FYP2\Dynamic\shortcourse5bussytem\daynmictest.dyr")
psspy.snap(sfile="C:\Users\user\Desktop\IT\FYP2\Dynamic\shortcourse5bussytem\daynmictest.snp")
flagbus