Ask Your Question

Change some (not all) branch data using branch_chng

asked 2021-06-10 10:49:08 -0500

NLacouve gravatar image

updated 2021-06-10 12:00:25 -0500

I have an application that produces a list of branches and their dynamic ratings based on temperature (eg: from bus, to bus, ckt ID's, and NEW RATING) from which I want to modify only the ratings of branches, leaving all other data like ownership and impedance unchanged.

When I do this in the PSSE GUI recording to a python script I get something like:

psspy.branch_chng(frombusNum,tobusNum,r"""cktID""",[_i,_i,_i,_i,_i,_i],[_f,_f,_f, newRatingAfloat,newRatingBfloat,newRatingCfloat,_f,_f,_f,_f,_f,_f,_f,_f,_f])

When I integrate the command in my python application, though, I can't pass the default values "i" and "f" to the command. API documentation indicates that the user is responsible for providing values for these defaults. If I pass a blank list for INTGAR and blank floats to the non-rating REALAR lists like this:


PSS\E thinks I want to change these blank float() values back to their defaults, which eliminates the already-defined impedance data. The ownership data (INTGAR, which above is called with a blank list []) remains unchanged. The API expects two lists when calling branch_chng. It will accept a list with nothing in it, but won't accept a list with elements that have NoneType values if it expects float or int. For example, this returns a Type error:


My question is: Do I have to call the API command BRNDAT to get the REALAR values that I don't want to change, or is there a way to call branch_chng without supplying or overwriting the data I don't want to change?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2021-06-11 11:42:01 -0500

perolofl gravatar image

Forget your "solution".

Use this to define the variables for the default values:

import psspy
psspy.branch_chng(frombusNum,tobusNum,r"""cktID""",[_i,_i,_i,_i,_i,_i],[_f,_f,_f, newRatingAfloat,newRatingBfloat,newRatingCfloat,_f,_f,_f,_f,_f,_f,_f,_f,_f])
edit flag offensive delete link more


Oof, I should have known that already. Thank you so much!

NLacouve gravatar imageNLacouve ( 2021-06-11 13:16:42 -0500 )edit

answered 2021-06-10 11:51:06 -0500

NLacouve gravatar image

updated 2021-06-10 11:59:31 -0500

Answering my question for posterity. Not an elegant solution, but this is the workaround that I currently have developed for my application:

BrImp = psspy.brndt2(int(fromBusNum),int(toBusNum),str(cktID),'RX') #get complex impedance for the branch
if BrImp[0] == 0:
    Cmplx_BrImp = complex(BrImp[1])
    Brn_Chrging = psspy.brndat(int(fromBusNum),int(toBusNum),str(cktID),'CHARG')[1] #get the charging data for the branch
    REALAR.insert(0,Cmplx_BrImp.real) #br resistance pu
    REALAR.insert(1,Cmplx_BrImp.imag) #br reactance pu
    REALAR.insert(2,float(Brn_Chrging)) #br charging 
    REALAR.insert(3, float(NewRATINGA)) #New Rating A
    REALAR.insert(4, float(NewRATINGB)) #New Rating B
    REALAR.insert(5, float(NewRATINGC)) #New Rating C

Oddly, even though the API won't accept NoneType values in the lists INTGAR and REALAR, it does accept a shorter-than-expected list for REALAR. Even though per API documentation REALAR is supposed to be 15 arguments long, it accepts this 6 element list and leaves the final 9 branch characteristic elements unchanged. The order of the shortened list must conform to the documentation. So I can get away with only calling brndt2() once and brndat() once to get existing impedance and charging data, since those are the only elements in the list REALAR that come before the Rating data.

This works, but doesn't feel "right." Calling brndt2() and brndat() iteratively for each rating change is needlessly expensive. Would still appreciate any other ideas!

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


Asked: 2021-06-10 10:49:08 -0500

Seen: 84 times

Last updated: Jun 11