# How would i go about making a hexagonal unit cell?

**URL:** <https://openmc.discourse.group/t/how-would-i-go-about-making-a-hexagonal-unit-cell/1097>\
**Category:** User Support\
**Created:** [March 30, 2021, 4:12pm UTC](https://openmc.discourse.group/t/how-would-i-go-about-making-a-hexagonal-unit-cell/1097 "2021-03-30T16:12:22Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![hhhnain](https://avatars.discourse-cdn.com/v4/letter/h/d6d6ee/32.png) [@hhhnain](https://openmc.discourse.group/u/hhhnain)\
**Post date:** [March 30, 2021, 4:12pm UTC](https://openmc.discourse.group/t/how-would-i-go-about-making-a-hexagonal-unit-cell/1097/1 "2021-03-30T16:12:22Z")

</div>

I basically want a hexagonal unit cell with sodium as the coolant, ht9 steel as cladding and the fuel in center.

---

<div class="post-metadata">

**Author:** ![Pranto](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/pranto/32/489_2.png) [@Pranto](https://openmc.discourse.group/u/Pranto)\
**Post date:** [March 30, 2021, 4:56pm UTC](https://openmc.discourse.group/t/how-would-i-go-about-making-a-hexagonal-unit-cell/1097/2 "2021-03-30T16:56:04Z")

</div>

```python

import openmc
import openmc.model as m

fuel = openmc.Material(material_id=1, name = 'fuel_mat')
....

clad = openmc.Material(name='steel')
....

coolant = openmc.Material(name='sodium')
....

mat = openmc.Materials([fuel, clad, coolant])
mat.export_to_xml()

fuel_or = openmc.ZCylinder(x0=0.0, y0=0.0, r=0.386)
clad_ir = openmc.ZCylinder(x0=0.0, y0=0.0, r=0.45)

u_fuel = openmc.model.pin([fuel_or, clad_ir], [fuel, clad, coolant])

root_cell = openmc.Cell(name='root cell')
root_cell.fill = u_fuel

hexa = m.hexagonal_prism(edge_length=0.6375, orientation='y', origin=(0.0, 0.0), boundary_type='reflective', corner_radius=0.)
root_cell.region = hexa

# Create root Universe

root_universe = openmc.Universe(universe_id=0, name='root universe')
root_universe.add_cell(root_cell)

# Create Geometry and set root Universe

geometry = openmc.Geometry(root_universe)

geometry.export_to_xml()

```

Check out [modelling hexagonal lattice](https://docs.openmc.org/en/stable/examples/hexagonal.html#modeling-hexagonal-lattices) notebook.

Hope this will help.

---

<div class="post-metadata">

**Author:** ![hhhnain](https://avatars.discourse-cdn.com/v4/letter/h/d6d6ee/32.png) [@hhhnain](https://openmc.discourse.group/u/hhhnain)\
**Post date:** [March 31, 2021, 10:25am UTC](https://openmc.discourse.group/t/how-would-i-go-about-making-a-hexagonal-unit-cell/1097/3 "2021-03-31T10:25:29Z")

</div>

thank you very much. that worked brilliantly. could you possibly comment on the edge length of the prism? The picture below shows my intent but i can’t find anywhere the dimension of how much coolant would go into it.

Again thank you, i understood your code well.  
 ![image](https://global.discourse-cdn.com/free1/uploads/openmc/original/2X/0/0692067327fb505c41054f892d7da70d2d095275.png)

---

<div class="post-metadata">

**Author:** ![Pranto](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/pranto/32/489_2.png) [@Pranto](https://openmc.discourse.group/u/Pranto)\
**Post date:** [March 31, 2021, 11:43am UTC](https://openmc.discourse.group/t/how-would-i-go-about-making-a-hexagonal-unit-cell/1097/4 "2021-03-31T11:43:29Z")

</div>

@hhhnain

> [@hhhnain](#):
>
> could you possibly comment on the edge length of the prism?

Nope. What’s the pitch of this unit cell? It’s supposed to be in the docs.

---

<div class="post-metadata">

**Author:** ![hhhnain](https://avatars.discourse-cdn.com/v4/letter/h/d6d6ee/32.png) [@hhhnain](https://openmc.discourse.group/u/hhhnain)\
**Post date:** [March 31, 2021, 12:00pm UTC](https://openmc.discourse.group/t/how-would-i-go-about-making-a-hexagonal-unit-cell/1097/5 "2021-03-31T12:00:43Z")

</div>

![image](https://global.discourse-cdn.com/free1/uploads/openmc/original/2X/0/00b37cbf2c154912757b83ef4e50a11d0339be46.png) im using an abr as a reference and the pitch is 16.2471cm

---

<div class="post-metadata">

**Author:** ![Pranto](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/pranto/32/489_2.png) [@Pranto](https://openmc.discourse.group/u/Pranto)\
**Post date:** [March 31, 2021, 12:14pm UTC](https://openmc.discourse.group/t/how-would-i-go-about-making-a-hexagonal-unit-cell/1097/6 "2021-03-31T12:14:29Z")

</div>

> [@hhhnain](#):
>
> im using an abr as a reference and the pitch is 16.2471cm

This is actually sub-assembly pitch.

For unit cell, edge length = `0.7764 cm`

Best  
pranto

---

<div class="post-metadata">

**Author:** ![hhhnain](https://avatars.discourse-cdn.com/v4/letter/h/d6d6ee/32.png) [@hhhnain](https://openmc.discourse.group/u/hhhnain)\
**Post date:** [March 31, 2021, 12:28pm UTC](https://openmc.discourse.group/t/how-would-i-go-about-making-a-hexagonal-unit-cell/1097/7 "2021-03-31T12:28:51Z")

</div>

thank you very much. This is the final result.

 ![image](https://global.discourse-cdn.com/free1/uploads/openmc/original/2X/f/fb1224dac50c9b48caa4390578c2a9fc331bc941.png)

---

<div class="post-metadata">

**Author:** ![Indah\_Sari](https://avatars.discourse-cdn.com/v4/letter/i/5f8ce5/32.png) [@Indah\_Sari](https://openmc.discourse.group/u/Indah_Sari)\
**Post date:** [April 22, 2021, 2:55am UTC](https://openmc.discourse.group/t/how-would-i-go-about-making-a-hexagonal-unit-cell/1097/8 "2021-04-22T02:55:32Z")

</div>

Hi, do you know how to calculate the volume?

---

<div class="post-metadata">

**Author:** ![hhhnain](https://avatars.discourse-cdn.com/v4/letter/h/d6d6ee/32.png) [@hhhnain](https://openmc.discourse.group/u/hhhnain)\
**Post date:** [April 23, 2021, 12:42am UTC](https://openmc.discourse.group/t/how-would-i-go-about-making-a-hexagonal-unit-cell/1097/9 "2021-04-23T00:42:10Z")

</div>

its pi r^2 of the fuel radius. maybe confirm with @paulromano

---

<div class="post-metadata">

**Author:** ![Indah\_Sari](https://avatars.discourse-cdn.com/v4/letter/i/5f8ce5/32.png) [@Indah\_Sari](https://openmc.discourse.group/u/Indah_Sari)\
**Post date:** [April 24, 2021, 4:24am UTC](https://openmc.discourse.group/t/how-would-i-go-about-making-a-hexagonal-unit-cell/1097/10 "2021-04-24T04:24:44Z")

</div>

If phi r^2 it’s just for fuel right?

---

<div class="post-metadata">

**Author:** ![hhhnain](https://avatars.discourse-cdn.com/v4/letter/h/d6d6ee/32.png) [@hhhnain](https://openmc.discourse.group/u/hhhnain)\
**Post date:** [April 24, 2021, 6:14am UTC](https://openmc.discourse.group/t/how-would-i-go-about-making-a-hexagonal-unit-cell/1097/11 "2021-04-24T06:14:51Z")

</div>

What problem are you having? Is it defining or the numeric? Be carefull to say fuel.volume if you named your main fuel as fuel

Of if you names your main fuel as Indah then it  
would be indah.volume = math.pi \* r \*\* 2

You have to import math aswell btw
