Ask Your Question

JervisW's profile - activity

2023-10-25 12:00:13 -0500 received badge  Great Answer (source)
2023-10-25 12:00:13 -0500 received badge  Guru (source)
2019-01-14 05:28:20 -0500 received badge  Favorite Question (source)
2018-09-13 13:56:35 -0500 received badge  Nice Answer (source)
2017-08-07 21:23:27 -0500 received badge  Nice Question (source)
2016-06-27 21:28:19 -0500 answered a question Selecting data to send to Excel - set_range

At this point here, you have all the information you want, but spread in three different lists (or columns). buses, iarea and volts

ierr, buses = psspy.abusint(-1,2,string='NUMBER')
ierr, iarea = psspy.abusint(-1,2, string='AREA')
ierr, volts = psspy.abusreal(-1,2,string='PU')

What you want is a way to filter for the rows where the area == 5

You need to transpose your columns into rows first.

rows = zip(buses, iarea, volts)

then you'll need to set the cells that you'd like. I don't think excelpy is efficiently using set_range. It is just calling set_cell individually. So we can do this without any performance penalty

for rowid, record in enumerate(rows):
    bus, area, voltage = record
    if area == 5:
        x1.set_cell(2 + rowid, 'a', area)
        x1.set_cell(2 + rowid, 'b', bus)
        x1.set_cell(2 + rowid, 'c', voltage)

where enumerate obviously gives us a 0-based index, and you wanted to start from row 2, that's why I add 2 to every rowid.

2016-05-09 21:12:17 -0500 marked best answer What if you initialise with too few bus numbers?

PSSE's psseinit function asks for the number of bus numbers to initialise with. What happens if you enter a low number like 40? Is there a benefit to entering a lower number than a higher number like 80000?

2016-05-09 21:11:40 -0500 marked best answer Invalid file type (OpnApplFil/OPNPTI) when saving

I tried to save a file recently with the following script:

import sys, os
PSSE = "c:/Program Files/pti/psse32/pssbin"
sys.path.append(PSSE)
os.environ['PATH'] += PSSE + ';'

import psspy
psspy.throwPsseExceptions = True

psspy.newcase_2(titl1="an empty saved case")
psspy.bus_data_2(101)
psspy.save("empty.sav")

and PSSE shows this error:

Invalid file type. empty.sav (OpnApplFil/OPNPTI)
Traceback (most recent call last):
  File "top_secret_consulting_work.py", line 72 in <module>
    psspy.save("empty.sav")
  File ".\psspy.py", line 13500, in save
psspy.SaveError: save Error: ierr=3

When looking up in the API ierr=3 is:

error opening SFILE.

Anyone have any ideas about what the problem is?

2016-05-09 21:11:39 -0500 marked best answer What does actv.exe do?

@jsexauer In the question:

Two copies of PSSE on the same computer

You wrote that you use actv.exe <LICENCE KEY> PYTHON.EXE in a batch script which is run before importing psspy.

What does actv.exe do?

2016-05-09 21:11:38 -0500 marked best answer PSSE bus codes

A reference of all the bus types in PSSE.

Type 1: Load Bus
Type 2: Generator Bus
Type 3: Swing Bus
Type 4: Disconnected
Type 5: Load Bus (at boundary of an area)

Have you ever used Type 5? I only came across it today in my research.

Here is how to create a new type 1 bus

busnumber, busname = 20020, "PARK_2"
psspy.bus_data_2(i=busnumber, intgar1=1, name=busname)

Beware though, if bus number 20020 already existed then this would change it's type and name - It wouldn't create a new bus at all.

2016-04-11 00:39:58 -0500 marked best answer What does psspy.asys do

I tried using psspy.asys to create a group of buses that are in two subsystems. After running the command I expected to see 23 buses in the subsystem. Instead there were 0 buses loaded into the subsystem.

What do you use it for, and how do you use it?

(edit) Here are some of the commands I used:

psspy.asys(sid=1, num=2, areas=[3,4])
ierr, buses = psspy.abuscount(sid=1)
# ierr == 2! Invalid SID value; BUSES returned as 0.

My work around

psspy.bsys

I use this to create subsystem of the buses in areas 3 and 4:

psspy.bsys(sid=1, numarea=2, areas=[3,4])
ierr, buses = psspy.abuscount(sid=1)
# ierr == 0! this method works.
2016-04-11 00:39:57 -0500 marked best answer The smallest number of elements to create a saved case

I'm going to make a saved case with the least number of elements in it. I tried saving an empty case and I get an error "No network data in memory".

What is the minimum number of elements that I can have before PSSE will save?

2016-04-11 00:39:57 -0500 marked best answer ADJM from switched shunt data retrieval doesn't work

I have been looking at this for hours. I am trying to get the Switched Shunt Adjustment Method for a switched shunt using the subsystem data retrieval api

ierr, adj_methods = psspy.aswshint(sid=-1, string=["STATUS", "ADJM"])

The status column return value is correct, but the ADJM column return is empty.

How do I get the Switched Shunt Adjustment Method value?

