Installing OpenMC in Docker

Hello,

I am interest in using for OpenMC for my capstone project to simulate different external material entering the core, and determining the effects they can have the reactivity. Since I only have a computer running Windows, I decided to install OpenMC through Docker. I was able to follow all of the steps from Section 7 of the Developer’s Guide; however, I am not sure how to proceed from here. I have opened a new container with the “debian/openmc:lastest” image, but I am not sure what do to next. This is my first experience with Docker and the Linux environment, so it is possible that I have missed something.

Any help would be greatly appreciated.

Welcome to the forum @alvinolay and glad to hear that you are interested to use OpenMC for your project. Once you have that image open, you should be able to run the openmc executable as well as any Python script that uses OpenMC’s API (import openmc; ...). Your docker image will need to have access to the relevant files (either a .py file that contains the model, or the generate .xml files that the openmc executable relies on).

@Shimwell is our docker expert so he might have further advice here.

Excellent choice to use Docker :slight_smile:

We should add some more instructions to the documentation at some point but in the mean time it would be helpful to know how you want to use OpenMC

The Docker image we have is minimal (by design) and can therefore be connected to in a few different ways. It can support a range of uses such as:

  • Continuous integration for testing.
  • Running in interactive mode which allows terminal access to the docker environment.
  • Volume mount with windows and run xml or py files made in windows.
  • Running with a Jupyter notebook server that forwards ports to a browser window access to the docker environment.

This last option is the one I tend to recommend for anyone getting started and I happen to have a tutorial video that shows the Jupyter usage would look like.

Is this interface to the docker image suitable for your project? If so I can provide details of how to add Jupyter to that image if not do any of the other options sound suitable?

Thank you both for responding!

The Jupyter interface does look more intuitive, so I’m going to follow your tutorial video and install through Docker. Is there any way to develop my own code through this method, or would I still require a Python interface that uses OpenMC’s API?

@alvinolay Could you elaborate on what you mean by “develop my own code”. Generally, building models in OpenMC involves using the Python API, so you would be writing your own code/script.

Sorry, that is what I meant, writing my own code/script. But I was wondering if it were possible using Jupyter notebooks. I was able to follow the tutorial video, and I looked through some of the examples through docker, but I am not quite sure how to start my own script.

Yes, a Jupyter notebook is basically a glorified Python script, with extra features (ability to run lines one at a time, adding text blocks, equations, etc) and a nice UI on top of it. So, anything you can do in a Python script, you can do in a Jupyter notebook.

Great, I was just able to figure out how to start my own script via a Jupyter notebook. Thank you for your help, I really appreciate it!

@Shimwell With your tutorial video, I was able to use the Jupyter notebook and start my own script to run one of the examples from the OpenMC website via the ukaeaa/openworkshop image. However, when I inputted the “openmc.run()” function, I got an error (attached below). Is it possible that I need to have the “debian/openmc:lastest” image running as well, or does the workshop image not support the said function?

Glad to hear that ukaea/openmcworkshop image is useful. It should work on its own without any additional images.

Did you run one of the tasks and it produced that error or have you build your own OpenMC model and run it to produce that error.

Any chance you can show the code you ran.

All the best Jon

Thanks for the response Jon. Turns out its was just a syntax error. Sorry to bother you.

Congrats on solving that one. Best of luck with the docker image.

You might also want to investigate volume mounting which would allow you to have files developed on your local machine and access them on the docker image Use volumes | Docker Documentation

Also just for your information I am planning to upgrade that docker image to use Jupyter Lab which is even nicer than the Jupyter notebook. This upgrade will give a little file folder view which can also be helpful for navigation and finding files.