0

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

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.

bikiran1991's avatar
47
bikiran1991
asked 2020-01-06 01:10:44 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

3 Answers

0

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

For documentation:

import dyntools
help(dyntools)
perolofl's avatar
3.8k
perolofl
answered 2020-01-07 00:16:29 -0500
edit flag offensive 0 remove flag delete 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's avatar bikiran1991 (2020-01-07 03:21:13 -0500) edit

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

perolofl's avatar perolofl (2020-01-08 01:32:58 -0500) edit
add a comment see more comments
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.

likethevegetable's avatar
101
likethevegetable
answered 2020-01-24 13:53:27 -0500, updated 2020-01-24 13:57:01 -0500
edit flag offensive 0 remove flag delete 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's avatar bikiran1991 (2020-01-29 21:43:32 -0500) 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's avatar likethevegetable (2020-02-05 12:49:08 -0500) 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's avatar bikiran1991 (2020-02-06 20:54:12 -0500) edit
add a comment see more comments
0

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.

GaryB's avatar
1
GaryB
answered 2022-05-05 19:28:19 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments

Your Answer

Login/Signup to Answer