Skip to content

HexLattice docs does not agree with functionality #3537

@lewisgross1296

Description

@lewisgross1296

While doing some model debugging with @pshriwise and @magnoxemo, we realized there's a discrepancy between what the HexLattice docs states and what actually gets built.

The HexLattice documentation for the orientation variable states
Image

I've created an MWE below that makes a simple HexLattice

import openmc

mat_a = openmc.Material(name="U")
mat_a.add_element("U",1.0)
mat_b = openmc.Material(name="H")
mat_b.add_element("H",1.0)
mat_c = openmc.Material(name="C")
mat_c.add_element("C",1.0)
mats = openmc.Materials([mat_a, mat_b, mat_c])
mats.export_to_xml()

univ_a = openmc.Universe(cells=[openmc.Cell(fill=mat_a)])
univ_b = openmc.Universe(cells=[openmc.Cell(fill=mat_b)])
univ_c = openmc.Universe(cells=[openmc.Cell(fill=mat_c)])

hex_lattice = openmc.HexLattice()
hex_lattice.center = (0.0, 0.0)

hex_lattice.pitch = (1,)
hex_lattice.outer = univ_c
# ring lists
center = [univ_a]
ring_1 = [univ_b] * 6

hex_lattice.universes = [ring_1, center]

z_cyl = openmc.ZCylinder(r=3)
cell = openmc.Cell(region=-z_cyl, fill=hex_lattice)
geometry = openmc.Geometry([cell])
geometry.export_to_xml()

settings = openmc.Settings()
settings.export_to_xml()

Visualizing this in the plotter shows
Image
Taking the "main diagonal" as the segment between two hex points parallel to a major axis, you can see that while the default here is "y" orientation, the main diagonal is parallel to the x axis!

There's a few options to fix this. The first would be to switch the behavior of "x" and "y", i.e. change the default to be "x" and just swap "x" and "y" behavior in the code. Alternatively, we could change no source code and only modify the wording of the docs, but I think the original intended meaning for the docs makes sense.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions