Lattice Cell as Tally CellFilter

Dears,

I apologize in advance if my question comes as naive.

Consider the attached figure.

I want to use the three copies of Cell0 as volumes to define a CellFilter tally.

When I try to retrieve them from CellW, I basically get three copies of the same cell. On the other hand, when I plot the geometry, I correctly get them in the intended position in the world reference.

I attach the code too, that is a little simpler than the picture, it only includes the three copies of Cell0 and its surroundings.

I will help with the coding if necessary.

thanks a lot,
Nicola

Hi @nicola and welcome to the forum! The normal CellFilter is not capable of distinguishing between multiple instances of the same underlying cell (as used in multiple universes/lattices). If you want a separate tally for that cell in each of the different lattice positions, you would need to use CellInstanceFilter. If those are the only three instances of that cell, the following should work:

tally.filters = [CellInstanceFilter([(d_cell, 0), (d_cell, 1), (d_cell, 2)])]

Hi @paulromano thanks a lot, I will refer to this test for usage.

I have still one question. How to I link the instance number, to the actual instance coordinates?
thanks a lot :slight_smile:

That’s a very good question. Right now, it’s not super easy to figure out how the instance number relates to coordinates. In your particular case, the instances will be numbered from bottom to top in the lattice starting at 0. In the general case, the only way you can get at this right now is if you know the coordinate of a point contained in the cell you are interested in. If this coordinate is (x,y,z), you can use the following code to determine it:

import openmc.lib

openmc.lib.init()
cell, instance = openmc.lib.find_cell((x, y, z))
print(f'Cell {cell.id}, Instance {instance}')
openmc.lib.finalize()

We’re planning on adding support to our plotting application for showing instance numbers, which would make this a lot easier.

Thanks a lot Paul, that’s a good starting point.

Cannot promise much, but I would like to study the code and see if I can contribute.

1 Like