I’ve been asked many times: “How do I solve a loadflow with Python?” It’s a great question because once you know how to solve a loadflow – you can begin to automate your PSSE work.
This video will show you exactly how to solve a PSSE loadflow using the full newton raphson solution.
If you want to see more tutorial posts like this: Tell us what topic you’d like covered using this form
Transcript
Hi there power systems engineers, today I’m going to show you how to solve a load flow in Python using PSSE. In the last lesson we looked at how to set up your PSSE script so that you could run PSSE from Python and not the other way around.
So I’m going to build on that script and add the capability to run a load flow and then say how many iterations that last load flow took to solve.
I’ve set up the script in the same way as the last video. We’ve changed the
python path so that python knows where to find the psspy
library. and I’ve
redirect
ed PSSE output to python.
Initialise PSSE
Just run psseinit
to initialise psse. If you run the
program you find that you get that psse initialise text.
Load a saved case
To solve a case you first need one loaded in memory.
To load the saved case use the case
function. I’m just using the example
saved case that comes with PSSE savnw.sav
.
If I run this again we see that the savnw
case is loaded in memory and
was correctly loaded.
Solve the saved case with fnsl
The next step is to solve it, and print a little message to the screen. That says the number of iterations in the last solution. I’m using the Full Newton Raphson solution.
I’m using the iterat
function. The iterat
function gives the number of
iterations the last solution took to solve. And we substitute this value into
the string with the percent ’s’ (%s
).
Here we can see there were 6 iterations, and my last print statement shows the number of iterations was 6.
Conclusion and sneak peak at the next video
That is how easy it is to run a full newton raphson solution. I can run with other options, I can run with taps stepping disabled and I can disable switched shunt adjustments as well.
The answer should be the same in this file, but that may not be true of your
files. I knew that these options, options1
and options5
existed, and I’ll
show you how I found them in the next video.
If you have any questions about how to solve a load flow with Python, get onto https://psspy.org/ and ask a question (it’s free).