Plotting error with external hexagonal boundary

Hello,

I’m new to OpenMC and I’m attempting to create pin cell model. The cell contains a hexagonal lattice contained within a hexagonal prism, which is then nested in another hexagonal prism. I have been attempting to use the openmc.model.hexagonal_prism function but I keep running into an error with with plotting. Here is my file:

#matplotlib inline
import openmc

Define materials

fuel = openmc.Material(name=‘fuel’)
fuel.add_nuclide(‘U235’, 0.153297, ‘wo’)
fuel.add_nuclide(‘U238’, 0.011538, ‘wo’)
fuel.add_element(‘Zr’, 0.497253, ‘wo’)
fuel.add_element(‘C’, 0.337912, ‘wo’)
fuel.set_density(‘g/cm3’, 3.64)
fuel.add_s_alpha_beta(‘c_Graphite’)
fuel.temperature = 300.0

fin_coat = openmc.Material(name=‘fin_coat’)
fin_coat.add_element(‘Zr’, 0.617, ‘wo’)
fin_coat.add_element(‘C’, 0.377, ‘wo’)
fin_coat.set_density(‘g/cm3’, 6.6)
fin_coat.add_s_alpha_beta(‘c_Graphite’)
fin_coat.temperature = 300.0

fout_coat = openmc.Material(name=‘fout_coat’)
fout_coat.add_element(‘Zr’, 0.617, ‘wo’)
fout_coat.add_element(‘C’, 0.377, ‘wo’)
fout_coat.set_density(‘g/cm3’, 6.6)
fout_coat.add_s_alpha_beta(‘c_Graphite’)
fout_coat.temperature = 300.0

coolant = openmc.Material(name=‘coolant’)
coolant.add_nuclide(‘H1’, 1.0, ‘wo’)
coolant.set_density(‘g/cm3’, 5.2E-04)
coolant.add_s_alpha_beta(‘c_para_H’)
coolant.add_s_alpha_beta(‘c_H_in_H2O’)
coolant.temperature = 300.0

materials = openmc.Materials((fuel, fin_coat, fout_coat, coolant))
materials.export_to_xml()

Define coolant channel

cool_rad = openmc.ZCylinder(r=0.11825)
cool_cell = openmc.Cell(fill=coolant, region=-cool_rad)

Define inner coating

coat_rad = openmc.ZCylinder(r=0.12825)
incoat_cell = openmc.Cell(fill=fin_coat, region=+cool_rad & -coat_rad)

Define fuel lattice element

fuel_cell = openmc.Cell(fill=fuel)
outer_universe = openmc.Universe(cells=(fuel_cell,))

Define channel universe

chan_un = openmc.Universe(cells=[cool_cell, incoat_cell])

Define lattice

hex_lat = openmc.HexLattice()
hex_lat.center = (0, 0)
hex_lat.pitch = [0.41028]
hex_lat.outer = outer_universe

outer_ring = [chan_un]*12
middle_ring = [chan_un]*6
inner_ring = [chan_un]
hex_lat.universes = [outer_ring, middle_ring, inner_ring]

Define fuel pin

pin_hex = openmc.model.hexagonal_prism(edge_length=1.09408, orientation=‘x’)
main_cell = openmc.Cell(fill=hex_lat, region=pin_hex)

Define outer coat

outer_hex = openmc.model.hexagonal_prism(edge_length=1.09985, orientation=‘x’, boundary_type=‘reflective’)
outcoat_cell = openmc.Cell(fill=fout_coat, region=~pin_hex & outer_hex)

pin_un = openmc.Universe(cells=[main_cell, outcoat_cell])

geometry = openmc.Geometry(root=pin_un)
geometry.export_to_xml()

plot = openmc.Plot.from_geometry(geometry)
plot.color_by = ‘material’
plot.colors = colors = {
coolant: ‘blue’,
fin_coat: ‘olive’,
fout_coat: ‘yellow’,
fuel: ‘red’
}
plot.to_ipython_image()

settings = openmc.Settings()
settings.run_mode = ‘eigenvalue’

settings.particles = 100000
settings.generations_per_batch = 10
settings.batches = 300
settings.inactive = 20

source = openmc.Source()
source.space = openmc.stats.Point(xyz=(0.3327, 0.0, 0.0))

and the error when running is:

Traceback (most recent call last):
File “/home/emmajstewart/Dropbox/snre_fuel_pin_2d.py”, line 85, in
plot = openmc.Plot.from_geometry(geometry)
File “/home/jack/miniconda3/envs/openmc-env/lib/python3.10/site-packages/openmc/plots.py”, line 508, in from_geometry
raise ValueError('The geometry does not appear to be bounded ’
ValueError: The geometry does not appear to be bounded in the xy plane.

although I have specified ‘reflective’ boundary conditions in the external hexagonal prism. I can’t see where I’m going wrong so any help would be much appreciated.

Thanks in advance,

Emma

When you run Plot.from_geometry, OpenMC will try to determine a proper view by looking at the bounding box of your model. However, in some cases it’s not able to do this because of the type of surfaces present in the geometry. One of those cases is when a non-axis-aligned plane is present (for you, when you use hexagonal_prism). I would just create a Plot object in the normal way and explicitly specify the origin and width:

plot = openmc.Plot()
plot.origin = ...
plot.width = ...
plot.color_by = 'material'
plot.colors = colors = {
...
3 Likes

One thing I noticed in your code is that you did not specify the material to be used to fill the region outside of coat rad


# Define inner coating

coat_rad = openmc.ZCylinder(r=0.12825)
incoat_cell = openmc.Cell(fill=fin_coat, region=+cool_rad & -coat_rad)

out_cell = openmc.Cell(fill=fuel, region=+coat_rad)

chan_un = openmc.Universe(cells=[cool_cell, incoat_cell, out_cell])

Hope, this will solve the problem.

Thank you both, I have fixed it now.