3D Lattice Troubleshooting

I have been trying to make a lattice for a fairly complex NuScale fuel assembly but I am running into some trouble getting it working. Because the fuel composition changes axially, and because the assembly needs to be axially segmented for tally purposes, I decided to structure the lattice as a vertical stack of 40, 5cm high 2D 17x17 lattice. The individual 17x17 lattices appear to work as intended. However, when combined into the core_lattice for stacking the geometry export fails and I receive the following error: AttributeError: ‘numpy.ndarray’ object has no attribute ‘_id’. I have been trying to troubleshoot the problem with AI but it seems to be going in circles.
Note: The issue seems to stem from the list of lists structure [[[univ]], [[…]]], as it does not occur when doing a horizontal stack [[univ], […]].
``

Lattice Stuff

core_cell = openmc.Cell(region=core_region)
core_lattice = openmc.RectLattice(name = 'root lattice')
core_lattice.pitch = [A_side, 5]
core_lattice.lower_left = [-A_side/2,-A_side/2] 
core_lattice.outer = void

# Layer Lattices
BLA_cell = openmc.Cell(region = assembly_region)
BLA_lattice = openmc.RectLattice()
BLA_lattice.pitch = [pitch,pitch]
BLA_lattice.lower_left = [-A_side/2,-A_side/2]


AS1_cell = openmc.Cell(region = assembly_region)
AS1_lattice = openmc.RectLattice()
AS1_lattice.pitch = [pitch,pitch]
AS1_lattice.lower_left = [-A_side/2,-A_side/2]


AS2_cell = openmc.Cell(region = assembly_region)
AS2_lattice = openmc.RectLattice()
AS2_lattice.pitch = [pitch,pitch]
AS2_lattice.lower_left = [-A_side/2,-A_side/2]


AS3_cell = openmc.Cell(region = assembly_region)
AS3_lattice = openmc.RectLattice()
AS3_lattice.pitch = [pitch,pitch]
AS3_lattice.lower_left = [-A_side/2,-A_side/2]



#core_lattice.universes = [[[f for _ in range(n)] for _ in range(n)] for _ in range(num_segs)]

# 17x17 NuScale Replication Core (need new geometries still)
if (n==17):

    BLA_lattice.universes =    
                                [[BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL],         
                                [BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL],
                                [BL, BL, BL, BL, BL, GT, BL, BL, GT, BL, BL, GT, BL, BL, BL, BL, BL],
                                [BL, BL, BL, GT, BL, BL, BL, BL, BL, BL, BL, BL, BL, GT, BL, BL, BL],
                                [BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL],
                                [BL, BL, GT, BL, BL, GT, BL, BL, GT, BL, BL, GT, BL, BL, GT, BL, BL],
                                [BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL],
                                [BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL],
                                [BL, BL, GT, BL, BL, GT, BL, BL, GT, BL, BL, GT, BL, BL, GT, BL, BL],
                                [BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL],
                                [BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL],
                                [BL, BL, GT, BL, BL, GT, BL, BL, GT, BL, BL, GT, BL, BL, GT, BL, BL],
                                [BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL],
                                [BL, BL, BL, GT, BL, BL, BL, BL, BL, BL, BL, BL, BL, GT, BL, BL, BL],
                                [BL, BL, BL, BL, BL, GT, BL, BL, GT, BL, BL, GT, BL, BL, BL, BL, BL],
                                [BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL],
                                [BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL, BL]]
                        
   
    AS1_lattice.universes =   
                               [[D2, D2, D2, D2, D2, D2, D2, D2, D2, D2, D2, D2, D2, D2, D2, D2, D2],   
                                [D2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, D2],
                                [D2, E2, E2, E2, E2, GT, E2, E2, GT, E2, E2, GT, E2, E2, E2, E2, D2],
                                [D2, E2, E2, GT, E2, E2, E2, E2, E2, E2, E2, E2, E2, GT, E2, E2, D2],
                                [D2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, D2],
                                [D2, E2, GT, E2, E2, GT, E2, E2, GT, E2, E2, GT, E2, E2, GT, E2, D2],
                                [D2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, D2],
                                [D2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, D2],
                                [D2, E2, GT, E2, E2, GT, E2, E2, GT, E2, E2, GT, E2, E2, GT, E2, D2],
                                [D2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, D2],
                                [D2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, D2],
                                [D2, E2, GT, E2, E2, GT, E2, E2, GT, E2, E2, GT, E2, E2, GT, E2, D2],
                                [D2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, D2],
                                [D2, E2, E2, GT, E2, E2, E2, E2, E2, E2, E2, E2, E2, GT, E2, E2, D2],
                                [D2, E2, E2, E2, E2, GT, E2, E2, GT, E2, E2, GT, E2, E2, E2, E2, D2],
                                [D2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, E2, D2],
                                [D2, D2, D2, D2, D2, D2, D2, D2, D2, D2, D2, D2, D2, D2, D2, D2, D2]]
                        
  
    
    BLA_cell.fill=BLA_lattice # paste to each n option
    AS1_cell.fill=AS1_lattice

    BLA_univ = openmc.Universe(cells=[BLA_cell])
    AS1_univ = openmc.Universe(cells=[AS1_cell])

    core_lattice.universes=[[[BLA_univ]],
                                          [[AS1_univ]], # 1
                                          [[AS1_univ]],
                                          [[AS1_univ]],
                                          [[AS1_univ]],
                                          [[AS1_univ]], # 5
                                          [[AS1_univ]],
                                          [[AS1_univ]],
                                          [[AS1_univ]],
                                          [[AS1_univ]],
                                          [[AS1_univ]], # 10
                                          [[AS1_univ]],
                                          [[AS1_univ]],
                                          [[AS1_univ]],
                                          [[AS1_univ]],
                                          [[AS1_univ]], # 15
                                          [[AS1_univ]],
                                          [[AS1_univ]], 
                                          [[AS1_univ]],
                                          [[AS1_univ]],
                                          [[AS1_univ]], # 20
                                          [[AS1_univ]],
                                          [[AS1_univ]],
                                          [[AS1_univ]],
                                          [[AS1_univ]],
                                          [[AS1_univ]], # 25
                                          [[AS1_univ]], 
                                          [[AS1_univ]],
                                          [[AS1_univ]],
                                          [[AS1_univ]],
                                          [[AS1_univ]], # 30
                                          [[AS1_univ]], 
                                          [[AS1_univ]],
                                          [[AS1_univ]],
                                          [[AS1_univ]],
                                          [[AS1_univ]], # 35
                                          [[AS1_univ]],
                                          [[AS1_univ]],
                                          [[AS1_univ]], # 38
                                          [[BLA_univ]]]

core_cell.fill=core_lattice

core = openmc.Universe(cells=[core_cell])
assembly = openmc.Geometry(core) 
assembly.export_to_xml()

``

Hi Daedalus, welcome back to the community.
Have you tried to use np.stack to stack your fuel pin lattice? It will make a stack of your universe ID, which can then be used for your lattice.universes. I hope this notebook could give you some idea 3DlatAgain.ipynb (228.8 KB)

2 Likes