# TRISO particle outside of lattice

**URL:** <https://openmc.discourse.group/t/triso-particle-outside-of-lattice/2360>\
**Category:** User Support\
**Created:** [October 13, 2022, 6:23pm UTC](https://openmc.discourse.group/t/triso-particle-outside-of-lattice/2360 "2022-10-13T18:23:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![averyarnone](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@averyarnone](https://openmc.discourse.group/u/averyarnone)\
**Post date:** [October 13, 2022, 6:23pm UTC](https://openmc.discourse.group/t/triso-particle-outside-of-lattice/2360/1 "2022-10-13T18:23:52Z")

</div>

Hello,

I have a reactor model that is edited from the VHTR example model available on GitHub.

When increasing the TRISO particle packing factor above 0.30, I run into a warning:

“UserWarning: TRISO particle is partially or completely outside of the lattice.”

It seems to me that the issue is from the sphere packing algorithm placing a coordinate outside of the accepted lattice region.

I have attached the section of code responsible for this below. Any help is appreciated.

kernelsph = openmc.Sphere(r=250e-4) # try 212.5um and 250um  
buffsph = openmc.Sphere(r=350e-4)  
IPyCsph = openmc.Sphere(r=390e-4)  
SiCsph = openmc.Sphere(r=425e-4)  
OPyCsph = openmc.Sphere(r=470e-4)  
triso\_outer\_radius = 470e-4  
layers = [kernelsph, buffsph, IPyCsph, SiCsph, OPyCsph]  
triso\_mats = [fuel, buffer\_mat, IPyC, SiC, OPyC]  
triso\_cells =   
for i in range(5):  
if (i == 0):  
triso\_cells.append(openmc.Cell(fill=triso\_mats[0], region=-layers[0]))  
else:  
triso\_cells.append(openmc.Cell(fill=triso\_mats[i], region=+layers[i-1] & -layers[i]))  
triso\_universe = openmc.Universe(universe\_id=1001,cells=triso\_cells)

cylsurf = openmc.ZCylinder(r=r\_pellet)  
maxz\_pin = openmc.ZPlane(z0=+pellet\_height/2)  
minz\_pin = openmc.ZPlane(z0=-pellet\_height/2)  
maxz = openmc.ZPlane(z0=+core\_height/2)  
minz = openmc.ZPlane(z0=-core\_height/2)  
maxz\_refl = openmc.ZPlane(z0= core\_height/2+top\_refl\_height, boundary\_type=‘vacuum’)  
minz\_refl = openmc.ZPlane(z0=-core\_height/2-bot\_refl\_height, boundary\_type=‘vacuum’)  
lattice\_region = -cylsurf & -maxz\_pin & +minz\_pin  
spheres = openmc.model.pack\_spheres(radius=triso\_outer\_radius, region=lattice\_region, pf=0.35)  
triso\_particles = [openmc.model.TRISO(triso\_outer\_radius, fill=triso\_universe, center=c) for c in spheres]  
lattice\_cell = openmc.Cell(region=lattice\_region)  
lower\_left, upp\_right = lattice\_cell.region.bounding\_box  
shape = (4, 4, 4)  
pitch = (upp\_right - lower\_left)/shape  
triso\_latt = openmc.model.create\_triso\_lattice(triso\_particles, lower\_left, pitch, shape, graphite)  
lattice\_cell.fill = triso\_latt  
lattice\_cell\_outer=openmc.Cell(region=~lattice\_region,fill=graphite)  
lattice\_universe = openmc.Universe(universe\_id=1002,cells=[lattice\_cell,lattice\_cell\_outer])

---

<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:** [November 26, 2022, 4:27am UTC](https://openmc.discourse.group/t/triso-particle-outside-of-lattice/2360/2 "2022-11-26T04:27:21Z")

</div>

> [@averyarnone](#):
>
> I have a reactor model that is edited from the VHTR example model available on GitHub.
> 
> When increasing the TRISO particle packing factor above 0.30, I run into a warning:
> 
> “UserWarning: TRISO particle is partially or completely outside of the lattice.”
> 
> It seems to me that the issue is from the sphere packing algorithm placing a coordinate outside of the accepted lattice region.

Hi,i think you can plot this geometry, then you may find some problems,I 've had the same problem before, probably caused by the inconsistency of the lattice and the cell 's outer boundary shapes

---

<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:** [December 7, 2022, 4:12am UTC](https://openmc.discourse.group/t/triso-particle-outside-of-lattice/2360/3 "2022-12-07T04:12:26Z")

</div>

I would agree with the previous suggestion (plotting is always helpful), although staring at your code for a little bit, I don’t see any obvious reason why a TRISO particle would end up outside the lattice since the lattice by definition should cover the region that was used when generating the TRISOs. @averyarnone If you’re able to share a full script, I can try to reproduce the behavior you’re seeing in order to give more specific advice.

---

<div class="post-metadata">

**Author:** ![ligross](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/ligross/32/1653_2.png) [@ligross](https://openmc.discourse.group/u/ligross)\
**Post date:** [May 18, 2023, 4:13am UTC](https://openmc.discourse.group/t/triso-particle-outside-of-lattice/2360/4 "2023-05-18T04:13:32Z")

</div>

I’ve been following along the [TRISO python notebook](https://github.com/openmc-dev/openmc-notebooks/blob/main/triso.ipynb), and I’m actually getting the same warning:

```auto
/home/lgross/openmc/openmc/model/triso.py:848: UserWarning: TRISO particle is partially or completely outside of the lattice.
  warnings.warn('TRISO particle is partially or completely '

```

I have the lines to check that the particles are in the lattice from the notebook

```auto
centers = np.vstack([triso.center for triso in trisos])
print(centers.min(axis=0))
print(centers.max(axis=0))

```

and strangely, the output of the above _is_ within the lattice (a cube with side length 1 centered at the origin), despite the warning appearing. Output:

```auto
[-0.457015 -0.457015 -0.457015]
[0.457015 0.457015 0.457015]

```

Note my TRISO outer radius is 0.042985 cm and 0.457015 cm + 0.042985 cm = 0.5 cm. It seems the edge of some TRISO spheres exactly touches the edge of the lattice. Maybe due to floating point error, it thinks a particle is outside?

I went to the plotter to investigate, but couldn’t see any TRISOs outside the lattice. To test, I generated a few `slice_coords` near both sides of the lattice boundaries for each basis: `xy`, `xz`, and `yz`.

One thing I am concerned about is the python notebook example slice plots show concentric circles for each region within a TRISO particle, but my image only shows solid purple spheres (which makes me think there’s an issue with my TRISO universes). [Here](https://github.com/lewisgross1296/gcmr/blob/6aa45990d6a93cac2cc91a2cc1803ffe2ed4fb66/triso/simple_triso.py) is the version of my script, in case you have time to investigate.  
 ![triso](https://global.discourse-cdn.com/free1/uploads/openmc/original/2X/3/385b196fe617c22c1b7f0d0f4ae8c950a68176d1.png)

---

<div class="post-metadata">

**Author:** ![ligross](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/ligross/32/1653_2.png) [@ligross](https://openmc.discourse.group/u/ligross)\
**Post date:** [June 2, 2023, 6:52pm UTC](https://openmc.discourse.group/t/triso-particle-outside-of-lattice/2360/5 "2023-06-02T18:52:49Z")

</div>

Following up:

1. I was able to eliminate the warning by slightly increasing the size of the lattice (by 0.01 cm in each direction) after packing the spheres. This suggests that the warning is resulting from handling the position’s floating point value when TRISO particles’ outer radius is very near (or exactly at) the lattice edge. Note sure if this warning check could use an adjustable tolerance so that spheres very near the boundary do not generate the warning. For my case, I know the spheres are good, so I’m confident to now run transport on this geometry
2. Re-only the purple in the spheres. I realized that I left a `1e-4r` in my version of the script adapted from the notebook, so each inner surface was at a radius four orders of magnitude below what was intended, hence why they did not appear visible.
