Ask Your Question

Peter B's profile - activity

2021-12-02 09:25:58 -0500 received badge  Famous Question (source)
2021-08-23 05:54:05 -0500 received badge  Notable Question (source)
2021-08-23 05:54:05 -0500 received badge  Popular Question (source)
2021-08-19 00:22:40 -0500 asked a question pssexcel.accc not working in GUI or via python in PSSE V34.7.0

Hi,

In PSS/E V34.7.0 I am having the following problems:

  • I cannot export ACCC results to Excel via the GUI.
  • I select Power flow -> Reports -> Export ACCC PV/PQ results to Excel...
  • and then nothing happens other than the message below in the progress window, there is no pop-up window to select the .acc file to extract data from etc.

Executing Python file:C:\Program Files (x86)\PTI\PSSE34\PSSPY27\excelexportw_frompsse.pyw

  • I therefore tried to see if I could extract the data from the .acc file using python code. My simple code is below

    accfilename = 'file_name.acc'
    xlsfilename = 'fileneme.xlsx'
    
    """Export results to excel"""
    import pssexcel
    
    # 's' or 'summary' ACCC Analysis Summary
    # 'e' or 'events' Contingency Events Description
    # 'b' or 'branch' Monitored Branch Flow (MVA)
    # 'i' or 'interface' Monitored Interface Flow (MW)
    # 'v' or 'voltage' Monitored Bus Voltage
    # 'l' or 'load' Loads Shed (MW)
    # 'g' or 'generator' Generator Dispatch (MW)
    # 'p' or 'phase shifter' Phase Shifter Angle
    
    options = ['s','e','b','v']  
    pssexcel.accc(accfile=accfilename, string=options, xlsfile=xlsfilename, ratecon = 'c', baseflowvio = True, basevoltvio = True, overloadreport = True)
    
  • Sometimes this works and creates an excel file like I used to be able to do via the GUI.

  • Sometimes, it starts to work, an excel file opens and starts to populate with data, but then crashes and gives the message below in the progress window in PSS/E (this is when it is trying to overwrite an existing excel file):

    File "Exportsresultsonly.py", line 25, in <module> pssexcel.accc(accfile=accfilename, string=options, xlsfile=xlsfilename, ratecon = 'c', baseflowvio = True, basevoltvio = True, overloadreport = True)

    File ".\pssexcel.py", line 1724, in accc    
    File ".\pssexcel.py", line 786, in _accc_co_events    
    File ".\excelpy.py", line 889, in set_active_sheet
    File "<COMObject <unknown>>", line 2, in Activate
    pywintypes.com_error: (-2146777998, 'OLE error 0x800ac472', None, None)
    
    • I get different errors if it creates a totally new excel file:

File "Exportsresultsonly.py", line 25, in <module>pssexcel.accc(accfile=accfilename, string=options, xlsfile=xlsfilename, ratecon = 'c', baseflowvio = True, basevoltvio = True, overloadreport = True)

File ".\pssexcel.py", line 1449, in accc
File ".\pssexcel.py", line 765, in _accc_summary
File ".\excelpy.py", line 446, in autofit_columns
File "<COMObject <unknown>>", line 2, in AutoFit
File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 287, in _ApplyTypes_result = self._oleobj_.InvokeTypes(*(dispid, LCID, wFlags, retType, argTypes) + args)
pywintypes.com_error: (-2147023170, 'The remote procedure call failed.', None, None)
  • I haven't been able to figure out the pattern of why the code sometimes work and sometimes doesn't.
  • Does anyone have any suggestions for what might be causing this problem and how to solve it? Or is there some other way to extract results from an .acc file?
2019-04-29 17:02:53 -0500 received badge  Famous Question (source)
2019-02-17 20:27:51 -0500 received badge  Famous Question (source)
2019-02-10 22:36:53 -0500 received badge  Notable Question (source)
2019-02-08 10:52:23 -0500 received badge  Popular Question (source)
2019-02-06 16:35:24 -0500 commented answer pause psspy.run based on the status of a monitored variable (to simulate an SPS)

Thanks perolofl, I feared that would be the case. I thought of the loop solution as well, but I anticipate it will make my simulation very slow. I'll do some experimentation and see how I go. I may also see if I can take this opportunity to learn how to code my own dynamic model.

2019-02-06 16:34:03 -0500 answered a question pause psspy.run based on the status of a monitored variable (to simulate an SPS)

Thanks perolofl,

I feared that would be the case. I thought of the loop solution as well, but I anticipate it will make my simulation very slow. I'll do some experimentation and see how I go. I may also see if I can take this opportunity to learn how to code my own dynamic model, but I have no experience in that at the moment!

Cheers,

Peter

2019-02-04 21:46:50 -0500 asked a question pause psspy.run based on the status of a monitored variable (to simulate an SPS)

Hi there,

In PSS/E dynamics I want to model a Special Protection Scheme (SPS), that takes some action (e.g. tripping specific generators, lines or loads) based on the value of some other monitored parameter or parameters (e.g. voltage/frequency at a given bus, flow on particular lines etc).

