Skip to content

Commit b99257a

Browse files
committed
Expose CompatFlags
1 parent 9ab8b59 commit b99257a

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

opendssdirect/Basic.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,47 @@ def AllowChangeDir(*args):
158158
CheckForError(lib.DSS_Set_AllowChangeDir(Value))
159159

160160

161+
def CompatFlags(*args):
162+
"""
163+
Controls some compatibility flags introduced to toggle some behavior from the official OpenDSS.
164+
165+
**THESE FLAGS ARE GLOBAL, affecting all DSS engines in the process.**
166+
167+
The current bit flags are:
168+
169+
- 0x1 (bit 0): If enabled, don't check for NaNs in the inner solution loop. This can lead to various errors.
170+
This flag is useful for legacy applications that don't handle OpenDSS API errors properly. Through the
171+
development of DSS Extensions, we noticed this is actually a quite common issue.
172+
- 0x2 (bit 1): Toggle worse precision for certain aspects of the engine. For example, the sequence-to-phase
173+
(`As2p`) and sequence-to-phase (`Ap2s`) transform matrices. On DSS C-API, we fill the matrix explicitly
174+
using higher precision, while numerical inversion of an initially worse precision matrix is used in the
175+
official OpenDSS. We will introduce better precision for other aspects of the engine in the future,
176+
so this flag can be used to toggle the old/bad values where feasible.
177+
- 0x4 (bit 2): Toggle some InvControl behavior introduced in OpenDSS 9.6.1.1. It could be a regression
178+
but needs further investigation, so we added this flag in the time being.
179+
180+
These flags may change for each version of DSS C-API, but the same value will not be reused. That is,
181+
when we remove a compatibility flag, it will have no effect but will also not affect anything else
182+
besides raising an error if the user tries to toggle a flag that was available in a previous version.
183+
184+
We expect to keep a very limited number of flags. Since the flags are more transient than the other
185+
options/flags, it was preferred to add this generic function instead of a separate function per
186+
flag.
187+
188+
Related enumeration: DSSCompatFlags
189+
190+
(API Extension)
191+
"""
192+
# Getter
193+
if len(args) == 0:
194+
return CheckForError(lib.DSS_Get_CompatFlags())
195+
196+
# Setter
197+
Value, = args
198+
CheckForError(lib.DSS_Set_CompatFlags(Value))
199+
200+
201+
161202
_columns = [
162203
"Classes",
163204
"DataPath",

0 commit comments

Comments
 (0)