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

PTDF matrix does not use lookup dictionary when retrieving a row of the matrix #79

Open
dlcole3 opened this issue Apr 9, 2024 · 3 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@dlcole3
Copy link

dlcole3 commented Apr 9, 2024

I found that the PTDF matrix does not recognize the lookup dictionary when trying to access the vector of line data corresponding to a given bus. For example, in the code below, I get an error on the last line because the number for the bus "Cobb" (321) is greater than that dimension of the matrix (73). This is using Julia 1.9 with PSY v3.3.0, PNM v0.10.0, and PSCB v1.2.5.

using PowerNetworkMatrices, PowerSystems, PowerSystemCaseBuilder
rts_sys = build_system(PSITestSystems, "test_RTS_GMLC_sys")

ptdf = PTDF(rts_sys)
bus = get_component(Bus, rts_sys, "Cobb")

vector = ptdf[:, get_number(bus)]

This error came up because I was using the code from PowerSimulations.jl here to compute the LMPs of a Sienna simulation. This was fairly easy to work around (just mapping the values in ptdf.axes[1] to the order they appear) but wasn't sure if this was expected behavior. Wondering if it would make sense to have ptdf.axes[1] be the bus names instead of the bus numbers to avoid this issue. For example, if I instead call ptdf["A1", :], I do get the expected behavior where it gives me the column corresponding to Line "A1".

Also, as a related note, it was a little confusing to me that the PTDF matrix expects the indexes to be passed as column then row, rather than row then column (e.g., ptdf["A1", 101] rather than ptdf[101, "A1"]) since the dimensions in ptdf.axes are listed with the bus number as dimension 1 and line names as dimension 2. Just an observation as a first time user. Overall though, thank you for making and supporting the Sienna suite. It has been very helpful.

@jd-lara jd-lara added the bug Something isn't working label May 28, 2024
@jd-lara
Copy link
Member

jd-lara commented May 28, 2024

I think this is a bug in the indexing.

@jd-lara
Copy link
Member

jd-lara commented Sep 21, 2024

I looked into this issue and it seems that we default to interpreting int indexes the the bus location and not the number. if you pass the bus object then it works fine. We could make this error more informative.

@jd-lara
Copy link
Member

jd-lara commented Sep 21, 2024

this should work

using PowerNetworkMatrices, PowerSystems, PowerSystemCaseBuilder
rts_sys = build_system(PSITestSystems, "test_RTS_GMLC_sys")

ptdf = PTDF(rts_sys)
bus = get_component(Bus, rts_sys, "Cobb")

vector = ptdf[:, bus]

@jd-lara jd-lara added documentation Improvements or additions to documentation and removed bug Something isn't working labels Sep 21, 2024
@jd-lara jd-lara self-assigned this Sep 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants