Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hexagonal Lattices Don't Roundtrip #3002

Closed
pshriwise opened this issue May 14, 2024 · 0 comments · Fixed by #3003
Closed

Hexagonal Lattices Don't Roundtrip #3002

pshriwise opened this issue May 14, 2024 · 0 comments · Fixed by #3003
Labels

Comments

@pshriwise
Copy link
Contributor

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]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant