First time here? We are a friendly community of Power Systems Engineers. Check out the FAQ!
1 | initial version |
def ContingencyFiles(idvfiles): idev = [a for a in listdir(idvfiles) if isfile(join(idvfiles, a))] idevinfile = [] for i in idev: idevinfile.append(os.path.splitext(i)[0]) return idev_infile
def ConvertedFiles(cnvfiles): cnv = [b for b in listdir(cnvfiles) if isfile(join(cnvfiles, b))] cnvinfile = [] for j in cnv: cnvinfile.append(os.path.splitext(j)[0]) return cnv_infile
def SnapshotFiles(snpfiles): snp = [c for c in listdir(snpfiles) if isfile(join(snpfiles, c))] snpinfile = [] for k in snp: snpinfile.append(os.path.splitext(k)[0]) return snp_infile
def log_out(directory): try: if not os.path.exists(directory): os.makedirs(directory) except OSError: print ('Error: Creating directory. ' + directory)
if name == 'main': import os, sys from os import listdir from os.path import isfile, join from os.path import splitext import time
pssedir = r"""C:\Program Files (x86)\PTI\PSSE32\PSSBIN"""
sys.path.append (pssedir)
os.environ["PATH"] = os.environ["PATH"] + ";" + pssedir
study_folder = r"""D:/Studies/BBB/"""
idv_files = r"""D:/Studies/BBB/contingency/"""
cnv_files = r"""D:/Studies/BBB/converted/"""
snp_files = r"""D:/Studies/BBB/snapshot/"""
import psspy
import redirect
_i = psspy.getdefaultint()
_f = psspy.getdefaultreal()
_c = psspy.getdefaultchar()
redirect.psse2py()
psspy.psseinit(150000)
for x, y in zip(Converted_Files(cnv_files),Snapshot_Files(snp_files)):
log_out(x)
for z in Contingency_Files(idv_files):
print 'Simulation executed at time ', time.ctime()
print 'The snapshot file is ', y + '.'
print 'The case file is ', x + '.'
print 'The Fault ID is ', z + '.'
print 'Processing dynamic simulation for Fault ID ', z + '...'
psspy.progress_output(2, study_folder + x + "/" + z + '.pdev', [0,0])
psspy.prompt_output(2, study_folder + x + "/" + z + '.odev', [0,0])
try:
psspy.rstr(snp_files + y + '.snp')
except:
print 'Error while opening the file ', y
sys.exit(0)
psspy.powerflowmode()
try:
psspy.case(cnv_files + x + '.cnv')
except:
print 'Error while opening the file ', x
sys.exit(0)
psspy.ordr(0)
psspy.fact()
psspy.tysl(0)
psspy.dynamicsmode(0)
psspy.strt(1, study_folder + x + "/" + z + '.out')
psspy.runrspnsfile(idv_files + z + '.idv')
psspy.run(1,15,60,3,0)
psspy.progress_output(1,'', [0,0])
psspy.prompt_output(1,'', [0,0])
print 'Simulation finished at time ', time.ctime()
print 'Dynamic simulation for Fault ID ', z + ' complete! \n\n'
print 'Total Simulation finished at time ', time.ctime()
print '\nEnd of Dynamic Simulation \n'
2 | No.2 Revision |
def