OpenMC 'aborts unexpectedly' when plotting

Hi all,

Sorry for the silly question, but I’m a bit confused on how to make a slice plot. I’m using Jupyter, and when I run my code with

!openmc --plot

the .png file is generated but it is empty due to the warning of

zsh:1: number expected

When I use openmc.plot_geometry() or openmc.plot_inline() I get an error that says

libpng warning: Application built with libpng-1.4.12 but running with 1.6.37

Any help is appreciated. Thanks!

Sorry to hear this is giving you trouble @madhofs. That’s really strange. If you list the resulting png file from the !openmc --plot command with ls -l, what do you see?

Hello @pshriwise, thanks for your response! So sorry for the delayed reply.

When I run !openmc --plot and then use ls -l in the directory, the line for the .png appears as

-rw-r--r-- 1 username staff 0 Dec 5 09:49 plot_5.png

Let me know if I can provide anything else for you. Thanks!

Thanks for the info @madhofs. It appears that the library found for the openmc executable at runtime isn’t the same as the one it was linked to when it was built. Do you see the same warning if you run openmc -p from the command line (in the same directory with your jupyter notebook)?

I have the same problem. When running the plot() function on my universe, it gives me RuntimeError: OpenMC aborted unexpectedly. If i run openmc -p from the same directory as my jupyter notebook, the following is written out

(openmc-env) <retracted> % openmc -p
                                %%%%%%%%%%%%%%%
                           %%%%%%%%%%%%%%%%%%%%%%%%
                        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                                    %%%%%%%%%%%%%%%%%%%%%%%%
                                     %%%%%%%%%%%%%%%%%%%%%%%%
                 ###############      %%%%%%%%%%%%%%%%%%%%%%%%
                ##################     %%%%%%%%%%%%%%%%%%%%%%%
                ###################     %%%%%%%%%%%%%%%%%%%%%%%
                ####################     %%%%%%%%%%%%%%%%%%%%%%
                #####################     %%%%%%%%%%%%%%%%%%%%%
                ######################     %%%%%%%%%%%%%%%%%%%%
                #######################     %%%%%%%%%%%%%%%%%%
                 #######################     %%%%%%%%%%%%%%%%%
                 ######################     %%%%%%%%%%%%%%%%%
                  ####################     %%%%%%%%%%%%%%%%%
                    #################     %%%%%%%%%%%%%%%%%
                     ###############     %%%%%%%%%%%%%%%%
                       ############     %%%%%%%%%%%%%%%
                          ########     %%%%%%%%%%%%%%
                                      %%%%%%%%%%%

                 | The OpenMC Monte Carlo Code
       Copyright | 2011-2022 MIT, UChicago Argonne LLC, and contributors
         License | https://docs.openmc.org/en/latest/license.html
         Version | 0.13.2
       Date/Time | 2023-01-23 12:50:14
   MPI Processes | 1
  OpenMP Threads | 8

 Reading settings XML file...
 Reading cross sections XML file...
 Reading materials XML file...
 Reading geometry XML file...
 Reading tallies XML file...
 Preparing distributed cell instances...
 Reading plot XML file...

 =======================>     PLOTTING SUMMARY     <========================

Plot ID: 2
Plot file: plot_2.png
Universe depth: -1
Plot Type: Slice
Origin: 5 2 3
Width:   50   50
Coloring: Cells
Basis: XZ
Pixels: 400 400

 Processing plot 2: plot_2.png...
libpng warning: Application built with libpng-1.4.12 but running with 1.6.39
zsh: segmentation fault  openmc -p

so the same error as for @madhofs. I installed OpenMC according to the normal procedure on the website, and I am using a conda environment.

@Kladdy See the related thread here:

Hi @paulromano, thanks for the response! This may be a silly question, but if I were to install OpenMC from source as @sop_kretzschmar did, I assume this means that I cannot install it with Conda/Anaconda? I noticed that to install the OpenMC Python package, you must use a pip command, and I have had bad luck trying to use pip and conda together, and frankly I’m a little scared to re-install OpenMC without conda because I am not tech-savvy enough to troubleshoot if something goes wrong. I am also not super familiar with GitHub. Is there a way to remedy this issue while still using Conda, or must I face my fears and try installing it without Conda?

Thanks for the help!

Hi @pshriwise, when I run OpenMC from the command line with

openmc -p

, the following prints:

=======================> PLOTTING SUMMARY <========================

Plot ID: 1
Plot file: plot_1.png
Universe depth: -1
Plot Type: Slice
Origin: 0 0 0
Width: 100 20
Coloring: Cells
Basis: XZ
Pixels: 400 80

Processing plot 1: plot_1.png…
libpng warning: Application built with libpng-1.4.12 but running with 1.6.37
zsh: segmentation fault openmc -p

I believe this is the same issue that @Kladdy printed above. Thanks for the help!

Hi all, I found a workaround by using the universe.plot() command instead of trying to plot from a .XML file using the openmc.plot_geometry(), the command line prompt, openmc --p, or the openmc.plot_inline() function.

