Hello,
I’m trying to create a code which is able to take several different dagmc-geometries and input settings from different folders and run them each in series. The aim is to be able to run several versions of a geometry in series as a batch run. I’m doing this so that other people who do thermofluids simulations can easily run several versions of their designs without too much hands-on work.
The current directory setup I have is:
/source
all_python_code
/batch_directory
/run_1
input_file.json
dagmc_file.h5m
/run_2
…
/…run_n
Where the python code simply iterates over the run-directories inside the batch_directory and runs each of the simulations in series. It saves all the results to the same directory. I do this by openmc.run(cwd=batch_directory/run_nr).
The first run I do always works fine but I get some strange issues on the second run. The surfaces I define and name manually in the geometry-setup come up as:
/home/user/miniconda3/envs/openmc_coupling/lib/python3.8/site-packages/openmc/mixin.py:70: IDWarning: Another Surface instance already exists with id=9999.
warn(msg, IDWarning)
/home/user/miniconda3/envs/openmc_coupling/lib/python3.8/site-packages/openmc/mixin.py:70: IDWarning: Another Surface instance already exists with id=9991.
warn(msg, IDWarning)
/home/user/miniconda3/envs/openmc_coupling/lib/python3.8/site-packages/openmc/mixin.py:70: IDWarning: Another Surface instance already exists with id=9992.
warn(msg, IDWarning)
Essentially saying that there already exists surfaces with those names. The surfaces I don’t name manually are “ok” because they get auto_IDs, but the script later gets an error because the autoIDs don’t work with my post-processing, which is directly related to the surface IDs. This is strange because I’m using a new instance of my openmc-model and the runs don’t share any of the input xml-files or even dagmc-files. I’ve tried adding
openmc.lib.hard_reset()
after each run, and also importlib.reload(openmc) but still getting the same warnings. I’ve tried deleting the previous run-directory between each run but same issue. This leads me to think that it’s some sort of memory-issue where the code has some legacy openmc-stuff floating around from the previous run. Is there a better way of resetting openmc or other parts of the code?
Any other ideas of what this could be? Of course it could just be something silly I do with the code but I genuinely can’t figure our what that would be. If I run the code manually in single-mode twice then there is no issue, but as soon as I run it twice in a simple loop then it fails, which is strange because there should really be nothing saved between those two runs.
if __name__ == '__main__':
for j in range(2):
main(run_mode='single')
Another option would be to create a new python script which runs the separate folders as separate processes using the subprocess module or similar. Maybe this is easier?