2016-04-11 00:39:57 -0500 marked best answer What is the default integer value in PSSE?

I heard once that the default integer _i had a value of -9999 or some number that is extremely unlikely to occur in practice.

How can I check what its value is now, does anyone have any clues?

2016-04-11 00:39:57 -0500 marked best answer reattempt solve if iteration limit is reached

How can I reattempt to solve using the full newton raphson method when the 20 iteration limit is reached?

2016-04-11 00:25:55 -0500 marked best answer Crash when in service line to out of service bus ASCC

When I call the ascc function with an in service line to an out of service bus in the system, PSSE crashes without saving. How can I disconnect all in service lines to out of service buses to prevent a crash?

2014-11-09 19:31:54 -0500 marked best answer DIgSILENT Powerfactory and Python scripts

I've heard of some people using Python with DIgSILENT's PowerFactory product (A competitor for PSS/E).

So my question is have you ever used Python and PowerFactory, or would you want to?

If you can, post some example code that you might run.

(edit) I have seen that PowerFactory has their own language that is used for scripting, what does that look like?

2014-10-20 05:28:52 -0500 commented answer Running PSSE University 33

Eli is correct. Python 2.7 and Python 3.4 are really like two different (albeit very similar looking) languages. It is perfectly acceptable to write your code in Python 2.7 and ignore Python 3.4 (for now).

2014-10-20 05:26:21 -0500 edited question cim5bl model

Hello friends, I am using cim5bl model for my dynamic studying. When I check DOCU for the model parameters, I get the notice as following:

*Model CIM5BL Bus 6 [10BBA       10.000] Load "4 " :
 Derived constant T" =      0.0031, outside of range > 0.0400 and < 0.2
 Derived constant X =      2.8900, outside of range > 0.0 and < 2.5
 Model CIM5BL is applied to bus 6 [10BBA       10.000] using load identifier "4"
    I C O N       C O N S     S T A T E S     V A R S      RES-ICONS
         8         86-104        46-51         10-20         74-77
     RA        XA        XM        R1        X1        R2        X2
    0.0300    0.0900    2.8000    0.0250    0.1100    0.1500    0.0400
     E1        S(E1)     E2        S(E2)     MBASE     PMULT     H
    1.0000    0.0400    1.2000    0.2000    2.9000    1.0000    0.5100
     VI        TI        TB        D       SYN-TOR        MOTOR TYPE
    0.0000    0.1000    0.1000    0.2100    0.0000             1*

How can I solve this problem? Trying to find out a formula about T'' and X but failed. I appreciate your answer and thank you so much!

2014-10-06 21:55:51 -0500 marked best answer What is the API for generating the .qv files?

I've written my own QV curve generator (see here) but I'm curious, how would I create one of those .qv files.

A .qv file is the binary results file that PSSE saves the QV analysis results to.

(edit) I'm looking for the exact psspy commands that I should be using to

  1. load in a case
  2. run a QV curve analysis on a single bus and store the results in a binary .qv file
  3. (option) Bonus marks awarded if you can show how to get the results out of the .qv file into a Python array like this:

Example qv results array

# (Q,  V)
[(0.4,  0.99),
 (0.39, 0.98),
 (...)]
2014-08-25 21:58:43 -0500 marked best answer How can I find all 500kV buses in an area?

My saved case has over 100 buses that are 500kV in a PSSE area (area 3). Finding all of the 500kV area 3 buses is easy using the filters on the PSSE user interface. But my question is how to find those bus numbers in Python?

2014-08-18 09:50:45 -0500 received badge  Good Answer (source)
2014-08-17 19:38:27 -0500 commented answer How to create a N-1 generator contingency list that enumerates every single generator in a subsystem?

Looks like a good solution! I hope that one day PSS/e provides a direct API for this rather than requiring us to write out physical files.

2014-08-17 19:35:16 -0500 edited answer How to create a N-1 generator contingency list that enumerates every single generator in a subsystem?

I figured out a way to create all N-1 generator contingency list by writing commands "REMOVE MACHINE [MCID] FROM BUS [BUSID]" explicitly one by one to the .con file. But my module I used in my problem is based on the possibility that you know how to associated a GUI defined subsystem label to a valid subsystem id (0~11). Right now, I use the whole working case as a subsystem, so that the subsystem id is equal to -1.

def createConFile(psspy, conFileName, subsysID, subSysLabel):

    # manipute with working case data- all returned data are in the same order
    ierr, (allMachID,) = psspy.amachchar(subsysID, 4, 'ID')   # return total number of machines in working case
    print "machID =", allMachID

    ierr, (busNums,) = psspy.amachint(subsysID, 4, 'NUMBER') 
    print "list of bus numbers ", busNums

    conFile = open(conFileName, 'w')

    # .con file header
    conFile.write("/PSS(R)E 33\n")
    conFile.write("COM\n")
    conFile.write("COM CONTINGENCY description file entry created by PSS(R)E Config File Builder \n")
    conFile.write("COM\n")
    conFile.write("SINGLE BRANCH IN SUBSYSTEM '%s' \n\n" % subSysLabel)

    # contingencies for removing each specified machine 
    for machid, busnum in zip(allMachID, busNums): 
        conFile.write("CONTINGENCY 'MACHINE %d-BUS%d' \n" %( int(machid), busnum))
        conFile.write('REMOVE MACHINE %s FROM BUS %d \n' %(machid, busNum))
        conFile.write('END \n\n')

    conFile.write('END')
    conFile.close()

