dss-extensions / dss_sharp

C#/.NET bindings for DSS C-API, an unofficial implementation of OpenDSS with a custom API in plain C, new features and API extensions.
https://dss-extensions.org/dss_sharp/
BSD 3-Clause "New" or "Revised" License
8 stars 0 forks source link
com csharp distribution dotnet dss electric linux macos opendss powerflow simulator windows

Build Latest NuGet release

Para uma versão em português 🇧🇷 deste arquivo, veja README.pt-BR.md.

DSS Sharp

DSS Sharp is a C#/.NET wrapper library for DSS C-API, which is an open-source, multi-platform, multi-architecture, extended alternative (unofficial, not provided by EPRI) OpenDSS engine, highly compatible with the official OpenDSS COM implementation and more.

DSS Sharp tries to mimic the organization of the official OpenDSS COM interfaces, plus several extensions (new properties and methods, and whole new classes). If you find conflicting behavior, feel free to report.

This projects exposes most of the functionality implemented in DSS C-API, including performance benefits, ZIP file support, initial JSON exports, multi-platform (Linux, Windows, macOS) support, including Intel x86/x64 and ARM architectures. Contrary to the official implementation, DSS Sharp supports multiple OpenDSS instances (dss_sharp.DSS.NewContext()), effectively enabling user-controlled multi-threading applications. Most of the official parallel-machine functions are also available.

For a general introduction visit https://dss-extensions.org and follow the development of the general documentation at https://github.com/dss-extensions/dss-extensions

Overview of related repositories

If you are looking for the bindings to other languages:

Documentation

We will grow general documentation at https://github.com/dss-extensions/dss-extensions. Several notes and a FAQ are already available there. Some of the new docs are already available at https://dss-extensions.org/ (this DSS language reference and general documents useful for new users).

Users can rely on the official OpenDSS COM documentation. We provide C#/.NET class library docs at https://dss-extensions.org/dss_sharp/

At a glance

If you are new to C# or have not use it a few years, it's recommended to check updated material on the current state of .NET and best practices.

If you are new to OpenDSS in general, there are two main aspects you need to study:

The official OpenDSS version from EPRI contains lots of material for both topics and, ignoring the whole installation and registering related to COM, are also applicable to DSS Sharp and other DSS-Extensions.

You can learn the basics using the official version and migrate to DSS Sharp when required or when you are interested in the extras from DSS-Extensions.

Installing

There multiple ways, we recommend using NuGet.

If you are using recent versions of Microsoft Visual Studio, you install the package using NuGet.

If you're using the SDK style .csproj, you can add a reference like (remember to adjust the version if required):

    <ItemGroup>
    <PackageReference Include="dss_sharp" Version="0.14.*" />
    </ItemGroup>

Finally, if you wish to clone the repository and customize the library code instead, remember to manually download the required DLLs, either using the scripts/download_native_libs.sh, or by visiting the DSS C-API releases page.

Minimal usage

After installing and/or adding the reference to dss_sharp in your project, you can test with a circuit.

Assuming you have OpenDSS installed at C:\Program Files, this should work:

using dss_sharp;

//...

var dss = new DSS();
dss.Start(0);
dss.Text.Command = @"redirect 'C:\Program Files\OpenDSS\IEEETestCases\13Bus\IEEE13Nodeckt.dss'";
var voltageMags = dss.ActiveCircuit.AllBusVmag;

You can also download our repository electricdss-tst to obtain the test/reference circuits and more already adjusted for multi-platform usage (the original files are distributed in the official OpenDSS installer).

More

A simple, but almost step-by-step, sample is available here: WinFormsAppSample