a map of indices #1348
Replies: 5 comments 5 replies
-
indeed there is, have a look at "mapping the buses" in https://github.com/e2nIEE/pandapower/blob/develop/tutorials/internal_datastructure.ipynb |
Beta Was this translation helpful? Give feedback.
-
I do not understand why in the tutorial we are taking the index for the Ybus matrix again from the pd2ppc_lookups. For the Ybus matrix, there is a second different mapping necessary from ppc indices. ref = net._ppc['internal']['ref']
pvpq = net._ppc['internal']['pvpq']
refpvpq = np.r_[ref, pvpq]
pvpq_lookup[refpvpq] = np.arange(len(refpvpq)) pvpq_lookup is the mapping you use to get from the ppc_index to the internal Ybus index. I agree that this is very confusing and that an explicit dictionary of some sort must be implemented instead of such mapping arrays, for the Ybus matrix but also for the J matrix. Best regards, Roman |
Beta Was this translation helpful? Give feedback.
-
Clearly, there is confusion in mapping indices, which has also been reflected in a tutorial. For a real-world grid model, a small mistake in creating these maps could lead to unrealistic results. I suggest that we create the following maps so that the user doesn't have to go through the internal layers (ppc and ppci) all by oneself.
These two dictionaries form maps between the two end layers involved in pandapower load flow calculations and can be used not just by the user but also inside pandapower if required. Furthermore, as @rbolgaryn also says, it would be very convenient to have two more similar dictionaries that map the pandapower indices to the indices of the Jacobian and vice versa. One could argue that a cleaner way of doing this would be to just have lists instead of dictionaries but that would lead to confusion again considering that the pandapower bus indices need not be from 0 to (N-1). |
Beta Was this translation helpful? Give feedback.
-
There used to be such a dictionary, but the reason why it was changed to an array is performance. For nets with a large number of buses, the dictionary solutions significantly slowed down the loadflow, because we aloways needed to iterate over every bus in a python loop. So we changed it to an array, which allows to vectorize the lookup and is therefore much, much faster. We could implement a helper function that creates such a mapping dictionary for "external" usage. But for the loadflow, we should stick with the array solution to keep the loadflow lightning fast :) |
Beta Was this translation helpful? Give feedback.
-
Hello, You might also use a class for this: in the init phase it saves net, ppc, ppci, used for the conversions. Say an object of the class is called conv. Suppose also that we have (say) a numpy array x_ppci with the rows indexed the same as the ppci bus matrix. Then you would like to be able to just do As shravanchiply says, the advantage is that you can use the speed of only using arrays, but that the logic behind it always stays hidden. |
Beta Was this translation helpful? Give feedback.
-
Hello,
Have been wondering if there is a function available that directly maps the indices of the voltage vector V that is calculated by the Newton-Raphson algorithm in AC power flow to the indices of buses in the pandapower network?
The source code indicates that ppci is modified by many functions along the way before it reaches the pandapower network with power flow results. Creating such a map would require going through all those functions and understanding how they work, which seems to be tedious. Is there a better way?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions