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

Ask Your Question
0

dyntools.CHNF() causes python to crash. Help!

asked Jan 6 '0

bikiran1991 gravatar image

I am running a python script to do dynamic contingency analysis. The command dyntools.CHNF() (to get the output channel values) causes python to crash when there are some NaN values. There is no error message, python just crashes.

Has anyone else encountered this behavior and found any ways to either skip over this issue or fix it? Ideally, i want to skip to the next simulation when this happens.

I couldnt find the command 'dyntools.CHNF()' in the PSSE API module as well. I was looking for ways to skip getting the output data if there were NaN values in the output channels.

3 answers

Sort by » oldest newest most voted
0

answered May 6 '2

GaryB gravatar image

Try this:

import multiprocessing as mp
def load_out(out_file,q):
    try:
        chnfobj = dyntools.CHNF(out_file,outvrsn=0)
    except TypeError:
        chnfobj = None
    q.put(chnfobj)

q = mp.Queue() #load the .out in a separate process 
p = mp.Process(target=load_out, args = (out_file,q,))
p.start()
chnfobj = q.get()

It runs in a subprocess and doesn't collide with psspy.

Note that there is no p.join() function; it hangs indefinitely. There is probably a way to garbage collect or pass data rather than the chnf obj back. But this works for me.

link
0

answered Jan 24 '0

likethevegetable gravatar image

updated Jan 24 '0

Use the following line:

psspy.set_NaN_python()

Immediately after psspy.psseinit(150000).

This is assuming you have psspy imported and PSSE initialized. I ran into the exact same issues. FYI, you can import and use dyntools without psspy, which would also help. If you aren't doing this, then I'll need some more info to help.

Hope this helps; sorry for the late reply.

link

Comments

I am using PSSE v33. It seems this command (psspy.set_NaN_python()) is not part of this psspy package. Also, i am not sure why importing dyntools without psspy would help. In any case, i am importing both when running my script. I need psspy to run the simulation and dyntools to get the output.

bikiran1991 gravatar imagebikiran1991 (Jan 30 '0)

Have you tried it yet? The command is not in the API manual, but it works for me (v 33.10). Importing dyntools without psspy had helped me when I ran into the same issue in the past; you only alluded to the fact that the issue arose with dyntools. For me, the issue actually came from psspy and NaN

likethevegetable gravatar imagelikethevegetable (Feb 5 '0)

Yeah i tried psspy.set_NaN_python() and its not part of the module. Maybe because I have an older version (v33.3). I need to run psspy for the simulations and then i use dyntools only for getting the outputs. And if i dont use the dyntools.CHNF command, there is no crash.

bikiran1991 gravatar imagebikiran1991 (Feb 7 '0)
0

answered Jan 7 '0

perolofl gravatar image

Test to use try statement in order to avoid Python crash.

For documentation:

import dyntools
help(dyntools)
link

Comments

tried that already. since python crashes, this doesn't work. checked the dyntools help. There is nothing helpful in the options for dyntools.CHNF. To fix this crash, i need to know if the output channels contain any NaN characters, before running the command: dyntools.CHNF().

bikiran1991 gravatar imagebikiran1991 (Jan 7 '0)

I assume PSS/E will crash if you open the corrupt out-file inside PSS/E.

perolofl gravatar imageperolofl (Jan 8 '0)

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

1 follower

Stats

Asked: Jan 6 '0

Seen: 1,540 times

Last updated: May 05 '22