Simulation error: Defining pebbles region

Hello everyone

I am simulating the pebbles having TRISO particles. I’m encountering an issue with my simulation involving pebble regions. When I create a pebble region using a 3-dimensional plane (x, y, z), the simulation runs smoothly. However, when I try to define the pebble region using shapes like a sphere or a cylinder, I encounter an error indicating that particles have a negative distance to the lattice boundary.

I would greatly appreciate any suggestions on how to resolve this issue. Thank you.
Error:
WARNING: Particle 9403 had a negative distance to a lattice boundary
WARNING: Particle 9405 had a negative distance to a lattice boundary
WARNING: Particle 1653 had a negative distance to a lattice boundary
WARNING: Particle 7352 had a negative distance to a lattice boundary
WARNING: Particle 2002 had a negative distance to a lattice boundary
WARNING: Particle 6051 had a negative distance to a lattice boundary
WARNING: Particle 7354 had a negative distance to a lattice boundary
WARNING: Particle 2353 had a negative distance to a lattice boundary
WARNING: Particle 3821 had a negative distance to a lattice boundary
WARNING: Particle 2857 had a negative distance to a lattice boundary
WARNING: Particle 4662 had a negative distance to a lattice boundary
WARNING: Particle 1459 had a negative distance to a lattice boundary
WARNING: Particle 5407 had a negative distance to a lattice boundary
WARNING: Particle 3017 had a negative distance to a lattice boundary
WARNING: WARNING: Particle 7260 had a negative distance to a lattice boundary
Particle 5011 had a negative distance to a lattice boundary

code…
import numpy as np
import matplotlib.pyplot as plt
import openmc
import openmc.model

fuel = openmc.Material(name=‘Fuel’)
fuel.set_density(‘g/cm3’, 10.5)
fuel.add_nuclide(‘U235’, 4.6716e-02)
fuel.add_nuclide(‘U238’, 2.8697e-01)
fuel.add_nuclide(‘O16’, 5.0000e-01)
fuel.add_element(‘C’, 1.6667e-01)

buff = openmc.Material(name=‘Buffer’)
buff.set_density(‘g/cm3’, 1.0)
buff.add_element(‘C’, 1.0)
buff.add_s_alpha_beta(‘c_Graphite’)

PyC1 = openmc.Material(name=‘PyC1’)
PyC1.set_density(‘g/cm3’, 1.9)
PyC1.add_element(‘C’, 1.0)
PyC1.add_s_alpha_beta(‘c_Graphite’)

PyC2 = openmc.Material(name=‘PyC2’)
PyC2.set_density(‘g/cm3’, 1.87)
PyC2.add_element(‘C’, 1.0)
PyC2.add_s_alpha_beta(‘c_Graphite’)

SiC = openmc.Material(name=‘SiC’)
SiC.set_density(‘g/cm3’, 3.2)
SiC.add_element(‘C’, 0.5)
SiC.add_element(‘Si’, 0.5)

Helium = openmc.Material(name=‘helium’)
Helium.set_density(‘g/cm3’, 0.001598)
Helium.add_element(‘He’, 1.0)

graphite = openmc.Material()
graphite.set_density(‘g/cm3’, 1.1995)
graphite.add_element(‘C’, 1.0)
graphite.add_s_alpha_beta(‘c_Graphite’)

spheres = [openmc.Sphere(r=1e-4*r)
for r in [215., 315., 350., 385.]]
cells = [openmc.Cell(fill=fuel, region=-spheres[0]),
openmc.Cell(fill=buff, region=+spheres[0] & -spheres[1]),
openmc.Cell(fill=PyC1, region=+spheres[1] & -spheres[2]),
openmc.Cell(fill=SiC, region=+spheres[2] & -spheres[3]),
openmc.Cell(fill=PyC2, region=+spheres[3])]
triso_univ = openmc.Universe(cells=cells)

pebble = openmc.Sphere(r=2.5)
pebble_o = openmc.Sphere(r=3)
region = -pebble
outer_radius = 425.*1e-4
##############################################################

centers = openmc.model.pack_spheres(radius = outer_radius, region=region, num_spheres = 19000, seed=124848351)
trisos = [openmc.model.TRISO(outer_radius, triso_univ, center) for center in centers]

pebble_f = openmc.Cell(region=region)
lower_left, upper_right = pebble_f.region.bounding_box
shape = (10,10,10)
pitch = (upper_right - lower_left)/shape
lattice = openmc.model.create_triso_lattice(
trisos, lower_left, pitch, shape, graphite)

pebble_f.fill = lattice
cell_p = openmc.Cell(fill=graphite, region=+pebble & -pebble_o)
uni_pebble = openmc.Universe(cells=[cell_p, pebble_f])

###############################################
reg_c= openmc.Sphere(x0 = 400, y0=120, z0 = 120, r=20, boundary_type = ‘reflective’)
reg_all= -reg_c
centersf = [[390.0, 120.0, 120.0], [410.0, 120.0, 120.0]] # 2 pebbles positions
pebble_outer = 3

pebble_in_r = [openmc.model.TRISO(pebble_o.r, uni_pebble, center) for center in centersf]

pebble_region = openmc.Cell(region=reg_all)
lower_left, upper_right = pebble_region.region.bounding_box

shape = (4,4,4)
pitch = (upper_right - lower_left)/shape
lattice_r = openmc.model.create_triso_lattice(
pebble_in_r, lower_left, pitch, shape, Helium)

pebble_region.fill = lattice_r
uni_pebble_region = openmc.Universe(cells= [pebble_region])

###########################

geom = openmc.Geometry([pebble_region])
geom.export_to_xml()

materials = list(geom.get_all_materials().values())
openmc.Materials(materials).export_to_xml()

####################################

settings = openmc.Settings()
settings.batches = 100
settings.inactive = 10
settings.particles = 10000

point1 = openmc.stats.Point(xyz= tuple(centersf[0]))
src1 = openmc.Source(space = point1)
src1.strength = 0.5

point2 = openmc.stats.Point(xyz= tuple(centersf[1]))
src2 = openmc.Source(space = point2)
src2.strength = 0.5
settings.source = [src1, src2]
settings.export_to_xml()