简体   繁体   English

如何在PSSE上查找/修复属性错误?

[英]How to find / fix attribute error on PSSE?

I am receiving an error when trying to find total load and generation in an area. 尝试查找某个区域的总负载和发电量时出现错误。 I keep getting an attribute error. 我不断收到属性错误。 WHere can i find specific attributes for the psspy.ardat code. 在这里,我可以找到psspy.ardat代码的特定属性。 For the load attribute, .real is correct but for generation attribute, .complex is incorrect. 对于load属性, .real是正确的,但是对于生成属性, .complex是不正确的。 I keep getting this error: AttributeError: 'complex' object has no attribute 'complex' 我不断收到此错误: AttributeError: 'complex' object has no attribute 'complex'

[ierr, sysload_N] = psspy.ardat(1, 'LOAD')
[ierr, sysload_D] = psspy.ardat(2, 'LOAD')
[ierr, sysload_M] = psspy.ardat(3, 'LOAD')
[ierr, sysgen_NI] = psspy.ardat(1, 'GEN')
[ierr, sysgen_DI] = psspy.ardat(2, 'GEN')
[ierr, sysgen_MI] = psspy.ardat(3, 'GEN')
sysload_TOT = sysload_N.real + sysload_D.real+sysload_M.real
output = 'Total Load iS #: {} MW\t'
formatted = output.format(sysload_TOT)
sysgen_TOT = sysgen_NI.complex + sysgen_DI.real+sysgen_MI.complex
output2 = 'Total Generation iS #: {} MW\t'
formatted2 = output2.format(sysgen_TOT)
sysLG_TOT=(sysload_TOT-sysgen_TOT)/(sysload_TOT)*100
output3 = 'Total Imports iS #: {}%\t'
formatted3 = output3.format(sysLG_TOT)
output.append(formatted)
output2.append(formatted2)
output3.append(formatted3)
print(output)
print(output2)
print(output3)

The function psspy.ardat() returns [ierr, cmpval] where ierr is an integer object and cmpval is a complex object as described by the docstring below and repeated in the API documentation: 函数psspy.ardat()返回[ierr, cmpval] ,其中ierr是一个integer对象,而cmpval是一个complex对象,如下面的文档字符串所述,并在API文档中重复进行:

"""
Use this API to return area totals.

Python syntax:

ierr, cmpval  = ardat(iar, string)

where:

Integer IAR Area number (input).

Character STRING String indicating the area total desired (input).
    = LOAD, Total owner load by bus owner assignment (net of load plus in-service distributed
            generation on load feeder).
    = LOADLD, Total owner load by load owner assignment.
    = LDGN, Total distributed generation on load feeder by bus owner assignment.
    = LDGNLD, Total distributed generation on load feeder by load owner assignment.
    = GEN, Total owner generation.
    = LOSS, Total owner losses.
    = INT, Net area interchange.
    = INDMAC, Total owner induction machine powers by bus owner assignment.
    = INDMACMC, Total owner induction machine powers by machine owner assignment.
    = INDGEN, Total owner induction generator powers by bus owner assignment.
    = INDGENMC, Total owner induction generator powers by machine owner assignment.
    = INDMOT, Total owner induction motor powers by bus owner assignment.
    = INDMOTMC, Total owner induction motor powers by machine owner assignment.

Complex CMPVAL Desired complex power (output).

Integer IERR Error code (output).
     = 0, No error; 'P' and 'Q' or 'CMPVAL' returned.
     = 1, Area number < 0 or > largest allowable area number; 'P' and 'Q' or 'CMPVAL' unchanged.
     = 2, No in-service buses with in-service loads (for 'LOAD'), no in-service loads (for
          'LOADLD'), no type 2 or type 3 buses (for 'GEN'), no branches (for 'LOSS'), or no ties
          (for 'INT') in area; 'P' and 'Q' or 'CMPVAL' unchanged.
     = 3, Area not found; 'P' and 'Q' or 'CMPVAL' unchanged.
     = 4, Bad 'STRING' value; 'P' and 'Q' or 'CMPVAL' unchanged.

"""

A complex object is defined in the Python standard library and has attributes .real and .imag but does not have a .complex attribute; complex对象在Python标准库中定义的,并且具有属性.real.imag但不具有.complex属性; this is why you are getting the AttributeError . 这就是为什么要获取AttributeError Try the following: 请尝试以下操作:

sysload_TOT = sysload_N.real + sysload_D.real + sysload_M.real
output1 = 'Total Load iS #: {} MW\t'
formatted = output.format(sysload_TOT)
sysgen_TOT = sysgen_NI.real + sysgen_DI.real + sysgen_MI.real
output2 = 'Total Generation iS #: {} MW\t'
formatted2 = output2.format(sysgen_TOT)
sysLG_TOT = 100 * (sysload_TOT - sysgen_TOT) / (sysload_TOT)
output3 = 'Total Imports is #: {}%\t'
formatted3 = output3.format(sysLG_TOT)

print(formatted)
print(formatted2)
print(formatted3)

If you are going to be performing this functionality often I would recommend the following approach: 如果您打算经常执行此功能,我建议您采用以下方法:

# create a subsystem which contains the areas of interest
psspy.asys(sid=0, num=3, areas=[1,2,3])

# return an array of real values for subsystem areas
ierr, rarray = psspy.aareareal(sid=0, string=['PLOAD', 'PGEN', 'PINT'])

Whenever you are using psspy functions referring to the documentation is very important. 每当您使用psspy函数时,参考文档都非常重要。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM