First time here? We are a friendly community of Power Systems Engineers. Check out the FAQ!
1 | initial version |
When running from PSSe GUI, PSSe send output to its GUI and python sends output to the PSSe GUI by default, so there is no need to redirect to 'python'. Your error fits this scenario. When running outside the PSSe GUI (within a DOS window, using line command) then you can send PSSe output to python using the redirect module. A little modified version of your code set to run outside the PSSe GUI (adjust path as needed) follows:
import os, sys
PYPATH = r'C:\Program Files (x86)\PTI\PSSE34\PSSPY27'
sys.path.append(PYPATH)
os.environ['PATH'] += ';' + PYPATH
import psspy
psspy.psseinit(12000)
import redirect
# Redirect output from PSSE to Python:
redirect.psse2py()
CASE = r'''C:\\Program Files (x86)\\PTI\\PSSE34\\EXAMPLE\\savnw.sav'''
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\\PSSE34\\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="test.snp")
# Initialize
psspy.strt(outfile="test.out")
simtime = 1
#psspy.run(tpause=simtime)
psspy.run(0,simtime,99,19,0)
# 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 under fault for 3 cycles
simtime += 3.0/60.0
#psspy.run(tpause=simtime)
psspy.run(0,simtime,99,3,0)
# 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
simtime = 5
#psspy.run(tpause=simtime)
psspy.run(0,simtime,99,9,0)
2 | No.2 Revision |
When running from PSSe GUI, PSSe send output to its GUI and python sends output to the PSSe GUI by default, so there is no need to redirect to 'python'. Your error fits this scenario.
When running outside the PSSe GUI (within a DOS window, using line command) then you can send PSSe output to python using the redirect module. A little modified version of your code set to run outside the PSSe GUI (adjust path as needed) follows: follows [to run in PSSe GUI comment lines 3 to 11]:
import os, sys
PYPATH = r'C:\Program Files (x86)\PTI\PSSE34\PSSPY27'
sys.path.append(PYPATH)
os.environ['PATH'] += ';' + PYPATH
import psspy
psspy.psseinit(12000)
import redirect
# Redirect output from PSSE to Python:
redirect.psse2py()
CASE = r'''C:\\Program Files (x86)\\PTI\\PSSE34\\EXAMPLE\\savnw.sav'''
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\\PSSE34\\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="test.snp")
# Initialize
psspy.strt(outfile="test.out")
simtime = 1
#psspy.run(tpause=simtime)
psspy.run(0,simtime,99,19,0)
# 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 under fault for 3 cycles
simtime += 3.0/60.0
#psspy.run(tpause=simtime)
psspy.run(0,simtime,99,3,0)
# 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
simtime = 5
#psspy.run(tpause=simtime)
psspy.run(0,simtime,99,9,0)