Specifically, creating a universe with all of my cells and then creating a single root universe with a single cell that contains the entirety of my first universe and using the command

root_universe.plot()

with parameters such as basis, color_by, width, pixels, and origin provided an in-line plot in Jupyter Notebooks. I referenced this example provided by @bentridisalah.

Thanks all for the help!

1 Like

Hey @madhofs , could you send me an example of your code? I’m having the same issue and can’t get it to plot in-line in Jupyter Notebook.

I’m doing:

Create root Cell

root_cell = openmc.Cell(name=‘root cell’)
root_cell.fill = universe

Add boundary planes

root_cell.region = -outer_surface

Create root Universe

root_universe = openmc.Universe(universe_id=0, name=‘root universe’)
root_universe.add_cell(root_cell)

root_universe.plot(plot_id=None, name=‘plot1’, basis = ‘xy’, origin = (0.0, 0.0, 0.0), pixels = (1000, 1000))

but it’s throwing up an error. I’m pretty sure I’m doing it wrong but I don’t wanna reinstall and run code from source

Hi @srichr221, here you go!

First, I create the cells and whatnot in my first universe. This is only one of a few cells I have, so this doesn’t define the entire universe, but it gives you an idea of how I create it.

Geometry for Beryllium Reflector (Source)

innerCylinder = openmc.ZCylinder(x0=-45, y0=0, r=25, boundary_type=‘transmission’, name=‘InnerCylinder’)
outerCylinder = openmc.ZCylinder(x0=-45, y0=0, r=35, boundary_type=‘transmission’, name=‘OuterCylinder’)

topOuter = openmc.ZPlane(z0=55, boundary_type=‘transmission’, name=‘topOuter’) #p1
topInner = openmc.ZPlane(z0=25, boundary_type=‘transmission’, name=‘topInner’) #p2
bottomInner = openmc.ZPlane(z0=-25, boundary_type=‘transmission’, name=‘bottomInner’) #p3
bottomOuter = openmc.ZPlane(z0=-55, boundary_type=‘transmission’, name=‘bottomOuter’) # p4

reflectorSideRegion = +innerCylinder & -outerCylinder & -topInner & +bottomInner

reflectorTopRegion = -outerCylinder & -topOuter & +topInner

reflectorBottomRegion = -outerCylinder & -bottomInner & +bottomOuter

totalReflectorRegion = reflectorSideRegion | reflectorTopRegion | reflectorBottomRegion

internalSourceVoidRegion = -innerCylinder & -topInner & +bottomInner

reflectorCell = openmc.Cell(region=totalReflectorRegion, fill=reflectorMat)

voidSourceCell = openmc.Cell(region=internalSourceVoidRegion)

universe.add_cell(reflectorCell)
universe.add_cell(voidSourceCell)

Next, I create my root cell, but not yet my root universe

OpenMC requires a “root” universe. Create “root cell” for root universe

root_cell = openmc.Cell(name=‘root cell’)
root_cell.fill = universe

Then, I assign an overarching region to my root cell. In this case, the back and far planes are the “kill” planes where anything that goes past them are just destroyed or leaked. Right now, my geometry is only bound in the x-direction. If you wanted it bound in more then you’d obviously have to further define your region

Assign root cell region

root_cell.region = +back_plane & -far_plane

Now I create my root universe, which only contains one cell, the root cell

Create root universe

root_universe = openmc.Universe(universe_id=0, name=‘root universe’)
root_universe.add_cell(root_cell)

You’ll also need to add a cell that’s everything NOT in your root cell

Create empty cell

not_root_cell = openmc.Cell(name=‘notInUniverse’)
not_root_cell.region = -back_plane & +far_plane
root_universe.add_cell(not_root_cell)

Then, I create my geometry and geometry.xml file (technically I don’t think you need to do this in order for the plot to work, I just have it next in my code)

Create geometry and include root universe

geometry = openmc.Geometry(root_universe)

Export to a geometry.xml file

geometry.export_to_xml()

Finally, I plot the root universe.

Plotting root universe

root_universe.plot(basis=‘xz’, color_by=‘material’, width=(200., 200.),
pixels=(500, 500), origin=(-25,0,0), colors={reflectorMat: 'blue’})

Hope this helps!

1 Like

I am having a similar issue with openmc compiled from source on INL’s hpc:

Processing plot 1: plot_1.png…
libpng warning: Application built with libpng-1.6.37 but running with 1.5.13
Segmentation fault (core dumped)

OpenMC makes use of libpng-dev to create the png image for plotting.

This error message sounds like the openmc executable you have was compiled with a different version libpng-dev to the version you have on the system you are running openmc on.

One option would be to update the version of libpng-dev installed on the system.

If you are running Ddebian derived OS then the command would be
sudo apt install libpng-dev

Perhaps another option would be write PPM files, if libpng is not found then openmc falls back to writting PPM image files

1 Like

Thank you for the response. I removed my OpenMC installation and a colleague was able to show me how to install and use it on HPC using conda. The issue seems to be resolved now.

2 Likes

how did you fix this issue?