DSS-Extensions#

DSS-Extensions enables cross-platform (Windows, Linux, macOS) multi-language interfaces and extensions for an alternative/community implementation of EPRI’s OpenDSS, based on extended DSS engine and APIs. OpenDSS is an open-source distribution system simulator distributed by EPRI.

The main project is the AltDSS engine/DSS C-API library, a customized port of the original/upstream OpenDSS source code, exposed with a more traditional C API. Nowadays, the public code repository from the upstream OpenDSS is tracked and changes are ported as required.

The language bindings expose the engine to the target languages, currently supporting Python, Julia, MATLAB, C#/.NET, Rust, Go, C++. See the Projects page for more.

The projects are 100% free, open-source software. Licenses vary from project to project.

For illustration purposes, there are very reduced samples in various of the supported languages of how to load a circuit, solve it, and finally read the complex voltage array. Please check the documentation or code repositories for more.

Three packages are available and can be used together: DSS-Python (drop-in replacement for OpenDSS COM), OpenDSSDirect.py (uses function-calls instead of Python properties, has some extras), and AltDSS-Python (new alternative: detailed, modern API exposing all DSS objects, batches and more). The basics are very similar, include many extensions, but AltDSS includes distinct features, while the other two are more intended for backwards compatibility:

from dss import dss # DSS-Python
dss.Text.Command = 'redirect "sample_circuit.dss"' # or dss('redirect sample_circuit.dss')
dss.ActiveCircuit.Solution.Solve()
voltages = dss.ActiveCircuit.AllBusVolts

from opendssdirect import dss as odd # OpenDSSDirect.py
odd('redirect "sample_circuit.dss"')
odd.Solution.Solve()
voltages = odd.Circuit.AllBusVolts()

from altdss import altdss # AltDSS
altdss('redirect "sample_circuit.dss"')
altdss.Solution.Solve()
voltages = altdss.BusVolts()

By default, OpenDSS engine errors are mapped to Python exceptions. Support for DSS plot commands is available.

For more, see OpenDSSDirect.jl. OpenDSS engine errors are mapped to Julia exceptions. Support for DSS plot commands is under development.

using OpenDSSDirect
dss("redirect 'sample_circuit.dss'")
Solution.Solve()
voltages = Circuit.AllBusVolts()

For more, see DSS_MATLAB. Intended as a multi-platform drop-in replacement for the official COM object.

dss = DSS_MATLAB.IDSS;
dss.Text.Command = 'redirect "sample_circuit.dss"';
dss.ActiveCircuit.Solution.Solve();
voltages = dss.ActiveCircuit.AllBusVolts;

Available on NuGet as dss_sharp. For more, see the repo and the docs. Intended as a multi-platform drop-in replacement for the official COM object.

using dss_sharp;
//...
DSS dss = new DSS();
dss.Text.Command = "redirect 'sample_circuit.dss'";
dss.ActiveCircuit.Solution.Solve();
var voltages = dss.ActiveCircuit.AllBusVolts;

By default, OpenDSS engine errors are mapped to C# exceptions, but the behavior is configurable.

See instructions on AltDSS-Go’s repo, including a more complete sample. Currently mimics the official COM object API layout, within what’s possible in Go. OpenDSS engine errors are mapped to Go errors.

import (
	"log"

	"github.com/dss-extensions/altdss-go/altdss"
)
func main() {
	dss := altdss.IDSS{}
	dss.Init(nil)
	err := dss.Text.Set_Command("redirect 'sample_circuit.dss'");
	if err != nil {
		log.Fatal(err)
	}
	err := dss.ActiveCircuit.Solution.Solve();
	if err != nil {
		log.Fatal(err)
	}
	voltages, err := dss.ActiveCircuit.AllBusVolts()
	if err != nil {
		log.Fatal(err)
	}
}

See instructions on AltDSS-Rust’s repo, including some samples. Currently mimics the official COM object API layout, within what’s possible in Rust. OpenDSS engine errors are mapped to Rust errors with Result.

use altdss::common::{DSSError, DSSContext};
use altdss::classic::IDSS;

fn run_sample(dss: &IDSS) -> Result<(), DSSError> {
  dss.Command("redirect 'sample_circuit.dss'")?;
  dss.ActiveCircuit.Solution.Solve()?;
  let voltages = dss.ActiveCircuit.AllBusVoltages()?;
}
fn main() {
  let ctx = DSSContext::prime();
  let dss = IDSS::new(&ctx);
  run_sample(&dss).unwrap();
}