dss-extensions / OpenDSSDirect.jl

OpenDSSDirect.jl is a cross-platform Julia package implements a "direct" library interface to OpenDSS, currently using the alternative OpenDSS implementation from DSS-Extensions
https://dss-extensions.org/OpenDSSDirect.jl/latest/
Other
24 stars 6 forks source link

`Transformers.kVA` returns wrong value #87

Closed felipemarkson closed 1 year ago

felipemarkson commented 2 years ago

Hi guys!

I'm facing a weird issue once I run a large distribution system. The Transformers.kVA is give me wrong values, but the Properties.Value("kVA") is right, comparing with OpenDSS.

Here is an example with the IEEE 8500 Node in the OpenDSS\IEEETestCases\8500-Node folder.

using OpenDSSDirect

sys = """
clear
Compile Master-unbal.dss     ! unbalanced load master

New Energymeter.m1 Line.ln5815900-1 1
New Monitor.m1 Line.ln5815900-1 1

Solve
"""

dss(sys)
Circuit.SetActiveElement("Transformer.T5337697B")
Transformers.Wdg(1.0)
Transformers.kVA() # Wrong value
Properties.Value("kVA") # Right value

But If I try a small distribution system, the Transformers.kVA() works here on my tests.

Is this a bug?

cc @Ibrahim-a-Ibrahim

PMeira commented 2 years ago

Pretty sure it's not a bug. I can confirm another day.

SetActiveElement doesn't activate the element in the component-specific lists. Use Transformers.Name("T5337697B") instead and it should work. For large-scale analysis, prefer Transformer.Idx to avoid any strings.

If you inspect Transformers.Name() in your sample, you'll probably see that your target transformer is not active there.

felipemarkson commented 2 years ago

Thanks very much, @PMeira!

You are right, SetActiveElement was not activating the element!

Transformers.Name works fine, thanks!

Is this also apply to PDElements.Name?

If yes, what is the point of SetActiveElement?

I also think that this could be on the documentation to avoid misunderstandings.

PMeira commented 2 years ago

Is this also apply to PDElements.Name?

I think so. For most elements, each interface uses a dedicated list. The only oddity is Lines, which reuses the current active circuit element.

If yes, what is the point of SetActiveElement?

Not every component has a dedicated interface, so that's useful in those situations, for example. Internally, OpenDSS also uses some similar functions when a general circuit element is required.

This behavior is inherited from the official implementation so we cannot change it. Our future alternative API should remove this limitation and others, but we will leave the current API intact both for backwards compatibility with our previous versions and on-going compatibility with the official OpenDSS concepts.

PMeira commented 1 year ago

Closing this one in favor of https://github.com/dss-extensions/dss-extensions/issues/12

EDIT: An exploration of this topic is now available at https://dss-extensions.org/classic_api#the-active-paradigm