Error running PSSE from Python
I'm new to PSS/E. And I want to run dynamic simulation in PSS/E. But encounter some problems when running PSS/E from python/. Here's the error from PSS/E when I try to open .py file in PSS/E:
Traceback (most recent call last): File "C:\Users\Cynthia\Desktop\0312.py", line 11, in <module> redirect.psse2py() File ".\redirect.py", line 147, in psse2py redirect.RedirectError: Python currently sending output to Psse Couldn't open Python file:C:\Users\Cynthia\Desktop\0312.py
And here's my code:
import os,sys
PYTHONPATH = r'C:\Program Files (x86)\PTI\PSSEXplore34\PSSPY27'
sys.path.append(PYTHONPATH)
os.environ['PATH'] += ';' + PYTHONPATH
import psspy
import redirect
# Redirect output from PSSE to Python:
redirect.psse2py()
# Last case:
CASE = r"C:\Program Files (x86)\PTI\PSSEXplore34\EXAMPLE\savnw.sav"
psspy.psseinit(12000)
psspy.case(CASE)
# Convert loads (3 step process):
psspy.conl(-1,1,1)
psspy.conl(-1,1,2,[0,0],[100,0,0,100])
psspy.conl(-1,1,3)
# Convert generators:
psspy.cong()
# Solve for dynamics
psspy.ordr()
psspy.fact()
psspy.tysl()
# Save converted case
case_root = os.path.splitext(CASE)[0]
psspy.save(case_root + "_C.sav")
# Add dynamics data
psspy.dyre_new(dyrefile="C:\Program Files (x86)\PTI\PSSEXplore34\EXAMPLE\savnw.dyr")
# Add channels by subsystem
# BUS VOLTAGE
psspy.chsb(sid=0,all=1, status=[-1,-1,-1,1,13,0])
# Save snapshot
psspy.snap(sfile="C:\Program Files (x86)\PTI\PSSE32\EXAMPLE\python_test.snp")
# Initialize
psspy.strt(outfile="C:\Program Files (x86)\PTI\PSSE32\EXAMPLE\python_test_1.out")
psspy.run(tpause=1)
# 3-phase fault on bus 201 (default bus fault is a 3phase and there is no bus 200)
psspy.dist_bus_fault(ibus=201)
# Run to 3 cycles
time = 3.0/60.0 + 1
psspy.run(tpause=time)
# Clear fault (assuming only part of bus faults)
psspy.dist_clear_fault()
psspy.dist_branch_trip(ibus=201, jbus=151, id='1')
# Run to 20 seconds
time = 10
Thanks a lot for your help!!!