Ask Your Question

sheng's profile - activity

2016-01-13 18:20:24 -0500 answered a question How to use psspy inside a function??

A NameError suggested that it is not a path issue. It means that psspy is not defined in one of the scripts that you have used, i.e. meaning you didn't even try to import psspy.

If the path is not correct, it should throw an ImportError when you try to import psspy.

2015-07-01 06:24:16 -0500 answered a question MW & Mvar flow in Python to Excel

You can either use excelpy or CSV module. I would stick to CSV if you were to store plain data, i.e. no requirements for features of XLSX etc.

First of all, get the data that you need.

# get bus numbers, circuit IDs and loading of in-service branches
ierr,busnum = psspy.abrnint(string=['FROMNUMBER','TONUMBER'])
ierr,ckt = psspy.abrnchar(string='ID')
ierr,loading = psspy.abrnreal(string=['P','Q'])

CSV option:

import csv

# open a CSV file for writing
csv_out = open('branch_flows.csv','wb')

# create the csv writer object
csvobj= csv.writer(csv_out)

# write header
csvobj.writerow(('From bus','To bus','ID','MW','MVAr'))

# write data
csvobj.writerows(zip(busnum[0],busnum[1],ckt[0],loading[0],loading[1]))

# close CSV file
csv_out.close()

excelpy option:

import excelpy

# create a Excel workbook for writing
xlobj = excelpy.workbook()

# write header
xlobj.set_range(1,'a',['From bus','To bus','ID','MW','MVAr'])

# write data
xlobj.set_range(2,'a',zip(*busnum))
xlobj.set_range(2,'c',zip(*ckt))
xlobj.set_range(2,'d',zip(*loading))

# save workbook
xlobj.save('branch_flows.xlsx')
2015-06-30 00:44:32 -0500 received badge  Necromancer (source)
2015-06-12 06:10:54 -0500 answered a question Short circuit current as function of distance from bus

You can use the short-circuit data retrieval APIs after SCMU.

scinit()
Use this API to initialize the short-circuit data retrieval APIs. It must be called when PSS(R)E is at the power flow activity level and must follow each execution of activity SCMU. Can be followed by SCBUS2, SCBRN2, SC3WND and SCMAC2 calls. SCDONE must be called after executing these and before any other calls or PSS(R)E activities can be executed.

    Python syntax:

    ierr = scinit()

    where:
    Integer IERR      Is the error code (output):
    IERR = 0 No error.
    IERR = 1 Sequence data not in case.
    IERR = 2 Unable to access SCMU results; one of the following occurred:
    *  No SCMU results file is open.
    *  SCMU results are not compatible with the working case.
    *  Error reading the SCMU results file.

scbus2(ibus=None, string=None)
Returns complex bus voltages and currents following activity SCMU.

    Python syntax:

    ierr, cmpval = scbus2(ibus, string)

    where:
    Integer IBUS      Bus number (input).
    Character STRING     String indicating the quantity desired (input):
    'VPOS'   Positive sequence voltage.
    'VNEG'   Negative sequence voltage.
    'VZERO'  Zero sequence voltage.
    'VA'  A-phase voltage.
    'VB'  B-phase voltage.
    'VC'  C-phase voltage.
    'SHUNTP' Positive sequence shunt current.
    'SHUNTN' Negative sequence shunt current.
    'SHUNTZ' Zero sequence shunt current.
    'SHUNTA' A-phase shunt current.
    'SHUNTB' B-phase shunt current.
    'SHUNTC' C-phase shunt current.
    'FAULTP' Positive sequence fault current.
    'FAULTN' Negative sequence fault current.
    'FAULTZ' Zero sequence fault current.
    'FAULTA' A-phase fault current.
    'FAULTB' B-phase fault current.
    'FAULTC' C-phase fault current.
    Real P      Real component of the complex value indicated by STRING (output).
    Real Q      Reactive component of the complex value indicated by STRING (output).
    Complex CMPVAL    Complex value indicated by STRING (output).
    Integer IERR      Is the error code (output):
    IERR = 0 No error; 'P,Q' or 'CMPVAL' returned.
    IERR = 1 'SCINIT' not successfully called; 'P,Q' or 'CMPVAL' unchanged.
    IERR = 2 Bus not found; 'P,Q' or 'CMPVAL' unchanged.
    IERR = 3 Bad value of 'STRING'; 'P,Q' or 'CMPVAL' unchanged.
    IERR = 4 Bus disconnected; 'P,Q' or 'CMPVAL' of (0.,0.) returned.
    IERR = 5 Bus not faulted; 'P,Q' or 'CMPVAL' of (0.,0.) returned.
2015-05-25 22:37:58 -0500 commented answer Optimal Capacitor Placement

Probably the best he could do but remember such trial-and-error approach is never optimal. Also note that his objective is to improve system voltage profile not maximising voltage collapse margins.

2015-05-24 07:43:32 -0500 answered a question Optimal Capacitor Placement

This is a very difficult problem to solve. Theoretically the best solution would be to employ an OPF algorithm with its objective being voltage profile improvement, and its control variables being the locations of capacitor placement.

However I don't think any of the available OPF objectives in PSSE is suitable for your use. Even if there is one, control variables still won't suit your problem.

Rewriting an OPF algorithm using Python for the dimension of your problem (5000 bus) is probably out of question as it involves deriving complicated Hessian matrices.

You could run numerous load flows to check impacts of different placements, i.e. trial-and-error type approach, but it won't be optimal.

