Hi Bruce,
You'd like a list of all of the loads grouped by bus number and their P and Q values. Is that close?
I'd use the subsystem data retrieval API to collect information about the loads. The subsystem API gives you all of the loads at once, rather than getting them one at time like with the single element data retrieval API.
Here is what it might look like to grab a list of the bus numbers and ids of all the loads in a case.
ierr, numbers_ids = psspy.aloadint(sid=-1, string=["NUMBER", "ID"])
sid=-1
is just a short-hand for "a subsystem that covers the entire case". The numbers_ids
variable will be a list of lists:
[ [2002, 2003, 2004, 2004, 2005, ... ]
[1, 1, 1, 2, 1, ...] ]
I'd do something similar to get the real and reactive power:
ierr, p_qs = psspy.aloadreal(sid=-1, string=["P", "Q"])
Now join the numbers, ids, P and Q values all together to make a list of four columns:
nums_ids_p_q = numbers_ids + p_qs
Transpose the list of four columns into rows because it is easier to work with:
loads = zip(*nums_ids_p_q)
Each row of the loads
variable represents the number, id, P and Q value:
[ (2002, 1, 1.3, 0.8),
(2003, 1, 1.04, 0.9),
... ]
Now your data is in a pretty standard looking format. Kind of like a spreadsheet in Excel. You could write little bits of code to sum up and give you totals per bus and per load.
Let me know how you get on with it. If you get some code working, but need some specific pointers, you can update your question pretty easily.
(edit)
The next step is to sum the total load flowing radially from a terminal station. And there are a couple of ways to do this.
1.
Total load flowing from the terminal station. This is probably what you are looking for if you are sizing the bus at the terminal station.
2.
Total load existing radially from the terminal station, excluding any losses. I'd sometimes use this method as a sanity check to see if my model is correct.
I'll take you through how to do number 1. It is far easier to calculate and answers your question (Let me know if it doesn't).
explanation of terms
In our mock system, bus 2100 is the terminal station bus. Buses 2110, 2120 and 2130 are radial from the terminal station. Whereas buses 2240 and 2250 are not radial.
the method
List of all the P and Q branch flows in the case.
Select the P and Q branch flows from our target terminal (some radial, some will be back into the main system)
Identify which branches are radial
Sum those radial PQ values.
list all PQ flows in the case
ierr, from_to = psspy.aflowint(sid=-1, string=["FROMNUMBER", "TONUMBER"])
ierr, p_q = psspy.aflowreal(sid=-1, string=["P", "Q"])
from_to_p_q = from_to + p_q
branches = zip(*from_to_p_q)
branches from our ... (more)
Sorry, I don't know of a script I can point to that is ready made. But here is how I'd start it off.