Ask Your Question

bronco7TX's profile - activity

2023-09-29 09:42:58 -0500 received badge  Teacher (source)
2022-05-23 07:36:06 -0500 received badge  Famous Question (source)
2020-12-15 13:31:49 -0500 received badge  Notable Question (source)
2020-10-05 22:47:26 -0500 received badge  Famous Question (source)
2020-09-29 21:33:47 -0500 received badge  Notable Question (source)
2020-09-29 00:03:13 -0500 received badge  Popular Question (source)
2020-09-28 12:59:09 -0500 answered a question Python API unable to load dsusr.dll?

After many internal discussions with engineers in my group, I have found out it is an issue with v33.12.1 and the library GVCA02v33.dll. When you open psse via the psspy.psseinit() function, dsusr.dll will automatically be loaded from the current working directory in python and in 2017 vintage MMWG models, the dll GVCA02v33.dll also needs loaded at the same time. I double and triple-checked my pathing to make sure I was in the current working directory but it would not recognize dsusr.dll.

The fix was to go back to v33.12.0 and everything worked without error.

If you are having the same problem with v33.12.1 and dsusr.dll, I suggest asking your IT dept to downgrade you back to v33.12.0 and retry to see if that solves the problem.

2020-09-28 09:03:45 -0500 commented answer Python API unable to load dsusr.dll?

Thanks for the tip. I tried that and still get the same error. I get ierr=1 when running it but I know the path and file name appear to be correct from what I've entered. That part that makes this so hard to pinpoint is this same code works fine for other stability case packages.

2020-09-28 07:55:25 -0500 commented answer Python API unable to load dsusr.dll?

I do not, when I load the case/snap then add libraries within the GUI, it all works without error.

2020-09-28 06:48:20 -0500 asked a question Python API unable to load dsusr.dll?

Hello all, I'm getting an intermittent bug that I can't explain. I have a python script that updates a snapshot, then loads all the adds all model library dll files in a folder and then runs a flatrun.

For some cases when I run the add model library code:

import psspy
workdir = os.getcwd()
print("Current Dir: {}".format(workdir))
liblist = []
for files in os.listdir(workdir):
    if files[-4:].lower() == '.dll':
        liblist.append(files)
for library in liblist:
    ierr = psspy.addmodellibrary(workdir + "\\" + library)

I get the following error:

Current Dir: C:\Users\sjudd\Documents_CodeDev\Model Acceptance Tool\MATLocalMASv33v34200928\PreProj Messages for api ADDMODELLIBRARY Library not found (004183) "C:\Users\sjudd\Documents_CodeDev\Model Acceptance Tool\MATLocalMASv33v34200928\PreProj\dsusr.dll"

The code loads in all other dlls without issue and for some cases it even loads dsusr.dll without issue.

I've run the stability package within the PSSE GUI and don't have issues loading dsusr.dll for the stability package in question.

Is there some pathing issue that causes it to not always recognize dsusr.dll?

2020-08-05 09:08:24 -0500 received badge  Famous Question (source)
2020-08-04 01:51:00 -0500 received badge  Notable Question (source)
2020-08-04 01:51:00 -0500 received badge  Popular Question (source)
2020-07-31 13:07:27 -0500 asked a question Is there an API call to get existing Channel arrays directly into Python?

I'm trying to load all existing channel data (ID, name, desc) from a snapshot into a python dictionary so it can be searched to avoid adding duplicate channels later on in my script. Is there any way to get the data from the API directly into a list or dict array?

All I've found is the following process:

psspy.report_output(2,"chan.txt",[1,0])
ierr = psspy.dlst(1,5)
# then open the text file chan.txt
# then parse the text in the report to build my list/dict manually

It would be ideal if I could avoid the cumbersome process of saving out a text report only to read it back in and split the text into a usable Python dictionary. I was hoping there was an API that had the data come out in arrays directly similar to the PSSARRAYS functions for ACCC data.

2019-10-21 09:09:29 -0500 received badge  Popular Question (source)
2019-10-17 14:41:52 -0500 asked a question How to delete single channel in snapshot or only add Branch VARS channel by itself

I have some scripts that systematically add channels to a case based on a user defined input file. In an effort to keep the out file as small as possible, the code doesn't add duplicate channels. My current problem is say a user already defined a branch P channel:

psspy.branchpchannel([1, -1, -1, 1, 2] '1 ', 'POWR_BRANCH 1-2 ID1')

Later, the user is importing some branches to define an interface and wants both P and Q channels for each branch. Since the user has already defined the P channel, I only want the code to add the Q channel for the branch. Problem is I can only use the pq channel function:

psspy.branchpqchannel([2, -1, -1, 1, 2] '1 ', 'POWR_BRANCH 1-2 ID1')

This creates 2 new channes, POWR on channel 2, and VARS on channel 3.

This however creates a duplicate POWR channel I don't want. I have two questions: 1. Can I just delete a single channel by index (#2 in this example)? I know you can delete all channels, but I don't want to do that because I want to keep all previously added channels. 2. Can I just add the VARS channel without adding the POWR channel?

