rwl / PYPOWER

Port of MATPOWER to Python
http://rwl.github.io/PYPOWER/api/
Other
329 stars 110 forks source link

Bugs in makeYbus.py, lines 35-36 and lines 66-67 #73

Closed RichriD closed 2 years ago

RichriD commented 2 years ago

if any(bus[:, BUS_I] != list(range(nb))): stderr.write('buses must appear in order by bus number\n') Should be: if any(bus[:, BUS_I] != list(range(1, nb+1))): stderr.write('buses must appear in order by bus number\n') Also: f = branch[:, F_BUS] t = branch[:, T_BUS] Should be: f = branch[:, F_BUS] - ones(nl) t = branch[:, T_BUS] - ones(nl)

RichriD commented 2 years ago

When I called the function 'makeYbus.py', it appears 'ValueError: column index exceeds matrix dimensions'. This is caused by an indexing error.

RichriD commented 2 years ago

I'm worried that this will happen with the rest of the similar functions, so I hope you will pay attention when using.

RichriD commented 2 years ago

To add, it is when the makeYbus function is called separately that this happens.

rwl commented 2 years ago

https://rwl.github.io/PYPOWER/api/pypower.ext2int-module.html

WoodpeckerBaby commented 1 year ago

Dude, he's right. The script doesn't run if the indexing is wrong.

WoodpeckerBaby commented 1 year ago

I had to use this to patch the bug here

print(thisCase["bus"][:, 0])   # debug Ybus formating.
thisCase["bus"][:, 0] = thisCase["bus"][:, 0] - 1
print(thisCase["bus"][:, 0])

print(thisCase["branch"][:, [0, 1]])
thisCase["branch"][:, [0, 1]] = thisCase["branch"][:, [0, 1]] - 1
print(thisCase["branch"][:, [0, 1]])
[1. 2. 3. 4. 5. 6.]
[0. 1. 2. 3. 4. 5.]
[[2. 3.]
 [3. 6.]
 [4. 5.]
 [3. 5.]
 [5. 6.]
 [2. 4.]
 [1. 2.]
 [1. 4.]
 [1. 5.]
 [2. 6.]
 [2. 5.]]
[[1. 2.]
 [2. 5.]
 [3. 4.]
 [2. 4.]
 [4. 5.]
 [1. 3.]
 [0. 1.]
 [0. 3.]
 [0. 4.]
 [1. 5.]
 [1. 4.]]

And it worked.

So, you have to think about indexing becaue python is zero indexing and matlab is 1 indexing.