To achieve this, I think I'll need to be able to monitor the relevant parameters (easily done), and then when they reach given value(s), pause the dynamic simulation (the part I don't know) and take whatever is action is relevant (via some python command - easy), and then set psspy.run going again.

psspy.run syntax is below. It will run until time tpause, which must be a real number. I don't know how to pause the simulation other than that.

psspy.run(option, tpause, nprt, nplt,crtplt)

Does anyone know if it's possible to pause a simulation based on a monitored variable criteria? I fear that if it can't be done my only option will be to write a bespoke dynamic model in Fortran.

P.S. I know about load trip relay models etc in PSS/E. They won't achieve what I'm trying to do, which is monitor element X trip element Y.

2019-01-04 08:08:40 -0500 received badge  Taxonomist
2016-05-09 21:11:37 -0500 marked best answer When running PSS/E from python how do I prevent progress windows from popping up?

When I run PSS/E from python I get all these annoying pop-ups that come up after I press F5 in IDLE. Each of these requires I press enter to make them go away. Sometimes the pop-up just states the case name but other times it gives obscure information about dimension sizes etc and I end up pressing enter dozens of times to remove them.

How I can I prevent these from coming up in the first place?

2014-12-03 19:34:06 -0500 received badge  Famous Question (source)
2014-03-13 17:03:31 -0500 received badge  Notable Question (source)
2014-03-03 07:05:31 -0500 received badge  Popular Question (source)
2014-02-24 23:49:53 -0500 asked a question initialise until no suspect initial conditions

Hi,

At the moment when I initialise a case using python I will call the psspy.strt() command an arbitrary number of times (usually 2 or 4).

I want to initialise using psspy.strt() only the minimum number of times needed to get rid of suspect initial conditions.

I know suspect initial conditions can be detected using the psspy.okstrt() command.

Does anyone know how I can combine the two commands in some kind of loop to achieve my objective?

Thanks,

Peter

2014-02-24 23:41:08 -0500 commented answer automatic contingency test in PSS/E

Make the .sub, .mon and .con files via the PSS/E GUI as described by @yfwing above.

2014-02-13 13:54:09 -0500 received badge  Famous Question (source)
2014-02-13 13:54:09 -0500 received badge  Notable Question (source)
2013-11-19 01:05:50 -0500 received badge  Famous Question (source)
2013-11-06 16:56:25 -0500 answered a question automatic contingency test in PSS/E

Also see the question and answer at the link below if you want to automate parts of the process

https://psspy.org/psse-help-forum/que...

2013-10-21 19:40:45 -0500 received badge  Popular Question (source)
2013-10-21 19:28:52 -0500 received badge  Notable Question (source)
2013-10-20 22:27:16 -0500 commented answer Close ACCC excel report

I was running from Python IDLE. I don't need the above lines to run pssexcel.accc on a single case, but when looping through multiple cases it seems to need it.

2013-10-20 22:23:54 -0500 commented answer ACCC script for multiple cases - crashes depending on the order of cases. How do I debug?

I tried this technique, when it got to the second iteration of executing the accc function call the Python Shell just gave me a ">>> ======= RESTART ======" message, as it had when I ran the script through in full without using pdb. So I'm none the wiser but I'll probably just run the script from inside PSS/E just to get it working smoothly.

2013-10-20 22:07:44 -0500 commented question ACCC script for multiple cases - crashes depending on the order of cases. How do I debug?

I just ran it from inside PSS/E and it did work, strange. As a matter of principle I'll still try and do some debugging as suggested by @JervisW, so that hopefully I can get it working properly from outside PSS/E. Thanks for the reminder to try the simple solution first @yfwing!

2013-10-20 22:04:05 -0500 received badge  Popular Question (source)
2013-10-16 01:22:34 -0500 commented question ACCC script for multiple cases - crashes depending on the order of cases. How do I debug?

For some reason when I write underscoreX, what comes out is an italicised X. That's why the case names in the question look a bit different to what's in the .dat file. I don't know how to fix that.

2013-10-16 01:18:41 -0500 asked a question ACCC script for multiple cases - crashes depending on the order of cases. How do I debug?

Hi,

I've written a script to run ACCC studies on multiple cases. The script reads in from a .dat file the names of the relevant .sav, .sub, .mon and .con files and then creates .dfx, .acc and .xlsx files also based on specifications in the .dat file.

Below is a screen shot of the .dat file contents:

image description

The weird issue I'm having is that my script works fine (i.e. produces all three ACCC reports in excel) if the order of cases listed in the data file begins with Test_case_2.sav.

But if Test_case_1.sav or Test_case_3.sav are listed first (as in the screenshot example), the script will create only one ACCC report and then just stop running (without throwing up any errors) when it is part way through making the second .acc file.

My question is, what debugging techniques can I use to try and find out why this is happening?

