Getting Started

OpenDSSDirect.py is a Python interface to the C calling interface of a OpenDSS shared library.

To use OpenDSSDirect.py open a Python interpreter and type the following command.

[1]:
import opendssdirect as dss

The dss module has submodules that act as interfaces to various components in OpenDSS. The full list of the modules is shown below.

dss.ActiveClass
dss.Basic
dss.Bus
dss.CapControls
dss.Capacitors
dss.Circuit
dss.CktElement
dss.Element
dss.Executive
dss.Fuses
dss.Generators
dss.Isource
dss.Lines
dss.LoadShape
dss.Loads
dss.Meters
dss.Monitors
dss.PDElements
dss.PVsystems
dss.Parser
dss.Properties
dss.Reclosers
dss.RegControls
dss.Relays
dss.Sensors
dss.Settings
dss.Solution
dss.SwtControls
dss.Topology
dss.Transformers
dss.Vsources
dss.XYCurves

These modules are the higher level interface to OpenDSS. The dss module also has a lower level interface in dss.dss_lib. The higher level interface uses the lower level interface to call the appropriate functions. For the most part, a OpenDSSDirect.py user will not need to use the lower level interface, but knowing that it exists can be useful.

The utils module implements helper functions that make it easier to use the interface.

[2]:
from opendssdirect.utils import run_command
[3]:
run_command('Redirect ../../tests/data/13Bus/IEEE13Nodeckt.dss');

This function is also provided on the base module

[4]:
dss.run_command('Redirect ../../tests/data/13Bus/IEEE13Nodeckt.dss');

We can print all bus names using the following.

[5]:
for i in dss.Circuit.AllBusNames():
    print(i)
sourcebus
650
rg60
633
634
671
645
646
692
675
611
652
670
632
680
684

Using the pandas interface

An optional pandas interface is also provided in the package, so making it easier to get data from OpenDSS. See installation instructions for how to install the requirements for this interface.

All load data can be attained using the loads_to_dataframe function.

[6]:
dss.utils.loads_to_dataframe()
[6]:
AllocationFactor CFactor CVRCurve CVRvars CVRwatts Class Count Daily Duty Growth ... Xneut Yearly ZipV kV kVABase kW kWh kWhDays kvar puSeriesRL
611 0.5 4 2 1 1 15 ... 0 [] 2.4 187.883 170 0 30 80 50
634a 0.5 4 2 1 1 15 ... 0 [] 0.277 194.165 160 0 30 110 50
634b 0.5 4 2 1 1 15 ... 0 [] 0.277 150 120 0 30 90 50
634c 0.5 4 2 1 1 15 ... 0 [] 0.277 150 120 0 30 90 50
645 0.5 4 2 1 1 15 ... 0 [] 2.4 211.009 170 0 30 125 50
646 0.5 4 2 1 1 15 ... 0 [] 4.16 265.187 230 0 30 132 50
652 0.5 4 2 1 1 15 ... 0 [] 2.4 154.208 128 0 30 86 50
670a 0.5 4 2 1 1 15 ... 0 [] 2.4 19.7231 17 0 30 10 50
670b 0.5 4 2 1 1 15 ... 0 [] 2.4 76.1577 66 0 30 38 50
670c 0.5 4 2 1 1 15 ... 0 [] 2.4 135.326 117 0 30 68 50
671 0.5 4 2 1 1 15 ... 0 [] 4.16 1330.27 1155 0 30 660 50
675a 0.5 4 2 1 1 15 ... 0 [] 2.4 520.889 485 0 30 190 50
675b 0.5 4 2 1 1 15 ... 0 [] 2.4 90.6863 68 0 30 60 50
675c 0.5 4 2 1 1 15 ... 0 [] 2.4 359.227 290 0 30 212 50
692 0.5 4 2 1 1 15 ... 0 [] 4.16 227.379 170 0 30 151 50

15 rows × 37 columns

Similarly, all transformer data can be attained using the transformers_to_dataframe function

[7]:
dss.utils.transformers_to_dataframe()
[7]:
Count IsDelta MaxTap MinTap Name NumTaps NumWindings R Rneut Tap Wdg XfmrCode Xhl Xht Xlt Xneut kV kVA
reg1 5 0 1.1 0.9 reg1 32 2 5e-05 -1 1.05625 2 0.0001 0.35 0.3 0 2.4 1666
reg2 5 0 1.1 0.9 reg2 32 2 5e-05 -1 1.0375 2 0.0001 0.35 0.3 0 2.4 1666
reg3 5 0 1.1 0.9 reg3 32 2 5e-05 -1 1.05625 2 0.0001 0.35 0.3 0 2.4 1666
sub 5 0 1.1 0.9 sub 32 2 5e-06 -1 1 2 8e-05 0.04 0.04 0 4.16 5000
xfm1 5 0 1.1 0.9 xfm1 32 2 0.0055 -1 1 2 0.02 0.01 0.01 0 0.48 500

A full list of available functions is listed below:

dss.utils.capacitors_to_dataframe
dss.utils.fuses_to_dataframe
dss.utils.generators_to_dataframe
dss.utils.isource_to_dataframe
dss.utils.lines_to_dataframe
dss.utils.loads_to_dataframe
dss.utils.loadshape_to_dataframe
dss.utils.meters_to_dataframe
dss.utils.monitors_to_dataframe
dss.utils.pvsystems_to_dataframe
dss.utils.reclosers_to_dataframe
dss.utils.regcontrols_to_dataframe
dss.utils.relays_to_dataframe
dss.utils.sensors_to_dataframe
dss.utils.transformers_to_dataframe
dss.utils.vsources_to_dataframe
dss.utils.xycurves_to_dataframe