Ask Your Question
0

psse python automatic machine outage

asked 2020-05-05 21:50:34 -0500

asd111333555777 gravatar image

updated 2020-05-06 10:11:03 -0500

jconto gravatar image

Hello everyone, I am now doing a simulation using psse python automatic turn-off machine, but encountered some problems,I am using the IEEE39 data

Cut off the generator to simulate the system power shortage, by the same load level, each cut off 1 generator (30,31,32, ... , 39) , a total of 10

At 50.25% , 50.5% , ... , 100% total 200 different rated load levels, rotating cutting machine, hoping to get 2000 groups of simulation samples

When the simulation condition is set to 0s, the cutting machine fault is 60s in simulation market

And I met some problems: 1、The simulation time seems too long, about 5 days. And the reason is that the programe write the data from scratch each time. 2、The 31 bus generator data seems wrong

edit retag flag offensive close merge delete

2 answers

Sort by » oldest newest most voted
0

answered 2020-05-06 10:09:40 -0500

jconto gravatar image

The code flow is good. I re-arranged it, set it for one case run, runtime to 5 sec for testing and added a log file as well as change the integration step back to 1/4 of a cycle, recommended for more power system studies. This version run OK in v.33:

# -- coding:utf-8 --

import os,sys 
import glob

PYTHONPATH = r'C:\Program Files (x86)\PTI\PSSE33\PSSBIN'

sys.path.append(PYTHONPATH) 
os.environ['PATH'] += ';' + PYTHONPATH 
import redirect 
import psspy

psspy.psseinit(12000) 
_i, _f = psspy.getbatdefaults()
#Redirect output from PSSE to Python:
redirect.psse2py()

GENERATORS = [[30,'1'],[31,'1'],[32,'1'],[33,'1'],[34,'1'],[35,'1'],[36,'1'],[37,'1'],[38,'1'],[39,'1']] 

#Loop through cases
#for CASEi in glob.glob(os.path.join('C:\Users\Desktop\IEEE39_new\sav\', '*.sav')): 
for k in range(1):
    CASEi = 'IEEE39_v33.sav'
    psspy.case(CASEi)

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

    # Add dynamics data
    #psspy.dyre_new(dyrefile="C:\Users\Desktop\\IEEE39_new\\IEEE39.dyr")
    psspy.dyre_new(dyrefile="IEEE39.dyr")

    # Add channels
    psspy.chsb(0,1,[-1,-1,-1,1,7,1])

    # Save snapshot
    psspy.snap(sfile=case_root + ".snp")

    #Loop through outages
    for gen in GENERATORS:
        study = case_root + "_SIM_%d_%s" % (gen[0],gen[1])
        sys.stdout = open(study+'.log','w') # redirect all prints to this log file

        # Re-load case
        psspy.case(case_root + "_C.sav")
        psspy.rstr(sfile=case_root + ".snp")
        #psspy.dynamics_solution_params([_i,_i,_i,_i,_i,_i,_i,_i],[_f,_f, 0.02,_f,_f,_f,_f,_f],"")
        psspy.dynamics_solution_params([_i,_i,_i,_i,_i,_i,_i,_i],[_f,_f,0.004,0.016,_f,_f,_f,_f],"")

        # Initialize
        psspy.strt(outfile=study+'.out')
        psspy.run(tpause=0)
        psspy.run(tpause=1)

        # Disconnect generator
        ierr = psspy.dist_machine_trip(gen[0],gen[1])

        # Run to 60 seconds
        time = 5
        psspy.run(tpause=time)
#Halt
psspy.pssehalt_2()
edit flag offensive delete link more
0

answered 2020-05-05 21:51:40 -0500

asd111333555777 gravatar image

updated 2020-05-06 10:04:25 -0500

jconto gravatar image
# -*- coding:utf-8 -*-  
import os,sys
import glob

PYTHONPATH = r'C:\Program Files (x86)\PTI\PSSE31\PSSBIN'

sys.path.append(PYTHONPATH)
os.environ['PATH'] += ';' + PYTHONPATH
import redirect
import psspy

GENERATORS = [[30,'1'],[31,'1'],[32,'1'],[33,'1'],[34,'1'],[35,'1'],[36,'1'],[37,'1'],[38,'1'],[39,'1']] 
_i, _f = psspy.getbatdefaults()
# Redirect output from PSSE to Python:
redirect.psse2py()

# Loop through cases
for CASE in glob.glob(os.path.join('C:\Users\Desktop\IEEE39_new\\sav\\', '*.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[0])[0]
psspy.save(case_root + "_C.sav")

# Add dynamics data
psspy.dyre_new(dyrefile="C:\Users\Desktop\\IEEE39_new\\IEEE39.dyr")

# Add channels
psspy.chsb(0,1,[-1,-1,-1,1,7,1])

# Save snapshot
psspy.snap(sfile=case_root + ".snp")

#Loop through outages
for gen in GENERATORS:    
    # Re-load case
    psspy.case(case_root + "_C.sav")
    psspy.rstr(sfile=case_root + ".snp")
    psspy.dynamics_solution_params([_i,_i,_i,_i,_i,_i,_i,_i],[_f,_f, 0.02,_f,_f,_f,_f,_f],"")

    # Initialize
    psspy.strt(outfile=case_root + "_SIM_%d_%s.out" % (gen[0],gen[1]))
    psspy.run(tpause=0)

    # Disconnect generator
    ierr = psspy.dist_machine_trip(gen[0],gen[1])

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

# Halt
psspy.pssehalt_2()

This is my python code

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Question Tools

1 follower

Stats

Asked: 2020-05-05 21:50:34 -0500

Seen: 67 times

Last updated: May 06