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

CapControl PTphase for single phase monitor element can create unexpected behavior #134

Open
3 tasks
nlaws-camus opened this issue Apr 15, 2024 · 1 comment

Comments

@nlaws-camus
Copy link

Versions

  • Python version: 3.10.12
  • Operating system and version: tested in Google CoLab
  • OpenDSSDirect.py version number:

DSS C-API Library version 0.14.5 revision 87d85c2622c8281b92255335bc7c09b11191b21d based on OpenDSS SVN 3723 [FPC 3.2.2] (64-bit build) MVMULT INCREMENTAL_Y CONTEXT_API PM 20240329033721; License Status: Open
DSS-Python version: 0.15.7
OpenDSSDirect.py version: 0.9.4

Bug

This might be an issue in the source code for OpenDSS, where it checks if PTphase is less than the number of phases, but I just wanted to bring it to your attention.

The problem arises when specifying the CapControl PTPhase value to 3 in a three phase model. With PTPhase=3 in the toy model below the CapControl seems to be ignored. If you change PTphase to 1 or 2 then the States will be [1], even though the load is balanced and the voltage is the same (before control) on all three phases.

import opendssdirect as dss
dss(f"""
Clear
New Circuit.Test bus1=bus1 pu=1 basekv=12.47

New Line.line1 bus1=bus1 bus2=bus2 r0=0.35 x0=0.4 r1=0.1 x0=0.1 length=5 units=kft
New Line.line2 bus1=bus2 bus2=bus3 r0=0.35 x0=0.4 r1=0.1 x0=0.1 length=5 units=kft

New Load.load3 bus1=bus3 kw=1000 kvar=300 kv=12.47

New Transformer.cap_trfx phases=1 buses=[bus2.3 dummy.3] kvs=[7.2 7.2] kvas=[25 25]

New Capacitor.cap1 phases=1 bus1=bus2.3 kvar=300 conn=wye states=[0] kv=7.2

New CapControl.capcontrol Element=Transformer.cap_trfx capacitor=cap1
~ type=voltage onsetting=7200 offsetting=8500 PTphase=3  voltoverride=no
~ eventlog=y ptratio=1

calcvoltagebases
Solve
""")

dss.Capacitors.States()
[0]
PMeira added a commit to dss-extensions/dss_capi that referenced this issue Apr 16, 2024
@PMeira
Copy link
Member

PMeira commented Apr 16, 2024

where it checks if PTphase is less than the number of phases

Thanks for reporting this. The issue is that the phase checks are skipped for most modes (only worked for type=PowerFactor). I had a TODO note there for a while at https://github.com/dss-extensions/dss_capi/blob/0.14.5/src/Controls/CapControl.pas#L370 and your report confirms what I suspected before.

I moved the phase checks so they work with any control type, so you'll get an error in the next release (since this is not urgent, we'll wait a week or so before releasing new versions).

Although the current version shouldn't cause memory corruption, it is reading invalid data if you use a phase number greater than the available phases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants