Ask Your Question
1

How to use Python do such a simulation on PSSE?

asked 2013-09-07 06:02:55 -0500

Bob gravatar image

New England 39-bus System ;five generator outages (at generator buses 32 35 37 38 and 39) and for different network poplolgier(full topology and topologier with lines 4-5, 21-22, 26-27 out of serbice).Therefore there are about 340 different simulations.

Now I want to do these simulations use Python Script (not on PSS/E,but Python command psse).

How can I write the Python Script? May use bat command ? I have very limited knowledge about both PSSE and Python, so any tips and tricks (best practice) would be most welcome!

edit retag flag offensive close merge delete

Comments

1

Hi Bob, is this for a project at university?

JervisW gravatar imageJervisW ( 2013-09-11 00:45:29 -0500 )edit

Is this just powerflow, or is it dynamics?

EBahr gravatar imageEBahr ( 2013-09-12 12:09:57 -0500 )edit

Yes,this is just a project at university,please help me , thank you!

Bob gravatar imageBob ( 2013-09-18 23:29:43 -0500 )edit

dynamics dynamic simulation

Bob gravatar imageBob ( 2013-09-18 23:30:32 -0500 )edit

1 answer

Sort by » oldest newest most voted
2

answered 2013-09-24 09:48:43 -0500

EBahr gravatar image

If I were you, I would first take all the N-1 line outages in powerflow and make sure they are good to go (ie; solve correctly and not blown up), then save them as individual cases and put them all in the same folder. Then create some code similar to this: https://psspy.org/psse-help-forum/que..., but wrap most of it up in a for loop that changes the case each loop. ie;

import os,sys
import glob
import psspy
import redirect
PYTHONPATH = r'C:\Program Files (x86)\PTI\PSSE32\PSSBIN'

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

#Modify GENERATORS to include generators you want to trip in form of [[BUS #, 'GEN_ID'],[BUS #, 'GEN_ID']....]
GENERATORS = [[32,'1'],[35,'1'],[37,'1'],[38,'1'],[39,'1']] #GEN_ID might not be correct here...

# Redirect output from PSSE to Python:
redirect.psse2py()

# Loop through cases
for CASE in glob.glob(os.path.join('C:\\YOUR\\DIRECTORY\\', '*.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:\\YOUR\\DIRECTORY\\YOUR_DYRE.DYR")

    # Add channels
    #ADD CHANNEL CODE HERE IF YOU NEED IT

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

    #Loop through outages
    for gen in GENERATORS:    
        # Re-load case
        psspy.open(case_root + "_C.sav")
        psspy.rstr(sfile=case_root + ".snp")

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

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

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

# Halt
psspy.pssehalt_2()

I haven't tested that code, but it should hopefully be something close to what you are looking for.

edit flag offensive delete link more

Comments

great! Thanks

Bob gravatar imageBob ( 2013-09-24 09:49:54 -0500 )edit

I like the use of `glob` in your code.

JervisW gravatar imageJervisW ( 2013-09-28 02:42:00 -0500 )edit

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

Stats

Asked: 2013-09-07 06:02:55 -0500

Seen: 2,086 times

Last updated: Sep 24 '13