Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bus names are set to lower case: can this be prevented? #136

Open
nlaws-camus opened this issue Nov 30, 2024 · 3 comments
Open

bus names are set to lower case: can this be prevented? #136

nlaws-camus opened this issue Nov 30, 2024 · 3 comments
Labels
engine Engine-related (hosted by DSS C-API) issue enhancement

Comments

@nlaws-camus
Copy link

Support Question

I am programmatically defining all circuit elements based on data that can have mixed string cases, and later I need to align the bus names (and many other things in the dss model) with the data. Is there a way to stop dss from changing the capitalization of the bus names?

dss(f"""
Clear
new circuit.dummy Bus=CapsBUS
solve
""")
dss.CktElement.BusNames()

['capsbus', 'capsbus.0.0.0']

@PMeira PMeira added enhancement engine Engine-related (hosted by DSS C-API) issue labels Dec 11, 2024
@PMeira
Copy link
Member

PMeira commented Dec 11, 2024

Currently, no. Nearly everything in OpenDSS/AltDSS is case-independent, so keeping the original names would either require maintaining copies or applying a upper/lowercase conversion in a lot of places. That is, currently not worth the effort of considering.

We can keep this open as a feature request though. We might be able to handle it cleanly in a few months (after the full C++ transition on the engine).

@nlaws-camus
Copy link
Author

Any tips on how to deal with indexing into the dss.Circuit.YNodeOrder, which does not change the node names, using dss.CktElement.BusNames(), which are lower case?

For example, to get the source nodes one can

  source_busses: list[str] = []
  source_bus_phases: list[list[int]] = []
  dss.Circuit.SetActiveClass("VSource")

  dss.Vsources.First()

  def _update_output():
      if dss.CktElement.Enabled():
          # BusNames is like ['source', 'source.0.0.0'] for a single 3 phase
          # source, and can look like ['newbus.1', 'newbus.0.0.0'] for a
          # single 1 phase source. 
          bus_name = dss.CktElement.BusNames()[0]
          # NOTE dss.Bus.Name() does not update with the VSource
          if "." in bus_name:
              bus_name = bus_name.split(".")[0]
          source_busses.append(bus_name)
          nodes = set(dss.CktElement.NodeOrder())
          nodes.discard(0)  # drop ground connections
          source_bus_phases.append(list(nodes))

  _update_output()
  while dss.Vsources.Next() > 0:
      _update_output()

  source_nodes = [
      bus + "." + str(phase)
      for bus, phases in zip(source_busses, source_bus_phases)
      for phase in phases
  ]

But the YNodeOrder will have the capitalization that was used in the New commands, while BusNames has lower case names.

@PMeira
Copy link
Member

PMeira commented Dec 19, 2024

But the YNodeOrder will have the capitalization that was used in the New commands, while BusNames has lower case names.

Maybe we could at least add an option to return lowercase strings from YNodeOrder.

Related to your sample, in the upcoming release, to avoid this common pattern...

if "." in bus_name:
              bus_name = bus_name.split(".")[0]

...BusNames now has an argument (keyword argument in ODD.py) to suppress the nodes.

I personally don't like that the bus connections are kept as strings, even in the internal code, but I haven't had the time to try alternatives yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
engine Engine-related (hosted by DSS C-API) issue enhancement
Projects
None yet
Development

No branches or pull requests

2 participants