Introducing openmc-plot a browser based option for plotting openmc geometry mesh tallies and dagmc geometry

The OpenMC-plotter is the best choice for plotting as it has tons of functionality.

Another option for plotting called openmc_plot is now available. The browser based approach used for openmc_plot offers a few interesting deployment options such as a web app or integration into docker based training courses.

The plotter can be installed to work locally with pip :snake:

pip install openmc_plot

And then launched with the command


As openmc_plot is a browser based I have also hosted a version for people to use without installing anything. It is on with my other neutronics apps but also accessible via this direct link.

The app is still relatively young so feedback is most welcome here or by raising a Github issue

The new plotter only took about 300 lines of code to make so it is easy to understand and maintain pull requests are most welcome. :pray:



Hi @Shimwell

Many thanks for coming up with this app. It seems very interesting, particularly for OpenMC beginners.

I tried using both the web-based version and the local installation. However, I get the same error with both (screenshot attached).

Could you please advice?

Thanks in advance.

Thanks for reaching out, would you be able to share the geometry.xml so I can reproduce the error and I shall get this fixed.


@lakshayjain I think I might have fixed it. I can’t be totally sure without running exactly the same geometry. But it looks like there was a bug with identifying materials that is now fixed.

Would you be able to try again with the recently released version 0.1.5 or the web app (which is running version 0.1.5). Many thanks

Also the app now has source plotting :tada:

Hi @Shimwell

Its a simple pincell problem. Here is the geometry file.
geometry.xml (713 Bytes)


1 Like

@Shimwell I tried using the web app. Although the earlier problem seems to have been sorted out, I am still seeing some error and the geometry is still not getting plotted.

Here’s a screenshot of the error I am seeing.

It seems that the z-coordinate of the origin is missing (Z axis offset bar extends from -NaN to -NaN).

Many thanks in advance for your help.

Awesome thanks for sharing the geometry.xml that made it so much easier to see I had totally forgotten about infinity values are possible for boundary values. @lakshayjain I reckon I’ve got it working with Verizon 0.1.7 if you have time to check.

Thanks so much for working through this with me

Hi @Shimwell,

I tried using the latest web app as well as version 0.1.7.

First of all, kudos for the wonderful job and thanks very much for coming up with it. The web app creates quick and robust interactive plots which, I feel, would be extremely useful for fresh and more experienced OpenMC users alike. Here’s a sample of what I got:

However, I am still facing issues with the installed version (0.1.7). The app seems to be searching for the path to cross_sections.xml using either the environment variable or materials.xml file. Is it necessary to set the environment variable since there is no option to upload the materials.xml file to the app?

Coming back to the web app, there is a new regular mesh tally plot option which is not yet there in the installed version. Are you planning to release it for the installed version as well (I am really looking forward to it)? Also, while the spatial distribution shows particle energy, the energy distribution plot shows an error. Could you share some insight into the requirements for generating the energy/angle distribution plot options?

Many thanks once again.

Thanks so much for reporting this cross section xml issue, I think I have now fixed that issue in version 0.1.8.

This version with the regular mesh plotter has also been released via PyPi as a pip install-able package for local use.

The code for the energy plotting comes form another package for plotting openmc sources GitHub - fusion-energy/openmc_source_plotter: A Python package for extracting and plotting the locations, directions, energy distributions of OpenMC source particles

If you can share the source settings.xml then I can get that fixed.

Many thanks for helping

The app now has mesh plotting :tada:

Thanks for looking into and fixing the issue in such short time and also releasing the regular mesh tally plotter feature with version 0.1.8. I have now tried plotting using the local installation of version 0.1.8 and the app generates excellent figures.

