First time here? We are a friendly community of Power Systems Engineers. Check out the FAQ!
1 | initial version |
Hi, instead reading the .dyr file you can retrieve the required values from internal dynamic data arrays. General idea is presented below (not the most elegant code but it serves its purpose). Hope this would help.
import psspy
# ------- SUBSYSTEM DEFINITION AND MACHINE SELECTION CRITERIA ---------
# (a basic example shown here)
Sid=-1 # All machines
Flag=1 # Only in-service machines at in-service plants
ierr, Nmach=psspy.amachcount(Sid, Flag) # get no of machines in the subsystem
ierr, iMbus = psspy.amachint(Sid, Flag, 'NUMBER') # get machine bus numbers
ierr, cMids = psspy.amachchar(Sid, Flag, 'ID') # get machine IDs
iMbus=iMbus[0]
cMids=cMids[0]
fout=open('D:\Examples\Inertia.txt','w') # open a text file at desired location
savFn, snpFn = psspy.sfiles()
fout.write('MODEL: Load flow: %s\n Dynamic model: %s\n\n' % (savFn,snpFn))
fout.write(' BUS NAME GEN MODEL H (sec)\n--------------------------------------------------------\n')
for iM in range(0,Nmach): # iterate through the list of machines
ibus=iMbus[iM]
genId=cMids[iM]
ierr,busN=psspy.notona(ibus)
iH=0 # resetting the intertia value index
ierr, icon0 = psspy.mdlind(ibus, genId, 'GEN', 'CON') # get initial CON address (index)
ierr, genMdl = psspy.mdlnam(ibus, genId, 'GEN') # get generator model name
genMdl=genMdl.strip() # remove blanks
# Find absolute index iH in CONS array using relative CON index in the generator model and
# previously found starting CON index of the generator model
# (here shown only for the three most common models)
if genMdl=='GENCLS': iH=icon0
if (genMdl=='GENSAL')|(genMdl=='GENSAE'): iH=icon0+3
if (genMdl=='GENROU')|(genMdl=='GENROE'): iH=icon0+4
# Get value from CONS array corresponding to the generator inertia
ierr,H=psspy.dsrval('CON', iH)
# Write output to the file
fout.write ('%6d %12s %2s %6s %6.3f\n' % (ibus,busN,genId,genMdl,H))
print ' *** END OF FINDING MACHINE INERTIAS ***'
fout.close()