Ask Your Question
0

Change some (not all) branch data using branch_chng

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

NLacouve gravatar image

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

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:

psspy.branch_chng(int(fromBusNum),int(toBusNum),str(cktID),[],[float(),float(),float(),float(RATINGA),float(RATINGB),float(RATINGC),float(),float(),float(),float(),float(),float(),float(),float(),float()])

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:

psspy.branch_chng(int(fromBusNum),int(toBusNum),str(cktID),[],[None,None,None,float(RATINGA),float(RATINGB),float(RATINGC),None,None,None,None,None,None,None,None,None])

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
0

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

perolofl gravatar image

Forget your "solution".

Use this to define the variables for the default values:

import psspy
_i=psspy.getdefaultint()
_f=psspy.getdefaultreal()
_s=psspy.getdefaultchar()
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

Comments

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

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

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

NLacouve gravatar image

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

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

INTGAR = []
REALAR = []
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
    psspy.branch_chng(int(fromBusNum),int(toBusNum),str(cktID),INTGAR,REALAR)

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

Stats

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

Seen: 637 times

Last updated: Jun 11 '21