Ask Your Question
1

Can you help me to review a Python program for PSS/E simulation?

asked 2013-09-11 10:50:03 -0500

Bob gravatar image

updated 2013-09-12 20:06:11 -0500

JervisW gravatar image

I now want to do simulations from Python not PSSE, but I can 't figure out how to do it. For example,trip Generator1 the out file name 1.out,trip Generator2, the out filee name 2.out.and so on. Thanks a lot! The commands are following:

i=1
while i<=3:
    psspy.case('savcnv.sav')
    psspy.rstr('savnw.snp')
    psspy.strt(outfile='i.out')
    psspy.run(tpause=1.0)
    psspy.dist_machine_trip(ibus=101, id='1 ')
    psspy.run(tpause=1.05)
    psspy.dist_clear_fault()
    psspy.run(tpause=5.0)
    i=i+1

Is this OK? How can I do to name the outfile as a variable when the 1st (i=1) simuliatin 1.out the 2nd(i=2) simulation 2.out

I do not know how to do this properly ,please give some advices,Thanks a lot!

edit retag flag offensive close merge delete

Comments

Could you possibly format your code so it is readable on here? What is your exact problem? Are you able to run the code? If so is it throwing error messages at you? Please try to define the problem more precisely, as that will increase the likelihood of you getting good help

nyga0082 gravatar imagenyga0082 ( 2013-09-11 12:04:19 -0500 )edit

2 answers

Sort by ยป oldest newest most voted
1

answered 2013-09-12 20:09:48 -0500

JervisW gravatar image

You are on the right track with this code:

i=1
while i<=3:
    psspy.case('savcnv.sav')
    psspy.rstr('savnw.snp')
    psspy.strt(outfile='i.out')
    psspy.run(tpause=1.0)
    psspy.dist_machine_trip(ibus=101, id='1 ')
    psspy.run(tpause=1.05)
    psspy.dist_clear_fault()
    psspy.run(tpause=5.0)
    i=i+1

But that line outfile='i.out' won't do what you think it does. 'i.out' is just a string, it doesn't know about the i variable you created. You must explicitly tell Python to substitute the i value into the string. e.g.

filename = '%s.out' % i
psspy.strt(outfile=filename)

the %s will be replaced with the i variable so it will change each time in your loop.

edit flag offensive delete link more

Comments

Thanks a lot! Your answer is quite right!

Bob gravatar imageBob ( 2013-09-13 07:48:51 -0500 )edit
1

answered 2013-12-05 15:44:47 -0500

jconto gravatar image

To have info on gen 1 trip be sent to out1:

genlst = [[101,'1'],[202,'1']]
i = 0
for genx in genlst:
    i +=1
    psspy.case('savcnv.sav')
    psspy.rstr('savnw.snp')
    psspy.strt(outfile='%s.out'%i)
    psspy.run(tpause=1.0)
    psspy.dist_machine_trip(ibus=genx[0], id=genx[1])
    psspy.run(tpause=1.05)
    psspy.dist_clear_fault()
    psspy.run(tpause=5.0)
edit flag offensive delete link more

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

Stats

Asked: 2013-09-11 10:50:03 -0500

Seen: 569 times

Last updated: Dec 05 '13