Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I have never used the dyntools toolbox before, but here is an example of how to do a simulation like your example. You were on the right track, but missing a few steps.

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

import psspy
import redirect

# 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)

# 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()

# Add dynamics data
psspy.dyre_new(dyrefile="C:\Program Files (x86)\PTI\PSSE32\EXAMPLE\savnw.dyr")

# Add channels by subsystem
#   BUS VOLTAGE
psspy.chsb(sid=0,all=1, status=[-1,-1,-1,1,13,0])
#   MACHINE SPEED
psspy.chsb(sid=0,all=1, status=[-1,-1,-1,1,7,0])

# Add channels individually
#   BRANCH MVA
psspy.branch_mva_channel([-1,-1,-1,3001,3002],'1')

# 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=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 to 3 cycles
time = 3/60
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 = 20
psspy.run(tpause=time)

#-----------------------------

# Run 2nd fault if you want
psspy.rstr(sfile="C:\Program Files (x86)\PTI\PSSE32\EXAMPLE\python_test.snp")

# Initialize
psspy.strt(outfile="C:\Program Files (x86)\PTI\PSSE32\EXAMPLE\python_test_2.out")
psspy.run(tpause=0)

# 1-phase fault branch 3001 to 3003
psspy.dist_branch_fault(ibus=3001, jbus=3003, id='1',units=1,values=[352,-2389])

# Run to 4 cycles
time = 4/60
psspy.run(tpause=time)

# Clear fault
psspy.dist_clear_fault()
psspy.dist_branch_trip(ibus=3001, jbus=3003, id='1')

# Run to 20 seconds
time = 20
psspy.run(tpause=time)


# Halt
psspy.pssehalt_2()

Hopefully that is enough to get you started. There is so much more you can do and this is a pretty basic example and doesn't cover adding any user dynamic model. I suggest poking around the API manual in Chapter 4 to see what is available dynamics wise and also the POM to see what these functions do.

I have never used the dyntools toolbox before, but here is an example of how to do a simulation like your example. example using just the functions in the standard psspy API. You were on the right track, but missing a few steps.

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

import psspy
import redirect

# 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)

# 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()

# Add dynamics data
psspy.dyre_new(dyrefile="C:\Program Files (x86)\PTI\PSSE32\EXAMPLE\savnw.dyr")

# Add channels by subsystem
#   BUS VOLTAGE
psspy.chsb(sid=0,all=1, status=[-1,-1,-1,1,13,0])
#   MACHINE SPEED
psspy.chsb(sid=0,all=1, status=[-1,-1,-1,1,7,0])

# Add channels individually
#   BRANCH MVA
psspy.branch_mva_channel([-1,-1,-1,3001,3002],'1')

# 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=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 to 3 cycles
time = 3/60
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 = 20
psspy.run(tpause=time)

#-----------------------------

# Run 2nd fault if you want
psspy.rstr(sfile="C:\Program Files (x86)\PTI\PSSE32\EXAMPLE\python_test.snp")

# Initialize
psspy.strt(outfile="C:\Program Files (x86)\PTI\PSSE32\EXAMPLE\python_test_2.out")
psspy.run(tpause=0)

# 1-phase fault branch 3001 to 3003
psspy.dist_branch_fault(ibus=3001, jbus=3003, id='1',units=1,values=[352,-2389])

# Run to 4 cycles
time = 4/60
psspy.run(tpause=time)

# Clear fault
psspy.dist_clear_fault()
psspy.dist_branch_trip(ibus=3001, jbus=3003, id='1')

# Run to 20 seconds
time = 20
psspy.run(tpause=time)


# Halt
psspy.pssehalt_2()

Hopefully that is enough to get you started. There is so much more you can do and this is a pretty basic example and doesn't cover adding any user dynamic model. I suggest poking around the API manual in Chapter 4 to see what is available dynamics wise and also the POM to see what these functions do.

click to hide/show revision 3
Added code to save case after conversion

I have never used the dyntools toolbox before, but here is an example of how to do a simulation like your example using just the functions in the standard psspy API. You were on the right track, but missing a few steps.

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

