HexLattice docs does not agree with functionality
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
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
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.
My 2c: Assuming that the y-option indeed produces "the other" option, which I think it does, the right(TM) thing to do would be to fix the code, no? I think it'd be a recipe for someone having to repeat the debugging session at some later time, to do otherwise. By fix the code - I mean your first option. This may mean adding a specific 'x' to tests as well of course.
For the other option the user's guide would have to be edited as well btw.
Yeah, it's probably best to switch the behaviors so the docs stays the same. Then we can add the "x" to the tests like you proposed. We can grep to find all the places that need to be updated.