Information exchange between python scripts during step-by-step simulation

Hello everybody,

What is the best way to dynamically exchange information between the “main” python simulation script (when simulation is ran step-by-step), and BC/source terms python script?

E.g. if values of BCs/source terms should change in time based on the current results of the simulation and some additional calculations?
Currently I’ve been doing it “primitively” by saving (from the main script) and loading (in BC script) json/txt files, but it’s done for every time step, and every source term point, so it results with a lot of read/write operations. Probably I’m missing some basic python knowledge to figure out a better solution :slight_smile:

Thank you and best regards

1 Like

Yes, writing data to files and reading back the information can be a significant bottleneck. All information should be kept in memory (in your case, in a single interpreter). Without having seen your Python scripts, we think the solution can be implemented either entirely in the Cosim environment (step by step) or in the Python BC/Source Term scripts. Perhaps you could provide us with your script so that we can understand the overall intent.

Tom and Tobias