Python与PSS/E
我试图使用python程序更改PSS/E中的总线负载。因此,我尝试用python编写一个脚本,可以在PSS/E中的两条总线之间将负载更改为不同的值。 我发现了这篇关于如何从PSSE运行Python命令的博文。不过,我认为你的问题与ASP.NET无关Python与PSS/E,python,psse,Python,Psse,我试图使用python程序更改PSS/E中的总线负载。因此,我尝试用python编写一个脚本,可以在PSS/E中的两条总线之间将负载更改为不同的值。 我发现了这篇关于如何从PSSE运行Python命令的博文。不过,我认为你的问题与ASP.NET无关 我发现了这篇关于如何从PSSE运行Python命令的博文。不过,我认为你的问题与ASP.NET无关 您可以使用名为“LOAD_CHNG_4”的API例程(在API.pdf文档中搜索此路由)。此例程属于负载数据规范函数集。它可用于修改工况中现有荷载的
我发现了这篇关于如何从PSSE运行Python命令的博文。不过,我认为你的问题与ASP.NET无关 您可以使用名为“LOAD_CHNG_4”的API例程(在API.pdf文档中搜索此路由)。此例程属于负载数据规范函数集。它可用于修改工况中现有荷载的数据 您可以使用名为“LOAD_CHNG_4”的API例程(在API.pdf文档中搜索此路由)。此例程属于负载数据规范函数集。它可用于修改工况中现有荷载的数据 请看PSSE python API的第二章。它完全涵盖了不断变化的潮流数据。负载数据可通过总线号和负载ID引用。手动输入负载数据本身时,您可以更改铭牌上显示的所有参数。使用以下功能更改负载:
ierr = psspy.load_chang(bus_number, load_id, intgar,realar)
更多信息请参见API手册第728页 请看PSSE python API的第二章。它完全涵盖了不断变化的潮流数据。负载数据可通过总线号和负载ID引用。手动输入负载数据本身时,您可以更改铭牌上显示的所有参数。使用以下功能更改负载:
ierr = psspy.load_chang(bus_number, load_id, intgar,realar)
更多信息请参见API手册第728页 我编写这个类是为了处理PSSE中的负载……它最初是与SQL alchemy一起发送的,因此它有一些额外的功能,我删除了这些功能:
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”的函数,它将获取load对象中存储的所有值,并刷新PSSE案例。我编写这个类是为了在PSSE中处理负载……它最初是通过SQL alchemy发送的,因此它有一些额外的内容,我删除了这些内容:
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”的函数,它将获取load对象中存储的任何值,并刷新PSSE案例