Here is the source settings.xml which corresponds to the geometry.xml I shared earlier (Introducing openmc-plot a browser based option for plotting openmc geometry - #5 by lakshayjain):
settings.xml (439 Bytes)

The app seems to be looking for an argument of the type ‘UnitSphere’ for angular distribution and ‘Univariate’ for energy distribution. Here are screenshots of the error:

It would be wonderful if you could look into this as well.

1 Like

Ah yes I see, the code was trying to set the angle but in this source the angle was set to None which was causing problems. I’ve added some checking before setting the angle, energy and space of the source now.

If you could give version 0.1.9 a go and let me know if that works for you. These are the plots I get with your settings.xml over here
Screenshot from 2022-11-28 22-43-09
Screenshot from 2022-11-28 22-42-59
Screenshot from 2022-11-28 22-42-50

This seems so cool. Thanks a lot! I just tried the web application, and it worked perfectly for two example geometry.xml files.

One thing that would make it even more pleasant to use, although I have no idea how to do such a thing (or how much work it is), would be if you could zoom in on specific areas with the mouse. A bit like in Matplotlib. I think this feature exists in the source plot.

If you could download it as svg, pgf or pdf, you could use the graphics generated here directly for publications / presentations.

But that’s just an idea that came to me, and actually, I wanted to say thank you first instead of giving you more work.

The source plotter is even more useful for me (did we have such a feature before? if so, I wasn’t aware of it.). So far, I was always doing it with a cumbersome construct of Python scripts.

Unfortunately, the pip package does not work properly for me, it seems like a similar problem lakshayjain had I believe.

I copied the terminal output below, and attach a screenshot of the error.


[cpf@t14s:~/Desktop/rdc/wip/run_20]$ openmc_plot

  👋 Welcome to Streamlit!

  If you’d like to receive helpful onboarding emails, news, offers, promotions,
  and the occasional swag, please enter your email address below. Otherwise,
  leave this field blank.


  You can find our privacy policy at

  - This open source library collects usage statistics.
  - We cannot see and do not store information contained inside Streamlit apps,
    such as text, charts, images, etc.
  - Telemetry data is stored in servers in the United States.
  - If you'd like to opt out, add the following to ~/.streamlit/config.toml,
    creating that file if necessary:

    gatherUsageStats = false

  You can now view your Streamlit app in your browser.

  Local URL: http://localhost:8501
  Network URL:

2022-11-29 09:49:38.492 Uncaught app exception
Traceback (most recent call last):
  File "/home/cpf/.local/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/", line 563, in _run_script
    exec(code, module.__dict__)
  File "/home/cpf/.local/lib/python3.9/site-packages/openmc_plot/", line 14, in <module>
    openmc.config['cross_sections'] = cross_section_path
AttributeError: module 'openmc' has no attribute 'config'
^C  Stopping...

1 Like

Thanks very much for posting @cp-f I really appreciate the ideas and feedback.

The downloading of a plot image can certainly be done, and I shall make that my next task :rocket:

For the local install, it looks like you have an older version of openmc. The openmc.config was introduced recently. Could you try updating your openmc version.

The zoom method you describe sounds good, I shall have to think about that one. Certainly, a feature I want to add but I only know how to do it with plotly. I shall put this on my todo list and look around for methods

Yes, you are right. At the moment, I am running an older version. This will probably solve the issue. Thanks a lot.

@cp-f we now have a Download button with v0.1.11 for the different plots. Most are just png files but the source plot is a html file when downloaded. To make this into an image open it in the browser (e.g. firefox) there is a small camera icon in the top right that allows one to take an image
Screenshot from 2022-11-29 16-17-06

This was fast. Thank you.

version 0.1.11 of openmc_plot has weight window plotting :tada:

Hi @Shimwell,

Many thanks for looking into the issue with source plotting and fixing the same. I am able to regenerate the plots similar to what you posted earlier, and again the plots are really of high quality, to say the least. Thanks for this and for introducing the weighted window plots.

I am still facing some issues with a different source plot though. The error I get is:
‘More than 95% of external source sites sampled were rejected. Please check your external source’s spatial definition’.
I am unsure of the problem at the moment and am looking into it. I will get in touch in case I am unable to figure it out.

Another small observation and it would be wonderful to have your insights on this. Plotting with the local installed version, there are some interesting warning messages:

  • Source plot: ‘Cross section library /path/to/local/installation/openmc_plot/FENDL-3.1d_Li6.h5 does not exist.’
    (Is the app looking for FENDL-3.1 data for the source plots and why particularly Li6)
  • Geometry plot: ‘/path/to/local/installation/openmc/ IDWarning: Another Material instance already exists with id=2.’
    (Is the app using some default material ids since no material data has been used as an input to the app. Similar messages are there for surface, cell and universe instances as well.)

Thanks once again and it would be great if you could shed some light on the above warning messages.

Thanks for posting.

The ‘More than 95% of external source sites sampled were rejected. Please check your external source’s spatial definition’. error message normally means the sources is outside of the geometry. Feel free to share and I shall see if I can fix the code for this source.

The warning ‘Cross section library /path/to/local/installation/openmc_plot/FENDL-3.1d_Li6.h5 is not a problem in this case. I just use this random isotope in the cross sections xml file. As we are not doing transport we don’t actually need the h5 file. I should probably rename it to something else to avoid confusion

The app makes a material for each material ID it finds in the geometry. It makes a Li6 material. These materials are just made to allow openmc to load up the geometry xml file. The from_xml function requires some materials so the code skims the geometry.xml file and makes a minimal Li6 material for each expected material

All the best


@cp-f version 0.1.13 now has an interactive plotter for the regular mesh tally. To access it look for “Plotly the interactive plot” tab on the “Regularmesh plot” tab
Screenshot from 2022-11-30 11-49-45

If this suits the interactive requirements then I can roll out another version with interactive plotting for weight windows.

I still don’t know how to do this interactivity nicely for the geometry (which currently just displays a png image) but I shall keep thinking about that. Perhaps I can sample the geometry to find the cell id or material id and build up the image directly.

1 Like