First time here? We are a friendly community of Power Systems Engineers. Check out the FAQ!
1 | initial version |
I've been following an example from the PSSE "Program Application Guide" to run a dynamic simulation where a fault is initialized and cleared.
I now want to do similar simulations from Python not PSSE, but I can't figure out how to do it.
The example goes as follows:
I have very limited knowledge about both PSSE and Python, so any tips and tricks (best practice) would be most welcome!
What is the correct way of creating faults? The equivalent of ALTR in PSSE? How can I plot the results afterwards? (Choose channels etc. etc.)
The (unfinished) code I have now is included below. It's plain to see that it's no good, but I don't what the correct way to do it is. Also, I don't know how to check if it works (besides noting that I don't get errors).
import os,sys
PYTHONPATH = r'C:\Program Files (x86)\PTI\PSSE32\PSSBIN'
MODELFOLDER = r'C:\Program Files (x86)\PTI\PSSE32\MODELDRW'
sys.path.append(PYTHONPATH)
os.environ['PATH'] += ';' + PYTHONPATH
## Numpy of matplotlib maa lastes ned for aa brukes:
## http://www.whit.com.au/blog/python-libraries-for-psse-python-training/
# import numpy as np
# import matplotlib.pyplot as plt
import psspy
import redirect
import dyntools
# Redirect output from PSSE to Python:
redirect.psse2py()
# Last case:
CASE = r"C:\Program Files (x86)\PTI\PSSE32\EXAMPLE\savnw.sav"
psspy.psseinit(12000)
psspy.case(CASE)
ierr = psspy.dyre_add(dyrefile="C:\Program Files (x86)\PTI\PSSE32\EXAMPLE\savnw.dyr")
ierr = psspy.rstr("C:\Program Files (x86)\PTI\PSSE32\EXAMPLE\savnw.snp")
# Convert generators:
ierr = psspy.cong()
# Convert loads:
ierr, rlods = psspy.conl(all=1,apiopt=2, status1=0, loadin1=100,loadin2=0, loadin3 = 0, loadin4 = 100)
ierr = psspy.fact()
ierr = psspy.strt(outfile="C:\Program Files (x86)\PTI\PSSE32\EXAMPLE\python_test.out")
2 | No.2 Revision |
I've been following an example from the PSSE "Program Application Guide" to run a dynamic simulation where a fault is initialized and cleared.
I now want to do similar simulations from Python not PSSE, but I can't figure out how to do it.
The example goes as follows:
I have very limited knowledge about both PSSE and Python, so any tips and tricks (best practice) would be most welcome!
What is the correct way of creating faults? The equivalent of ALTR in PSSE? How can I plot the results afterwards? (Choose channels etc. etc.)
The (unfinished) code I have now is included below. It's plain to see that it's no good, but I don't what the correct way to do it is. Also, I don't know how to check if it works (besides noting that I don't get errors).
import os,sys
PYTHONPATH = r'C:\Program Files (x86)\PTI\PSSE32\PSSBIN'
MODELFOLDER = r'C:\Program Files (x86)\PTI\PSSE32\MODELDRW'
sys.path.append(PYTHONPATH)
os.environ['PATH'] += ';' + PYTHONPATH
## Numpy of matplotlib maa lastes ned for aa brukes:
## http://www.whit.com.au/blog/python-libraries-for-psse-python-training/
# import numpy as np
# import matplotlib.pyplot as plt
import psspy
import redirect
import dyntools
# Redirect output from PSSE to Python:
redirect.psse2py()
# Last case:
CASE = r"C:\Program Files (x86)\PTI\PSSE32\EXAMPLE\savnw.sav"
psspy.psseinit(12000)
psspy.case(CASE)
ierr = psspy.dyre_add(dyrefile="C:\Program Files (x86)\PTI\PSSE32\EXAMPLE\savnw.dyr")
ierr = psspy.rstr("C:\Program Files (x86)\PTI\PSSE32\EXAMPLE\savnw.snp")
# Convert generators:
ierr = psspy.cong()
# Convert loads:
ierr, rlods = psspy.conl(all=1,apiopt=2, status1=0, loadin1=100,loadin2=0, loadin3 = 0, loadin4 = 100)
ierr = psspy.fact()
ierr = psspy.strt(outfile="C:\Program Files (x86)\PTI\PSSE32\EXAMPLE\python_test.out")
Btw, the complete path name is written, because it can't find the files if I don't.