OpenDSS bindings and tools based on the DSS C-API project
Project description
DSS Python: Unofficial bindings for EPRI's OpenDSS
Python bindings and misc tools for using OpenDSS (EPRI Distribution System Simulator). Based on CFFI and DSS C-API, aiming for full COM compatibility on Windows, Linux and MacOS.
See also the other projects from DSS-Extensions.org:
- DSS C-API library: the base library that exposes a slightly modified version of EPRI's OpenDSS through a more traditional C interface, built with the open-source Free Pascal compiler instead of Delphi.
- OpenDSSDirect.py: if you don't need COM compatibility, or just would like to check its extra funcionalities. You can mix DSS Python and OpenDSSDirect.py -- for example, if you have old code using the official COM objects, you could quickly switch to DSS Python with very few code changes, and then use
opendssdirect.utils
to generate some DataFrames. - OpenDSSDirect.jl: a Julia module, created by Tom Short (@tshort), recently migrated with the help of Dheepak Krishnamurthy (@kdheepak) to DSS C-API instead of the DDLL.
- DSS Sharp: available for .NET/C#, also mimics the COM classes, but Windows-only at the moment. Soon it will be possible to use it via COM too.
- DSS MATLAB: presents multi-platform integration (Windows, Linux, MacOS) with DSS C-API and is also very compatible with the COM classes.
Version 0.10.7, based on OpenDSS revision 2963 (OpenDSS v9.1.3.4). While we plan to add a lot more funcionality into DSS Python, the main goal of creating a COM-compatible API has been reached. If you find an unexpected missing feature, please report it!
This module mimics the COM structure (as exposed via win32com
or comtypes
), effectively enabling multi-platform compatibility at Python level.
Most of the COM documentation can be used as-is, but instead of returning tuples or lists, this modules returns/accepts NumPy arrays for numeric data exchange.
The module depends on CFFI, NumPy and, optionally, SciPy.Sparse for reading the sparse system admittance matrix.
Brief release history
- 2020-12-28 / version 0.10.7: Maintenance release to match DSS C-API 0.10.7, based on on OpenDSS revision 2963. Includes fixes and new features from the official OpenDSS.
- 2020-07-31 / version 0.10.6: Maintenance release to match DSS C-API 0.10.6, based on on OpenDSS revision 2909. New important settings:
DSS.LegacyModels
andDSS.Error.ExtendedErrors
. - 2020-03-03 / version 0.10.5: Maintenance release to match DSS C-API 0.10.5, based on on OpenDSS revision 2837. Temporarily drops the v8 parallel-machine functions, as well as conda packages on Windows.
- 2019-11-16 / version 0.10.4: Maintenance release to match DSS C-API 0.10.4.
- 2019-05-22 / version 0.10.3: Some important fixes, better general performance, new API extensions, new features ported from COM and the OpenDSS version 8 codebase.
- 2019-02-28 / version 0.10.2: Some small fixes, adds the missing
CtrlQueue.Push
, faster LoadShapes and new propertyDSS.AllowEditor
to toggle editor calls. - 2019-02-17 / version 0.10.1: Integrate DSS C-API changes/fix, some small fixes, and more error-checking.
- 2018-11-17 / version 0.10.0: Lots of changes, fixes and new features. Check the new changelog document for a list.
- 2018-08-12 / version 0.9.8: Reorganize modules (v7 and v8), adds 8 missing methods and new backend methods for OpenDSSDirect.py v0.3+. Integrates many fixes from DSS_CAPI and the upstream OpenDSS.
- 2018-04-30 / version 0.9.7: Fix some of the setters that used array data.
- 2018-04-05 / version 0.9.6: Adds missing
ActiveCircuit.CktElements[index]
(or...CktElements(index)
) andActiveCircuit.Buses[index]
(or...Buses(index)
). - 2018-03-07 / version 0.9.4: Allows using
len
on several classes, fixes DSSProperty, and includes COM helpstrings as docstrings. Contains changes up to OpenDSS revision 2152. - 2018-02-16 / version 0.9.3: Integrates COM interface fixes from revision 2136 (
First
Next
iteration on some elements) - 2018-02-12 / version 0.9.2: Experimental support for OpenDSS-PM (at the moment, a custom patch is provided for FreePascal support) and port COM interface fixes (OpenDSS revision 2134)
- 2018-02-08 / version 0.9.1: First public release (OpenDSS revision 2123)
Recent changes
Changes in 0.10.7, since 0.10.6
Check the changelog document for a detailed list for all releases.
- Simple maintenance release.
- Updated to DSS C-API 0.10.7, which includes most changes up to OpenDSS v9.1.3.4.
- Includes tweaks related to the
CapRadius
property. - New properties ported from the official COM interface:
Bus.AllPCEatBus
,Bus.AllPDEatBus
, andCktElement.TotalPowers
.
Missing features and limitations
Most limitations are inherited from dss_capi
, i.e., these are not implemented:
DSSEvents
fromDLL/ImplEvents.pas
: seems too dependent on COM.DSSProgress
fromDLL/ImplDSSProgress.pas
: would need a reimplementation depending on the target UI (GUI, text, headless, etc.).- OpenDSS-GIS features are not implemented since they're not open-source.
In general, the DLL from dss_capi
provides more features than both the official Direct DLL and the COM object.
Extra features
Besides most of the COM methods, some of the unique DDLL methods are also exposed in adapted forms, namely the methods from DYMatrix.pas
, especially GetCompressedYMatrix
(check the source files for more information).
Since no GUI components are used in the FreePascal DLL, we are experimenting with different ways of handling OpenDSS errors. Currently, the DSS.Text.Command
call checks for OpenDSS errors (through the DSS.Error
interface) and converts those to Python exceptions. Ideally every error should be converted to Python exceptions, but that could negatively impact performance. You can manually trigger an error check by calling the function CheckForError()
from the main module.
Installing
On all major platforms, you can install directly from pip:
pip install dss_python
Or, if you're using the Anaconda distribution, you can try:
conda install -c pmeira dss_python
Binary wheels are provided for all major platforms (Windows, Linux and MacOS) and many combinations of Python versions (3.5 to 3.9). If you have issues with a specific version, please open an issue about it. Conda packages support at least Python 3.6, 3.7 and 3.8 (varying according to the release).
After a successful installation, you can then import the dss
module from your Python interpreter.
Building
Get the repository:
git clone https://github.com/dss-extensions/dss_python.git
Assuming you successfully built or downloaded the DSS C-API DLLs (check its repository for instructions), keep the folder organization as follows:
dss_capi/
dss_python/
electricdss-src/
Open a command prompt in the dss_python
subfolder and run the build process:
python setup.py build
python setup.py install
If you are familiar with conda-build
, there is a complete recipe to build DSS C-API, KLUSolve and DSS Python in the conda
subfolder.
Example usage
If you were using win32com
in code like:
import win32com.client
dss_engine = win32com.client.gencache.EnsureDispatch("OpenDSSEngine.DSS")
or comtypes
:
import comtypes.client
dss_engine = comtypes.client.CreateObject("OpenDSSEngine.DSS")
you can replace that fragment with:
import dss
dss_engine = dss.DSS
If you need the mixed-cased handling (that is, you were not using early bindings with win32com), add a call to dss.use_com_compat()
.
Assuming you have a DSS script named master.dss
, you should be able to run it as shown below:
import dss
dss_engine = dss.DSS
dss_engine.Text.Command = "compile c:/dss_files/master.dss"
dss_engine.ActiveCircuit.Solution.Solve()
voltages = dss_engine.ActiveCircuit.AllBusVolts
for i in range(len(voltages) // 2):
print('node %d: %f + j%f' % (i, voltages[2*i], voltages[2*i + 1]))
If you want to play with the experimental OpenDSS-PM interface (from OpenDSS v8), it is installed side-by-side and you can import it as: -- temporarily disabled in DSS Python 0.10.5. Check back in a few months.
import dss.v8
dss_engine = dss.v8.DSS
Although it is experimental, most of its funcionality is working. Depending on your use-case, the parallel interface can be an easy way of better using your machine resources. Otherwise, you can always use general distributed computing resources via Python.
Beware the v8 alternative can present issues and it should be removed as soon as all OpenDSS 8+ features are integrated into the default version.
Testing
Since the DLL is built using the Free Pascal compiler, which is not officially supported by EPRI, the results are validated running sample networks provided in the official OpenDSS distribution. The only modifications are done directly by the script, removing interactive features and some other minor issues. Most of the sample files from the official OpenDSS repository are used for validation.
The validation scripts is tests/validation.py
and requires the same folder structure as the building process. You need win32com
to run it on Windows.
As of version 0.11, the full validation suite can be run on the three supported platforms. This is possible by saving the official COM DLL output and loading it on macOS and Linux. We hope to automate this validation in the future.
Roadmap
Besides bug fixes, the main funcionality of this library is mostly done. Notable desirable features that may be implemented are:
- More and better documentation
- Plotting and reports integrated in Python.
- Parallel-machine properties (disabled in DSS Python 0.10.5, to be reworked).
Expect news about these items by version 0.11.
Questions?
If you have any question, feel free to open a ticket on GitHub, or contact directly me through email (pmeira at ieee.org). Please allow me a few days to respond.
Credits / Acknowlegement
DSS Python is based on EPRI's OpenDSS via the dss_capi
project, check its licensing information.
This project is licensed under the (new) BSD, available in the LICENSE
file. It's the same license OpenDSS uses (OPENDSS_LICENSE
). OpenDSS itself uses KLUSolve and SuiteSparse, licensed under the GNU LGPL 2.1.
I thank my colleagues at the University of Campinas, Brazil, for providing feedback and helping me test this module.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for dss_python-0.10.7rc2-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c1f080e4e5690da77c543398c262a63b2775917dbdfd6ebf8df9b212e09cd16 |
|
MD5 | 42263f2ea2bef33f502e366f5ad58c38 |
|
BLAKE2b-256 | 5718be1fb45e6bece77ad7df108518eb98ad0a06e5d76bdbbd748a9161b43f9b |
Hashes for dss_python-0.10.7rc2-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b27d9a27ee881a894414ab55750fcae8c5a37be11c0ef56b0cb142dede362e9 |
|
MD5 | fcc1947cbc5bfd77261a852851aa18c1 |
|
BLAKE2b-256 | 23ee93ad9aab040b00708772135b1736204ed7fcd7082898c131b37f3547efe4 |
Hashes for dss_python-0.10.7rc2-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 133ce041bff49807f3ea6f56431a93e7448fbc0c0be24d1f444ccdfc4e35d799 |
|
MD5 | 97bfbfc9daf14f0e1bf0d9d45e53ef76 |
|
BLAKE2b-256 | 6d95702ea06907c398bfd1378756db4726a4e61343c814ab00653046ae6f104a |
Hashes for dss_python-0.10.7rc2-cp39-cp39-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b81d6b0bbe86a0ffa69b1ed59f45da50938f278c02fadb1a89a88debcb398f15 |
|
MD5 | d800d03cc61e60aea386e292d2f3f3db |
|
BLAKE2b-256 | c49f7d757d597fa13a1ee7a5f654bb2a28a41c4cbb54a3275b66e6fc65d2c3e2 |
Hashes for dss_python-0.10.7rc2-cp39-cp39-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ba5733801e374bcdb0e08c86ba7ac53f445703180a11be04c84d5e3d742a480 |
|
MD5 | 2345d9d7348083f14d665cebf79fc02e |
|
BLAKE2b-256 | 178e6bd2a1aefc1041e7393692407ebcd6d86f22e8b98e39e44113c0760469ef |
Hashes for dss_python-0.10.7rc2-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b68fc63a91bec94e1938fd2744eddc434c3b9235a34102817f54c6bd6df5fb02 |
|
MD5 | 5214436b39a2d81f879f7bed6002f79c |
|
BLAKE2b-256 | 92e0cd7cb46266f2fb293b66f1d75cb0b06f306da0b7843185115a9d729237bc |
Hashes for dss_python-0.10.7rc2-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3944f2eb262c204a967829ea71715ffe0e0853c822eea8c8968a61cf762d0efc |
|
MD5 | 4f71c3a80c85c61a9f50706d3cb3f6c8 |
|
BLAKE2b-256 | ee17b75985261ebe777c519617d07efe6d8a2ff70d5f8ea04dbecfdfe159bed2 |
Hashes for dss_python-0.10.7rc2-cp38-cp38-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d8c4efb856019d6ae952187fbd7e8125835584bb848f5f30260103a88ab0a155 |
|
MD5 | d4fca17a60b25b88dd394f7e103a1c89 |
|
BLAKE2b-256 | 205205ca494527c3ebbcf41ad3c4a65a6ec0d4c857f458abad9c7c30c1788fe6 |
Hashes for dss_python-0.10.7rc2-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 577fc0e5bc71e400053b1ab23d53c7e7038b22a343ea3c38823a74780e2e6202 |
|
MD5 | 220d802a07a591bef542803841aceb6a |
|
BLAKE2b-256 | 821bd3aa59d194568eaadcb7756dca4b355cc32238de13e431fa0d38823e285b |
Hashes for dss_python-0.10.7rc2-cp38-cp38-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9dde3fd9a432b97444906f1f0f7aa5f89046b1761ff9160c3848563ed5b4cc8e |
|
MD5 | 5d8c120defb300ca7dde515a687f5fae |
|
BLAKE2b-256 | 14720eeec8e9edf741a9e325d169edf5bbbededf56797ac5ef9e9411a0434054 |
Hashes for dss_python-0.10.7rc2-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d4d26a2e25a90fc696cb694b832f3c5dfcaa1617555fa2adb0a88d4b6888d90 |
|
MD5 | b9f60429248270e532d19aa219e4a9dd |
|
BLAKE2b-256 | 71ba046b391c71c812040fdfd189f8fa24f6246c34b79eb4dfedc9d12a110071 |
Hashes for dss_python-0.10.7rc2-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a8d9c397e9481255f09b56741827e1aaec1beb7a0eeeff93aad5ab935900121 |
|
MD5 | de92ec9ad36825772b9a632835e81455 |
|
BLAKE2b-256 | a154de99c94b941c18c683b6328aced3a1c1cb493104e366ab088b3faa38bce1 |
Hashes for dss_python-0.10.7rc2-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d59e6f58c7e8380637ebabbe878c78a082d685c9ad38b89f4f96e18e13cc3f90 |
|
MD5 | 815ce2c99d94f7654466e6ff0e24da54 |
|
BLAKE2b-256 | 57e1940cd3d5b522ba23d0199218be9f73b4f5d9edca6339dbfd16e91440c193 |
Hashes for dss_python-0.10.7rc2-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f65f47abed409c953d50b836696709ea8fbd6aef7b706d2dc02eeba6721f5477 |
|
MD5 | c9bcf302456e7cf2824e19bf353a8e5e |
|
BLAKE2b-256 | f22764a0b8d0e6f9328c0fbea56b9e5174c1b6790fdb82788315123e5ca1adfe |
Hashes for dss_python-0.10.7rc2-cp37-cp37m-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4a6bbabac1a7631e9c2468b32ba06bc252ca98a0c4227549f6c02f87abdeec9 |
|
MD5 | d5acf5a017bf4554219db9f4d0b3dc36 |
|
BLAKE2b-256 | 0bfbe5e615156dd23ca697511ab683762df45998ab5a5ee0e99eefd6a37ed5ca |
Hashes for dss_python-0.10.7rc2-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51e85c510b0fbda2ab2abcededb50911cdbdb06038ef9af2dbbeadc27749adcd |
|
MD5 | bc779b1f409b2a4bb8f9c51eaa05c25b |
|
BLAKE2b-256 | b7001fbf589942901ab0034c31ed55fbbb66496ba7b37d44f4624945621a2459 |
Hashes for dss_python-0.10.7rc2-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff7d687b6938c8a731290d81a25abdeadaf253f5ca237d78f6fc43e7cac6627e |
|
MD5 | 12d0080b1756e1482e195dce0fdaa0ba |
|
BLAKE2b-256 | 64a77a3fbba0ee870738e9346c7ed03742b92ea44f51de9485faed8d8d082c66 |
Hashes for dss_python-0.10.7rc2-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad10624384c7bf7f5ed3937e458e0265683a3d3dba28dc8159d43e5bfef253bd |
|
MD5 | b25a167f0b4a59b449e735fc92750bbd |
|
BLAKE2b-256 | 348acc17185e6229134806b473451f21ad86f6e3828a1184e8c46375951046b2 |
Hashes for dss_python-0.10.7rc2-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18a2e366dc4cb57e802be65f7b5a31778c11405c222dce6384b6ee0531903709 |
|
MD5 | 4d3c61f4c89bda4d225df2f8372c2f69 |
|
BLAKE2b-256 | af13b5b675654edcf600294bc99b9393f43481223a1b7b67af4c86ab56e41e1f |
Hashes for dss_python-0.10.7rc2-cp36-cp36m-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bef1522f55742cca08c6adc74058288f0b4932227c3f95e28f6da679a45e3d56 |
|
MD5 | fb5ce4fe16ccbc63fba4709620676789 |
|
BLAKE2b-256 | df6644fe1887f754b7e9fdbb20ced95204cd4f5a6619312871a6871882a165cb |
Hashes for dss_python-0.10.7rc2-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b570994877f21e3be1e87f12c7b15e83c0368fb851bde2a411d8e6ea737fac0f |
|
MD5 | 80f20274f3a6587c9e5e187d738e7493 |
|
BLAKE2b-256 | 9f51c3ae1d82e75976b4e899745885b137974d9f34697116be0cb42661e235f6 |
Hashes for dss_python-0.10.7rc2-cp35-cp35m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27fc375bbb4a45e03e4efd85680caf963d5f1c8e69bb4777989806f41a89231c |
|
MD5 | 66789ca57ab9c9d4def4b22d57ad8c6a |
|
BLAKE2b-256 | 87260bb1d253f11c86b3ab209e1343bd3384f3016b5e0f3d2b9a7bae72b2c253 |
Hashes for dss_python-0.10.7rc2-cp35-cp35m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9db8a74b9797131fcea704ce8ca75e2a0a00c7445b84b0bf86de52cdbcbf0df0 |
|
MD5 | 5cab4246959c06fabca6610e350544b8 |
|
BLAKE2b-256 | ddfd15f503f7f6b90e58143c67edbff952d6a02fef0e240c97d409574dfdb263 |
Hashes for dss_python-0.10.7rc2-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 74452e51af4cf38d0fa66f96d81c3132c0990f765070d5274d3811b8ec112300 |
|
MD5 | a4a43ce854d0836a10cd4ec8f14b43ab |
|
BLAKE2b-256 | 5ebe85ed0b33b915938e90e54cd6ef96fa4cf6a51ef2bee66030d77ac593aeda |
Hashes for dss_python-0.10.7rc2-cp35-cp35m-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42e887a178fedc78409eb9d85bd64051ff255f78d67a36013d5c2ab921adcdae |
|
MD5 | 75a9e87b0ad879787436da952495b777 |
|
BLAKE2b-256 | ed716ad76a6375df26ea97a259573cba5a70c4062268af281645402396d506d9 |