Hope someone will find this helpful.

2014-08-17 19:27:35 -0500 commented question How to assign a subsystem id for a defined subsystem in GUI?

An interesting test @ypwang so based on the result you'd say they aren't linked?

2014-08-03 20:24:22 -0500 commented question Obtain model constant DESCRIPTION

This would be great to know. Did you discover anything?

2014-08-03 20:22:39 -0500 commented question How to terminate a running python code within IDLE?

I'm not sure what the correct answer is here. I suspect you are close to the optimal solution. This is one of the reasons I stopped using IDLE, now I use a standard python console + a normal text editor.

2014-08-03 20:16:55 -0500 edited answer What is the API for tripping and reconnecting loads

Perhaps you could move the load to a new bus, which is connected to the original bus via a zero impedance line. Use DIST_BRANCH_TRIP to trip the branch (and island the load), then use busdata2 to change the bus code to 1 before using DIST_BRANCH_CLOSE to reconnect it.

2014-08-03 20:14:54 -0500 answered a question Finding the processing time using full N-R and fast decoupled N-R

You can use the python timeit module. It will run the same piece of code multiple times (to attempt to compensate for changing conditions on your computer, e.g. caches being warmed up, other processes taking more time).

Why is it important for you to find the relative processing time between the two solution methods?

2014-08-03 19:26:57 -0500 edited question whats wrong with this fvsi program?
report("steadystate30-6-14: %s\n\n"%savfile)
clnttls = "%6s,%18s,%6s,%18s,%3s,%8s,%8s,%8s,%8s,%8s,%8s,%8s,%8s,%8s,%8s\n"%('FRMBUS','FROMBUSEXNAME','TOBUS','TOBUSEXNAME','CKT','R(pu)','X(pu)','Z(pu)','Z*Z','Vs(pu)','Vs*Vs','Pj','Qj','Qj(pu)','FVSI')


report(clnttls)

for i in range(len(ibuses['number'])):
    bus = ibuses['number'][i]

    flowfrombusidxes = busindexes(bus,ibranch['fromnumber'])

    for idx in flowfrombusidxes:
        b = ibranch['fromnumber'][idx]
        fbn = cbranch['fromexname'][idx]
        tb = ibranch['tonumber'][idx]
        tbn = cbranch['toexname'][idx]
        ckt = cbranch['id'][idx]
        r = abs(xbranch['rx'][idx].real)
        x = xbranch['rx'][idx].imag

        frombusidx = busindexes(ibranch['fromnumber'][idx],ibusesall['number'])
        vs = rbusesall['pu'][frombusidx[0]]

        ps = rbranch['p'][idx]
        qs = rbranch['q'][idx]

        from math import sqrt
        z = sqrt(r*r+x*x)
        z2 = pow(z,2)
        vs2 = pow(vs,2)
        qsj = abs(qs/100)
        fvsi = (4*z2*qsj)/(vs2*x)

        report("%(b)6d,%(fbn)18s,%(tb)6d,%(tbn)18s,%(ckt)3s,%(r)8.6f,%(x)8.6f,%(z2)8.6f,%(vs)8.4f,%(ps)8.2f,%(qs)8.2f,%(qsj)8.2f,%(fvsi)8.4f\n"%vars())
2014-08-03 19:24:41 -0500 edited question Seperate a single .py file into multiple .py files
  1. I want to separate the file (*.py). If I saparate the file which are A.py and B.py and C.py. B and C are the sub-files of A.py If I run the A.py, A file must call the B and C files. How should I do?

    1. I want make the modeling about Low pass filter for the frequency from PSS/E. How should I solve this problem?
2014-07-31 00:36:55 -0500 received badge  Nice Answer (source)
2014-06-21 04:38:57 -0500 received badge  Famous Question (source)
2014-06-21 04:38:57 -0500 received badge  Popular Question (source)
2014-06-21 04:38:57 -0500 received badge  Notable Question (source)
2014-03-26 23:09:57 -0500 edited question Read keyboard input directly in progress window, not terminal read

Hi everyone,

When I use "raw_input" function to read keyboard input, a "terminal read" window pops up so that I can enter my data there.

It works fine, but I would like to know if we can type our data directly in progress window of PSSE, just like when PSSE asks us to enter choice for its function, such as:

 ACTIVITY? vchk kv

   ENTER OUTPUT DEVICE CODE:

    0 FOR NO OUTPUT               1 FOR REPORT DEVICE

    2 FOR A FILE                  3 FOR DEFAULT PRINTER

    6 FOR ALTERNATE SPOOL DEVICE  7 FOR PROGRESS DEVICE:

   7

   ENTER MIN, MAX BASE KV
   750 750

   ENTER VMAX, VMIN: 1.05 0.95

Thanks,