Ask Your Question

Mus's profile - activity

2019-08-15 23:30:51 -0500 received badge  Taxonomist
2015-12-20 22:18:58 -0500 received badge  Famous Question (source)
2015-12-14 02:25:06 -0500 received badge  Notable Question (source)
2015-12-13 09:16:43 -0500 received badge  Popular Question (source)
2015-12-12 03:27:41 -0500 asked a question HOW TO CALCULATE FVSI FROM DYNAMIC SIMULATION

Hello Everyone,

i want a code to perform dynamic simulation and calculate FVSI later ... to achieve that i had compile some codes got it from here, but i stuck to complete the code. can you please help me to complete it ..

Much Thanks

*#identify system office and tools function.
import os
import sys
import glob

#To idntifty where is psse file inside the computer files
PSSE_PATH = r'C:\Program Files (x86)\PTI\PSSEUniversity33\PSSBIN'
#Telling python where to find psse 
sys.path.append(PSSE_PATH)
#settle the enviorment file
os.environ['PATH'] += ';' + PSSE_PATH

#PSSE INITIALIZATION
import psspy
import redirect
redirect.psse2py()
psspy.psseinit()

# RUN POWER FLOW CASE 
bussystem= r"""C:\Users\user\Desktop\IT\FYP2\Dynamic\shortcourse5bussytem\TEST1.sav"""
psspy.case(bussystem)
#solve powerflow
psspy.fdns([0,0,0,1,1,0,99,0])

# 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:\Users\user\Desktop\IT\FYP2\Dynamic\shortcourse5bussytem\daynmictest.dyr")

# Add channels by subsystem
#   BUS VOLTAGE
psspy.chsb(sid=0,all=1, status=[-1,-1,-1,1,13,0])
#   BUS ANGLE
psspy.chsb(sid=0,all=1, status=[-1,-1,-1,1,1,0])
#   BUS P&Q
psspy.chsb(sid=0,all=1, status=[-1,-1,-1,1,16,0])

# Save snapshot
psspy.snap(sfile="C:\Users\user\Desktop\IT\FYP2\Dynamic\shortcourse5bussytem\daynmictest.snp")

# Initialize + RUN DYN FOR 1 SND
psspy.strt(outfile="C:\Users\user\Desktop\IT\FYP2\Dynamic\shortcourse5bussytem\daynmictest.out")
psspy.run(tpause=1)


####APPLYING BUS FAULT
####PRE FAULT CONDITION + CUREATING FAULT
###3-phase fault on bus 100 (default bus fault is a 3phase and there is no bus 200)
##psspy.dist_bus_fault(ibus=100)
##
### DURING FAULT CONDITION RUNNING FOR 1.1 SND
##time = 1.1
##psspy.run(tpause=time)
##
### Clear fault (assuming only part of bus faults)
####psspy.dist_clear_fault()
##psspy.dist_branch_trip(ibus=100, jbus=150, id='1')
##
####AFTER FAULT CONDITION
### Run to 15 seconds
##time = 15
##psspy.run(tpause=time)

# ----------------------------------------------------------------------------------------------------
def array2dict(dict_keys, dict_values):
    '''Convert array to dictionary of arrays.
    psspy.halt()s dictionary as {dict_keys:dict_values}
    '''
    tmpdict = {}
    for i in range(len(dict_keys)):
        tmpdict[dict_keys[i].lower()] = dict_values[i]
    return tmpdict

# ----------------------------------------------------------------------------------------------------
def busindexes(busnum, busnumlist):
    '''Find indexes of a bus in list of buses.
    psspy.halt()s list with indexes of 'busnum' in 'busnumlist'.
    '''
    busidxes = []
    startidx = 0
    buscounts = busnumlist.count(busnum)
    if buscounts:
        for i in range(buscounts):
            tmpidx = busnumlist.index(busnum,startidx)
            busidxes.append(tmpidx)
            startidx = tmpidx+1
    return busidxes

# ----------------------------------------------------------------------------------------------------
def splitstring_commaspace(tmpstr):
    '''Split string first at comma and then by space. Example:
    Input  tmpstr = a1       a2,  ,a4 a5 ,,,a8,a9
    Output strlst = ['a1', 'a2', ' ', 'a4', 'a5', ' ', ' ', 'a8', 'a9']
    '''
    strlst = []
    commalst = tmpstr.split(',')
    for each in commalst:
        eachlst = each.split()
        if eachlst:
            strlst.extend(eachlst)
        else:
            strlst.extend(' ')

    return strlst

savfile = 'savnw.sav'
print "steadystate30-6-14: %s\n\n"%savfile
clnttls = "%6s,%18s,%6s,%18s,%3s,%8s,%8s ...
(more)
2015-07-08 07:58:41 -0500 received badge  Famous Question (source)
2015-05-25 04:35:19 -0500 received badge  Notable Question (source)
2015-05-25 04:35:19 -0500 received badge  Popular Question (source)
2015-05-20 02:17:21 -0500 received badge  Editor (source)
2015-05-18 21:57:04 -0500 asked a question Python code for interchange between two areas

Trying to extract the interchange between two areas and save it on excel. I have already create the python code, but having a problem with extracting data. I need to make the extract ( cmpval ) data on matrix form so i can save it on excel. here is the code .. please check it out users and help me about regards

import os,sys

PSSEPATH = r'C:\Program Files (x86)\PTI\PSSEUniversity33\PSSBIN' sys.path.append(PSSEPATH) os.environ['PATH'] += ';' + PSSE_PATH

import psspy import redirect

redirect.psse2py() psspy.psseinit(9) psspy.case('C:\Users\user\Desktop\9busnew.sav')

import excelpy x1 = excelpy.workbook() x1.show() x1.setcell('a1', 'FROMAREA/ZONE') x1.setcell('b1', 'TOAREA/ZONE') x1.set_cell('c1', 'Total Change')

code for extracting the interchange between two areas. ierr, areas = psspy.aareacount(sid = -1, flag = 1) for i in range(areas): for j in range(areas): frarea = i + 1; toarea = j + 1; ierr, cmpval = psspy.aritoj(frarea, toarea) print cmpval having a problem with cmpval, i need to put in matrix form x1.set_range(2,'c',zip(cmpval))

code for areas numbers, but still having a problem on puting all the numbers ierr, Fromarea = psspy.aareaint(-1, 1, 'NUMBER') ierr, toarea = psspy.aareaint(-1, 1, 'NUMBER') Fromarea = Fromarea[0] toarea = toarea[0] x1.setrange(2,'a', zip(Fromarea)) x1.setrange(2,'b', zip(toarea))