Ask Your Question

miltonfrey's profile - activity

2023-10-12 10:19:38 -0500 received badge  Student (source)
2023-10-12 10:18:22 -0500 received badge  Self-Learner (source)
2023-10-12 10:18:22 -0500 received badge  Teacher (source)
2022-12-28 01:23:36 -0500 received badge  Famous Question (source)
2022-12-28 01:23:36 -0500 received badge  Notable Question (source)
2022-12-23 01:56:04 -0500 received badge  Popular Question (source)
2022-12-22 13:50:29 -0500 received badge  Supporter (source)
2022-12-22 13:50:27 -0500 commented answer Dynamics of starting a generator

I must say I'm surprised. Okay, I will go ahead and see what I can do. Thanks for the help.

2022-12-22 13:28:11 -0500 received badge  Famous Question (source)
2022-12-22 12:59:49 -0500 asked a question Dynamics of starting a generator

Is there a way to simulate a generator starting up and simulate the resulting inrush current and voltage sag?

I am looking specifically at a weak system during power system restoration from blackout, starting the first two or three baseload generators after blackstart units are online and cranking paths have been established.

The problems I have run into so far are that I should not change a generators status as seen in "Reconnecting Generators During Dynamic Simulation". (Can't post links due to karma). That post also mentions having the generator on a separate island, however in this case that would require that the generator already be online, and it would have to be a swing machine. I don't believe that would be the correct simulation for this scenario.

2022-10-20 22:54:02 -0500 received badge  Popular Question (source)
2022-10-20 22:54:02 -0500 received badge  Notable Question (source)
2022-10-13 13:58:51 -0500 commented answer [SOLVED] Cannot load psscommon

That's what I was doing previously when using Python 2.7, but I was no longer able to get it to work in Python 3.9. It can't find psse34 even though 'C:\Program Files (x86)\PTI\PSSE34\PSSPY39' is in PATH variable.

2022-10-13 11:48:31 -0500 answered a question [SOLVED] Cannot load psscommon

SOLVED

I was able to get it working. All that was missing was import psse34 as well.

import sys, os
PSSE_LOCATION = r'''C:\Program Files (x86)\PTI\PSSE34\PSSPY39'''
sys.path.append(PSSE_LOCATION)
os.environ['PATH'] = os.environ['PATH'] + ';' + PSSE_LOCATION
import psse34
import psspy

This solves the DLL import issue. I'm not sure why, but there's the fix.

2022-10-11 08:37:56 -0500 asked a question [SOLVED] Cannot load psscommon

When running my code, I get this traceback. This is only on PSSE 34.9.4 and 32 bit Python 3.9.13, using 32 bit Python 2.7.18 and PSSE 34.9.4 works just fine.

PS C:\Users\path> .\run.bat
    Traceback (most recent call last):
        File "C:\Users\path\program.py", line 26, in <module>
            import psspy
        File ".\psspy.py", line 56, in <module>
ImportError: DLL load failed while importing psscommon: The specified module could not be found.

I have done all the importing and path setting with this code.

import sys, os
PSSE_LOCATION = r'''C:\Program Files (x86)\PTI\PSSE34\PSSPY39'''
sys.path.append(PSSE_LOCATION)
os.environ['PATH'] = os.environ['PATH'] + ';' + PSSE_LOCATION
import psspy

The part that confuses me is that the file psspy.pyc and psscommon.pyd are both in the folder added to the path.

2022-09-14 07:24:55 -0500 received badge  Enthusiast
2022-06-30 07:30:19 -0500 commented answer [SOLVED] Import custom Python file

Thanks, this worked perfectly. Still need to import psspy, but this makes it much easier.

2022-06-30 07:29:42 -0500 received badge  Scholar (source)
2022-06-29 14:15:38 -0500 answered a question [SOLVED] Import custom Python file

Okay, I solved it. The boilerplate code didn't recompile until I closed PSSE which is why my error changed today. The problem I was having yesterday is that the boilerplate code needed to import psspy for some reason, even though it was running in PSSE (GUI). The code for importing is:

import sys, os
PSSE_LOCATION = os.path.join('C:', os.sep, 'Program Files (x86)', 'PTI', 'PSSE34','PSSPY27')
sys.path.append(PSSE_LOCATION)
os.environ['PATH'] = os.environ['PATH'] + PSSE_LOCATION +';'
import psspy from psspy import _i,_f, _s

The code would not run without this importing. The main code did not need to import it, but the boilerplate did.

So, importing a custom Python file works just fine, just make sure to import psspy in the custom file and close and reopen PSSE after changing code in the custom file so it can recompile.

EDIT

After reading through the docs some more, an easier version of the code above is:

import psse34
import psspy
from psspy import _i, _f, _s
2022-06-29 13:46:46 -0500 commented answer [SOLVED] Import custom Python file

So, my old error has gone away, I'm not sure what I changed, but you are probably right with printing "sys.path" to see if there is an error. The path did include my working directory, I wish I could have done that yesterday. Now it's saying "_i" is not defined, I'll update the post.

2022-06-29 12:50:52 -0500 received badge  Famous Question (source)
2022-06-29 07:27:55 -0500 received badge  Notable Question (source)
2022-06-29 07:27:55 -0500 received badge  Popular Question (source)
2022-06-28 11:42:14 -0500 received badge  Editor (source)
2022-06-28 11:41:59 -0500 asked a question [SOLVED] Import custom Python file

I am writing lots of scripts and keep using the same functions in each script so I wanted to write a separate boilerplate Python file to store those functions and import them into my main file. This works perfectly when I am running the script outside of PSSE, but breaks when I run it in PSSE. It gives me the error NameError: global name 'psspy' is not defined. I know this error is in the boilerplate file and not the main file because the main file runs psspy.case successfully.

I have tried all four combinations of importing and not importing psspy in the main and boilerplate file with the code:

PSSE_LOCATION = os.path.join('C:', os.sep, 'Program Files (x86)', 'PTI', 'PSSE34', 'PSSPY27')
sys.path.append(PSSE_LOCATION)
os.environ['PATH'] = os.environ['PATH'] + PSSE_LOCATION + ';'
import psspy

I have viewed the question "How to import a custom Python module in PSSE?" (I can't link it as I don't have enough karma), however, their problem was the module not importing correctly. The boilerplate module imports just fine, but it can't access psspy when running in PSSE.

Am I going about importing custom Python files incorrectly?

I am running PSSE 34 and Python 2.7.