First time here? We are a friendly community of Power Systems Engineers. Check out the FAQ!

Ask Your Question
1

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

asked Sep 11 '13

Bob gravatar image

updated Sep 13 '13

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!

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 (Sep 11 '13)

2 answers

Sort by » oldest newest most voted
1

answered Sep 13 '13

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.

link

Comments

Thanks a lot! Your answer is quite right!

Bob gravatar imageBob (Sep 13 '13)
1

answered Dec 5 '13

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)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.
Want to format code in your answer? Here is a one minute demo on Youtube

Add Answer

[hide preview]

Question Tools

Stats

Asked: Sep 11 '13

Seen: 980 times

Last updated: Dec 05 '13