Ask Your Question
0

BESS dynamic simulation through python script

asked 2023-08-02 04:52:58 -0500

Zhnoob gravatar image

updated 2023-08-03 05:21:34 -0500

Hello everyone, I want to build a small system with BESS, and change the active power output from BESS by adding Paux in the REECCU model then test the dynamic simulation, so I have tried the model "BESSjconto20230613" in the post "Example .dyr data for BESS" provide by jconto, so I have some question at this moment as bellow:

  1. I know how to run the dynamic simulation through GUI, but not really sure how to use the python script from jconto, when I use the CLI at bellow and choose python to import "SMIB_BESS.py", the error is as follow:

Traceback (most recent call last):

File "<string>", line 1, in <module>

File "SMIB_BESS.py", line 9, in <module>

_i = psspy.getdefaultint()

NameError: name 'psspy' is not defined

Even after import os, sys will get the same error, but _i = psspy.getdefaultint() means it did read the script, right? And psspy is no need to import through GUI, so I am confused. (My PSS/E is v.34)

My print sys.path :

['', 'C:\\Program Files (x86)\\PTI\\PSSE34\\PSSPYTHON27', 'C:\\Program Files (x86)\\PTI\\PSSE34\\PSSPY27', 'C:\\WINDOWS\\SYSTEM32\\python27.zip', 'C:\\Python27\\Lib', 'C:\\Python27\\DLLs', 'C:\\Python27\\Lib\\lib-tk', 'C:\\Users\\POWER\\Documents\\PTI\\PSSE34', 'C:\\Program Files (x86)\\PTI\\PSSE34\\PSSBIN', 'C:\\Python27', 'C:\\Python27\\lib\\site-packages', 'C:\\Python27\\lib\\site-packages\\psse_env_manager', 'C:\\Python27\\lib\\site-packages\\win32', 'C:\\Python27\\lib\\site-packages\\win32\\lib', 'C:\\Python27\\lib\\site-packages\\Pythonwin', 'C:\\Python27\\lib\\site-packages\\wx-3.0-msw']

2.Will it be better to do it by python, not through GUI, if I want to change Paux constantly in VAR(L) of REECCU model

I am new to PSS/E and python, but any suggestion will be much appreciate!


Thanks for the reply, I have tried the method you mentioned. (Changing the directory to the working folder and and also copied the two files is done).

Is the python27 folder needed, when execute the python script? Or the code as follow is viable?

C:\..>python SMIB_BESS.py

Because to execute by python in cmd is like >python filename.py

After changing this, I didn't get any return from cmd or PSSe, but if I type

C:\..>SMIB_BESS.py

it will return:

import redirect

ImportError: No module named redirect

Thanks!

edit retag flag offensive close merge delete

Comments

To run it outside the GUI add the following 3 lines of code after "import os,sys" [See my edited answer below]: import psse34; import psspy; psspy.psseinit()

jconto gravatar imagejconto ( 2023-08-03 08:23:14 -0500 )edit

Thanks! I can get all the result now, your instruction helps a lot.

Zhnoob gravatar imageZhnoob ( 2023-08-04 04:36:27 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2023-08-02 18:19:47 -0500

jconto gravatar image

updated 2023-08-03 08:26:56 -0500

Since the setup is for PSSe v.34 and python 2.7, to run a PSSe python script outside the GUI:

-Locate the "PSSE 34 Command Prompt" link (in the Desktop?) to open a DOS windows (a.k.a. CMD command prompt)
- Double click such link to open a DOS window
- To change directory to the working folder if needed, in the DOS box type:
  C:\..>cd "working_folder_full_path"
- execute the python script as:
  c:\..>python27\python SMIB_BESS.py

if the 'psspy' error persist:

- From PSSE34 installation folder C:\Program Files (x86)\PTI\PSSE34\PSSPY27, copy following two files:
psse34.py
psseloc.pyc
to Python 27 installation folder C:\Python27\Lib\site-packages

and on the DOS box, execute the python script again.

The code SMIB_BESS.py was a quick test to be run inside the GUI:

# SMIB_test.py - run this script from PSSe GUI
import os, sys
# -------------------------------------------------------------------------
# INITIALIZE PSSE
import redirect
redirect.py2psse()

To run it outside the GUI add the following three lines of code after "import os,sys":

import psse34
import psspy
psspy.psseinit()

Q2.Will it be better to do it by python, not through GUI, if I want to change Paux constantly in VAR(L) of REECCU model

Yes python will allow to vary values for a given model parameter within a loop run.

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: 2023-08-02 04:52:58 -0500

Seen: 475 times

Last updated: Aug 03 '23