Skip to content

DSS MATLAB 0.10.6: upgrades and fixes

Compare
Choose a tag to compare
@PMeira PMeira released this 03 Aug 01:24

This DSS MATLAB release includes fixes and updates from the base OpenDSS engine, more unofficial extensions, as well as a reviewed error reporting system. This project uses the DSS C-API library version 0.10.6, based on OpenDSS revision 2909 (which is slightly newer than OpenDSS v9.0.0.3).

With this set of releases from the DSS Extensions project, most API calls are checked, avoiding surprising/confusing messages when the errors are not handled immediately. In DSS MATLAB, the error messages provided in the OpenDSS Error interface are automatically mapped to MATLAB errors and should now provide a better context for the errors.

Please file an issue or contact the author for feedback (pmeira at ieee.org).

What's this?

DSS MATLAB is a member of the family of multi-platform language bindings based on the DSS C-API project, which exposes EPRI's OpenDSS with a custom API intended to replace and extend the functionality of the official COM object API. For other languages: check DSS Python, OpenDSSDirect.py and DSS Sharp. See more alternatives at https://dss-extensions.org/

As with DSS Python and DSS Sharp, this package tries to mimic the COM object structure to facilitate the transition and keep most of the existing code valid. The package is usually faster than the COM object. Most of the missing features are related to the plotting methods from OpenDSS, which are not available in DSS C-API. You can, of course, use MATLAB's plotting capabilities.

📦 Downloads

Download the file according to your platform, as each file contains platform-specific binaries:

If you want to try DSS_MATLAB with a sample circuit, a simple example for the IEEE13 system is also included in the download package, under the examples folder. Continue reading for more.

News at a glance

Two new important compatibility settings are introduced:

  • DSSobj.Error.ExtendedErrors (defaults to enabled state): this new mechanism provides more error messages from the validation checks at the API level. You can disable the new messages, falling back to the previous behavior, using DSSobj.Error.ExtendedErrors = 0.
  • DSSobj.LegacyModels (defaults to disabled state): in OpenDSS v9.0, the old PVSystem, Storage, ... models were deprecated and removed from the official release. In ODD.py, you can toggle the old models using DSSobj.LegacyModels = 1. The current/new models, previously known as PVSystem2, Storage2, ... have been validated with the official tests and enabled by default.

About OpenDSS 9.0: https://sourceforge.net/p/electricdss/discussion/861976/thread/00ef2da276/

Changes from DSS C-API 0.10.6

