Ask Your Question
0

Issue Running Dynamic Simulation in Loop, PSSEv35 vs PSSEv34

asked 2022-05-12 09:41:58 -0500

jeffchwai gravatar image

I am using PSSEv35.3 and PSSEv34.9. All I want to do is to write a loop to perform repetitive dynamic simulation. While my script works perfectly for PSSEv34, it behave differently in PSSEv35. To be more specific, it stops at the second loop right after initializing PSSE. I wonder if any of you aware of this issue?

Following is an example (simplified version) script I have for the PSSEv35. All it does is to initialize psse, open a powerflow case, convert load and gen, run CONG, ORDR, FACT & TYSL, and then open the dyr file (p.s., I am not even going to start any transient simulation at this point). I try to repeat the above steps 10 times. Running this in PSSE35 the scripts stops right after psse initialize in the second loop. However, this completes the loop perfectly in PSSE34 (the script for the psse34 version is just a change to the pssepy_PATH and the call to psse34)

Please let me know if I miss anything or if someone also experience the same issue. Thanks in advance.

import sys,os
from contextlib import contextmanager

pssepy_PATH = r"C:\Program Files\PTI\PSSE35\35.3\PSSPY39"
sys.path.append(pssepy_PATH)

import psse35
import psspy
psspy.throwPsseExceptions = True

_i = psspy.getdefaultint()
_f = psspy.getdefaultreal()
_s = psspy.getdefaultchar()

@contextmanager
def open_sav(fname):
    try:
        psspy.psseinit(150000)
        psspy.case(fname)
        yield
    except psspy.PsseException as e:
        print(e.message)
    finally:
        try:
            psspy.close_powerflow()
            psspy.deltmpfiles()
            psspy.pssehalt_2()
        except psspy.PsseException as e:
            print(e.message)

def coft():
    psspy.cong(0)
    psspy.ordr(0)
    psspy.fact()
    psspy.tysl(0)


def main():
    for i in range (10):
        with open_sav(r"xyz.sav"):
            print("loop #: ")
            print(i)
            convertload() # it is just a simple function call to conl 
            coft() 
            psspy.dyre_new([_i,_i,_i,_i],r"aaa.dyr","","","") 

    print("finish loop")


if __name__ == "__main__":
    main()

p.s. I run the script in Python3.9 (x64 for PSSEv35 and x86 for PSSEv34)

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2022-05-12 11:12:34 -0500

jconto gravatar image

I was able to run it in v.34 & v35 after these changes:

- Move  "psspy.psseinit(150000)" to just below "import psspy"
- Comment "psspy.pssehalt_2()"
- Comment "convertload()"

It seems that "pssehalt_2" closes PSSe and with that psspy, therefore causing errors on subsequent calls to psspy.

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: 2022-05-12 09:41:58 -0500

Seen: 80 times

Last updated: May 12