# Particle crossed surface but could not be located in any cell

**URL:** <https://openmc.discourse.group/t/particle-crossed-surface-but-could-not-be-located-in-any-cell/3087>\
**Category:** User Support\
**Created:** [June 12, 2023, 3:03am UTC](https://openmc.discourse.group/t/particle-crossed-surface-but-could-not-be-located-in-any-cell/3087 "2023-06-12T03:03:13Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![luluq279](https://avatars.discourse-cdn.com/v4/letter/l/bbce88/32.png) [@luluq279](https://openmc.discourse.group/u/luluq279)\
**Post date:** [June 12, 2023, 3:03am UTC](https://openmc.discourse.group/t/particle-crossed-surface-but-could-not-be-located-in-any-cell/3087/1 "2023-06-12T03:03:13Z")

</div>

Hi everyone,  
I am new to OpenMC. I am attempting to simulate a HDPE neutron collimator with diameter 5cm, 18.5cm long, and aperture diameter 3.8cm. The neutron source energy is 2.45MeV (D-D reactions). However, I ran into a warning stating that after particle #number crossed surface 4 it could not be located in any cell and it did not leak. May I know how can I solve this problem? Below is my code. Thank you. Regards.

import openmc

# Define the materials

hdpe = openmc.Material(name=“HDPE”)  
hdpe.add\_element(“C”, 2)  
hdpe.add\_element(“H”, 4)  
hdpe.set\_density(“g/cm3”, 0.95)  
materials = openmc.Materials([hdpe])

# Define the geometry

geometry = openmc.Geometry()

# Define the collimator dimensions

outer\_radius = 2.5 # cm  
inner\_radius = 1.9 # cm  
length = 18.5 # cm  
distance = 1.0 # cm

# Create the collimator geometry

collimator\_outer\_surface = openmc.YCylinder(surface\_id=1, r=outer\_radius, boundary\_type=‘vacuum’)  
collimator\_inner\_surface = openmc.YCylinder(surface\_id=2, r=inner\_radius)  
collimator\_right\_surface = openmc.YPlane(surface\_id=3, y0=length / 2)  
collimator\_left\_surface = openmc.YPlane(surface\_id=4, y0=-length / 2)

collimator\_region = -collimator\_outer\_surface & +collimator\_inner\_surface & -collimator\_right\_surface & +collimator\_left\_surface

collimator\_cell = openmc.Cell(cell\_id=1, region=collimator\_region, fill=hdpe)  
aperture\_cell = openmc.Cell(cell\_id=2, region=-collimator\_inner\_surface)  
entry\_cell = openmc.Cell(cell\_id=3, region=-collimator\_left\_surface)  
exit\_cell = openmc.Cell(cell\_id=4, region=+collimator\_right\_surface)

# Add the cells to the geometry

geometry.root\_universe = openmc.Universe(cells=[collimator\_cell, aperture\_cell, entry\_cell, exit\_cell])

# Create the settings

settings = openmc.Settings()  
settings.run\_mode = “fixed source”  
settings.particles = 1000000  
settings.batches = 10  
settings.inactive = 0  
settings.source = openmc.Source(space=openmc.stats.Point(xyz=(0,-(length / 2) - distance,0)), energy=openmc.stats.Discrete([2.45e6], [1]))

# Create the tallies

tally = openmc.Tally(name=“neutron\_collimation”)  
tally.scores = [“flux”]  
tally.filters = [openmc.CellFilter(collimator\_cell)]  
tallies = openmc.Tallies([tally])

# Run the simulation

model = openmc.model.Model(geometry, materials, settings, tallies)  
model.run()

---

<div class="post-metadata">

**Author:** ![AlexandreTrottier](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/alexandretrottier/32/1357_2.png) [@AlexandreTrottier](https://openmc.discourse.group/u/AlexandreTrottier)\
**Post date:** [June 12, 2023, 1:16pm UTC](https://openmc.discourse.group/t/particle-crossed-surface-but-could-not-be-located-in-any-cell/3087/2 "2023-06-12T13:16:42Z")

</div>

Hello. I recommend you add the max\_lost\_particle specification to your settings, with a limit of 1. Also, there is a particle hdf5 file created when a particle is lost. I do not recall if this is dependent on using the max\_lost\_particle spec. You can view data in the particle hdf5 file from the command line using: `h5dump your_data_file.h5 | less`

---

<div class="post-metadata">

**Author:** ![bentridisalah](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/bentridisalah/32/1421_2.png) [@bentridisalah](https://openmc.discourse.group/u/bentridisalah)\
**Post date:** [June 12, 2023, 7:57pm UTC](https://openmc.discourse.group/t/particle-crossed-surface-but-could-not-be-located-in-any-cell/3087/3 "2023-06-12T19:57:36Z")

</div>

Hi,  
@luluq279, I join @AlexandreTrottier about the issue you got there. It is defintely a problem with your geometry, mainly in the way you define boundary type of the other surfaces, since openmc take by default ‘transmission’ surface, unless you define another type. Usually, adjacent cell (filled with material) should exist, and I think it is not the case in your example:

collimator\_outer\_surface = openmc.YCylinder(surface\_id=1, r=outer\_radius, boundary\_type=‘vacuum’)  
collimator\_inner\_surface = openmc.YCylinder(surface\_id=2, r=inner\_radius) #\<\<\<\< here  
collimator\_right\_surface = openmc.YPlane(surface\_id=3, y0=length / 2) #\<\<\<\<\< and here  
collimator\_left\_surface = openmc.YPlane(surface\_id=4, y0=-length / 2) # \<\<\<\<\< and here

Besides that, I think that the definition of the following cells, should be reconsidered, since they are infinite cells and it is more likely causing scoring particles issue:

aperture\_cell = openmc.Cell(cell\_id=2, region=-collimator\_inner\_surface)  
entry\_cell = openmc.Cell(cell\_id=3, region=-collimator\_left\_surface)  
exit\_cell = openmc.Cell(cell\_id=4, region=+collimator\_right\_surface)

---

<div class="post-metadata">

**Author:** ![luluq279](https://avatars.discourse-cdn.com/v4/letter/l/bbce88/32.png) [@luluq279](https://openmc.discourse.group/u/luluq279)\
**Post date:** [June 20, 2023, 5:56am UTC](https://openmc.discourse.group/t/particle-crossed-surface-but-could-not-be-located-in-any-cell/3087/6 "2023-06-20T05:56:23Z")

</div>

Hi sir. I have added more to my code but I ran into a warning: could not find the cell containing particle #some number, and also a runtime error: maximum number of lost particles has been reached. Would you mind sharing your idea on how to deal with this problem? Below is my code:

# Define the materials

hdpe = openmc.Material(material\_id=1, name=“HDPE”)

hdpe.add\_element(“C”, 2)

hdpe.add\_element(“H”, 4)

hdpe.set\_density(“g/cm3”, 0.96)

lead = openmc.Material(material\_id=2, name=“Pb”)

lead.add\_element(‘Pb’, 1)

lead.set\_density(‘g/cm3’, 11.34)

highvacuum = openmc.Material(material\_id=3, name=‘high vacuum’)

highvacuum.add\_nuclide(‘H2’, 2.0)

highvacuum.set\_density(‘kg/m3’, 1e-7)

lowvacuum = openmc.Material(material\_id=4, name=‘low vacuum’)

lowvacuum.add\_nuclide(‘H2’, 2.0)

lowvacuum.set\_density(‘kg/m3’, 1e-6)

feed\_gas = openmc.Material(material\_id=5, name=‘deuterium’)

feed\_gas.add\_nuclide(‘H2’, 2.0) # Deuterium

feed\_gas.set\_density(‘kg/m3’, 3.2e-4) # Density of deuterium gas at 4 mbar

materials = openmc.Materials([hdpe, lowvacuum, lead, highvacuum, feed\_gas])

# Define the collimator dimensions

outer\_radius = 2.45 # cm

inner\_radius = 1.9 # cm

length = 18.5 # cm

source\_distance = 1.0 # cm

scintillator\_distance = 3.4 # cm

chamber\_width = 3.5 # cm

chamber\_length = 15.0 # cm

# Create the collimator geometry

collimator\_outer\_surface = openmc.XCylinder(surface\_id=1, r=outer\_radius, boundary\_type=‘vacuum’)

collimator\_inner\_surface = openmc.XCylinder(surface\_id=2, r=inner\_radius, boundary\_type=‘reflective’)

collimator\_front\_surface = openmc.XPlane(surface\_id=3, x0=length / 2, )

collimator\_back\_surface = openmc.XPlane(surface\_id=4, x0=-length / 2, )

scintillator\_position = openmc.XPlane(surface\_id=5, x0=-(length / 2) - scintillator\_distance, boundary\_type=‘vacuum’)

source\_position = openmc.XPlane(surface\_id=6, x0=length / 2 + source\_distance, boundary\_type=‘vacuum’)

chamber\_wall\_right = openmc.YPlane(surface\_id=7, y0=chamber\_width, boundary\_type=‘vacuum’)

chamber\_wall\_left = openmc.YPlane(surface\_id=8, y0=-chamber\_width, boundary\_type=‘vacuum’)

chamber\_front = openmc.XPlane(surface\_id=9, x0=-chamber\_length, boundary\_type=‘vacuum’)

chamber\_back = openmc.XPlane(surface\_id=10, x0=chamber\_length, boundary\_type=‘vacuum’)

# Define the regions

collimator\_region = -collimator\_outer\_surface & +collimator\_inner\_surface & -collimator\_front\_surface & +collimator\_back\_surface

aperture\_region = -collimator\_inner\_surface & -collimator\_front\_surface & +collimator\_back\_surface

entry\_region = +collimator\_front\_surface & -source\_position & -collimator\_outer\_surface

exit\_region = -collimator\_back\_surface & +scintillator\_position & -collimator\_outer\_surface

empty\_region = +collimator\_outer\_surface & -chamber\_wall\_right & +chamber\_wall\_left & -chamber\_back & +chamber\_front

lead\_region = -collimator\_outer\_surface & -collimator\_back\_surface & +chamber\_front & ~exit\_region

# Define the cells

collimator\_cell = openmc.Cell(cell\_id=1, region=collimator\_region, fill=hdpe)

aperture\_cell = openmc.Cell(cell\_id=2, region=aperture\_region, fill=lowvacuum)

entry\_cell = openmc.Cell(cell\_id=3, region=entry\_region, fill=feed\_gas)

exit\_cell = openmc.Cell(cell\_id=4, region=exit\_region, fill=highvacuum)

empty\_cell = openmc.Cell(cell\_id=5, region=empty\_region, fill=lowvacuum)

lead\_cell = openmc.Cell(cell\_id=6, region=lead\_region, fill=lead)

# Define the geometry and add the cells to the geometry

geometry = openmc.Geometry(openmc.Universe(cells=[collimator\_cell, aperture\_cell, entry\_cell, exit\_cell, lead\_cell, empty\_cell]))

# Create the settings

settings = openmc.Settings()

settings.run\_mode = “fixed source”

settings.particles = 1000000

settings.batches = 10

settings.inactive = 0

settings.source = openmc.Source(space=openmc.stats.Point((length / 2 + source\_distance,0,0)), energy=openmc.stats.Discrete([2.5e6], [1]))

# Create the tallies

tally = openmc.Tally(name=“neutron\_collimation”)

tally.scores = [‘flux’, ‘absorption’, ‘elastic’, ‘scatter’, ‘total’, ‘events’]

tally.filters = [openmc.CellFilter([collimator\_cell, aperture\_cell, entry\_cell, exit\_cell, empty\_cell, lead\_cell])]

tallies = openmc.Tallies([tally])

# Create the plot

plot = openmc.Plot()

plot.filename = “collimator”

plot.width = (35.0, 35.0)

plot.pixels = (500, 500)

plot.color\_by = “material”

plot.colors = {hdpe: “green”, lowvacuum: (176, 196, 222), highvacuum: ( 47, 79, 79), lead: (165, 42, 42), feed\_gas: ‘blue’}

plots = openmc.Plots([plot])

# Run the simulation

model = openmc.model.Model(geometry, materials, settings, tallies, plots)  
model.run()

Thank you very much sir. Regards.

---

<div class="post-metadata">

**Author:** ![bentridisalah](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/bentridisalah/32/1421_2.png) [@bentridisalah](https://openmc.discourse.group/u/bentridisalah)\
**Post date:** [June 21, 2023, 9:47am UTC](https://openmc.discourse.group/t/particle-crossed-surface-but-could-not-be-located-in-any-cell/3087/7 "2023-06-21T09:47:48Z")

</div>

HI @luluq279 ;

I took a look in your new model, and I tried some modifications mainly on the boundary type of the used surfaces (don’t define “vacuum” surface for cells which are adjacent to another material cells), and also some cells, like the empty\_cell, which create an undefined volume on the right of the source surface.

What I did and it works is to put the source in the middle of the collimator (0, 0, 0). Of course, this is not the purpose of the model, but I did just to see if the issue came from the definition of the source, since there are too much lost particles.

I will let you know if I will find something new ;), unless you or someone else will find the origin of the problem !

Good luck

---

<div class="post-metadata">

**Author:** ![luluq279](https://avatars.discourse-cdn.com/v4/letter/l/bbce88/32.png) [@luluq279](https://openmc.discourse.group/u/luluq279)\
**Post date:** [July 28, 2023, 2:13am UTC](https://openmc.discourse.group/t/particle-crossed-surface-but-could-not-be-located-in-any-cell/3087/8 "2023-07-28T02:13:29Z")

</div>

Hi sir. Thank you very much for your help. Now I am building a new model but without any collimator, only the detector.

 ![Setup2](https://global.discourse-cdn.com/free1/uploads/openmc/original/2X/4/44ab8fd0d8e6477db3334ad6316af38c23282b51.png)

Attached below is the code:  
[setup\_2.py](https://openmc.discourse.group/uploads/short-url/bXv2K99zl33q4gDFTe9xndC3xdx.py) (10.1 KB)

However, the result that I obtained is 0 flux at the detector (scintillator). If you run the code and save the result for mesh in excel format, you will notice starting at radius 6, there is no flux detected. May I know if there is anything wrong with the geometry defined?

---

<div class="post-metadata">

**Author:** ![bentridisalah](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/bentridisalah/32/1421_2.png) [@bentridisalah](https://openmc.discourse.group/u/bentridisalah)\
**Post date:** [July 29, 2023, 10:46am UTC](https://openmc.discourse.group/t/particle-crossed-surface-but-could-not-be-located-in-any-cell/3087/9 "2023-07-29T10:46:29Z")

</div>

Hi @luluq279 ,

First, please you can call me Salah and no need to call me Sir 😉  
Secondly, I looked in your python file and I got the same results as you : only the room chamber is registering neutrons and nothing elsewhere.  
That why, I would to suggest you to do something simple in the first step … for example only your cylindrical source and detector, and put the whole system in spherical volume (with vacuum spherical boundary). Then, you can see if your detector cell is recording any of travelling neutrons or not. At this stage it will be much easier to find the issue with zero-tally value on your detector and to fix it.

regards

Salah

---

<div class="post-metadata">

**Author:** ![luluq279](https://avatars.discourse-cdn.com/v4/letter/l/bbce88/32.png) [@luluq279](https://openmc.discourse.group/u/luluq279)\
**Post date:** [July 31, 2023, 4:02am UTC](https://openmc.discourse.group/t/particle-crossed-surface-but-could-not-be-located-in-any-cell/3087/10 "2023-07-31T04:02:13Z")

</div>

Dear Salah,  
Thank you for the response. I have tried your suggestion, and I have finally figured out the problem. The boundary\_type of the YCylinder, some YPlanes, and the body of the scintillator need to be changed to transmission so that flux reading will be non-zero. Thank you very much for your idea.

Regards,  
Luqman

---

<div class="post-metadata">

**Author:** ![bentridisalah](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/bentridisalah/32/1421_2.png) [@bentridisalah](https://openmc.discourse.group/u/bentridisalah)\
**Post date:** [August 1, 2023, 9:04am UTC](https://openmc.discourse.group/t/particle-crossed-surface-but-could-not-be-located-in-any-cell/3087/11 "2023-08-01T09:04:45Z")

</div>

Dear Luqman;

It is very nice to hear that you could solve the issue, you are very welcome

Best regards

Salah
