Skip to content

DSS Python 0.12.1

Compare
Choose a tag to compare
@PMeira PMeira released this 16 Jul 14:52
· 204 commits to master since this release

Incremental release to address a bug found right after v0.12.0 was released.

  • Fix handling of Voltexceptionreport option
  • Add the missing property descriptions
  • Update docstrings for the experimental DSS.Obj API.

Slight modified original announcement for v0.12.0 follows.


Version 0.12.0 has been released on the official Python package repository (PyPI) for Windows, macOS and Linux. This release includes support for Intel x86 and x86-64, ARM32 and ARM64 platforms, including Apple's M1 and later.

For Anaconda cloud (channel dss-extensions), packages will be uploaded in the coming days.

Note: Although the majority of features are ported frequently from the official OpenDSS and validated with a large suite of tests, this is not an official EPRI project.

The main differences in behavior compared to the official OpenDSS implementation are listed in https://github.com/dss-extensions/dss_capi/blob/master/docs/known_differences.md

This is a major release merging parallel features, multiple DSS engine instances, ZIP file support, incremental Y matrix updates, new API functions, partial plotting support, better performance, and so on. General usage examples for the new features will be incrementally added to https://github.com/dss-extensions/dss-extensions, a new location to reduce duplication of documentation efforts across all DSS Extensions.

The help messages for the help command and a few functions are missing in this release. Users can expect more frequent updates to address this.

Installation

Using pip (Python versions: 3.6 to 3.10):

pip install dss_python==0.12.1

Conda packages are available for Linux (including a couple of PyPy versions) and macOS:

conda install -c dss-extensions dss_python=0.12.1

The binary wheels are also available as attachments on this release announcement.

Recent changes

(Not a complete list)

  • Removed CmathLib: not useful in Python or most programming languages targetted by DSS Extensions.
  • Allow creating multiple DSS engine instances via DSS.NewContext().
  • Reenabled Parallel interface and PM functions (actors and so on), based on a new implementation.
  • Enable incremental Y matrix options -- controlled by DSS.YMatrix.SolverOptions, options listed in SparseSolverOptions.
  • New ToJSON functions to dump object properties (power flow state is not included at the moment)
  • Initial implementation of the new DSS.Obj API for direct DSS object and uniform batch manipulation, covering all DSS classes implemented in DSS C-API. The shape of this API may change for the next releases. At the moment it is intended for advanced users. For example, if you get an object handle from the engine and load a new circuit, the handle is invalid and you should not access it anymore (otherwise, crashes are expected).
  • Initial (work-in-progress) implementation of plotting functions. This will also be finished and polished in following releases.
  • Due to some changes ported from the official OpenDSS since 0.10.7, some results may change, especially for circuits that used miles as length units. The same is observed across the official OpenDSS releases.

DSS C-API 0.12.0 changes:

Includes porting of most official OpenDSS features up to revision 3460. Check the OpenDSS SVN commits for details.

Since version 0.11 accumulated too many changes for too long (nearly 2 years), making it hard to keep two parallel but increasingly distinct codebases, version 0.12 is a stepping stone to the next big version (planned as 0.13) that will contain all of the 0.11 changes. As such, only some of the 0.11 features are included. The previous 0.10.8 changes are also included here.

