First time here? We are a friendly community of Power Systems Engineers. Check out the FAQ!

Ask Your Question
1

How to use Python do such a simulation on PSSE?

asked Sep 7 '13

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!

Comments

1

Hi Bob, is this for a project at university?

JervisW gravatar imageJervisW (Sep 11 '13)

Is this just powerflow, or is it dynamics?

EBahr gravatar imageEBahr (Sep 12 '13)

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

Bob gravatar imageBob (Sep 19 '13)

dynamics dynamic simulation

Bob gravatar imageBob (Sep 19 '13)

1 answer

Sort by » oldest newest most voted
2

answered Sep 24 '13

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.

link

Comments

great! Thanks

Bob gravatar imageBob (Sep 24 '13)

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

JervisW gravatar imageJervisW (Sep 28 '13)

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.
Want to format code in your answer? Here is a one minute demo on Youtube

Add Answer

[hide preview]

Question Tools

Stats

Asked: Sep 7 '13

Seen: 5,138 times

Last updated: Sep 24 '13