2

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?

lmcqueen's avatar
76
lmcqueen
asked 2018-07-27 01:28:04 -0500
edit flag offensive 0 remove flag close merge delete

Comments

1

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

EBahr's avatar EBahr (2018-08-09 11:53:14 -0500) edit
add a comment see more comments

3 Answers

1

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.

perolofl's avatar
3.8k
perolofl
answered 2018-08-17 05:07:12 -0500
edit flag offensive 0 remove flag delete link

Comments

You can also add this directly to CONET.flx --- IF(ITER .GT. ITMXDS) --- then set the flags as @perolofl mentioned.

wassup_doc's avatar wassup_doc (2019-02-21 17:04:31 -0500) edit
add a comment see more comments
1

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.

Aryan Ritwajeet Jha's avatar
27
Aryan Ritwajeet Jha
answered 2022-06-12 13:21:40 -0500, updated 2022-06-12 13:24:53 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments
0

Morning I never tried this problem but I can advice you that read chapter 4 in the documentation Best regards

Anderson's avatar
1
Anderson
answered 2018-07-31 23:35:05 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments

Your Answer

Login/Signup to Answer