OpendssdirectEnhancer reference

class krangpower.enhancer.OpendssdirectEnhancer(stack=None, oe_id='OpenDSSEnhancer')

OpendssdirectEnhancer constitues an OpenDSSDirect.py wrapper and overhaul, and it is usable in and by itself as a substitute of the OpenDSSDirect.py module when interested in the additional functionality.

OpendssdirectEnhancer is designed to behave exactly as the opendssdirect MODULE by wrapping all its calls, but adds some handy functionality:

  • Items returned as a list of floats (e.g., <>.Circuit.Losses(), <>.Bus.Voltages()…) are returned as lists of complex numbers, matrices of [nterm x ncond], etc. as is appropriate. How the results returned by opendss are treated is decided in the configuration files of krangpower.

  • Structured items such as opendssdirect.Circuit.SistemY() are returned as pandas.DataFrame for easier manipulation, export…

  • Items come, where appropriate, as Quantities (from the pint package) with the appropriate measurement unit. This enables easy conversions and secures against miscalculations.

  • OpendssdirectEnhancer supports easy and intuitive element exploration through bracket indicization with the names, either fully qualified or simple, of the circuit’s elements in the way shown below:

    >>> myOE = OpendssdirectEnhancer()
    >>> myOE.utils.run_command("Clear")
    ''
    >>> myOE.utils.run_command("New object = circuit.myckt bus1=sourcebus basekv=11.0 pu=1.0 angle=0.0 phases=3")
    ''
    >>> myOE.utils.run_command("New load.myload bus1=sourcebus kw=10.0 kv=11.0 basefreq=50.0")
    ''
    >>> myOE.utils.run_command("solve")
    ''
    >>> myOE['load.myload'].CFactor() # taken from the Loads interface
    4.0
    >>> abs(myOE['myload'].Currents()[0,1]) # taken from the CktElement interface
    <Quantity(0.5964385133615372, 'ampere')>
    

As in the example above, the user needs not to worry about selecting the item with MOE.Circuit.SetActiveElement(‘load.myload’), MOE.Laods.Name(‘load.myload’); the OpendssdirectEnhancer takes care of the selections automatically.

The OpendssdirectEnhancer members are dynamically generated from those of OpenDSSDirect.py, so the api reference is the same.

__call__(*args)

Call self as a function.

__getattr__(item)

Directly wraps the calls to OpenDSSDirect.py.

__getitem__(item)

Bracket indicization looks for an object with the name desired and returns a nice packed element whose attributes are the same present in the OpenDSSDirect.py api, but without ever worrying again about SetActiveElement() and the likes.

__init__(stack=None, oe_id='OpenDSSEnhancer')

Initialize self. See help(type(self)) for accurate signature.

__repr__()

Return repr(self).

__str__()

Return str(self).

classmethod get_all_names()

Gets the fully qualified names of the elements, plus buses, loadshapes and xycurves. It’s worth noting that object such as LineCodes, WireCodes, etc are not as of today retrievable, because their names are not accessible in a direct way.

log_line(line: str, lvl=10)

Logs a line in the command log.

txt_command(cmd_str: str, echo=True)

Performs a text interface call with the argument passed and logs command and response. The log output can be suppressed by setting the keyword argument echo=False.