Python和PSS / E.

时间:2012-07-03 18:10:16

标签: python psse

我试图通过使用python程序来改变PSS / E中的总线负载。所以我试图在python中编写一个脚本,我可以在PSS / E中将两个总线之间的负载更改为不同的值。

4 个答案:

答案 0 :(得分:1)

您可以使用名为" LOAD_CHNG_4"的API例程(在API.pdf文档中搜索此例程)。该例程属于一组加载数据规范函数。它可用于修改工作案例中现有负载的数据。

答案 1 :(得分:1)

查看PSSE python API的第二章。它完全涵盖了不断变化的潮流数据。可以使用总线编号和加载ID来引用加载数据。手动输入装载数据本身时,可以更改铭牌中显示的所有参数。使用下面的此功能更改负载:

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

有关详细信息,请参阅API手册的第728页。

答案 2 :(得分:1)

我写了这个类来处理PSSE中的加载...它最初是用SQL炼金术发送的,所以它有一些我删除的附加内容:

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)

如果你调用名为的函数," updateCase"它将采用任何值存储在加载对象中并刷新PSSE的情况。

答案 3 :(得分:0)

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

我在博客文章中发现了如何从PSSE运行Python命令。我不认为你的问题与ASP.NET有什么关系。