Ask Your Question
0

Terminate Simulation When Rotor Angle Exceed Certain Value

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

eklabog gravatar image

Hi,

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
0

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

eklabog gravatar image

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

for y in range(30,50,10): x = 1+y*.001

psspy.case(r"""C:\SAVNW\C.cnv""")
psspy.rstr(r"""C:\SAVNW\C.snp""")

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

psspy.bsys(1,0,[0.0,0.0],0,[],3,[102],0,[],0,[])
psspy.chsb(1,0,[-1,-1,-1,1,1,0])
psspy.strt(0,OutFileName)

psspy.run(0, 1.0,1,1,0)
psspy.dist_bus_fault(151,1,0.0,[0.0,-0.2E+10])
psspy.run(0,x,1,1,0) 
psspy.dist_clear_fault(1)

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

Comments

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 -0600 )edit

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

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

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

perolofl gravatar image

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

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

Comments

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 -0600 )edit

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

eklabog gravatar imageeklabog ( 2018-09-07 01:24:49 -0600 )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: 2018-08-25 00:49:24 -0600

Seen: 539 times

Last updated: Sep 07 '18