This same situation applies to psspy.voltageandangle_channel(), I'd like know if I can only add the ANGLE channel without adding the VOLT channel.

2019-10-08 20:32:53 -0500 received badge  Famous Question (source)
2019-08-29 08:14:28 -0500 received badge  Editor (source)
2019-08-29 08:11:46 -0500 answered a question Use multiple Processor for PSSE Dynamics Run

Python also has the ability to split work across multiple cores. Some sample code below on how we run multiple dynamic simulations on the same machine in parallel. Be careful on how many workers you add. The problem can become I/O with all the data from the multiple runs and running 4 in parallel will not be 400% faster than running 1. You get a diminishing rate of return the more cores you add. With this code, you can easily play around with how many cores you want to use and find the optimal number for your machine.

Sample code:

import multiprocessing
from multiprocessing import Process
from multiprocessing import Pool

workers = multiprocessing.cpu_count() - 1 # Run on N-1 cores on local machine
p = Pool(workers)
p.map(run_test, tests) # run_test is a function you call in parallel, tests is an array of data that gets passed to the function (could be case name, snapshot, fault name, etc...)

def run_test(test):
    # Run you stability run here...
2019-08-22 11:30:33 -0500 received badge  Popular Question (source)
2019-08-22 11:30:33 -0500 received badge  Notable Question (source)
2019-08-20 10:03:48 -0500 asked a question How to reload psspy to different PSSE version in same script?

I have a python script where I'm performing acceptance testing of new v34 dynamics models. To do that I run a set of tests with the old model in v33 then run the same tests with the new model in v34. The problem I'm running into is trying to switch PSSE versions mid-script.

Initially I add the v33 BIN and LIB paths to sys.path and os.environ['PATH'] and PSSE intitializes in v33 properly. Next, before I run v34, I remove all v33 paths from sys.path and os.environ, then add in the v34 paths. When I go to initialize PSSE it still has v33 start not v34.

I think it has to do with how the previously imported psspy is still pointing to the v33 location, how do I force python to repoint psspy to the v34 location?

Sample Code:

ver = 33
# Remove old PSSE paths in sys.path and os.environ['PATH']
for p in list(sys.path):
    if 'PTI' in p:
        sys.path.remove(p)
        print 'Removed sys.path Path:' + p
os_paths = os.environ['PATH'].split(';')
for p in list(os_paths):
    if 'PTI' in p:
        os_paths.remove(p)
        print 'Removed os.environ Path:' + p
os.environ['PATH'] = ';'.join(os_paths)

if ver == 33:
    strPssePath = ''  # path to PSSE program executable
    if os.path.exists(r'C:\Program Files (x86)\PTI\PSSE33'):  # 32-bit applications
        strPssePath = r'C:\Program Files (x86)\PTI\PSSE33'
    elif os.path.exists(r'C:\Program Files\PTI\PSSE33'):  # 64-bit applications
        strPssePath = r'C:\Program Files\PTI\PSSE33'

    sys.path.append(os.path.join(strPssePath, 'PSSBIN'))
    sys.path.append(os.path.join(strPssePath, 'PSSLIB'))
    os.environ['PATH'] += ';' + os.path.join(strPssePath, 'PSSBIN')
    os.environ['PATH'] += ';' + os.path.join(strPssePath, 'PSSLIB')

elif ver == 34:
    strPssePath = ''  # path to PSSE program executable
    if os.path.exists(r'C:\Program Files (x86)\PTI\PSSE34'):  # 32-bit applications
        strPssePath = r'C:\Program Files (x86)\PTI\PSSE34'
    elif os.path.exists(r'C:\Program Files\PTI\PSSE34'):  # 64-bit applications
        strPssePath = r'C:\Program Files\PTI\PSSE34'

    sys.path.append(os.path.join(strPssePath, 'PSSBIN'))
    sys.path.append(os.path.join(strPssePath, 'PSSLIB'))
    sys.path.append(os.path.join(strPssePath, 'PSSPY27'))
    os.environ['PATH'] += ';' + os.path.join(strPssePath, 'PSSBIN')
    os.environ['PATH'] += ';' + os.path.join(strPssePath, 'PSSLIB')

import psspy
import redirect
redirect.psse2py()
psspy.psseinit(150000)

(Do some stuff in v33 then repeat code with '34' as the variable ver in the code above)

ver = 34
# Remove old PSSE paths in sys.path and os.environ['PATH']
for p in list(sys.path):
    if 'PTI' in p:
        sys.path.remove(p)
        print 'Removed sys.path Path:' + p
os_paths = os.environ['PATH'].split(';')
for p in list(os_paths):
    if 'PTI' in p:
        os_paths.remove(p)
        print 'Removed os.environ Path:' + p
os.environ['PATH'] = ';'.join(os_paths)

if ver == 33:
    strPssePath = ''  # path to PSSE program executable
    if os.path.exists(r'C:\Program Files (x86)\PTI\PSSE33'):  # 32-bit applications
        strPssePath = r'C:\Program Files (x86)\PTI\PSSE33'
    elif os.path.exists(r'C ...
(more)