Ask Your Question
0

PSAS to idev converter using python?

asked 2020-09-25 11:31:47 -0500

Type1_bus gravatar image

I'm wondering if perhaps there's an easy way to convert PSAS contingency files to regular idv response. I would like to do this since sometimes I get an error which states that PSSE does not recognize the PSAS command I provide.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2020-09-26 14:35:26 -0500

jconto gravatar image

PSAS files can be converted to *.idv using the python API "psas". Let's translate to idv the following "dxy.psa":

RECOVER FROM savnw.SNP AND SAVNW_cnv.SAV NORETURN
CONVERT MW TO 100 0 MVAR TO 0 100
INITIALIZE OUTPUT dxy.OUT
RUN TO 1 SECONDS PRINT 0 PLOT 1
APPLY FAULT AT BUS 154
RUN FOR 9 CYCLES PRINT 0 PLOT 1
CLEAR FAULT
TRIP LINE FROM BUS 153 TO BUS 154 CIRCUIT 1
RUN TO 5 SECONDS PRINT 0 PLOT 1
END

Now using the following python code "psa2idv.py":

#psa2idv.py - 4 PSSe GUI
'''
convert *.psa to *.idv
Open PSSe and
to convert dxy.psa to dxy.idv: run psa2idv.py
to convert any other x.psa to x.idv: run psa2idv.py with argument x
'''
psas = 'dxy'
if len(sys.argv)>1 and sys.argv[1]:
   psas = sys.argv[1]
infile  = '%s.psa'%psas
outfile = '%s.idv'%psas
ierr, respfile = psspy.psas(infile, outfile)
print ('PSAS converted to ',respfile)

Open PSSe GUI, and run the python code. An *.idv would be created, representing the translation of the *.psa file. Warning: All data files referred within the *.psa file should be accessible to avoid runtime errors.

You can used the macro recorder to get a 'translation' into python by running the *.psa file with 'recording' on.

edit flag offensive delete link more

Comments

Thanks jconto!

Type1_bus gravatar imageType1_bus ( 2020-09-29 09:40:42 -0500 )edit

Is it possible to convert python contingency files to PSAS?

Type1_bus gravatar imageType1_bus ( 2023-06-05 23:44:24 -0500 )edit

No, I have not found a API function to do that, but it can be done using python. You would build code that reads the python contingency and write a text file paraphrasing the PSAS commands. I prefer to keep the contingency in python format.

jconto gravatar imagejconto ( 2023-06-07 09:48:12 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Question Tools

1 follower

Stats

Asked: 2020-09-25 11:31:47 -0500

Seen: 700 times

Last updated: Sep 26 '20