My code is below, I'm already using psspy.throwPsseExceptions = True, I've had a go at using logging but you can probably tell from the code I don't know what I'm doing with it.

Thanks,

Peter

import math, sys, csv,os, logging

# Location of libraries
sys.path.append("C:\Program Files (x86)\PTI\PSSE32\PSSBIN")   # psspy

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

import psspy, pssexcel, excelpy
import redirect      #redirects popups
redirect.psse2py()
psspy.psseinit()     #initialise PSSE so psspy commands can be called
psspy.throwPsseExceptions = True

def clearall():
    all = [var for var in globals() if (var[:2], var[-2:]) != ("__", "__")]
    for var in all:
        del globals()[var]

class IOFile:

    #To retrieve data from input.csv input file
    def Input_File(self):
        try:
            fileinput_tmp = open('input_ACCC_123.dat','rb')
            fileinput = csv.reader(fileinput_tmp)

        except IOError:
            psspy.lines_per_page_one_device(2,10000000)
            psspy.progress_output(1,"",[0,0])
            print ' **************** Input File Not Found **************** '
        else:
            pass

        #To store sav,sub,mon,con,dfx,accc,excel
        sav=[]
        sub=[]
        mon=[]
        con=[]
        dfx=[]
        accc=[]
        excel=[]


        for numcase, row in enumerate(fileinput):
            if row[0]=='0':
                break
            sav.append(row[0]) 
            sub.append(row[1])
            mon.append(row[2])
            con.append(row[3])
            dfx.append(row[4])
            accc.append(row[5])
            excel.append(row[6])


        #To close input file
        fileinput_tmp.close()

        return sav,sub,mon,con,dfx,accc,excel,numcase

class Run:

    #To perform ACCC in all cases 
    def multi_ACCC(self,sav,sub,mon,con,dfx,accc,excel,numcase):
        #newcase=[]

        for i in range(0,numcase,1):
            psspy.base_frequency( 50.0)
            psspy.case(sav[i])
            print'sav file opened'

            """Run ACCC"""
            psspy.dfax([1,1], sub[i], mon[i], con[i], dfx[i])
            print'dfx file created'
            psspy.accc( 0.5,[1,1,0,1,1,1,0],dfx[i],accc[i],"")
            print'acc file created'

            # 's' or 'summary' ACCC Analysis Summary
            # 'e' or 'events' Contingency Events Description
            # 'b' or 'branch' Monitored Branch Flow (MVA)
            # 'i' or 'interface' Monitored Interface Flow (MW)
            # 'v' or 'voltage' Monitored Bus Voltage
            # 'l' or ...
(more)
2013-10-15 23:59:22 -0500 answered a question Close ACCC excel report

I figured this out:

import excelpy
xl = excelpy.workbook()
xl.close()

Will close an open excel workbook created by pssexcel.accc.

But I've got far stranger issues in my script that I might put a separate question up for.

2013-10-15 01:02:35 -0500 asked a question Close ACCC excel report

Hi,

I have a script I use to run ACCC studies that uses the pssexcel.accc command. At the moment it's very basic and just runs a study for whatever case is loaded into PSS/E.

I'm trying to update the script so that it runs on multiple cases recorded in a .dat file.

My issue is that it seems to only give me an ACCC excel report for the last case listed in the .dat file. So what I think I'm missing is some code to save and close each excel report as the code loops through.

How do I save and close an excel workbook created by pssexcel.accc?

Thanks,

Peter

2013-10-07 21:49:01 -0500 received badge  Notable Question (source)
2013-03-25 12:44:21 -0500 received badge  Famous Question (source)
2013-03-25 12:44:21 -0500 received badge  Notable Question (source)
2012-09-21 10:16:46 -0500 received badge  Popular Question (source)
2012-09-12 12:54:34 -0500 received badge  Popular Question (source)
2012-09-12 12:52:03 -0500 received badge  Famous Question (source)
2012-09-12 01:24:58 -0500 received badge  Commentator
2012-09-12 01:24:58 -0500 commented question Python for PSS/E V29.5?

Thanks Jervis, I'll look into it.

2012-09-12 01:24:17 -0500 commented question Is anyone else finding the comments function isn't working?

I see, I'm a bit of an anachronism still using Explorer :), I did this comment with Chrome, cool.

2012-09-06 20:07:55 -0500 asked a question Is anyone else finding the comments function isn't working?

Hi all,

I've visited the forum a couple of times over the last couple of weeks and each time have found that I can't post comments. I've been logged in when I've tried. There's no error message or anything, I just click comment and then nothing happens.

Thanks,

Pete

2012-08-28 18:33:33 -0500 asked a question Python for PSS/E V29.5?

Hi,

I'm doing some analysis where I have to use PSS/E V29.5 and a whole bunch of inherited IPLAN and IDEV scripts and Batch files to get results. Results are output to text files in tricky formats and a lot of manual handling is required.

Could it be possible to use a python script to Open PSS/E 29.5, run all the various files I need to run and also include code that extracts and formats data from the various text file outputs?