DSS C-API is the low-level, extended OpenDSS library used in the DSS Extensions project. It provides a plain C interface, easily used by many programming languages.

  • This version should be fully API compatible with 0.10.3+. The behavior of some functions changed with the new extensions. Especially, empty strings are explicitly return as nulls instead of "\0". This conforms to the behavior already seen in arrays of strings.
  • The binary releases now use Free Pascal 3.2.0. We observed the solution process is around 6% faster, and results are even closer to the official OpenDSS.
  • The releases now include both the optimized/default binary and a non-optimized/debug version. See the Debugging document for more.
  • Extended API validation and Extended Errors mechanism:
    • The whole API was reviewed to add basic checks for active circuit and element access.
    • By default, invalid accesses now result in errors reported through the Error interface. This can be disabled to achieve the previous behavior, more compatible with the official COM implementation -- that is, ignore the error, just return a default/invalid value and assume the user has handled it.
    • The mechanism can be toggled by API functions DSS_Set_ExtendedErrors and DSS_Get_ExtendedErrors, or environment variable DSS_CAPI_EXTENDED_ERRORS=0 to disable (defaults to enabled state).
  • New Legacy Models mechanism:
    • OpenDSS 9.0+ dropped the old PVsystem, Storage, InvControl, and StorageController models, replacing with the new versions previously known as PVsystem2, Storage2, InvControl2 and StorageController2.
    • The behavior and parameters from the new models are different -- they are better, more complete and versatile models. Check the official OpenDSS docs and examples for further information.
    • The implementation of the new models in DSS C-API was validated successfully with all test cases available. As such, we mirror the decision to make them the default models.
    • As an extension, we implemented the Legacy Models option. By toggling it, a clear command will be issued and the alternative models will be loaded. This should allow users to migrate to the new version but, if something that used to work with the old models stopped working somehow, the user can toggle the old models. The idea is to keep reproducibility of results while we keep updating the engine and the API.
    • Since EPRI dropped/deprecated the old models, we might drop them too, in a future release. Please open an issue on GitHub or send a message if those old models are important to you.
    • The mechanism can be controlled by API functions DSS_Set_LegacyModels and DSS_Get_LegacyModels, or environment variable DSS_CAPI_LEGACY_MODELS=1 to enable (defaults to disabled state).
  • WireData API: expose the CapRadius property as a new pair of functions.
  • PDElements API: extended with many batch functions exposing equivalents to some CSV reports: AllNames, AllMaxCurrents, AllPctNorm, AllPctEmerg, AllCurrents, AllCurrentsMagAng, AllCplxSeqCurrents, AllSeqCurrents, AllPowers, AllSeqPowers, AllNumPhases, AllNumConductors, AllNumTerminals.
  • CktElement_Get_SeqPowers: fix issue for positive sequence circuits (wrong results could corrupt memory).
  • Many API functions were optimized to avoid unnecessary allocations and copies.
  • Some bugs found in DSS C-API and also reported upstream (already fixed in SVN):
    • CapRadius DSS property: if the radius was initialized using GMRac, CapRadius was left uninitialized, resulting in invalid/NaN values.
    • Sensors API: some functions edited capacitors instead of sensors.
  • Updated to the official OpenDSS revision 2903, corresponding to versions 9.0.0+. Changes include:
    • ExportCIMXML: updated.
    • Relay: Fix in GetPropertyValue.
    • Line: In DumpProperties and MakePosSequence, the length is handled differently for lines with LineGeometry or LineSpacing.
    • Bus API: new LineList, LoadList functions.
    • Lines API: SeasonRating now returns NormAmps if there's no SeasonSignal.
    • New command DSS Zsc012: "Returns symmetrical component short circuit impedances Z0, Z1, and Z2 for the ACTIVE 3-PHASE BUS. Determined from Zsc matrix."
    • PVsystem2, Storage2, InvControl2, StorageController2 updated and renamed.

Basic usage

  1. Download and extract the package appropriate for your system.
  2. Add the folder containing +DSS_MATLAB to your MATLAB path (e.g. path(path, 'c:\dss_matlab');).
  3. Instantiate DSS_MATLAB.IDSS. For example:
dss = DSS_MATLAB.IDSS;

If you code is based on DSSStartup.m from the examples included in the official distribution, in general you only need to replace the Obj = actxserver('OpenDSSEngine.DSS'); line. That is, update DSSStartup.m to:

%--------------------------------------------------------------------------
function [Start,Obj,Text] = DSSStartup
    % Function for starting up the DSS
    
    %instantiate the DSS Object
    Obj = DSS_MATLAB.IDSS;
    %
    %Start the DSS.   Only needs to be executed the first time w/in a
    %Matlab session
    Start = Obj.Start(0);

    % Define the text interface
    Text = Obj.Text;    

If you want more code to play with, you can use the MATLAB examples from the official OpenDSS distribution, from a local installation (e.g. C:\OpenDSS\Examples\Matlab) or from the official SVN repository.

Sandia's GridPV toolbox has been confirmed to work with very minor changes. Note that the toolbox seems to be out-of-date for some features, so don't expect everything to work even with COM (e.g. Google Maps integration seems broken).

As a general advice (valid for COM and DSS_MATLAB), avoid using the get function without parameters on OpenDSS classes. Some properties like First and Next used for iteration of elements change the current active element and can lead to misleading data!

Known differences and more

We maintain a list of important differences between the official COM implementation and DSS C-API at:

https://github.com/dss-extensions/dss_capi/blob/0.10.x/docs/known_differences.md

Most of these apply indirectly to DSS_MATLAB.

The list of important changes through development is also useful.

Credits / Acknowlegement

This project is derived from EPRI's OpenDSS and the same style of license (BSD style) is used. As OpenDSS, the project also depends on KLUSolve and SuiteSparse, licensed under the LGPL. The licenses are included in the installation packages.

See the DSS C-API project for more details and source files.