First time here? We are a friendly community of Power Systems Engineers. Check out the FAQ!
1 | initial version |
You may use a small script within your python file which reads the last n
lines of progress_file.txt
generated by the simulation at fixed time intervals.
If and when it detects the Network not converged string, you may extract the full line to get further details, example:
'Network not converged at TIME = 97.8525'
As per the asked question, you are free to stop your simulation at the same interval.
Why use this method?
This method can help you diagnose (or at least get an idea about) your simulation problems within your python run.
By reading the progress_file, you can also acquire 'events' which led to the Network not converged without shifting your eyes from the python file you're using to run PSSE. For example, using an additional search for beyond string in the the same last n
lines may reveal warning lines like:
Machine "1" at bus 1 [BUS1 16.500]: PGEN (7.0) is beyond its limits (PMIN=10.0, PMAX=250.0)
which you may then print to the terminal within the run.
Python code
If you want, you may refer to my implementation of this script in python, which itself uses a module (tail.py
) I found in this StackOverflow answer for reading last n
lines of the desired file.
Note 0: The tail.py
linked in this answer is only for Python 2. But you may use a different implementation available on the same page for Python 3.
Note 1: My implementation is a bit sloppy as I chose the value of n
to be arbitrarily high like a 1000
which may cause overlapping 'reads' of the same string in different checking intervals. The code can definitely be refined to 'smartly' read after simulation time step or a multiple of such steps instead of a fixed number of lines.
2 | No.2 Revision |
You may use a small script within your python file which reads the last n
lines of progress_file.txt
generated by the simulation at fixed time intervals.
If and when it detects the Network not converged string, you may extract the full line to get further details, example:
'Network not converged at TIME = 97.8525'
As per the asked question, you are free to stop your simulation at the same interval.
This method can help you diagnose (or at least get an idea about) your simulation problems within your python run.
By reading the progress_file, you can also acquire 'events' which led to the Network not converged without shifting your eyes from the python file you're using to run PSSE. For example, using an additional search for beyond string in the the same last n
lines may reveal warning lines like:
Machine "1" at bus 1 [BUS1 16.500]: PGEN (7.0) is beyond its limits (PMIN=10.0, PMAX=250.0)
which you may then print to the terminal within the run.
If you want, you may refer to my implementation of this script in python, which itself uses a module (tail.py
) I found in this StackOverflow answer for reading last n
lines of the desired file.
Note 0: The tail.py
linked in this answer is only for Python 2. But you may use a different implementation available on the same page for Python 3.
Note 1: My implementation is a bit sloppy as I chose the value of n
to be arbitrarily high like a 1000
which may cause overlapping 'reads' of the same string in different checking intervals. The code can definitely be refined to 'smartly' read after simulation time step or a multiple of such steps instead of a fixed number of lines.