# Hexagonal fuel assembly

**URL:** <https://openmc.discourse.group/t/hexagonal-fuel-assembly/4525>\
**Category:** New Ideas\
**Created:** [July 6, 2024, 11:26am UTC](https://openmc.discourse.group/t/hexagonal-fuel-assembly/4525 "2024-07-06T11:26:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aslan](https://avatars.discourse-cdn.com/v4/letter/a/df705f/32.png) [@Aslan](https://openmc.discourse.group/u/Aslan)\
**Post date:** [July 6, 2024, 11:26am UTC](https://openmc.discourse.group/t/hexagonal-fuel-assembly/4525/1 "2024-07-06T11:26:59Z")

</div>

Hi,  
I am new user. I am creating a hexagonal fuel assembly (UO2). Fuel pellet has a hole in the center with radius 0.1 cm. Outer radius of fuel pellet 0.45 cm. Cladding inner radius is 0.465 and cladding outer radius is 0.525.

Hexagonal fuel assembly has 7 rings including center. the pitch size between fuel pins is 1.215 cm. assembly thickness is 0.7 cm. Thus, fuel assembly contains 127 pins.

I tried to create this hexagonal assembly but I met trouble. Please, could you help me.

Below I attached my code

import openmc  
import matplotlib.pyplot as plt

# Materials

uo2 = openmc.Material(name=“fuel”)  
uo2.add\_nuclide(‘U235’, 0.03)  
uo2.add\_nuclide(‘U238’, 0.97)  
uo2.add\_nuclide(‘O16’, 2.0)  
uo2.set\_density(‘g/cm3’, 10.0)

cladding = openmc.Material(name=“steel”)  
cladding.add\_element(‘Ti’, 0.0373)  
cladding.add\_element(‘C’, 0.0739)  
cladding.add\_element(‘Mn’, 0.0246)  
cladding.add\_element(‘Mo’, 0.0220)  
cladding.add\_element(‘Ni’, 0.1387)  
cladding.add\_element(‘Cr’, 0.1348)  
cladding.add\_element(‘Si’, 0.0231)  
cladding.add\_element(‘Fe’, 0.5456)  
cladding.set\_density(‘g/cm3’, 6.6)

gap = openmc.Material(name=“helium”)  
gap.add\_element(‘He’, 1.0)  
gap.set\_density(‘g/cm3’, 0.176e-3)

water = openmc.Material(name=“h2o”)  
water.add\_nuclide(‘H1’, 2.0)  
water.add\_nuclide(‘O16’, 1.0)  
water.set\_density(‘g/cm3’, 1.0)  
water.add\_s\_alpha\_beta(‘c\_H\_in\_H2O’)

materials = openmc.Materials([uo2, cladding, water, gap])

# Geometry

uo2\_outer\_radius = 0.45  
cladding\_outer\_radius = 0.525  
cladding\_inner\_radius = 0.465  
hole\_radius = 0.1

z\_min = openmc.ZPlane(z0=0, boundary\_type=‘reflective’)  
z\_max = openmc.ZPlane(z0=60, boundary\_type=‘reflective’)

uo2\_cylinder = openmc.ZCylinder(r=uo2\_outer\_radius)  
cladding\_cylinder = openmc.ZCylinder(r=cladding\_outer\_radius)  
gap\_cylinder = openmc.ZCylinder(r=cladding\_inner\_radius)  
hole\_cylinder = openmc.ZCylinder(r=hole\_radius)

assembly = openmc.model.HexagonalPrism(edge\_length=15.8, orientation=‘y’,  
boundary\_type=‘reflective’)  
assembly\_region = assembly & +z\_min & -z\_max  
assembly\_cell = openmc.Cell(region=assembly\_region)

uo2\_cell = openmc.Cell(fill=uo2, region=+hole\_cylinder & -uo2\_cylinder & +z\_min &  
-z\_max)  
gap\_cell = openmc.Cell(fill=gap, region=+uo2\_cylinder & -gap\_cylinder & +z\_min &  
-z\_max)  
cladding\_cell = openmc.Cell(fill=cladding, region=+gap\_cylinder & -cladding\_cylinder  
& +z\_min & -z\_max)  
hole\_cell = openmc.Cell(fill=water, region=-hole\_cylinder & +z\_min & -z\_max)  
water\_surrounding\_cell = openmc.Cell(fill=water, region=+cladding\_cylinder & +z\_min  
& -z\_max)

pin\_universe = openmc.Universe(cells=[uo2\_cell, gap\_cell, cladding\_cell, hole\_cell,  
water\_surrounding\_cell])

all\_water\_cell = openmc.Cell(fill=water)  
outer\_universe = openmc.Universe(cells=[all\_water\_cell])

lattice = openmc.HexLattice(name=‘assembly’)  
lattice.center = (0., 0.)  
lattice.pitch = (1.215,)  
lattice.outer = outer\_universe

ring\_6 = [pin\_universe] \* 36  
ring\_5 = [pin\_universe] \* 30  
ring\_4 = [pin\_universe] \* 24  
ring\_3 = [pin\_universe] \* 18  
ring\_2 = [pin\_universe] \* 12  
ring\_1 = [pin\_universe] \* 6  
center = [pin\_universe]

lattice.orientation = ‘y’  
lattice.universes = [ring\_6, ring\_5, ring\_4, ring\_3, ring\_2, ring\_1, center]

assembly\_cell.fill = lattice  
assembly\_universe = openmc.Universe(cells=[assembly\_cell])  
geometry = openmc.Geometry(assembly\_universe)

# Export to XML

materials.export\_to\_xml()  
geometry.export\_to\_xml()

# Create plot

plot = openmc.Plot()  
plot.filename = ‘assembly’  
plot.width = (50, 50)  
plot.pixels = (400, 400)  
plot.color\_by = ‘material’  
plot.colors = {water: ‘blue’, uo2: ‘yellow’, gap: ‘white’, cladding: ‘gray’}  
plot.origin = (0, 0, 30) # Middle of the z-axis  
plot.basis = ‘xy’

plots = openmc.Plots([plot])  
plots.export\_to\_xml()

# Generate and display the plot

openmc.plot\_geometry(output=False)  
plt.savefig(‘hexagonal\_assembly.png’)  
plt.show()

---

<div class="post-metadata">

**Author:** ![wahidluthfi](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/wahidluthfi/32/3375_2.png) [@wahidluthfi](https://openmc.discourse.group/u/wahidluthfi)\
**Post date:** [July 8, 2024, 3:31pm UTC](https://openmc.discourse.group/t/hexagonal-fuel-assembly/4525/2 "2024-07-08T15:31:04Z")

</div>

Hi Aslan, welcome to the community.  
First of all, I think in the future you could ask this kind of question in the [User Support](https://openmc.discourse.group/c/user-support/5) category since your question is about troubleshooting during the use of openmc.  
While New Ideas is more on the discussion regarding feature requests and other ideas for the openmc.  
About your case, I think the problem is in the assembly region definition, since openmc.model.HexagonalPrism needs an - and + for defining either the inside or outside region when using the surface.

```auto
assembly_region = -assembly & +z_min & -z_max #check

```

this can be read on the release note of openmc version 0.14.0  
[https://docs.openmc.org/en/stable/releasenotes/0.14.0.html](https://docs.openmc.org/en/stable/releasenotes/0.14.0.html)
