Hello,Why can’t I fill universe1 into cell4? (‘cell4.fill=u1’ in universe_bug.py) In universe_bug.py, I filled cell4 with the defined universe, named u1. But when I run openmc, I get an error message in bug.png photo.
I translated it according to the MCNP example editing card. In MCNP, the cell can fill the universe, but why is OpenMC not working? Or is there a mistake in my writing? Please help me, thank you.
universe_bug.py (2.07 KB)
corrected.py (1.99 KB)
Based on the error in bug.png,the problem is that the cells
parameter accepts an iterable of cells. It looks like you tried to make cell4
a tuple so that it was iterable by adding parentheses around it. However, to make a Tuple from one entry, Python requires you to add a comma after the entry. In other words, this should be written as (cell4,)
. The comma is necessary as thats the cleanest way to tell the Python interpreter that you didn’t just mean parentheses.
So in summary, root=openmc.Universe(cells=(cell4))
should instead be:
root=openmc.Universe(cells=(cell4,))
OR
root=openmc.Universe(cells=tuple(cell4))
OR
root=openmc.Universe(cells=[cell4])
…
Hope this helps