This version still maintains basic compatibility with the 0.10.x series of releases, but there are many important changes. Version 0.13 will break API and ABI compatibility since function signatures and datatypes will be extensively adjusted. Still, if you use DSS C-API through one of the projects from DSS Extensions, we expect that your code will require few or no changes.

  • The binary releases now use Free Pascal 3.2.2.

  • The library name was changed from dss_capi_v7 to dss_capi. The codebase was cleaned up and reorganized.

  • The code was finally unified, merging remaining features from OpenDSS v8+ (with few exceptions). Most of the DSS PM commands and functions were enabled. To achieve this, most of the global variables from the OpenDSS engine were encapsulated in a new class, a DSS Context class. Multi-threaded features are based on DSSContexts, both the original OpenDSS PM features and new extensions.

  • Using DSS Contexts, user threads are now possible.

  • Initial ARM64/AARCH64 support added. ARM32 building scripts were also added. Support includes Apple M1 support, including parallel/multi-threading features.

  • Finally use KLUSolveX (our KLUSolve fork, rewritten and extended), enabling incremental Y updates for transformers and capacitor banks. Documentation including usage notes and limitations still not written. This was planned for version v0.13, but momved back to v0.12 to enable ARM32 (armv7l) support and better results in ARM64 (aarch64).

  • Experimental callbacks for plotting and message output. Expect initial support in Python soon after DSS C-API v0.12 is released.

  • Introduce AllowChangeDir mechanism: defaults to enabled state for backwards compatibility. When disabled, the engine will not change the current working directory in any situation. This is exposed through a new pair of functions
    DSS_Set_AllowChangeDir and DSS_Get_AllowChangeDir, besides the environment variable DSS_CAPI_ALLOW_CHANGE_DIR.

  • New setting to toggle DOScmd command. Can be controlled through the environment variable DSS_CAPI_ALLOW_DOSCMD or functions DSS_Get_AllowDOScmd/DSS_Set_AllowDOScmd.

  • Use OutputDirectory more. OutputDirectory is set to the current DataPath if DataPath is writable. If not, it's set to a general location (%LOCALAPPDATA%/dss-extensions and /tmp/dss-extensions since this release). This should make life easier for a user running files from a read-only location. Note that this is only an issue when running a compile command. If the user only uses redirect commands, the DataPath and OutputDirectory are left empty, meaning the files are written to the current working directory (CWD), which the user can control through the programming language driving DSS C-API. Note that the official OpenDSS COM behavior is different, since it loads the DataPath saved in the registry and modifies the CWD accordingly when OpenDSS is initialized.

  • File IO rewritten to drop deprecated Pascal functions and features. This removes some limitations related to long paths due to the legacy implementation being limited to 255 chars.

  • Reworked TPowerTerminal to achieve better memory layout. This makes simulations running LoadsTerminalCheck=false and LoadsTerminalCheck=true closer in performance, yet disabling the check is still faster.

  • Use TFPHashList where possible (replacing the custom, original THashList implementation from OpenDSS).

  • New LoadShape functions and internals:

    • Port memory-mapped files from the official OpenDSS, used when MemoryMapping=Yes from a DSS script while creating a LoadShape object.
    • Release the LoadShape_Set_Points function, which can be used for faster LoadShape input, memory-mapping externally, shared memory, chunked input, etc.
  • Some new functions:

    • Circuit_Get_ElementLosses
    • CktElement_Get_NodeRef
  • DSS_Get_COMErrorResults/DSS_Set_COMErrorResults: New compatibility setting for error/empty result. If enabled, in case of errors or empty arrays, the API returns arrays with values compatible with the official OpenDSS COM interface.

    For example, consider the function Loads_Get_ZIPV. If there is no active circuit or active load element:

    • In the disabled state (COMErrorResults=False), the function will return "[]", an array with 0 elements.
    • In the enabled state (COMErrorResults=True), the function will return "[0.0]" instead. This should
      be compatible with the return value of the official COM interface.

    Defaults to True/1 (enabled state) in the v0.12.x series. This will change to false in future series.

    This can also be set through the environment variable DSS_CAPI_COM_DEFAULTS. Setting it to 0 disables
    the legacy/COM behavior. The value can be toggled through the API at any time.

  • Drop function aliases: previously deprecated function aliases (LoadShapes_Set_Sinterval and LoadShapes_Get_sInterval) were removed to simplify the build process. Use LoadShapes_Set_SInterval and LoadShapes_Get_SInterval instead.

  • Monitor headers: From the official OpenDSS, since May 2021, the monitor binary stream doesn't include the header anymore. When porting the change to DSS Extensions, we took the opportunity to rewrite the related code, simplifying it. As such, the implementation in DSS Extensions deviates from the official one. Extra blank chars are not included, and fields should be more consistent. As a recommendation, if your code needs to be compatible with both implementations, trimming the fields should be enough.

  • Error messages: most messages are now more specific and, if running a DSS script from files, include the file names and line numbers.

  • Spectrum: To reduce overhead during object edits, now required to exist before the object that uses it. This is consistent with most of the other types in OpenDSS.

  • New object and batch APIs for direct manipulation of DSS objects and batches of objects

  • New experimental API for loading scripts/data from ZIP files

  • New convenience functions to bulk load commands from the API

  • User-models: headers updated, and removed support for user-models in LegacyModels mode. LegacyModels will be removed in v0.13.

  • New functions to export the DSS properties of objects as JSON-encoded strings

  • The C headers for our library were updated to include the const modifier for various of the parameters. A few function declarations were fixed.

  • Initial batch of i18n changes.

Due to the high number of IO changes, we recommend checking the performance before and after the upgrade to ensure your use case is not affected negatively, especially if your application relies heavily on OpenDSS text output. If issues are found, please do report.

Reminder: mixed-case handling

If you were using set_case_insensitive_attributes (previously use_com_compat) to allow mixed-cased attributes, it should work better than before. You may now use set_case_insensitive_attributes(warn=True) to warn when you use an attribute that wouldn't exist without calling set_case_insensitive_attributes. The intention is that the user should run their code to get a list of warnings, fix it, and then remove set_case_insensitive_attributes since it does have a small performance impact.