Python for Power Systems

A blog for power systems engineers to learn Python.

How the Max Buses Setting Affects Your Code

..when you have eliminated the impossible, whatever remains, however improbable, must be the truth

Sherlock Holmes The Sign of the Four

This is a story about psspy.psseinit and how its buses argument is not so innocent and will one day commit a terrible crime on your study.

Have you ever sat and wondered why PSSE insists on asking for a buses argument when initialising? Did you notice that it isn’t optional? I’ve sat at my computer many times thinking: “Will I need 300, 1000 or 10,000 buses?”

What is the buses argument?

According to the API guide in section 12.13: The buses argument is the requested bus size. Not especially helpful, so in plain english we say the buses argument is:

buses - The maximum number of buses allowed in your study

Why have a maximum number?

PSSE was written in a time when creating a busmatrix in the computer’s memory was a difficult task. In those days, once you had picked a matrix size, thats was it, there was no second chance to resize it. So picking the maximum number of buses was very important. Choose a huge matrix and your poor computer’s memory would fill up, choose one too small then the matrix wouldn’t fit all of your buses.

PSSE uses more memory when you initialise more buses

We decided to put this to the test. The PSSE documentation states that the maximum number of buses it can handle is 150,000. So we initialised PSSE over and over and over with a maximum of 10 buses up to 1 million and measured how much memory it used.

The results are clear, allocating more maximum buses uses more memory until 150,000 when allocating more buses has no effect – because the additional buses beyond 150,000 are ignored.

The terrible crime and how to avoid it

Because of the history when PSSE was written, you must pick the correct size. If you pick a maximum number of 100 buses, and your raw file has 120 buses then 20 of those buses will not be loaded. Unlike for raw files, our experiments have shown that loading a saved case (.sav file) resets the maximum bus size to the one used in the sav case.

So some advice: be sure to set a maximum bus size large enough to handle your system size, but not too large otherwise PSSE will gobble up all of your memory. We suggest that 10,000 buses is enough, if you regularly use more than 10,000 buses let us know in the comments.