openmc-dev/openmc

Hexagonal Lattices Don't Roundtrip

Closed this issue · 0 comments

Bug Description

Our hexagonal lattices don't currently roundtrip from XML correctly for multiple axial layers. The first layer is fine, but layers beyond that are incorrect.

  <hex_lattice id="100" n_axial="2" n_rings="	  <hex_lattice id="100" n_axial="2" n_rings="
    <pitch>1.0 1.0</pitch>			    <pitch>1.0 1.0</pitch>
    <center>0.0 0.0 0.0</center>		    <center>0.0 0.0 0.0</center>
    <universes>					    <universes>
    16  17  18					    16  17  18
  15  6   7   19				  15  6   7   19
14  5   1   2   8 				14  5   1   2   8 
  13  4   3   9 				  13  4   3   9 
    12  11  10					    12  11  10
    10  16  17				      |	    16  17  18
  18  15  6   7 			      |	  15  6   7   19
19  14  5   1   2 			      |	14  5   1   2   8 
  8   13  4   3 			      |	  13  4   3   9 
    9   12  11</universes>		      |	    12  11  10</universes>
  </hex_lattice>				  </hex_lattice>
</geometry>					</geometry>

Steps to Reproduce

# coding: utf-8
import openmc

openmc.reset_auto_ids()

latt = openmc.HexLattice(lattice_id=100)
latt.pitch = (1.0, 1.0)
latt.center = (0.0, 0.0, 0.0)

u19 = [openmc.Universe(cells=[openmc.Cell()]) for i in range(19)]
axial_one = [u19[-12:], u19[1:7], u19[0:1]]
latt.orientation = 'x'

u19 = [openmc.Universe(cells=[openmc.Cell()]) for i in range(19)]
axial_two = [u19[-12:], u19[1:7], u19[0:1]]

latt.universes = [axial_one, axial_one]

outer_univ = openmc.Universe(cells=[openmc.Cell(fill=latt)])
geom = openmc.Geometry(root=outer_univ)
geom.export_to_xml()

geom2 = openmc.Geometry.from_xml(materials=openmc.Materials())

print("Original Lattice:")
print(latt)
print("Roundtrip Lattice:")
print(geom2.get_all_lattices()[latt.id])

rt_latt = geom2.get_all_lattices()[latt.id]

for aixal_og, axial_rt in zip(latt.universes, rt_latt.universes):
    for ring_og, ring_rt in zip(aixal_og, axial_rt):
        assert [u.id for u in ring_og] == [u.id for u in ring_rt]