Ask Your Question

Scipy optimize during dynamic simulations

asked 2020-11-27 00:52:08 -0500

IndiraX gravatar image

updated 2020-11-27 01:00:14 -0500

Hi everyone,

Does anyone has used scipy.optimize to tune control parameters during dynamic simulations? What I expect is to adjust (increase/decrease) my parameters regarding an optimal decision for each dynamic simulation (iteration). The outcome will be a set of control parameters that will provide the desired response.

Thanks in advance. (

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2020-12-02 02:05:50 -0500

jfconroy gravatar image

updated 2020-12-02 02:06:15 -0500

This sounds like a classic optimization problem. You need to define what your objective is, and what are the ranges for which you are allowing the input parameters (controller settings) to change. You will then have to run simulations in a loop, checking the value of your objective function after each run, and adjusting your input parameters according to your optimization algorithm. This can all be automated in a Python program that is calling PSS/E, running the simulation and extracting the results from .out or .outx files.

edit flag offensive delete link more


Hi jfconroy! Yes, it is what I need to do. Firstly, I thought to use scipy but I don't think it will work. Then, I wonder if I could get an example from the forum to build my own code. It would be just great! Thanks

IndiraX gravatar imageIndiraX ( 2020-12-02 03:06:15 -0500 )edit

I don't have an example that I can provide.

jfconroy gravatar imagejfconroy ( 2020-12-02 03:49:48 -0500 )edit

If you're not happy with scipi, you can use one of the many optimization packages that are available on the Python package website Before starting your optimization code, you need to write the code to run PSS/E simulations in a loop and extract the results into Python/numpy arrays.

jfconroy gravatar imagejfconroy ( 2020-12-02 03:50:15 -0500 )edit

Yes, I have my code to run the PSS/E simulation in a loop, read and change the CONs. I will have a look on the website you suggested jfconroy. Thanks

IndiraX gravatar imageIndiraX ( 2020-12-02 21:43:41 -0500 )edit

answered 2020-11-30 21:37:09 -0500

IndiraX gravatar image

Nobody has replied :(

edit flag offensive delete link more


This is a pretty big ask. I don't have experience with this, but I could imagine how one could go about. Run your simulation within Python, open up the .out file, look at the recorded parameters, and adjust. I think opening the .out fle every one or few timesteps will get slow.

likethevegetable gravatar imagelikethevegetable ( 2020-12-01 10:13:53 -0500 )edit

You might be better off tuning the controls post-processing. If you have an algorithm to dynamically tune the parameters, perhaps you could implement it in a user-written model? Although writing that FORTRAN could be tough.

likethevegetable gravatar imagelikethevegetable ( 2020-12-01 10:15:26 -0500 )edit

Hi! I think you understand my issue really well. I have run my simulation, I access to the parameters, and I can evaluate my variables post-simulation. What I am looking for it is an algorithm to tune the parameters. I thought of scipy but I haven't seen any code on how to use for this process

IndiraX gravatar imageIndiraX ( 2020-12-01 19:39:48 -0500 )edit

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


Asked: 2020-11-27 00:52:08 -0500

Seen: 91 times

Last updated: Dec 02 '20