-
Notifications
You must be signed in to change notification settings - Fork 19
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
PyDSS is incompatible with OpenDSSDirect.py v0.8.1 #121
Comments
Hi, @daniel-thom, Note that on recent OpenDSS releases there are Apologies if I'm jumping to conclusions (I didn't check the whole code), but maybe the usage on the related code in PyDSS is not fully appropriate: Lines 83 to 91 in cf9dc0d
There currently these related functions in ODD.py, but I only saw
(The "Variable" term is a bit murky and overloaded (e.g. there are parser variables too), but here they mostly refer to "state variables") Sample for $ pip list | grep -i dss
dss-python 0.14.2
dss-python-backend 0.13.2
OpenDSSDirect.py 0.8.2 >>> import opendssdirect as odd
>>> odd.Basic.Version()
'DSS C-API Library version 0.13.2 revision 4594b283edf19767f69e24ca3ad22f7553505731 based on OpenDSS SVN 3604 [FPC 3.2.2] (64-bit build) MVMULT INCREMENTAL_Y CONTEXT_API PM 20230525031931; License Status: Open '
>>> odd.Basic.NewCircuit('test')
'New Circuit'
>>> odd.Text.Command('new line.line1')
>>> odd.CktElement.Name()
'Line.line1'
>>> odd.CktElement.AllVariableNames()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/meira/bin/python/lib/python3.10/site-packages/opendssdirect/CktElement.py", line 78, in AllVariableNames
return CheckForError(get_string_array(lib.CktElement_Get_AllVariableNames))
File "/home/meira/bin/python/lib/python3.10/site-packages/dss/_cffi_api_util.py", line 145, in _check_for_error
raise DSSException(error_num, self._get_string(self._lib.Error_Get_Description()))
dss._cffi_api_util.DSSException: (#100004) The active circuit element is not a PC Element
>>> odd.CktElement.AllVariableValues()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/meira/bin/python/lib/python3.10/site-packages/opendssdirect/CktElement.py", line 83, in AllVariableValues
return CheckForError(get_float64_array(lib.CktElement_Get_AllVariableValues))
File "/home/meira/bin/python/lib/python3.10/site-packages/dss/_cffi_api_util.py", line 145, in _check_for_error
raise DSSException(error_num, self._get_string(self._lib.Error_Get_Description()))
dss._cffi_api_util.DSSException: (#100004) The active circuit element is not a PC Element
>>> odd.Error.ExtendedErrors(False)
>>> odd.CktElement.AllVariableNames()
[]
>>> odd.CktElement.AllVariableValues()
[0.0]
>>> Samples for (
Note that most of the variables have useful values only when import opendssdirect as odd
odd.Basic.AllowEditor(False)
odd.Text.Command('redirect "./electricdss-tst/Version8/Distrib/Examples/InductionMachine/Run.dss"')
odd.Circuit.SetActiveElement('IndMach012.motor1')
print(odd.CktElement.Name())
print(dict(zip(odd.CktElement.AllVariableNames(), odd.CktElement.AllVariableValues()))) Should output:
PS: if you want to see the plots for this last sample (requires matplotlib), add these at the beginning: import dss.plot
dss.plot.enable() |
@PMeira Thanks for checking on this issue and providing this helpful information. |
EDIT: some recommendations in the new docs too: https://dss-extensions.org/OpenDSSDirect.py/updating_to_0.9.html Since the ticket is still open, I'd like to mention what would be needed to upgrade to v0.9, which is under final testing and is planned to be released today. There will be a general document with some recommendations when upgrading, but since I checked testsuite from PyDSS, it's worth mentioning what I found:
from opendssdirect import dss as odd, enums as dss_enums
odd.Settings.SetPropertyNameStyle(dss_enums.DSSPropertyNameStyle.Legacy) There is also
BusVarDict = dssInstance.Bus.__dict__
for key in BusVarDict.keys(): with BusVarList = dir(dssInstance.Bus)
for key in BusVarList: There are similar issues in Note that many ODD.py classes/modules have had a
import opendssdirect as dss with from opendssdirect import dss Using 1 and 2 is enough to make all tests pass, so it shouldn't take too much effort to upgrade to v0.9 later. |
Here is a partial backtrace when running PyDSS on a circuit that has a Vsource element. OpenDSSDirect v0.8 has a new restriction that disallows calling
AllVariableNames()
when the active element is not a power conversion element (PCElement). The old docstring said,"Array of strings listing all the published variable names, if a PCElement. Otherwise, null string.
", so I suspect that this was always invalid and they are now correctly failing the operation.The text was updated successfully, but these errors were encountered: