Python functions for extracting, executing routines, etc. from projects modeled in OpenDSS
With pip
pip install openpy-fx-tools-dss
First, in the IDE (Integrated Development Environment) of preference, we import the library:
import openpy_fx_tools_dss as fx_dss
The library has IEEE example circuits (Table 1), which can be found in the OpenDSS installation files.
For the example files the class examples_lib()
is called:
Table 1. Sample tests
Name | Option | DSS files | xlsx file |
---|---|---|---|
13BusIEEE | 1 | x | x |
37BusIEEE | 2 | x | x |
123BusIEEE | 3 | x | x |
test = fx_dss.examples_lib()
To use the .DSS files:
DSS_path = test.load_examples_DSS()
To use .xlsx file:
xlsx_path = test.load_examples_xlsx()
The functions that generate OpenDSS scripts to a .xlsx file and vice versa are inside the xlsx_DSS_xlsx()
class and are called in the following way:
xlsx = fx_dss.xlsx_DSS_xlsx()
An .xlsx template with the OpenDSS elements is created by calling the create_template_xlsx
function as follows:
xlsx.create_template_xlsx(
path_save: str = None,
prj_name: str = 'default',
elem_list: list = [],
all_elem: bool = True
)
The circuit data is entered in the .xlsx template. Each sheet of the template corresponds to the elements that are modeled in OpenDSS. When generating the OpenDSS scripts, only the cells that are not empty are considered.
For this purpose, the xlsx_to_OpenDSS
function is called as follows:
xlsx.xlsx_to_OpenDSS(
xlsx_path=xlsx_path['xlsx_path'],
path_save=xlsx_path['path_save'],
prj_name=DSS_path['prj_name']
)
Important:
- Do not alter the names of the sheets, and columns, since the element will not be taken into account.
- The form of data entry must coincide with the OpenDSS specifications.
From an OpenDSS file, the xlsx template can be generated. For this purpose, the OpenDSS_to_xlsx
function is used as follows:
xlsx.OpenDSS_to_xlsx(
DSS_path=DSS_path['DSS_path'],
path_save=DSS_path['path_save'],
prj_name=DSS_path['prj_name']
)
License: CC BY-NC-SA 4.0
This work has a license Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.