BESS dynamic simulation through python script
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:
- 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!
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()
Thanks! I can get all the result now, your instruction helps a lot.