import psspy
import redirect

# 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)

# 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(sys.argv[1])[0]
psspy.save(case_root + "_C.sav")

# Add dynamics data
psspy.dyre_new(dyrefile="C:\Program Files (x86)\PTI\PSSE32\EXAMPLE\savnw.dyr")

# Add channels by subsystem
#   BUS VOLTAGE
psspy.chsb(sid=0,all=1, status=[-1,-1,-1,1,13,0])
#   MACHINE SPEED
psspy.chsb(sid=0,all=1, status=[-1,-1,-1,1,7,0])

# Add channels individually
#   BRANCH MVA
psspy.branch_mva_channel([-1,-1,-1,3001,3002],'1')

# 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=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 to 3 cycles
time = 3/60
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 = 20
psspy.run(tpause=time)

#-----------------------------

# Run 2nd fault if you want
psspy.open(case_root + "_C.sav")
psspy.rstr(sfile="C:\Program Files (x86)\PTI\PSSE32\EXAMPLE\python_test.snp")

# Initialize
psspy.strt(outfile="C:\Program Files (x86)\PTI\PSSE32\EXAMPLE\python_test_2.out")
psspy.run(tpause=0)

# 1-phase fault branch 3001 to 3003
psspy.dist_branch_fault(ibus=3001, jbus=3003, id='1',units=1,values=[352,-2389])

# Run to 4 cycles
time = 4/60
psspy.run(tpause=time)

# Clear fault
psspy.dist_clear_fault()
psspy.dist_branch_trip(ibus=3001, jbus=3003, id='1')

# Run to 20 seconds
time = 20
psspy.run(tpause=time)


# Halt
psspy.pssehalt_2()

Hopefully that is enough to get you started. There is so much more you can do and this is a pretty basic example and doesn't cover adding any user dynamic model. I suggest poking around the API manual in Chapter 4 to see what is available dynamics wise and also the POM to see what these functions do.

I have never used the dyntools toolbox before, but here is an example of how to do a simulation like your example using just the functions in the standard psspy API. You were on the right track, but missing a few steps.

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

import psspy
import redirect

# 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)

# 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(sys.argv[1])[0]
psspy.save(case_root + "_C.sav")

# Add dynamics data
psspy.dyre_new(dyrefile="C:\Program Files (x86)\PTI\PSSE32\EXAMPLE\savnw.dyr")

# Add channels by subsystem
#   BUS VOLTAGE
psspy.chsb(sid=0,all=1, status=[-1,-1,-1,1,13,0])
#   MACHINE SPEED
psspy.chsb(sid=0,all=1, status=[-1,-1,-1,1,7,0])

# Add channels individually
#   BRANCH MVA
psspy.branch_mva_channel([-1,-1,-1,3001,3002],'1')

# 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=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 to 3 cycles
time = 3/60
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 = 20
psspy.run(tpause=time)

#-----------------------------

