Ask Your Question

Terminate Simulation When Rotor Angle Exceed Certain Value

asked 2018-08-25 00:49:24 -0500

eklabog gravatar image


I made a script to run a set of transient simulations while applying a fault on a bus. Fault duration will increase in each step of a loop and a separate out file will be created for every fault duration. I have done up to this but want to terminate the simulation when the rotor angle exceeds a certain value (to save simulation time).

Is there any way to read a particular channel value (while the dynamic simulation is running) and compare it with some predefined value by an "if statement" and then terminating the loop when the if statement becomes true?

Can anybody help me with some python code?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2018-09-07 01:14:12 -0500

eklabog gravatar image

updated 2018-09-07 01:21:57 -0500

for y in range(30,50,10): x = 1+y*.001"""C:\SAVNW\C.cnv""")

OutFileName = 'ANGL_test'+str(y)+'.out'

psspy.strt(0,OutFileName), 1.0,1,1,0)

for t in range(2,10,1): = t)       
    if psspy.chnval(1) < -1000 or psspy.chnval(1) > 1000:       
edit flag offensive delete link more


See my answer above. API chnval returns a tuple so your if statement is wrong, i.e. always True. Use ierr,ang = psspy.chnval(1) instead and use ang in your if statement. You would have seen this yourself if you just used print psspy.chnval(1) in your code.

perolofl gravatar imageperolofl ( 2018-09-07 01:44:54 -0500 )edit

Thanks a lot, man, your idea works great, thanks again.

eklabog gravatar imageeklabog ( 2018-09-07 13:41:00 -0500 )edit

answered 2018-08-27 02:50:02 -0500

perolofl gravatar image

updated 2018-09-07 01:39:39 -0500

Use an extra loop to perform the simulation in steps of a delta time, e.g. 1 second step.

The simulation will then stop every second and you can check the channel value with psspy.chnval.

Terminate the loop with break if rotor angle exceeds the chosen limit.

Please note that chnval returns a tuple:

ierr, rval = chnval(n)
edit flag offensive delete link more


Thank you very much perolofl, I have modified my code according to your suggestion, but it seems no matter what value the if statement detects, it returns true and terminates the extra loop, Can you please check the code in the next (above) answer.

eklabog gravatar imageeklabog ( 2018-09-07 01:14:02 -0500 )edit

N.B.: I have used the "savnw" example case from PSSE v33

eklabog gravatar imageeklabog ( 2018-09-07 01:24:49 -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


Asked: 2018-08-25 00:49:24 -0500

Seen: 309 times

Last updated: Sep 07 '18