Running openmc from python

Heiyas,

I’m very new to openmc and want to it from python. How should I do this? Is this something I type in the .py script, and if so, how do I execute it?

To be clear, I don’t want to run openmc in my terminal since I want to be able to set the number of threads it will use.

1 Like

Welcome to the forum @TimeLard

If you want to run it from python, you can set number of threads with

openmc.run(threads=8)

you’ll find more details here

From the command line, you can use -S command-line argument to set number of threads.

Thank you. What does it mean by a “process” in the MPI section?

It means number of copies of the program on the given node. Those instances will communicate with each other via MPI.

A process is simply an application running on your computer with one or more threads. MPI allows you to start multiple copies of the same OpenMC process that run independently (notably each occupies its own memory space) but can communicate through standards calls. OpenMC uses these communication calls in order to collect results from the different processes. If you have multiple cores on a computer, you need to either use threading, MPI, or a combination of them to fully utilize the hardware resources. If you are running on a single machine, threading is usually sufficient. If you are running on a cluster where multiple nodes are connected by a network, MPI is needed to utilize multiple nodes.