Python API to Terminate Dynamic Simulation
Is there an API to terminate dynamic simulation when a given number or threshold of Network Not Converged (NNC) is exceeded?
First time here? We are a friendly community of Power Systems Engineers. Check out the FAQ!
Is there an API to terminate dynamic simulation when a given number or threshold of Network Not Converged (NNC) is exceeded?
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.
You have to write a user miscellaneous model that in MODE 3 will check variable ITER or IFLAG and set the following variables in order to stop the on-going simulation.
TPAUSE = -1.
KPAUSE = 1
The simulation will be interrupted and control is back to activity level. Read Program Operation, Chapter 23 Model Writing.
You can also add this directly to CONET.flx --- IF(ITER .GT. ITMXDS) --- then set the flags as @perolofl mentioned.
Morning I never tried this problem but I can advice you that read chapter 4 in the documentation Best regards
Asked: 2018-07-27 01:28:04 -0500
Seen: 923 times
Last updated: Jun 12 '22
API for changing tap position in dynamic simulation
Frequency change on load change in dynamic simulation.
USER DEFINED MACHINE MODEL "GEWTT1" NOT ACCESSIBLE
Where can I find good tutorials to initiate python with PSSE?
HOW TO CALCULATE FVSI FROM DYNAMIC SIMULATION
Dynamic simulation output channel
I hope someone has an answer to this as I have been looking for a solution like this for a while. It doesn't appear PSSEHALT works for this. Best thing I can conceive is a FORTRAN model that monitors the simulation then when I want simulation to stop, crash PSSE by dividing by zero. Awful, I know