AttributeError: 'tuple' object has no attribute '__name__'

I am trying to simulate neutrons going into a block of lead, and the evaporation neutrons produced.

I am getting the error:

File ~/anaconda3/envs/openmc-env/lib/python3.12/site-packages/openmc/checkvalue.py:137 in check_iterable_type
f’“{expected_type.name}”, but item at {ind_str} is ’

AttributeError: ‘tuple’ object has no attribute ‘name

Any help is greatly appreciated!

Here is my code:

import openmc

#DEFINING MATERIALS

#lead material

lead = openmc.Material(11, “lead”)

lead.add_nuclide(‘Pb208’,1.0)

lead.set_density(‘g/cm3’, 11.35)

#create materials file

materials = openmc.Materials([lead])

print(lead)

#path to cross sections

materials.cross_sections = ‘/home/physicslab/anaconda3/openMC/endfb-vii.1-hdf5/cross_sections.xml’

#export materials file to xml

materials.export_to_xml()

#GEOMETRY

box = openmc.model.RectangularPrism(width=10, height=10, boundary_type=‘vacuum’)

z_planefirst = openmc.ZPlane(z0=5, boundary_type=‘vacuum’)

z_planesecond = openmc.ZPlane(z0=-5, boundary_type=‘vacuum’)

lead_region = -box & -z_planefirst & +z_planesecond

lead_region.bounding_box

cell = openmc.Cell(name=‘cell’)

cell.fill = lead

cell.region = lead_region

universe = openmc.Universe()

universe.add_cell(cell)

geometry = openmc.Geometry(universe)

geometry.export_to_xml()

#plot cell

universe.plot(width=(11, 11))

universe.plot(width=(11, 11), basis=‘xz’)

#STARTING SOURCE AND SETTINGS

source = openmc.IndependentSource()

source.space = openmc.stats.Point(xyz=(0,0,0))

source.angle = openmc.stats.Isotropic()

source.energy = openmc.stats.Discrete([1.0], [10000])

settings = openmc.Settings()

settings.particles=100

settings.batches = 10

settings.generations_per_batch=10

settings.run_mode = ‘fixed source’

settings.source=source

settings.export_to_xml()

#TALLIES

cell_filter = openmc.CellFilter(lead)

tally = openmc.Tally

tally.filters = [cell_filter]

tally.nuclides = [‘Pb208’]

tally.scores = [‘(n,2n)’, ‘(n,3n)’, ‘50’, ‘51’, ‘52’]

tallies = openmc.Tallies([tally])

tallies.export_to_xml()

#RUN

openmc.run()

Hi Adeline, welcome to the openmc community.
I think you forgot to call the name of your cell in your cell filter. Your cell name was “cell” while you use “lead” as a cell filter which is a material, not a cell. Also, you forgot to add () to your tally initialization. I also added a tally name parameter if you want to add a tally name to it.

cell_filter = openmc.CellFilter(cell)
tally = openmc.Tally(name='tally name')

here is the notebook for your case
n-vs-lead.ipynb (22.1 KB)