Ask Your Question
0

Storing Short Circuit Analysis Data

asked 2017-11-19 20:21:53 -0600

anonymous user

Anonymous

Hi,

So I'm extremely new to both Python and PSSE and am trying to figure out how I can extract the fault currents for busses using Python. My end goal is to export this data to excel, however, I'm confused with how to actually store the data I'm looking for into my variables.

I've been using this previous thread as a guideline.

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

Where can I find the methods that the object provided in the link above ( rlst = pssarrays.ascccurrents(subsystem, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 2, 2, 1, 1, 1, '', '', '') ) contains?

Thanks!

edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted
0

answered 2017-12-13 11:31:39 -0600

nelak gravatar image

updated 2017-12-13 11:35:29 -0600

Approximation of how I do this:

Running Short circuit and building lots of text files:

def splitter(self, inputlist, chunk=100):
        """ Breaks inputlist into a list of lists with size chunk."""
        chunks = [inputlist[x:x + chunk] for x in range(0, len(inputlist), chunk)]
        return chunks

def RunASCC_study(self, options):
        ascc_results = []

    # create subsystem of areas in user input
    self.createSubsystemOfAreas(options['Areas'])

    # find all buses in study areas
    study_buses = self.returnBusesInSubsystem(sid=0, in_service_only=False, bus_property='Number')

    # make list of buses manageable size for PSS/E report window
    self.log('Segmenting %d study buses.' % len(study_buses))
    study_buses = self.splitter(study_buses, chunk=100)

    # loop thru lists of buses, create subsystems, and perform ASCC on them
    self.log('Created %d segments of size %d.\nPerforming ASCC portion of study.' % (
             len(study_buses), len(study_buses[0])))
    for i, segment_of_study_buses in enumerate(study_buses, 1):
        self.createSubsystemOfBuses(segment_of_study_buses, sid=0)
        self.log('Running ASCC for segment %d' % i)
        self.__ASCC(i, self.report_directory, 0)

def __ASCC(self, out_file_identifier, out_file_path, subsystem, gen_scfiles=False):
    """
    :param out_file_identifier: increments file names
    :param out_file_path: gives folder to place reports in
    :param subsystem: specifies subsystem id for psspy.ascc api
    :param gen_scfiles: option flag for scfile output of psspy.ascc api
    :return:
    """
    ierr = self.psspy.report_output(2, os.path.join(out_file_path, '%d_ASCC_rawData.txt' % out_file_identifier))
    if ierr: self.log('Error on ASCC segment %s ier %s' % (out_file_identifier, ierr), 'error')
    # class fault analysis conditions
    # ierr = self.psspy.flat_2([1, 1, 1, 2, 1, 2, 1, 3], [1, 1])

    if gen_scfiles:
        if not os.path.exists(os.path.join(out_file_path, 'scfiles')):
            os.makedirs(os.path.join(out_file_path, 'scfiles'))
        scfile_path = os.path.join(out_file_path, 'scfiles', '%d_scfile.sc' % out_file_identifier)
    else:
        scfile_path = ""

    ierr = self.psspy.ascc_3(subsystem, 0, [1, 1, 0, 1, 0, 2, 0, 1, 0, 1, 1, 0, 0, 2, 2, 1, 1], [1],
                                 '', '', scfile_path)
    if ierr: self.log('Error on ASCC segment %s' % out_file_identifier, 'error')

Parsing text files:

def __compileASCCresults(self, folder):
    """
    Parses a folder and build ASCC results from PSSE ASCC report txt files.
    :param folder: Directory of containing psse reports.
    :return: List of result objects.
    """

    # get list of report filepaths
    list_of_ascc_reports = []
    for txtfile in os.listdir(folder):
        if txtfile.endswith("ASCC_rawData.txt"):
            list_of_ascc_reports.append(os.path.join(folder, txtfile))

    # file in memory
    data = []
    for report in list_of_ascc_reports:
        data_file = open(report, 'rU')
        data.extend(data_file.readlines())

    # parse file
    list_of_result_objects = []
    options = []
    while data:
        line = data.pop(0)
        line = line.rstrip().rstrip('\r\n')
        # build options
        if line.upper().startswith('OPTIONS USED'):
            # only need options once because its the same
            if not options:
                options.append(line)
                line = data.pop(0).rstrip().rstrip('\r\n')
                while line:
                    options.append(line.split('-', 1)[1])
                    line = data.pop(0).rstrip().rstrip('\r\n')
            else:
                pass
        # build fault result objects
        temp_list = []
        if line.startswith('AT BUS'):
            while line != "-----------------------------------------------------------------------------------------------------------------------------------------------":
                temp_list.append(line)
                line = data.pop(0).rstrip().rstrip('\r\n')
            list_of_result_objects.append(self.ASCCfaultResult(temp_list, options, self.log))
    self.log('Read in %d ASCC data files.' % len(list_of_ascc_reports))
    return list_of_result_objects

class ASCCfaultResult():
    """ Creates an object from a list of text lines ...
(more)
edit flag offensive delete link more

Comments

As I am new to python and PSSE, I was unable to understand your code... Can u please share detailed code with me.. Mail id 359venkat@gmail.com It would help in exploring study analysis

Sandeep gravatar imageSandeep ( 2020-02-04 08:33:38 -0600 )edit
0

answered 2017-11-28 03:36:36 -0600

perolofl gravatar image

To print the help text inside PSSE do the following:

import pssarrays
help(pssarrays.ascc_currents)
edit flag offensive delete link more
0

answered 2017-11-20 20:47:26 -0600

jconto gravatar image

To print the 'help' text in the module pssarrays, run the following v.33 py code:

import os,sys
psseversion = 33
if psseversion== 34 or psseversion== 33:
   exec('import psse%s'%psseversion)
else:
   pssepath = r"C:\Program Files (x86)\PTI\PSSE32\PSSBIN"
   if pssepath not in sys.path:
      sys.path.append(pssepath)
#--------------------------------
import pydoc
import pssarrays
#--------------------------------
strhelp = pydoc.render_doc(pssarrays, "Help %s")
print strhelp
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Question Tools

2 followers

Stats

Asked: 2017-11-19 20:21:53 -0600

Seen: 1,673 times

Last updated: Dec 13 '17