# OpenMC 'aborts unexpectedly' when plotting

**URL:** <https://openmc.discourse.group/t/openmc-aborts-unexpectedly-when-plotting/2350>\
**Category:** User Support\
**Created:** [October 9, 2022, 12:46am UTC](https://openmc.discourse.group/t/openmc-aborts-unexpectedly-when-plotting/2350 "2022-10-09T00:46:37Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![madhofs](https://avatars.discourse-cdn.com/v4/letter/m/f6c823/32.png) [@madhofs](https://openmc.discourse.group/u/madhofs)\
**Post date:** [October 9, 2022, 12:46am UTC](https://openmc.discourse.group/t/openmc-aborts-unexpectedly-when-plotting/2350/1 "2022-10-09T00:46:37Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![pshriwise](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/pshriwise/32/3863_2.png) [@pshriwise](https://openmc.discourse.group/u/pshriwise)\
**Post date:** [October 11, 2022, 3:45pm UTC](https://openmc.discourse.group/t/openmc-aborts-unexpectedly-when-plotting/2350/2 "2022-10-11T15:45:41Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![madhofs](https://avatars.discourse-cdn.com/v4/letter/m/f6c823/32.png) [@madhofs](https://openmc.discourse.group/u/madhofs)\
**Post date:** [December 5, 2022, 4:52pm UTC](https://openmc.discourse.group/t/openmc-aborts-unexpectedly-when-plotting/2350/3 "2022-12-05T16:52:40Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![pshriwise](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/pshriwise/32/3863_2.png) [@pshriwise](https://openmc.discourse.group/u/pshriwise)\
**Post date:** [December 5, 2022, 7:24pm UTC](https://openmc.discourse.group/t/openmc-aborts-unexpectedly-when-plotting/2350/4 "2022-12-05T19:24:57Z")

</div>

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)?

---

<div class="post-metadata">

**Author:** ![Kladdy](https://avatars.discourse-cdn.com/v4/letter/k/839c29/32.png) [@Kladdy](https://openmc.discourse.group/u/Kladdy)\
**Post date:** [January 23, 2023, 11:53am UTC](https://openmc.discourse.group/t/openmc-aborts-unexpectedly-when-plotting/2350/5 "2023-01-23T11:53:40Z")

</div>

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

```auto
(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.

---

<div class="post-metadata">

**Author:** ![paulromano](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/paulromano/32/486_2.png) [@paulromano](https://openmc.discourse.group/u/paulromano)\
**Post date:** [January 28, 2023, 5:08pm UTC](https://openmc.discourse.group/t/openmc-aborts-unexpectedly-when-plotting/2350/6 "2023-01-28T17:08:34Z")

</div>

@Kladdy See the related thread here:

> [@RuntimeError when plotting (in pincell-tutorial's universe.plot() and openmc.plot\_geometry())](https://openmc.discourse.group/t/runtimeerror-when-plotting-in-pincell-tutorials-universe-plot-and-openmc-plot-geometry/2605/4):
>
> @sop_kretzschmar Glad to hear you were able to get around this problem! To expand on the underlying issue: libpng warning: Application built with libpng-1.4.12 but running with 1.6.39 Traceback (most recent call last): This tells us that the OpenMC executable was built with one version of libpng (used for plotting) but at the time it’s running, it is picking up a different version of libpng. I think this is really a problem with the conda package for OpenMC, and we probably need to update our …

---

<div class="post-metadata">

**Author:** ![madhofs](https://avatars.discourse-cdn.com/v4/letter/m/f6c823/32.png) [@madhofs](https://openmc.discourse.group/u/madhofs)\
**Post date:** [February 5, 2023, 1:51am UTC](https://openmc.discourse.group/t/openmc-aborts-unexpectedly-when-plotting/2350/7 "2023-02-05T01:51:49Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![madhofs](https://avatars.discourse-cdn.com/v4/letter/m/f6c823/32.png) [@madhofs](https://openmc.discourse.group/u/madhofs)\
**Post date:** [February 5, 2023, 1:56am UTC](https://openmc.discourse.group/t/openmc-aborts-unexpectedly-when-plotting/2350/8 "2023-02-05T01:56:46Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![madhofs](https://avatars.discourse-cdn.com/v4/letter/m/f6c823/32.png) [@madhofs](https://openmc.discourse.group/u/madhofs)\
**Post date:** [February 5, 2023, 6:44pm UTC](https://openmc.discourse.group/t/openmc-aborts-unexpectedly-when-plotting/2350/9 "2023-02-05T18:44:21Z")

</div>

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](https://nbviewer.org/github/openmc-dev/openmc-notebooks/blob/main/post-processing.ipynb) provided by @bentridisalah.

Thanks all for the help!

---

<div class="post-metadata">

**Author:** ![srichr221](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/srichr221/32/2360_2.png) [@srichr221](https://openmc.discourse.group/u/srichr221)\
**Post date:** [February 7, 2023, 4:17pm UTC](https://openmc.discourse.group/t/openmc-aborts-unexpectedly-when-plotting/2350/10 "2023-02-07T16:17:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![madhofs](https://avatars.discourse-cdn.com/v4/letter/m/f6c823/32.png) [@madhofs](https://openmc.discourse.group/u/madhofs)\
**Post date:** [February 8, 2023, 4:46pm UTC](https://openmc.discourse.group/t/openmc-aborts-unexpectedly-when-plotting/2350/11 "2023-02-08T16:46:56Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![pbehne](https://avatars.discourse-cdn.com/v4/letter/p/e495f1/32.png) [@pbehne](https://openmc.discourse.group/u/pbehne)\
**Post date:** [July 27, 2023, 10:39pm UTC](https://openmc.discourse.group/t/openmc-aborts-unexpectedly-when-plotting/2350/12 "2023-07-27T22:39:12Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![Shimwell](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/shimwell/32/3876_2.png) [@Shimwell](https://openmc.discourse.group/u/Shimwell)\
**Post date:** [July 28, 2023, 9:20am UTC](https://openmc.discourse.group/t/openmc-aborts-unexpectedly-when-plotting/2350/13 "2023-07-28T09:20:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pbehne](https://avatars.discourse-cdn.com/v4/letter/p/e495f1/32.png) [@pbehne](https://openmc.discourse.group/u/pbehne)\
**Post date:** [August 8, 2023, 2:58pm UTC](https://openmc.discourse.group/t/openmc-aborts-unexpectedly-when-plotting/2350/14 "2023-08-08T14:58:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![cclaro](https://avatars.discourse-cdn.com/v4/letter/c/9de053/32.png) [@cclaro](https://openmc.discourse.group/u/cclaro)\
**Post date:** [January 24, 2024, 10:09pm UTC](https://openmc.discourse.group/t/openmc-aborts-unexpectedly-when-plotting/2350/15 "2024-01-24T22:09:05Z")

</div>

how did you fix this issue?
