Ask Your Question
0

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

asked 2020-01-06 01:10:44 -0600

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.

edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted
0

answered 2022-05-05 19:28:19 -0600

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.

edit flag offensive delete link more
0

answered 2020-01-24 13:53:27 -0600

likethevegetable gravatar image

updated 2020-01-24 13:57:01 -0600

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.

edit flag offensive delete link more

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 ( 2020-01-29 21:43:32 -0600 )edit

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 ( 2020-02-05 12:49:08 -0600 )edit

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 ( 2020-02-06 20:54:12 -0600 )edit
0

answered 2020-01-07 00:16:29 -0600

perolofl gravatar image

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

For documentation:

import dyntools
help(dyntools)
edit flag offensive delete link more

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 ( 2020-01-07 03:21:13 -0600 )edit

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

perolofl gravatar imageperolofl ( 2020-01-08 01:32:58 -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: 2020-01-06 01:10:44 -0600

Seen: 1,436 times

Last updated: May 05 '22