2015-05-14 02:39:34 -0500 received badge  Good Answer (source)
2015-05-04 21:00:48 -0500 commented answer Python Parallel Dynamics Simulations

Issue is multiprocessing.Pool hang forever if a worker process dies unexpectedly

2015-04-17 07:23:09 -0500 answered a question How to get total charging for an area?

Line charging quantities are defined as per unit capacitance whereas the total charging from AREA total is reactive power (VAr) resulting from line charge. I don't think there is any API that would return VAr due to line charge as a variable. You could either parse the output of SUBS API or calculate and sum up VAr charge per branch.

# get details of all branches in defined subsystem ID
ierr, buses = psspy.abrnint(sid=subsysid,ties=3,string=['FROMNUMBER','TONUMBER'])
fbuses = buses[0]
tbuses = buses[1]
ierr, (cktids,) = psspy.abrnchar(sid=subsysid,ties=3,string='ID')
ierr, (charging,) = psspy.abrnreal(sid=subsysid,ties=3,string='CHARGING')
mvabase = psspy.sysmva()

# iterate every branch in defined subsystem and calculate charging vars
total_charge=0
for fbus,tbus,ckt,charge in zip(fbuses,tbuses,cktids,charging):
    ierr, fbus_puvolt = psspy.busdat(ibus=fbus,string='PU')
    ierr, tbus_puvolt = psspy.busdat(ibus=tbus,string='PU')
    total_charge += charge*mvabase/2 * (fbus_puvolt**2 + tbus_puvolt**2)
2015-04-17 05:57:19 -0500 commented answer Python Parallel Dynamics Simulations

I did something similar but I do experience few race conditions with PSSE32. Do you experience any? Another issue is zombie processes in multiprocessing module--how do you manage it?

2015-04-17 05:57:19 -0500 received badge  Commentator
2015-03-31 15:40:53 -0500 received badge  Nice Answer (source)
2015-03-25 18:59:44 -0500 commented answer how to calculate Zbus matrix for each change in configuration to a 39 bus system in psse??

Nice, I didn't know we could at least dump Ybus to a file. That would make things a lot easier.

2015-03-25 18:59:03 -0500 received badge  Supporter (source)
2015-03-17 23:12:01 -0500 answered a question Dynamic Simulation Bus Monitoring (psspy.chsb) Pointer Limit?

Check the dimensional capacity you have used to start up PSSE--see Section 3.3.1 of Program Operation Manual

2015-03-15 22:47:27 -0500 answered a question how to calculate Zbus matrix for each change in configuration to a 39 bus system in psse??

I doubt you can export Ybus or Zbus from PSS/E. I would suggest you build your own from scratch using Python.

2015-02-19 06:26:52 -0500 answered a question Open several psspy-instances from Python

I'm not sure what you have proposed will work.

Try using the Python Multiprocessing module--I have used it to run multiple instances of PSSE to perform tasks currently.

However if you are only solving couple of load flows, it is probably not worth the trouble.

2015-02-14 05:31:28 -0500 answered a question System instability

Such angle deviation without any perturbation usually means something is not quite right rather than instability. I would suggest checking STRT errors etc, and also are you plotting absolute angles rather than relative angles?

2014-09-30 20:42:47 -0500 commented question dynamic simulation - linear analysis - PSS/E

I believe that's an add-on

2014-09-30 20:40:22 -0500 commented answer PSSE32&PSSE33

Note that although sensitivity APIs are not documented in v32 manual, they are still be available for use.

2014-09-22 06:00:38 -0500 commented question Calculte CCT with series capacitor transmission line.

Just curious if results are significantly different when fault is applied on main buses or intermediate buses

2014-09-19 05:42:33 -0500 commented question Calculte CCT with series capacitor transmission line.

Can't you just sum up the impedances of the line sections and remove those intermediate buses?

2014-09-18 21:20:48 -0500 received badge  Nice Answer (source)
2014-09-18 17:31:07 -0500 answered a question Count the number of network not converged message

You probably can modify the following http://www.whit.com.au/blog/2013/07/c...

2014-09-14 22:00:49 -0500 answered a question Get three winding power flow.

use WNDDAT

2014-09-02 06:33:57 -0500 received badge  Editor (source)
2014-09-02 06:04:36 -0500 answered a question Quantiative criteria for instability system

If you are purely after rotor angle stability then monitoring angle spread would probably be your best option, which corresponds to your (1). The easiest way to approach this would be using the SYSANG model .

Alternatively, you may also make use of OSSCAN model (monitoring only), which scans for out-of-step conditions. However you would need to parse PSS/E progress printing for out-of-step messages.

2014-06-11 19:20:57 -0500 commented answer how to calculate the Jacobian of the system from python using PSSE . thanks a lot

Interested to know if anyone has success on this? Load flow Jacobian can always provide additional insight, e.g. modal analysis etc.

2013-08-05 00:29:21 -0500 commented question Can I create xyplots in Python 2.7 for *.out files created using PSSE 32

Python 2.7 should work fine if you are using PSSE 33, but reading out files created by PSSE 32. Your issue seems like you have forgotten to close the figures after plotting?

2013-08-04 17:32:07 -0500 received badge  Teacher (source)
2013-08-01 18:09:37 -0500 commented answer load and generator conversion

If you need a more customisable PV/QV analysis with more flexibility than what PSS/E provides, I suggest writing your own PV/QV codes in python.