It has been 2 days I have performed the step 4 under Local Installation as mentioned in GitHub - fusion-energy/neutronics-workshop: A workshop covering a range of fusion relevant analysis and simulations with OpenMC, DAGMC, Paramak and other open source fusion neutronics tools. It is still showing some stuffs extracting and downloading and the following appeared:
I would also like to know that whether do I need to follow all these steps everytime I use OpenMC?
When using a prebuilt docker image containing openmc you tend to download the image once with a docker pull
command. Then it is saved to your computer. The image can then be run with a docker run
command.
In the neutronics workshop image the url displayed in the terminal can be loaded up with a browser and you should be presented with a jupyter notebook.
The neutronics-workshop is just one image but there are other images that have openmc installed such as these ones
https://hub.docker.com/r/openmc/openmc/tags
after pulling the latest docker image using docker pull openmc/openmc:latest, how do I run it?
docker run openmc/openmc:latest returned error.
Without seeing the error I can only guess that the command is missing something.
Perhaps try including -it
in the command like this
docker run -it openmc/openmc:latest
This is returning root@c0dad529ee9d:/# I tried to google on what shall I type to proceed further but it resulted nothing.
That sounds like the command has loaded up the docker environment. You should find openmc is installed in this new terminal. You can test that by typing openmc
This is what I receive:
PS C:\WINDOWS\system32> docker run openmc/openmc
PS C:\WINDOWS\system32> docker run -it openmc/openmc:latest
root@c0dad529ee9d:/# openmc
ERROR: Settings XML file ‘settings.xml’ does not exist! In order to run OpenMC,
you first need a set of input files; at a minimum, this includes
settings.xml, geometry.xml, and materials.xml. Please consult the user’s
guide at https://docs.openmc.org for further information.
application called MPI_Abort(MPI_COMM_WORLD, -1) - process 0
[unset]: write_line error; fd=-1 buf=:cmd=abort exitcode=-1
:
system msg for write_line failure : Bad file descriptor
root@c0dad529ee9d:/#
This is the error message from openmc saying it needs input xml files to work.
Congratulations you now have OpenMC installed and accessible in the Docker environment.
Thank you. That is great. But how do I access it now?
Now you have the software environment to run openmc the next step would be to make some openmc scripts and run them.
From within the docker file you can also run python scripts, including python scripts that have openmc models. Perhaps this section of the docs is useful
4. Basics of Using OpenMC — OpenMC Documentation
This is where I am now. How do I proceed to the python script or the Jupyter Notebook?
The openmc/openmc:latest docker image doesn’t have jupyter notebooks so if you wanted that you would need to modify the dockerfile and rebuild it. The neutronics-workshop images do have jupyter install and there are video tutorials for launching that on the github page
To launch python in the openmc/openmc:latest docker image I would click on the Terminal button, that will get you to the terminal of the docker image.
Once at the terminal you can type python
followed by the name of your python script. There are some example scripts in the examples folder so if you want to run a random example then you could type python /root/OpenMC/openmc/examples/jezebel/jezebel.py
1 Like
@Shimwell Thank you very much. You are a true saviour. It did work. But previously also and now too when I try to write a python script in the terminal of the Docker, it does not work.
For example if I want to create a simple geometry of a sphere I start with the import openmc command, it returns an error.
I think that is a third way of running things using the python in interactive mode.
This is different to running a script as you would have to enter each line one at a time. This might be ok for a few lines but running a script will be easier for a bigger number of lines.
It is worth looking carefully at the start of the terminal line to know if you are inside the docker bash shell #
or an interactive python shell >>>
Did you run this inside Windows Power Shell?
import openmc
import matplotlib.pyplot as plt
surf1 = openmc.Sphere(r=10)
reg= +surf1
cell= openmc.Cell(region=reg)
univ = openmc.Universe(cells=[cell])
plt.show(univ.plot(width=(1200, 1200), basis=‘xy’, colors=color_assignment))
upon writing the above code I received this below error:
Traceback (most recent call last):
File “”, line 1, in
File “/usr/local/lib/python3.9/dist-packages/matplotlib/pyplot.py”, line 411, in show
return _get_backend_mod().show(*args, **kwargs)
TypeError: show() takes 1 positional argument but 2 were given
I’m running docker from ubuntu terminal, but once you are inside a docker image the location shouldn’t make much different to the user where it was run from.
looks like univ.plot returns a matplotlib axis so you could try this
import openmc
import matplotlib.pyplot as plt
surf1 = openmc.Sphere(r=10)
reg= +surf1
cell= openmc.Cell(region=reg)
univ = openmc.Universe(cells=[cell])
f=univ.plot(width=(1200, 1200), basis="xy")
f.figure.show()
However docker run in interactive mode (-it) might not work with graphics such as showing the plot. So you might want have to run in WSL with graphics or docker with jupyter notebook enabled (like the neutronics-workshop docker image) or save the plot as a file and transfer it from docker to your regular OS using docker volumes.
Unfortunately this did not result any output when I typed the mentioned code in Windows Powershell.
Alternatively, I have installed WSL on my another system. I have installed Ubuntu 22.04 within it followed by installing VS code in the WSL environment and python extension within it. I did also install Anaconda within the linux subsystem. Then I followed the process of OpenMC installation in Linux . But now when I am trying to run a python script , there’s a message appearing saying that it cannot find python modules like matplotlib.pyplot. I am unable to figure out the issue.
the code block above is python so it would need to be typed into a python terminal or run as a python script, it is not intended to be directly typed into power shell.
matplotlib is installed when openmc is installed automatically so I’m not sure how this would have not been installed if openmc was installed.
Perhaps pop by the monthly meet up tomorrow and I’m sure we can get something working for you