# Building Geometry and Plotting Issues

**URL:** <https://openmc.discourse.group/t/building-geometry-and-plotting-issues/5145>\
**Category:** User Support\
**Created:** [January 16, 2025, 2:13am UTC](https://openmc.discourse.group/t/building-geometry-and-plotting-issues/5145 "2025-01-16T02:13:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AbdullahAlharbi](https://avatars.discourse-cdn.com/v4/letter/a/45deac/32.png) [@AbdullahAlharbi](https://openmc.discourse.group/u/AbdullahAlharbi)\
**Post date:** [January 16, 2025, 2:13am UTC](https://openmc.discourse.group/t/building-geometry-and-plotting-issues/5145/1 "2025-01-16T02:13:55Z")

</div>

Hello, I just installed OpenMC a few days ago and I am working on a big project using it, I’m running into a few issues and I would benefit a lot from clarifications:

1- What is the best IDE to write and execute OpenMC simulation, I am used to PyCharm, is it a good IDE for OpenMC ?, I see most people are using Jupiter notebook.

2- When I try to plot a piece of geometry, a cell or a universe, I always get this error:  
===\> fuel\_assembly\_cell.plot()  
===\> OSError: \path\. so: cannot open shared object file: No such file or directory

3- after I build the geometry, it gets exported to xml just fine, but when I try to plot it through:  
===\> plot = mc.Plot()  
===\>plots = openmc.Plots([plot])  
===\>plots.export\_to\_xml()  
===\>openmc.plot\_geometry()  
or run a simulation through openmc.run(), I get the following error:  
Simulating batch 1  
ERROR: Particle -1 left lattice 2, but it has no outer definition.  
ERROR: Particle -1 left lattice 2, but it has no outer definition.  
Traceback (most recent call last):  
File “/mnt/c/openMC/UFTR/test.py”, line 126, in   
mc.run()  
File “/home/eastdusty/openmc\_env/lib/python3.11/site-packages/openmc/executor.py”, line 314, in run  
\_run(args, output, cwd)  
File “/home/eastdusty/openmc\_env/lib/python3.11/site-packages/openmc/executor.py”, line 125, in \_run  
raise RuntimeError(error\_msg)  
RuntimeError: Particle -1 left lattice 2, but it has no outer definition. ERROR: Particle -1 left lattice 2, but it has no outer definition.

Since I can not include my code in a pdf file, I will include it below as plain text, and please let me know if there is an issue with geometry definition or program installation, I am new to OpenMC and trying to learn, and has been stuck for about two days now with this issue.

import os  
import matplotlib.pyplot as plt

os.environ[‘OPENMC\_CROSS\_SECTIONS’] = ‘/home/eastdusty/openmc\_env/share/data/endfb80/endfb-viii.0-hdf5/cross\_sections.xml’

import openmc as mc  
import openmc.plotter as plotter

U3Si2Al = mc.Material(name=‘U3Si2Al’)  
U3Si2Al.add\_nuclide(‘U238’, 3 \* 0.8025)  
U3Si2Al.add\_nuclide(‘U235’, 3 \* 0.1975)  
U3Si2Al.add\_nuclide(‘Si28’, 2 \* 0.922545)  
U3Si2Al.add\_nuclide(‘Si29’, 2 \* 0.04672)  
U3Si2Al.add\_nuclide(‘Si30’, 2 \* 0.030735)  
U3Si2Al.add\_nuclide(‘Al27’, 1)  
U3Si2Al.set\_density(‘g/cm3’, 5.55)

Al6061 = mc.Material(name=‘Al6061’)  
Al6061.add\_nuclide(‘Al27’, 1)  
Al6061.set\_density(‘g/cm3’, 2.7)

water = mc.Material(name=‘Water’)  
water.add\_nuclide(‘H1’, 0.111877)  
water.add\_nuclide(‘H2’, 0.000013)  
water.add\_nuclide(‘O16’, 0.88811)  
water.set\_density(‘g/cm3’, 1.0)

materials = mc.Materials([U3Si2Al, Al6061, water])  
materials.export\_to\_xml()

fuel\_top = mc.ZPlane(z0=30)  
fuel\_bottom = mc.ZPlane(z0=-30)  
fuel\_right = mc.XPlane(x0=2.98)  
fuel\_left = mc.XPlane(x0=-2.98)  
fuel\_front = mc.YPlane(y0=0.0255)  
fuel\_back = mc.YPlane(y0=-0.0255)

fuel\_region = +fuel\_bottom & -fuel\_top & +fuel\_left & -fuel\_right & -fuel\_front & +fuel\_back

fuel\_cell = mc.Cell(region=fuel\_region, fill=U3Si2Al)

clad\_top = mc.ZPlane(z0=32.55, boundary\_type = ‘vacuum’)  
clad\_bottom = mc.ZPlane(z0=-32.55, boundary\_type = ‘vacuum’)  
clad\_right = mc.XPlane(x0=3.615, boundary\_type = ‘vacuum’)  
clad\_left = mc.XPlane(x0=-3.615, boundary\_type = ‘vacuum’)  
clad\_front = mc.YPlane(y0=0.0636)  
clad\_back = mc.YPlane(y0=-0.0636)

clad\_region = +clad\_bottom & -clad\_top & +clad\_left & -clad\_right & -clad\_front & +clad\_back & ~fuel\_region

clad\_cell = mc.Cell(region=clad\_region, fill=Al6061)

coolant\_top = mc.ZPlane(z0=32.55)  
coolant\_bottom = mc.ZPlane(z0=-32.55)  
coolant\_front = mc.YPlane(y0=0.2046)  
coolant\_back = mc.YPlane(y0=-0.2046)  
coolant\_left = clad\_left  
coolant\_right = clad\_right

coolant\_region = -coolant\_top & + coolant\_bottom & -coolant\_front & +coolant\_back & +coolant\_left & -coolant\_right & ~clad\_region & ~ fuel\_region

coolant = mc.Cell(region=coolant\_region, fill=water)

fuel\_plate = mc.Universe(cells=[fuel\_cell, clad\_cell, coolant])

fuel\_assembly = mc.RectLattice(name = ‘fuel assembly’)  
fuel\_assembly.lower\_left = (0,-2.8644)  
fuel\_assembly.pitch = (1, 0.2046)  
fuel\_assembly.universes = [[fuel\_plate, fuel\_plate, fuel\_plate, fuel\_plate, fuel\_plate, fuel\_plate, fuel\_plate, fuel\_plate, fuel\_plate, fuel\_plate, fuel\_plate, fuel\_plate]]

fuel\_assembly\_cell = mc.Cell()  
fuel\_assembly\_cell.fill = fuel\_assembly

fuel\_assembly\_universe = mc.Universe(cells=[fuel\_assembly\_cell])

front\_boundary = mc.YPlane(y0=2.8644, boundary\_type = ‘vacuum’)  
back\_boundary = mc.YPlane(y0=-2.8644, boundary\_type = ‘vacuum’)

geometry = mc.Geometry(fuel\_assembly\_universe)  
geometry.export\_to\_xml()

color = {fuel\_cell: ‘red’, clad\_cell: ‘green’, coolant: ‘blue’}

plot = mc.Plot()  
plot.basis = ‘xy’  
plot.origin = (0, 0, 0)  
plot.width = (7.25, 5.73)  
plot.pixels = (500, 500)  
plot.colors = color  
plot.filename = ‘geometry\_plot’  
plot.filetype = ‘png’  
plots = mc.Plots([plot])  
plots.export\_to\_xml()  
mc.plot\_geometry()

settings = mc.Settings()  
settings.run\_mode = ‘fixed source’

source = mc.Source()  
source.space = mc.stats.Point((0.0, 0.0, 0.0))  
source.angle = mc.stats.Isotropic()  
source.energy = mc.stats.Discrete([1.0e6], [1.0])  
settings.source = source

settings.batches = 50  
settings.particles = 1000  
settings.inactive = 10

settings.export\_to\_xml()

mc.run()

---

<div class="post-metadata">

**Author:** ![skyawlker](https://avatars.discourse-cdn.com/v4/letter/s/a587f6/32.png) [@skyawlker](https://openmc.discourse.group/u/skyawlker)\
**Post date:** [January 16, 2025, 1:35pm UTC](https://openmc.discourse.group/t/building-geometry-and-plotting-issues/5145/2 "2025-01-16T13:35:58Z")

</div>

> [@AbdullahAlharbi](#):
>
> 2- When I try to plot a piece of geometry, a cell or a universe, I always get this error:  
> ===\> fuel\_assembly\_cell.plot()  
> ===\> OSError: \path. so: cannot open shared object file: No such file or directory

fuel\_assembly\_cell.plot() is worked when we use Jupyter notebook. If you don’t use it, you can use `openmc -p` in terminal to plot.

> [@AbdullahAlharbi](#):
>
> 3- after I build the geometry, it gets exported to xml just fine, but when I try to plot it through:  
> ===\> plot = mc.Plot()  
> ===\>plots = openmc.Plots([plot])  
> ===\>plots.export\_to\_xml()  
> ===\>openmc.plot\_geometry()  
> or run a simulation through openmc.run(), I get the following error:  
> Simulating batch 1

You should define the outer when the lattice was used. Or this error will happen when the region of the cell small than the lattice which filld with.

---

<div class="post-metadata">

**Author:** ![AbdullahAlharbi](https://avatars.discourse-cdn.com/v4/letter/a/45deac/32.png) [@AbdullahAlharbi](https://openmc.discourse.group/u/AbdullahAlharbi)\
**Post date:** [January 20, 2025, 4:12am UTC](https://openmc.discourse.group/t/building-geometry-and-plotting-issues/5145/4 "2025-01-20T04:12:40Z")

</div>

Yes that worked, after I defined the outer boundary everything was fine.
