Ask Your Question
0

Interconnection capacity screening

asked 2019-08-12 11:54:02 -0600

lodea415 gravatar image

Hi,

Does anyone have a reference on how to write code that can screen the transfer capacity at a large number of busses in a system? The purpose is to create a screening process for identifying where thermal capacity exists to integrate new generation.

Thx for any help!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-08-13 04:39:37 -0600

drsgao gravatar image

Maybe something like the following. Give you a sorted CSV for post processing.

# -*- coding: utf-8 -*- 

'''
Written for PSSE v33.4 and Python 2.7.0.

For showing system loading.
'''

import psspy

import os, operator, csv

__version__ = '1.0.0'
__date__    = '2019.08.13'

def showLoading(int_sid, int_tie, int_flag, str_rate_opt='PCTMVA', int_round=4, str_path_csv_out=''):
    '''
    This function finds the loading of the branches and optionally output the findinding as a CSV.

    Parameters
    ----------
    int_sid : int
        The subsystem ID.

    int_tie : int
        Tie line option.

    int_flag : int
        Subsystem branch option.

    str_rate_opt : str
        Branch flow optional string.

        Default = 'PCTMVA', i.e., percent MVA loading of Rating A.

    int_round : int
        Percentage rounding option. 
        Default = 4, i.e., round to the 4th decimal number.

    str_path_csv_out : str
        Optional. The output CSV file full path.

        If an empty string is given, the findings will be printed to the console.

        Default = empty string.

    Returns
    -------
    None.

    Reference
    ----------------------
    PSSE API manual.
    '''

    # on exception, through exception and stop the script
    psspy.throwPsseExceptions = True

    _, list_from_bus_names = psspy.abrnchar(sid=int_sid, ties=int_tie, flag=int_flag, string='FROMEXNAME')
    list_from_bus_names    = list_from_bus_names[0]

    _, list_from_bus_no    = psspy.abrnint(sid=int_sid, ties=int_tie, flag=int_flag, string='FROMNUMBER')
    list_from_bus_no       = list_from_bus_no[0]

    _, list_to_bus_names   = psspy.abrnchar(sid=int_sid, ties=int_tie, flag=int_flag, string='TOEXNAME')
    list_to_bus_names      = list_to_bus_names[0]

    _, list_to_bus_no      = psspy.abrnint(sid=int_sid, ties=int_tie, flag=int_flag, string='TONUMBER')
    list_to_bus_no         = list_to_bus_no[0]

    _, list_brn_id         = psspy.abrnchar(sid=int_sid, tie=int_tie, flag=int_flag, string='ID')
    list_brn_id            = list_brn_id[0]


    list_load_percent_from_bus = []

    for i in xrange(0, len(list_from_bus_no)):

        _, dbl_temp = psspy.brnmsc(list_from_bus_no[i], list_to_bus_no[i], list_brn_id[i], string=str_rate_opt)

        list_load_percent_from_bus.append(dbl_temp)

    list_load_percent_from_bus = [round(j, int_round) for j in list_load_percent_from_bus]

    list_load_percent_to_bus = []

    for i in xrange(0, len(list_to_bus_no)):

        _, dbl_temp = psspy.brnmsc(list_to_bus_no[i], list_from_bus_no[i], list_brn_id[i], string=str_rate_opt)

        list_load_percent_to_bus.append(dbl_temp)


    list_load_percent_to_bus = [round(j, int_round) for j in list_load_percent_to_bus]

    list_data_from_bus = zip(list_from_bus_no, list_from_bus_names, list_load_percent_from_bus)
    list_data_to_bus   = zip(list_to_bus_no, list_to_bus_names, list_load_percent_to_bus)

    list_data_all      = list_data_from_bus + list_data_to_bus

    # remove duplicates
    list_data_all = list(dict.fromkeys(list_data_all))

    # sort according to percentages
    list_data_all = sorted(list_data_all, key=operator.itemgetter(-1, 0))

    list_header   = ['Bus No.', 'Bus Name', r'% of MVA Loading']

    list_data_all = [list_header] + list_data_all

    if str_path_csv_out:

        with open(str_path_csv_out, 'wb') as fout:

            w = csv.writer(fout)

            w.writerows(list_data_all)

        print('Output file : ' + str_path_csv_out)

    else:

        print(list_data_all)



if __name__ == '__main__':

    # subsystem contains all buses
    int_sid = -1

    # for both interior subsystem branches and tie branches
    int_tie = 3

    # all non-transformer branches
    int_flag = 2

    str_rate_opt='PCTMVA'

    # percentage rounding
    int_round = 4

    # the output CSV file path, change this as desired
    # this puts it in the same folder as the script
    str_path_csv_out = os.path.join(os.getcwd(), 'system_loading.csv')

    showLoading(int_sid=int_sid, int_tie=int_tie, int_flag=int_flag, str_rate_opt=str_rate_opt, int_round=int_round, str_path_csv_out=str_path_csv_out)
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

1 follower

Stats

Asked: 2019-08-12 11:54:02 -0600

Seen: 249 times

Last updated: Aug 13 '19