dss-extensions / OpenDSSDirect.py

OpenDSSDirect.py: a cross-platform Python package that implements a native/direct library interface to the alternative OpenDSS engine from DSS-Extensions.org

Home Page:https://dss-extensions.org/OpenDSSDirect.py/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The `dss.Circuit.AllBusNames()` don't get properly the bus names without solving

felipemarkson opened this issue · comments

Versions

  • Python version: 3.10.4
  • Python architecture: x64
  • Operating system and version: Fedora 35
  • OpenDSSDirect.py version number: v0.6.1

Bug

What is the current behavior?

If you try to redirect to a .dss file that doesn't have the solve command, the dss.Circuit.AllBusNames() doesn't get properly the bus names.

Is there another way to get the bus names without running the entire power flow?

What is the expected behavior? What is the motivation/use case for changing the behavior?

Sometimes, especially in a big distribution system, could be useful to get the bus names without solving the power flow.

What are the steps to reproduce this bug? Please provide a minimal working example of the bug if possible.

import opendssdirect as dss

dss.run_command("Clear")
dss.run_command("Redirect path/to/IEEE13Nodeckt_without_solve_command.dss")
print(dss.Circuit.AllBusNames())) # []

Sorry, I couldn't reproduce that. Here's a self-contained sample:

import opendssdirect as dss
dss.Text.Command('clear')
dss.Text.Command('new circuit.test bus1=1')
dss.Text.Command('new line.12 bus1=1 bus2=2')
print(dss.CktElement.BusNames())

Output:

['1', '2']

Here is a sample code to reproduce the bug:

In master.dss

clear
new circuit.test bus1=1
new line.12 bus1=1 bus2=2
new line.23 bus1=2 bus2=3
new line.34 bus1=3 bus2=4
new line.45 bus1=4 bus2=5

In test.py

import opendssdirect as dss
dss.run_command("Redirect master.dss")
print(dss.Circuit.AllBusNames()) #[]

We get the same problem calling direct from dss:

import opendssdirect as dss
dss.run_command(
    """
    clear
    new circuit.test bus1=1
    new line.12 bus1=1 bus2=2
    new line.23 bus1=2 bus2=3
    new line.34 bus1=3 bus2=4
    new line.45 bus1=4 bus2=5
    """
)

print(dss.Circuit.AllBusNames())  #[]

Or:

import opendssdirect as dss
dss.run_command("clear")
dss.run_command("new circuit.test bus1=1")
dss.run_command("new line.12 bus1=1 bus2=2")
dss.run_command("new line.23 bus1=2 bus2=3")
dss.run_command("new line.34 bus1=3 bus2=4")
dss.run_command("new line.45 bus1=4 bus2=5")
print(dss.Circuit.AllBusNames()) #[]

Sorry, I confused the commands. I already corrected the comments.

The weird part of this is that the dss.CktElement.BusNames() show the buses of the active element but dss.Circuit.AllBusNames() don't.

@felipemarkson Ah, that's expected. Just run MakeBusList to fill that:

import opendssdirect as dss
dss.run_command("clear")
dss.run_command("new circuit.test bus1=1")
dss.run_command("new line.12 bus1=1 bus2=2")
dss.run_command("new line.23 bus1=2 bus2=3")
dss.run_command("new line.34 bus1=3 bus2=4")
dss.run_command("new line.45 bus1=4 bus2=5")
print(dss.Circuit.AllBusNames())
dss.run_command("MakeBusList")
print(dss.Circuit.AllBusNames())

Output:

[]
['1', '2', '3', '4', '5']

From the help:

Command Description
MakeBusList Updates the buslist, if needed, using the currently enabled circuit elements. (This happens automatically for Solve command.) See ReprocessBuses
ReprocessBuses Forces reprocessing of bus definitions whether there has been a change or not. Use for rebuilding meter zone lists when a line length changes, for example or some other event that would not normally trigger an update to the bus list.