Ask Your Question
1

PSSE35 psspy.pssehalt_2()

asked 2025-01-01 22:25:05 -0600

trapezoid gravatar image

updated 2025-01-12 14:14:54 -0600

I have a Python automation tool that has options to print out several different types of reports.

It works well with PSSE34, but in PSSE35, it crashes when the psspy.pssehalt2() function is called and psseinit() is called after. I tried commenting psspy.pssehalt2() out which in some cases is ok, but it appears that calling pssehalt_2() is still necessary because without it, psseinit() crashes routinely and I have trouble initializing simulations.

It seems to me that psspy.pssehalt_2() is bugged.

Does anyone know a workaround for this? PSSE version 35.6, Python 3.7 64-bit. I have the same issue in Python 3.9 64-bit.

Thanks.

EDIT to add code:

This code does not work in PSSE35. It crashes in the second loop.

import sys
sys.path.insert(0,"C:/Program Files/PTI/PSSE35/35.6/PSSPY37")
sys.path.insert(0,"C:/Program Files/PTI/PSSE35/35.6/PSSBIN")
case_file = "IEEE 39 bus.RAW"
dyr_file = "IEEE 39 bus.dyr"
for i in range(2):
    import psse35
    import psspy

    psspy.psseinit(150_000)
    ierr = psspy.read(0, case_file)
    ierr = psspy.dyre_new([1, 1, 1, 1], dyr_file, "", "", "")

    psspy.pssehalt_2()
edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted
1

answered 2025-01-03 08:18:58 -0600

jconto gravatar image

updated 2025-01-12 20:40:52 -0600

From the API manual: "1.221. PSSEHALT_2 Use this API to end the operation of PSSE, closes all associated files and returns to the calling application"

After pssehalt is called, there is no PSSe in memory. So for the next run, you need to star over (import PSSe35 -> import psspy -> import psseinit)

Can you can post some code to see the pssehalt behavior?

The following code completed the 2 loops, having halt2 run once outside the loop:

import sys
import psse35
import psspy
psspy.psseinit()

sys.path.insert(1,r"C:/Program Files/PTI/PSSE35/35.6/PSSPY39")
#sys.path.insert(0,"C:/Program Files/PTI/PSSE35/35.6/PSSBIN")
case_file = "IEEE9_v35.RAW"
dyr_file = "IEEE9.dyr"

for i in range(2):
    ierr = psspy.read(0, case_file)
    ierr = psspy.dyre_new([1, 1, 1, 1], dyr_file, "", "", "")    
    print('loop ',i)
psspy.pssehalt_2()
edit flag offensive delete link more

Comments

Added code!

trapezoid gravatar imagetrapezoid ( 2025-01-12 14:07:30 -0600 )edit
0

answered 2025-01-12 14:07:18 -0600

trapezoid gravatar image

Sorry for the delay. I had to narrow the code down.

This code does not work in PSSE35. It crashes in the second loop.

import sys
sys.path.insert(0,"C:/Program Files/PTI/PSSE35/35.6/PSSPY37")
sys.path.insert(0,"C:/Program Files/PTI/PSSE35/35.6/PSSBIN")
case_file = "IEEE 39 bus.RAW"
dyr_file = "IEEE 39 bus.dyr"
for i in range(2):
    import psse35
    import psspy

    psspy.psseinit(150_000)
    ierr = psspy.read(0, case_file)
    ierr = psspy.dyre_new([1, 1, 1, 1], dyr_file, "", "", "")

    psspy.pssehalt_2()
edit flag offensive delete link more

Comments

You need to dedent the line psspy.pssehalt2_() to get out from the for-loop to avoid closing the loaded case. Indentation in python code should be reviewed. Also take the import lines and psseinit line out from the for-loop, it's not a good practice to import libraries each iteration. Hope this help

ssellsch gravatar imagessellsch ( 2025-01-14 09:31:55 -0600 )edit
0

answered 2025-01-13 04:37:04 -0600

perolofl gravatar image

I can confirm that pssehalt_2 works as intended in rev 33. In rev 35 the script is aborted in the second loop after psseinit. PSSE is started again but the rest of the commands in the loop are not executed! Is that what you mean with "crash"? It seems to be a bug in rev 35.

The workaround I propose is not to stop PSSE at the end of each loop. Start PSSE before the loop and use the same PSSE instance for all loops. See @jconto's answer for more details.

edit flag offensive delete link more

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: 2025-01-01 22:25:05 -0600

Seen: 175 times

Last updated: Jan 13