user1499609
user1499609

Reputation: 11

Python and PSS/E

I am trying to have the bus loads in PSS/E to change by using python program. So I am trying to write a script in python where I could change loads to different values between two buses in PSS/E.

Upvotes: 1

Views: 7747

Answers (4)

Jimmy
Jimmy

Reputation: 23

I wrote this class to handle loads in PSSE...It originally sent with SQL alchemy so it has some extras which I removed:

class Load():

    def __init__(self,busnumber,loadID):
        # Initialize the Branch Class Instance Variables to a Default 0; Except for the From,To and Circuit ID
        self.bus = Bus(busnumber)
        self.busI = busnumber
        self.loadID = loadID
        self.status = 0
        self.Pload = 0.0
        self.Qload = 0.0

        self.errorList = []
        self.init()
    def init(self):
        # Setup the load from the case
        # Check to see if bus exists
        busOk = self.bus.init()
        if not busOk[0]: 
            return (False,self.bus.number,"The bus number %d is invalid or does not exist..." % self.bus.number)
        if psspy.loddt2(self.bus.number,self.loadID,'TOTAL','ACT')[0] != 0:
            return (False,False)
        Scomplex = self.check(psspy.loddt2(self.bus.number,self.loadID,'TOTAL','ACT'),'loddt2','ACT')               # Grab the S vector/phasor from the power flow case for the load specified at the BUS number
        self.Pload = Scomplex.real
        self.Qload = Scomplex.imag
        self.status = self.check(psspy.lodint(self.bus.number,self.loadID,'STATUS'),'lodint','STATUS')              # Grab the Status of the Load

        return (True,self.bus.number)

    def check(self,tuple,funName,subFun):
        # Define Error Messages that should be accesable by the end-user and developer
        loddt2 = {
            0:'No error; P and Q or CMPVAL returned',
            1:'Bus not found; P and Q or CMPVAL unchanged.',
            2:'Load not found; P and Q or CMPVAL unchanged.',
            3:'Bus type code is not 1, 2 or 3; P and Q or CMPVAL returned.',
            4:'Load out-of-service; P and Q or CMPVAL returned.',
            5:'Invalid value of STRING1 or STRING2; P and Q or CMPVAL unchanged.'
        }   

        lodint = {
            0:'No error; IVAL returned.',
            1:'Bus not found; IVAL unchanged.',
            2:'Load not found; IVAL unchanged.',
            3:'Bus type code is not 1, 2 or 3; IVAL returned.',
            4:'Load out-of-service; IVAL returned.',
            5:'Invalid value of STRING; IVAL unchanged.'
        }       

        funDic = {
            'loddt2':loddt2,
            'lodint':lodint
        }

        # Retrieve the Right Error Message
        list = funDic[funName]
        msg = list[tuple[0]]
        if tuple[0] > 0:
            logging.debug("Function Name:  %s  Sub Function Name:  %s   Error Message: %s"%(funName,subFun,msg))

        return tuple[1]

    def setLoad(self,loadP):
        self.Pload = loadP
    def updateCase(self):

        # Setup Defaults
        _i = psspy.getdefaultint()
        _f = psspy.getdefaultreal()
        cDef = psspy.getdefaultchar()
        psspy.load_data_3(self.bus.number,self.loadID,[self.status,_i,_i,_i,_i],[self.Pload, self.Qload,_f,_f,_f,_f])

    # To String Method 
    def __repr__(self):
        return "%d %s %d %d" %(self.bus.number,self.loadID,self.Pload,self.Qload)

    # printf Statement that Dumps information to CMD line...Homeage to C and C++
    def printf(self):
        print "\n Bus: %d \n Load ID: %s \n MW Value: %d \n MVAR Value: %d \n" % (self.bus.number,self.loadID,self.Pload,self.Qload)

If you call the function named, "updateCase" it will take what ever values are stored in the load object and refresh the PSSE case.

Upvotes: 1

bud
bud

Reputation: 485

Look at chapter II of the PSSE python API. It completely covers changing power flow data. Load data can be referenced with the bus number and load ID. You can change all the parameters you see in the nameplate when you manually enter in the load data itself. Use this function below to change the load:

ierr = psspy.load_chang(bus_number, load_id, intgar,realar)

See page 728 of the API manual for more info.

Upvotes: 1

Deanna1125
Deanna1125

Reputation: 33

You can use API routine called "LOAD_CHNG_4" (search for this routin in API.pdf documentation). This routine belongs to the set of load data specification functions. It can be used to modify the data of an existing load in the working case.

Upvotes: 1

hugowurstl
hugowurstl

Reputation: 1

http://www.whit.com.au/blog/2011/07/run-psse-from-python-and-not-other-way/

I found this blog post about how to run Python command from PSSE. I don't think that your question has anything to do with ASP.NET though.

Upvotes: 0

Related Questions