Ask Your Question
2

Python API to Terminate Dynamic Simulation

asked 2018-07-27 01:28:04 -0500

ffl gravatar image

Is there an API to terminate dynamic simulation when a given number or threshold of Network Not Converged (NNC) is exceeded?

edit retag flag offensive 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 gravatar imageEBahr ( 2018-08-09 11:53:14 -0500 )edit

3 answers

Sort by ยป oldest newest most voted
0

answered 2018-07-31 23:35:05 -0500

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

edit flag offensive delete link more
1

answered 2018-08-17 05:07:12 -0500

perolofl gravatar image

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.

edit flag offensive delete link more

Comments

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

wassup_doc gravatar imagewassup_doc ( 2019-02-21 17:04:31 -0500 )edit
1

answered 2022-06-12 13:21:40 -0500

Aryan Ritwajeet Jha gravatar image

updated 2022-06-12 13:24:53 -0500

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Question Tools

1 follower

Stats

Asked: 2018-07-27 01:28:04 -0500

Seen: 854 times

Last updated: Jun 12 '22