Closed RichriD closed 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.
I'm worried that this will happen with the rest of the similar functions, so I hope you will pay attention when using.
To add, it is when the makeYbus function is called separately that this happens.
Dude, he's right. The script doesn't run if the indexing is wrong.
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.
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)