# Run 2nd fault if you want
psspy.open(case_root psspy.case(case_root + "_C.sav")
psspy.rstr(sfile="C:\Program Files (x86)\PTI\PSSE32\EXAMPLE\python_test.snp")

# Initialize
psspy.strt(outfile="C:\Program Files (x86)\PTI\PSSE32\EXAMPLE\python_test_2.out")
psspy.run(tpause=0)

# 1-phase fault branch 3001 to 3003
psspy.dist_branch_fault(ibus=3001, jbus=3003, id='1',units=1,values=[352,-2389])

# Run to 4 cycles
time = 4/60
psspy.run(tpause=time)

# Clear fault
psspy.dist_clear_fault()
psspy.dist_branch_trip(ibus=3001, jbus=3003, id='1')

# Run to 20 seconds
time = 20
psspy.run(tpause=time)


# Halt
psspy.pssehalt_2()

Hopefully that is enough to get you started. There is so much more you can do and this is a pretty basic example and doesn't cover adding any user dynamic model. I suggest poking around the API manual in Chapter 4 to see what is available dynamics wise and also the POM to see what these functions do.

I have never used the dyntools toolbox before, but here is an example of how to do a simulation like your example using just the functions in the standard psspy API. You were on the right track, but missing a few steps.

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

import psspy
import redirect

# 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)

# 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(sys.argv[1])[0]
os.path.splitext(CASE)[0]
psspy.save(case_root + "_C.sav")

# Add dynamics data
psspy.dyre_new(dyrefile="C:\Program Files (x86)\PTI\PSSE32\EXAMPLE\savnw.dyr")

# Add channels by subsystem
#   BUS VOLTAGE
psspy.chsb(sid=0,all=1, status=[-1,-1,-1,1,13,0])
#   MACHINE SPEED
psspy.chsb(sid=0,all=1, status=[-1,-1,-1,1,7,0])

# Add channels individually
#   BRANCH MVA
psspy.branch_mva_channel([-1,-1,-1,3001,3002],'1')

# 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=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 to 3 cycles
time = 3/60
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 = 20
psspy.run(tpause=time)

#-----------------------------

# Run 2nd fault if you want
psspy.case(case_root + "_C.sav")
psspy.rstr(sfile="C:\Program Files (x86)\PTI\PSSE32\EXAMPLE\python_test.snp")

# Initialize
psspy.strt(outfile="C:\Program Files (x86)\PTI\PSSE32\EXAMPLE\python_test_2.out")
psspy.run(tpause=0)

# 1-phase fault branch 3001 to 3003
psspy.dist_branch_fault(ibus=3001, jbus=3003, id='1',units=1,values=[352,-2389])

# Run to 4 cycles
time = 4/60
psspy.run(tpause=time)

# Clear fault
psspy.dist_clear_fault()
psspy.dist_branch_trip(ibus=3001, jbus=3003, id='1')

# Run to 20 seconds
time = 20
psspy.run(tpause=time)


# Halt
psspy.pssehalt_2()

Hopefully that is enough to get you started. There is so much more you can do and this is a pretty basic example and doesn't cover adding any user dynamic model. I suggest poking around the API manual in Chapter 4 to see what is available dynamics wise and also the POM to see what these functions do.

I have never used the dyntools toolbox before, but here is an example of how to do a simulation like your example using just the functions in the standard psspy API. You were on the right track, but missing a few steps.

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

import psspy
import redirect

# 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)

# 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\PSSE32\EXAMPLE\savnw.dyr")

# Add channels by subsystem
#   BUS VOLTAGE
psspy.chsb(sid=0,all=1, status=[-1,-1,-1,1,13,0])
#   MACHINE SPEED
psspy.chsb(sid=0,all=1, status=[-1,-1,-1,1,7,0])

# Add channels individually
#   BRANCH MVA
psspy.branch_mva_channel([-1,-1,-1,3001,3002],'1')

# 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=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 to 3 cycles
time = 3/60
3.0/60.0
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 = 20
psspy.run(tpause=time)

#-----------------------------

# Run 2nd fault if you want
psspy.case(case_root + "_C.sav")
psspy.rstr(sfile="C:\Program Files (x86)\PTI\PSSE32\EXAMPLE\python_test.snp")

# Initialize
psspy.strt(outfile="C:\Program Files (x86)\PTI\PSSE32\EXAMPLE\python_test_2.out")
psspy.run(tpause=0)

# 1-phase fault branch 3001 to 3003
psspy.dist_branch_fault(ibus=3001, jbus=3003, id='1',units=1,values=[352,-2389])

# Run to 4 cycles
time = 4/60
4.0/60.0
psspy.run(tpause=time)

# Clear fault
psspy.dist_clear_fault()
psspy.dist_branch_trip(ibus=3001, jbus=3003, id='1')

# Run to 20 seconds
time = 20
psspy.run(tpause=time)


# Halt
psspy.pssehalt_2()

Hopefully that is enough to get you started. There is so much more you can do and this is a pretty basic example and doesn't cover adding any user dynamic model. I suggest poking around the API manual in Chapter 4 to see what is available dynamics wise and also the POM to see what these functions do.